Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ждать в одном стейтменте #151

Merged
merged 5 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/main/antlr/BSLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ forEachStatement : FOR_KEYWORD EACH_KEYWORD IDENTIFIER IN_KEYWORD expression DO
tryStatement : TRY_KEYWORD tryCodeBlock EXCEPT_KEYWORD exceptCodeBlock ENDTRY_KEYWORD;
returnStatement : RETURN_KEYWORD expression?;
executeStatement : EXECUTE_KEYWORD (doCall | callParamList);
callStatement : WAIT_KEYWORD? (((IDENTIFIER | globalMethodCall) modifier* accessCall) | globalMethodCall);
waitStatement : WAIT_KEYWORD IDENTIFIER;
callStatement : ((IDENTIFIER | globalMethodCall) modifier* accessCall) | globalMethodCall;
waitStatement : waitExpression;

labelName : IDENTIFIER;
label : TILDA labelName COLON;
Expand All @@ -203,6 +203,7 @@ removeHandlerStatement
;

ternaryOperator : QUESTION LPAREN expression COMMA expression COMMA expression RPAREN;
waitExpression : WAIT_KEYWORD expression;

// main
fileCodeBlockBeforeSub
Expand Down Expand Up @@ -230,7 +231,7 @@ statement
)
| SEMICOLON
;
assignment : lValue preprocessor* ASSIGN (preprocessor* expression)?;
assignment : lValue preprocessor* ASSIGN (preprocessor* expression);
callParamList : callParam (COMMA callParam)*;
callParam : expression?;
expression : member (preprocessor* operation preprocessor* member preprocessor*)*;
Expand All @@ -244,7 +245,8 @@ member
constValue
| complexIdentifier
| (( LPAREN expression RPAREN ) modifier*)
| (WAIT_KEYWORD (IDENTIFIER | globalMethodCall))
| (IDENTIFIER | globalMethodCall)
| waitExpression
);
newExpression : NEW_KEYWORD typeName doCall? | NEW_KEYWORD doCall;
typeName : IDENTIFIER;
Expand Down
24 changes: 22 additions & 2 deletions src/test/java/com/github/_1c_syntax/bsl/parser/BSLParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,6 @@ void testExpression() {

setInput("Выполнить");
assertNotMatches(parser.expression());
setInput("А = Выполнить");
assertNotMatches(parser.expression());

}

Expand Down Expand Up @@ -1145,6 +1143,7 @@ void TestWait() {

setInput("Асинх Процедура Test()\n" +
"Ждать КопироватьФайлыАсинх(ИсходныйКаталог, ЦелевойКаталог); //1 \n" +
"КопироватьФайлы(ИсходныйКаталог, ЦелевойКаталог); //1 \n" +
"Файлы = Ждать НайтиФайлыАсинх(ИсхКаталог, \"*\", Ложь); //2\n" +
"Сч = Ждать КопироватьФайлыАсинх(ИсходныйКаталог, ЦелевойКаталог); //1\n" +
"Об = КопироватьФайлАсинх(ИсхФайл, ЦелФайл); \n" +
Expand Down Expand Up @@ -1172,6 +1171,27 @@ void TestWait() {
statements.forEach(this::assertMatches);
assertThat(statements.stream().filter(statementContext -> statementContext.callStatement() != null))
.hasSize(1);
assertThat(statements.stream().filter(statementContext -> statementContext.waitStatement() != null))
.hasSize(2);

}

@Test
void TestAnotherWait() {

setInput("Асинх Функция Test()\n" +
"Ждать 1; \n" +
"Ждать (Ждать 1); \n" +
"Существует = Ждать ФайлНаДиске.СуществуетАсинх();\n" +
"Возврат Ждать (Ждать 1) + Ждать (Ждать 2); \n" +
"КонецФункции");
var file = parser.file();
assertMatches(file);
var codeBlockContext = file.subs().sub(0).function().subCodeBlock().codeBlock();
assertMatches(codeBlockContext.statement(0).waitStatement());
assertMatches(codeBlockContext.statement(1).waitStatement());
assertMatches(codeBlockContext.statement(2).assignment());
assertMatches(codeBlockContext.statement(3).compoundStatement().returnStatement().expression().member(0).waitExpression());

}

Expand Down