Skip to content

Commit

Permalink
Merge pull request #151 from 1c-syntax/fix/wait
Browse files Browse the repository at this point in the history
  • Loading branch information
nixel2007 authored Nov 23, 2021
2 parents 4e4c0a7 + 98c55ad commit b0858f1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/main/antlr/BSLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,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 @@ -204,6 +204,7 @@ removeHandlerStatement
;

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

// main
fileCodeBlockBeforeSub
Expand Down Expand Up @@ -231,7 +232,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 @@ -245,7 +246,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 @@ -667,8 +667,6 @@ void testExpression() {

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

}

Expand Down Expand Up @@ -1148,6 +1146,7 @@ void TestWait() {

setInput("Асинх Процедура Test()\n" +
"Ждать КопироватьФайлыАсинх(ИсходныйКаталог, ЦелевойКаталог); //1 \n" +
"КопироватьФайлы(ИсходныйКаталог, ЦелевойКаталог); //1 \n" +
"Файлы = Ждать НайтиФайлыАсинх(ИсхКаталог, \"*\", Ложь); //2\n" +
"Сч = Ждать КопироватьФайлыАсинх(ИсходныйКаталог, ЦелевойКаталог); //1\n" +
"Об = КопироватьФайлАсинх(ИсхФайл, ЦелФайл); \n" +
Expand Down Expand Up @@ -1175,6 +1174,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

0 comments on commit b0858f1

Please sign in to comment.