Skip to content

Commit b7308c5

Browse files
authored
Merge pull request #387 from 1c-syntax/develop
Sync
2 parents a30f816 + cd3e454 commit b7308c5

5 files changed

Lines changed: 22 additions & 8 deletions

File tree

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ plugins {
99
antlr
1010
id("cloud.rio.license") version "0.18.0"
1111
id("me.qoomon.git-versioning") version "6.4.4"
12-
id("io.freefair.javadoc-links") version "9.2.0"
13-
id("io.freefair.javadoc-utf-8") version "9.2.0"
14-
id("io.freefair.lombok") version "9.2.0"
12+
id("io.freefair.javadoc-links") version "9.5.0"
13+
id("io.freefair.javadoc-utf-8") version "9.5.0"
14+
id("io.freefair.lombok") version "9.5.0"
1515
// id("io.freefair.maven-central.validate-poms") version "9.2.0"
1616
id("com.github.ben-manes.versions") version "0.54.0"
1717
id("ru.vyarus.pom") version "3.0.0"
@@ -58,7 +58,7 @@ dependencies {
5858
exclude("org.antlr:ST4")
5959
}
6060

61-
testImplementation(platform("org.junit:junit-bom:6.0.3"))
61+
testImplementation(platform("org.junit:junit-bom:6.1.0"))
6262
testImplementation("org.junit.jupiter:junit-jupiter-api")
6363
testImplementation("org.junit.jupiter:junit-jupiter-params")
6464
testImplementation("org.assertj:assertj-core:3.27.7")

src/main/antlr/BSLLexer.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ PREPROC_RPAREN: RPAREN;
196196
197197
PREPROC_STRING: '"' (~["\n\r])* '"';
198198
PREPROC_NATIVE: 'NATIVE';
199+
PREPROC_STACK: 'STACK';
199200
PREPROC_USE_KEYWORD: ('ИСПОЛЬЗОВАТЬ' | 'USE') -> pushMode(USE_MODE);
200201
PREPROC_REGION: ('ОБЛАСТЬ' | 'REGION') -> pushMode(REGION_MODE);
201202
PREPROC_END_REGION: 'КОНЕЦОБЛАСТИ' | 'ENDREGION';

src/main/antlr/BSLParser.g4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ file: shebang? moduleAnnotations? preprocessor* moduleVars? preprocessor* (fileC
3131

3232
// moduleAnnotations
3333
preproc_native : HASH PREPROC_NATIVE;
34+
preproc_stack : HASH PREPROC_STACK;
3435
usedLib : (PREPROC_STRING | PREPROC_IDENTIFIER);
3536
use : HASH PREPROC_USE_KEYWORD usedLib;
3637

3738
moduleAnnotations
3839
:
39-
(preproc_native use*)
40-
| (use+ preproc_native? use*)
40+
((preproc_native | preproc_stack) use*)
41+
| (use+ (preproc_native | preproc_stack)? use*)
4142
;
4243

4344
// preprocessor

src/test/java/com/github/_1c_syntax/bsl/parser/BSLLexerTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ void testUse() {
9797
.containsAll(BSLLexer.WHITE_SPACE, BSLLexer.LINE_COMMENT);
9898
}
9999

100+
@Test
101+
void testPreprocNativeAndStack() {
102+
testLexer.assertThat(BSLLexer.PREPROCESSOR_MODE, "native").containsAll(BSLLexer.PREPROC_NATIVE);
103+
testLexer.assertThat(BSLLexer.PREPROCESSOR_MODE, "stack").containsAll(BSLLexer.PREPROC_STACK);
104+
}
105+
100106
@Test
101107
void testPreproc_LineComment() {
102108
testLexer.assertThat("#КонецОбласти // Концевой комментарий")
@@ -566,7 +572,8 @@ void checkAsyncModeMapping() {
566572
|| BSLLexer.UNKNOWN == i
567573
|| BSLLexer.DOT_TRAILING == i
568574
|| BSLLexer.Async_DOT == i // в runtime всегда переписывается на DOT или DOT_TRAILING
569-
|| BSLLexer.PREPROC_NATIVE == i) {
575+
|| BSLLexer.PREPROC_NATIVE == i
576+
|| BSLLexer.PREPROC_STACK == i) {
570577
Assertions.assertThat(tokenTypes).doesNotContain(i);
571578
} else {
572579
Assertions.assertThat(tokenTypes).contains(i);

src/test/java/com/github/_1c_syntax/bsl/parser/BSLParserMatchesTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ void testNative() {
7676
testParser.assertThat("#native").matches(testParser.parser().preproc_native());
7777
}
7878

79+
@Test
80+
void testStack() {
81+
testParser.assertThat("#stack").matches(testParser.parser().preproc_stack());
82+
}
83+
7984
@Test
8085
void testNativeFile() {
8186
testParser.assertThat("""
@@ -89,7 +94,7 @@ void testNativeFile() {
8994
@ParameterizedTest
9095
@ValueSource(strings =
9196
{
92-
"#Использовать А", "#Использовать \".\"", "#native"
97+
"#Использовать А", "#Использовать \".\"", "#native", "#stack"
9398
}
9499
)
95100
void testModuleAnnotations(String inputString) {

0 commit comments

Comments
 (0)