Skip to content

Commit

Permalink
Merge pull request #35 from 1c-syntax/fix/use
Browse files Browse the repository at this point in the history
Dash in use
  • Loading branch information
nixel2007 authored Jun 12, 2019
2 parents c7ce5a0 + dbdcb3a commit f81eb2e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/antlr/BSLLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,10 @@ PREPROC_STRING: '"' (~["\n\r])* '"';
PREPROC_STRINGTAIL: BAR (~["\n\r])* '"';
PREPROC_STRINGPART: BAR (~["\n\r])*;
PREPROC_USE_KEYWORD: RU_I RU_S RU_P RU_O RU_L RU_SOFT_SIGN RU_Z RU_O RU_V RU_A RU_T RU_SOFT_SIGN | U S E;
PREPROC_USE_KEYWORD
:
(RU_I RU_S RU_P RU_O RU_L RU_SOFT_SIGN RU_Z RU_O RU_V RU_A RU_T RU_SOFT_SIGN
| U S E) -> pushMode(USE_MODE);
PREPROC_REGION
:
Expand Down Expand Up @@ -600,3 +603,12 @@ REGION_WHITE_SPACE
;
REGION_IDENTIFIER : LETTER ( LETTER | DIGIT )* -> type(PREPROC_IDENTIFIER), popMode;

mode USE_MODE;
fragment USE_LETTER: [\p{Letter}] | '_' | '-';
USE_WHITE_SPACE
: [ \t\f]
-> channel(HIDDEN)
;
USE_STRING : '"' (~["\n\r])* '"' -> type(PREPROC_STRING), popMode;
USE_IDENTIFIER : USE_LETTER ( USE_LETTER | DIGIT )* -> type(PREPROC_IDENTIFIER), popMode;
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ void testCRCR() {
void testUse() {
assertMatch(BSLLexer.PREPROCESSOR_MODE, "Использовать lib", BSLLexer.PREPROC_USE_KEYWORD, BSLLexer.PREPROC_IDENTIFIER);
assertMatch(BSLLexer.PREPROCESSOR_MODE, "Использовать \"lib\"", BSLLexer.PREPROC_USE_KEYWORD, BSLLexer.PREPROC_STRING);
assertMatch(BSLLexer.PREPROCESSOR_MODE, "Использовать lib-name", BSLLexer.PREPROC_USE_KEYWORD, BSLLexer.PREPROC_IDENTIFIER);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ void testUse() {
setInput("Использовать \"./lib\"", BSLLexer.PREPROCESSOR_MODE);
assertMatches(parser.use());

setInput("Использовать lib-name", BSLLexer.PREPROCESSOR_MODE);
assertMatches(parser.use());

setInput("Использовать 1", BSLLexer.PREPROCESSOR_MODE);
assertNotMatches(parser.use());
}
Expand Down

0 comments on commit f81eb2e

Please sign in to comment.