Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Text;
- using ICSharpCode.NRefactory.Parser;
- using ICSharpCode.NRefactory.Ast;
- using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute;
- using Types = ICSharpCode.NRefactory.Ast.ClassType;
- COMPILER Andromeda
- /*------------------------------------------------------------------------*
- *----- LEXER TOKEN LIST ------------------------------------------------*
- *------------------------------------------------------------------------*/
- /* START AUTOGENERATED TOKENS SECTION */
- TOKENS
- /* Terminal classes. */
- /* EOF is 0 */
- ident
- Literal
- /* Special characters. */
- "="
- "+"
- "-"
- "*"
- "/"
- "%"
- ":"
- "::"
- ";"
- "?"
- "??"
- ","
- "."
- "{"
- "}"
- "["
- "]"
- "("
- ")"
- ">"
- "<"
- "!"
- "&&"
- "||"
- "~"
- "&"
- "|"
- "^"
- "++"
- "--"
- "=="
- "!="
- ">="
- "<="
- "<<"
- "+="
- "-="
- "*="
- "/="
- "%="
- "&="
- "|="
- "^="
- "<<="
- "->"
- /* Keywords. */
- "abilcmd"
- "abstract"
- "actor"
- "actorscope"
- "aifilter"
- "bank"
- "bool"
- "break"
- "byte"
- "camerainfo"
- "case"
- "catch"
- "class"
- "color"
- "const"
- "continue"
- "default"
- "do"
- "doodad"
- "else"
- "enrich"
- "extends"
- "false"
- "final"
- "finally"
- "fixed"
- "for"
- "if"
- "implements"
- "import"
- "include"
- "inline"
- "instance"
- "int"
- "interface"
- "internal"
- "is"
- "iskey"
- "keyof"
- "marker"
- "namespace"
- "native"
- "new"
- "null"
- "order"
- "out"
- "override"
- "package"
- "playergroup"
- "point"
- "private"
- "protected"
- "public"
- "readonly"
- "revealer"
- "ref"
- "return"
- "setinstancelimit"
- "sound"
- "soundlink"
- "stackalloc"
- "static"
- "string"
- "struct"
- "super"
- "switch"
- "text"
- "this"
- "throws"
- "throw"
- "timer"
- "transient"
- "transmissionsource"
- "trigger"
- "true"
- "try"
- "typedef"
- "typeof"
- "unit"
- "unitfilter"
- "unitgroup"
- "unitref"
- "uses"
- "virtual"
- "volatile"
- "void"
- "wave"
- "waveinfo"
- "wavetarget"
- "while"
- "get"
- "set"
- /* END AUTOGENERATED TOKENS SECTION */
- /*------------------------------------------------------------------------*
- *----- PARSER -----------------------------------------------------------*
- *------------------------------------------------------------------------*/
- PRODUCTIONS
- Andromeda
- (. lexer.NextToken(); /* get the first token */ .)
- =
- { NamespaceMemberDecl }
- EOF
- .
- NamespaceMemberDecl
- (.
- ModifierList m = new ModifierList();
- string qualident;
- .)
- = /*--- namespace declaration: */
- "package" (. Location startPos = t.Location; .)
- Qualident<out qualident> (. INode node = new NamespaceDeclaration(qualident);
- node.StartLocation = startPos;
- compilationUnit.AddChild(node);
- compilationUnit.BlockStart(node);
- .)
- ";"
- { NamespaceMemberDecl }
- [ ";" ] (. node.EndLocation = t.EndLocation;
- compilationUnit.BlockEnd();
- .)
- /*--- type declaration: */
- |
- { TypeModifier<m> }
- TypeDecl<m>
- .
- TypeDecl<ModifierList m>
- (.
- List<TypeReference> names;
- List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
- List<TemplateDefinition> templates;
- .)
- = /*--- class declaration: */ (. m.Check(Modifiers.Classes); .)
- "class" (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, new List<AttributeSection>());
- templates = newType.Templates;
- compilationUnit.AddChild(newType);
- compilationUnit.BlockStart(newType);
- newType.StartLocation = m.GetDeclarationLocation(t.Location);
- newType.Type = Types.Class;
- .)
- Identifier (. newType.Name = t.val; .)
- [ ClassBase<out names> (. newType.BaseTypes = names; .) ]
- (. newType.BodyStartLocation = t.EndLocation; .)
- ClassBody
- [ ";" ] (. newType.EndLocation = t.Location;
- compilationUnit.BlockEnd();
- .)
- | /*--- enrichment declaration: */
- "enrich" (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, new List<AttributeSection>());
- templates = newType.Templates;
- compilationUnit.AddChild(newType);
- compilationUnit.BlockStart(newType);
- newType.StartLocation = m.GetDeclarationLocation(t.Location);
- newType.Type = Types.Enrichment;
- .)
- Identifier (. newType.Name = t.val; .)
- [ ClassBae<out names> (. newType.BsaeTypes = names; .) ]
- (. newType.BodyStartLocation = t.EndLocation; .)
- ClassBody
- [ ";" ] (. newType.EndLocation = t.Location;
- compilationUnit.BlockEnd();
- .)
- | /*--- interface declaration: */
- "interface" (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, new List<AttributeSection>());
- templates = newType.Templates;
- compilationUnit.AddChild(newType);
- compilationUnit.BlockStart(newType);
- newType.StartLocation = m.GetDeclarationLocation(t.Location);
- newType.Type = Types.Interface;
- .)
- Identifier (. newType.Name = t.val; .)
- [ ClassBase<out names> (. newType.BaseTypes = names; .) ]
- (. newType.BodyStartLocation = t.EndLocation; .)
- ClassBody
- [ ";" ] (. newType.EndLocation = t.Location;
- compilationUnit.BlockEnd();
- .)
- .
- Qualident<out string qualident>
- =
- ident (. string str = ""; qualidentBuilder.Length = 0; qualidentBuilder.Append(t.val); .)
- { IF (DotAndIdent()) "." IdentifierTimes<out str> (. qualidentBuilder.Append('.');
- qualidentBuilder.Append(str);
- .)
- } (. qualident = qualidentBuilder.ToString(); .)
- .
- IdentifierTimes<out string str>
- (. str = ""; .)
- =
- ident (. str = t.val; .) | "*" (.str = "*"; .)
- .
- ClassBase<out List<TypeReference> names>
- (.
- TypeReference typeRef;
- names = new List<TypeReference>();
- TypeReferenceKind kind = TypeReferenceKind.Extends;
- .)
- =
- {"extends" ClassType<out typeRef> (. if (typeRef != null) { kind = TypeReferenceKind.Extends; typeRef.Kind = kind; names.Add(typeRef); } .) }
- {"implements" ClassType<out typeRef> (. if (typeRef != null) { kind = TypeReferenceKind.Implements; typeRef.Kind = kind; names.Add(typeRef); } .) }
- { "," TypeName<out typeRef> (. if (typeRef != null) { typeRef.Kind = kind; names.Add(typeRef); } .) }
- .
- ClassBody
- =
- "{"
- { (.ModifierList m = new ModifierList(); .)
- ClassMemberDecl<m>
- }
- "}"
- .
- Type<out TypeReference type>
- =
- TypeWithRestriction<out type>
- .
- TypeWithRestriction<out TypeReference type>
- (.
- string name;
- type = null;
- .)
- =
- ( ClassType<out type>
- | SimpleType<out name> (. type = new TypeReference(name); .)
- | "void" (. type = new TypeReference("void"); .)
- ) (. List<int> r = new List<int>(); .)
- { IF (IsPointerOrDims()) (. int i = 0; .)
- ( "[" { "," (. ++i; .) } "]" (. r.Add(i); .) )
- }
- (. if (type != null) {
- type.RankSpecifier = r.ToArray();
- }
- .)
- .
- NonArrayType<out TypeReference type>
- (.
- string name;
- type = null;
- .)
- =
- ( ClassType<out type>
- | SimpleType<out name> (. type = new TypeReference(name); .)
- | "void" (. type = new TypeReference("void"); .)
- )
- .
- SimpleType<out string name>
- (. name = String.Empty; .)
- =
- IntegralType<out name>
- | "abilcmd" (. name = "abilcmd"; .)
- | "actor" (. name = "actor"; .)
- | "actorscope" (. name = "actorscope"; .)
- | "aifilter" (. name = "aifilter"; .)
- | "bank" (. name = "bank"; .)
- | "bool" (. name = "bool"; .)
- | "byte" (. name = "byte"; .)
- | "camerainfo" (. name = "camerainfo"; .)
- | "color" (. name = "color"; .)
- | "doodad" (. name = "doodad"; .)
- | "fixed" (. name = "fixed"; .)
- | "int" (. name = "int"; .)
- | "marker" (. name = "marker"; .)
- | "order" (. name = "order"; .)
- | "playergroup" (. name = "playergroup"; .)
- | "point" (. name = "point"; .)
- | "revealer" (. name = "revealer"; .)
- | "sound" (. name = "sound"; .)
- | "soundlink" (. name = "soundlink"; .)
- | "string" (. name = "string"; .)
- | "text" (. name = "text"; .)
- | "timer" (. name = "timer"; .)
- | "transmissionsource" (. name = "transmissionsource"; .)
- | "trigger" (. name = "trigger"; .)
- | "unit" (. name = "unit"; .)
- | "unitfilter" (. name = "unitfilter"; .)
- | "unitgroup" (. name = "unitgroup"; .)
- | "unitref" (. name = "unitref"; .)
- | "void" (. name = "void"; .)
- | "wave" (. name = "wave"; .)
- | "waveinfo" (. name = "waveinfo"; .)
- | "wavetarget" (. name = "wavetarget"; .)
- .
- FormalParameterList<List<ParameterDeclarationExpression> parameter>
- (.
- ParameterDeclarationExpression p;
- .)
- =
- (
- FixedParameter<out p> (.
- p.Attributes = new List<AttributeSection>();
- parameter.Add(p);
- .)
- {
- ","
- (
- FixedParameter<out p> (. p.Attributes = new List<AttributeSection>(); parameter.Add(p); .)
- )
- }
- )
- .
- FixedParameter<out ParameterDeclarationExpression p>
- (.
- TypeReference type;
- ParameterModifiers mod = ParameterModifiers.In;
- Location start = t.Location;
- bool final = false;
- .)
- =
- [ "final" (. final = true; .) ]
- Type<out type> ident (. if (final) { mod = mod | ParameterModifiers.Final; } p = new ParameterDeclarationExpression(type, t.val, mod); p.StartLocation = start; p.EndLocation = t.Location; .)
- ArrayRank<type>
- .
- TypeModifier<ModifierList m>
- =
- "new" (. m.Add(Modifiers.New, t.Location); .)
- | "public" (. m.Add(Modifiers.Public, t.Location); .)
- | "protected" (. m.Add(Modifiers.Protected, t.Location); .)
- | "private" (. m.Add(Modifiers.Private, t.Location); .)
- | "abstract" (. m.Add(Modifiers.Abstract, t.Location); .)
- | "static" (. m.Add(Modifiers.Static, t.Location); .)
- | "final" (. m.Add(Modifiers.Final, t.Location); .)
- .
- ClassType<out TypeReference typeRef>
- (. TypeReference r; typeRef = null; .)
- =
- TypeName<out r> (. typeRef = r; .)
- .
- IntegralType<out string name> (. name = ""; .)
- =
- "abilcmd" (. name = "abilcmd"; .)
- | "actor" (. name = "actor"; .)
- | "actorscope" (. name = "actorscope"; .)
- | "aifilter" (. name = "aifilter"; .)
- | "bank" (. name = "bank"; .)
- | "bool" (. name = "bool"; .)
- | "byte" (. name = "byte"; .)
- | "camerainfo" (. name = "camerainfo"; .)
- | "color" (. name = "color"; .)
- | "doodad" (. name = "doodad"; .)
- | "fixed" (. name = "fixed"; .)
- | "int" (. name = "int"; .)
- | "marker" (. name = "marker"; .)
- | "order" (. name = "order"; .)
- | "playergroup" (. name = "playergroup"; .)
- | "point" (. name = "point"; .)
- | "revealer" (. name = "revealer"; .)
- | "sound" (. name = "sound"; .)
- | "soundlink" (. name = "soundlink"; .)
- | "string" (. name = "string"; .)
- | "text" (. name = "text"; .)
- | "timer" (. name = "timer"; .)
- | "transmissionsource" (. name = "transmissionsource"; .)
- | "trigger" (. name = "trigger"; .)
- | "unit" (. name = "unit"; .)
- | "unitfilter" (. name = "unitfilter"; .)
- | "unitgroup" (. name = "unitgroup"; .)
- | "unitref" (. name = "unitref"; .)
- | "void" (. name = "void"; .)
- | "wave" (. name = "wave"; .)
- | "waveinfo" (. name = "waveinfo"; .)
- | "wavetarget" (. name = "wavetarget"; .)
- .
- MemberModifiers<ModifierList m>
- =
- {
- "abstract" (. m.Add(Modifiers.Abstract, t.Location); .)
- | "new" (. m.Add(Modifiers.New, t.Location); .)
- | "private" (. m.Add(Modifiers.Private, t.Location); .)
- | "protected" (. m.Add(Modifiers.Protected, t.Location); .)
- | "public" (. m.Add(Modifiers.Public, t.Location); .)
- | "final" (. m.Add(Modifiers.Final, t.Location); .)
- | "static" (. m.Add(Modifiers.Static, t.Location); .)
- | "volatile" (. m.Add(Modifiers.Volatile, t.Location); .)
- | "transient" (. m.Add(Modifiers.Transient, t.Location); .)
- | "native" (. m.Add(Modifiers.Native, t.Location); .)
- }
- .
- StructMemberDecl<ModifierList m>
- (.
- string qualident = null;
- TypeReference type;
- Expression expr;
- List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
- Statement stmt = null;
- List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>();
- List<TemplateDefinition> templates = new List<TemplateDefinition>();
- TypeReference explicitInterface = null;
- .)
- =
- /*--- constant declaration: */ (. m.Check(Modifiers.Constants); .)
- "const" (.Location startPos = t.Location; .)
- Type<out type> ident (. FieldDeclaration fd = new FieldDeclaration(new List<AttributeSection>(), type, m.Modifier | Modifiers.Const);
- fd.StartLocation = m.GetDeclarationLocation(startPos);
- VariableDeclaration f = new VariableDeclaration(t.val);
- fd.Fields.Add(f);
- .)
- "=" Expr<out expr> (. f.Initializer = expr; .)
- { "," ident (. f = new VariableDeclaration(t.val);
- fd.Fields.Add(f);
- .)
- "=" Expr<out expr> (. f.Initializer = expr; .)
- } ";" (. fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); .)
- | /*--- void method (procedure) declaration: */
- IF (NotVoidPointer()) (. m.Check(Modifiers.PropertysEventsMethods); .)
- "void" (. Location startPos = t.Location; .)
- ( IF (IsExplicitInterfaceImplementation())
- TypeName<out explicitInterface>
- (.if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) {
- qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
- } .)
- | Identifier (. qualident = t.val; .)
- )
- "("
- [ FormalParameterList<p> ] ")"
- (. MethodDeclaration methodDeclaration = new MethodDeclaration(qualident,
- m.Modifier,
- new TypeReference("void"),
- p,
- new List<AttributeSection>());
- methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
- methodDeclaration.EndLocation = t.EndLocation;
- methodDeclaration.Templates = templates;
- if (explicitInterface != null)
- methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident));
- compilationUnit.AddChild(methodDeclaration);
- compilationUnit.BlockStart(methodDeclaration);
- .)
- [ Throws<methodDeclaration.Throws> ]
- ( Block<out stmt> | ";" ) (. compilationUnit.BlockEnd();
- methodDeclaration.Body = (BlockStatement)stmt;
- .) [";"]
- | /*--- constructor or static contructor declaration: */
- IF (IdentAndLPar()) (. m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); .)
- Identifier (. string name = t.val; Location startPos = t.Location; .) "(" [ (. m.Check(Modifiers.Constructors); .)
- FormalParameterList<p>
- ]
- ")" (. m.Check(Modifiers.Constructors); .)
- (.
- ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, null, new List<AttributeSection>());
- cd.StartLocation = startPos;
- cd.EndLocation = t.EndLocation;
- .)
- [ Throws<cd.Throws> ]
- ( "{" ConstructorBlock<out stmt,cd> | ";" ) "}"
- (.
- cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd);
- .)
- [";"]
- |
- "{" (. ConstructorDeclaration cd = new ConstructorDeclaration("InitializerBlock", Modifiers.Public, null, null, null); .)
- ( ConstructorBlock<out stmt,cd> | ";" ) (. cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); .)
- "}"
- | /*--- inner type declaration: */
- TypeDecl<m>
- | Type<out type> (. Location startPos = t.Location; .)
- (
- /*--- field declaration: */
- IF (IsVarDecl())
- (. m.Check(Modifiers.Fields);
- FieldDeclaration fd = new FieldDeclaration(new List<AttributeSection>(), type, m.Modifier);
- fd.StartLocation = m.GetDeclarationLocation(startPos);
- .)
- ( IF (m.Contains(Modifiers.Fixed))
- VariableDeclarator<variableDeclarators,type>
- "["
- Expr<out expr> (. if (variableDeclarators.Count > 0)
- variableDeclarators[variableDeclarators.Count-1].FixedArrayInitialization = expr; .)
- "]"
- { ","
- VariableDeclarator<variableDeclarators,type>
- "["
- Expr<out expr> (. if (variableDeclarators.Count > 0)
- variableDeclarators[variableDeclarators.Count-1].FixedArrayInitialization = expr; .)
- "]"
- }
- | /* non-fixed field */
- VariableDeclarator<variableDeclarators,type>
- { "," VariableDeclarator<variableDeclarators,type> }
- )
- ";" (. fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); .)
- [";"]
- | IF (IsIdentifierToken(la))
- ( IF (IsExplicitInterfaceImplementation())
- TypeName<out explicitInterface>
- (.if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) {
- qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
- } .)
- | Identifier (. qualident = t.val; .)
- )
- (. Location qualIdentEndLocation = t.EndLocation; .)
- (
- /*--- "not void" method (function) declaration: */
- ( (. m.Check(Modifiers.PropertysEventsMethods); .)
- "(" [ FormalParameterList<p> ] ")" (.
- MethodDeclaration methodDeclaration = new MethodDeclaration(qualident,
- m.Modifier,
- type,
- p,
- new List<AttributeSection>());
- if (explicitInterface != null)
- methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident));
- methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
- methodDeclaration.EndLocation = t.EndLocation;
- methodDeclaration.Templates = templates;
- compilationUnit.AddChild(methodDeclaration);
- .)
- [ Throws<methodDeclaration.Throws> ]
- ( Block<out stmt> | ";" ) (. methodDeclaration.Body = (BlockStatement)stmt; .)
- [";"]
- )
- )
- )
- .
- Throws<List<TypeReference> types >
- (. TypeReference throwsTypeRef; .)
- =
- "throws" TypeName<out throwsTypeRef> (. types.Add(throwsTypeRef); .)
- { "," TypeName<out throwsTypeRef> (. types.Add(throwsTypeRef); .) }
- .
- ClassMemberDecl<ModifierList m>
- (. Statement stmt = null; .)
- =
- IF (StaticConstructor())
- "static" (. ConstructorDeclaration cd = new ConstructorDeclaration("static", Modifiers.Static, null, null, null); .)
- ( Block<out stmt> | ";" ) (. cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); .)
- | MemberModifiers<m>
- StructMemberDecl<m>
- | /*--- destructor declaration: */ (. m.Check(Modifiers.Destructors); Location startPos = t.Location; .)
- "~" Identifier (. DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, null);
- d.Modifier = m.Modifier;
- d.StartLocation = m.GetDeclarationLocation(startPos);
- .)
- "(" ")" (. d.EndLocation = t.EndLocation; .) ( Block<out stmt> | ";" ) (.
- d.Body = (BlockStatement)stmt;
- compilationUnit.AddChild(d);
- .)
- .
- VariableDeclarator<List<VariableDeclaration> fieldDeclaration,TypeReference type>
- (. Expression expr = null; .)
- =
- Identifier (. VariableDeclaration f = new VariableDeclaration(t.val); .)
- ArrayRank<type>
- [ "=" VariableInitializer<out expr> (. f.Initializer = expr; .) ] (. fieldDeclaration.Add(f); .)
- .
- Block<out Statement stmt> /* not BlockStatement because of EmbeddedStatement */
- =
- "{" (. BlockStatement blockStmt = new BlockStatement();
- blockStmt.StartLocation = t.Location;
- compilationUnit.BlockStart(blockStmt);
- if (!ParseMethodBodies) lexer.SkipCurrentBlock(0);
- .)
- { AndromedaStatement }
- "}" (.
- stmt = blockStmt;
- blockStmt.EndLocation = t.EndLocation;
- compilationUnit.BlockEnd();
- .)
- [";"]
- .
- ConstructorBlock<out Statement stmt,ConstructorDeclaration cd>
- =
- (. BlockStatement blockStmt = new BlockStatement();
- blockStmt.StartLocation = t.EndLocation;
- compilationUnit.BlockStart(blockStmt);
- if (!ParseMethodBodies) lexer.SkipCurrentBlock(0);
- .)
- [IF (ConstructorInitializer()) ConstructorInitializer<cd>]
- { AndromedaStatement }
- (.
- stmt = blockStmt;
- blockStmt.EndLocation = t.EndLocation;
- compilationUnit.BlockEnd();
- .)
- .
- ConstructorInitializer<ConstructorDeclaration cd>
- (. Expression expr; cd.ConstructorInitializer = new ConstructorInitializer(); ConstructorInitializer ci = cd.ConstructorInitializer; .)
- =
- ("super" (. ci.ConstructorInitializerType = ConstructorInitializerType.Base; .)
- | "this" (. ci.ConstructorInitializerType = ConstructorInitializerType.This; .) )
- "("
- [ Argument<out expr> (. if (expr != null) { ci.Arguments.Add(expr); } .) { "," Argument<out expr> (. if (expr != null) { ci.Arguments.Add(expr); } .) } ]
- ")" ";"
- .
- VariableInitializer<out Expression initializerExpression>
- (. initializerExpression = null; .)
- =
- Expr<out initializerExpression>
- | CollectionInitializer<out initializerExpression>
- | IF (la.kind == Tokens.Void) ( PrimaryExpr<out initializerExpression> )
- .
- Argument<out Expression argumentexpr>
- (.
- Expression expr = null;
- FieldDirection fd = FieldDirection.None;
- .)
- =
- Expr<out expr>
- (. argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; .)
- .
- AssignmentOperator<out AssignmentOperatorType op>
- (. op = AssignmentOperatorType.None; .)
- =
- "=" (. op = AssignmentOperatorType.Assign; .)
- | "+=" (. op = AssignmentOperatorType.Add; .)
- | "-=" (. op = AssignmentOperatorType.Subtract; .)
- | "*=" (. op = AssignmentOperatorType.Multiply; .)
- | "/=" (. op = AssignmentOperatorType.Divide; .)
- | "%=" (. op = AssignmentOperatorType.Modulus; .)
- | "&=" (. op = AssignmentOperatorType.BitwiseAnd; .)
- | "|=" (. op = AssignmentOperatorType.BitwiseOr; .)
- | "^=" (. op = AssignmentOperatorType.ExclusiveOr; .)
- | "<<=" (. op = AssignmentOperatorType.ShiftLeft; .)
- | IF (la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual)
- ">" ">=" (. op = AssignmentOperatorType.ShiftRight; .)
- .
- CollectionInitializer<out Expression outExpr>
- (.
- Expression expr = null;
- CollectionInitializerExpression initializer = new CollectionInitializerExpression();
- .)
- =
- "{"
- [ VariableInitializer<out expr>
- (. if (expr != null) { initializer.CreateExpressions.Add(expr); } .)
- { IF (NotFinalComma())
- "," VariableInitializer<out expr>
- (. if (expr != null) { initializer.CreateExpressions.Add(expr); } .)
- }
- [ "," ]
- ]
- "}" (. outExpr = initializer; .)
- .
- LocalVariableDecl<out Statement stmt>
- (.
- TypeReference type;
- VariableDeclaration var = null;
- LocalVariableDeclaration localVariableDeclaration;
- bool final = false;
- .)
- =
- ["final" (. final = true; .) ]
- Type<out type> (. localVariableDeclaration = new LocalVariableDeclaration(type); if (final) { localVariableDeclaration.Modifier = localVariableDeclaration.Modifier | Modifiers.Final; } localVariableDeclaration.StartLocation = t.Location; .)
- LocalVariableDeclarator<out var,type> (. localVariableDeclaration.Variables.Add(var); .)
- { "," LocalVariableDeclarator<out var,type> (. localVariableDeclaration.Variables.Add(var); .) }
- (. stmt = localVariableDeclaration; .)
- .
- LocalVariableDeclarator<out VariableDeclaration var,TypeReference type>
- (. Expression expr = null; .)
- =
- Identifier (. var = new VariableDeclaration(t.val); .)
- ArrayRank<type>
- [ "=" VariableInitializer<out expr> (. var.Initializer = expr; .) ]
- .
- /*
- LocalVariableInitializer<out Expression expr>
- (. expr = null; .)
- =
- Expr<out expr>
- | CollectionInitializer<out expr>
- .
- */
- Statement
- (.
- TypeReference type;
- Expression expr;
- Statement stmt = null;
- Location startPos = la.Location;
- List<TypeReference> names;
- .)
- =
- (
- /*--- labeled statement: */
- IF (IsLabel()) Identifier (. compilationUnit.AddChild(new LabelStatement(t.val)); .)
- ":" AndromedaStatement
- /*--- local constant declaration: */
- | "const" Type<out type> (. LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifiers.Const); string ident = null; var.StartLocation = t.Location; .)
- ident (. ident = t.val; .)
- "=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .)
- { "," ident (. ident = t.val; .) "=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .) }
- ";" (. compilationUnit.AddChild(var); .)
- | "class" (. TypeDeclaration newType = new TypeDeclaration(Modifiers.None, new List<AttributeSection>());
- stmt = new ClassDeclarationStatement(newType);
- newType.Type = Types.Class;
- compilationUnit.BlockStart(newType);
- .)
- ident (. newType.Name = t.val; .)
- [ ClassBase<out names> (. newType.BaseTypes = names; .) ]
- ClassBody [ ";" ] (. newType.EndLocation = t.Location; compilationUnit.BlockEnd(); compilationUnit.AddChild(stmt); .)
- /*--- local variable declaration: */
- | EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
- /* LL(1) confict: LocalVariableDecl *
- * <-> StatementExpr *
- * ident {"." ident} { "[" Expr ... */
- )
- (.
- if (stmt != null) {
- stmt.StartLocation = startPos;
- stmt.EndLocation = t.EndLocation;
- }
- .)
- .
- EmbeddedStatement<out Statement statement>
- (.
- Expression expr = null;
- Statement embeddedStatement = null;
- statement = null;
- .)
- =
- Block<out statement>
- /*--- empty statement: */
- | ";" (. statement = new EmptyStatement(); .)
- /*--- selection statements (if, switch): */
- | "if" (. Statement elseStatement = null; .)
- "(" Expr<out expr> ")"
- EmbeddedStatement<out embeddedStatement>
- [ "else" EmbeddedStatement<out elseStatement> ]
- (. statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); .)
- (. if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) {
- /* else if-section (otherwise we would have a BlockStatment) */
- (statement as IfElseStatement).ElseIfSections.Add(
- new ElseIfSection((elseStatement as IfElseStatement).Condition,
- (elseStatement as IfElseStatement).TrueStatement[0]));
- (statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections);
- (statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement;
- } .)
- | "switch" (. List<SwitchSection> switchSections = new List<SwitchSection>(); .)
- "(" Expr<out expr> ")"
- "{" SwitchSections<switchSections>
- "}" (. statement = new SwitchStatement(expr, switchSections); .)
- /*--- iteration statements (while, do, for, foreach): */
- | "while" "(" Expr<out expr> ")"
- EmbeddedStatement<out embeddedStatement> (. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);.)
- | "do" EmbeddedStatement<out embeddedStatement> "while"
- "(" Expr<out expr> ")" ";" (. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); .)
- | "for" (. List<Statement> initializer = null; List<Statement> iterator = null; .)
- "(" ["final"] [ ForInitializer<out initializer> ] ";"
- [ Expr<out expr> ] ";"
- [ ForIterator<out iterator> ] ")"
- EmbeddedStatement<out embeddedStatement> (. statement = new ForStatement(initializer, expr, iterator, embeddedStatement); .)
- /*--- jump statements (break, contine, goto, return, throw): */
- | "break" (. statement = new BreakStatement(); .)
- [ident (. ((BreakStatement)statement).Label = t.val; .) ]
- ";"
- | "continue" (. statement = new ContinueStatement(); .)
- [ident (. ((ContinueStatement)statement).Label = t.val; .) ]
- ";"
- | "return" [ Expr<out expr> ] ";" (. statement = new ReturnStatement(expr); .)
- | "throw" [ Expr<out expr> ] ";" (. statement = new ThrowStatement(expr); .)
- /*--- expression statement: */
- | StatementExpr<out statement> ";"
- /*--- try statement: */
- | TryStatement<out statement>
- EmbeddedStatement<out embeddedStatement> (. statement = new LockStatement(expr, embeddedStatement); .)
- .
- ForInitializer<out List<Statement> initializer>
- (.
- Statement stmt;
- initializer = new List<Statement>();
- .)
- =
- IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> (. initializer.Add(stmt);.)
- | StatementExpr<out stmt> (.initializer.Add(stmt);.) { "," StatementExpr<out stmt> (. initializer.Add(stmt);.) }
- .
- ForIterator<out List<Statement> iterator>
- (.
- Statement stmt;
- iterator = new List<Statement>();
- .)
- =
- StatementExpr<out stmt> (. iterator.Add(stmt);.) { "," StatementExpr<out stmt> (. iterator.Add(stmt); .) }
- .
- SwitchSections<List<SwitchSection> switchSections>
- (.
- SwitchSection switchSection = new SwitchSection();
- CaseLabel label;
- .)
- =
- SwitchLabel<out label> (. if (label != null) { switchSection.SwitchLabels.Add(label); } .)
- (. compilationUnit.BlockStart(switchSection); .)
- {
- ( SwitchLabel<out label>
- (. if (label != null) {
- if (switchSection.Children.Count > 0) {
- // open new section
- compilationUnit.BlockEnd(); switchSections.Add(switchSection);
- switchSection = new SwitchSection();
- compilationUnit.BlockStart(switchSection);
- }
- switchSection.SwitchLabels.Add(label);
- }
- .)
- | AndromedaStatement)
- }
- (. compilationUnit.BlockEnd(); switchSections.Add(switchSection); .)
- .
- SwitchLabel<out CaseLabel label>
- (. Expression expr = null; label = null; .)
- =
- "case" Expr<out expr> ":" (. label = new CaseLabel(expr); .)
- | "default" ":" (. label = new CaseLabel(); .)
- .
- TryStatement<out Statement tryStatement>
- (.
- Statement blockStmt = null, finallyStmt = null;
- List<CatchClause> catchClauses = null;
- .)
- =
- "try" Block<out blockStmt>
- (
- CatchClauses<out catchClauses> [ "finally" Block<out finallyStmt> ]
- | "finally" Block<out finallyStmt>
- )
- (.
- tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
- .)
- .
- CatchClauses<out List<CatchClause> catchClauses>
- (.
- catchClauses = new List<CatchClause>();
- .)
- =
- "catch" (. string identifier;
- Statement stmt;
- TypeReference typeRef;
- .)
- /*--- general catch clause (as only catch clause) */
- (
- Block<out stmt> (. catchClauses.Add(new CatchClause(stmt)); .)
- /*--- specific catch clause */
- | "(" ["final"] ClassType<out typeRef> (. identifier = null; .)
- [ ident (. identifier = t.val; .) ]
- ")" Block<out stmt>
- (. catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); .)
- { IF (IsTypedCatch()) "catch" "(" ["final"] ClassType<out typeRef> (. identifier = null; .)
- [ ident (. identifier = t.val; .) ]
- ")" Block<out stmt>
- (. catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); .) }
- /*--- general catch clause (after specific catch clauses, optional) */
- [ "catch" Block<out stmt> (. catchClauses.Add(new CatchClause(stmt)); .) ]
- )
- .
- StatementExpr<out Statement stmt>
- (. Expression expr; .)
- =
- Expr<out expr>
- /* The grammar allows only assignments or method invocations here, */
- /* but we don't enforce that here */
- (. stmt = new ExpressionStatement(expr); .)
- .
- Expr<out Expression expr>
- (. expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; .)
- =
- IF(la.kind == Tokens.Void) ( PrimaryExpr<out expr> )
- | UnaryExpr<out expr>
- /*--- conditional expression: */
- (
- ( AssignmentOperator<out op> Expr<out expr1> (. expr = new AssignmentExpression(expr, op, expr1); .) )
- | IF (la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual)
- ( AssignmentOperator<out op> Expr<out expr1> (. expr = new AssignmentExpression(expr, op, expr1); .) )
- | (
- ConditionalOrExpr<ref expr>
- [ "??" Expr<out expr1> (. expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); .) ]
- [ "?" Expr<out expr1> ":" Expr<out expr2> (. expr = new ConditionalExpression(expr, expr1, expr2); .) ]
- )
- )
- .
- UnaryExpr<out Expression uExpr>
- (.
- TypeReference type = null;
- Expression expr;
- ArrayList expressions = new ArrayList();
- uExpr = null;
- .)
- =
- {
- /* IF (Tokens.UnaryOp[la.kind] || IsTypeCast()) */
- (
- "+" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); .)
- | "-" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); .)
- | "!" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); .)
- | "~" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); .)
- | "*" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Star)); .)
- | "++" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); .)
- | "--" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); .)
- | "&" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitWiseAnd)); .)
- /*--- cast expression: */
- /* Problem: "(" Type ")" from here and *
- * "(" Expr ")" from PrimaryExpr *
- * Solution: (in IsTypeCast()) */
- | IF (IsTypeCast()) "(" Type<out type> ")" (. expressions.Add(new CastExpression(type)); .)
- )
- }
- PrimaryExpr<out expr> (. for (int i = 0; i < expressions.Count; ++i) {
- Expression nextExpression = i + 1 < expressions.Count ? (Expression)expressions[i + 1] : expr;
- if (expressions[i] is CastExpression) {
- ((CastExpression)expressions[i]).Expression = nextExpression;
- } else {
- ((UnaryOperatorExpression)expressions[i]).Expression = nextExpression;
- }
- }
- if (expressions.Count > 0) {
- uExpr = (Expression)expressions[0];
- } else {
- uExpr = expr;
- }
- .)
- .
- PrimaryExpr<out Expression pexpr>
- (.
- TypeReference type = null;
- Expression expr;
- pexpr = null;
- .)
- =
- (
- "true" (.pexpr = new PrimitiveExpression(true, "true"); .)
- | "false" (.pexpr = new PrimitiveExpression(false, "false"); .)
- | "null" (.pexpr = new PrimitiveExpression(null, "null"); .) /* from literal token */
- | Literal (.pexpr = new PrimitiveExpression(t.literalValue, t.val); .)
- | "void" (. type = new TypeReference("void"); pexpr = new TypeReferenceExpression(type); .) "." "class" (. type.Kind = TypeReferenceKind.DotClass; .)
- | IF (IsTypeReferenceWithDotClassOrThis())
- (
- Type<out type> (. pexpr = new TypeReferenceExpression(type); .) "."
- (
- "class" (. type.Kind = TypeReferenceKind.DotClass; .)
- | "this" (. type.Kind = TypeReferenceKind.DotThis; .)
- )
- )
- /*--- simple name: */
- | ident (. pexpr = new IdentifierExpression(t.val); .)
- /*--- parenthesized expression: */
- | "(" Expr<out expr> ")" (. pexpr = new ParenthesizedExpression(expr); .)
- | /*--- predefined type member access: */
- (. string val = null; .)
- (
- "abilcmd" (. val = "abilcmd"; .)
- | "actor" (. val = "actor"; .)
- | "actorscope" (. val = "actorscope"; .)
- | "aifilter" (. val = "aifilter"; .)
- | "bank" (. val = "bank"; .)
- | "bool" (. val = "bool"; .)
- | "byte" (. val = "byte"; .)
- | "camerainfo" (. val = "camerainfo"; .)
- | "color" (. val = "color"; .)
- | "doodad" (. val = "doodad"; .)
- | "fixed" (. val = "fixed"; .)
- | "int" (. val = "int"; .)
- | "marker" (. val = "marker"; .)
- | "order" (. val = "order"; .)
- | "playergroup" (. val = "playergroup"; .)
- | "point" (. val = "point"; .)
- | "revealer" (. val = "revealer"; .)
- | "sound" (. val = "sound"; .)
- | "soundlink" (. val = "soundlink"; .)
- | "string" (. val = "string"; .)
- | "text" (. val = "text"; .)
- | "timer" (. val = "timer"; .)
- | "transmissionsource" (. val = "transmissionsource"; .)
- | "trigger" (. val = "trigger"; .)
- | "unit" (. val = "unit"; .)
- | "unitfilter" (. val = "unitfilter"; .)
- | "unitgroup" (. val = "unitgroup"; .)
- | "unitref" (. val = "unitref"; .)
- | "void" (. val = "void"; .)
- | "wave" (. val = "wave"; .)
- | "waveinfo" (. val = "waveinfo"; .)
- | "wavetarget" (. val = "wavetarget"; .)
- ) (. t.val = ""; .) "." ident (. pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); .)
- /*--- this access: */
- | "this" (. pexpr = new ThisReferenceExpression(); .)
- /*--- base access: */
- | "super" (. Expression retExpr = new BaseReferenceExpression(); .)
- (
- "." Identifier (. retExpr = new FieldReferenceExpression(retExpr, t.val); .)
- | "[" Expr<out expr> (. List<Expression> indices = new List<Expression>(); if (expr != null) { indices.Add(expr); } .)
- { "," Expr<out expr> (. if (expr != null) { indices.Add(expr); } .) }
- "]" (. retExpr = new IndexerExpression(retExpr, indices); .)
- ) (. pexpr = retExpr; .)
- | "new" NonArrayType<out type>
- (. List<Expression> parameters = new List<Expression>(); .)
- /*--- delegate / object creation expression: */
- /* Note: a delegate creation expression allow only a single Expr */
- /* not an argument list, but this is not distinguished here */
- (
- "(" (. ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); .)
- [ Argument<out expr> (. if (expr != null) { parameters.Add(expr); } .)
- { "," Argument<out expr> (. if (expr != null) { parameters.Add(expr); } .) }
- ]
- ")" (. pexpr = oce; .)
- [
- (.
- ModifierList m = new ModifierList();
- TypeDeclaration newType = new TypeDeclaration(Modifiers.Public, null);
- compilationUnit.BlockStart(newType);
- newType.Type = Types.Class;
- newType.Name = t.val;
- .)
- ClassBody
- (.
- compilationUnit.BlockEnd();
- oce.AnonymousClass = newType;
- .)
- ]
- | "[" /*--- array creation expression: */
- (. ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; .)
- (. int dims = 0; List<int> ranks = new List<int>(); .)
- (
- { "," (. dims += 1; .) }
- "]" (. ranks.Add(dims); dims = 0; .)
- { "[" { "," (. ++dims; .) } "]" (. ranks.Add(dims); dims = 0; .) }
- (. ace.CreateType.RankSpecifier = ranks.ToArray(); .)
- CollectionInitializer<out expr> (. ace.ArrayInitializer = (CollectionInitializerExpression)expr; .)
- | Expr<out expr> (. if (expr != null) parameters.Add(expr); .)
- "]" (. ace.Arguments = parameters; .)
- { "[" (. dims++; expr = null; .)
- [ [Expr<out expr>] (. if (expr != null) parameters.Add(expr); else parameters.RemoveRange(1, parameters.Count - 1);.) ]
- "]" (. ranks.Add(0); dims = 0; .)
- } (. ranks.Add(dims); .)
- (. ace.CreateType.RankSpecifier = ranks.ToArray(); .)
- [ CollectionInitializer<out expr> (. ace.ArrayInitializer = (CollectionInitializerExpression)expr; .) ]
- )
- )
- | "typeof" "("
- (
- IF (NotVoidPointer()) "void" (. type = new TypeReference("void"); .)
- | TypeWithRestriction<out type>
- ) ")" (. pexpr = new TypeOfExpression(type); .)
- | "default" "(" Type<out type> ")" (. pexpr = new DefaultValueExpression(type); .)
- )
- {
- (
- "++" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); .)
- | "--" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); .)
- )
- /*--- member access */
- | "." Identifier (. pexpr = new FieldReferenceExpression(pexpr, t.val);.)
- /*--- invocation expression: */
- | "(" (. List<Expression> parameters = new List<Expression>(); .)
- [ Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .)
- { "," Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .)
- } ] ")" (. pexpr = new InvocationExpression(pexpr, parameters); .)
- /*--- element access */
- | (. /*if (isArrayCreation) Error("element access not allow on array creation");*/
- List<Expression> indices = new List<Expression>();
- .)
- "[" Expr<out expr> (. if (expr != null) { indices.Add(expr); } .)
- { "," Expr<out expr> (. if (expr != null) { indices.Add(expr); } .)
- } "]" (. pexpr = new IndexerExpression(pexpr, indices); .)
- }
- .
- ConditionalOrExpr<ref Expression outExpr>
- (. Expression expr; .)
- =
- ConditionalAndExpr<ref outExpr> { "||" UnaryExpr<out expr> ConditionalAndExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); .) }
- .
- ConditionalAndExpr<ref Expression outExpr>
- (. Expression expr; .)
- =
- InclusiveOrExpr<ref outExpr> { "&&" UnaryExpr<out expr> InclusiveOrExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); .) }
- .
- InclusiveOrExpr<ref Expression outExpr>
- (. Expression expr; .)
- =
- ExclusiveOrExpr<ref outExpr> { "|" UnaryExpr<out expr> ExclusiveOrExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); .) }
- .
- ExclusiveOrExpr<ref Expression outExpr>
- (. Expression expr; .)
- =
- AndExpr<ref outExpr> { "^" UnaryExpr<out expr> AndExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); .) }
- .
- AndExpr<ref Expression outExpr>
- (. Expression expr; .)
- =
- EqualityExpr<ref outExpr> { "&" UnaryExpr<out expr> EqualityExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); .) }
- .
- EqualityExpr<ref Expression outExpr>
- (.
- Expression expr;
- BinaryOperatorType op = BinaryOperatorType.None;
- .)
- =
- RelationalExpr<ref outExpr>
- {
- (
- "!=" (. op = BinaryOperatorType.InEquality; .)
- | "==" (. op = BinaryOperatorType.Equality; .)
- )
- UnaryExpr<out expr> RelationalExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
- }
- .
- RelationalExpr<ref Expression outExpr>
- (.
- TypeReference type;
- Expression expr;
- BinaryOperatorType op = BinaryOperatorType.None;
- .)
- =
- ShiftExpr<ref outExpr>
- {
- ( "<" (. op = BinaryOperatorType.LessThan; .)
- | ">" (. op = BinaryOperatorType.GreaterThan; .)
- | "<=" (. op = BinaryOperatorType.LessThanOrEqual; .)
- | ">=" (. op = BinaryOperatorType.GreaterThanOrEqual; .)
- )
- UnaryExpr<out expr>
- ShiftExpr<ref expr>
- (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
- |
- (
- TypeWithRestriction<out type>
- (. outExpr = new TypeOfIsExpression(outExpr, type); .)
- )
- }
- .
- ShiftExpr<ref Expression outExpr>
- (.
- Expression expr;
- BinaryOperatorType op = BinaryOperatorType.None;
- .)
- =
- AdditiveExpr<ref outExpr>
- {
- ( "<<" (. op = BinaryOperatorType.ShiftLeft; .)
- | IF (IsShiftRight()) (
- ">" ">" (. op = BinaryOperatorType.ShiftRight; .)
- [">" (. op = BinaryOperatorType.UnsignedShiftRight; .)
- | ">=" (. op = BinaryOperatorType.UnsignedShiftRightAssign; .)]
- )
- )
- UnaryExpr<out expr> AdditiveExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
- }
- .
- AdditiveExpr<ref Expression outExpr>
- (.
- Expression expr;
- BinaryOperatorType op = BinaryOperatorType.None;
- .)
- =
- MultiplicativeExpr<ref outExpr>
- {
- (
- "+" (. op = BinaryOperatorType.Add; .)
- | "-" (. op = BinaryOperatorType.Subtract; .)
- )
- UnaryExpr<out expr> MultiplicativeExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
- }
- .
- MultiplicativeExpr<ref Expression outExpr>
- (.
- Expression expr;
- BinaryOperatorType op = BinaryOperatorType.None;
- .)
- =
- {
- (
- "*" (. op = BinaryOperatorType.Multiply; .)
- | "/" (. op = BinaryOperatorType.Divide; .)
- | "%" (. op = BinaryOperatorType.Modulus; .)
- )
- UnaryExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
- }
- .
- TypeName<out TypeReference typeRef>
- (.
- string qualident;
- .)
- =
- Qualident<out qualident>
- (.
- typeRef = new TypeReference(qualident, new List<TypeReference>());
- .)
- { IF (DotAndIdent())
- "."
- Qualident<out qualident>
- }
- .
- Identifier
- =
- ident
- .
- ArrayRank<TypeReference type>
- =
- [
- (. List<int> r = new List<int>(); int i = -1;.)
- { "[" (. ++i; .) "]" } (. r.Add(i); .)
- (. type.RankSpecifier = r.ToArray(); .)
- ]
- .
- AndromedaStatement
- (.
- Statement stmt = null;
- .)
- =
- IF (IsLocalVarDecl()) ( LocalVariableDecl<out stmt> ";" ) (. compilationUnit.AddChild(stmt); .)
- | "final" ( LocalVariableDecl<out stmt> ";" ) (. compilationUnit.AddChild(stmt); .)
- | Statement
- .
- END Andromeda.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement