-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for unicode properties in lexer charsets (#138)
- Loading branch information
1 parent
be1fd0f
commit 869828c
Showing
6 changed files
with
169 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2023 Renata Hodovan, Akos Kiss. | ||
* | ||
* Licensed under the BSD 3-Clause License | ||
* <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>. | ||
* This file may not be copied, modified, or distributed except | ||
* according to those terms. | ||
*/ | ||
|
||
lexer grammar UnicodePropertiesLexer; | ||
|
||
UPROP : [\p{Lu}] ; | ||
GENERAL : [\p{General_Category=Other_Letter}] ; | ||
ENUM_BLOCK : [\p{Blk=Latin_1_Sup}] [\p{Block=Latin_1_Supplement}] [\p{InLatin_1_Supplement}] [\p{InYijing_Hexagram_Symbols}] [\p{InAncient_Greek_Numbers}] ; | ||
ENUM_SCRIPT : [\p{Script=Latin}] [\p{Script=Cyrillic}] -> mode(InvertedMode); | ||
|
||
mode InvertedMode; | ||
INVERTED : [\P{Latin}] -> mode(ExtrasMode); | ||
|
||
mode ExtrasMode; | ||
EXTRAS : [\p{EmojiPresentation=EmojiDefault}] [\p{EmojiPresentation=TextDefault}] [\p{EmojiPresentation=Text}] [\p{EmojiRK}] [\p{Extended_Pictographic}] -> mode(InvertedExtrasMode) ; | ||
|
||
mode InvertedExtrasMode; | ||
INVERTED_EXTRAS : [\P{Extended_Pictographic}] [\P{EmojiRK}] -> mode(InvertedExtrasMode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2023 Renata Hodovan, Akos Kiss. | ||
* | ||
* Licensed under the BSD 3-Clause License | ||
* <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>. | ||
* This file may not be copied, modified, or distributed except | ||
* according to those terms. | ||
*/ | ||
|
||
/* | ||
* Tests handling of unicode property escapes. | ||
*/ | ||
|
||
// TEST-PROCESS: {grammar}Parser.g4 {grammar}Lexer.g4 -o {tmpdir} | ||
// TEST-GENERATE: {grammar}Generator.{grammar}Generator -r start -j 1 -o {tmpdir}/{grammar}%d.txt | ||
// TEST-ANTLR: {grammar}Parser.g4 {grammar}Lexer.g4 -o {tmpdir} | ||
// TEST-REPARSE: -p {grammar}Parser -l {grammar}Lexer -r start {tmpdir}/{grammar}%d.txt | ||
|
||
parser grammar UnicodePropertiesParser; | ||
|
||
start : UPROP GENERAL ENUM_BLOCK ENUM_SCRIPT INVERTED EXTRAS INVERTED_EXTRAS; |