File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
UnrealAngelscriptParser/Grammar Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,18 @@ public void Namespace(string @namespace)
3131 new UnrealAngelscriptSimpleVisitor ( script ) . VisitChildren ( parser . script ( ) ) ;
3232 }
3333
34+ [ TestMethod ]
35+ public void NamedArgumentsFunctionCall ( )
36+ {
37+ var script = "void Func(bool Arg1 = false, int Arg2 = 0) {}\r \n void main() { Func(Arg2: 1, Arg1: true); }\r \n " ;
38+ var lexer = new UnrealAngelscriptLexer ( new AntlrInputStream ( script ) ) ;
39+ var tokenStream = new CommonTokenStream ( lexer ) ;
40+ var parser = new UnrealAngelscriptParser ( tokenStream ) ;
41+ parser . RemoveErrorListeners ( ) ;
42+ parser . AddErrorListener ( new ThrowingErrorListener ( ) ) ;
43+ new UnrealAngelscriptSimpleVisitor ( script ) . VisitChildren ( parser . script ( ) ) ;
44+ }
45+
3446 [ TestMethod ]
3547 [ DataRow ( "" ) ]
3648 [ DataRow ( "final" ) ]
@@ -40,7 +52,7 @@ public void Namespace(string @namespace)
4052 [ DataRow ( "accept_temporary_this" ) ] // UnrealAngelscript
4153 public void FunctionModifier ( string modifier )
4254 {
43- var script = $ "protected bool CanActivate_Client () { modifier } \r \n {{\r \n return true;\r \n }}";
55+ var script = $ "protected bool Func () { modifier } \r \n {{\r \n return true;\r \n }}";
4456 var lexer = new UnrealAngelscriptLexer ( new AntlrInputStream ( script ) ) ;
4557 var tokenStream = new CommonTokenStream ( lexer ) ;
4658 var parser = new UnrealAngelscriptParser ( tokenStream ) ;
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ qualifiedId: nestedNameSpecifier unqualifiedId;
8989nestedNameSpecifier :
9090 (theTypeName | namespaceName | decltypeSpecifier)? Doublecolon
9191 | nestedNameSpecifier Identifier Doublecolon;
92+
9293lambdaExpression :
9394 lambdaIntroducer lambdaDeclarator? compoundStatement;
9495
@@ -217,6 +218,7 @@ assignmentOperator:
217218expression : assignmentExpression (Comma assignmentExpression)*;
218219
219220constantExpression : conditionalExpression;
221+
220222/* Statements*/
221223
222224statement :
@@ -468,7 +470,11 @@ braceOrEqualInitializer:
468470 Assign initializerClause
469471 | bracedInitList;
470472
471- initializerClause : assignmentExpression | bracedInitList;
473+ // Angelscript supports C#-like named arguments.
474+ // https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/named-and-optional-arguments
475+ initializerClause :
476+ (Identifier Colon)? assignmentExpression
477+ | bracedInitList;
472478
473479initializerList :
474480 initializerClause (Comma initializerClause)* Comma?; // I *really* don't like that trailing commas are a thing in AS...
You can’t perform that action at this time.
0 commit comments