From 64971ec4214bc505791c1957ee282b95f15c63d2 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 16 Jul 2006 14:43:49 +0000 Subject: [PATCH] Implemented SD2-446: Support skipping method bodies in VB Lexer. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1586 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../VBNetBinding/Project/Src/Parser/Parser.cs | 1 + .../NRefactory/Project/NRefactory.csproj | 2 + .../Project/Src/Lexer/AbstractLexer.cs | 19 +- .../Project/Src/Lexer/CSharp/Lexer.cs | 2 +- .../NRefactory/Project/Src/Lexer/ILexer.cs | 4 +- .../Project/Src/Lexer/VBNet/Lexer.cs | 21 +- .../Src/Output/AbstractOutputFormatter.cs | 11 + .../Src/Output/CSharp/OutputFormatter.cs | 10 +- .../Project/Src/Parser/AbstractParser.cs | 2 +- .../Project/Src/Parser/CSharp/CSharpParser.cs | 506 ++++ .../Project/Src/Parser/CSharp/Parser.cs | 2591 +++++++---------- .../Project/Src/Parser/CSharp/cs.ATG | 536 +--- .../Project/Src/Parser/Frames/Parser.frame | 40 +- .../Src/Parser/Frames/Parser.frame.new | 36 +- .../Src/Parser/Frames/Parser.frame.old | 40 +- .../Project/Src/Parser/VBNet/Parser.cs | 2424 +++++++-------- .../Project/Src/Parser/VBNet/VBNET.ATG | 344 +-- .../Project/Src/Parser/VBNet/VBNetParser.cs | 269 ++ .../Test/Lexer/CSharp/CustomLexerTests.cs | 8 +- .../Test/Output/SpecialOutputVisitor.cs | 16 + 20 files changed, 3045 insertions(+), 3837 deletions(-) create mode 100644 src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs create mode 100644 src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs index 1d0a785a0b..856ccedb98 100644 --- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs +++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs @@ -101,6 +101,7 @@ namespace VBNetBinding.Parser ICompilationUnit Parse(ICSharpCode.NRefactory.Parser.IParser p, string fileName, IProjectContent projectContent) { p.Lexer.SpecialCommentTags = lexerTags; + p.ParseMethodBodies = false; p.Parse(); NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(projectContent); diff --git a/src/Libraries/NRefactory/Project/NRefactory.csproj b/src/Libraries/NRefactory/Project/NRefactory.csproj index 98737e6c07..ad64bbe135 100644 --- a/src/Libraries/NRefactory/Project/NRefactory.csproj +++ b/src/Libraries/NRefactory/Project/NRefactory.csproj @@ -127,6 +127,8 @@ Configuration\GlobalAssemblyInfo.cs + + diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs index bb67f45e4d..a72fc24092 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs @@ -201,17 +201,6 @@ namespace ICSharpCode.NRefactory.Parser protected abstract Token Next(); - /// - /// Skips to the end of the current code block. - /// For this, the lexer must have read the next token AFTER the token opening the - /// block (so that Lexer.Token is the block-opening token, not Lexer.LookAhead). - /// After the call, Lexer.LookAhead will be the block-closing token. - /// - public virtual void SkipCurrentBlock() - { - throw new NotSupportedException(); - } - protected bool IsIdentifierPart(int ch) { if (ch == 95) return true; // 95 = '_' @@ -293,5 +282,13 @@ namespace ICSharpCode.NRefactory.Parser col += retStr.Length; return retStr; } + + /// + /// Skips to the end of the current code block. + /// For this, the lexer must have read the next token AFTER the token opening the + /// block (so that Lexer.Token is the block-opening token, not Lexer.LookAhead). + /// After the call, Lexer.LookAhead will be the block-closing token. + /// + public abstract void SkipCurrentBlock(int targetToken); } } diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs index 988a37d4d2..87f74332c8 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs @@ -800,7 +800,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp /// block (so that Lexer.Token is the block-opening token, not Lexer.LookAhead). /// After the call, Lexer.LookAhead will be the block-closing token. /// - public override void SkipCurrentBlock() + public override void SkipCurrentBlock(int targetToken) { int braceCount = 0; while (curToken != null) { diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/ILexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/ILexer.cs index 37b835c16a..ae23653dfe 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/ILexer.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/ILexer.cs @@ -76,12 +76,12 @@ namespace ICSharpCode.NRefactory.Parser /// An object. Token NextToken(); - /// + /// /// Skips to the end of the current code block. /// For this, the lexer must have read the next token AFTER the token opening the /// block (so that Lexer.Token is the block-opening token, not Lexer.LookAhead). /// After the call, Lexer.LookAhead will be the block-closing token. /// - void SkipCurrentBlock(); + void SkipCurrentBlock(int targetToken); } } diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs index e5e78eb2d2..285f76220a 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs @@ -17,7 +17,7 @@ namespace ICSharpCode.NRefactory.Parser.VB { internal class Lexer : AbstractLexer { - bool lineEnd = false; + bool lineEnd = true; public Lexer(TextReader reader) : base(reader) { @@ -61,7 +61,11 @@ namespace ICSharpCode.NRefactory.Parser.VB int x = Col - 1; int y = Line; if (HandleLineEnd(ch)) { - if (!lineEnd) { + if (lineEnd) { + // second line end before getting to a token + // -> here was a blank line + specialTracker.AddEndOfLine(new Location(x, y)); + } else { lineEnd = true; return new Token(Tokens.EOL, x, y); } @@ -707,5 +711,18 @@ namespace ICSharpCode.NRefactory.Parser.VB } return null; } + + public override void SkipCurrentBlock(int targetToken) + { + int lastKind = -1; + int kind = base.lastToken.kind; + while (kind != Tokens.EOF && + !(lastKind == Tokens.End && kind == targetToken)) + { + lastKind = kind; + NextToken(); + kind = lastToken.kind; + } + } } } diff --git a/src/Libraries/NRefactory/Project/Src/Output/AbstractOutputFormatter.cs b/src/Libraries/NRefactory/Project/Src/Output/AbstractOutputFormatter.cs index abacf58b19..34ae933783 100644 --- a/src/Libraries/NRefactory/Project/Src/Output/AbstractOutputFormatter.cs +++ b/src/Libraries/NRefactory/Project/Src/Output/AbstractOutputFormatter.cs @@ -152,6 +152,17 @@ namespace ICSharpCode.NRefactory.PrettyPrinter } } + /// + /// Prints a text that cannot be inserted before using WriteInPreviousLine + /// into the current line + /// + protected void PrintSpecialText(string specialText) + { + lineBeforeLastStart = text.Length; + text.Append(specialText); + lastLineStart = text.Length; + } + public void PrintTokenList(ArrayList tokenList) { foreach (int token in tokenList) { diff --git a/src/Libraries/NRefactory/Project/Src/Output/CSharp/OutputFormatter.cs b/src/Libraries/NRefactory/Project/Src/Output/CSharp/OutputFormatter.cs index 6db3ac68ba..6ad65346c4 100644 --- a/src/Libraries/NRefactory/Project/Src/Output/CSharp/OutputFormatter.cs +++ b/src/Libraries/NRefactory/Project/Src/Output/CSharp/OutputFormatter.cs @@ -118,13 +118,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter { switch (comment.CommentType) { case CommentType.Block: -// if (forceWriteInPreviousBlock) { + if (forceWriteInPreviousBlock) { WriteInPreviousLine("/*" + comment.CommentText + "*/", forceWriteInPreviousBlock); -// } else { -// PrintText("/*"); -// PrintText(comment.CommentText); -// PrintText("*/"); -// } + } else { + PrintSpecialText("/*" + comment.CommentText + "*/"); + } break; case CommentType.Documentation: WriteLineInPreviousLine("///" + comment.CommentText, forceWriteInPreviousBlock); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AbstractParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/AbstractParser.cs index 8be33f3c0e..02a2a4aa6f 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/AbstractParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/AbstractParser.cs @@ -19,7 +19,7 @@ namespace ICSharpCode.NRefactory.Parser protected const string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text protected Errors errors; - protected ILexer lexer; + private ILexer lexer; protected int errDist = minErrDist; diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs new file mode 100644 index 0000000000..a86746e0bd --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs @@ -0,0 +1,506 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 16.07.2006 + * Time: 15:55 + */ + +using System; +using System.Text; +using System.Collections.Generic; +using ICSharpCode.NRefactory.Parser.AST; + +namespace ICSharpCode.NRefactory.Parser.CSharp +{ + internal sealed partial class Parser : AbstractParser + { + Lexer lexer; + + public Parser(ILexer lexer) : base(lexer) + { + this.lexer = (Lexer)lexer; + } + + string assemblyName = null; + StringBuilder qualidentBuilder = new StringBuilder(); + + public string ContainingAssembly { + set { + assemblyName = value; + } + } + + Token t { + [System.Diagnostics.DebuggerStepThrough] + get { + return lexer.Token; + } + } + + Token la { + [System.Diagnostics.DebuggerStepThrough] + get { + return lexer.LookAhead; + } + } + + public void Error(string s) + { + if (errDist >= minErrDist) { + errors.Error(la.line, la.col, s); + } + errDist = 0; + } + + public override Expression ParseExpression() + { + lexer.NextToken(); + Expression expr; + Expr(out expr); + return expr; + } + // Begin ISTypeCast + bool IsTypeCast() + { + if (la.kind != Tokens.OpenParenthesis) { + return false; + } + if (IsSimpleTypeCast()) { + return true; + } + return GuessTypeCast(); + } + + // "(" ( typeKW [ "[" {","} "]" | "*" ] | void ( "[" {","} "]" | "*" ) ) ")" + // only for built-in types, all others use GuessTypeCast! + bool IsSimpleTypeCast () + { + // assert: la.kind == _lpar + lexer.StartPeek(); + Token pt = lexer.Peek(); + + if (!IsTypeKWForTypeCast(ref pt)) { + return false; + } + if (pt.kind == Tokens.Question) + pt = lexer.Peek(); + return pt.kind == Tokens.CloseParenthesis; + } + + /* !!! Proceeds from current peek position !!! */ + bool IsTypeKWForTypeCast(ref Token pt) + { + if (Tokens.TypeKW[pt.kind]) { + pt = lexer.Peek(); + return IsPointerOrDims(ref pt) && SkipQuestionMark(ref pt); + } else if (pt.kind == Tokens.Void) { + pt = lexer.Peek(); + return IsPointerOrDims(ref pt); + } + return false; + } + + /* !!! Proceeds from current peek position !!! */ + bool IsTypeNameOrKWForTypeCast(ref Token pt) + { + if (IsTypeKWForTypeCast(ref pt)) + return true; + else + return IsTypeNameForTypeCast(ref pt); + } + + // TypeName = ident [ "::" ident ] { ["<" TypeNameOrKW { "," TypeNameOrKW } ">" ] "." ident } ["?"] PointerOrDims + /* !!! Proceeds from current peek position !!! */ + bool IsTypeNameForTypeCast(ref Token pt) + { + // ident + if (pt.kind != Tokens.Identifier) { + return false; + } + pt = Peek(); + // "::" ident + if (pt.kind == Tokens.DoubleColon) { + pt = Peek(); + if (pt.kind != Tokens.Identifier) { + return false; + } + pt = Peek(); + } + // { ["<" TypeNameOrKW { "," TypeNameOrKW } ">" ] "." ident } + while (true) { + if (pt.kind == Tokens.LessThan) { + do { + pt = Peek(); + if (!IsTypeNameOrKWForTypeCast(ref pt)) { + return false; + } + } while (pt.kind == Tokens.Comma); + if (pt.kind != Tokens.GreaterThan) { + return false; + } + pt = Peek(); + } + if (pt.kind != Tokens.Dot) + break; + pt = Peek(); + if (pt.kind != Tokens.Identifier) { + return false; + } + pt = Peek(); + } + // ["?"] + if (pt.kind == Tokens.Question) { + pt = Peek(); + } + if (pt.kind == Tokens.Times || pt.kind == Tokens.OpenSquareBracket) { + return IsPointerOrDims(ref pt); + } + return true; + } + + // "(" TypeName ")" castFollower + bool GuessTypeCast () + { + // assert: la.kind == _lpar + StartPeek(); + Token pt = Peek(); + + if (!IsTypeNameForTypeCast(ref pt)) { + return false; + } + + // ")" + if (pt.kind != Tokens.CloseParenthesis) { + return false; + } + // check successor + pt = Peek(); + return Tokens.CastFollower[pt.kind] || (Tokens.TypeKW[pt.kind] && lexer.Peek().kind == Tokens.Dot); + } + // END IsTypeCast + + /* Checks whether the next sequences of tokens is a qualident * + * and returns the qualident string */ + /* !!! Proceeds from current peek position !!! */ + bool IsQualident(ref Token pt, out string qualident) + { + if (pt.kind == Tokens.Identifier) { + qualidentBuilder.Length = 0; qualidentBuilder.Append(pt.val); + pt = Peek(); + while (pt.kind == Tokens.Dot || pt.kind == Tokens.DoubleColon) { + pt = Peek(); + if (pt.kind != Tokens.Identifier) { + qualident = String.Empty; + return false; + } + qualidentBuilder.Append('.'); + qualidentBuilder.Append(pt.val); + pt = Peek(); + } + qualident = qualidentBuilder.ToString(); + return true; + } + qualident = String.Empty; + return false; + } + + /* Skips generic type extensions */ + /* !!! Proceeds from current peek position !!! */ + + /* skip: { "*" | "[" { "," } "]" } */ + /* !!! Proceeds from current peek position !!! */ + bool IsPointerOrDims (ref Token pt) + { + for (;;) { + if (pt.kind == Tokens.OpenSquareBracket) { + do pt = Peek(); + while (pt.kind == Tokens.Comma); + if (pt.kind != Tokens.CloseSquareBracket) return false; + } else if (pt.kind != Tokens.Times) break; + pt = Peek(); + } + return true; + } + + /* Return the n-th token after the current lookahead token */ + void StartPeek() + { + lexer.StartPeek(); + } + + Token Peek() + { + return lexer.Peek(); + } + + Token Peek (int n) + { + lexer.StartPeek(); + Token x = la; + while (n > 0) { + x = lexer.Peek(); + n--; + } + return x; + } + + /*-----------------------------------------------------------------* + * Resolver routines to resolve LL(1) conflicts: * * + * These resolution routine return a boolean value that indicates * + * whether the alternative at hand shall be choosen or not. * + * They are used in IF ( ... ) expressions. * + *-----------------------------------------------------------------*/ + + /* True, if ident is followed by "=" */ + bool IdentAndAsgn () + { + return la.kind == Tokens.Identifier && Peek(1).kind == Tokens.Assign; + } + + bool IsAssignment () { return IdentAndAsgn(); } + + /* True, if ident is followed by ",", "=", or ";" */ + bool IdentAndCommaOrAsgnOrSColon () { + int peek = Peek(1).kind; + return la.kind == Tokens.Identifier && + (peek == Tokens.Comma || peek == Tokens.Assign || peek == Tokens.Semicolon); + } + bool IsVarDecl () { return IdentAndCommaOrAsgnOrSColon(); } + + /* True, if the comma is not a trailing one, * + * like the last one in: a, b, c, */ + bool NotFinalComma () { + int peek = Peek(1).kind; + return la.kind == Tokens.Comma && + peek != Tokens.CloseCurlyBrace && peek != Tokens.CloseSquareBracket; + } + + /* True, if "void" is followed by "*" */ + bool NotVoidPointer () { + return la.kind == Tokens.Void && Peek(1).kind != Tokens.Times; + } + + /* True, if "checked" or "unchecked" are followed by "{" */ + bool UnCheckedAndLBrace () { + return la.kind == Tokens.Checked || la.kind == Tokens.Unchecked && + Peek(1).kind == Tokens.OpenCurlyBrace; + } + + /* True, if "." is followed by an ident */ + bool DotAndIdent () { + return la.kind == Tokens.Dot && Peek(1).kind == Tokens.Identifier; + } + + /* True, if ident is followed by ":" */ + bool IdentAndColon () { + return la.kind == Tokens.Identifier && Peek(1).kind == Tokens.Colon; + } + + bool IsLabel () { return IdentAndColon(); } + + /* True, if ident is followed by "(" */ + bool IdentAndLPar () { + return la.kind == Tokens.Identifier && Peek(1).kind == Tokens.OpenParenthesis; + } + + /* True, if "catch" is followed by "(" */ + bool CatchAndLPar () { + return la.kind == Tokens.Catch && Peek(1).kind == Tokens.OpenParenthesis; + } + bool IsTypedCatch () { return CatchAndLPar(); } + + /* True, if "[" is followed by the ident "assembly" */ + bool IsGlobalAttrTarget () { + Token pt = Peek(1); + return la.kind == Tokens.OpenSquareBracket && + pt.kind == Tokens.Identifier && pt.val == "assembly"; + } + + /* True, if "[" is followed by "," or "]" */ + bool LBrackAndCommaOrRBrack () { + int peek = Peek(1).kind; + return la.kind == Tokens.OpenSquareBracket && + (peek == Tokens.Comma || peek == Tokens.CloseSquareBracket); + } + + bool IsDims () { return LBrackAndCommaOrRBrack(); } + + /* True, if "[" is followed by "," or "]" */ + /* or if the current token is "*" */ + bool TimesOrLBrackAndCommaOrRBrack () { + return la.kind == Tokens.Times || LBrackAndCommaOrRBrack(); + } + bool IsPointerOrDims () { return TimesOrLBrackAndCommaOrRBrack(); } + bool IsPointer () { return la.kind == Tokens.Times; } + + + bool SkipGeneric(ref Token pt) + { + if (pt.kind == Tokens.LessThan) { + do { + pt = Peek(); + if (!IsTypeNameOrKWForTypeCast(ref pt)) return false; + } while (pt.kind == Tokens.Comma); + if (pt.kind != Tokens.GreaterThan) return false; + pt = Peek(); + } + return true; + } + bool SkipQuestionMark(ref Token pt) + { + if (pt.kind == Tokens.Question) { + pt = Peek(); + } + return true; + } + + /* True, if lookahead is a primitive type keyword, or */ + /* if it is a type declaration followed by an ident */ + bool IsLocalVarDecl () { + if (IsYieldStatement()) { + return false; + } + if ((Tokens.TypeKW[la.kind] && Peek(1).kind != Tokens.Dot) || la.kind == Tokens.Void) { + return true; + } + + StartPeek(); + Token pt = la; + return IsTypeNameOrKWForTypeCast(ref pt) && pt.kind == Tokens.Identifier; + } + + /* True if lookahead is type parameters (<...>) followed by the specified token */ + bool IsGenericFollowedBy(int token) + { + Token t = la; + if (t.kind != Tokens.LessThan) return false; + StartPeek(); + return SkipGeneric(ref t) && t.kind == token; + } + + bool IsExplicitInterfaceImplementation() + { + StartPeek(); + Token pt = la; + pt = Peek(); + if (pt.kind == Tokens.Dot || pt.kind == Tokens.DoubleColon) + return true; + if (pt.kind == Tokens.LessThan) { + if (SkipGeneric(ref pt)) + return pt.kind == Tokens.Dot; + } + return false; + } + + /* True, if lookahead ident is "where" */ + bool IdentIsWhere () { + return la.kind == Tokens.Identifier && la.val == "where"; + } + + /* True, if lookahead ident is "get" */ + bool IdentIsGet () { + return la.kind == Tokens.Identifier && la.val == "get"; + } + + /* True, if lookahead ident is "set" */ + bool IdentIsSet () { + return la.kind == Tokens.Identifier && la.val == "set"; + } + + /* True, if lookahead ident is "add" */ + bool IdentIsAdd () { + return la.kind == Tokens.Identifier && la.val == "add"; + } + + /* True, if lookahead ident is "remove" */ + bool IdentIsRemove () { + return la.kind == Tokens.Identifier && la.val == "remove"; + } + + bool IsNotYieldStatement () { + return !IsYieldStatement(); + } + /* True, if lookahead ident is "yield" and than follows a break or return */ + bool IsYieldStatement () { + return la.kind == Tokens.Identifier && la.val == "yield" && (Peek(1).kind == Tokens.Return || Peek(1).kind == Tokens.Break); + } + + /* True, if lookahead is a local attribute target specifier, * + * i.e. one of "event", "return", "field", "method", * + * "module", "param", "property", or "type" */ + bool IsLocalAttrTarget () { + int cur = la.kind; + string val = la.val; + + return (cur == Tokens.Event || cur == Tokens.Return || + (cur == Tokens.Identifier && + (val == "field" || val == "method" || val == "module" || + val == "param" || val == "property" || val == "type"))) && + Peek(1).kind == Tokens.Colon; + } + + bool IsShiftRight() + { + Token next = Peek(1); + // TODO : Add col test (seems not to work, lexer bug...) : && la.col == next.col - 1 + return (la.kind == Tokens.GreaterThan && next.kind == Tokens.GreaterThan); + } + + bool IsTypeReferenceExpression(Expression expr) + { + if (expr is TypeReferenceExpression) return ((TypeReferenceExpression)expr).TypeReference.GenericTypes.Count == 0; + while (expr is FieldReferenceExpression) { + expr = ((FieldReferenceExpression)expr).TargetObject; + if (expr is TypeReferenceExpression) return true; + } + return expr is IdentifierExpression; + } + + TypeReferenceExpression GetTypeReferenceExpression(Expression expr, List genericTypes) + { + TypeReferenceExpression tre = expr as TypeReferenceExpression; + if (tre != null) { + return new TypeReferenceExpression(new TypeReference(tre.TypeReference.Type, tre.TypeReference.PointerNestingLevel, tre.TypeReference.RankSpecifier, genericTypes)); + } + StringBuilder b = new StringBuilder(); + if (!WriteFullTypeName(b, expr)) { + // there is some TypeReferenceExpression hidden in the expression + while (expr is FieldReferenceExpression) { + expr = ((FieldReferenceExpression)expr).TargetObject; + } + tre = expr as TypeReferenceExpression; + if (tre != null) { + TypeReference typeRef = tre.TypeReference; + if (typeRef.GenericTypes.Count == 0) { + typeRef = typeRef.Clone(); + typeRef.Type += "." + b.ToString(); + typeRef.GenericTypes.AddRange(genericTypes); + } else { + typeRef = new InnerClassTypeReference(typeRef, b.ToString(), genericTypes); + } + return new TypeReferenceExpression(typeRef); + } + } + return new TypeReferenceExpression(new TypeReference(b.ToString(), 0, null, genericTypes)); + } + + /* Writes the type name represented through the expression into the string builder. */ + /* Returns true when the expression was converted successfully, returns false when */ + /* There was an unknown expression (e.g. TypeReferenceExpression) in it */ + bool WriteFullTypeName(StringBuilder b, Expression expr) + { + FieldReferenceExpression fre = expr as FieldReferenceExpression; + if (fre != null) { + bool result = WriteFullTypeName(b, fre.TargetObject); + if (b.Length > 0) b.Append('.'); + b.Append(fre.FieldName); + return result; + } else if (expr is IdentifierExpression) { + b.Append(((IdentifierExpression)expr).Identifier); + return true; + } else { + return false; + } + } + } +} diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index a466bca440..50e11d1713 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -18,7 +18,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp { -internal class Parser : AbstractParser +partial class Parser : AbstractParser { const int maxT = 125; @@ -26,494 +26,7 @@ internal class Parser : AbstractParser const bool x = false; -#line 13 "cs.ATG" -string assemblyName = null; -StringBuilder qualidentBuilder = new StringBuilder(); - -public string ContainingAssembly { - set { - assemblyName = value; - } -} - -Token t { - [System.Diagnostics.DebuggerStepThrough] - get { - return lexer.Token; - } -} - -Token la { - [System.Diagnostics.DebuggerStepThrough] - get { - return lexer.LookAhead; - } -} - -public void Error(string s) -{ - if (errDist >= minErrDist) { - errors.Error(la.line, la.col, s); - } - errDist = 0; -} - -public override Expression ParseExpression() -{ - lexer.NextToken(); - Expression expr; - Expr(out expr); - return expr; -} -// Begin ISTypeCast -bool IsTypeCast() -{ - if (la.kind != Tokens.OpenParenthesis) { - return false; - } - if (IsSimpleTypeCast()) { - return true; - } - return GuessTypeCast(); -} - -// "(" ( typeKW [ "[" {","} "]" | "*" ] | void ( "[" {","} "]" | "*" ) ) ")" -// only for built-in types, all others use GuessTypeCast! -bool IsSimpleTypeCast () -{ - // assert: la.kind == _lpar - lexer.StartPeek(); - Token pt = lexer.Peek(); - - if (!IsTypeKWForTypeCast(ref pt)) { - return false; - } - if (pt.kind == Tokens.Question) - pt = lexer.Peek(); - return pt.kind == Tokens.CloseParenthesis; -} - -/* !!! Proceeds from current peek position !!! */ -bool IsTypeKWForTypeCast(ref Token pt) -{ - if (Tokens.TypeKW[pt.kind]) { - pt = lexer.Peek(); - return IsPointerOrDims(ref pt) && SkipQuestionMark(ref pt); - } else if (pt.kind == Tokens.Void) { - pt = lexer.Peek(); - return IsPointerOrDims(ref pt); - } - return false; -} - -/* !!! Proceeds from current peek position !!! */ -bool IsTypeNameOrKWForTypeCast(ref Token pt) -{ - if (IsTypeKWForTypeCast(ref pt)) - return true; - else - return IsTypeNameForTypeCast(ref pt); -} - -// TypeName = ident [ "::" ident ] { ["<" TypeNameOrKW { "," TypeNameOrKW } ">" ] "." ident } ["?"] PointerOrDims -/* !!! Proceeds from current peek position !!! */ -bool IsTypeNameForTypeCast(ref Token pt) -{ - // ident - if (pt.kind != Tokens.Identifier) { - return false; - } - pt = Peek(); - // "::" ident - if (pt.kind == Tokens.DoubleColon) { - pt = Peek(); - if (pt.kind != Tokens.Identifier) { - return false; - } - pt = Peek(); - } - // { ["<" TypeNameOrKW { "," TypeNameOrKW } ">" ] "." ident } - while (true) { - if (pt.kind == Tokens.LessThan) { - do { - pt = Peek(); - if (!IsTypeNameOrKWForTypeCast(ref pt)) { - return false; - } - } while (pt.kind == Tokens.Comma); - if (pt.kind != Tokens.GreaterThan) { - return false; - } - pt = Peek(); - } - if (pt.kind != Tokens.Dot) - break; - pt = Peek(); - if (pt.kind != Tokens.Identifier) { - return false; - } - pt = Peek(); - } - // ["?"] - if (pt.kind == Tokens.Question) { - pt = Peek(); - } - if (pt.kind == Tokens.Times || pt.kind == Tokens.OpenSquareBracket) { - return IsPointerOrDims(ref pt); - } - return true; -} - -// "(" TypeName ")" castFollower -bool GuessTypeCast () -{ - // assert: la.kind == _lpar - StartPeek(); - Token pt = Peek(); - - if (!IsTypeNameForTypeCast(ref pt)) { - return false; - } - - // ")" - if (pt.kind != Tokens.CloseParenthesis) { - return false; - } - // check successor - pt = Peek(); - return Tokens.CastFollower[pt.kind] || (Tokens.TypeKW[pt.kind] && lexer.Peek().kind == Tokens.Dot); -} -// END IsTypeCast - -/* Checks whether the next sequences of tokens is a qualident * - * and returns the qualident string */ -/* !!! Proceeds from current peek position !!! */ -bool IsQualident(ref Token pt, out string qualident) -{ - if (pt.kind == Tokens.Identifier) { - qualidentBuilder.Length = 0; qualidentBuilder.Append(pt.val); - pt = Peek(); - while (pt.kind == Tokens.Dot || pt.kind == Tokens.DoubleColon) { - pt = Peek(); - if (pt.kind != Tokens.Identifier) { - qualident = String.Empty; - return false; - } - qualidentBuilder.Append('.'); - qualidentBuilder.Append(pt.val); - pt = Peek(); - } - qualident = qualidentBuilder.ToString(); - return true; - } - qualident = String.Empty; - return false; -} - -/* Skips generic type extensions */ -/* !!! Proceeds from current peek position !!! */ - -/* skip: { "*" | "[" { "," } "]" } */ -/* !!! Proceeds from current peek position !!! */ -bool IsPointerOrDims (ref Token pt) -{ - for (;;) { - if (pt.kind == Tokens.OpenSquareBracket) { - do pt = Peek(); - while (pt.kind == Tokens.Comma); - if (pt.kind != Tokens.CloseSquareBracket) return false; - } else if (pt.kind != Tokens.Times) break; - pt = Peek(); - } - return true; -} - -/* Return the n-th token after the current lookahead token */ -void StartPeek() -{ - lexer.StartPeek(); -} - -Token Peek() -{ - return lexer.Peek(); -} - -Token Peek (int n) -{ - lexer.StartPeek(); - Token x = la; - while (n > 0) { - x = lexer.Peek(); - n--; - } - return x; -} - -/*-----------------------------------------------------------------* - * Resolver routines to resolve LL(1) conflicts: * * - * These resolution routine return a boolean value that indicates * - * whether the alternative at hand shall be choosen or not. * - * They are used in IF ( ... ) expressions. * - *-----------------------------------------------------------------*/ - -/* True, if ident is followed by "=" */ -bool IdentAndAsgn () -{ - return la.kind == Tokens.Identifier && Peek(1).kind == Tokens.Assign; -} - -bool IsAssignment () { return IdentAndAsgn(); } - -/* True, if ident is followed by ",", "=", or ";" */ -bool IdentAndCommaOrAsgnOrSColon () { - int peek = Peek(1).kind; - return la.kind == Tokens.Identifier && - (peek == Tokens.Comma || peek == Tokens.Assign || peek == Tokens.Semicolon); -} -bool IsVarDecl () { return IdentAndCommaOrAsgnOrSColon(); } - -/* True, if the comma is not a trailing one, * - * like the last one in: a, b, c, */ -bool NotFinalComma () { - int peek = Peek(1).kind; - return la.kind == Tokens.Comma && - peek != Tokens.CloseCurlyBrace && peek != Tokens.CloseSquareBracket; -} - -/* True, if "void" is followed by "*" */ -bool NotVoidPointer () { - return la.kind == Tokens.Void && Peek(1).kind != Tokens.Times; -} - -/* True, if "checked" or "unchecked" are followed by "{" */ -bool UnCheckedAndLBrace () { - return la.kind == Tokens.Checked || la.kind == Tokens.Unchecked && - Peek(1).kind == Tokens.OpenCurlyBrace; -} - -/* True, if "." is followed by an ident */ -bool DotAndIdent () { - return la.kind == Tokens.Dot && Peek(1).kind == Tokens.Identifier; -} - -/* True, if ident is followed by ":" */ -bool IdentAndColon () { - return la.kind == Tokens.Identifier && Peek(1).kind == Tokens.Colon; -} - -bool IsLabel () { return IdentAndColon(); } - -/* True, if ident is followed by "(" */ -bool IdentAndLPar () { - return la.kind == Tokens.Identifier && Peek(1).kind == Tokens.OpenParenthesis; -} - -/* True, if "catch" is followed by "(" */ -bool CatchAndLPar () { - return la.kind == Tokens.Catch && Peek(1).kind == Tokens.OpenParenthesis; -} -bool IsTypedCatch () { return CatchAndLPar(); } - -/* True, if "[" is followed by the ident "assembly" */ -bool IsGlobalAttrTarget () { - Token pt = Peek(1); - return la.kind == Tokens.OpenSquareBracket && - pt.kind == Tokens.Identifier && pt.val == "assembly"; -} - -/* True, if "[" is followed by "," or "]" */ -bool LBrackAndCommaOrRBrack () { - int peek = Peek(1).kind; - return la.kind == Tokens.OpenSquareBracket && - (peek == Tokens.Comma || peek == Tokens.CloseSquareBracket); -} - -bool IsDims () { return LBrackAndCommaOrRBrack(); } - -/* True, if "[" is followed by "," or "]" */ -/* or if the current token is "*" */ -bool TimesOrLBrackAndCommaOrRBrack () { - return la.kind == Tokens.Times || LBrackAndCommaOrRBrack(); -} -bool IsPointerOrDims () { return TimesOrLBrackAndCommaOrRBrack(); } -bool IsPointer () { return la.kind == Tokens.Times; } - - -bool SkipGeneric(ref Token pt) -{ - if (pt.kind == Tokens.LessThan) { - do { - pt = Peek(); - if (!IsTypeNameOrKWForTypeCast(ref pt)) return false; - } while (pt.kind == Tokens.Comma); - if (pt.kind != Tokens.GreaterThan) return false; - pt = Peek(); - } - return true; -} -bool SkipQuestionMark(ref Token pt) -{ - if (pt.kind == Tokens.Question) { - pt = Peek(); - } - return true; -} - -/* True, if lookahead is a primitive type keyword, or */ -/* if it is a type declaration followed by an ident */ -bool IsLocalVarDecl () { - if (IsYieldStatement()) { - return false; - } - if ((Tokens.TypeKW[la.kind] && Peek(1).kind != Tokens.Dot) || la.kind == Tokens.Void) { - return true; - } - - StartPeek(); - Token pt = la; - return IsTypeNameOrKWForTypeCast(ref pt) && pt.kind == Tokens.Identifier; -} - -/* True if lookahead is type parameters (<...>) followed by the specified token */ -bool IsGenericFollowedBy(int token) -{ - Token t = la; - if (t.kind != Tokens.LessThan) return false; - StartPeek(); - return SkipGeneric(ref t) && t.kind == token; -} - -bool IsExplicitInterfaceImplementation() -{ - StartPeek(); - Token pt = la; - pt = Peek(); - if (pt.kind == Tokens.Dot || pt.kind == Tokens.DoubleColon) - return true; - if (pt.kind == Tokens.LessThan) { - if (SkipGeneric(ref pt)) - return pt.kind == Tokens.Dot; - } - return false; -} - -/* True, if lookahead ident is "where" */ -bool IdentIsWhere () { - return la.kind == Tokens.Identifier && la.val == "where"; -} - -/* True, if lookahead ident is "get" */ -bool IdentIsGet () { - return la.kind == Tokens.Identifier && la.val == "get"; -} - -/* True, if lookahead ident is "set" */ -bool IdentIsSet () { - return la.kind == Tokens.Identifier && la.val == "set"; -} - -/* True, if lookahead ident is "add" */ -bool IdentIsAdd () { - return la.kind == Tokens.Identifier && la.val == "add"; -} - -/* True, if lookahead ident is "remove" */ -bool IdentIsRemove () { - return la.kind == Tokens.Identifier && la.val == "remove"; -} - -bool IsNotYieldStatement () { - return !IsYieldStatement(); -} -/* True, if lookahead ident is "yield" and than follows a break or return */ -bool IsYieldStatement () { - return la.kind == Tokens.Identifier && la.val == "yield" && (Peek(1).kind == Tokens.Return || Peek(1).kind == Tokens.Break); -} - -/* True, if lookahead is a local attribute target specifier, * - * i.e. one of "event", "return", "field", "method", * - * "module", "param", "property", or "type" */ -bool IsLocalAttrTarget () { - int cur = la.kind; - string val = la.val; - - return (cur == Tokens.Event || cur == Tokens.Return || - (cur == Tokens.Identifier && - (val == "field" || val == "method" || val == "module" || - val == "param" || val == "property" || val == "type"))) && - Peek(1).kind == Tokens.Colon; -} - -bool IsShiftRight() -{ - Token next = Peek(1); - // TODO : Add col test (seems not to work, lexer bug...) : && la.col == next.col - 1 - return (la.kind == Tokens.GreaterThan && next.kind == Tokens.GreaterThan); -} - -bool IsTypeReferenceExpression(Expression expr) -{ - if (expr is TypeReferenceExpression) return ((TypeReferenceExpression)expr).TypeReference.GenericTypes.Count == 0; - while (expr is FieldReferenceExpression) { - expr = ((FieldReferenceExpression)expr).TargetObject; - if (expr is TypeReferenceExpression) return true; - } - return expr is IdentifierExpression; -} - -TypeReferenceExpression GetTypeReferenceExpression(Expression expr, List genericTypes) -{ - TypeReferenceExpression tre = expr as TypeReferenceExpression; - if (tre != null) { - return new TypeReferenceExpression(new TypeReference(tre.TypeReference.Type, tre.TypeReference.PointerNestingLevel, tre.TypeReference.RankSpecifier, genericTypes)); - } - StringBuilder b = new StringBuilder(); - if (!WriteFullTypeName(b, expr)) { - // there is some TypeReferenceExpression hidden in the expression - while (expr is FieldReferenceExpression) { - expr = ((FieldReferenceExpression)expr).TargetObject; - } - tre = expr as TypeReferenceExpression; - if (tre != null) { - TypeReference typeRef = tre.TypeReference; - if (typeRef.GenericTypes.Count == 0) { - typeRef = typeRef.Clone(); - typeRef.Type += "." + b.ToString(); - typeRef.GenericTypes.AddRange(genericTypes); - } else { - typeRef = new InnerClassTypeReference(typeRef, b.ToString(), genericTypes); - } - return new TypeReferenceExpression(typeRef); - } - } - return new TypeReferenceExpression(new TypeReference(b.ToString(), 0, null, genericTypes)); -} - -/* Writes the type name represented through the expression into the string builder. */ -/* Returns true when the expression was converted successfully, returns false when */ -/* There was an unknown expression (e.g. TypeReferenceExpression) in it */ -bool WriteFullTypeName(StringBuilder b, Expression expr) -{ - FieldReferenceExpression fre = expr as FieldReferenceExpression; - if (fre != null) { - bool result = WriteFullTypeName(b, fre.TargetObject); - if (b.Length > 0) b.Append('.'); - b.Append(fre.FieldName); - return result; - } else if (expr is IdentifierExpression) { - b.Append(((IdentifierExpression)expr).Identifier); - return true; - } else { - return false; - } -} - -/*------------------------------------------------------------------------* - *----- LEXER TOKEN LIST ------------------------------------------------* - *------------------------------------------------------------------------*/ - -/* START AUTOGENERATED TOKENS SECTION */ +#line 18 "cs.ATG" /* @@ -522,14 +35,14 @@ bool WriteFullTypeName(StringBuilder b, Expression expr) void CS() { -#line 641 "cs.ATG" +#line 159 "cs.ATG" lexer.NextToken(); /* get the first token */ compilationUnit = new CompilationUnit(); while (la.kind == 120) { UsingDirective(); } while ( -#line 645 "cs.ATG" +#line 163 "cs.ATG" IsGlobalAttrTarget()) { GlobalAttributeSection(); } @@ -541,25 +54,25 @@ IsGlobalAttrTarget()) { void UsingDirective() { -#line 652 "cs.ATG" +#line 170 "cs.ATG" string qualident = null; TypeReference aliasedType = null; Expect(120); -#line 655 "cs.ATG" +#line 173 "cs.ATG" Location startPos = t.Location; Qualident( -#line 656 "cs.ATG" +#line 174 "cs.ATG" out qualident); if (la.kind == 3) { lexer.NextToken(); NonArrayType( -#line 657 "cs.ATG" +#line 175 "cs.ATG" out aliasedType); } Expect(11); -#line 659 "cs.ATG" +#line 177 "cs.ATG" if (qualident != null && qualident.Length > 0) { INode node; if (aliasedType != null) { @@ -577,11 +90,11 @@ out aliasedType); void GlobalAttributeSection() { Expect(18); -#line 675 "cs.ATG" +#line 193 "cs.ATG" Location startPos = t.Location; Expect(1); -#line 676 "cs.ATG" +#line 194 "cs.ATG" if (t.val != "assembly") Error("global attribute target specifier (\"assembly\") expected"); string attributeTarget = t.val; List attributes = new List(); @@ -589,20 +102,20 @@ out aliasedType); Expect(9); Attribute( -#line 681 "cs.ATG" +#line 199 "cs.ATG" out attribute); -#line 681 "cs.ATG" +#line 199 "cs.ATG" attributes.Add(attribute); while ( -#line 682 "cs.ATG" +#line 200 "cs.ATG" NotFinalComma()) { Expect(14); Attribute( -#line 682 "cs.ATG" +#line 200 "cs.ATG" out attribute); -#line 682 "cs.ATG" +#line 200 "cs.ATG" attributes.Add(attribute); } if (la.kind == 14) { @@ -610,7 +123,7 @@ out attribute); } Expect(19); -#line 684 "cs.ATG" +#line 202 "cs.ATG" AttributeSection section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -620,7 +133,7 @@ out attribute); void NamespaceMemberDecl() { -#line 775 "cs.ATG" +#line 293 "cs.ATG" AttributeSection section; List attributes = new List(); Modifiers m = new Modifiers(); @@ -629,13 +142,13 @@ out attribute); if (la.kind == 87) { lexer.NextToken(); -#line 781 "cs.ATG" +#line 299 "cs.ATG" Location startPos = t.Location; Qualident( -#line 782 "cs.ATG" +#line 300 "cs.ATG" out qualident); -#line 782 "cs.ATG" +#line 300 "cs.ATG" INode node = new NamespaceDeclaration(qualident); node.StartLocation = startPos; compilationUnit.AddChild(node); @@ -653,139 +166,139 @@ out qualident); lexer.NextToken(); } -#line 791 "cs.ATG" +#line 309 "cs.ATG" node.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); } else if (StartOf(2)) { while (la.kind == 18) { AttributeSection( -#line 795 "cs.ATG" +#line 313 "cs.ATG" out section); -#line 795 "cs.ATG" +#line 313 "cs.ATG" attributes.Add(section); } while (StartOf(3)) { TypeModifier( -#line 796 "cs.ATG" +#line 314 "cs.ATG" m); } TypeDecl( -#line 797 "cs.ATG" +#line 315 "cs.ATG" m, attributes); } else SynErr(126); } void Qualident( -#line 919 "cs.ATG" +#line 437 "cs.ATG" out string qualident) { Expect(1); -#line 921 "cs.ATG" +#line 439 "cs.ATG" qualidentBuilder.Length = 0; qualidentBuilder.Append(t.val); while ( -#line 922 "cs.ATG" +#line 440 "cs.ATG" DotAndIdent()) { Expect(15); Expect(1); -#line 922 "cs.ATG" +#line 440 "cs.ATG" qualidentBuilder.Append('.'); qualidentBuilder.Append(t.val); } -#line 925 "cs.ATG" +#line 443 "cs.ATG" qualident = qualidentBuilder.ToString(); } void NonArrayType( -#line 1034 "cs.ATG" +#line 552 "cs.ATG" out TypeReference type) { -#line 1036 "cs.ATG" +#line 554 "cs.ATG" string name; int pointer = 0; type = null; if (la.kind == 1 || la.kind == 90 || la.kind == 107) { ClassType( -#line 1041 "cs.ATG" +#line 559 "cs.ATG" out type, false); } else if (StartOf(4)) { SimpleType( -#line 1042 "cs.ATG" +#line 560 "cs.ATG" out name); -#line 1042 "cs.ATG" +#line 560 "cs.ATG" type = new TypeReference(name); } else if (la.kind == 122) { lexer.NextToken(); Expect(6); -#line 1043 "cs.ATG" +#line 561 "cs.ATG" pointer = 1; type = new TypeReference("void"); } else SynErr(127); if (la.kind == 12) { NullableQuestionMark( -#line 1046 "cs.ATG" +#line 564 "cs.ATG" ref type); } while ( -#line 1048 "cs.ATG" +#line 566 "cs.ATG" IsPointer()) { Expect(6); -#line 1049 "cs.ATG" +#line 567 "cs.ATG" ++pointer; } -#line 1051 "cs.ATG" +#line 569 "cs.ATG" if (type != null) { type.PointerNestingLevel = pointer; } } void Attribute( -#line 691 "cs.ATG" +#line 209 "cs.ATG" out ASTAttribute attribute) { -#line 692 "cs.ATG" +#line 210 "cs.ATG" string qualident; string alias = null; if ( -#line 696 "cs.ATG" +#line 214 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { lexer.NextToken(); -#line 697 "cs.ATG" +#line 215 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 700 "cs.ATG" +#line 218 "cs.ATG" out qualident); -#line 701 "cs.ATG" +#line 219 "cs.ATG" List positional = new List(); List named = new List(); string name = (alias != null && alias != "global") ? alias + "." + qualident : qualident; if (la.kind == 20) { AttributeArguments( -#line 705 "cs.ATG" +#line 223 "cs.ATG" positional, named); } -#line 705 "cs.ATG" +#line 223 "cs.ATG" attribute = new ICSharpCode.NRefactory.Parser.AST.Attribute(name, positional, named); } void AttributeArguments( -#line 708 "cs.ATG" +#line 226 "cs.ATG" List positional, List named) { -#line 710 "cs.ATG" +#line 228 "cs.ATG" bool nameFound = false; string name = ""; Expression expr; @@ -793,22 +306,22 @@ List positional, List named) { Expect(20); if (StartOf(5)) { if ( -#line 718 "cs.ATG" +#line 236 "cs.ATG" IsAssignment()) { -#line 718 "cs.ATG" +#line 236 "cs.ATG" nameFound = true; lexer.NextToken(); -#line 719 "cs.ATG" +#line 237 "cs.ATG" name = t.val; Expect(3); } Expr( -#line 721 "cs.ATG" +#line 239 "cs.ATG" out expr); -#line 721 "cs.ATG" +#line 239 "cs.ATG" if (expr != null) {if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -816,26 +329,26 @@ out expr); while (la.kind == 14) { lexer.NextToken(); if ( -#line 729 "cs.ATG" +#line 247 "cs.ATG" IsAssignment()) { -#line 729 "cs.ATG" +#line 247 "cs.ATG" nameFound = true; Expect(1); -#line 730 "cs.ATG" +#line 248 "cs.ATG" name = t.val; Expect(3); } else if (StartOf(5)) { -#line 732 "cs.ATG" +#line 250 "cs.ATG" if (nameFound) Error("no positional argument after named argument"); } else SynErr(128); Expr( -#line 733 "cs.ATG" +#line 251 "cs.ATG" out expr); -#line 733 "cs.ATG" +#line 251 "cs.ATG" if (expr != null) { if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -846,70 +359,70 @@ out expr); } void Expr( -#line 2075 "cs.ATG" +#line 1593 "cs.ATG" out Expression expr) { -#line 2076 "cs.ATG" +#line 1594 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; UnaryExpr( -#line 2078 "cs.ATG" +#line 1596 "cs.ATG" out expr); if (StartOf(6)) { AssignmentOperator( -#line 2081 "cs.ATG" +#line 1599 "cs.ATG" out op); Expr( -#line 2081 "cs.ATG" +#line 1599 "cs.ATG" out expr1); -#line 2081 "cs.ATG" +#line 1599 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if ( -#line 2082 "cs.ATG" +#line 1600 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { AssignmentOperator( -#line 2083 "cs.ATG" +#line 1601 "cs.ATG" out op); Expr( -#line 2083 "cs.ATG" +#line 1601 "cs.ATG" out expr1); -#line 2083 "cs.ATG" +#line 1601 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if (StartOf(7)) { ConditionalOrExpr( -#line 2085 "cs.ATG" +#line 1603 "cs.ATG" ref expr); if (la.kind == 13) { lexer.NextToken(); Expr( -#line 2086 "cs.ATG" +#line 1604 "cs.ATG" out expr1); -#line 2086 "cs.ATG" +#line 1604 "cs.ATG" expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); } if (la.kind == 12) { lexer.NextToken(); Expr( -#line 2087 "cs.ATG" +#line 1605 "cs.ATG" out expr1); Expect(9); Expr( -#line 2087 "cs.ATG" +#line 1605 "cs.ATG" out expr2); -#line 2087 "cs.ATG" +#line 1605 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else SynErr(129); } void AttributeSection( -#line 742 "cs.ATG" +#line 260 "cs.ATG" out AttributeSection section) { -#line 744 "cs.ATG" +#line 262 "cs.ATG" string attributeTarget = ""; List attributes = new List(); ASTAttribute attribute; @@ -917,25 +430,25 @@ out AttributeSection section) { Expect(18); -#line 750 "cs.ATG" +#line 268 "cs.ATG" Location startPos = t.Location; if ( -#line 751 "cs.ATG" +#line 269 "cs.ATG" IsLocalAttrTarget()) { if (la.kind == 68) { lexer.NextToken(); -#line 752 "cs.ATG" +#line 270 "cs.ATG" attributeTarget = "event"; } else if (la.kind == 100) { lexer.NextToken(); -#line 753 "cs.ATG" +#line 271 "cs.ATG" attributeTarget = "return"; } else { lexer.NextToken(); -#line 754 "cs.ATG" +#line 272 "cs.ATG" if (t.val != "field" || t.val != "method" || t.val != "module" || t.val != "param" || t.val != "property" || t.val != "type") @@ -947,20 +460,20 @@ IsLocalAttrTarget()) { Expect(9); } Attribute( -#line 764 "cs.ATG" +#line 282 "cs.ATG" out attribute); -#line 764 "cs.ATG" +#line 282 "cs.ATG" attributes.Add(attribute); while ( -#line 765 "cs.ATG" +#line 283 "cs.ATG" NotFinalComma()) { Expect(14); Attribute( -#line 765 "cs.ATG" +#line 283 "cs.ATG" out attribute); -#line 765 "cs.ATG" +#line 283 "cs.ATG" attributes.Add(attribute); } if (la.kind == 14) { @@ -968,7 +481,7 @@ out attribute); } Expect(19); -#line 767 "cs.ATG" +#line 285 "cs.ATG" section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -976,76 +489,76 @@ out attribute); } void TypeModifier( -#line 1121 "cs.ATG" +#line 639 "cs.ATG" Modifiers m) { switch (la.kind) { case 88: { lexer.NextToken(); -#line 1123 "cs.ATG" +#line 641 "cs.ATG" m.Add(Modifier.New, t.Location); break; } case 97: { lexer.NextToken(); -#line 1124 "cs.ATG" +#line 642 "cs.ATG" m.Add(Modifier.Public, t.Location); break; } case 96: { lexer.NextToken(); -#line 1125 "cs.ATG" +#line 643 "cs.ATG" m.Add(Modifier.Protected, t.Location); break; } case 83: { lexer.NextToken(); -#line 1126 "cs.ATG" +#line 644 "cs.ATG" m.Add(Modifier.Internal, t.Location); break; } case 95: { lexer.NextToken(); -#line 1127 "cs.ATG" +#line 645 "cs.ATG" m.Add(Modifier.Private, t.Location); break; } case 118: { lexer.NextToken(); -#line 1128 "cs.ATG" +#line 646 "cs.ATG" m.Add(Modifier.Unsafe, t.Location); break; } case 48: { lexer.NextToken(); -#line 1129 "cs.ATG" +#line 647 "cs.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 102: { lexer.NextToken(); -#line 1130 "cs.ATG" +#line 648 "cs.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 106: { lexer.NextToken(); -#line 1131 "cs.ATG" +#line 649 "cs.ATG" m.Add(Modifier.Static, t.Location); break; } case 1: { lexer.NextToken(); -#line 1132 "cs.ATG" +#line 650 "cs.ATG" if (t.val == "partial") { m.Add(Modifier.Partial, t.Location); } else { Error("Unexpected identifier"); } break; } @@ -1054,10 +567,10 @@ Modifiers m) { } void TypeDecl( -#line 800 "cs.ATG" +#line 318 "cs.ATG" Modifiers m, List attributes) { -#line 802 "cs.ATG" +#line 320 "cs.ATG" TypeReference type; List names; List p = new List(); @@ -1066,11 +579,11 @@ Modifiers m, List attributes) { if (la.kind == 58) { -#line 808 "cs.ATG" +#line 326 "cs.ATG" m.Check(Modifier.Classes); lexer.NextToken(); -#line 809 "cs.ATG" +#line 327 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; compilationUnit.AddChild(newType); @@ -1081,48 +594,48 @@ Modifiers m, List attributes) { Expect(1); -#line 817 "cs.ATG" +#line 335 "cs.ATG" newType.Name = t.val; if (la.kind == 23) { TypeParameterList( -#line 820 "cs.ATG" +#line 338 "cs.ATG" templates); } if (la.kind == 9) { ClassBase( -#line 822 "cs.ATG" +#line 340 "cs.ATG" out names); -#line 822 "cs.ATG" +#line 340 "cs.ATG" newType.BaseTypes = names; } while ( -#line 825 "cs.ATG" +#line 343 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 825 "cs.ATG" +#line 343 "cs.ATG" templates); } -#line 827 "cs.ATG" +#line 345 "cs.ATG" newType.BodyStartLocation = t.EndLocation; ClassBody(); if (la.kind == 11) { lexer.NextToken(); } -#line 829 "cs.ATG" +#line 347 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (StartOf(8)) { -#line 832 "cs.ATG" +#line 350 "cs.ATG" m.Check(Modifier.StructsInterfacesEnumsDelegates); if (la.kind == 108) { lexer.NextToken(); -#line 833 "cs.ATG" +#line 351 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; newType.StartLocation = m.GetDeclarationLocation(t.Location); @@ -1132,44 +645,44 @@ templates); Expect(1); -#line 840 "cs.ATG" +#line 358 "cs.ATG" newType.Name = t.val; if (la.kind == 23) { TypeParameterList( -#line 843 "cs.ATG" +#line 361 "cs.ATG" templates); } if (la.kind == 9) { StructInterfaces( -#line 845 "cs.ATG" +#line 363 "cs.ATG" out names); -#line 845 "cs.ATG" +#line 363 "cs.ATG" newType.BaseTypes = names; } while ( -#line 848 "cs.ATG" +#line 366 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 848 "cs.ATG" +#line 366 "cs.ATG" templates); } -#line 851 "cs.ATG" +#line 369 "cs.ATG" newType.BodyStartLocation = t.EndLocation; StructBody(); if (la.kind == 11) { lexer.NextToken(); } -#line 853 "cs.ATG" +#line 371 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (la.kind == 82) { lexer.NextToken(); -#line 857 "cs.ATG" +#line 375 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; compilationUnit.AddChild(newType); @@ -1179,44 +692,44 @@ templates); Expect(1); -#line 864 "cs.ATG" +#line 382 "cs.ATG" newType.Name = t.val; if (la.kind == 23) { TypeParameterList( -#line 867 "cs.ATG" +#line 385 "cs.ATG" templates); } if (la.kind == 9) { InterfaceBase( -#line 869 "cs.ATG" +#line 387 "cs.ATG" out names); -#line 869 "cs.ATG" +#line 387 "cs.ATG" newType.BaseTypes = names; } while ( -#line 872 "cs.ATG" +#line 390 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 872 "cs.ATG" +#line 390 "cs.ATG" templates); } -#line 874 "cs.ATG" +#line 392 "cs.ATG" newType.BodyStartLocation = t.EndLocation; InterfaceBody(); if (la.kind == 11) { lexer.NextToken(); } -#line 876 "cs.ATG" +#line 394 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (la.kind == 67) { lexer.NextToken(); -#line 880 "cs.ATG" +#line 398 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); @@ -1225,81 +738,81 @@ templates); Expect(1); -#line 886 "cs.ATG" +#line 404 "cs.ATG" newType.Name = t.val; if (la.kind == 9) { lexer.NextToken(); IntegralType( -#line 887 "cs.ATG" +#line 405 "cs.ATG" out name); -#line 887 "cs.ATG" +#line 405 "cs.ATG" newType.BaseTypes.Add(new TypeReference(name)); } -#line 889 "cs.ATG" +#line 407 "cs.ATG" newType.BodyStartLocation = t.EndLocation; EnumBody(); if (la.kind == 11) { lexer.NextToken(); } -#line 891 "cs.ATG" +#line 409 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else { lexer.NextToken(); -#line 895 "cs.ATG" +#line 413 "cs.ATG" DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); templates = delegateDeclr.Templates; delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location); if ( -#line 899 "cs.ATG" +#line 417 "cs.ATG" NotVoidPointer()) { Expect(122); -#line 899 "cs.ATG" +#line 417 "cs.ATG" delegateDeclr.ReturnType = new TypeReference("void", 0, null); } else if (StartOf(9)) { Type( -#line 900 "cs.ATG" +#line 418 "cs.ATG" out type); -#line 900 "cs.ATG" +#line 418 "cs.ATG" delegateDeclr.ReturnType = type; } else SynErr(131); Expect(1); -#line 902 "cs.ATG" +#line 420 "cs.ATG" delegateDeclr.Name = t.val; if (la.kind == 23) { TypeParameterList( -#line 905 "cs.ATG" +#line 423 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 907 "cs.ATG" +#line 425 "cs.ATG" p); -#line 907 "cs.ATG" +#line 425 "cs.ATG" delegateDeclr.Parameters = p; } Expect(21); while ( -#line 911 "cs.ATG" +#line 429 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 911 "cs.ATG" +#line 429 "cs.ATG" templates); } Expect(11); -#line 913 "cs.ATG" +#line 431 "cs.ATG" delegateDeclr.EndLocation = t.Location; compilationUnit.AddChild(delegateDeclr); @@ -1308,90 +821,90 @@ templates); } void TypeParameterList( -#line 2476 "cs.ATG" +#line 1994 "cs.ATG" List templates) { -#line 2478 "cs.ATG" +#line 1996 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(23); while (la.kind == 18) { AttributeSection( -#line 2482 "cs.ATG" +#line 2000 "cs.ATG" out section); -#line 2482 "cs.ATG" +#line 2000 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2483 "cs.ATG" +#line 2001 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 14) { lexer.NextToken(); while (la.kind == 18) { AttributeSection( -#line 2484 "cs.ATG" +#line 2002 "cs.ATG" out section); -#line 2484 "cs.ATG" +#line 2002 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2485 "cs.ATG" +#line 2003 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(22); } void ClassBase( -#line 928 "cs.ATG" +#line 446 "cs.ATG" out List names) { -#line 930 "cs.ATG" +#line 448 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); ClassType( -#line 934 "cs.ATG" +#line 452 "cs.ATG" out typeRef, false); -#line 934 "cs.ATG" +#line 452 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 14) { lexer.NextToken(); TypeName( -#line 935 "cs.ATG" +#line 453 "cs.ATG" out typeRef, false); -#line 935 "cs.ATG" +#line 453 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } void TypeParameterConstraintsClause( -#line 2489 "cs.ATG" +#line 2007 "cs.ATG" List templates) { -#line 2490 "cs.ATG" +#line 2008 "cs.ATG" string name = ""; TypeReference type; Expect(1); -#line 2492 "cs.ATG" +#line 2010 "cs.ATG" if (t.val != "where") Error("where expected"); Expect(1); -#line 2493 "cs.ATG" +#line 2011 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2495 "cs.ATG" +#line 2013 "cs.ATG" out type); -#line 2496 "cs.ATG" +#line 2014 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1404,10 +917,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2505 "cs.ATG" +#line 2023 "cs.ATG" out type); -#line 2506 "cs.ATG" +#line 2024 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1422,110 +935,110 @@ out type); void ClassBody() { -#line 939 "cs.ATG" +#line 457 "cs.ATG" AttributeSection section; Expect(16); while (StartOf(11)) { -#line 942 "cs.ATG" +#line 460 "cs.ATG" List attributes = new List(); Modifiers m = new Modifiers(); while (la.kind == 18) { AttributeSection( -#line 945 "cs.ATG" +#line 463 "cs.ATG" out section); -#line 945 "cs.ATG" +#line 463 "cs.ATG" attributes.Add(section); } MemberModifiers( -#line 946 "cs.ATG" +#line 464 "cs.ATG" m); ClassMemberDecl( -#line 947 "cs.ATG" +#line 465 "cs.ATG" m, attributes); } Expect(17); } void StructInterfaces( -#line 952 "cs.ATG" +#line 470 "cs.ATG" out List names) { -#line 954 "cs.ATG" +#line 472 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); TypeName( -#line 958 "cs.ATG" +#line 476 "cs.ATG" out typeRef, false); -#line 958 "cs.ATG" +#line 476 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 14) { lexer.NextToken(); TypeName( -#line 959 "cs.ATG" +#line 477 "cs.ATG" out typeRef, false); -#line 959 "cs.ATG" +#line 477 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } void StructBody() { -#line 963 "cs.ATG" +#line 481 "cs.ATG" AttributeSection section; Expect(16); while (StartOf(12)) { -#line 966 "cs.ATG" +#line 484 "cs.ATG" List attributes = new List(); Modifiers m = new Modifiers(); while (la.kind == 18) { AttributeSection( -#line 969 "cs.ATG" +#line 487 "cs.ATG" out section); -#line 969 "cs.ATG" +#line 487 "cs.ATG" attributes.Add(section); } MemberModifiers( -#line 970 "cs.ATG" +#line 488 "cs.ATG" m); StructMemberDecl( -#line 971 "cs.ATG" +#line 489 "cs.ATG" m, attributes); } Expect(17); } void InterfaceBase( -#line 976 "cs.ATG" +#line 494 "cs.ATG" out List names) { -#line 978 "cs.ATG" +#line 496 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); TypeName( -#line 982 "cs.ATG" +#line 500 "cs.ATG" out typeRef, false); -#line 982 "cs.ATG" +#line 500 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 14) { lexer.NextToken(); TypeName( -#line 983 "cs.ATG" +#line 501 "cs.ATG" out typeRef, false); -#line 983 "cs.ATG" +#line 501 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } @@ -1539,72 +1052,72 @@ out typeRef, false); } void IntegralType( -#line 1143 "cs.ATG" +#line 661 "cs.ATG" out string name) { -#line 1143 "cs.ATG" +#line 661 "cs.ATG" name = ""; switch (la.kind) { case 101: { lexer.NextToken(); -#line 1145 "cs.ATG" +#line 663 "cs.ATG" name = "sbyte"; break; } case 53: { lexer.NextToken(); -#line 1146 "cs.ATG" +#line 664 "cs.ATG" name = "byte"; break; } case 103: { lexer.NextToken(); -#line 1147 "cs.ATG" +#line 665 "cs.ATG" name = "short"; break; } case 119: { lexer.NextToken(); -#line 1148 "cs.ATG" +#line 666 "cs.ATG" name = "ushort"; break; } case 81: { lexer.NextToken(); -#line 1149 "cs.ATG" +#line 667 "cs.ATG" name = "int"; break; } case 115: { lexer.NextToken(); -#line 1150 "cs.ATG" +#line 668 "cs.ATG" name = "uint"; break; } case 86: { lexer.NextToken(); -#line 1151 "cs.ATG" +#line 669 "cs.ATG" name = "long"; break; } case 116: { lexer.NextToken(); -#line 1152 "cs.ATG" +#line 670 "cs.ATG" name = "ulong"; break; } case 56: { lexer.NextToken(); -#line 1153 "cs.ATG" +#line 671 "cs.ATG" name = "char"; break; } @@ -1614,25 +1127,25 @@ out string name) { void EnumBody() { -#line 992 "cs.ATG" +#line 510 "cs.ATG" FieldDeclaration f; Expect(16); if (la.kind == 1 || la.kind == 18) { EnumMemberDecl( -#line 995 "cs.ATG" +#line 513 "cs.ATG" out f); -#line 995 "cs.ATG" +#line 513 "cs.ATG" compilationUnit.AddChild(f); while ( -#line 996 "cs.ATG" +#line 514 "cs.ATG" NotFinalComma()) { Expect(14); EnumMemberDecl( -#line 997 "cs.ATG" +#line 515 "cs.ATG" out f); -#line 997 "cs.ATG" +#line 515 "cs.ATG" compilationUnit.AddChild(f); } if (la.kind == 14) { @@ -1643,36 +1156,36 @@ out f); } void Type( -#line 1002 "cs.ATG" +#line 520 "cs.ATG" out TypeReference type) { TypeWithRestriction( -#line 1004 "cs.ATG" +#line 522 "cs.ATG" out type, true, false); } void FormalParameterList( -#line 1065 "cs.ATG" +#line 583 "cs.ATG" List parameter) { -#line 1068 "cs.ATG" +#line 586 "cs.ATG" ParameterDeclarationExpression p; AttributeSection section; List attributes = new List(); while (la.kind == 18) { AttributeSection( -#line 1073 "cs.ATG" +#line 591 "cs.ATG" out section); -#line 1073 "cs.ATG" +#line 591 "cs.ATG" attributes.Add(section); } if (StartOf(14)) { FixedParameter( -#line 1075 "cs.ATG" +#line 593 "cs.ATG" out p); -#line 1075 "cs.ATG" +#line 593 "cs.ATG" bool paramsFound = false; p.Attributes = attributes; parameter.Add(p); @@ -1680,96 +1193,96 @@ out p); while (la.kind == 14) { lexer.NextToken(); -#line 1080 "cs.ATG" +#line 598 "cs.ATG" attributes = new List(); if (paramsFound) Error("params array must be at end of parameter list"); while (la.kind == 18) { AttributeSection( -#line 1081 "cs.ATG" +#line 599 "cs.ATG" out section); -#line 1081 "cs.ATG" +#line 599 "cs.ATG" attributes.Add(section); } if (StartOf(14)) { FixedParameter( -#line 1083 "cs.ATG" +#line 601 "cs.ATG" out p); -#line 1083 "cs.ATG" +#line 601 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else if (la.kind == 94) { ParameterArray( -#line 1084 "cs.ATG" +#line 602 "cs.ATG" out p); -#line 1084 "cs.ATG" +#line 602 "cs.ATG" paramsFound = true; p.Attributes = attributes; parameter.Add(p); } else SynErr(134); } } else if (la.kind == 94) { ParameterArray( -#line 1087 "cs.ATG" +#line 605 "cs.ATG" out p); -#line 1087 "cs.ATG" +#line 605 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else SynErr(135); } void ClassType( -#line 1135 "cs.ATG" +#line 653 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 1136 "cs.ATG" +#line 654 "cs.ATG" TypeReference r; typeRef = null; if (la.kind == 1) { TypeName( -#line 1138 "cs.ATG" +#line 656 "cs.ATG" out r, canBeUnbound); -#line 1138 "cs.ATG" +#line 656 "cs.ATG" typeRef = r; } else if (la.kind == 90) { lexer.NextToken(); -#line 1139 "cs.ATG" +#line 657 "cs.ATG" typeRef = new TypeReference("object"); } else if (la.kind == 107) { lexer.NextToken(); -#line 1140 "cs.ATG" +#line 658 "cs.ATG" typeRef = new TypeReference("string"); } else SynErr(136); } void TypeName( -#line 2419 "cs.ATG" +#line 1937 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 2420 "cs.ATG" +#line 1938 "cs.ATG" List typeArguments = null; string alias = null; string qualident; if ( -#line 2425 "cs.ATG" +#line 1943 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { lexer.NextToken(); -#line 2426 "cs.ATG" +#line 1944 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2429 "cs.ATG" +#line 1947 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2430 "cs.ATG" +#line 1948 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2432 "cs.ATG" +#line 1950 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1780,129 +1293,129 @@ out typeArguments, canBeUnbound); } while ( -#line 2441 "cs.ATG" +#line 1959 "cs.ATG" DotAndIdent()) { Expect(15); -#line 2442 "cs.ATG" +#line 1960 "cs.ATG" typeArguments = null; Qualident( -#line 2443 "cs.ATG" +#line 1961 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2444 "cs.ATG" +#line 1962 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2445 "cs.ATG" +#line 1963 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } } void MemberModifiers( -#line 1156 "cs.ATG" +#line 674 "cs.ATG" Modifiers m) { while (StartOf(15) || -#line 1173 "cs.ATG" +#line 691 "cs.ATG" la.kind == Tokens.Identifier && la.val == "partial") { if (la.kind == 48) { lexer.NextToken(); -#line 1159 "cs.ATG" +#line 677 "cs.ATG" m.Add(Modifier.Abstract, t.Location); } else if (la.kind == 70) { lexer.NextToken(); -#line 1160 "cs.ATG" +#line 678 "cs.ATG" m.Add(Modifier.Extern, t.Location); } else if (la.kind == 83) { lexer.NextToken(); -#line 1161 "cs.ATG" +#line 679 "cs.ATG" m.Add(Modifier.Internal, t.Location); } else if (la.kind == 88) { lexer.NextToken(); -#line 1162 "cs.ATG" +#line 680 "cs.ATG" m.Add(Modifier.New, t.Location); } else if (la.kind == 93) { lexer.NextToken(); -#line 1163 "cs.ATG" +#line 681 "cs.ATG" m.Add(Modifier.Override, t.Location); } else if (la.kind == 95) { lexer.NextToken(); -#line 1164 "cs.ATG" +#line 682 "cs.ATG" m.Add(Modifier.Private, t.Location); } else if (la.kind == 96) { lexer.NextToken(); -#line 1165 "cs.ATG" +#line 683 "cs.ATG" m.Add(Modifier.Protected, t.Location); } else if (la.kind == 97) { lexer.NextToken(); -#line 1166 "cs.ATG" +#line 684 "cs.ATG" m.Add(Modifier.Public, t.Location); } else if (la.kind == 98) { lexer.NextToken(); -#line 1167 "cs.ATG" +#line 685 "cs.ATG" m.Add(Modifier.ReadOnly, t.Location); } else if (la.kind == 102) { lexer.NextToken(); -#line 1168 "cs.ATG" +#line 686 "cs.ATG" m.Add(Modifier.Sealed, t.Location); } else if (la.kind == 106) { lexer.NextToken(); -#line 1169 "cs.ATG" +#line 687 "cs.ATG" m.Add(Modifier.Static, t.Location); } else if (la.kind == 118) { lexer.NextToken(); -#line 1170 "cs.ATG" +#line 688 "cs.ATG" m.Add(Modifier.Unsafe, t.Location); } else if (la.kind == 121) { lexer.NextToken(); -#line 1171 "cs.ATG" +#line 689 "cs.ATG" m.Add(Modifier.Virtual, t.Location); } else if (la.kind == 123) { lexer.NextToken(); -#line 1172 "cs.ATG" +#line 690 "cs.ATG" m.Add(Modifier.Volatile, t.Location); } else { Expect(1); -#line 1174 "cs.ATG" +#line 692 "cs.ATG" m.Add(Modifier.Partial, t.Location); } } } void ClassMemberDecl( -#line 1449 "cs.ATG" +#line 967 "cs.ATG" Modifiers m, List attributes) { -#line 1450 "cs.ATG" +#line 968 "cs.ATG" Statement stmt = null; if (StartOf(16)) { StructMemberDecl( -#line 1452 "cs.ATG" +#line 970 "cs.ATG" m, attributes); } else if (la.kind == 27) { -#line 1453 "cs.ATG" +#line 971 "cs.ATG" m.Check(Modifier.Destructors); Location startPos = t.Location; lexer.NextToken(); Expect(1); -#line 1454 "cs.ATG" +#line 972 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = m.GetDeclarationLocation(startPos); @@ -1910,17 +1423,17 @@ m, attributes); Expect(20); Expect(21); -#line 1458 "cs.ATG" +#line 976 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 1458 "cs.ATG" +#line 976 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(137); -#line 1459 "cs.ATG" +#line 977 "cs.ATG" d.Body = (BlockStatement)stmt; compilationUnit.AddChild(d); @@ -1928,10 +1441,10 @@ out stmt); } void StructMemberDecl( -#line 1179 "cs.ATG" +#line 697 "cs.ATG" Modifiers m, List attributes) { -#line 1181 "cs.ATG" +#line 699 "cs.ATG" string qualident = null; TypeReference type; Expression expr; @@ -1943,18 +1456,18 @@ Modifiers m, List attributes) { if (la.kind == 59) { -#line 1191 "cs.ATG" +#line 709 "cs.ATG" m.Check(Modifier.Constants); lexer.NextToken(); -#line 1192 "cs.ATG" +#line 710 "cs.ATG" Location startPos = t.Location; Type( -#line 1193 "cs.ATG" +#line 711 "cs.ATG" out type); Expect(1); -#line 1193 "cs.ATG" +#line 711 "cs.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclaration f = new VariableDeclaration(t.val); @@ -1962,72 +1475,72 @@ out type); Expect(3); Expr( -#line 1198 "cs.ATG" +#line 716 "cs.ATG" out expr); -#line 1198 "cs.ATG" +#line 716 "cs.ATG" f.Initializer = expr; while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1199 "cs.ATG" +#line 717 "cs.ATG" f = new VariableDeclaration(t.val); fd.Fields.Add(f); Expect(3); Expr( -#line 1202 "cs.ATG" +#line 720 "cs.ATG" out expr); -#line 1202 "cs.ATG" +#line 720 "cs.ATG" f.Initializer = expr; } Expect(11); -#line 1203 "cs.ATG" +#line 721 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if ( -#line 1207 "cs.ATG" +#line 725 "cs.ATG" NotVoidPointer()) { -#line 1207 "cs.ATG" +#line 725 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); Expect(122); -#line 1208 "cs.ATG" +#line 726 "cs.ATG" Location startPos = t.Location; if ( -#line 1209 "cs.ATG" +#line 727 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 1210 "cs.ATG" +#line 728 "cs.ATG" out explicitInterface, false); -#line 1211 "cs.ATG" +#line 729 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (la.kind == 1) { lexer.NextToken(); -#line 1214 "cs.ATG" +#line 732 "cs.ATG" qualident = t.val; } else SynErr(139); if (la.kind == 23) { TypeParameterList( -#line 1217 "cs.ATG" +#line 735 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1220 "cs.ATG" +#line 738 "cs.ATG" p); } Expect(21); -#line 1221 "cs.ATG" +#line 739 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, new TypeReference("void"), @@ -2042,31 +1555,31 @@ p); compilationUnit.BlockStart(methodDeclaration); while ( -#line 1236 "cs.ATG" +#line 754 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1236 "cs.ATG" +#line 754 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 1238 "cs.ATG" +#line 756 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(140); -#line 1238 "cs.ATG" +#line 756 "cs.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 68) { -#line 1242 "cs.ATG" +#line 760 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); lexer.NextToken(); -#line 1243 "cs.ATG" +#line 761 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration(null, null, m.Modifier, attributes, null); eventDecl.StartLocation = t.Location; compilationUnit.AddChild(eventDecl); @@ -2075,104 +1588,104 @@ out stmt); EventRemoveRegion removeBlock = null; Type( -#line 1250 "cs.ATG" +#line 768 "cs.ATG" out type); -#line 1250 "cs.ATG" +#line 768 "cs.ATG" eventDecl.TypeReference = type; if ( -#line 1251 "cs.ATG" +#line 769 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 1252 "cs.ATG" +#line 770 "cs.ATG" out explicitInterface, false); -#line 1253 "cs.ATG" +#line 771 "cs.ATG" qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); -#line 1254 "cs.ATG" +#line 772 "cs.ATG" eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); } else if (la.kind == 1) { lexer.NextToken(); -#line 1256 "cs.ATG" +#line 774 "cs.ATG" qualident = t.val; } else SynErr(141); -#line 1258 "cs.ATG" +#line 776 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; if (la.kind == 16) { lexer.NextToken(); -#line 1259 "cs.ATG" +#line 777 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( -#line 1260 "cs.ATG" +#line 778 "cs.ATG" out addBlock, out removeBlock); Expect(17); -#line 1261 "cs.ATG" +#line 779 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } if (la.kind == 11) { lexer.NextToken(); } -#line 1264 "cs.ATG" +#line 782 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( -#line 1270 "cs.ATG" +#line 788 "cs.ATG" IdentAndLPar()) { -#line 1270 "cs.ATG" +#line 788 "cs.ATG" m.Check(Modifier.Constructors | Modifier.StaticConstructors); Expect(1); -#line 1271 "cs.ATG" +#line 789 "cs.ATG" string name = t.val; Location startPos = t.Location; Expect(20); if (StartOf(10)) { -#line 1271 "cs.ATG" +#line 789 "cs.ATG" m.Check(Modifier.Constructors); FormalParameterList( -#line 1272 "cs.ATG" +#line 790 "cs.ATG" p); } Expect(21); -#line 1274 "cs.ATG" +#line 792 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { -#line 1275 "cs.ATG" +#line 793 "cs.ATG" m.Check(Modifier.Constructors); ConstructorInitializer( -#line 1276 "cs.ATG" +#line 794 "cs.ATG" out init); } -#line 1278 "cs.ATG" +#line 796 "cs.ATG" ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 1283 "cs.ATG" +#line 801 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(142); -#line 1283 "cs.ATG" +#line 801 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 69 || la.kind == 79) { -#line 1286 "cs.ATG" +#line 804 "cs.ATG" m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; @@ -2181,45 +1694,45 @@ out stmt); if (la.kind == 79) { lexer.NextToken(); -#line 1291 "cs.ATG" +#line 809 "cs.ATG" startPos = t.Location; } else { lexer.NextToken(); -#line 1291 "cs.ATG" +#line 809 "cs.ATG" isImplicit = false; startPos = t.Location; } Expect(91); Type( -#line 1292 "cs.ATG" +#line 810 "cs.ATG" out type); -#line 1292 "cs.ATG" +#line 810 "cs.ATG" TypeReference operatorType = type; Expect(20); Type( -#line 1293 "cs.ATG" +#line 811 "cs.ATG" out type); Expect(1); -#line 1293 "cs.ATG" +#line 811 "cs.ATG" string varName = t.val; Expect(21); -#line 1294 "cs.ATG" +#line 812 "cs.ATG" Location endPos = t.Location; if (la.kind == 16) { Block( -#line 1295 "cs.ATG" +#line 813 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); -#line 1295 "cs.ATG" +#line 813 "cs.ATG" stmt = null; } else SynErr(143); -#line 1298 "cs.ATG" +#line 816 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier, @@ -2235,61 +1748,61 @@ out stmt); } else if (StartOf(17)) { TypeDecl( -#line 1314 "cs.ATG" +#line 832 "cs.ATG" m, attributes); } else if (StartOf(9)) { Type( -#line 1316 "cs.ATG" +#line 834 "cs.ATG" out type); -#line 1316 "cs.ATG" +#line 834 "cs.ATG" Location startPos = t.Location; if (la.kind == 91) { -#line 1318 "cs.ATG" +#line 836 "cs.ATG" OverloadableOperatorType op; m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( -#line 1322 "cs.ATG" +#line 840 "cs.ATG" out op); -#line 1322 "cs.ATG" +#line 840 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(20); Type( -#line 1323 "cs.ATG" +#line 841 "cs.ATG" out firstType); Expect(1); -#line 1323 "cs.ATG" +#line 841 "cs.ATG" string firstName = t.val; if (la.kind == 14) { lexer.NextToken(); Type( -#line 1324 "cs.ATG" +#line 842 "cs.ATG" out secondType); Expect(1); -#line 1324 "cs.ATG" +#line 842 "cs.ATG" secondName = t.val; } else if (la.kind == 21) { } else SynErr(144); -#line 1332 "cs.ATG" +#line 850 "cs.ATG" Location endPos = t.Location; Expect(21); if (la.kind == 16) { Block( -#line 1333 "cs.ATG" +#line 851 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(145); -#line 1335 "cs.ATG" +#line 853 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { @@ -2306,43 +1819,43 @@ out stmt); compilationUnit.AddChild(operatorDeclaration); } else if ( -#line 1352 "cs.ATG" +#line 870 "cs.ATG" IsVarDecl()) { -#line 1352 "cs.ATG" +#line 870 "cs.ATG" m.Check(Modifier.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclarator( -#line 1356 "cs.ATG" +#line 874 "cs.ATG" variableDeclarators); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 1357 "cs.ATG" +#line 875 "cs.ATG" variableDeclarators); } Expect(11); -#line 1358 "cs.ATG" +#line 876 "cs.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); } else if (la.kind == 110) { -#line 1361 "cs.ATG" +#line 879 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(18); FormalParameterList( -#line 1362 "cs.ATG" +#line 880 "cs.ATG" p); Expect(19); -#line 1362 "cs.ATG" +#line 880 "cs.ATG" Location endLocation = t.EndLocation; Expect(16); -#line 1363 "cs.ATG" +#line 881 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -2351,58 +1864,58 @@ p); PropertySetRegion setRegion; AccessorDecls( -#line 1370 "cs.ATG" +#line 888 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1371 "cs.ATG" +#line 889 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; compilationUnit.AddChild(indexer); } else if ( -#line 1376 "cs.ATG" +#line 894 "cs.ATG" la.kind == Tokens.Identifier) { if ( -#line 1377 "cs.ATG" +#line 895 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 1378 "cs.ATG" +#line 896 "cs.ATG" out explicitInterface, false); -#line 1379 "cs.ATG" +#line 897 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (la.kind == 1) { lexer.NextToken(); -#line 1382 "cs.ATG" +#line 900 "cs.ATG" qualident = t.val; } else SynErr(146); -#line 1384 "cs.ATG" +#line 902 "cs.ATG" Location qualIdentEndLocation = t.EndLocation; if (la.kind == 16 || la.kind == 20 || la.kind == 23) { if (la.kind == 20 || la.kind == 23) { -#line 1388 "cs.ATG" +#line 906 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); if (la.kind == 23) { TypeParameterList( -#line 1390 "cs.ATG" +#line 908 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1391 "cs.ATG" +#line 909 "cs.ATG" p); } Expect(21); -#line 1392 "cs.ATG" +#line 910 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, type, @@ -2416,26 +1929,26 @@ p); compilationUnit.AddChild(methodDeclaration); while ( -#line 1404 "cs.ATG" +#line 922 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1404 "cs.ATG" +#line 922 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 1405 "cs.ATG" +#line 923 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(147); -#line 1405 "cs.ATG" +#line 923 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 1408 "cs.ATG" +#line 926 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); if (explicitInterface != null) pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); @@ -2446,11 +1959,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 1417 "cs.ATG" +#line 935 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1419 "cs.ATG" +#line 937 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2459,17 +1972,17 @@ out getRegion, out setRegion); } } else if (la.kind == 15) { -#line 1427 "cs.ATG" +#line 945 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(110); Expect(18); FormalParameterList( -#line 1428 "cs.ATG" +#line 946 "cs.ATG" p); Expect(19); -#line 1429 "cs.ATG" +#line 947 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; @@ -2480,14 +1993,14 @@ p); Expect(16); -#line 1437 "cs.ATG" +#line 955 "cs.ATG" Location bodyStart = t.Location; AccessorDecls( -#line 1438 "cs.ATG" +#line 956 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1439 "cs.ATG" +#line 957 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2501,7 +2014,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1466 "cs.ATG" +#line 984 "cs.ATG" TypeReference type; AttributeSection section; @@ -2516,51 +2029,51 @@ out getRegion, out setRegion); while (la.kind == 18) { AttributeSection( -#line 1479 "cs.ATG" +#line 997 "cs.ATG" out section); -#line 1479 "cs.ATG" +#line 997 "cs.ATG" attributes.Add(section); } if (la.kind == 88) { lexer.NextToken(); -#line 1480 "cs.ATG" +#line 998 "cs.ATG" mod = Modifier.New; startLocation = t.Location; } if ( -#line 1483 "cs.ATG" +#line 1001 "cs.ATG" NotVoidPointer()) { Expect(122); -#line 1483 "cs.ATG" +#line 1001 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Expect(1); -#line 1483 "cs.ATG" +#line 1001 "cs.ATG" name = t.val; if (la.kind == 23) { TypeParameterList( -#line 1484 "cs.ATG" +#line 1002 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1485 "cs.ATG" +#line 1003 "cs.ATG" parameters); } Expect(21); while ( -#line 1486 "cs.ATG" +#line 1004 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1486 "cs.ATG" +#line 1004 "cs.ATG" templates); } Expect(11); -#line 1488 "cs.ATG" +#line 1006 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2570,39 +2083,39 @@ templates); } else if (StartOf(18)) { if (StartOf(9)) { Type( -#line 1495 "cs.ATG" +#line 1013 "cs.ATG" out type); -#line 1495 "cs.ATG" +#line 1013 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; if (la.kind == 1) { lexer.NextToken(); -#line 1497 "cs.ATG" +#line 1015 "cs.ATG" name = t.val; Location qualIdentEndLocation = t.EndLocation; if (la.kind == 20 || la.kind == 23) { if (la.kind == 23) { TypeParameterList( -#line 1501 "cs.ATG" +#line 1019 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1502 "cs.ATG" +#line 1020 "cs.ATG" parameters); } Expect(21); while ( -#line 1504 "cs.ATG" +#line 1022 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1504 "cs.ATG" +#line 1022 "cs.ATG" templates); } Expect(11); -#line 1505 "cs.ATG" +#line 1023 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2611,72 +2124,72 @@ templates); } else if (la.kind == 16) { -#line 1512 "cs.ATG" +#line 1030 "cs.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); lexer.NextToken(); -#line 1513 "cs.ATG" +#line 1031 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1513 "cs.ATG" +#line 1031 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1513 "cs.ATG" +#line 1031 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(151); } else if (la.kind == 110) { lexer.NextToken(); Expect(18); FormalParameterList( -#line 1516 "cs.ATG" +#line 1034 "cs.ATG" parameters); Expect(19); -#line 1516 "cs.ATG" +#line 1034 "cs.ATG" Location bracketEndLocation = t.EndLocation; -#line 1516 "cs.ATG" +#line 1034 "cs.ATG" IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); Expect(16); -#line 1517 "cs.ATG" +#line 1035 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1517 "cs.ATG" +#line 1035 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1517 "cs.ATG" +#line 1035 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(152); } else { lexer.NextToken(); -#line 1520 "cs.ATG" +#line 1038 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Type( -#line 1520 "cs.ATG" +#line 1038 "cs.ATG" out type); Expect(1); -#line 1520 "cs.ATG" +#line 1038 "cs.ATG" EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes, null); compilationUnit.AddChild(ed); Expect(11); -#line 1523 "cs.ATG" +#line 1041 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(153); } void EnumMemberDecl( -#line 1528 "cs.ATG" +#line 1046 "cs.ATG" out FieldDeclaration f) { -#line 1530 "cs.ATG" +#line 1048 "cs.ATG" Expression expr = null; List attributes = new List(); AttributeSection section = null; @@ -2684,15 +2197,15 @@ out FieldDeclaration f) { while (la.kind == 18) { AttributeSection( -#line 1536 "cs.ATG" +#line 1054 "cs.ATG" out section); -#line 1536 "cs.ATG" +#line 1054 "cs.ATG" attributes.Add(section); } Expect(1); -#line 1537 "cs.ATG" +#line 1055 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2701,78 +2214,78 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1542 "cs.ATG" +#line 1060 "cs.ATG" out expr); -#line 1542 "cs.ATG" +#line 1060 "cs.ATG" varDecl.Initializer = expr; } } void TypeWithRestriction( -#line 1007 "cs.ATG" +#line 525 "cs.ATG" out TypeReference type, bool allowNullable, bool canBeUnbound) { -#line 1009 "cs.ATG" +#line 527 "cs.ATG" string name; int pointer = 0; type = null; if (la.kind == 1 || la.kind == 90 || la.kind == 107) { ClassType( -#line 1014 "cs.ATG" +#line 532 "cs.ATG" out type, canBeUnbound); } else if (StartOf(4)) { SimpleType( -#line 1015 "cs.ATG" +#line 533 "cs.ATG" out name); -#line 1015 "cs.ATG" +#line 533 "cs.ATG" type = new TypeReference(name); } else if (la.kind == 122) { lexer.NextToken(); Expect(6); -#line 1016 "cs.ATG" +#line 534 "cs.ATG" pointer = 1; type = new TypeReference("void"); } else SynErr(154); -#line 1017 "cs.ATG" +#line 535 "cs.ATG" List r = new List(); if ( -#line 1019 "cs.ATG" +#line 537 "cs.ATG" allowNullable && la.kind == Tokens.Question) { NullableQuestionMark( -#line 1019 "cs.ATG" +#line 537 "cs.ATG" ref type); } while ( -#line 1021 "cs.ATG" +#line 539 "cs.ATG" IsPointerOrDims()) { -#line 1021 "cs.ATG" +#line 539 "cs.ATG" int i = 0; if (la.kind == 6) { lexer.NextToken(); -#line 1022 "cs.ATG" +#line 540 "cs.ATG" ++pointer; } else if (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 1023 "cs.ATG" +#line 541 "cs.ATG" ++i; } Expect(19); -#line 1023 "cs.ATG" +#line 541 "cs.ATG" r.Add(i); } else SynErr(155); } -#line 1026 "cs.ATG" +#line 544 "cs.ATG" if (type != null) { type.RankSpecifier = r.ToArray(); type.PointerNestingLevel = pointer; @@ -2781,57 +2294,57 @@ IsPointerOrDims()) { } void SimpleType( -#line 1054 "cs.ATG" +#line 572 "cs.ATG" out string name) { -#line 1055 "cs.ATG" +#line 573 "cs.ATG" name = String.Empty; if (StartOf(19)) { IntegralType( -#line 1057 "cs.ATG" +#line 575 "cs.ATG" out name); } else if (la.kind == 74) { lexer.NextToken(); -#line 1058 "cs.ATG" +#line 576 "cs.ATG" name = "float"; } else if (la.kind == 65) { lexer.NextToken(); -#line 1059 "cs.ATG" +#line 577 "cs.ATG" name = "double"; } else if (la.kind == 61) { lexer.NextToken(); -#line 1060 "cs.ATG" +#line 578 "cs.ATG" name = "decimal"; } else if (la.kind == 51) { lexer.NextToken(); -#line 1061 "cs.ATG" +#line 579 "cs.ATG" name = "bool"; } else SynErr(156); } void NullableQuestionMark( -#line 2450 "cs.ATG" +#line 1968 "cs.ATG" ref TypeReference typeRef) { -#line 2451 "cs.ATG" +#line 1969 "cs.ATG" List typeArguments = new List(1); Expect(12); -#line 2455 "cs.ATG" +#line 1973 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments); } void FixedParameter( -#line 1091 "cs.ATG" +#line 609 "cs.ATG" out ParameterDeclarationExpression p) { -#line 1093 "cs.ATG" +#line 611 "cs.ATG" TypeReference type; ParamModifier mod = ParamModifier.In; Location start = t.Location; @@ -2840,93 +2353,93 @@ out ParameterDeclarationExpression p) { if (la.kind == 99) { lexer.NextToken(); -#line 1099 "cs.ATG" +#line 617 "cs.ATG" mod = ParamModifier.Ref; } else { lexer.NextToken(); -#line 1100 "cs.ATG" +#line 618 "cs.ATG" mod = ParamModifier.Out; } } Type( -#line 1102 "cs.ATG" +#line 620 "cs.ATG" out type); Expect(1); -#line 1102 "cs.ATG" +#line 620 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); p.StartLocation = start; p.EndLocation = t.Location; } void ParameterArray( -#line 1105 "cs.ATG" +#line 623 "cs.ATG" out ParameterDeclarationExpression p) { -#line 1106 "cs.ATG" +#line 624 "cs.ATG" TypeReference type; Expect(94); Type( -#line 1108 "cs.ATG" +#line 626 "cs.ATG" out type); Expect(1); -#line 1108 "cs.ATG" +#line 626 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, ParamModifier.Params); } void AccessorModifiers( -#line 1111 "cs.ATG" +#line 629 "cs.ATG" out Modifiers m) { -#line 1112 "cs.ATG" +#line 630 "cs.ATG" m = new Modifiers(); if (la.kind == 95) { lexer.NextToken(); -#line 1114 "cs.ATG" +#line 632 "cs.ATG" m.Add(Modifier.Private, t.Location); } else if (la.kind == 96) { lexer.NextToken(); -#line 1115 "cs.ATG" +#line 633 "cs.ATG" m.Add(Modifier.Protected, t.Location); if (la.kind == 83) { lexer.NextToken(); -#line 1116 "cs.ATG" +#line 634 "cs.ATG" m.Add(Modifier.Internal, t.Location); } } else if (la.kind == 83) { lexer.NextToken(); -#line 1117 "cs.ATG" +#line 635 "cs.ATG" m.Add(Modifier.Internal, t.Location); if (la.kind == 96) { lexer.NextToken(); -#line 1118 "cs.ATG" +#line 636 "cs.ATG" m.Add(Modifier.Protected, t.Location); } } else SynErr(157); } void Block( -#line 1667 "cs.ATG" +#line 1185 "cs.ATG" out Statement stmt) { Expect(16); -#line 1669 "cs.ATG" +#line 1187 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.EndLocation; compilationUnit.BlockStart(blockStmt); - if (!parseMethodContents) lexer.SkipCurrentBlock(); + if (!parseMethodContents) lexer.SkipCurrentBlock(0); while (StartOf(20)) { Statement(); } Expect(17); -#line 1676 "cs.ATG" +#line 1194 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2934,10 +2447,10 @@ out Statement stmt) { } void EventAccessorDecls( -#line 1602 "cs.ATG" +#line 1120 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1603 "cs.ATG" +#line 1121 "cs.ATG" AttributeSection section; List attributes = new List(); Statement stmt; @@ -2946,102 +2459,102 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 18) { AttributeSection( -#line 1610 "cs.ATG" +#line 1128 "cs.ATG" out section); -#line 1610 "cs.ATG" +#line 1128 "cs.ATG" attributes.Add(section); } if ( -#line 1612 "cs.ATG" +#line 1130 "cs.ATG" IdentIsAdd()) { -#line 1612 "cs.ATG" +#line 1130 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1613 "cs.ATG" +#line 1131 "cs.ATG" out stmt); -#line 1613 "cs.ATG" +#line 1131 "cs.ATG" attributes = new List(); addBlock.Block = (BlockStatement)stmt; while (la.kind == 18) { AttributeSection( -#line 1614 "cs.ATG" +#line 1132 "cs.ATG" out section); -#line 1614 "cs.ATG" +#line 1132 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1615 "cs.ATG" +#line 1133 "cs.ATG" out stmt); -#line 1615 "cs.ATG" +#line 1133 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; } else if ( -#line 1616 "cs.ATG" +#line 1134 "cs.ATG" IdentIsRemove()) { RemoveAccessorDecl( -#line 1617 "cs.ATG" +#line 1135 "cs.ATG" out stmt); -#line 1617 "cs.ATG" +#line 1135 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new List(); while (la.kind == 18) { AttributeSection( -#line 1618 "cs.ATG" +#line 1136 "cs.ATG" out section); -#line 1618 "cs.ATG" +#line 1136 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1619 "cs.ATG" +#line 1137 "cs.ATG" out stmt); -#line 1619 "cs.ATG" +#line 1137 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; } else if (la.kind == 1) { lexer.NextToken(); -#line 1620 "cs.ATG" +#line 1138 "cs.ATG" Error("add or remove accessor declaration expected"); } else SynErr(158); } void ConstructorInitializer( -#line 1698 "cs.ATG" +#line 1216 "cs.ATG" out ConstructorInitializer ci) { -#line 1699 "cs.ATG" +#line 1217 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 50) { lexer.NextToken(); -#line 1703 "cs.ATG" +#line 1221 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 110) { lexer.NextToken(); -#line 1704 "cs.ATG" +#line 1222 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(159); Expect(20); if (StartOf(21)) { Argument( -#line 1707 "cs.ATG" +#line 1225 "cs.ATG" out expr); -#line 1707 "cs.ATG" +#line 1225 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1707 "cs.ATG" +#line 1225 "cs.ATG" out expr); -#line 1707 "cs.ATG" +#line 1225 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } } } @@ -3049,161 +2562,161 @@ out expr); } void OverloadableOperator( -#line 1719 "cs.ATG" +#line 1237 "cs.ATG" out OverloadableOperatorType op) { -#line 1720 "cs.ATG" +#line 1238 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1722 "cs.ATG" +#line 1240 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1723 "cs.ATG" +#line 1241 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 24: { lexer.NextToken(); -#line 1725 "cs.ATG" +#line 1243 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 27: { lexer.NextToken(); -#line 1726 "cs.ATG" +#line 1244 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 31: { lexer.NextToken(); -#line 1728 "cs.ATG" +#line 1246 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 32: { lexer.NextToken(); -#line 1729 "cs.ATG" +#line 1247 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 112: { lexer.NextToken(); -#line 1731 "cs.ATG" +#line 1249 "cs.ATG" op = OverloadableOperatorType.IsTrue; break; } case 71: { lexer.NextToken(); -#line 1732 "cs.ATG" +#line 1250 "cs.ATG" op = OverloadableOperatorType.IsFalse; break; } case 6: { lexer.NextToken(); -#line 1734 "cs.ATG" +#line 1252 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1735 "cs.ATG" +#line 1253 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1736 "cs.ATG" +#line 1254 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 28: { lexer.NextToken(); -#line 1738 "cs.ATG" +#line 1256 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 29: { lexer.NextToken(); -#line 1739 "cs.ATG" +#line 1257 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 30: { lexer.NextToken(); -#line 1740 "cs.ATG" +#line 1258 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 37: { lexer.NextToken(); -#line 1742 "cs.ATG" +#line 1260 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 33: { lexer.NextToken(); -#line 1743 "cs.ATG" +#line 1261 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 34: { lexer.NextToken(); -#line 1744 "cs.ATG" +#line 1262 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 23: { lexer.NextToken(); -#line 1745 "cs.ATG" +#line 1263 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 35: { lexer.NextToken(); -#line 1746 "cs.ATG" +#line 1264 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 36: { lexer.NextToken(); -#line 1747 "cs.ATG" +#line 1265 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 22: { lexer.NextToken(); -#line 1748 "cs.ATG" +#line 1266 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 22) { lexer.NextToken(); -#line 1748 "cs.ATG" +#line 1266 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -3213,34 +2726,34 @@ out OverloadableOperatorType op) { } void VariableDeclarator( -#line 1660 "cs.ATG" +#line 1178 "cs.ATG" List fieldDeclaration) { -#line 1661 "cs.ATG" +#line 1179 "cs.ATG" Expression expr = null; Expect(1); -#line 1663 "cs.ATG" +#line 1181 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1664 "cs.ATG" +#line 1182 "cs.ATG" out expr); -#line 1664 "cs.ATG" +#line 1182 "cs.ATG" f.Initializer = expr; } -#line 1664 "cs.ATG" +#line 1182 "cs.ATG" fieldDeclaration.Add(f); } void AccessorDecls( -#line 1546 "cs.ATG" +#line 1064 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1548 "cs.ATG" +#line 1066 "cs.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -3249,96 +2762,96 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1555 "cs.ATG" +#line 1073 "cs.ATG" out section); -#line 1555 "cs.ATG" +#line 1073 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1556 "cs.ATG" +#line 1074 "cs.ATG" out modifiers); } if ( -#line 1558 "cs.ATG" +#line 1076 "cs.ATG" IdentIsGet()) { GetAccessorDecl( -#line 1559 "cs.ATG" +#line 1077 "cs.ATG" out getBlock, attributes); -#line 1560 "cs.ATG" +#line 1078 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } if (StartOf(22)) { -#line 1561 "cs.ATG" +#line 1079 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1562 "cs.ATG" +#line 1080 "cs.ATG" out section); -#line 1562 "cs.ATG" +#line 1080 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1563 "cs.ATG" +#line 1081 "cs.ATG" out modifiers); } SetAccessorDecl( -#line 1564 "cs.ATG" +#line 1082 "cs.ATG" out setBlock, attributes); -#line 1565 "cs.ATG" +#line 1083 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } } } else if ( -#line 1567 "cs.ATG" +#line 1085 "cs.ATG" IdentIsSet()) { SetAccessorDecl( -#line 1568 "cs.ATG" +#line 1086 "cs.ATG" out setBlock, attributes); -#line 1569 "cs.ATG" +#line 1087 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } if (StartOf(22)) { -#line 1570 "cs.ATG" +#line 1088 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1571 "cs.ATG" +#line 1089 "cs.ATG" out section); -#line 1571 "cs.ATG" +#line 1089 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1572 "cs.ATG" +#line 1090 "cs.ATG" out modifiers); } GetAccessorDecl( -#line 1573 "cs.ATG" +#line 1091 "cs.ATG" out getBlock, attributes); -#line 1574 "cs.ATG" +#line 1092 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } } } else if (la.kind == 1) { lexer.NextToken(); -#line 1576 "cs.ATG" +#line 1094 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(161); } void InterfaceAccessors( -#line 1624 "cs.ATG" +#line 1142 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1626 "cs.ATG" +#line 1144 "cs.ATG" AttributeSection section; List attributes = new List(); getBlock = null; setBlock = null; @@ -3346,274 +2859,274 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1632 "cs.ATG" +#line 1150 "cs.ATG" out section); -#line 1632 "cs.ATG" +#line 1150 "cs.ATG" attributes.Add(section); } -#line 1633 "cs.ATG" +#line 1151 "cs.ATG" Location startLocation = la.Location; if ( -#line 1635 "cs.ATG" +#line 1153 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1635 "cs.ATG" +#line 1153 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1636 "cs.ATG" +#line 1154 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1636 "cs.ATG" +#line 1154 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1637 "cs.ATG" +#line 1155 "cs.ATG" Error("set or get expected"); } else SynErr(162); Expect(11); -#line 1640 "cs.ATG" +#line 1158 "cs.ATG" if (getBlock != null) { getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } if (setBlock != null) { setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } attributes = new List(); if (la.kind == 1 || la.kind == 18) { while (la.kind == 18) { AttributeSection( -#line 1644 "cs.ATG" +#line 1162 "cs.ATG" out section); -#line 1644 "cs.ATG" +#line 1162 "cs.ATG" attributes.Add(section); } -#line 1645 "cs.ATG" +#line 1163 "cs.ATG" startLocation = la.Location; if ( -#line 1647 "cs.ATG" +#line 1165 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1647 "cs.ATG" +#line 1165 "cs.ATG" if (getBlock != null) Error("get already declared"); else { getBlock = new PropertyGetRegion(null, attributes); lastBlock = getBlock; } } else if ( -#line 1650 "cs.ATG" +#line 1168 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1650 "cs.ATG" +#line 1168 "cs.ATG" if (setBlock != null) Error("set already declared"); else { setBlock = new PropertySetRegion(null, attributes); lastBlock = setBlock; } } else if (la.kind == 1) { lexer.NextToken(); -#line 1653 "cs.ATG" +#line 1171 "cs.ATG" Error("set or get expected"); } else SynErr(163); Expect(11); -#line 1656 "cs.ATG" +#line 1174 "cs.ATG" if (lastBlock != null) { lastBlock.StartLocation = startLocation; lastBlock.EndLocation = t.EndLocation; } } } void GetAccessorDecl( -#line 1580 "cs.ATG" +#line 1098 "cs.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1581 "cs.ATG" +#line 1099 "cs.ATG" Statement stmt = null; Expect(1); -#line 1584 "cs.ATG" +#line 1102 "cs.ATG" if (t.val != "get") Error("get expected"); -#line 1585 "cs.ATG" +#line 1103 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1586 "cs.ATG" +#line 1104 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(164); -#line 1587 "cs.ATG" +#line 1105 "cs.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); -#line 1588 "cs.ATG" +#line 1106 "cs.ATG" getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } void SetAccessorDecl( -#line 1591 "cs.ATG" +#line 1109 "cs.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1592 "cs.ATG" +#line 1110 "cs.ATG" Statement stmt = null; Expect(1); -#line 1595 "cs.ATG" +#line 1113 "cs.ATG" if (t.val != "set") Error("set expected"); -#line 1596 "cs.ATG" +#line 1114 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1597 "cs.ATG" +#line 1115 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(165); -#line 1598 "cs.ATG" +#line 1116 "cs.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); -#line 1599 "cs.ATG" +#line 1117 "cs.ATG" setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } void AddAccessorDecl( -#line 1682 "cs.ATG" +#line 1200 "cs.ATG" out Statement stmt) { -#line 1683 "cs.ATG" +#line 1201 "cs.ATG" stmt = null; Expect(1); -#line 1686 "cs.ATG" +#line 1204 "cs.ATG" if (t.val != "add") Error("add expected"); Block( -#line 1687 "cs.ATG" +#line 1205 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1690 "cs.ATG" +#line 1208 "cs.ATG" out Statement stmt) { -#line 1691 "cs.ATG" +#line 1209 "cs.ATG" stmt = null; Expect(1); -#line 1694 "cs.ATG" +#line 1212 "cs.ATG" if (t.val != "remove") Error("remove expected"); Block( -#line 1695 "cs.ATG" +#line 1213 "cs.ATG" out stmt); } void VariableInitializer( -#line 1711 "cs.ATG" +#line 1229 "cs.ATG" out Expression initializerExpression) { -#line 1712 "cs.ATG" +#line 1230 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(5)) { Expr( -#line 1714 "cs.ATG" +#line 1232 "cs.ATG" out initializerExpression); } else if (la.kind == 16) { ArrayInitializer( -#line 1715 "cs.ATG" +#line 1233 "cs.ATG" out initializerExpression); } else if (la.kind == 105) { lexer.NextToken(); Type( -#line 1716 "cs.ATG" +#line 1234 "cs.ATG" out type); Expect(18); Expr( -#line 1716 "cs.ATG" +#line 1234 "cs.ATG" out expr); Expect(19); -#line 1716 "cs.ATG" +#line 1234 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else SynErr(166); } void Statement() { -#line 1828 "cs.ATG" +#line 1346 "cs.ATG" TypeReference type; Expression expr; Statement stmt = null; Location startPos = la.Location; if ( -#line 1836 "cs.ATG" +#line 1354 "cs.ATG" IsLabel()) { Expect(1); -#line 1836 "cs.ATG" +#line 1354 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 59) { lexer.NextToken(); Type( -#line 1839 "cs.ATG" +#line 1357 "cs.ATG" out type); -#line 1839 "cs.ATG" +#line 1357 "cs.ATG" LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifier.Const); string ident = null; var.StartLocation = t.Location; Expect(1); -#line 1840 "cs.ATG" +#line 1358 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1841 "cs.ATG" +#line 1359 "cs.ATG" out expr); -#line 1841 "cs.ATG" +#line 1359 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1842 "cs.ATG" +#line 1360 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1842 "cs.ATG" +#line 1360 "cs.ATG" out expr); -#line 1842 "cs.ATG" +#line 1360 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); } Expect(11); -#line 1843 "cs.ATG" +#line 1361 "cs.ATG" compilationUnit.AddChild(var); } else if ( -#line 1845 "cs.ATG" +#line 1363 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1845 "cs.ATG" +#line 1363 "cs.ATG" out stmt); Expect(11); -#line 1845 "cs.ATG" +#line 1363 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(23)) { EmbeddedStatement( -#line 1846 "cs.ATG" +#line 1364 "cs.ATG" out stmt); -#line 1846 "cs.ATG" +#line 1364 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(167); -#line 1852 "cs.ATG" +#line 1370 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3622,10 +3135,10 @@ out stmt); } void Argument( -#line 1751 "cs.ATG" +#line 1269 "cs.ATG" out Expression argumentexpr) { -#line 1753 "cs.ATG" +#line 1271 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3633,48 +3146,48 @@ out Expression argumentexpr) { if (la.kind == 99) { lexer.NextToken(); -#line 1758 "cs.ATG" +#line 1276 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1759 "cs.ATG" +#line 1277 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1761 "cs.ATG" +#line 1279 "cs.ATG" out expr); -#line 1761 "cs.ATG" +#line 1279 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void ArrayInitializer( -#line 1781 "cs.ATG" +#line 1299 "cs.ATG" out Expression outExpr) { -#line 1783 "cs.ATG" +#line 1301 "cs.ATG" Expression expr = null; ArrayInitializerExpression initializer = new ArrayInitializerExpression(); Expect(16); if (StartOf(24)) { VariableInitializer( -#line 1788 "cs.ATG" +#line 1306 "cs.ATG" out expr); -#line 1789 "cs.ATG" +#line 1307 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1790 "cs.ATG" +#line 1308 "cs.ATG" NotFinalComma()) { Expect(14); VariableInitializer( -#line 1791 "cs.ATG" +#line 1309 "cs.ATG" out expr); -#line 1792 "cs.ATG" +#line 1310 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } if (la.kind == 14) { @@ -3683,138 +3196,138 @@ out expr); } Expect(17); -#line 1796 "cs.ATG" +#line 1314 "cs.ATG" outExpr = initializer; } void AssignmentOperator( -#line 1764 "cs.ATG" +#line 1282 "cs.ATG" out AssignmentOperatorType op) { -#line 1765 "cs.ATG" +#line 1283 "cs.ATG" op = AssignmentOperatorType.None; if (la.kind == 3) { lexer.NextToken(); -#line 1767 "cs.ATG" +#line 1285 "cs.ATG" op = AssignmentOperatorType.Assign; } else if (la.kind == 38) { lexer.NextToken(); -#line 1768 "cs.ATG" +#line 1286 "cs.ATG" op = AssignmentOperatorType.Add; } else if (la.kind == 39) { lexer.NextToken(); -#line 1769 "cs.ATG" +#line 1287 "cs.ATG" op = AssignmentOperatorType.Subtract; } else if (la.kind == 40) { lexer.NextToken(); -#line 1770 "cs.ATG" +#line 1288 "cs.ATG" op = AssignmentOperatorType.Multiply; } else if (la.kind == 41) { lexer.NextToken(); -#line 1771 "cs.ATG" +#line 1289 "cs.ATG" op = AssignmentOperatorType.Divide; } else if (la.kind == 42) { lexer.NextToken(); -#line 1772 "cs.ATG" +#line 1290 "cs.ATG" op = AssignmentOperatorType.Modulus; } else if (la.kind == 43) { lexer.NextToken(); -#line 1773 "cs.ATG" +#line 1291 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; } else if (la.kind == 44) { lexer.NextToken(); -#line 1774 "cs.ATG" +#line 1292 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; } else if (la.kind == 45) { lexer.NextToken(); -#line 1775 "cs.ATG" +#line 1293 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; } else if (la.kind == 46) { lexer.NextToken(); -#line 1776 "cs.ATG" +#line 1294 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; } else if ( -#line 1777 "cs.ATG" +#line 1295 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { Expect(22); Expect(35); -#line 1778 "cs.ATG" +#line 1296 "cs.ATG" op = AssignmentOperatorType.ShiftRight; } else SynErr(168); } void LocalVariableDecl( -#line 1799 "cs.ATG" +#line 1317 "cs.ATG" out Statement stmt) { -#line 1801 "cs.ATG" +#line 1319 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Type( -#line 1806 "cs.ATG" +#line 1324 "cs.ATG" out type); -#line 1806 "cs.ATG" +#line 1324 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = t.Location; LocalVariableDeclarator( -#line 1807 "cs.ATG" +#line 1325 "cs.ATG" out var); -#line 1807 "cs.ATG" +#line 1325 "cs.ATG" localVariableDeclaration.Variables.Add(var); while (la.kind == 14) { lexer.NextToken(); LocalVariableDeclarator( -#line 1808 "cs.ATG" +#line 1326 "cs.ATG" out var); -#line 1808 "cs.ATG" +#line 1326 "cs.ATG" localVariableDeclaration.Variables.Add(var); } -#line 1809 "cs.ATG" +#line 1327 "cs.ATG" stmt = localVariableDeclaration; } void LocalVariableDeclarator( -#line 1812 "cs.ATG" +#line 1330 "cs.ATG" out VariableDeclaration var) { -#line 1813 "cs.ATG" +#line 1331 "cs.ATG" Expression expr = null; Expect(1); -#line 1816 "cs.ATG" +#line 1334 "cs.ATG" var = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1816 "cs.ATG" +#line 1334 "cs.ATG" out expr); -#line 1816 "cs.ATG" +#line 1334 "cs.ATG" var.Initializer = expr; } } void EmbeddedStatement( -#line 1859 "cs.ATG" +#line 1377 "cs.ATG" out Statement statement) { -#line 1861 "cs.ATG" +#line 1379 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; @@ -3822,57 +3335,57 @@ out Statement statement) { if (la.kind == 16) { Block( -#line 1867 "cs.ATG" +#line 1385 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1869 "cs.ATG" +#line 1387 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1871 "cs.ATG" +#line 1389 "cs.ATG" UnCheckedAndLBrace()) { -#line 1871 "cs.ATG" +#line 1389 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 57) { lexer.NextToken(); } else if (la.kind == 117) { lexer.NextToken(); -#line 1872 "cs.ATG" +#line 1390 "cs.ATG" isChecked = false; } else SynErr(169); Block( -#line 1873 "cs.ATG" +#line 1391 "cs.ATG" out block); -#line 1873 "cs.ATG" +#line 1391 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 78) { lexer.NextToken(); -#line 1875 "cs.ATG" +#line 1393 "cs.ATG" Statement elseStatement = null; Expect(20); Expr( -#line 1876 "cs.ATG" +#line 1394 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1877 "cs.ATG" +#line 1395 "cs.ATG" out embeddedStatement); if (la.kind == 66) { lexer.NextToken(); EmbeddedStatement( -#line 1878 "cs.ATG" +#line 1396 "cs.ATG" out elseStatement); } -#line 1879 "cs.ATG" +#line 1397 "cs.ATG" statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); -#line 1880 "cs.ATG" +#line 1398 "cs.ATG" if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) { /* else if-section (otherwise we would have a BlockStatment) */ (statement as IfElseStatement).ElseIfSections.Add( @@ -3884,99 +3397,99 @@ out elseStatement); } else if (la.kind == 109) { lexer.NextToken(); -#line 1888 "cs.ATG" +#line 1406 "cs.ATG" List switchSections = new List(); Expect(20); Expr( -#line 1889 "cs.ATG" +#line 1407 "cs.ATG" out expr); Expect(21); Expect(16); SwitchSections( -#line 1890 "cs.ATG" +#line 1408 "cs.ATG" switchSections); Expect(17); -#line 1891 "cs.ATG" +#line 1409 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 124) { lexer.NextToken(); Expect(20); Expr( -#line 1893 "cs.ATG" +#line 1411 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1895 "cs.ATG" +#line 1413 "cs.ATG" out embeddedStatement); -#line 1895 "cs.ATG" +#line 1413 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 64) { lexer.NextToken(); EmbeddedStatement( -#line 1896 "cs.ATG" +#line 1414 "cs.ATG" out embeddedStatement); Expect(124); Expect(20); Expr( -#line 1897 "cs.ATG" +#line 1415 "cs.ATG" out expr); Expect(21); Expect(11); -#line 1897 "cs.ATG" +#line 1415 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 75) { lexer.NextToken(); -#line 1898 "cs.ATG" +#line 1416 "cs.ATG" List initializer = null; List iterator = null; Expect(20); if (StartOf(5)) { ForInitializer( -#line 1899 "cs.ATG" +#line 1417 "cs.ATG" out initializer); } Expect(11); if (StartOf(5)) { Expr( -#line 1900 "cs.ATG" +#line 1418 "cs.ATG" out expr); } Expect(11); if (StartOf(5)) { ForIterator( -#line 1901 "cs.ATG" +#line 1419 "cs.ATG" out iterator); } Expect(21); EmbeddedStatement( -#line 1902 "cs.ATG" +#line 1420 "cs.ATG" out embeddedStatement); -#line 1902 "cs.ATG" +#line 1420 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 76) { lexer.NextToken(); Expect(20); Type( -#line 1903 "cs.ATG" +#line 1421 "cs.ATG" out type); Expect(1); -#line 1903 "cs.ATG" +#line 1421 "cs.ATG" string varName = t.val; Location start = t.Location; Expect(80); Expr( -#line 1904 "cs.ATG" +#line 1422 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1905 "cs.ATG" +#line 1423 "cs.ATG" out embeddedStatement); -#line 1905 "cs.ATG" +#line 1423 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); statement.EndLocation = t.EndLocation; @@ -3984,34 +3497,34 @@ out embeddedStatement); lexer.NextToken(); Expect(11); -#line 1909 "cs.ATG" +#line 1427 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 60) { lexer.NextToken(); Expect(11); -#line 1910 "cs.ATG" +#line 1428 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 77) { GotoStatement( -#line 1911 "cs.ATG" +#line 1429 "cs.ATG" out statement); } else if ( -#line 1912 "cs.ATG" +#line 1430 "cs.ATG" IsYieldStatement()) { Expect(1); if (la.kind == 100) { lexer.NextToken(); Expr( -#line 1912 "cs.ATG" +#line 1430 "cs.ATG" out expr); -#line 1912 "cs.ATG" +#line 1430 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 52) { lexer.NextToken(); -#line 1913 "cs.ATG" +#line 1431 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(170); Expect(11); @@ -4019,140 +3532,140 @@ out expr); lexer.NextToken(); if (StartOf(5)) { Expr( -#line 1914 "cs.ATG" +#line 1432 "cs.ATG" out expr); } Expect(11); -#line 1914 "cs.ATG" +#line 1432 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 111) { lexer.NextToken(); if (StartOf(5)) { Expr( -#line 1915 "cs.ATG" +#line 1433 "cs.ATG" out expr); } Expect(11); -#line 1915 "cs.ATG" +#line 1433 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(5)) { StatementExpr( -#line 1918 "cs.ATG" +#line 1436 "cs.ATG" out statement); Expect(11); } else if (la.kind == 113) { TryStatement( -#line 1920 "cs.ATG" +#line 1438 "cs.ATG" out statement); } else if (la.kind == 85) { lexer.NextToken(); Expect(20); Expr( -#line 1922 "cs.ATG" +#line 1440 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1923 "cs.ATG" +#line 1441 "cs.ATG" out embeddedStatement); -#line 1923 "cs.ATG" +#line 1441 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 120) { -#line 1925 "cs.ATG" +#line 1443 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1927 "cs.ATG" +#line 1445 "cs.ATG" out resourceAcquisitionStmt); Expect(21); EmbeddedStatement( -#line 1928 "cs.ATG" +#line 1446 "cs.ATG" out embeddedStatement); -#line 1928 "cs.ATG" +#line 1446 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 118) { lexer.NextToken(); Block( -#line 1930 "cs.ATG" +#line 1448 "cs.ATG" out embeddedStatement); -#line 1930 "cs.ATG" +#line 1448 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 73) { lexer.NextToken(); Expect(20); Type( -#line 1933 "cs.ATG" +#line 1451 "cs.ATG" out type); -#line 1933 "cs.ATG" +#line 1451 "cs.ATG" if (type.PointerNestingLevel == 0) Error("can only fix pointer types"); List pointerDeclarators = new List(1); Expect(1); -#line 1936 "cs.ATG" +#line 1454 "cs.ATG" string identifier = t.val; Expect(3); Expr( -#line 1937 "cs.ATG" +#line 1455 "cs.ATG" out expr); -#line 1937 "cs.ATG" +#line 1455 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1939 "cs.ATG" +#line 1457 "cs.ATG" identifier = t.val; Expect(3); Expr( -#line 1940 "cs.ATG" +#line 1458 "cs.ATG" out expr); -#line 1940 "cs.ATG" +#line 1458 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); } Expect(21); EmbeddedStatement( -#line 1942 "cs.ATG" +#line 1460 "cs.ATG" out embeddedStatement); -#line 1942 "cs.ATG" +#line 1460 "cs.ATG" statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); } else SynErr(171); } void SwitchSections( -#line 1964 "cs.ATG" +#line 1482 "cs.ATG" List switchSections) { -#line 1966 "cs.ATG" +#line 1484 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1970 "cs.ATG" +#line 1488 "cs.ATG" out label); -#line 1970 "cs.ATG" +#line 1488 "cs.ATG" if (label != null) { switchSection.SwitchLabels.Add(label); } -#line 1971 "cs.ATG" +#line 1489 "cs.ATG" compilationUnit.BlockStart(switchSection); while (StartOf(25)) { if (la.kind == 54 || la.kind == 62) { SwitchLabel( -#line 1973 "cs.ATG" +#line 1491 "cs.ATG" out label); -#line 1974 "cs.ATG" +#line 1492 "cs.ATG" if (label != null) { if (switchSection.Children.Count > 0) { // open new section @@ -4168,346 +3681,346 @@ out label); } } -#line 1986 "cs.ATG" +#line 1504 "cs.ATG" compilationUnit.BlockEnd(); switchSections.Add(switchSection); } void ForInitializer( -#line 1945 "cs.ATG" +#line 1463 "cs.ATG" out List initializer) { -#line 1947 "cs.ATG" +#line 1465 "cs.ATG" Statement stmt; initializer = new List(); if ( -#line 1951 "cs.ATG" +#line 1469 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1951 "cs.ATG" +#line 1469 "cs.ATG" out stmt); -#line 1951 "cs.ATG" +#line 1469 "cs.ATG" initializer.Add(stmt); } else if (StartOf(5)) { StatementExpr( -#line 1952 "cs.ATG" +#line 1470 "cs.ATG" out stmt); -#line 1952 "cs.ATG" +#line 1470 "cs.ATG" initializer.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1952 "cs.ATG" +#line 1470 "cs.ATG" out stmt); -#line 1952 "cs.ATG" +#line 1470 "cs.ATG" initializer.Add(stmt); } } else SynErr(172); } void ForIterator( -#line 1955 "cs.ATG" +#line 1473 "cs.ATG" out List iterator) { -#line 1957 "cs.ATG" +#line 1475 "cs.ATG" Statement stmt; iterator = new List(); StatementExpr( -#line 1961 "cs.ATG" +#line 1479 "cs.ATG" out stmt); -#line 1961 "cs.ATG" +#line 1479 "cs.ATG" iterator.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1961 "cs.ATG" +#line 1479 "cs.ATG" out stmt); -#line 1961 "cs.ATG" +#line 1479 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 2039 "cs.ATG" +#line 1557 "cs.ATG" out Statement stmt) { -#line 2040 "cs.ATG" +#line 1558 "cs.ATG" Expression expr; stmt = null; Expect(77); if (la.kind == 1) { lexer.NextToken(); -#line 2044 "cs.ATG" +#line 1562 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 54) { lexer.NextToken(); Expr( -#line 2045 "cs.ATG" +#line 1563 "cs.ATG" out expr); Expect(11); -#line 2045 "cs.ATG" +#line 1563 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 62) { lexer.NextToken(); Expect(11); -#line 2046 "cs.ATG" +#line 1564 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(173); } void StatementExpr( -#line 2066 "cs.ATG" +#line 1584 "cs.ATG" out Statement stmt) { -#line 2067 "cs.ATG" +#line 1585 "cs.ATG" Expression expr; Expr( -#line 2069 "cs.ATG" +#line 1587 "cs.ATG" out expr); -#line 2072 "cs.ATG" +#line 1590 "cs.ATG" stmt = new StatementExpression(expr); } void TryStatement( -#line 1996 "cs.ATG" +#line 1514 "cs.ATG" out Statement tryStatement) { -#line 1998 "cs.ATG" +#line 1516 "cs.ATG" Statement blockStmt = null, finallyStmt = null; List catchClauses = null; Expect(113); Block( -#line 2002 "cs.ATG" +#line 1520 "cs.ATG" out blockStmt); if (la.kind == 55) { CatchClauses( -#line 2004 "cs.ATG" +#line 1522 "cs.ATG" out catchClauses); if (la.kind == 72) { lexer.NextToken(); Block( -#line 2004 "cs.ATG" +#line 1522 "cs.ATG" out finallyStmt); } } else if (la.kind == 72) { lexer.NextToken(); Block( -#line 2005 "cs.ATG" +#line 1523 "cs.ATG" out finallyStmt); } else SynErr(174); -#line 2008 "cs.ATG" +#line 1526 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void ResourceAcquisition( -#line 2050 "cs.ATG" +#line 1568 "cs.ATG" out Statement stmt) { -#line 2052 "cs.ATG" +#line 1570 "cs.ATG" stmt = null; Expression expr; if ( -#line 2057 "cs.ATG" +#line 1575 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 2057 "cs.ATG" +#line 1575 "cs.ATG" out stmt); } else if (StartOf(5)) { Expr( -#line 2058 "cs.ATG" +#line 1576 "cs.ATG" out expr); -#line 2062 "cs.ATG" +#line 1580 "cs.ATG" stmt = new StatementExpression(expr); } else SynErr(175); } void SwitchLabel( -#line 1989 "cs.ATG" +#line 1507 "cs.ATG" out CaseLabel label) { -#line 1990 "cs.ATG" +#line 1508 "cs.ATG" Expression expr = null; label = null; if (la.kind == 54) { lexer.NextToken(); Expr( -#line 1992 "cs.ATG" +#line 1510 "cs.ATG" out expr); Expect(9); -#line 1992 "cs.ATG" +#line 1510 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 62) { lexer.NextToken(); Expect(9); -#line 1993 "cs.ATG" +#line 1511 "cs.ATG" label = new CaseLabel(); } else SynErr(176); } void CatchClauses( -#line 2013 "cs.ATG" +#line 1531 "cs.ATG" out List catchClauses) { -#line 2015 "cs.ATG" +#line 1533 "cs.ATG" catchClauses = new List(); Expect(55); -#line 2018 "cs.ATG" +#line 1536 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; if (la.kind == 16) { Block( -#line 2024 "cs.ATG" +#line 1542 "cs.ATG" out stmt); -#line 2024 "cs.ATG" +#line 1542 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } else if (la.kind == 20) { lexer.NextToken(); ClassType( -#line 2026 "cs.ATG" +#line 1544 "cs.ATG" out typeRef, false); -#line 2026 "cs.ATG" +#line 1544 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 2027 "cs.ATG" +#line 1545 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 2028 "cs.ATG" +#line 1546 "cs.ATG" out stmt); -#line 2029 "cs.ATG" +#line 1547 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); while ( -#line 2030 "cs.ATG" +#line 1548 "cs.ATG" IsTypedCatch()) { Expect(55); Expect(20); ClassType( -#line 2030 "cs.ATG" +#line 1548 "cs.ATG" out typeRef, false); -#line 2030 "cs.ATG" +#line 1548 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 2031 "cs.ATG" +#line 1549 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 2032 "cs.ATG" +#line 1550 "cs.ATG" out stmt); -#line 2033 "cs.ATG" +#line 1551 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); } if (la.kind == 55) { lexer.NextToken(); Block( -#line 2035 "cs.ATG" +#line 1553 "cs.ATG" out stmt); -#line 2035 "cs.ATG" +#line 1553 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } } else SynErr(177); } void UnaryExpr( -#line 2093 "cs.ATG" +#line 1611 "cs.ATG" out Expression uExpr) { -#line 2095 "cs.ATG" +#line 1613 "cs.ATG" TypeReference type = null; Expression expr; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(26) || -#line 2117 "cs.ATG" +#line 1635 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 2104 "cs.ATG" +#line 1622 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 2105 "cs.ATG" +#line 1623 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 24) { lexer.NextToken(); -#line 2106 "cs.ATG" +#line 1624 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 27) { lexer.NextToken(); -#line 2107 "cs.ATG" +#line 1625 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 2108 "cs.ATG" +#line 1626 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Star)); } else if (la.kind == 31) { lexer.NextToken(); -#line 2109 "cs.ATG" +#line 1627 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 32) { lexer.NextToken(); -#line 2110 "cs.ATG" +#line 1628 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 28) { lexer.NextToken(); -#line 2111 "cs.ATG" +#line 1629 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitWiseAnd)); } else { Expect(20); Type( -#line 2117 "cs.ATG" +#line 1635 "cs.ATG" out type); Expect(21); -#line 2117 "cs.ATG" +#line 1635 "cs.ATG" expressions.Add(new CastExpression(type)); } } PrimaryExpr( -#line 2121 "cs.ATG" +#line 1639 "cs.ATG" out expr); -#line 2121 "cs.ATG" +#line 1639 "cs.ATG" for (int i = 0; i < expressions.Count; ++i) { Expression nextExpression = i + 1 < expressions.Count ? (Expression)expressions[i + 1] : expr; if (expressions[i] is CastExpression) { @@ -4525,33 +4038,33 @@ out expr); } void ConditionalOrExpr( -#line 2290 "cs.ATG" +#line 1808 "cs.ATG" ref Expression outExpr) { -#line 2291 "cs.ATG" +#line 1809 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 2293 "cs.ATG" +#line 1811 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 2293 "cs.ATG" +#line 1811 "cs.ATG" out expr); ConditionalAndExpr( -#line 2293 "cs.ATG" +#line 1811 "cs.ATG" ref expr); -#line 2293 "cs.ATG" +#line 1811 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 2138 "cs.ATG" +#line 1656 "cs.ATG" out Expression pexpr) { -#line 2140 "cs.ATG" +#line 1658 "cs.ATG" TypeReference type = null; List typeList = null; bool isArrayCreation = false; @@ -4561,332 +4074,332 @@ out Expression pexpr) { if (la.kind == 112) { lexer.NextToken(); -#line 2148 "cs.ATG" +#line 1666 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 71) { lexer.NextToken(); -#line 2149 "cs.ATG" +#line 1667 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 89) { lexer.NextToken(); -#line 2150 "cs.ATG" +#line 1668 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 2151 "cs.ATG" +#line 1669 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); } else if ( -#line 2152 "cs.ATG" +#line 1670 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { Expect(1); -#line 2153 "cs.ATG" +#line 1671 "cs.ATG" type = new TypeReference(t.val); Expect(10); -#line 2154 "cs.ATG" +#line 1672 "cs.ATG" pexpr = new TypeReferenceExpression(type); Expect(1); -#line 2155 "cs.ATG" +#line 1673 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); } else if (la.kind == 1) { lexer.NextToken(); -#line 2157 "cs.ATG" +#line 1675 "cs.ATG" pexpr = new IdentifierExpression(t.val); } else if (la.kind == 20) { lexer.NextToken(); Expr( -#line 2159 "cs.ATG" +#line 1677 "cs.ATG" out expr); Expect(21); -#line 2159 "cs.ATG" +#line 1677 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(27)) { -#line 2161 "cs.ATG" +#line 1679 "cs.ATG" string val = null; switch (la.kind) { case 51: { lexer.NextToken(); -#line 2163 "cs.ATG" +#line 1681 "cs.ATG" val = "bool"; break; } case 53: { lexer.NextToken(); -#line 2164 "cs.ATG" +#line 1682 "cs.ATG" val = "byte"; break; } case 56: { lexer.NextToken(); -#line 2165 "cs.ATG" +#line 1683 "cs.ATG" val = "char"; break; } case 61: { lexer.NextToken(); -#line 2166 "cs.ATG" +#line 1684 "cs.ATG" val = "decimal"; break; } case 65: { lexer.NextToken(); -#line 2167 "cs.ATG" +#line 1685 "cs.ATG" val = "double"; break; } case 74: { lexer.NextToken(); -#line 2168 "cs.ATG" +#line 1686 "cs.ATG" val = "float"; break; } case 81: { lexer.NextToken(); -#line 2169 "cs.ATG" +#line 1687 "cs.ATG" val = "int"; break; } case 86: { lexer.NextToken(); -#line 2170 "cs.ATG" +#line 1688 "cs.ATG" val = "long"; break; } case 90: { lexer.NextToken(); -#line 2171 "cs.ATG" +#line 1689 "cs.ATG" val = "object"; break; } case 101: { lexer.NextToken(); -#line 2172 "cs.ATG" +#line 1690 "cs.ATG" val = "sbyte"; break; } case 103: { lexer.NextToken(); -#line 2173 "cs.ATG" +#line 1691 "cs.ATG" val = "short"; break; } case 107: { lexer.NextToken(); -#line 2174 "cs.ATG" +#line 1692 "cs.ATG" val = "string"; break; } case 115: { lexer.NextToken(); -#line 2175 "cs.ATG" +#line 1693 "cs.ATG" val = "uint"; break; } case 116: { lexer.NextToken(); -#line 2176 "cs.ATG" +#line 1694 "cs.ATG" val = "ulong"; break; } case 119: { lexer.NextToken(); -#line 2177 "cs.ATG" +#line 1695 "cs.ATG" val = "ushort"; break; } } -#line 2178 "cs.ATG" +#line 1696 "cs.ATG" t.val = ""; Expect(15); Expect(1); -#line 2178 "cs.ATG" +#line 1696 "cs.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); } else if (la.kind == 110) { lexer.NextToken(); -#line 2180 "cs.ATG" +#line 1698 "cs.ATG" pexpr = new ThisReferenceExpression(); } else if (la.kind == 50) { lexer.NextToken(); -#line 2182 "cs.ATG" +#line 1700 "cs.ATG" Expression retExpr = new BaseReferenceExpression(); if (la.kind == 15) { lexer.NextToken(); Expect(1); -#line 2184 "cs.ATG" +#line 1702 "cs.ATG" retExpr = new FieldReferenceExpression(retExpr, t.val); } else if (la.kind == 18) { lexer.NextToken(); Expr( -#line 2185 "cs.ATG" +#line 1703 "cs.ATG" out expr); -#line 2185 "cs.ATG" +#line 1703 "cs.ATG" List indices = new List(); if (expr != null) { indices.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Expr( -#line 2186 "cs.ATG" +#line 1704 "cs.ATG" out expr); -#line 2186 "cs.ATG" +#line 1704 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(19); -#line 2187 "cs.ATG" +#line 1705 "cs.ATG" retExpr = new IndexerExpression(retExpr, indices); } else SynErr(178); -#line 2188 "cs.ATG" +#line 1706 "cs.ATG" pexpr = retExpr; } else if (la.kind == 88) { lexer.NextToken(); NonArrayType( -#line 2189 "cs.ATG" +#line 1707 "cs.ATG" out type); -#line 2190 "cs.ATG" +#line 1708 "cs.ATG" List parameters = new List(); if (la.kind == 20) { lexer.NextToken(); -#line 2195 "cs.ATG" +#line 1713 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); if (StartOf(21)) { Argument( -#line 2196 "cs.ATG" +#line 1714 "cs.ATG" out expr); -#line 2196 "cs.ATG" +#line 1714 "cs.ATG" if (expr != null) { parameters.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2197 "cs.ATG" +#line 1715 "cs.ATG" out expr); -#line 2197 "cs.ATG" +#line 1715 "cs.ATG" if (expr != null) { parameters.Add(expr); } } } Expect(21); -#line 2199 "cs.ATG" +#line 1717 "cs.ATG" pexpr = oce; } else if (la.kind == 18) { lexer.NextToken(); -#line 2201 "cs.ATG" +#line 1719 "cs.ATG" isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; -#line 2202 "cs.ATG" +#line 1720 "cs.ATG" int dims = 0; List ranks = new List(); if (la.kind == 14 || la.kind == 19) { while (la.kind == 14) { lexer.NextToken(); -#line 2204 "cs.ATG" +#line 1722 "cs.ATG" dims += 1; } Expect(19); -#line 2205 "cs.ATG" +#line 1723 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2206 "cs.ATG" +#line 1724 "cs.ATG" ++dims; } Expect(19); -#line 2206 "cs.ATG" +#line 1724 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2207 "cs.ATG" +#line 1725 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); ArrayInitializer( -#line 2208 "cs.ATG" +#line 1726 "cs.ATG" out expr); -#line 2208 "cs.ATG" +#line 1726 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } else if (StartOf(5)) { Expr( -#line 2209 "cs.ATG" +#line 1727 "cs.ATG" out expr); -#line 2209 "cs.ATG" +#line 1727 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 2210 "cs.ATG" +#line 1728 "cs.ATG" dims += 1; Expr( -#line 2211 "cs.ATG" +#line 1729 "cs.ATG" out expr); -#line 2211 "cs.ATG" +#line 1729 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 2213 "cs.ATG" +#line 1731 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2214 "cs.ATG" +#line 1732 "cs.ATG" ++dims; } Expect(19); -#line 2214 "cs.ATG" +#line 1732 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2215 "cs.ATG" +#line 1733 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { ArrayInitializer( -#line 2216 "cs.ATG" +#line 1734 "cs.ATG" out expr); -#line 2216 "cs.ATG" +#line 1734 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } } else SynErr(179); @@ -4895,202 +4408,202 @@ out expr); lexer.NextToken(); Expect(20); if ( -#line 2221 "cs.ATG" +#line 1739 "cs.ATG" NotVoidPointer()) { Expect(122); -#line 2221 "cs.ATG" +#line 1739 "cs.ATG" type = new TypeReference("void"); } else if (StartOf(9)) { TypeWithRestriction( -#line 2222 "cs.ATG" +#line 1740 "cs.ATG" out type, true, true); } else SynErr(181); Expect(21); -#line 2223 "cs.ATG" +#line 1741 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 62) { lexer.NextToken(); Expect(20); Type( -#line 2225 "cs.ATG" +#line 1743 "cs.ATG" out type); Expect(21); -#line 2225 "cs.ATG" +#line 1743 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 104) { lexer.NextToken(); Expect(20); Type( -#line 2226 "cs.ATG" +#line 1744 "cs.ATG" out type); Expect(21); -#line 2226 "cs.ATG" +#line 1744 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 57) { lexer.NextToken(); Expect(20); Expr( -#line 2227 "cs.ATG" +#line 1745 "cs.ATG" out expr); Expect(21); -#line 2227 "cs.ATG" +#line 1745 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 117) { lexer.NextToken(); Expect(20); Expr( -#line 2228 "cs.ATG" +#line 1746 "cs.ATG" out expr); Expect(21); -#line 2228 "cs.ATG" +#line 1746 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 63) { lexer.NextToken(); AnonymousMethodExpr( -#line 2229 "cs.ATG" +#line 1747 "cs.ATG" out expr); -#line 2229 "cs.ATG" +#line 1747 "cs.ATG" pexpr = expr; } else SynErr(182); while (StartOf(28) || -#line 2240 "cs.ATG" +#line 1758 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr) || -#line 2249 "cs.ATG" +#line 1767 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { if (la.kind == 31 || la.kind == 32) { if (la.kind == 31) { lexer.NextToken(); -#line 2233 "cs.ATG" +#line 1751 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); -#line 2234 "cs.ATG" +#line 1752 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(183); } else if (la.kind == 47) { lexer.NextToken(); Expect(1); -#line 2237 "cs.ATG" +#line 1755 "cs.ATG" pexpr = new PointerReferenceExpression(pexpr, t.val); } else if (la.kind == 15) { lexer.NextToken(); Expect(1); -#line 2238 "cs.ATG" +#line 1756 "cs.ATG" pexpr = new FieldReferenceExpression(pexpr, t.val); } else if ( -#line 2240 "cs.ATG" +#line 1758 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr)) { TypeArgumentList( -#line 2241 "cs.ATG" +#line 1759 "cs.ATG" out typeList, false); Expect(15); Expect(1); -#line 2243 "cs.ATG" +#line 1761 "cs.ATG" pexpr = new FieldReferenceExpression(GetTypeReferenceExpression(pexpr, typeList), t.val); } else if (la.kind == 20) { lexer.NextToken(); -#line 2245 "cs.ATG" +#line 1763 "cs.ATG" List parameters = new List(); if (StartOf(21)) { Argument( -#line 2246 "cs.ATG" +#line 1764 "cs.ATG" out expr); -#line 2246 "cs.ATG" +#line 1764 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2247 "cs.ATG" +#line 1765 "cs.ATG" out expr); -#line 2247 "cs.ATG" +#line 1765 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(21); -#line 2248 "cs.ATG" +#line 1766 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); } else if ( -#line 2249 "cs.ATG" +#line 1767 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { TypeArgumentList( -#line 2249 "cs.ATG" +#line 1767 "cs.ATG" out typeList, false); Expect(20); -#line 2250 "cs.ATG" +#line 1768 "cs.ATG" List parameters = new List(); if (StartOf(21)) { Argument( -#line 2251 "cs.ATG" +#line 1769 "cs.ATG" out expr); -#line 2251 "cs.ATG" +#line 1769 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2252 "cs.ATG" +#line 1770 "cs.ATG" out expr); -#line 2252 "cs.ATG" +#line 1770 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(21); -#line 2253 "cs.ATG" +#line 1771 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeList); } else { -#line 2255 "cs.ATG" +#line 1773 "cs.ATG" if (isArrayCreation) Error("element access not allow on array creation"); List indices = new List(); lexer.NextToken(); Expr( -#line 2258 "cs.ATG" +#line 1776 "cs.ATG" out expr); -#line 2258 "cs.ATG" +#line 1776 "cs.ATG" if (expr != null) { indices.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Expr( -#line 2259 "cs.ATG" +#line 1777 "cs.ATG" out expr); -#line 2259 "cs.ATG" +#line 1777 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(19); -#line 2260 "cs.ATG" +#line 1778 "cs.ATG" pexpr = new IndexerExpression(pexpr, indices); } } } void AnonymousMethodExpr( -#line 2264 "cs.ATG" +#line 1782 "cs.ATG" out Expression outExpr) { -#line 2266 "cs.ATG" +#line 1784 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; Statement stmt; @@ -5101,74 +4614,74 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(10)) { FormalParameterList( -#line 2275 "cs.ATG" +#line 1793 "cs.ATG" p); -#line 2275 "cs.ATG" +#line 1793 "cs.ATG" expr.Parameters = p; } Expect(21); } -#line 2280 "cs.ATG" +#line 1798 "cs.ATG" if (compilationUnit != null) { Block( -#line 2281 "cs.ATG" +#line 1799 "cs.ATG" out stmt); -#line 2281 "cs.ATG" +#line 1799 "cs.ATG" expr.Body = (BlockStatement)stmt; -#line 2282 "cs.ATG" +#line 1800 "cs.ATG" } else { Expect(16); -#line 2284 "cs.ATG" - lexer.SkipCurrentBlock(); +#line 1802 "cs.ATG" + lexer.SkipCurrentBlock(0); Expect(17); -#line 2286 "cs.ATG" +#line 1804 "cs.ATG" } -#line 2287 "cs.ATG" +#line 1805 "cs.ATG" expr.EndLocation = t.Location; } void TypeArgumentList( -#line 2460 "cs.ATG" +#line 1978 "cs.ATG" out List types, bool canBeUnbound) { -#line 2462 "cs.ATG" +#line 1980 "cs.ATG" types = new List(); TypeReference type = null; Expect(23); if ( -#line 2467 "cs.ATG" +#line 1985 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2468 "cs.ATG" +#line 1986 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2469 "cs.ATG" +#line 1987 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(9)) { Type( -#line 2470 "cs.ATG" +#line 1988 "cs.ATG" out type); -#line 2470 "cs.ATG" +#line 1988 "cs.ATG" types.Add(type); while (la.kind == 14) { lexer.NextToken(); Type( -#line 2471 "cs.ATG" +#line 1989 "cs.ATG" out type); -#line 2471 "cs.ATG" +#line 1989 "cs.ATG" types.Add(type); } } else SynErr(184); @@ -5176,206 +4689,206 @@ out type); } void ConditionalAndExpr( -#line 2296 "cs.ATG" +#line 1814 "cs.ATG" ref Expression outExpr) { -#line 2297 "cs.ATG" +#line 1815 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 2299 "cs.ATG" +#line 1817 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2299 "cs.ATG" +#line 1817 "cs.ATG" out expr); InclusiveOrExpr( -#line 2299 "cs.ATG" +#line 1817 "cs.ATG" ref expr); -#line 2299 "cs.ATG" +#line 1817 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 2302 "cs.ATG" +#line 1820 "cs.ATG" ref Expression outExpr) { -#line 2303 "cs.ATG" +#line 1821 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 2305 "cs.ATG" +#line 1823 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2305 "cs.ATG" +#line 1823 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2305 "cs.ATG" +#line 1823 "cs.ATG" ref expr); -#line 2305 "cs.ATG" +#line 1823 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 2308 "cs.ATG" +#line 1826 "cs.ATG" ref Expression outExpr) { -#line 2309 "cs.ATG" +#line 1827 "cs.ATG" Expression expr; AndExpr( -#line 2311 "cs.ATG" +#line 1829 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 2311 "cs.ATG" +#line 1829 "cs.ATG" out expr); AndExpr( -#line 2311 "cs.ATG" +#line 1829 "cs.ATG" ref expr); -#line 2311 "cs.ATG" +#line 1829 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 2314 "cs.ATG" +#line 1832 "cs.ATG" ref Expression outExpr) { -#line 2315 "cs.ATG" +#line 1833 "cs.ATG" Expression expr; EqualityExpr( -#line 2317 "cs.ATG" +#line 1835 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2317 "cs.ATG" +#line 1835 "cs.ATG" out expr); EqualityExpr( -#line 2317 "cs.ATG" +#line 1835 "cs.ATG" ref expr); -#line 2317 "cs.ATG" +#line 1835 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2320 "cs.ATG" +#line 1838 "cs.ATG" ref Expression outExpr) { -#line 2322 "cs.ATG" +#line 1840 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2326 "cs.ATG" +#line 1844 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 2329 "cs.ATG" +#line 1847 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2330 "cs.ATG" +#line 1848 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2332 "cs.ATG" +#line 1850 "cs.ATG" out expr); RelationalExpr( -#line 2332 "cs.ATG" +#line 1850 "cs.ATG" ref expr); -#line 2332 "cs.ATG" +#line 1850 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2336 "cs.ATG" +#line 1854 "cs.ATG" ref Expression outExpr) { -#line 2338 "cs.ATG" +#line 1856 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2343 "cs.ATG" +#line 1861 "cs.ATG" ref outExpr); while (StartOf(29)) { if (StartOf(30)) { if (la.kind == 23) { lexer.NextToken(); -#line 2345 "cs.ATG" +#line 1863 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 2346 "cs.ATG" +#line 1864 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 2347 "cs.ATG" +#line 1865 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 2348 "cs.ATG" +#line 1866 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(185); UnaryExpr( -#line 2350 "cs.ATG" +#line 1868 "cs.ATG" out expr); ShiftExpr( -#line 2351 "cs.ATG" +#line 1869 "cs.ATG" ref expr); -#line 2352 "cs.ATG" +#line 1870 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 84) { lexer.NextToken(); TypeWithRestriction( -#line 2355 "cs.ATG" +#line 1873 "cs.ATG" out type, false, false); if ( -#line 2356 "cs.ATG" +#line 1874 "cs.ATG" la.kind == Tokens.Question && Tokens.CastFollower[Peek(1).kind] == false) { NullableQuestionMark( -#line 2357 "cs.ATG" +#line 1875 "cs.ATG" ref type); } -#line 2358 "cs.ATG" +#line 1876 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type); } else if (la.kind == 49) { lexer.NextToken(); TypeWithRestriction( -#line 2360 "cs.ATG" +#line 1878 "cs.ATG" out type, false, false); if ( -#line 2361 "cs.ATG" +#line 1879 "cs.ATG" la.kind == Tokens.Question && Tokens.CastFollower[Peek(1).kind] == false) { NullableQuestionMark( -#line 2362 "cs.ATG" +#line 1880 "cs.ATG" ref type); } -#line 2363 "cs.ATG" +#line 1881 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast); } else SynErr(186); } @@ -5383,83 +4896,83 @@ ref type); } void ShiftExpr( -#line 2368 "cs.ATG" +#line 1886 "cs.ATG" ref Expression outExpr) { -#line 2370 "cs.ATG" +#line 1888 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2374 "cs.ATG" +#line 1892 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 2377 "cs.ATG" +#line 1895 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 2376 "cs.ATG" +#line 1894 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 2378 "cs.ATG" +#line 1896 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2381 "cs.ATG" +#line 1899 "cs.ATG" out expr); AdditiveExpr( -#line 2381 "cs.ATG" +#line 1899 "cs.ATG" ref expr); -#line 2381 "cs.ATG" +#line 1899 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2385 "cs.ATG" +#line 1903 "cs.ATG" ref Expression outExpr) { -#line 2387 "cs.ATG" +#line 1905 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2391 "cs.ATG" +#line 1909 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2394 "cs.ATG" +#line 1912 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2395 "cs.ATG" +#line 1913 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2397 "cs.ATG" +#line 1915 "cs.ATG" out expr); MultiplicativeExpr( -#line 2397 "cs.ATG" +#line 1915 "cs.ATG" ref expr); -#line 2397 "cs.ATG" +#line 1915 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2401 "cs.ATG" +#line 1919 "cs.ATG" ref Expression outExpr) { -#line 2403 "cs.ATG" +#line 1921 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5467,65 +4980,62 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2409 "cs.ATG" +#line 1927 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2410 "cs.ATG" +#line 1928 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2411 "cs.ATG" +#line 1929 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2413 "cs.ATG" +#line 1931 "cs.ATG" out expr); -#line 2413 "cs.ATG" +#line 1931 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2517 "cs.ATG" +#line 2035 "cs.ATG" out TypeReference type) { -#line 2518 "cs.ATG" +#line 2036 "cs.ATG" TypeReference t; type = null; if (la.kind == 108) { lexer.NextToken(); -#line 2520 "cs.ATG" +#line 2038 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 58) { lexer.NextToken(); -#line 2521 "cs.ATG" +#line 2039 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 88) { lexer.NextToken(); Expect(20); Expect(21); -#line 2522 "cs.ATG" +#line 2040 "cs.ATG" type = new TypeReference("struct"); } else if (StartOf(9)) { Type( -#line 2523 "cs.ATG" +#line 2041 "cs.ATG" out t); -#line 2523 "cs.ATG" +#line 2041 "cs.ATG" type = t; } else SynErr(187); } - public Parser(ILexer lexer) : base(lexer) - { - } public override void Parse() { @@ -5533,39 +5043,6 @@ out t); } - protected void ExpectWeak(int n, int follow) - { - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - } else { - SynErr(n); - while (!StartOf(follow)) { - lexer.NextToken(); - } - } - } - - protected bool WeakSeparator(int n, int syFol, int repFol) - { - bool[] s = new bool[maxT + 1]; - - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - return true; - } else if (StartOf(repFol)) { - return false; - } else { - for (int i = 0; i <= maxT; i++) { - s[i] = set[syFol, i] || set[repFol, i] || set[0, i]; - } - SynErr(n); - while (!s[lexer.LookAhead.kind]) { - lexer.NextToken(); - } - return StartOf(syFol); - } - } - protected override void SynErr(int line, int col, int errorNumber) { errors.count++; @@ -5765,7 +5242,7 @@ out t); errors.Error(line, col, s); } - protected bool StartOf(int s) + private bool StartOf(int s) { return set[s, lexer.LookAhead.kind]; } @@ -5806,4 +5283,4 @@ out t); }; } // end Parser -} +} \ No newline at end of file diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index 2334489135..09626da320 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -9,488 +9,6 @@ using Types = ICSharpCode.NRefactory.Parser.AST.ClassType; COMPILER CS /* AW 2002-12-30 renamed from CompilationUnit to CS */ -/*----------------------------- token sets -------------------------------*/ -string assemblyName = null; -StringBuilder qualidentBuilder = new StringBuilder(); - -public string ContainingAssembly { - set { - assemblyName = value; - } -} - -Token t { - [System.Diagnostics.DebuggerStepThrough] - get { - return lexer.Token; - } -} - -Token la { - [System.Diagnostics.DebuggerStepThrough] - get { - return lexer.LookAhead; - } -} - -public void Error(string s) -{ - if (errDist >= minErrDist) { - errors.Error(la.line, la.col, s); - } - errDist = 0; -} - -public override Expression ParseExpression() -{ - lexer.NextToken(); - Expression expr; - Expr(out expr); - return expr; -} -// Begin ISTypeCast -bool IsTypeCast() -{ - if (la.kind != Tokens.OpenParenthesis) { - return false; - } - if (IsSimpleTypeCast()) { - return true; - } - return GuessTypeCast(); -} - -// "(" ( typeKW [ "[" {","} "]" | "*" ] | void ( "[" {","} "]" | "*" ) ) ")" -// only for built-in types, all others use GuessTypeCast! -bool IsSimpleTypeCast () -{ - // assert: la.kind == _lpar - lexer.StartPeek(); - Token pt = lexer.Peek(); - - if (!IsTypeKWForTypeCast(ref pt)) { - return false; - } - if (pt.kind == Tokens.Question) - pt = lexer.Peek(); - return pt.kind == Tokens.CloseParenthesis; -} - -/* !!! Proceeds from current peek position !!! */ -bool IsTypeKWForTypeCast(ref Token pt) -{ - if (Tokens.TypeKW[pt.kind]) { - pt = lexer.Peek(); - return IsPointerOrDims(ref pt) && SkipQuestionMark(ref pt); - } else if (pt.kind == Tokens.Void) { - pt = lexer.Peek(); - return IsPointerOrDims(ref pt); - } - return false; -} - -/* !!! Proceeds from current peek position !!! */ -bool IsTypeNameOrKWForTypeCast(ref Token pt) -{ - if (IsTypeKWForTypeCast(ref pt)) - return true; - else - return IsTypeNameForTypeCast(ref pt); -} - -// TypeName = ident [ "::" ident ] { ["<" TypeNameOrKW { "," TypeNameOrKW } ">" ] "." ident } ["?"] PointerOrDims -/* !!! Proceeds from current peek position !!! */ -bool IsTypeNameForTypeCast(ref Token pt) -{ - // ident - if (pt.kind != Tokens.Identifier) { - return false; - } - pt = Peek(); - // "::" ident - if (pt.kind == Tokens.DoubleColon) { - pt = Peek(); - if (pt.kind != Tokens.Identifier) { - return false; - } - pt = Peek(); - } - // { ["<" TypeNameOrKW { "," TypeNameOrKW } ">" ] "." ident } - while (true) { - if (pt.kind == Tokens.LessThan) { - do { - pt = Peek(); - if (!IsTypeNameOrKWForTypeCast(ref pt)) { - return false; - } - } while (pt.kind == Tokens.Comma); - if (pt.kind != Tokens.GreaterThan) { - return false; - } - pt = Peek(); - } - if (pt.kind != Tokens.Dot) - break; - pt = Peek(); - if (pt.kind != Tokens.Identifier) { - return false; - } - pt = Peek(); - } - // ["?"] - if (pt.kind == Tokens.Question) { - pt = Peek(); - } - if (pt.kind == Tokens.Times || pt.kind == Tokens.OpenSquareBracket) { - return IsPointerOrDims(ref pt); - } - return true; -} - -// "(" TypeName ")" castFollower -bool GuessTypeCast () -{ - // assert: la.kind == _lpar - StartPeek(); - Token pt = Peek(); - - if (!IsTypeNameForTypeCast(ref pt)) { - return false; - } - - // ")" - if (pt.kind != Tokens.CloseParenthesis) { - return false; - } - // check successor - pt = Peek(); - return Tokens.CastFollower[pt.kind] || (Tokens.TypeKW[pt.kind] && lexer.Peek().kind == Tokens.Dot); -} -// END IsTypeCast - -/* Checks whether the next sequences of tokens is a qualident * - * and returns the qualident string */ -/* !!! Proceeds from current peek position !!! */ -bool IsQualident(ref Token pt, out string qualident) -{ - if (pt.kind == Tokens.Identifier) { - qualidentBuilder.Length = 0; qualidentBuilder.Append(pt.val); - pt = Peek(); - while (pt.kind == Tokens.Dot || pt.kind == Tokens.DoubleColon) { - pt = Peek(); - if (pt.kind != Tokens.Identifier) { - qualident = String.Empty; - return false; - } - qualidentBuilder.Append('.'); - qualidentBuilder.Append(pt.val); - pt = Peek(); - } - qualident = qualidentBuilder.ToString(); - return true; - } - qualident = String.Empty; - return false; -} - -/* Skips generic type extensions */ -/* !!! Proceeds from current peek position !!! */ - -/* skip: { "*" | "[" { "," } "]" } */ -/* !!! Proceeds from current peek position !!! */ -bool IsPointerOrDims (ref Token pt) -{ - for (;;) { - if (pt.kind == Tokens.OpenSquareBracket) { - do pt = Peek(); - while (pt.kind == Tokens.Comma); - if (pt.kind != Tokens.CloseSquareBracket) return false; - } else if (pt.kind != Tokens.Times) break; - pt = Peek(); - } - return true; -} - -/* Return the n-th token after the current lookahead token */ -void StartPeek() -{ - lexer.StartPeek(); -} - -Token Peek() -{ - return lexer.Peek(); -} - -Token Peek (int n) -{ - lexer.StartPeek(); - Token x = la; - while (n > 0) { - x = lexer.Peek(); - n--; - } - return x; -} - -/*-----------------------------------------------------------------* - * Resolver routines to resolve LL(1) conflicts: * * - * These resolution routine return a boolean value that indicates * - * whether the alternative at hand shall be choosen or not. * - * They are used in IF ( ... ) expressions. * - *-----------------------------------------------------------------*/ - -/* True, if ident is followed by "=" */ -bool IdentAndAsgn () -{ - return la.kind == Tokens.Identifier && Peek(1).kind == Tokens.Assign; -} - -bool IsAssignment () { return IdentAndAsgn(); } - -/* True, if ident is followed by ",", "=", or ";" */ -bool IdentAndCommaOrAsgnOrSColon () { - int peek = Peek(1).kind; - return la.kind == Tokens.Identifier && - (peek == Tokens.Comma || peek == Tokens.Assign || peek == Tokens.Semicolon); -} -bool IsVarDecl () { return IdentAndCommaOrAsgnOrSColon(); } - -/* True, if the comma is not a trailing one, * - * like the last one in: a, b, c, */ -bool NotFinalComma () { - int peek = Peek(1).kind; - return la.kind == Tokens.Comma && - peek != Tokens.CloseCurlyBrace && peek != Tokens.CloseSquareBracket; -} - -/* True, if "void" is followed by "*" */ -bool NotVoidPointer () { - return la.kind == Tokens.Void && Peek(1).kind != Tokens.Times; -} - -/* True, if "checked" or "unchecked" are followed by "{" */ -bool UnCheckedAndLBrace () { - return la.kind == Tokens.Checked || la.kind == Tokens.Unchecked && - Peek(1).kind == Tokens.OpenCurlyBrace; -} - -/* True, if "." is followed by an ident */ -bool DotAndIdent () { - return la.kind == Tokens.Dot && Peek(1).kind == Tokens.Identifier; -} - -/* True, if ident is followed by ":" */ -bool IdentAndColon () { - return la.kind == Tokens.Identifier && Peek(1).kind == Tokens.Colon; -} - -bool IsLabel () { return IdentAndColon(); } - -/* True, if ident is followed by "(" */ -bool IdentAndLPar () { - return la.kind == Tokens.Identifier && Peek(1).kind == Tokens.OpenParenthesis; -} - -/* True, if "catch" is followed by "(" */ -bool CatchAndLPar () { - return la.kind == Tokens.Catch && Peek(1).kind == Tokens.OpenParenthesis; -} -bool IsTypedCatch () { return CatchAndLPar(); } - -/* True, if "[" is followed by the ident "assembly" */ -bool IsGlobalAttrTarget () { - Token pt = Peek(1); - return la.kind == Tokens.OpenSquareBracket && - pt.kind == Tokens.Identifier && pt.val == "assembly"; -} - -/* True, if "[" is followed by "," or "]" */ -bool LBrackAndCommaOrRBrack () { - int peek = Peek(1).kind; - return la.kind == Tokens.OpenSquareBracket && - (peek == Tokens.Comma || peek == Tokens.CloseSquareBracket); -} - -bool IsDims () { return LBrackAndCommaOrRBrack(); } - -/* True, if "[" is followed by "," or "]" */ -/* or if the current token is "*" */ -bool TimesOrLBrackAndCommaOrRBrack () { - return la.kind == Tokens.Times || LBrackAndCommaOrRBrack(); -} -bool IsPointerOrDims () { return TimesOrLBrackAndCommaOrRBrack(); } -bool IsPointer () { return la.kind == Tokens.Times; } - - -bool SkipGeneric(ref Token pt) -{ - if (pt.kind == Tokens.LessThan) { - do { - pt = Peek(); - if (!IsTypeNameOrKWForTypeCast(ref pt)) return false; - } while (pt.kind == Tokens.Comma); - if (pt.kind != Tokens.GreaterThan) return false; - pt = Peek(); - } - return true; -} -bool SkipQuestionMark(ref Token pt) -{ - if (pt.kind == Tokens.Question) { - pt = Peek(); - } - return true; -} - -/* True, if lookahead is a primitive type keyword, or */ -/* if it is a type declaration followed by an ident */ -bool IsLocalVarDecl () { - if (IsYieldStatement()) { - return false; - } - if ((Tokens.TypeKW[la.kind] && Peek(1).kind != Tokens.Dot) || la.kind == Tokens.Void) { - return true; - } - - StartPeek(); - Token pt = la; - return IsTypeNameOrKWForTypeCast(ref pt) && pt.kind == Tokens.Identifier; -} - -/* True if lookahead is type parameters (<...>) followed by the specified token */ -bool IsGenericFollowedBy(int token) -{ - Token t = la; - if (t.kind != Tokens.LessThan) return false; - StartPeek(); - return SkipGeneric(ref t) && t.kind == token; -} - -bool IsExplicitInterfaceImplementation() -{ - StartPeek(); - Token pt = la; - pt = Peek(); - if (pt.kind == Tokens.Dot || pt.kind == Tokens.DoubleColon) - return true; - if (pt.kind == Tokens.LessThan) { - if (SkipGeneric(ref pt)) - return pt.kind == Tokens.Dot; - } - return false; -} - -/* True, if lookahead ident is "where" */ -bool IdentIsWhere () { - return la.kind == Tokens.Identifier && la.val == "where"; -} - -/* True, if lookahead ident is "get" */ -bool IdentIsGet () { - return la.kind == Tokens.Identifier && la.val == "get"; -} - -/* True, if lookahead ident is "set" */ -bool IdentIsSet () { - return la.kind == Tokens.Identifier && la.val == "set"; -} - -/* True, if lookahead ident is "add" */ -bool IdentIsAdd () { - return la.kind == Tokens.Identifier && la.val == "add"; -} - -/* True, if lookahead ident is "remove" */ -bool IdentIsRemove () { - return la.kind == Tokens.Identifier && la.val == "remove"; -} - -bool IsNotYieldStatement () { - return !IsYieldStatement(); -} -/* True, if lookahead ident is "yield" and than follows a break or return */ -bool IsYieldStatement () { - return la.kind == Tokens.Identifier && la.val == "yield" && (Peek(1).kind == Tokens.Return || Peek(1).kind == Tokens.Break); -} - -/* True, if lookahead is a local attribute target specifier, * - * i.e. one of "event", "return", "field", "method", * - * "module", "param", "property", or "type" */ -bool IsLocalAttrTarget () { - int cur = la.kind; - string val = la.val; - - return (cur == Tokens.Event || cur == Tokens.Return || - (cur == Tokens.Identifier && - (val == "field" || val == "method" || val == "module" || - val == "param" || val == "property" || val == "type"))) && - Peek(1).kind == Tokens.Colon; -} - -bool IsShiftRight() -{ - Token next = Peek(1); - // TODO : Add col test (seems not to work, lexer bug...) : && la.col == next.col - 1 - return (la.kind == Tokens.GreaterThan && next.kind == Tokens.GreaterThan); -} - -bool IsTypeReferenceExpression(Expression expr) -{ - if (expr is TypeReferenceExpression) return ((TypeReferenceExpression)expr).TypeReference.GenericTypes.Count == 0; - while (expr is FieldReferenceExpression) { - expr = ((FieldReferenceExpression)expr).TargetObject; - if (expr is TypeReferenceExpression) return true; - } - return expr is IdentifierExpression; -} - -TypeReferenceExpression GetTypeReferenceExpression(Expression expr, List genericTypes) -{ - TypeReferenceExpression tre = expr as TypeReferenceExpression; - if (tre != null) { - return new TypeReferenceExpression(new TypeReference(tre.TypeReference.Type, tre.TypeReference.PointerNestingLevel, tre.TypeReference.RankSpecifier, genericTypes)); - } - StringBuilder b = new StringBuilder(); - if (!WriteFullTypeName(b, expr)) { - // there is some TypeReferenceExpression hidden in the expression - while (expr is FieldReferenceExpression) { - expr = ((FieldReferenceExpression)expr).TargetObject; - } - tre = expr as TypeReferenceExpression; - if (tre != null) { - TypeReference typeRef = tre.TypeReference; - if (typeRef.GenericTypes.Count == 0) { - typeRef = typeRef.Clone(); - typeRef.Type += "." + b.ToString(); - typeRef.GenericTypes.AddRange(genericTypes); - } else { - typeRef = new InnerClassTypeReference(typeRef, b.ToString(), genericTypes); - } - return new TypeReferenceExpression(typeRef); - } - } - return new TypeReferenceExpression(new TypeReference(b.ToString(), 0, null, genericTypes)); -} - -/* Writes the type name represented through the expression into the string builder. */ -/* Returns true when the expression was converted successfully, returns false when */ -/* There was an unknown expression (e.g. TypeReferenceExpression) in it */ -bool WriteFullTypeName(StringBuilder b, Expression expr) -{ - FieldReferenceExpression fre = expr as FieldReferenceExpression; - if (fre != null) { - bool result = WriteFullTypeName(b, fre.TargetObject); - if (b.Length > 0) b.Append('.'); - b.Append(fre.FieldName); - return result; - } else if (expr is IdentifierExpression) { - b.Append(((IdentifierExpression)expr).Identifier); - return true; - } else { - return false; - } -} /*------------------------------------------------------------------------* *----- LEXER TOKEN LIST ------------------------------------------------* @@ -652,7 +170,7 @@ UsingDirective string qualident = null; TypeReference aliasedType = null; .) = - "using" (. Point startPos = t.Location; .) + "using" (. Location startPos = t.Location; .) Qualident [ "=" NonArrayType ] ";" (. @@ -672,7 +190,7 @@ UsingDirective GlobalAttributeSection = - "[" (. Point startPos = t.Location; .) ident + "[" (. Location startPos = t.Location; .) ident (. if (t.val != "assembly") Error("global attribute target specifier (\"assembly\") expected"); string attributeTarget = t.val; List attributes = new List(); @@ -747,7 +265,7 @@ AttributeSection .) = - "[" (. Point startPos = t.Location; .) /*--- attribute target specifier: */ + "[" (. Location startPos = t.Location; .) /*--- attribute target specifier: */ [ IF (IsLocalAttrTarget()) ( "event" (. attributeTarget = "event";.) | "return" (. attributeTarget = "return";.) @@ -778,7 +296,7 @@ NamespaceMemberDecl string qualident; .) = /*--- namespace declaration: */ - "namespace" (. Point startPos = t.Location; .) + "namespace" (. Location startPos = t.Location; .) Qualident (. INode node = new NamespaceDeclaration(qualident); node.StartLocation = startPos; compilationUnit.AddChild(node); @@ -1189,7 +707,7 @@ StructMemberDecl attributes> .) = /*--- constant declaration: */ (. m.Check(Modifier.Constants); .) - "const" (.Point startPos = t.Location; .) + "const" (.Location startPos = t.Location; .) Type ident (. FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclaration f = new VariableDeclaration(t.val); @@ -1205,7 +723,7 @@ StructMemberDecl attributes> | /*--- void method (procedure) declaration: */ IF (NotVoidPointer()) (. m.Check(Modifier.PropertysEventsMethods); .) - "void" (. Point startPos = t.Location; .) + "void" (. Location startPos = t.Location; .) ( IF (IsExplicitInterfaceImplementation()) TypeName (.if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { @@ -1268,7 +786,7 @@ StructMemberDecl attributes> | /*--- constructor or static contructor declaration: */ IF (IdentAndLPar()) (. m.Check(Modifier.Constructors | Modifier.StaticConstructors); .) - ident (. string name = t.val; Point startPos = t.Location; .) "(" [ (. m.Check(Modifier.Constructors); .) + ident (. string name = t.val; Location startPos = t.Location; .) "(" [ (. m.Check(Modifier.Constructors); .) FormalParameterList

] ")" (.ConstructorInitializer init = null; .) @@ -1286,12 +804,12 @@ StructMemberDecl attributes> | /*--- conversion operator declaration: */ (. m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; - Point startPos = Point.Empty; + Location startPos = Location.Empty; .) ( "implicit" (. startPos = t.Location; .) | "explicit" (. isImplicit = false; startPos = t.Location; .) ) "operator" Type (. TypeReference operatorType = type; .) "(" Type ident (. string varName = t.val; .) ")" - (. Point endPos = t.Location; .) + (. Location endPos = t.Location; .) ( Block | ";" (. stmt = null; .) ) (. @@ -1313,7 +831,7 @@ StructMemberDecl attributes> | /*--- inner type declaration: */ TypeDecl -| Type (. Point startPos = t.Location; .) +| Type (. Location startPos = t.Location; .) ( /*--- operator declaration: */ (. OverloadableOperatorType op; m.Check(Modifier.Operators); @@ -1329,7 +847,7 @@ StructMemberDecl attributes> } .)*/ ) - (. Point endPos = t.Location; .) + (. Location endPos = t.Location; .) ")" ( Block | ";" ) (. List parameters = new List(); @@ -1359,7 +877,7 @@ StructMemberDecl attributes> /*--- unqualified indexer declaration (without interface name): */ | (. m.Check(Modifier.Indexers); .) - "this" "[" FormalParameterList

"]" (. Point endLocation = t.EndLocation; .) "{" (. + "this" "[" FormalParameterList

"]" (. Location endLocation = t.EndLocation; .) "{" (. IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -1381,7 +899,7 @@ StructMemberDecl attributes> } .) | ident (. qualident = t.val; .) ) - (. Point qualIdentEndLocation = t.EndLocation; .) + (. Location qualIdentEndLocation = t.EndLocation; .) ( /*--- "not void" method (function) declaration: */ @@ -1434,7 +952,7 @@ StructMemberDecl attributes> PropertyGetRegion getRegion; PropertySetRegion setRegion; .) - "{" (. Point bodyStart = t.Location; .) + "{" (. Location bodyStart = t.Location; .) AccessorDecls "}" (. indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; @@ -1450,7 +968,7 @@ ClassMemberDecl attributes> (. Statement stmt = null; .) = StructMemberDecl - | /*--- destructor declaration: */ (. m.Check(Modifier.Destructors); Point startPos = t.Location; .) + | /*--- destructor declaration: */ (. m.Check(Modifier.Destructors); Location startPos = t.Location; .) "~" ident (. DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = m.GetDeclarationLocation(startPos); @@ -1472,7 +990,7 @@ InterfaceMemberDecl string name; PropertyGetRegion getBlock; PropertySetRegion setBlock; - Point startLocation = new Point(-1, -1); + Location startLocation = new Location(-1, -1); List templates = new List(); .) = @@ -1494,7 +1012,7 @@ InterfaceMemberDecl | ( Type (. if (startLocation.X == -1) startLocation = t.Location; .) ( - ident (. name = t.val; Point qualIdentEndLocation = t.EndLocation; .) + ident (. name = t.val; Location qualIdentEndLocation = t.EndLocation; .) ( /*--- interface "not void" method (function) declaration: */ /* .NET 2.0 */ @@ -1510,11 +1028,11 @@ InterfaceMemberDecl .) /*--- interface property declaration: */ | (. PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); .) - "{" (. Point bodyStart = t.Location;.) InterfaceAccessors "}" (. pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; .) + "{" (. Location bodyStart = t.Location;.) InterfaceAccessors "}" (. pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; .) ) /*--- interface indexer declaration: */ - | "this" "[" FormalParameterList "]" (.Point bracketEndLocation = t.EndLocation; .) (. IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); .) - "{" (. Point bodyStart = t.Location;.) InterfaceAccessors "}" (. id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;.) + | "this" "[" FormalParameterList "]" (.Location bracketEndLocation = t.EndLocation; .) (. IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); .) + "{" (. Location bodyStart = t.Location;.) InterfaceAccessors "}" (. id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;.) ) /*--- interface event declaration: */ | "event" (. if (startLocation.X == -1) startLocation = t.Location; .) Type ident (. EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes, null); @@ -1582,7 +1100,7 @@ GetAccessorDecl attribute = ident /* "get" is not a keyword! */ (. if (t.val != "get") Error("get expected"); .) - (. Point startLocation = t.Location; .) + (. Location startLocation = t.Location; .) ( Block | ";" ) (. getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); .) (. getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; .) @@ -1593,7 +1111,7 @@ SetAccessorDecl attribute = ident /* "set" is not a keyword! */ (. if (t.val != "set") Error("set expected"); .) - (. Point startLocation = t.Location; .) + (. Location startLocation = t.Location; .) ( Block | ";" ) (. setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); .) (. setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; .) @@ -1630,7 +1148,7 @@ InterfaceAccessors (. attributes.Add(section); .) } - (. Point startLocation = la.Location; .) + (. Location startLocation = la.Location; .) ( IF (IdentIsGet()) ident (. getBlock = new PropertyGetRegion(null, attributes); .) | IF (IdentIsSet()) ident (. setBlock = new PropertySetRegion(null, attributes); .) @@ -1669,7 +1187,7 @@ Block /* not BlockStatement because of EmbeddedStatement */ "{" (. BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.EndLocation; compilationUnit.BlockStart(blockStmt); - if (!parseMethodContents) lexer.SkipCurrentBlock(); + if (!parseMethodContents) lexer.SkipCurrentBlock(0); .) { Statement } "}" (. @@ -1828,7 +1346,7 @@ Statement TypeReference type; Expression expr; Statement stmt = null; - Point startPos = la.Location; + Location startPos = la.Location; .) = ( @@ -1900,7 +1418,7 @@ EmbeddedStatement [ Expr ] ";" [ ForIterator ] ")" EmbeddedStatement (. statement = new ForStatement(initializer, expr, iterator, embeddedStatement); .) - | "foreach" "(" Type ident (. string varName = t.val; Point start = t.Location;.) + | "foreach" "(" Type ident (. string varName = t.val; Location start = t.Location;.) "in" Expr ")" EmbeddedStatement (. statement = new ForeachStatement(type, varName , expr, embeddedStatement); statement.EndLocation = t.EndLocation; @@ -2281,7 +1799,7 @@ AnonymousMethodExpr Block (. expr.Body = (BlockStatement)stmt; .) (. } else { .) "{" - (. lexer.SkipCurrentBlock(); .) + (. lexer.SkipCurrentBlock(0); .) "}" (. } .) (. expr.EndLocation = t.Location; .) diff --git a/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame b/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame index 09ae9caf45..3463003c31 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame +++ b/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame @@ -8,7 +8,7 @@ using System.Reflection; -->tokens -internal class Parser : AbstractParser +partial class Parser : AbstractParser { -->constants const bool T = true; @@ -21,48 +21,12 @@ internal class Parser : AbstractParser */ -->productions - public Parser(ILexer lexer) : base(lexer) - { - } public override void Parse() { -->parseRoot } - protected void ExpectWeak(int n, int follow) - { - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - } else { - SynErr(n); - while (!StartOf(follow)) { - lexer.NextToken(); - } - } - } - - protected bool WeakSeparator(int n, int syFol, int repFol) - { - bool[] s = new bool[maxT + 1]; - - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - return true; - } else if (StartOf(repFol)) { - return false; - } else { - for (int i = 0; i <= maxT; i++) { - s[i] = set[syFol, i] || set[repFol, i] || set[0, i]; - } - SynErr(n); - while (!s[lexer.LookAhead.kind]) { - lexer.NextToken(); - } - return StartOf(syFol); - } - } - protected override void SynErr(int line, int col, int errorNumber) { errors.count++; @@ -74,7 +38,7 @@ internal class Parser : AbstractParser errors.Error(line, col, s); } - protected bool StartOf(int s) + private bool StartOf(int s) { return set[s, lexer.LookAhead.kind]; } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame.new b/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame.new index a37b20b597..4a0e4cbf24 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame.new +++ b/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame.new @@ -30,41 +30,7 @@ internal class Parser : AbstractParser -->parseRoot } - protected void ExpectWeak(int n, int follow) - { - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - } else { - SynErr(n); - while (!StartOf(follow)) { - lexer.NextToken(); - } - } - } - - protected bool WeakSeparator(int n, int syFol, int repFol) - { - bool[] s = new bool[maxT + 1]; - - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - return true; - } else if (StartOf(repFol)) { - return false; - } else { - for (int i = 0; i <= maxT; i++) { - s[i] = set[syFol, i] || set[repFol, i] || set[0, i]; - } - SynErr(n); - while (!s[lexer.LookAhead.kind]) { - lexer.NextToken(); - } - return StartOf(syFol); - } - } - - - protected bool StartOf(int s) + private bool StartOf(int s) { return set[s, lexer.LookAhead.kind]; } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame.old b/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame.old index 86ed818937..fa07ea311f 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame.old +++ b/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame.old @@ -8,7 +8,7 @@ using System.Reflection; -->tokens -internal class Parser : AbstractParser +partial class Parser : AbstractParser { -->constants const bool T = true; @@ -21,48 +21,12 @@ internal class Parser : AbstractParser */ -->productions - public Parser(ILexer lexer) : base(lexer) - { - } public override void Parse() { -->parseRoot } - protected void ExpectWeak(int n, int follow) - { - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - } else { - SynErr(n); - while (!StartOf(follow)) { - lexer.NextToken(); - } - } - } - - protected bool WeakSeparator(int n, int syFol, int repFol) - { - bool[] s = new bool[maxT + 1]; - - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - return true; - } else if (StartOf(repFol)) { - return false; - } else { - for (int i = 0; i <= maxT; i++) { - s[i] = set[syFol, i] || set[repFol, i] || set[0, i]; - } - SynErr(n); - while (!s[lexer.LookAhead.kind]) { - lexer.NextToken(); - } - return StartOf(syFol); - } - } - protected override void SynErr(int line, int col, int errorNumber) { errors.count++; @@ -74,7 +38,7 @@ internal class Parser : AbstractParser errors.Error(line, col, s); } - protected bool StartOf(int s) + private bool StartOf(int s) { return set[s, lexer.LookAhead.kind]; } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs index ad7cc5e77c..a8c69ec349 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs @@ -17,7 +17,7 @@ namespace ICSharpCode.NRefactory.Parser.VB { -internal class Parser : AbstractParser +partial class Parser : AbstractParser { const int maxT = 205; @@ -25,254 +25,7 @@ internal class Parser : AbstractParser const bool x = false; -#line 11 "VBNET.ATG" -private Stack withStatements; -private StringBuilder qualidentBuilder = new StringBuilder(); - -Token t -{ - [System.Diagnostics.DebuggerStepThrough] - get { - return lexer.Token; - } -} -Token la -{ - [System.Diagnostics.DebuggerStepThrough] - get { - return lexer.LookAhead; - } -} - -/* Return the n-th token after the current lookahead token */ -void StartPeek() -{ - lexer.StartPeek(); -} - -Token Peek() -{ - return lexer.Peek(); -} - -Token Peek (int n) -{ - lexer.StartPeek(); - Token x = la; - while (n > 0) { - x = lexer.Peek(); - n--; - } - return x; -} - -public void Error(string s) -{ - if (errDist >= minErrDist) { - errors.Error(la.line, la.col, s); - } - errDist = 0; -} - -public override Expression ParseExpression() -{ - lexer.NextToken(); - Expression expr; - Expr(out expr); - return expr; -} - -bool LeaveBlock() -{ - int peek = Peek(1).kind; - return Tokens.BlockSucc[la.kind] && (la.kind != Tokens.End || peek == Tokens.EOL || peek == Tokens.Colon); -} - -/* True, if "." is followed by an ident */ -bool DotAndIdentOrKw () { - int peek = Peek(1).kind; - return la.kind == Tokens.Dot && (peek == Tokens.Identifier || peek >= Tokens.AddHandler); -} - -bool IsEndStmtAhead() -{ - int peek = Peek(1).kind; - return la.kind == Tokens.End && (peek == Tokens.EOL || peek == Tokens.Colon); -} - -bool IsNotClosingParenthesis() { - return la.kind != Tokens.CloseParenthesis; -} - -/* - True, if ident is followed by "=" -*/ -bool IdentAndAsgn () { - if(la.kind == Tokens.Identifier) { - if(Peek(1).kind == Tokens.Assign) return true; - if(Peek(1).kind == Tokens.Colon && Peek(2).kind == Tokens.Assign) return true; - } - return false; -} - -/* - True, if ident is followed by "=" or by ":" and "=" -*/ -bool IsNamedAssign() { -// if(Peek(1).kind == Tokens.Assign) return true; // removed: not in the lang spec - if(Peek(1).kind == Tokens.Colon && Peek(2).kind == Tokens.Assign) return true; - return false; -} - -bool IsObjectCreation() { - return la.kind == Tokens.As && Peek(1).kind == Tokens.New; -} - -/* - True, if "<" is followed by the ident "assembly" or "module" -*/ -bool IsGlobalAttrTarget () { - Token pt = Peek(1); - return la.kind == Tokens.LessThan && ( string.Equals(pt.val, "assembly", StringComparison.InvariantCultureIgnoreCase) || string.Equals(pt.val, "module", StringComparison.InvariantCultureIgnoreCase)); -} - -/* - True if the next token is a "(" and is followed by "," or ")" -*/ -bool IsDims() -{ - int peek = Peek(1).kind; - return la.kind == Tokens.OpenParenthesis - && (peek == Tokens.Comma || peek == Tokens.CloseParenthesis); -} - -bool IsSize() -{ - return la.kind == Tokens.OpenParenthesis; -} - -/* - True, if the comma is not a trailing one, - like the last one in: a, b, c, -*/ -bool NotFinalComma() { - int peek = Peek(1).kind; - return la.kind == Tokens.Comma && - peek != Tokens.CloseCurlyBrace; -} - -/* - True, if the next token is "Else" and this one - if followed by "If" -*/ -bool IsElseIf() -{ - int peek = Peek(1).kind; - return la.kind == Tokens.Else && peek == Tokens.If; -} - -/* - True if the next token is goto and this one is - followed by minus ("-") (this is allowd in in - error clauses) -*/ -bool IsNegativeLabelName() -{ - int peek = Peek(1).kind; - return la.kind == Tokens.GoTo && peek == Tokens.Minus; -} - -/* - True if the next statement is a "Resume next" statement -*/ -bool IsResumeNext() -{ - int peek = Peek(1).kind; - return la.kind == Tokens.Resume && peek == Tokens.Next; -} - -/* - True, if ident/literal integer is followed by ":" -*/ -bool IsLabel() -{ - return (la.kind == Tokens.Identifier || la.kind == Tokens.LiteralInteger) - && Peek(1).kind == Tokens.Colon; -} - -bool IsNotStatementSeparator() -{ - return la.kind == Tokens.Colon && Peek(1).kind == Tokens.EOL; -} - -bool IsAssignment () -{ - return IdentAndAsgn(); -} - -bool IsMustOverride(Modifiers m) -{ - return m.Contains(Modifier.Abstract); -} - -TypeReferenceExpression GetTypeReferenceExpression(Expression expr, List genericTypes) -{ - TypeReferenceExpression tre = expr as TypeReferenceExpression; - if (tre != null) { - return new TypeReferenceExpression(new TypeReference(tre.TypeReference.Type, tre.TypeReference.PointerNestingLevel, tre.TypeReference.RankSpecifier, genericTypes)); - } - StringBuilder b = new StringBuilder(); - if (!WriteFullTypeName(b, expr)) { - // there is some TypeReferenceExpression hidden in the expression - while (expr is FieldReferenceExpression) { - expr = ((FieldReferenceExpression)expr).TargetObject; - } - tre = expr as TypeReferenceExpression; - if (tre != null) { - TypeReference typeRef = tre.TypeReference; - if (typeRef.GenericTypes.Count == 0) { - typeRef = typeRef.Clone(); - typeRef.Type += "." + b.ToString(); - typeRef.GenericTypes.AddRange(genericTypes); - } else { - typeRef = new InnerClassTypeReference(typeRef, b.ToString(), genericTypes); - } - return new TypeReferenceExpression(typeRef); - } - } - return new TypeReferenceExpression(new TypeReference(b.ToString(), 0, null, genericTypes)); -} - -/* Writes the type name represented through the expression into the string builder. */ -/* Returns true when the expression was converted successfully, returns false when */ -/* There was an unknown expression (e.g. TypeReferenceExpression) in it */ -bool WriteFullTypeName(StringBuilder b, Expression expr) -{ - FieldReferenceExpression fre = expr as FieldReferenceExpression; - if (fre != null) { - bool result = WriteFullTypeName(b, fre.TargetObject); - if (b.Length > 0) b.Append('.'); - b.Append(fre.FieldName); - return result; - } else if (expr is IdentifierExpression) { - b.Append(((IdentifierExpression)expr).Identifier); - return true; - } else { - return false; - } -} - -/* - True, if lookahead is a local attribute target specifier, - i.e. one of "event", "return", "field", "method", - "module", "param", "property", or "type" -*/ -bool IsLocalAttrTarget() { - // TODO - return false; -} - -/* START AUTOGENERATED TOKENS SECTION */ +#line 12 "VBNET.ATG" /* @@ -281,10 +34,9 @@ bool IsLocalAttrTarget() { void VBNET() { -#line 476 "VBNET.ATG" +#line 230 "VBNET.ATG" lexer.NextToken(); // get the first token compilationUnit = new CompilationUnit(); - withStatements = new Stack(); while (la.kind == 1) { lexer.NextToken(); @@ -296,7 +48,7 @@ bool IsLocalAttrTarget() { ImportsStmt(); } while ( -#line 483 "VBNET.ATG" +#line 236 "VBNET.ATG" IsGlobalAttrTarget()) { GlobalAttributeSection(); } @@ -308,49 +60,49 @@ IsGlobalAttrTarget()) { void OptionStmt() { -#line 488 "VBNET.ATG" +#line 241 "VBNET.ATG" INode node = null; bool val = true; Expect(136); -#line 489 "VBNET.ATG" +#line 242 "VBNET.ATG" Location startPos = t.Location; if (la.kind == 95) { lexer.NextToken(); if (la.kind == 134 || la.kind == 135) { OptionValue( -#line 491 "VBNET.ATG" +#line 244 "VBNET.ATG" ref val); } -#line 492 "VBNET.ATG" +#line 245 "VBNET.ATG" node = new OptionDeclaration(OptionType.Explicit, val); } else if (la.kind == 164) { lexer.NextToken(); if (la.kind == 134 || la.kind == 135) { OptionValue( -#line 494 "VBNET.ATG" +#line 247 "VBNET.ATG" ref val); } -#line 495 "VBNET.ATG" +#line 248 "VBNET.ATG" node = new OptionDeclaration(OptionType.Strict, val); } else if (la.kind == 70) { lexer.NextToken(); if (la.kind == 51) { lexer.NextToken(); -#line 497 "VBNET.ATG" +#line 250 "VBNET.ATG" node = new OptionDeclaration(OptionType.CompareBinary, val); } else if (la.kind == 169) { lexer.NextToken(); -#line 498 "VBNET.ATG" +#line 251 "VBNET.ATG" node = new OptionDeclaration(OptionType.CompareText, val); } else SynErr(206); } else SynErr(207); EndOfStmt(); -#line 503 "VBNET.ATG" +#line 256 "VBNET.ATG" if (node != null) { node.StartLocation = startPos; node.EndLocation = t.Location; @@ -361,33 +113,33 @@ ref val); void ImportsStmt() { -#line 526 "VBNET.ATG" +#line 279 "VBNET.ATG" List usings = new List(); Expect(108); -#line 530 "VBNET.ATG" +#line 283 "VBNET.ATG" Location startPos = t.Location; Using u; ImportClause( -#line 533 "VBNET.ATG" +#line 286 "VBNET.ATG" out u); -#line 533 "VBNET.ATG" +#line 286 "VBNET.ATG" if (u != null) { usings.Add(u); } while (la.kind == 12) { lexer.NextToken(); ImportClause( -#line 535 "VBNET.ATG" +#line 288 "VBNET.ATG" out u); -#line 535 "VBNET.ATG" +#line 288 "VBNET.ATG" if (u != null) { usings.Add(u); } } EndOfStmt(); -#line 539 "VBNET.ATG" +#line 292 "VBNET.ATG" UsingDeclaration usingDeclaration = new UsingDeclaration(usings); usingDeclaration.StartLocation = startPos; usingDeclaration.EndLocation = t.Location; @@ -397,7 +149,7 @@ out u); void GlobalAttributeSection() { -#line 2188 "VBNET.ATG" +#line 1958 "VBNET.ATG" Location startPos = t.Location; Expect(27); if (la.kind == 49) { @@ -406,20 +158,20 @@ out u); lexer.NextToken(); } else SynErr(208); -#line 2190 "VBNET.ATG" +#line 1960 "VBNET.ATG" string attributeTarget = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture); List attributes = new List(); ASTAttribute attribute; Expect(13); Attribute( -#line 2194 "VBNET.ATG" +#line 1964 "VBNET.ATG" out attribute); -#line 2194 "VBNET.ATG" +#line 1964 "VBNET.ATG" attributes.Add(attribute); while ( -#line 2195 "VBNET.ATG" +#line 1965 "VBNET.ATG" NotFinalComma()) { if (la.kind == 12) { lexer.NextToken(); @@ -431,10 +183,10 @@ NotFinalComma()) { Expect(13); } Attribute( -#line 2195 "VBNET.ATG" +#line 1965 "VBNET.ATG" out attribute); -#line 2195 "VBNET.ATG" +#line 1965 "VBNET.ATG" attributes.Add(attribute); } if (la.kind == 12) { @@ -443,7 +195,7 @@ out attribute); Expect(26); EndOfStmt(); -#line 2200 "VBNET.ATG" +#line 1970 "VBNET.ATG" AttributeSection section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -453,7 +205,7 @@ out attribute); void NamespaceMemberDecl() { -#line 568 "VBNET.ATG" +#line 321 "VBNET.ATG" Modifiers m = new Modifiers(); AttributeSection section; List attributes = new List(); @@ -462,14 +214,14 @@ out attribute); if (la.kind == 126) { lexer.NextToken(); -#line 575 "VBNET.ATG" +#line 328 "VBNET.ATG" Location startPos = t.Location; Qualident( -#line 577 "VBNET.ATG" +#line 330 "VBNET.ATG" out qualident); -#line 579 "VBNET.ATG" +#line 332 "VBNET.ATG" INode node = new NamespaceDeclaration(qualident); node.StartLocation = startPos; compilationUnit.AddChild(node); @@ -478,42 +230,42 @@ out qualident); Expect(1); NamespaceBody(); -#line 587 "VBNET.ATG" +#line 340 "VBNET.ATG" node.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (StartOf(2)) { while (la.kind == 27) { AttributeSection( -#line 591 "VBNET.ATG" +#line 344 "VBNET.ATG" out section); -#line 591 "VBNET.ATG" +#line 344 "VBNET.ATG" attributes.Add(section); } while (StartOf(3)) { TypeModifier( -#line 592 "VBNET.ATG" +#line 345 "VBNET.ATG" m); } NonModuleDeclaration( -#line 592 "VBNET.ATG" +#line 345 "VBNET.ATG" m, attributes); } else SynErr(210); } void OptionValue( -#line 511 "VBNET.ATG" +#line 264 "VBNET.ATG" ref bool val) { if (la.kind == 135) { lexer.NextToken(); -#line 513 "VBNET.ATG" +#line 266 "VBNET.ATG" val = true; } else if (la.kind == 134) { lexer.NextToken(); -#line 515 "VBNET.ATG" +#line 268 "VBNET.ATG" val = false; } else SynErr(211); } @@ -530,25 +282,25 @@ ref bool val) { } void ImportClause( -#line 546 "VBNET.ATG" +#line 299 "VBNET.ATG" out Using u) { -#line 548 "VBNET.ATG" +#line 301 "VBNET.ATG" string qualident = null; TypeReference aliasedType = null; u = null; Qualident( -#line 552 "VBNET.ATG" +#line 305 "VBNET.ATG" out qualident); if (la.kind == 11) { lexer.NextToken(); TypeName( -#line 553 "VBNET.ATG" +#line 306 "VBNET.ATG" out aliasedType); } -#line 555 "VBNET.ATG" +#line 308 "VBNET.ATG" if (qualident != null && qualident.Length > 0) { if (aliasedType != null) { u = new Using(qualident, aliasedType); @@ -560,47 +312,47 @@ out aliasedType); } void Qualident( -#line 2900 "VBNET.ATG" +#line 2668 "VBNET.ATG" out string qualident) { -#line 2902 "VBNET.ATG" +#line 2670 "VBNET.ATG" string name; qualidentBuilder.Length = 0; Identifier(); -#line 2906 "VBNET.ATG" +#line 2674 "VBNET.ATG" qualidentBuilder.Append(t.val); while ( -#line 2907 "VBNET.ATG" +#line 2675 "VBNET.ATG" DotAndIdentOrKw()) { Expect(10); IdentifierOrKeyword( -#line 2907 "VBNET.ATG" +#line 2675 "VBNET.ATG" out name); -#line 2907 "VBNET.ATG" +#line 2675 "VBNET.ATG" qualidentBuilder.Append('.'); qualidentBuilder.Append(name); } -#line 2909 "VBNET.ATG" +#line 2677 "VBNET.ATG" qualident = qualidentBuilder.ToString(); } void TypeName( -#line 2081 "VBNET.ATG" +#line 1851 "VBNET.ATG" out TypeReference typeref) { -#line 2082 "VBNET.ATG" +#line 1852 "VBNET.ATG" ArrayList rank = null; NonArrayTypeName( -#line 2084 "VBNET.ATG" +#line 1854 "VBNET.ATG" out typeref, false); ArrayTypeModifiers( -#line 2085 "VBNET.ATG" +#line 1855 "VBNET.ATG" out rank); -#line 2086 "VBNET.ATG" +#line 1856 "VBNET.ATG" if (rank != null && typeref != null) { typeref.RankSpecifier = (int[])rank.ToArray(typeof(int)); } @@ -617,35 +369,35 @@ out rank); } void AttributeSection( -#line 2257 "VBNET.ATG" +#line 2027 "VBNET.ATG" out AttributeSection section) { -#line 2259 "VBNET.ATG" +#line 2029 "VBNET.ATG" string attributeTarget = "";List attributes = new List(); ASTAttribute attribute; Expect(27); -#line 2263 "VBNET.ATG" +#line 2033 "VBNET.ATG" Location startPos = t.Location; if ( -#line 2264 "VBNET.ATG" +#line 2034 "VBNET.ATG" IsLocalAttrTarget()) { if (la.kind == 93) { lexer.NextToken(); -#line 2265 "VBNET.ATG" +#line 2035 "VBNET.ATG" attributeTarget = "event"; } else if (la.kind == 154) { lexer.NextToken(); -#line 2266 "VBNET.ATG" +#line 2036 "VBNET.ATG" attributeTarget = "return"; } else { Identifier(); -#line 2269 "VBNET.ATG" +#line 2039 "VBNET.ATG" string val = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture); if (val != "field" || val != "method" || val != "module" || val != "param" || @@ -658,20 +410,20 @@ IsLocalAttrTarget()) { Expect(13); } Attribute( -#line 2279 "VBNET.ATG" +#line 2049 "VBNET.ATG" out attribute); -#line 2279 "VBNET.ATG" +#line 2049 "VBNET.ATG" attributes.Add(attribute); while ( -#line 2280 "VBNET.ATG" +#line 2050 "VBNET.ATG" NotFinalComma()) { Expect(12); Attribute( -#line 2280 "VBNET.ATG" +#line 2050 "VBNET.ATG" out attribute); -#line 2280 "VBNET.ATG" +#line 2050 "VBNET.ATG" attributes.Add(attribute); } if (la.kind == 12) { @@ -679,7 +431,7 @@ out attribute); } Expect(26); -#line 2284 "VBNET.ATG" +#line 2054 "VBNET.ATG" section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -687,69 +439,69 @@ out attribute); } void TypeModifier( -#line 2976 "VBNET.ATG" +#line 2744 "VBNET.ATG" Modifiers m) { switch (la.kind) { case 148: { lexer.NextToken(); -#line 2977 "VBNET.ATG" +#line 2745 "VBNET.ATG" m.Add(Modifier.Public, t.Location); break; } case 147: { lexer.NextToken(); -#line 2978 "VBNET.ATG" +#line 2746 "VBNET.ATG" m.Add(Modifier.Protected, t.Location); break; } case 99: { lexer.NextToken(); -#line 2979 "VBNET.ATG" +#line 2747 "VBNET.ATG" m.Add(Modifier.Internal, t.Location); break; } case 145: { lexer.NextToken(); -#line 2980 "VBNET.ATG" +#line 2748 "VBNET.ATG" m.Add(Modifier.Private, t.Location); break; } case 158: { lexer.NextToken(); -#line 2981 "VBNET.ATG" +#line 2749 "VBNET.ATG" m.Add(Modifier.Static, t.Location); break; } case 157: { lexer.NextToken(); -#line 2982 "VBNET.ATG" +#line 2750 "VBNET.ATG" m.Add(Modifier.New, t.Location); break; } case 122: { lexer.NextToken(); -#line 2983 "VBNET.ATG" +#line 2751 "VBNET.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 131: { lexer.NextToken(); -#line 2984 "VBNET.ATG" +#line 2752 "VBNET.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 203: { lexer.NextToken(); -#line 2985 "VBNET.ATG" +#line 2753 "VBNET.ATG" m.Add(Modifier.Partial, t.Location); break; } @@ -758,21 +510,21 @@ Modifiers m) { } void NonModuleDeclaration( -#line 643 "VBNET.ATG" +#line 396 "VBNET.ATG" Modifiers m, List attributes) { -#line 645 "VBNET.ATG" +#line 398 "VBNET.ATG" TypeReference typeRef = null; List baseInterfaces = null; switch (la.kind) { case 67: { -#line 648 "VBNET.ATG" +#line 401 "VBNET.ATG" m.Check(Modifier.Classes); lexer.NextToken(); -#line 651 "VBNET.ATG" +#line 404 "VBNET.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); newType.StartLocation = t.Location; compilationUnit.AddChild(newType); @@ -782,36 +534,36 @@ Modifiers m, List attributes) { Identifier(); -#line 658 "VBNET.ATG" +#line 411 "VBNET.ATG" newType.Name = t.val; TypeParameterList( -#line 659 "VBNET.ATG" +#line 412 "VBNET.ATG" newType.Templates); EndOfStmt(); -#line 661 "VBNET.ATG" +#line 414 "VBNET.ATG" newType.BodyStartLocation = t.Location; if (la.kind == 110) { ClassBaseType( -#line 662 "VBNET.ATG" +#line 415 "VBNET.ATG" out typeRef); -#line 662 "VBNET.ATG" +#line 415 "VBNET.ATG" newType.BaseTypes.Add(typeRef); } while (la.kind == 107) { TypeImplementsClause( -#line 663 "VBNET.ATG" +#line 416 "VBNET.ATG" out baseInterfaces); -#line 663 "VBNET.ATG" +#line 416 "VBNET.ATG" newType.BaseTypes.AddRange(baseInterfaces); } ClassBody( -#line 664 "VBNET.ATG" +#line 417 "VBNET.ATG" newType); -#line 666 "VBNET.ATG" +#line 419 "VBNET.ATG" compilationUnit.BlockEnd(); break; @@ -819,7 +571,7 @@ newType); case 121: { lexer.NextToken(); -#line 670 "VBNET.ATG" +#line 423 "VBNET.ATG" m.Check(Modifier.VBModules); TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); compilationUnit.AddChild(newType); @@ -829,17 +581,17 @@ newType); Identifier(); -#line 677 "VBNET.ATG" +#line 430 "VBNET.ATG" newType.Name = t.val; Expect(1); -#line 679 "VBNET.ATG" +#line 432 "VBNET.ATG" newType.BodyStartLocation = t.Location; ModuleBody( -#line 680 "VBNET.ATG" +#line 433 "VBNET.ATG" newType); -#line 682 "VBNET.ATG" +#line 435 "VBNET.ATG" compilationUnit.BlockEnd(); break; @@ -847,7 +599,7 @@ newType); case 166: { lexer.NextToken(); -#line 686 "VBNET.ATG" +#line 439 "VBNET.ATG" m.Check(Modifier.VBStructures); TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); compilationUnit.AddChild(newType); @@ -857,28 +609,28 @@ newType); Identifier(); -#line 693 "VBNET.ATG" +#line 446 "VBNET.ATG" newType.Name = t.val; TypeParameterList( -#line 694 "VBNET.ATG" +#line 447 "VBNET.ATG" newType.Templates); Expect(1); -#line 696 "VBNET.ATG" +#line 449 "VBNET.ATG" newType.BodyStartLocation = t.Location; while (la.kind == 107) { TypeImplementsClause( -#line 697 "VBNET.ATG" +#line 450 "VBNET.ATG" out baseInterfaces); -#line 697 "VBNET.ATG" +#line 450 "VBNET.ATG" newType.BaseTypes.AddRange(baseInterfaces); } StructureBody( -#line 698 "VBNET.ATG" +#line 451 "VBNET.ATG" newType); -#line 700 "VBNET.ATG" +#line 453 "VBNET.ATG" compilationUnit.BlockEnd(); break; @@ -886,7 +638,7 @@ newType); case 90: { lexer.NextToken(); -#line 705 "VBNET.ATG" +#line 458 "VBNET.ATG" m.Check(Modifier.VBEnums); TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); newType.StartLocation = m.GetDeclarationLocation(t.Location); @@ -897,26 +649,26 @@ newType); Identifier(); -#line 713 "VBNET.ATG" +#line 466 "VBNET.ATG" newType.Name = t.val; if (la.kind == 48) { lexer.NextToken(); NonArrayTypeName( -#line 714 "VBNET.ATG" +#line 467 "VBNET.ATG" out typeRef, false); -#line 714 "VBNET.ATG" +#line 467 "VBNET.ATG" newType.BaseTypes.Add(typeRef); } Expect(1); -#line 716 "VBNET.ATG" +#line 469 "VBNET.ATG" newType.BodyStartLocation = t.Location; EnumBody( -#line 717 "VBNET.ATG" +#line 470 "VBNET.ATG" newType); -#line 719 "VBNET.ATG" +#line 472 "VBNET.ATG" compilationUnit.BlockEnd(); break; @@ -924,7 +676,7 @@ newType); case 112: { lexer.NextToken(); -#line 724 "VBNET.ATG" +#line 477 "VBNET.ATG" m.Check(Modifier.VBInterfacs); TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); newType.StartLocation = m.GetDeclarationLocation(t.Location); @@ -934,28 +686,28 @@ newType); Identifier(); -#line 731 "VBNET.ATG" +#line 484 "VBNET.ATG" newType.Name = t.val; TypeParameterList( -#line 732 "VBNET.ATG" +#line 485 "VBNET.ATG" newType.Templates); EndOfStmt(); -#line 734 "VBNET.ATG" +#line 487 "VBNET.ATG" newType.BodyStartLocation = t.Location; while (la.kind == 110) { InterfaceBase( -#line 735 "VBNET.ATG" +#line 488 "VBNET.ATG" out baseInterfaces); -#line 735 "VBNET.ATG" +#line 488 "VBNET.ATG" newType.BaseTypes.AddRange(baseInterfaces); } InterfaceBody( -#line 736 "VBNET.ATG" +#line 489 "VBNET.ATG" newType); -#line 738 "VBNET.ATG" +#line 491 "VBNET.ATG" compilationUnit.BlockEnd(); break; @@ -963,7 +715,7 @@ newType); case 80: { lexer.NextToken(); -#line 743 "VBNET.ATG" +#line 496 "VBNET.ATG" m.Check(Modifier.VBDelegates); DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); delegateDeclr.ReturnType = new TypeReference("", "System.Void"); @@ -974,63 +726,63 @@ newType); lexer.NextToken(); Identifier(); -#line 750 "VBNET.ATG" +#line 503 "VBNET.ATG" delegateDeclr.Name = t.val; TypeParameterList( -#line 751 "VBNET.ATG" +#line 504 "VBNET.ATG" delegateDeclr.Templates); if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 752 "VBNET.ATG" +#line 505 "VBNET.ATG" p); } Expect(25); -#line 752 "VBNET.ATG" +#line 505 "VBNET.ATG" delegateDeclr.Parameters = p; } } else if (la.kind == 100) { lexer.NextToken(); Identifier(); -#line 754 "VBNET.ATG" +#line 507 "VBNET.ATG" delegateDeclr.Name = t.val; TypeParameterList( -#line 755 "VBNET.ATG" +#line 508 "VBNET.ATG" delegateDeclr.Templates); if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 756 "VBNET.ATG" +#line 509 "VBNET.ATG" p); } Expect(25); -#line 756 "VBNET.ATG" +#line 509 "VBNET.ATG" delegateDeclr.Parameters = p; } if (la.kind == 48) { lexer.NextToken(); -#line 757 "VBNET.ATG" +#line 510 "VBNET.ATG" TypeReference type; TypeName( -#line 757 "VBNET.ATG" +#line 510 "VBNET.ATG" out type); -#line 757 "VBNET.ATG" +#line 510 "VBNET.ATG" delegateDeclr.ReturnType = type; } } else SynErr(214); -#line 759 "VBNET.ATG" +#line 512 "VBNET.ATG" delegateDeclr.EndLocation = t.EndLocation; Expect(1); -#line 762 "VBNET.ATG" +#line 515 "VBNET.ATG" compilationUnit.AddChild(delegateDeclr); break; @@ -1040,31 +792,31 @@ out type); } void TypeParameterList( -#line 596 "VBNET.ATG" +#line 349 "VBNET.ATG" List templates) { -#line 598 "VBNET.ATG" +#line 351 "VBNET.ATG" TemplateDefinition template; if ( -#line 601 "VBNET.ATG" +#line 354 "VBNET.ATG" la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { lexer.NextToken(); Expect(200); TypeParameter( -#line 602 "VBNET.ATG" +#line 355 "VBNET.ATG" out template); -#line 604 "VBNET.ATG" +#line 357 "VBNET.ATG" if (template != null) templates.Add(template); while (la.kind == 12) { lexer.NextToken(); TypeParameter( -#line 607 "VBNET.ATG" +#line 360 "VBNET.ATG" out template); -#line 609 "VBNET.ATG" +#line 362 "VBNET.ATG" if (template != null) templates.Add(template); } @@ -1073,15 +825,15 @@ out template); } void TypeParameter( -#line 617 "VBNET.ATG" +#line 370 "VBNET.ATG" out TemplateDefinition template) { Identifier(); -#line 619 "VBNET.ATG" +#line 372 "VBNET.ATG" template = new TemplateDefinition(t.val, null); if (la.kind == 48) { TypeParameterConstraints( -#line 620 "VBNET.ATG" +#line 373 "VBNET.ATG" template); } } @@ -1137,199 +889,199 @@ template); } void TypeParameterConstraints( -#line 624 "VBNET.ATG" +#line 377 "VBNET.ATG" TemplateDefinition template) { -#line 626 "VBNET.ATG" +#line 379 "VBNET.ATG" TypeReference constraint; Expect(48); if (la.kind == 22) { lexer.NextToken(); TypeName( -#line 632 "VBNET.ATG" +#line 385 "VBNET.ATG" out constraint); -#line 632 "VBNET.ATG" +#line 385 "VBNET.ATG" if (constraint != null) { template.Bases.Add(constraint); } while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 635 "VBNET.ATG" +#line 388 "VBNET.ATG" out constraint); -#line 635 "VBNET.ATG" +#line 388 "VBNET.ATG" if (constraint != null) { template.Bases.Add(constraint); } } Expect(23); } else if (StartOf(5)) { TypeName( -#line 638 "VBNET.ATG" +#line 391 "VBNET.ATG" out constraint); -#line 638 "VBNET.ATG" +#line 391 "VBNET.ATG" if (constraint != null) { template.Bases.Add(constraint); } } else SynErr(217); } void ClassBaseType( -#line 939 "VBNET.ATG" +#line 692 "VBNET.ATG" out TypeReference typeRef) { -#line 941 "VBNET.ATG" +#line 694 "VBNET.ATG" typeRef = null; Expect(110); TypeName( -#line 944 "VBNET.ATG" +#line 697 "VBNET.ATG" out typeRef); EndOfStmt(); } void TypeImplementsClause( -#line 1686 "VBNET.ATG" +#line 1456 "VBNET.ATG" out List baseInterfaces) { -#line 1688 "VBNET.ATG" +#line 1458 "VBNET.ATG" baseInterfaces = new List(); TypeReference type = null; Expect(107); TypeName( -#line 1691 "VBNET.ATG" +#line 1461 "VBNET.ATG" out type); -#line 1693 "VBNET.ATG" +#line 1463 "VBNET.ATG" baseInterfaces.Add(type); while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 1696 "VBNET.ATG" +#line 1466 "VBNET.ATG" out type); -#line 1697 "VBNET.ATG" +#line 1467 "VBNET.ATG" baseInterfaces.Add(type); } EndOfStmt(); } void ClassBody( -#line 772 "VBNET.ATG" +#line 525 "VBNET.ATG" TypeDeclaration newType) { -#line 773 "VBNET.ATG" +#line 526 "VBNET.ATG" AttributeSection section; while (StartOf(6)) { -#line 775 "VBNET.ATG" +#line 528 "VBNET.ATG" List attributes = new List(); Modifiers m = new Modifiers(); while (la.kind == 27) { AttributeSection( -#line 778 "VBNET.ATG" +#line 531 "VBNET.ATG" out section); -#line 778 "VBNET.ATG" +#line 531 "VBNET.ATG" attributes.Add(section); } while (StartOf(7)) { MemberModifier( -#line 779 "VBNET.ATG" +#line 532 "VBNET.ATG" m); } ClassMemberDecl( -#line 780 "VBNET.ATG" +#line 533 "VBNET.ATG" m, attributes); } Expect(88); Expect(67); -#line 782 "VBNET.ATG" +#line 535 "VBNET.ATG" newType.EndLocation = t.EndLocation; Expect(1); } void ModuleBody( -#line 801 "VBNET.ATG" +#line 554 "VBNET.ATG" TypeDeclaration newType) { -#line 802 "VBNET.ATG" +#line 555 "VBNET.ATG" AttributeSection section; while (StartOf(6)) { -#line 804 "VBNET.ATG" +#line 557 "VBNET.ATG" List attributes = new List(); Modifiers m = new Modifiers(); while (la.kind == 27) { AttributeSection( -#line 807 "VBNET.ATG" +#line 560 "VBNET.ATG" out section); -#line 807 "VBNET.ATG" +#line 560 "VBNET.ATG" attributes.Add(section); } while (StartOf(7)) { MemberModifier( -#line 808 "VBNET.ATG" +#line 561 "VBNET.ATG" m); } ClassMemberDecl( -#line 809 "VBNET.ATG" +#line 562 "VBNET.ATG" m, attributes); } Expect(88); Expect(121); -#line 811 "VBNET.ATG" +#line 564 "VBNET.ATG" newType.EndLocation = t.EndLocation; Expect(1); } void StructureBody( -#line 786 "VBNET.ATG" +#line 539 "VBNET.ATG" TypeDeclaration newType) { -#line 787 "VBNET.ATG" +#line 540 "VBNET.ATG" AttributeSection section; while (StartOf(6)) { -#line 789 "VBNET.ATG" +#line 542 "VBNET.ATG" List attributes = new List(); Modifiers m = new Modifiers(); while (la.kind == 27) { AttributeSection( -#line 792 "VBNET.ATG" +#line 545 "VBNET.ATG" out section); -#line 792 "VBNET.ATG" +#line 545 "VBNET.ATG" attributes.Add(section); } while (StartOf(7)) { MemberModifier( -#line 793 "VBNET.ATG" +#line 546 "VBNET.ATG" m); } StructureMemberDecl( -#line 794 "VBNET.ATG" +#line 547 "VBNET.ATG" m, attributes); } Expect(88); Expect(166); -#line 796 "VBNET.ATG" +#line 549 "VBNET.ATG" newType.EndLocation = t.EndLocation; Expect(1); } void NonArrayTypeName( -#line 2104 "VBNET.ATG" +#line 1874 "VBNET.ATG" out TypeReference typeref, bool canBeUnbound) { -#line 2106 "VBNET.ATG" +#line 1876 "VBNET.ATG" string name; typeref = null; bool isGlobal = false; @@ -1339,93 +1091,93 @@ out TypeReference typeref, bool canBeUnbound) { lexer.NextToken(); Expect(10); -#line 2111 "VBNET.ATG" +#line 1881 "VBNET.ATG" isGlobal = true; } QualIdentAndTypeArguments( -#line 2112 "VBNET.ATG" +#line 1882 "VBNET.ATG" out typeref, canBeUnbound); -#line 2113 "VBNET.ATG" +#line 1883 "VBNET.ATG" typeref.IsGlobal = isGlobal; while (la.kind == 10) { lexer.NextToken(); -#line 2114 "VBNET.ATG" +#line 1884 "VBNET.ATG" TypeReference nestedTypeRef; QualIdentAndTypeArguments( -#line 2115 "VBNET.ATG" +#line 1885 "VBNET.ATG" out nestedTypeRef, canBeUnbound); -#line 2116 "VBNET.ATG" +#line 1886 "VBNET.ATG" typeref = new InnerClassTypeReference(typeref, nestedTypeRef.Type, nestedTypeRef.GenericTypes); } } else if (la.kind == 133) { lexer.NextToken(); -#line 2119 "VBNET.ATG" +#line 1889 "VBNET.ATG" typeref = new TypeReference("System.Object"); } else if (StartOf(9)) { PrimitiveTypeName( -#line 2120 "VBNET.ATG" +#line 1890 "VBNET.ATG" out name); -#line 2120 "VBNET.ATG" +#line 1890 "VBNET.ATG" typeref = new TypeReference(name); } else SynErr(218); } void EnumBody( -#line 815 "VBNET.ATG" +#line 568 "VBNET.ATG" TypeDeclaration newType) { -#line 816 "VBNET.ATG" +#line 569 "VBNET.ATG" FieldDeclaration f; while (StartOf(10)) { EnumMemberDecl( -#line 818 "VBNET.ATG" +#line 571 "VBNET.ATG" out f); -#line 818 "VBNET.ATG" +#line 571 "VBNET.ATG" compilationUnit.AddChild(f); } Expect(88); Expect(90); -#line 820 "VBNET.ATG" +#line 573 "VBNET.ATG" newType.EndLocation = t.EndLocation; Expect(1); } void InterfaceBase( -#line 1671 "VBNET.ATG" +#line 1441 "VBNET.ATG" out List bases) { -#line 1673 "VBNET.ATG" +#line 1443 "VBNET.ATG" TypeReference type; bases = new List(); Expect(110); TypeName( -#line 1677 "VBNET.ATG" +#line 1447 "VBNET.ATG" out type); -#line 1677 "VBNET.ATG" +#line 1447 "VBNET.ATG" bases.Add(type); while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 1680 "VBNET.ATG" +#line 1450 "VBNET.ATG" out type); -#line 1680 "VBNET.ATG" +#line 1450 "VBNET.ATG" bases.Add(type); } Expect(1); } void InterfaceBody( -#line 824 "VBNET.ATG" +#line 577 "VBNET.ATG" TypeDeclaration newType) { while (StartOf(11)) { InterfaceMemberDecl(); @@ -1433,33 +1185,33 @@ TypeDeclaration newType) { Expect(88); Expect(112); -#line 826 "VBNET.ATG" +#line 579 "VBNET.ATG" newType.EndLocation = t.EndLocation; Expect(1); } void FormalParameterList( -#line 2291 "VBNET.ATG" +#line 2061 "VBNET.ATG" List parameter) { -#line 2293 "VBNET.ATG" +#line 2063 "VBNET.ATG" ParameterDeclarationExpression p; AttributeSection section; List attributes = new List(); while (la.kind == 27) { AttributeSection( -#line 2297 "VBNET.ATG" +#line 2067 "VBNET.ATG" out section); -#line 2297 "VBNET.ATG" +#line 2067 "VBNET.ATG" attributes.Add(section); } FormalParameter( -#line 2299 "VBNET.ATG" +#line 2069 "VBNET.ATG" out p); -#line 2301 "VBNET.ATG" +#line 2071 "VBNET.ATG" bool paramsFound = false; p.Attributes = attributes; parameter.Add(p); @@ -1467,152 +1219,152 @@ out p); while (la.kind == 12) { lexer.NextToken(); -#line 2306 "VBNET.ATG" +#line 2076 "VBNET.ATG" if (paramsFound) Error("params array must be at end of parameter list"); while (la.kind == 27) { AttributeSection( -#line 2307 "VBNET.ATG" +#line 2077 "VBNET.ATG" out section); -#line 2307 "VBNET.ATG" +#line 2077 "VBNET.ATG" attributes.Add(section); } FormalParameter( -#line 2309 "VBNET.ATG" +#line 2079 "VBNET.ATG" out p); -#line 2309 "VBNET.ATG" +#line 2079 "VBNET.ATG" p.Attributes = attributes; parameter.Add(p); } } void MemberModifier( -#line 2988 "VBNET.ATG" +#line 2756 "VBNET.ATG" Modifiers m) { switch (la.kind) { case 122: { lexer.NextToken(); -#line 2989 "VBNET.ATG" +#line 2757 "VBNET.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 79: { lexer.NextToken(); -#line 2990 "VBNET.ATG" +#line 2758 "VBNET.ATG" m.Add(Modifier.Default, t.Location); break; } case 99: { lexer.NextToken(); -#line 2991 "VBNET.ATG" +#line 2759 "VBNET.ATG" m.Add(Modifier.Internal, t.Location); break; } case 157: { lexer.NextToken(); -#line 2992 "VBNET.ATG" +#line 2760 "VBNET.ATG" m.Add(Modifier.New, t.Location); break; } case 142: { lexer.NextToken(); -#line 2993 "VBNET.ATG" +#line 2761 "VBNET.ATG" m.Add(Modifier.Override, t.Location); break; } case 123: { lexer.NextToken(); -#line 2994 "VBNET.ATG" +#line 2762 "VBNET.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 145: { lexer.NextToken(); -#line 2995 "VBNET.ATG" +#line 2763 "VBNET.ATG" m.Add(Modifier.Private, t.Location); break; } case 147: { lexer.NextToken(); -#line 2996 "VBNET.ATG" +#line 2764 "VBNET.ATG" m.Add(Modifier.Protected, t.Location); break; } case 148: { lexer.NextToken(); -#line 2997 "VBNET.ATG" +#line 2765 "VBNET.ATG" m.Add(Modifier.Public, t.Location); break; } case 131: { lexer.NextToken(); -#line 2998 "VBNET.ATG" +#line 2766 "VBNET.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 132: { lexer.NextToken(); -#line 2999 "VBNET.ATG" +#line 2767 "VBNET.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 158: { lexer.NextToken(); -#line 3000 "VBNET.ATG" +#line 2768 "VBNET.ATG" m.Add(Modifier.Static, t.Location); break; } case 141: { lexer.NextToken(); -#line 3001 "VBNET.ATG" +#line 2769 "VBNET.ATG" m.Add(Modifier.Virtual, t.Location); break; } case 140: { lexer.NextToken(); -#line 3002 "VBNET.ATG" +#line 2770 "VBNET.ATG" m.Add(Modifier.Overloads, t.Location); break; } case 150: { lexer.NextToken(); -#line 3003 "VBNET.ATG" +#line 2771 "VBNET.ATG" m.Add(Modifier.ReadOnly, t.Location); break; } case 184: { lexer.NextToken(); -#line 3004 "VBNET.ATG" +#line 2772 "VBNET.ATG" m.Add(Modifier.WriteOnly, t.Location); break; } case 183: { lexer.NextToken(); -#line 3005 "VBNET.ATG" +#line 2773 "VBNET.ATG" m.Add(Modifier.WithEvents, t.Location); break; } case 81: { lexer.NextToken(); -#line 3006 "VBNET.ATG" +#line 2774 "VBNET.ATG" m.Add(Modifier.Dim, t.Location); break; } @@ -1621,18 +1373,18 @@ Modifiers m) { } void ClassMemberDecl( -#line 935 "VBNET.ATG" +#line 688 "VBNET.ATG" Modifiers m, List attributes) { StructureMemberDecl( -#line 936 "VBNET.ATG" +#line 689 "VBNET.ATG" m, attributes); } void StructureMemberDecl( -#line 949 "VBNET.ATG" +#line 702 "VBNET.ATG" Modifiers m, List attributes) { -#line 951 "VBNET.ATG" +#line 704 "VBNET.ATG" TypeReference type = null; List p = new List(); Statement stmt = null; @@ -1642,37 +1394,37 @@ Modifiers m, List attributes) { switch (la.kind) { case 67: case 80: case 90: case 112: case 121: case 166: { NonModuleDeclaration( -#line 958 "VBNET.ATG" +#line 711 "VBNET.ATG" m, attributes); break; } case 167: { lexer.NextToken(); -#line 962 "VBNET.ATG" +#line 715 "VBNET.ATG" Location startPos = t.Location; if (StartOf(12)) { -#line 966 "VBNET.ATG" +#line 719 "VBNET.ATG" string name = String.Empty; MethodDeclaration methodDeclaration; List handlesClause = null; List implementsClause = null; Identifier(); -#line 972 "VBNET.ATG" +#line 725 "VBNET.ATG" name = t.val; m.Check(Modifier.VBMethods); TypeParameterList( -#line 975 "VBNET.ATG" +#line 728 "VBNET.ATG" templates); if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 976 "VBNET.ATG" +#line 729 "VBNET.ATG" p); } Expect(25); @@ -1680,23 +1432,23 @@ p); if (la.kind == 105 || la.kind == 107) { if (la.kind == 107) { ImplementsClause( -#line 979 "VBNET.ATG" +#line 732 "VBNET.ATG" out implementsClause); } else { HandlesClause( -#line 981 "VBNET.ATG" +#line 734 "VBNET.ATG" out handlesClause); } } -#line 984 "VBNET.ATG" +#line 737 "VBNET.ATG" Location endLocation = t.EndLocation; Expect(1); if ( -#line 988 "VBNET.ATG" +#line 741 "VBNET.ATG" IsMustOverride(m)) { -#line 990 "VBNET.ATG" +#line 743 "VBNET.ATG" methodDeclaration = new MethodDeclaration(name, m.Modifier, null, p, attributes); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = endLocation; @@ -1710,7 +1462,7 @@ IsMustOverride(m)) { } else if (StartOf(13)) { -#line 1003 "VBNET.ATG" +#line 756 "VBNET.ATG" methodDeclaration = new MethodDeclaration(name, m.Modifier, null, p, attributes); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = endLocation; @@ -1721,20 +1473,28 @@ IsMustOverride(m)) { methodDeclaration.InterfaceImplementations = implementsClause; compilationUnit.AddChild(methodDeclaration); - compilationUnit.BlockStart(methodDeclaration); + +#line 768 "VBNET.ATG" + if (parseMethodContents) { Block( -#line 1015 "VBNET.ATG" +#line 769 "VBNET.ATG" out stmt); - -#line 1017 "VBNET.ATG" - compilationUnit.BlockEnd(); - methodDeclaration.Body = (BlockStatement)stmt; - Expect(88); Expect(167); -#line 1020 "VBNET.ATG" +#line 771 "VBNET.ATG" + } else { + // don't parse method body + lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); + if (t.kind != Tokens.Sub) throw new ApplicationException("Failed to skip sub"); + } + + +#line 778 "VBNET.ATG" + methodDeclaration.Body = (BlockStatement)stmt; + +#line 779 "VBNET.ATG" methodDeclaration.Body.EndLocation = t.EndLocation; Expect(1); } else SynErr(220); @@ -1744,29 +1504,40 @@ out stmt); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1023 "VBNET.ATG" +#line 782 "VBNET.ATG" p); } Expect(25); } -#line 1024 "VBNET.ATG" +#line 783 "VBNET.ATG" m.Check(Modifier.Constructors); -#line 1025 "VBNET.ATG" +#line 784 "VBNET.ATG" Location constructorEndLocation = t.EndLocation; Expect(1); + +#line 787 "VBNET.ATG" + if (parseMethodContents) { Block( -#line 1027 "VBNET.ATG" +#line 788 "VBNET.ATG" out stmt); Expect(88); Expect(167); -#line 1028 "VBNET.ATG" +#line 790 "VBNET.ATG" + } else { + // don't parse method body + lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); + if (t.kind != Tokens.Sub) throw new ApplicationException("Failed to skip sub"); + } + + +#line 797 "VBNET.ATG" Location endLocation = t.EndLocation; Expect(1); -#line 1030 "VBNET.ATG" +#line 799 "VBNET.ATG" ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); cd.StartLocation = m.GetDeclarationLocation(startPos); cd.EndLocation = constructorEndLocation; @@ -1780,7 +1551,7 @@ out stmt); case 100: { lexer.NextToken(); -#line 1042 "VBNET.ATG" +#line 811 "VBNET.ATG" m.Check(Modifier.VBMethods); string name = String.Empty; Location startPos = t.Location; @@ -1790,16 +1561,16 @@ out stmt); Identifier(); -#line 1049 "VBNET.ATG" +#line 818 "VBNET.ATG" name = t.val; TypeParameterList( -#line 1050 "VBNET.ATG" +#line 819 "VBNET.ATG" templates); if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1051 "VBNET.ATG" +#line 820 "VBNET.ATG" p); } Expect(25); @@ -1808,15 +1579,15 @@ p); lexer.NextToken(); while (la.kind == 27) { AttributeSection( -#line 1052 "VBNET.ATG" +#line 821 "VBNET.ATG" out returnTypeAttributeSection); } TypeName( -#line 1052 "VBNET.ATG" +#line 821 "VBNET.ATG" out type); } -#line 1054 "VBNET.ATG" +#line 823 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object"); } @@ -1824,20 +1595,20 @@ out type); if (la.kind == 105 || la.kind == 107) { if (la.kind == 107) { ImplementsClause( -#line 1060 "VBNET.ATG" +#line 829 "VBNET.ATG" out implementsClause); } else { HandlesClause( -#line 1062 "VBNET.ATG" +#line 831 "VBNET.ATG" out handlesClause); } } Expect(1); if ( -#line 1068 "VBNET.ATG" +#line 837 "VBNET.ATG" IsMustOverride(m)) { -#line 1070 "VBNET.ATG" +#line 839 "VBNET.ATG" methodDeclaration = new MethodDeclaration(name, m.Modifier, type, p, attributes); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = t.EndLocation; @@ -1853,7 +1624,7 @@ IsMustOverride(m)) { } else if (StartOf(13)) { -#line 1085 "VBNET.ATG" +#line 854 "VBNET.ATG" methodDeclaration = new MethodDeclaration(name, m.Modifier, type, p, attributes); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = t.EndLocation; @@ -1867,20 +1638,21 @@ IsMustOverride(m)) { } compilationUnit.AddChild(methodDeclaration); - compilationUnit.BlockStart(methodDeclaration); + if (parseMethodContents) { Block( -#line 1100 "VBNET.ATG" +#line 869 "VBNET.ATG" out stmt); - -#line 1102 "VBNET.ATG" - compilationUnit.BlockEnd(); - methodDeclaration.Body = (BlockStatement)stmt; - Expect(88); Expect(100); -#line 1107 "VBNET.ATG" +#line 871 "VBNET.ATG" + } else { + // don't parse method body + lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement(); + if (t.kind != Tokens.Function) throw new ApplicationException("Failed to skip function"); + } + methodDeclaration.Body = (BlockStatement)stmt; methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation; methodDeclaration.Body.EndLocation = t.EndLocation; @@ -1891,7 +1663,7 @@ out stmt); case 78: { lexer.NextToken(); -#line 1116 "VBNET.ATG" +#line 886 "VBNET.ATG" m.Check(Modifier.VBExternalMethods); Location startPos = t.Location; CharsetModifier charsetModifer = CharsetModifier.None; @@ -1901,39 +1673,39 @@ out stmt); if (StartOf(14)) { Charset( -#line 1123 "VBNET.ATG" +#line 893 "VBNET.ATG" out charsetModifer); } if (la.kind == 167) { lexer.NextToken(); Identifier(); -#line 1126 "VBNET.ATG" +#line 896 "VBNET.ATG" name = t.val; Expect(115); Expect(3); -#line 1127 "VBNET.ATG" +#line 897 "VBNET.ATG" library = t.literalValue.ToString(); if (la.kind == 44) { lexer.NextToken(); Expect(3); -#line 1128 "VBNET.ATG" +#line 898 "VBNET.ATG" alias = t.literalValue.ToString(); } if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1129 "VBNET.ATG" +#line 899 "VBNET.ATG" p); } Expect(25); } Expect(1); -#line 1132 "VBNET.ATG" +#line 902 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; @@ -1943,25 +1715,25 @@ p); lexer.NextToken(); Identifier(); -#line 1139 "VBNET.ATG" +#line 909 "VBNET.ATG" name = t.val; Expect(115); Expect(3); -#line 1140 "VBNET.ATG" +#line 910 "VBNET.ATG" library = t.literalValue.ToString(); if (la.kind == 44) { lexer.NextToken(); Expect(3); -#line 1141 "VBNET.ATG" +#line 911 "VBNET.ATG" alias = t.literalValue.ToString(); } if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1142 "VBNET.ATG" +#line 912 "VBNET.ATG" p); } Expect(25); @@ -1969,12 +1741,12 @@ p); if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1143 "VBNET.ATG" +#line 913 "VBNET.ATG" out type); } Expect(1); -#line 1146 "VBNET.ATG" +#line 916 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; @@ -1986,7 +1758,7 @@ out type); case 93: { lexer.NextToken(); -#line 1156 "VBNET.ATG" +#line 926 "VBNET.ATG" m.Check(Modifier.VBEvents); Location startPos = t.Location; EventDeclaration eventDeclaration; @@ -1995,19 +1767,19 @@ out type); Identifier(); -#line 1162 "VBNET.ATG" +#line 932 "VBNET.ATG" name= t.val; if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1164 "VBNET.ATG" +#line 934 "VBNET.ATG" out type); } else if (la.kind == 1 || la.kind == 24 || la.kind == 107) { if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1166 "VBNET.ATG" +#line 936 "VBNET.ATG" p); } Expect(25); @@ -2015,11 +1787,11 @@ p); } else SynErr(224); if (la.kind == 107) { ImplementsClause( -#line 1168 "VBNET.ATG" +#line 938 "VBNET.ATG" out implementsClause); } -#line 1170 "VBNET.ATG" +#line 940 "VBNET.ATG" eventDeclaration = new EventDeclaration(type, m.Modifier, p, attributes, name, implementsClause); eventDeclaration.StartLocation = m.GetDeclarationLocation(startPos); eventDeclaration.EndLocation = t.EndLocation; @@ -2030,30 +1802,30 @@ out implementsClause); } case 2: case 47: case 49: case 50: case 51: case 70: case 144: case 169: case 176: case 177: { -#line 1177 "VBNET.ATG" +#line 947 "VBNET.ATG" Location startPos = t.Location; -#line 1179 "VBNET.ATG" +#line 949 "VBNET.ATG" m.Check(Modifier.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); IdentifierForFieldDeclaration(); -#line 1183 "VBNET.ATG" +#line 953 "VBNET.ATG" string name = t.val; VariableDeclaratorPartAfterIdentifier( -#line 1184 "VBNET.ATG" +#line 954 "VBNET.ATG" variableDeclarators, name); while (la.kind == 12) { lexer.NextToken(); VariableDeclarator( -#line 1185 "VBNET.ATG" +#line 955 "VBNET.ATG" variableDeclarators); } Expect(1); -#line 1188 "VBNET.ATG" +#line 958 "VBNET.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); @@ -2062,35 +1834,35 @@ variableDeclarators); } case 71: { -#line 1193 "VBNET.ATG" +#line 963 "VBNET.ATG" m.Check(Modifier.Fields); lexer.NextToken(); -#line 1194 "VBNET.ATG" +#line 964 "VBNET.ATG" m.Add(Modifier.Const, t.Location); -#line 1196 "VBNET.ATG" +#line 966 "VBNET.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(t.Location); List constantDeclarators = new List(); ConstantDeclarator( -#line 1200 "VBNET.ATG" +#line 970 "VBNET.ATG" constantDeclarators); while (la.kind == 12) { lexer.NextToken(); ConstantDeclarator( -#line 1201 "VBNET.ATG" +#line 971 "VBNET.ATG" constantDeclarators); } -#line 1203 "VBNET.ATG" +#line 973 "VBNET.ATG" fd.Fields = constantDeclarators; fd.EndLocation = t.Location; Expect(1); -#line 1208 "VBNET.ATG" +#line 978 "VBNET.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); @@ -2099,20 +1871,20 @@ constantDeclarators); case 146: { lexer.NextToken(); -#line 1214 "VBNET.ATG" +#line 984 "VBNET.ATG" m.Check(Modifier.VBProperties); Location startPos = t.Location; List implementsClause = null; Identifier(); -#line 1218 "VBNET.ATG" +#line 988 "VBNET.ATG" string propertyName = t.val; if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1219 "VBNET.ATG" +#line 989 "VBNET.ATG" p); } Expect(25); @@ -2120,26 +1892,26 @@ p); if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1220 "VBNET.ATG" +#line 990 "VBNET.ATG" out type); } -#line 1222 "VBNET.ATG" +#line 992 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object"); } if (la.kind == 107) { ImplementsClause( -#line 1226 "VBNET.ATG" +#line 996 "VBNET.ATG" out implementsClause); } Expect(1); if ( -#line 1230 "VBNET.ATG" +#line 1000 "VBNET.ATG" IsMustOverride(m)) { -#line 1232 "VBNET.ATG" +#line 1002 "VBNET.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = t.Location; @@ -2150,7 +1922,7 @@ IsMustOverride(m)) { } else if (la.kind == 27 || la.kind == 101 || la.kind == 156) { -#line 1242 "VBNET.ATG" +#line 1012 "VBNET.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = t.Location; @@ -2162,13 +1934,13 @@ IsMustOverride(m)) { PropertySetRegion setRegion; AccessorDecls( -#line 1252 "VBNET.ATG" +#line 1022 "VBNET.ATG" out getRegion, out setRegion); Expect(88); Expect(146); Expect(1); -#line 1256 "VBNET.ATG" +#line 1026 "VBNET.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2180,11 +1952,11 @@ out getRegion, out setRegion); case 204: { lexer.NextToken(); -#line 1263 "VBNET.ATG" +#line 1033 "VBNET.ATG" Location startPos = t.Location; Expect(93); -#line 1265 "VBNET.ATG" +#line 1035 "VBNET.ATG" m.Check(Modifier.VBCustomEvents); EventAddRemoveRegion eventAccessorDeclaration; EventAddRegion addHandlerAccessorDeclaration = null; @@ -2194,24 +1966,24 @@ out getRegion, out setRegion); Identifier(); -#line 1272 "VBNET.ATG" +#line 1042 "VBNET.ATG" string customEventName = t.val; Expect(48); TypeName( -#line 1273 "VBNET.ATG" +#line 1043 "VBNET.ATG" out type); if (la.kind == 107) { ImplementsClause( -#line 1274 "VBNET.ATG" +#line 1044 "VBNET.ATG" out implementsClause); } Expect(1); while (StartOf(15)) { EventAccessorDeclaration( -#line 1277 "VBNET.ATG" +#line 1047 "VBNET.ATG" out eventAccessorDeclaration); -#line 1279 "VBNET.ATG" +#line 1049 "VBNET.ATG" if(eventAccessorDeclaration is EventAddRegion) { addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration; @@ -2230,7 +2002,7 @@ out eventAccessorDeclaration); Expect(93); Expect(1); -#line 1295 "VBNET.ATG" +#line 1065 "VBNET.ATG" if(addHandlerAccessorDeclaration == null) { Error("Need to provide AddHandler accessor."); @@ -2258,24 +2030,24 @@ out eventAccessorDeclaration); } case 187: case 201: case 202: { -#line 1318 "VBNET.ATG" +#line 1088 "VBNET.ATG" ConversionType opConversionType = ConversionType.None; if (la.kind == 201 || la.kind == 202) { if (la.kind == 202) { lexer.NextToken(); -#line 1319 "VBNET.ATG" +#line 1089 "VBNET.ATG" opConversionType = ConversionType.Implicit; } else { lexer.NextToken(); -#line 1320 "VBNET.ATG" +#line 1090 "VBNET.ATG" opConversionType = ConversionType.Explicit; } } Expect(187); -#line 1323 "VBNET.ATG" +#line 1093 "VBNET.ATG" m.Check(Modifier.VBOperators); Location startPos = t.Location; TypeReference returnType = NullTypeReference.Instance; @@ -2287,7 +2059,7 @@ out eventAccessorDeclaration); List returnTypeAttributes = new List(); OverloadableOperator( -#line 1333 "VBNET.ATG" +#line 1103 "VBNET.ATG" out operatorType); Expect(24); if (la.kind == 55) { @@ -2295,16 +2067,16 @@ out operatorType); } Identifier(); -#line 1334 "VBNET.ATG" +#line 1104 "VBNET.ATG" operandName = t.val; if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1335 "VBNET.ATG" +#line 1105 "VBNET.ATG" out operandType); } -#line 1336 "VBNET.ATG" +#line 1106 "VBNET.ATG" parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParamModifier.In)); while (la.kind == 12) { lexer.NextToken(); @@ -2313,48 +2085,48 @@ out operandType); } Identifier(); -#line 1340 "VBNET.ATG" +#line 1110 "VBNET.ATG" operandName = t.val; if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1341 "VBNET.ATG" +#line 1111 "VBNET.ATG" out operandType); } -#line 1342 "VBNET.ATG" +#line 1112 "VBNET.ATG" parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParamModifier.In)); } Expect(25); -#line 1345 "VBNET.ATG" +#line 1115 "VBNET.ATG" Location endPos = t.EndLocation; if (la.kind == 48) { lexer.NextToken(); while (la.kind == 27) { AttributeSection( -#line 1346 "VBNET.ATG" +#line 1116 "VBNET.ATG" out section); -#line 1346 "VBNET.ATG" +#line 1116 "VBNET.ATG" returnTypeAttributes.Add(section); } TypeName( -#line 1346 "VBNET.ATG" +#line 1116 "VBNET.ATG" out returnType); -#line 1346 "VBNET.ATG" +#line 1116 "VBNET.ATG" endPos = t.EndLocation; Expect(1); } Block( -#line 1347 "VBNET.ATG" +#line 1117 "VBNET.ATG" out stmt); Expect(88); Expect(187); Expect(1); -#line 1349 "VBNET.ATG" +#line 1119 "VBNET.ATG" OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier, attributes, parameters, @@ -2377,25 +2149,25 @@ out stmt); } void EnumMemberDecl( -#line 917 "VBNET.ATG" +#line 670 "VBNET.ATG" out FieldDeclaration f) { -#line 919 "VBNET.ATG" +#line 672 "VBNET.ATG" Expression expr = null;List attributes = new List(); AttributeSection section = null; VariableDeclaration varDecl = null; while (la.kind == 27) { AttributeSection( -#line 923 "VBNET.ATG" +#line 676 "VBNET.ATG" out section); -#line 923 "VBNET.ATG" +#line 676 "VBNET.ATG" attributes.Add(section); } Identifier(); -#line 926 "VBNET.ATG" +#line 679 "VBNET.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2404,10 +2176,10 @@ out section); if (la.kind == 11) { lexer.NextToken(); Expr( -#line 931 "VBNET.ATG" +#line 684 "VBNET.ATG" out expr); -#line 931 "VBNET.ATG" +#line 684 "VBNET.ATG" varDecl.Initializer = expr; } Expect(1); @@ -2415,7 +2187,7 @@ out expr); void InterfaceMemberDecl() { -#line 834 "VBNET.ATG" +#line 587 "VBNET.ATG" TypeReference type =null; List p = new List(); List templates = new List(); @@ -2427,31 +2199,31 @@ out expr); if (StartOf(16)) { while (la.kind == 27) { AttributeSection( -#line 842 "VBNET.ATG" +#line 595 "VBNET.ATG" out section); -#line 842 "VBNET.ATG" +#line 595 "VBNET.ATG" attributes.Add(section); } while (StartOf(7)) { MemberModifier( -#line 845 "VBNET.ATG" +#line 598 "VBNET.ATG" mod); } if (la.kind == 93) { lexer.NextToken(); -#line 848 "VBNET.ATG" +#line 601 "VBNET.ATG" mod.Check(Modifier.VBInterfaceEvents); Identifier(); -#line 849 "VBNET.ATG" +#line 602 "VBNET.ATG" name = t.val; if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 850 "VBNET.ATG" +#line 603 "VBNET.ATG" p); } Expect(25); @@ -2459,12 +2231,12 @@ p); if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 851 "VBNET.ATG" +#line 604 "VBNET.ATG" out type); } Expect(1); -#line 854 "VBNET.ATG" +#line 607 "VBNET.ATG" EventDeclaration ed = new EventDeclaration(type, mod.Modifier, p, attributes, name, null); compilationUnit.AddChild(ed); ed.EndLocation = t.EndLocation; @@ -2472,27 +2244,27 @@ out type); } else if (la.kind == 167) { lexer.NextToken(); -#line 860 "VBNET.ATG" +#line 613 "VBNET.ATG" mod.Check(Modifier.VBInterfaceMethods); Identifier(); -#line 861 "VBNET.ATG" +#line 614 "VBNET.ATG" name = t.val; TypeParameterList( -#line 862 "VBNET.ATG" +#line 615 "VBNET.ATG" templates); if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 863 "VBNET.ATG" +#line 616 "VBNET.ATG" p); } Expect(25); } Expect(1); -#line 866 "VBNET.ATG" +#line 619 "VBNET.ATG" MethodDeclaration md = new MethodDeclaration(name, mod.Modifier, null, p, attributes); md.TypeReference = new TypeReference("", "System.Void"); md.EndLocation = t.EndLocation; @@ -2502,20 +2274,20 @@ p); } else if (la.kind == 100) { lexer.NextToken(); -#line 874 "VBNET.ATG" +#line 627 "VBNET.ATG" mod.Check(Modifier.VBInterfaceMethods); Identifier(); -#line 875 "VBNET.ATG" +#line 628 "VBNET.ATG" name = t.val; TypeParameterList( -#line 876 "VBNET.ATG" +#line 629 "VBNET.ATG" templates); if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 877 "VBNET.ATG" +#line 630 "VBNET.ATG" p); } Expect(25); @@ -2524,15 +2296,15 @@ p); lexer.NextToken(); while (la.kind == 27) { AttributeSection( -#line 878 "VBNET.ATG" +#line 631 "VBNET.ATG" out returnTypeAttributeSection); } TypeName( -#line 878 "VBNET.ATG" +#line 631 "VBNET.ATG" out type); } -#line 880 "VBNET.ATG" +#line 633 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object"); } @@ -2549,17 +2321,17 @@ out type); } else if (la.kind == 146) { lexer.NextToken(); -#line 895 "VBNET.ATG" +#line 648 "VBNET.ATG" mod.Check(Modifier.VBInterfaceProperties); Identifier(); -#line 896 "VBNET.ATG" +#line 649 "VBNET.ATG" name = t.val; if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 897 "VBNET.ATG" +#line 650 "VBNET.ATG" p); } Expect(25); @@ -2567,18 +2339,18 @@ p); if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 898 "VBNET.ATG" +#line 651 "VBNET.ATG" out type); } -#line 900 "VBNET.ATG" +#line 653 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object"); } Expect(1); -#line 906 "VBNET.ATG" +#line 659 "VBNET.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes); pd.Parameters = p; pd.EndLocation = t.EndLocation; @@ -2587,97 +2359,97 @@ out type); } else SynErr(227); } else if (StartOf(17)) { NonModuleDeclaration( -#line 913 "VBNET.ATG" +#line 666 "VBNET.ATG" mod, attributes); } else SynErr(228); } void Expr( -#line 1732 "VBNET.ATG" +#line 1502 "VBNET.ATG" out Expression expr) { DisjunctionExpr( -#line 1734 "VBNET.ATG" +#line 1504 "VBNET.ATG" out expr); } void ImplementsClause( -#line 1703 "VBNET.ATG" +#line 1473 "VBNET.ATG" out List baseInterfaces) { -#line 1705 "VBNET.ATG" +#line 1475 "VBNET.ATG" baseInterfaces = new List(); TypeReference type = null; string memberName = null; Expect(107); NonArrayTypeName( -#line 1710 "VBNET.ATG" +#line 1480 "VBNET.ATG" out type, false); -#line 1711 "VBNET.ATG" +#line 1481 "VBNET.ATG" if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); -#line 1712 "VBNET.ATG" +#line 1482 "VBNET.ATG" baseInterfaces.Add(new InterfaceImplementation(type, memberName)); while (la.kind == 12) { lexer.NextToken(); NonArrayTypeName( -#line 1714 "VBNET.ATG" +#line 1484 "VBNET.ATG" out type, false); -#line 1715 "VBNET.ATG" +#line 1485 "VBNET.ATG" if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); -#line 1716 "VBNET.ATG" +#line 1486 "VBNET.ATG" baseInterfaces.Add(new InterfaceImplementation(type, memberName)); } } void HandlesClause( -#line 1661 "VBNET.ATG" +#line 1431 "VBNET.ATG" out List handlesClause) { -#line 1663 "VBNET.ATG" +#line 1433 "VBNET.ATG" handlesClause = new List(); string name; Expect(105); EventMemberSpecifier( -#line 1666 "VBNET.ATG" +#line 1436 "VBNET.ATG" out name); -#line 1666 "VBNET.ATG" +#line 1436 "VBNET.ATG" handlesClause.Add(name); while (la.kind == 12) { lexer.NextToken(); EventMemberSpecifier( -#line 1667 "VBNET.ATG" +#line 1437 "VBNET.ATG" out name); -#line 1667 "VBNET.ATG" +#line 1437 "VBNET.ATG" handlesClause.Add(name); } } void Block( -#line 2347 "VBNET.ATG" +#line 2117 "VBNET.ATG" out Statement stmt) { -#line 2350 "VBNET.ATG" +#line 2120 "VBNET.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.Location; compilationUnit.BlockStart(blockStmt); while (StartOf(18) || -#line 2355 "VBNET.ATG" +#line 2125 "VBNET.ATG" IsEndStmtAhead()) { if ( -#line 2355 "VBNET.ATG" +#line 2125 "VBNET.ATG" IsEndStmtAhead()) { Expect(88); EndOfStmt(); -#line 2355 "VBNET.ATG" +#line 2125 "VBNET.ATG" compilationUnit.AddChild(new EndStatement()); } else { Statement(); @@ -2685,7 +2457,7 @@ IsEndStmtAhead()) { } } -#line 2360 "VBNET.ATG" +#line 2130 "VBNET.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2693,26 +2465,26 @@ IsEndStmtAhead()) { } void Charset( -#line 1653 "VBNET.ATG" +#line 1423 "VBNET.ATG" out CharsetModifier charsetModifier) { -#line 1654 "VBNET.ATG" +#line 1424 "VBNET.ATG" charsetModifier = CharsetModifier.None; if (la.kind == 100 || la.kind == 167) { } else if (la.kind == 47) { lexer.NextToken(); -#line 1655 "VBNET.ATG" +#line 1425 "VBNET.ATG" charsetModifier = CharsetModifier.ANSI; } else if (la.kind == 50) { lexer.NextToken(); -#line 1656 "VBNET.ATG" +#line 1426 "VBNET.ATG" charsetModifier = CharsetModifier.Auto; } else if (la.kind == 176) { lexer.NextToken(); -#line 1657 "VBNET.ATG" +#line 1427 "VBNET.ATG" charsetModifier = CharsetModifier.Unicode; } else SynErr(229); } @@ -2764,38 +2536,38 @@ out CharsetModifier charsetModifier) { } void VariableDeclaratorPartAfterIdentifier( -#line 1542 "VBNET.ATG" +#line 1312 "VBNET.ATG" List fieldDeclaration, string name) { -#line 1544 "VBNET.ATG" +#line 1314 "VBNET.ATG" Expression expr = null; TypeReference type = null; ArrayList rank = null; List dimension = null; if ( -#line 1549 "VBNET.ATG" +#line 1319 "VBNET.ATG" IsSize() && !IsDims()) { ArrayInitializationModifier( -#line 1549 "VBNET.ATG" +#line 1319 "VBNET.ATG" out dimension); } if ( -#line 1550 "VBNET.ATG" +#line 1320 "VBNET.ATG" IsDims()) { ArrayNameModifier( -#line 1550 "VBNET.ATG" +#line 1320 "VBNET.ATG" out rank); } if ( -#line 1552 "VBNET.ATG" +#line 1322 "VBNET.ATG" IsObjectCreation()) { Expect(48); ObjectCreateExpression( -#line 1552 "VBNET.ATG" +#line 1322 "VBNET.ATG" out expr); -#line 1554 "VBNET.ATG" +#line 1324 "VBNET.ATG" if (expr is ObjectCreateExpression) { type = ((ObjectCreateExpression)expr).CreateType; } else { @@ -2806,11 +2578,11 @@ out expr); if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1561 "VBNET.ATG" +#line 1331 "VBNET.ATG" out type); } -#line 1563 "VBNET.ATG" +#line 1333 "VBNET.ATG" if (type != null && dimension != null) { if(type.RankSpecifier != null) { Error("array rank only allowed one time"); @@ -2836,52 +2608,52 @@ out type); if (la.kind == 11) { lexer.NextToken(); VariableInitializer( -#line 1585 "VBNET.ATG" +#line 1355 "VBNET.ATG" out expr); } } else SynErr(231); -#line 1587 "VBNET.ATG" +#line 1357 "VBNET.ATG" fieldDeclaration.Add(new VariableDeclaration(name, expr, type)); } void VariableDeclarator( -#line 1536 "VBNET.ATG" +#line 1306 "VBNET.ATG" List fieldDeclaration) { Identifier(); -#line 1538 "VBNET.ATG" +#line 1308 "VBNET.ATG" string name = t.val; VariableDeclaratorPartAfterIdentifier( -#line 1539 "VBNET.ATG" +#line 1309 "VBNET.ATG" fieldDeclaration, name); } void ConstantDeclarator( -#line 1519 "VBNET.ATG" +#line 1289 "VBNET.ATG" List constantDeclaration) { -#line 1521 "VBNET.ATG" +#line 1291 "VBNET.ATG" Expression expr = null; TypeReference type = null; string name = String.Empty; Identifier(); -#line 1525 "VBNET.ATG" +#line 1295 "VBNET.ATG" name = t.val; if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1526 "VBNET.ATG" +#line 1296 "VBNET.ATG" out type); } Expect(11); Expr( -#line 1527 "VBNET.ATG" +#line 1297 "VBNET.ATG" out expr); -#line 1529 "VBNET.ATG" +#line 1299 "VBNET.ATG" VariableDeclaration f = new VariableDeclaration(name, expr); f.TypeReference = type; constantDeclaration.Add(f); @@ -2889,10 +2661,10 @@ out expr); } void AccessorDecls( -#line 1461 "VBNET.ATG" +#line 1231 "VBNET.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1463 "VBNET.ATG" +#line 1233 "VBNET.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -2900,60 +2672,60 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 27) { AttributeSection( -#line 1468 "VBNET.ATG" +#line 1238 "VBNET.ATG" out section); -#line 1468 "VBNET.ATG" +#line 1238 "VBNET.ATG" attributes.Add(section); } if (la.kind == 101) { GetAccessorDecl( -#line 1470 "VBNET.ATG" +#line 1240 "VBNET.ATG" out getBlock, attributes); if (la.kind == 27 || la.kind == 156) { -#line 1472 "VBNET.ATG" +#line 1242 "VBNET.ATG" attributes = new List(); while (la.kind == 27) { AttributeSection( -#line 1473 "VBNET.ATG" +#line 1243 "VBNET.ATG" out section); -#line 1473 "VBNET.ATG" +#line 1243 "VBNET.ATG" attributes.Add(section); } SetAccessorDecl( -#line 1474 "VBNET.ATG" +#line 1244 "VBNET.ATG" out setBlock, attributes); } } else if (la.kind == 156) { SetAccessorDecl( -#line 1477 "VBNET.ATG" +#line 1247 "VBNET.ATG" out setBlock, attributes); if (la.kind == 27 || la.kind == 101) { -#line 1479 "VBNET.ATG" +#line 1249 "VBNET.ATG" attributes = new List(); while (la.kind == 27) { AttributeSection( -#line 1480 "VBNET.ATG" +#line 1250 "VBNET.ATG" out section); -#line 1480 "VBNET.ATG" +#line 1250 "VBNET.ATG" attributes.Add(section); } GetAccessorDecl( -#line 1481 "VBNET.ATG" +#line 1251 "VBNET.ATG" out getBlock, attributes); } } else SynErr(232); } void EventAccessorDeclaration( -#line 1424 "VBNET.ATG" +#line 1194 "VBNET.ATG" out EventAddRemoveRegion eventAccessorDeclaration) { -#line 1426 "VBNET.ATG" +#line 1196 "VBNET.ATG" Statement stmt = null; List p = new List(); AttributeSection section; @@ -2962,10 +2734,10 @@ out EventAddRemoveRegion eventAccessorDeclaration) { while (la.kind == 27) { AttributeSection( -#line 1432 "VBNET.ATG" +#line 1202 "VBNET.ATG" out section); -#line 1432 "VBNET.ATG" +#line 1202 "VBNET.ATG" attributes.Add(section); } if (la.kind == 42) { @@ -2974,20 +2746,20 @@ out section); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1434 "VBNET.ATG" +#line 1204 "VBNET.ATG" p); } Expect(25); } Expect(1); Block( -#line 1435 "VBNET.ATG" +#line 1205 "VBNET.ATG" out stmt); Expect(88); Expect(42); Expect(1); -#line 1437 "VBNET.ATG" +#line 1207 "VBNET.ATG" eventAccessorDeclaration = new EventAddRegion(attributes); eventAccessorDeclaration.Block = (BlockStatement)stmt; eventAccessorDeclaration.Parameters = p; @@ -2998,20 +2770,20 @@ out stmt); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1442 "VBNET.ATG" +#line 1212 "VBNET.ATG" p); } Expect(25); } Expect(1); Block( -#line 1443 "VBNET.ATG" +#line 1213 "VBNET.ATG" out stmt); Expect(88); Expect(152); Expect(1); -#line 1445 "VBNET.ATG" +#line 1215 "VBNET.ATG" eventAccessorDeclaration = new EventRemoveRegion(attributes); eventAccessorDeclaration.Block = (BlockStatement)stmt; eventAccessorDeclaration.Parameters = p; @@ -3022,20 +2794,20 @@ out stmt); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1450 "VBNET.ATG" +#line 1220 "VBNET.ATG" p); } Expect(25); } Expect(1); Block( -#line 1451 "VBNET.ATG" +#line 1221 "VBNET.ATG" out stmt); Expect(88); Expect(149); Expect(1); -#line 1453 "VBNET.ATG" +#line 1223 "VBNET.ATG" eventAccessorDeclaration = new EventRaiseRegion(attributes); eventAccessorDeclaration.Block = (BlockStatement)stmt; eventAccessorDeclaration.Parameters = p; @@ -3044,163 +2816,163 @@ out stmt); } void OverloadableOperator( -#line 1366 "VBNET.ATG" +#line 1136 "VBNET.ATG" out OverloadableOperatorType operatorType) { -#line 1367 "VBNET.ATG" +#line 1137 "VBNET.ATG" operatorType = OverloadableOperatorType.None; switch (la.kind) { case 14: { lexer.NextToken(); -#line 1369 "VBNET.ATG" +#line 1139 "VBNET.ATG" operatorType = OverloadableOperatorType.Add; break; } case 15: { lexer.NextToken(); -#line 1371 "VBNET.ATG" +#line 1141 "VBNET.ATG" operatorType = OverloadableOperatorType.Subtract; break; } case 16: { lexer.NextToken(); -#line 1373 "VBNET.ATG" +#line 1143 "VBNET.ATG" operatorType = OverloadableOperatorType.Multiply; break; } case 17: { lexer.NextToken(); -#line 1375 "VBNET.ATG" +#line 1145 "VBNET.ATG" operatorType = OverloadableOperatorType.Divide; break; } case 18: { lexer.NextToken(); -#line 1377 "VBNET.ATG" +#line 1147 "VBNET.ATG" operatorType = OverloadableOperatorType.DivideInteger; break; } case 19: { lexer.NextToken(); -#line 1379 "VBNET.ATG" +#line 1149 "VBNET.ATG" operatorType = OverloadableOperatorType.Concat; break; } case 116: { lexer.NextToken(); -#line 1381 "VBNET.ATG" +#line 1151 "VBNET.ATG" operatorType = OverloadableOperatorType.Like; break; } case 120: { lexer.NextToken(); -#line 1383 "VBNET.ATG" +#line 1153 "VBNET.ATG" operatorType = OverloadableOperatorType.Modulus; break; } case 45: { lexer.NextToken(); -#line 1385 "VBNET.ATG" +#line 1155 "VBNET.ATG" operatorType = OverloadableOperatorType.BitwiseAnd; break; } case 138: { lexer.NextToken(); -#line 1387 "VBNET.ATG" +#line 1157 "VBNET.ATG" operatorType = OverloadableOperatorType.BitwiseOr; break; } case 185: { lexer.NextToken(); -#line 1389 "VBNET.ATG" +#line 1159 "VBNET.ATG" operatorType = OverloadableOperatorType.ExclusiveOr; break; } case 20: { lexer.NextToken(); -#line 1391 "VBNET.ATG" +#line 1161 "VBNET.ATG" operatorType = OverloadableOperatorType.Power; break; } case 31: { lexer.NextToken(); -#line 1393 "VBNET.ATG" +#line 1163 "VBNET.ATG" operatorType = OverloadableOperatorType.ShiftLeft; break; } case 32: { lexer.NextToken(); -#line 1395 "VBNET.ATG" +#line 1165 "VBNET.ATG" operatorType = OverloadableOperatorType.ShiftRight; break; } case 11: { lexer.NextToken(); -#line 1397 "VBNET.ATG" +#line 1167 "VBNET.ATG" operatorType = OverloadableOperatorType.Equality; break; } case 28: { lexer.NextToken(); -#line 1399 "VBNET.ATG" +#line 1169 "VBNET.ATG" operatorType = OverloadableOperatorType.InEquality; break; } case 27: { lexer.NextToken(); -#line 1401 "VBNET.ATG" +#line 1171 "VBNET.ATG" operatorType = OverloadableOperatorType.LessThan; break; } case 30: { lexer.NextToken(); -#line 1403 "VBNET.ATG" +#line 1173 "VBNET.ATG" operatorType = OverloadableOperatorType.LessThanOrEqual; break; } case 26: { lexer.NextToken(); -#line 1405 "VBNET.ATG" +#line 1175 "VBNET.ATG" operatorType = OverloadableOperatorType.GreaterThan; break; } case 29: { lexer.NextToken(); -#line 1407 "VBNET.ATG" +#line 1177 "VBNET.ATG" operatorType = OverloadableOperatorType.GreaterThanOrEqual; break; } case 75: { lexer.NextToken(); -#line 1409 "VBNET.ATG" +#line 1179 "VBNET.ATG" operatorType = OverloadableOperatorType.CType; break; } case 2: case 47: case 49: case 50: case 51: case 70: case 144: case 169: case 176: case 177: case 204: { Identifier(); -#line 1413 "VBNET.ATG" +#line 1183 "VBNET.ATG" string opName = t.val; if (string.Equals(opName, "istrue", StringComparison.InvariantCultureIgnoreCase)) { operatorType = OverloadableOperatorType.IsTrue; @@ -3217,98 +2989,98 @@ out OverloadableOperatorType operatorType) { } void GetAccessorDecl( -#line 1487 "VBNET.ATG" +#line 1257 "VBNET.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1488 "VBNET.ATG" +#line 1258 "VBNET.ATG" Statement stmt = null; Expect(101); -#line 1490 "VBNET.ATG" +#line 1260 "VBNET.ATG" Location startLocation = t.Location; Expect(1); Block( -#line 1492 "VBNET.ATG" +#line 1262 "VBNET.ATG" out stmt); -#line 1493 "VBNET.ATG" +#line 1263 "VBNET.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); Expect(88); Expect(101); -#line 1495 "VBNET.ATG" +#line 1265 "VBNET.ATG" getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; Expect(1); } void SetAccessorDecl( -#line 1500 "VBNET.ATG" +#line 1270 "VBNET.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1502 "VBNET.ATG" +#line 1272 "VBNET.ATG" Statement stmt = null; List p = new List(); Expect(156); -#line 1505 "VBNET.ATG" +#line 1275 "VBNET.ATG" Location startLocation = t.Location; if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1506 "VBNET.ATG" +#line 1276 "VBNET.ATG" p); } Expect(25); } Expect(1); Block( -#line 1508 "VBNET.ATG" +#line 1278 "VBNET.ATG" out stmt); -#line 1510 "VBNET.ATG" +#line 1280 "VBNET.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); setBlock.Parameters = p; Expect(88); Expect(156); -#line 1514 "VBNET.ATG" +#line 1284 "VBNET.ATG" setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; Expect(1); } void ArrayInitializationModifier( -#line 1591 "VBNET.ATG" +#line 1361 "VBNET.ATG" out List arrayModifiers) { -#line 1593 "VBNET.ATG" +#line 1363 "VBNET.ATG" arrayModifiers = null; Expect(24); InitializationRankList( -#line 1595 "VBNET.ATG" +#line 1365 "VBNET.ATG" out arrayModifiers); Expect(25); } void ArrayNameModifier( -#line 2140 "VBNET.ATG" +#line 1910 "VBNET.ATG" out ArrayList arrayModifiers) { -#line 2142 "VBNET.ATG" +#line 1912 "VBNET.ATG" arrayModifiers = null; ArrayTypeModifiers( -#line 2144 "VBNET.ATG" +#line 1914 "VBNET.ATG" out arrayModifiers); } void ObjectCreateExpression( -#line 2021 "VBNET.ATG" +#line 1791 "VBNET.ATG" out Expression oce) { -#line 2023 "VBNET.ATG" +#line 1793 "VBNET.ATG" TypeReference type = null; Expression initializer = null; List arguments = null; @@ -3317,35 +3089,35 @@ out Expression oce) { Expect(127); NonArrayTypeName( -#line 2029 "VBNET.ATG" +#line 1799 "VBNET.ATG" out type, false); if (la.kind == 24) { lexer.NextToken(); ArgumentList( -#line 2030 "VBNET.ATG" +#line 1800 "VBNET.ATG" out arguments); Expect(25); if (la.kind == 22 || -#line 2031 "VBNET.ATG" +#line 1801 "VBNET.ATG" la.kind == Tokens.OpenParenthesis) { if ( -#line 2031 "VBNET.ATG" +#line 1801 "VBNET.ATG" la.kind == Tokens.OpenParenthesis) { ArrayTypeModifiers( -#line 2032 "VBNET.ATG" +#line 1802 "VBNET.ATG" out dimensions); ArrayInitializer( -#line 2033 "VBNET.ATG" +#line 1803 "VBNET.ATG" out initializer); } else { ArrayInitializer( -#line 2034 "VBNET.ATG" +#line 1804 "VBNET.ATG" out initializer); } } } -#line 2037 "VBNET.ATG" +#line 1807 "VBNET.ATG" if (type == null) type = new TypeReference("Object"); // fallback type on parser errors if (initializer == null) { oce = new ObjectCreateExpression(type, arguments); @@ -3361,120 +3133,120 @@ out initializer); } void VariableInitializer( -#line 1625 "VBNET.ATG" +#line 1395 "VBNET.ATG" out Expression initializerExpression) { -#line 1627 "VBNET.ATG" +#line 1397 "VBNET.ATG" initializerExpression = null; if (StartOf(20)) { Expr( -#line 1629 "VBNET.ATG" +#line 1399 "VBNET.ATG" out initializerExpression); } else if (la.kind == 22) { ArrayInitializer( -#line 1630 "VBNET.ATG" +#line 1400 "VBNET.ATG" out initializerExpression); } else SynErr(235); } void InitializationRankList( -#line 1599 "VBNET.ATG" +#line 1369 "VBNET.ATG" out List rank) { -#line 1601 "VBNET.ATG" +#line 1371 "VBNET.ATG" rank = new List(); Expression expr = null; Expr( -#line 1604 "VBNET.ATG" +#line 1374 "VBNET.ATG" out expr); if (la.kind == 172) { lexer.NextToken(); -#line 1606 "VBNET.ATG" +#line 1376 "VBNET.ATG" if (!(expr is PrimitiveExpression) || (expr as PrimitiveExpression).StringValue != "0") Error("lower bound of array must be zero"); Expr( -#line 1609 "VBNET.ATG" +#line 1379 "VBNET.ATG" out expr); } -#line 1611 "VBNET.ATG" +#line 1381 "VBNET.ATG" if (expr != null) { rank.Add(expr); } while (la.kind == 12) { lexer.NextToken(); Expr( -#line 1613 "VBNET.ATG" +#line 1383 "VBNET.ATG" out expr); if (la.kind == 172) { lexer.NextToken(); -#line 1615 "VBNET.ATG" +#line 1385 "VBNET.ATG" if (!(expr is PrimitiveExpression) || (expr as PrimitiveExpression).StringValue != "0") Error("lower bound of array must be zero"); Expr( -#line 1618 "VBNET.ATG" +#line 1388 "VBNET.ATG" out expr); } -#line 1620 "VBNET.ATG" +#line 1390 "VBNET.ATG" if (expr != null) { rank.Add(expr); } } } void ArrayInitializer( -#line 1634 "VBNET.ATG" +#line 1404 "VBNET.ATG" out Expression outExpr) { -#line 1636 "VBNET.ATG" +#line 1406 "VBNET.ATG" Expression expr = null; ArrayInitializerExpression initializer = new ArrayInitializerExpression(); Expect(22); if (StartOf(21)) { VariableInitializer( -#line 1641 "VBNET.ATG" +#line 1411 "VBNET.ATG" out expr); -#line 1643 "VBNET.ATG" +#line 1413 "VBNET.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1646 "VBNET.ATG" +#line 1416 "VBNET.ATG" NotFinalComma()) { Expect(12); VariableInitializer( -#line 1646 "VBNET.ATG" +#line 1416 "VBNET.ATG" out expr); -#line 1647 "VBNET.ATG" +#line 1417 "VBNET.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } } Expect(23); -#line 1650 "VBNET.ATG" +#line 1420 "VBNET.ATG" outExpr = initializer; } void EventMemberSpecifier( -#line 1720 "VBNET.ATG" +#line 1490 "VBNET.ATG" out string name) { -#line 1721 "VBNET.ATG" +#line 1491 "VBNET.ATG" string type; name = String.Empty; if (StartOf(12)) { Identifier(); -#line 1722 "VBNET.ATG" +#line 1492 "VBNET.ATG" type = t.val; Expect(10); Identifier(); -#line 1724 "VBNET.ATG" +#line 1494 "VBNET.ATG" name = type + "." + t.val; } else if (la.kind == 124) { lexer.NextToken(); @@ -3482,128 +3254,128 @@ out string name) { if (StartOf(12)) { Identifier(); -#line 1727 "VBNET.ATG" +#line 1497 "VBNET.ATG" name = "MyBase." + t.val; } else if (la.kind == 92) { lexer.NextToken(); -#line 1728 "VBNET.ATG" +#line 1498 "VBNET.ATG" name = "MyBase.Error"; } else SynErr(236); } else SynErr(237); } void DisjunctionExpr( -#line 1870 "VBNET.ATG" +#line 1640 "VBNET.ATG" out Expression outExpr) { -#line 1872 "VBNET.ATG" +#line 1642 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ConjunctionExpr( -#line 1875 "VBNET.ATG" +#line 1645 "VBNET.ATG" out outExpr); while (la.kind == 138 || la.kind == 139 || la.kind == 185) { if (la.kind == 138) { lexer.NextToken(); -#line 1878 "VBNET.ATG" +#line 1648 "VBNET.ATG" op = BinaryOperatorType.BitwiseOr; } else if (la.kind == 139) { lexer.NextToken(); -#line 1879 "VBNET.ATG" +#line 1649 "VBNET.ATG" op = BinaryOperatorType.LogicalOr; } else { lexer.NextToken(); -#line 1880 "VBNET.ATG" +#line 1650 "VBNET.ATG" op = BinaryOperatorType.ExclusiveOr; } ConjunctionExpr( -#line 1882 "VBNET.ATG" +#line 1652 "VBNET.ATG" out expr); -#line 1882 "VBNET.ATG" +#line 1652 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AssignmentOperator( -#line 1737 "VBNET.ATG" +#line 1507 "VBNET.ATG" out AssignmentOperatorType op) { -#line 1738 "VBNET.ATG" +#line 1508 "VBNET.ATG" op = AssignmentOperatorType.None; switch (la.kind) { case 11: { lexer.NextToken(); -#line 1739 "VBNET.ATG" +#line 1509 "VBNET.ATG" op = AssignmentOperatorType.Assign; break; } case 41: { lexer.NextToken(); -#line 1740 "VBNET.ATG" +#line 1510 "VBNET.ATG" op = AssignmentOperatorType.ConcatString; break; } case 33: { lexer.NextToken(); -#line 1741 "VBNET.ATG" +#line 1511 "VBNET.ATG" op = AssignmentOperatorType.Add; break; } case 35: { lexer.NextToken(); -#line 1742 "VBNET.ATG" +#line 1512 "VBNET.ATG" op = AssignmentOperatorType.Subtract; break; } case 36: { lexer.NextToken(); -#line 1743 "VBNET.ATG" +#line 1513 "VBNET.ATG" op = AssignmentOperatorType.Multiply; break; } case 37: { lexer.NextToken(); -#line 1744 "VBNET.ATG" +#line 1514 "VBNET.ATG" op = AssignmentOperatorType.Divide; break; } case 38: { lexer.NextToken(); -#line 1745 "VBNET.ATG" +#line 1515 "VBNET.ATG" op = AssignmentOperatorType.DivideInteger; break; } case 34: { lexer.NextToken(); -#line 1746 "VBNET.ATG" +#line 1516 "VBNET.ATG" op = AssignmentOperatorType.Power; break; } case 39: { lexer.NextToken(); -#line 1747 "VBNET.ATG" +#line 1517 "VBNET.ATG" op = AssignmentOperatorType.ShiftLeft; break; } case 40: { lexer.NextToken(); -#line 1748 "VBNET.ATG" +#line 1518 "VBNET.ATG" op = AssignmentOperatorType.ShiftRight; break; } @@ -3612,10 +3384,10 @@ out AssignmentOperatorType op) { } void SimpleExpr( -#line 1752 "VBNET.ATG" +#line 1522 "VBNET.ATG" out Expression pexpr) { -#line 1754 "VBNET.ATG" +#line 1524 "VBNET.ATG" Expression expr; TypeReference type = null; string name = String.Empty; @@ -3626,145 +3398,145 @@ out Expression pexpr) { case 3: { lexer.NextToken(); -#line 1762 "VBNET.ATG" +#line 1532 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 4: { lexer.NextToken(); -#line 1763 "VBNET.ATG" +#line 1533 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 7: { lexer.NextToken(); -#line 1764 "VBNET.ATG" +#line 1534 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 6: { lexer.NextToken(); -#line 1765 "VBNET.ATG" +#line 1535 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 5: { lexer.NextToken(); -#line 1766 "VBNET.ATG" +#line 1536 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 9: { lexer.NextToken(); -#line 1767 "VBNET.ATG" +#line 1537 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 8: { lexer.NextToken(); -#line 1768 "VBNET.ATG" +#line 1538 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 173: { lexer.NextToken(); -#line 1770 "VBNET.ATG" +#line 1540 "VBNET.ATG" pexpr = new PrimitiveExpression(true, "true"); break; } case 96: { lexer.NextToken(); -#line 1771 "VBNET.ATG" +#line 1541 "VBNET.ATG" pexpr = new PrimitiveExpression(false, "false"); break; } case 130: { lexer.NextToken(); -#line 1772 "VBNET.ATG" +#line 1542 "VBNET.ATG" pexpr = new PrimitiveExpression(null, "null"); break; } case 24: { lexer.NextToken(); Expr( -#line 1773 "VBNET.ATG" +#line 1543 "VBNET.ATG" out expr); Expect(25); -#line 1773 "VBNET.ATG" +#line 1543 "VBNET.ATG" pexpr = new ParenthesizedExpression(expr); break; } case 2: case 47: case 49: case 50: case 51: case 70: case 144: case 169: case 176: case 177: case 204: { Identifier(); -#line 1774 "VBNET.ATG" +#line 1544 "VBNET.ATG" pexpr = new IdentifierExpression(t.val); break; } case 10: case 52: case 54: case 65: case 76: case 77: case 84: case 111: case 117: case 133: case 159: case 160: case 165: case 190: case 191: case 192: case 193: { -#line 1775 "VBNET.ATG" +#line 1545 "VBNET.ATG" string val = String.Empty; if (StartOf(23)) { if (StartOf(9)) { PrimitiveTypeName( -#line 1776 "VBNET.ATG" +#line 1546 "VBNET.ATG" out val); } else { lexer.NextToken(); -#line 1776 "VBNET.ATG" +#line 1546 "VBNET.ATG" val = "Object"; } } Expect(10); -#line 1777 "VBNET.ATG" +#line 1547 "VBNET.ATG" t.val = ""; Identifier(); -#line 1777 "VBNET.ATG" +#line 1547 "VBNET.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); break; } case 119: { lexer.NextToken(); -#line 1778 "VBNET.ATG" +#line 1548 "VBNET.ATG" pexpr = new ThisReferenceExpression(); break; } case 124: case 125: { -#line 1779 "VBNET.ATG" +#line 1549 "VBNET.ATG" Expression retExpr = null; if (la.kind == 124) { lexer.NextToken(); -#line 1780 "VBNET.ATG" +#line 1550 "VBNET.ATG" retExpr = new BaseReferenceExpression(); } else if (la.kind == 125) { lexer.NextToken(); -#line 1781 "VBNET.ATG" +#line 1551 "VBNET.ATG" retExpr = new ClassReferenceExpression(); } else SynErr(239); Expect(10); IdentifierOrKeyword( -#line 1783 "VBNET.ATG" +#line 1553 "VBNET.ATG" out name); -#line 1783 "VBNET.ATG" +#line 1553 "VBNET.ATG" pexpr = new FieldReferenceExpression(retExpr, name); break; } @@ -3773,77 +3545,77 @@ out name); Expect(10); Identifier(); -#line 1785 "VBNET.ATG" +#line 1555 "VBNET.ATG" type = new TypeReference(t.val ?? ""); -#line 1787 "VBNET.ATG" +#line 1557 "VBNET.ATG" type.IsGlobal = true; -#line 1788 "VBNET.ATG" +#line 1558 "VBNET.ATG" pexpr = new TypeReferenceExpression(type); break; } case 127: { ObjectCreateExpression( -#line 1789 "VBNET.ATG" +#line 1559 "VBNET.ATG" out expr); -#line 1789 "VBNET.ATG" +#line 1559 "VBNET.ATG" pexpr = expr; break; } case 75: case 82: case 199: { -#line 1791 "VBNET.ATG" +#line 1561 "VBNET.ATG" CastType castType = CastType.Cast; if (la.kind == 82) { lexer.NextToken(); } else if (la.kind == 75) { lexer.NextToken(); -#line 1793 "VBNET.ATG" +#line 1563 "VBNET.ATG" castType = CastType.Conversion; } else if (la.kind == 199) { lexer.NextToken(); -#line 1794 "VBNET.ATG" +#line 1564 "VBNET.ATG" castType = CastType.TryCast; } else SynErr(240); Expect(24); Expr( -#line 1796 "VBNET.ATG" +#line 1566 "VBNET.ATG" out expr); Expect(12); TypeName( -#line 1796 "VBNET.ATG" +#line 1566 "VBNET.ATG" out type); Expect(25); -#line 1797 "VBNET.ATG" +#line 1567 "VBNET.ATG" pexpr = new CastExpression(type, expr, castType); break; } case 59: case 60: case 61: case 62: case 63: case 64: case 66: case 68: case 69: case 72: case 73: case 74: case 194: case 195: case 196: case 197: { CastTarget( -#line 1798 "VBNET.ATG" +#line 1568 "VBNET.ATG" out type); Expect(24); Expr( -#line 1798 "VBNET.ATG" +#line 1568 "VBNET.ATG" out expr); Expect(25); -#line 1798 "VBNET.ATG" +#line 1568 "VBNET.ATG" pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion); break; } case 43: { lexer.NextToken(); Expr( -#line 1799 "VBNET.ATG" +#line 1569 "VBNET.ATG" out expr); -#line 1799 "VBNET.ATG" +#line 1569 "VBNET.ATG" pexpr = new AddressOfExpression(expr); break; } @@ -3851,159 +3623,159 @@ out expr); lexer.NextToken(); Expect(24); GetTypeTypeName( -#line 1800 "VBNET.ATG" +#line 1570 "VBNET.ATG" out type); Expect(25); -#line 1800 "VBNET.ATG" +#line 1570 "VBNET.ATG" pexpr = new TypeOfExpression(type); break; } case 175: { lexer.NextToken(); SimpleExpr( -#line 1801 "VBNET.ATG" +#line 1571 "VBNET.ATG" out expr); Expect(113); TypeName( -#line 1801 "VBNET.ATG" +#line 1571 "VBNET.ATG" out type); -#line 1801 "VBNET.ATG" +#line 1571 "VBNET.ATG" pexpr = new TypeOfIsExpression(expr, type); break; } } while (la.kind == 10 || la.kind == 24) { InvocationOrMemberReferenceExpression( -#line 1803 "VBNET.ATG" +#line 1573 "VBNET.ATG" ref pexpr); } } else if (la.kind == 10) { lexer.NextToken(); IdentifierOrKeyword( -#line 1806 "VBNET.ATG" +#line 1576 "VBNET.ATG" out name); -#line 1806 "VBNET.ATG" +#line 1576 "VBNET.ATG" pexpr = new FieldReferenceExpression(pexpr, name); while (la.kind == 10 || la.kind == 24) { InvocationOrMemberReferenceExpression( -#line 1807 "VBNET.ATG" +#line 1577 "VBNET.ATG" ref pexpr); } } else SynErr(241); } void PrimitiveTypeName( -#line 2950 "VBNET.ATG" +#line 2718 "VBNET.ATG" out string type) { -#line 2951 "VBNET.ATG" +#line 2719 "VBNET.ATG" type = String.Empty; switch (la.kind) { case 52: { lexer.NextToken(); -#line 2952 "VBNET.ATG" +#line 2720 "VBNET.ATG" type = "Boolean"; break; } case 76: { lexer.NextToken(); -#line 2953 "VBNET.ATG" +#line 2721 "VBNET.ATG" type = "Date"; break; } case 65: { lexer.NextToken(); -#line 2954 "VBNET.ATG" +#line 2722 "VBNET.ATG" type = "Char"; break; } case 165: { lexer.NextToken(); -#line 2955 "VBNET.ATG" +#line 2723 "VBNET.ATG" type = "String"; break; } case 77: { lexer.NextToken(); -#line 2956 "VBNET.ATG" +#line 2724 "VBNET.ATG" type = "Decimal"; break; } case 54: { lexer.NextToken(); -#line 2957 "VBNET.ATG" +#line 2725 "VBNET.ATG" type = "Byte"; break; } case 159: { lexer.NextToken(); -#line 2958 "VBNET.ATG" +#line 2726 "VBNET.ATG" type = "Short"; break; } case 111: { lexer.NextToken(); -#line 2959 "VBNET.ATG" +#line 2727 "VBNET.ATG" type = "Integer"; break; } case 117: { lexer.NextToken(); -#line 2960 "VBNET.ATG" +#line 2728 "VBNET.ATG" type = "Long"; break; } case 160: { lexer.NextToken(); -#line 2961 "VBNET.ATG" +#line 2729 "VBNET.ATG" type = "Single"; break; } case 84: { lexer.NextToken(); -#line 2962 "VBNET.ATG" +#line 2730 "VBNET.ATG" type = "Double"; break; } case 191: { lexer.NextToken(); -#line 2963 "VBNET.ATG" +#line 2731 "VBNET.ATG" type = "UInteger"; break; } case 192: { lexer.NextToken(); -#line 2964 "VBNET.ATG" +#line 2732 "VBNET.ATG" type = "ULong"; break; } case 193: { lexer.NextToken(); -#line 2965 "VBNET.ATG" +#line 2733 "VBNET.ATG" type = "UShort"; break; } case 190: { lexer.NextToken(); -#line 2966 "VBNET.ATG" +#line 2734 "VBNET.ATG" type = "SByte"; break; } @@ -4012,130 +3784,130 @@ out string type) { } void IdentifierOrKeyword( -#line 2943 "VBNET.ATG" +#line 2711 "VBNET.ATG" out string name) { -#line 2945 "VBNET.ATG" +#line 2713 "VBNET.ATG" lexer.NextToken(); name = t.val; } void CastTarget( -#line 1848 "VBNET.ATG" +#line 1618 "VBNET.ATG" out TypeReference type) { -#line 1850 "VBNET.ATG" +#line 1620 "VBNET.ATG" type = null; switch (la.kind) { case 59: { lexer.NextToken(); -#line 1852 "VBNET.ATG" +#line 1622 "VBNET.ATG" type = new TypeReference("System.Boolean"); break; } case 60: { lexer.NextToken(); -#line 1853 "VBNET.ATG" +#line 1623 "VBNET.ATG" type = new TypeReference("System.Byte"); break; } case 194: { lexer.NextToken(); -#line 1854 "VBNET.ATG" +#line 1624 "VBNET.ATG" type = new TypeReference("System.SByte"); break; } case 61: { lexer.NextToken(); -#line 1855 "VBNET.ATG" +#line 1625 "VBNET.ATG" type = new TypeReference("System.Char"); break; } case 62: { lexer.NextToken(); -#line 1856 "VBNET.ATG" +#line 1626 "VBNET.ATG" type = new TypeReference("System.DateTime"); break; } case 64: { lexer.NextToken(); -#line 1857 "VBNET.ATG" +#line 1627 "VBNET.ATG" type = new TypeReference("System.Decimal"); break; } case 63: { lexer.NextToken(); -#line 1858 "VBNET.ATG" +#line 1628 "VBNET.ATG" type = new TypeReference("System.Double"); break; } case 72: { lexer.NextToken(); -#line 1859 "VBNET.ATG" +#line 1629 "VBNET.ATG" type = new TypeReference("System.Int16"); break; } case 66: { lexer.NextToken(); -#line 1860 "VBNET.ATG" +#line 1630 "VBNET.ATG" type = new TypeReference("System.Int32"); break; } case 68: { lexer.NextToken(); -#line 1861 "VBNET.ATG" +#line 1631 "VBNET.ATG" type = new TypeReference("System.Int64"); break; } case 195: { lexer.NextToken(); -#line 1862 "VBNET.ATG" +#line 1632 "VBNET.ATG" type = new TypeReference("System.UInt16"); break; } case 196: { lexer.NextToken(); -#line 1863 "VBNET.ATG" +#line 1633 "VBNET.ATG" type = new TypeReference("System.UInt32"); break; } case 197: { lexer.NextToken(); -#line 1864 "VBNET.ATG" +#line 1634 "VBNET.ATG" type = new TypeReference("System.UInt64"); break; } case 69: { lexer.NextToken(); -#line 1865 "VBNET.ATG" +#line 1635 "VBNET.ATG" type = new TypeReference("System.Object"); break; } case 73: { lexer.NextToken(); -#line 1866 "VBNET.ATG" +#line 1636 "VBNET.ATG" type = new TypeReference("System.Single"); break; } case 74: { lexer.NextToken(); -#line 1867 "VBNET.ATG" +#line 1637 "VBNET.ATG" type = new TypeReference("System.String"); break; } @@ -4144,19 +3916,19 @@ out TypeReference type) { } void GetTypeTypeName( -#line 2092 "VBNET.ATG" +#line 1862 "VBNET.ATG" out TypeReference typeref) { -#line 2093 "VBNET.ATG" +#line 1863 "VBNET.ATG" ArrayList rank = null; NonArrayTypeName( -#line 2095 "VBNET.ATG" +#line 1865 "VBNET.ATG" out typeref, true); ArrayTypeModifiers( -#line 2096 "VBNET.ATG" +#line 1866 "VBNET.ATG" out rank); -#line 2097 "VBNET.ATG" +#line 1867 "VBNET.ATG" if (rank != null && typeref != null) { typeref.RankSpecifier = (int[])rank.ToArray(typeof(int)); } @@ -4164,53 +3936,53 @@ out rank); } void InvocationOrMemberReferenceExpression( -#line 1811 "VBNET.ATG" +#line 1581 "VBNET.ATG" ref Expression pexpr) { -#line 1812 "VBNET.ATG" +#line 1582 "VBNET.ATG" string name; if (la.kind == 10) { lexer.NextToken(); IdentifierOrKeyword( -#line 1814 "VBNET.ATG" +#line 1584 "VBNET.ATG" out name); -#line 1814 "VBNET.ATG" +#line 1584 "VBNET.ATG" pexpr = new FieldReferenceExpression(pexpr, name); } else if (la.kind == 24) { InvocationExpression( -#line 1815 "VBNET.ATG" +#line 1585 "VBNET.ATG" ref pexpr); } else SynErr(244); } void InvocationExpression( -#line 1818 "VBNET.ATG" +#line 1588 "VBNET.ATG" ref Expression pexpr) { -#line 1819 "VBNET.ATG" +#line 1589 "VBNET.ATG" List typeParameters = new List(); List parameters = null; TypeReference type; Expect(24); -#line 1823 "VBNET.ATG" +#line 1593 "VBNET.ATG" Location start = t.Location; if (la.kind == 200) { lexer.NextToken(); TypeName( -#line 1825 "VBNET.ATG" +#line 1595 "VBNET.ATG" out type); -#line 1825 "VBNET.ATG" +#line 1595 "VBNET.ATG" if (type != null) typeParameters.Add(type); while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 1828 "VBNET.ATG" +#line 1598 "VBNET.ATG" out type); -#line 1828 "VBNET.ATG" +#line 1598 "VBNET.ATG" if (type != null) typeParameters.Add(type); } Expect(25); @@ -4218,365 +3990,365 @@ out type); lexer.NextToken(); Identifier(); -#line 1833 "VBNET.ATG" +#line 1603 "VBNET.ATG" pexpr = new FieldReferenceExpression(GetTypeReferenceExpression(pexpr, typeParameters), t.val); } else if (la.kind == 24) { lexer.NextToken(); ArgumentList( -#line 1835 "VBNET.ATG" +#line 1605 "VBNET.ATG" out parameters); Expect(25); -#line 1837 "VBNET.ATG" +#line 1607 "VBNET.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeParameters); } else SynErr(245); } else if (StartOf(24)) { ArgumentList( -#line 1839 "VBNET.ATG" +#line 1609 "VBNET.ATG" out parameters); Expect(25); -#line 1841 "VBNET.ATG" +#line 1611 "VBNET.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeParameters); } else SynErr(246); -#line 1843 "VBNET.ATG" +#line 1613 "VBNET.ATG" pexpr.StartLocation = start; pexpr.EndLocation = t.Location; } void ArgumentList( -#line 2052 "VBNET.ATG" +#line 1822 "VBNET.ATG" out List arguments) { -#line 2054 "VBNET.ATG" +#line 1824 "VBNET.ATG" arguments = new List(); Expression expr = null; if (StartOf(20)) { Argument( -#line 2057 "VBNET.ATG" +#line 1827 "VBNET.ATG" out expr); } while (la.kind == 12) { lexer.NextToken(); -#line 2058 "VBNET.ATG" +#line 1828 "VBNET.ATG" arguments.Add(expr ?? Expression.Null); expr = null; if (StartOf(20)) { Argument( -#line 2059 "VBNET.ATG" +#line 1829 "VBNET.ATG" out expr); } -#line 2060 "VBNET.ATG" +#line 1830 "VBNET.ATG" if (expr == null) expr = Expression.Null; } -#line 2062 "VBNET.ATG" +#line 1832 "VBNET.ATG" if (expr != null) arguments.Add(expr); } void ConjunctionExpr( -#line 1886 "VBNET.ATG" +#line 1656 "VBNET.ATG" out Expression outExpr) { -#line 1888 "VBNET.ATG" +#line 1658 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; NotExpr( -#line 1891 "VBNET.ATG" +#line 1661 "VBNET.ATG" out outExpr); while (la.kind == 45 || la.kind == 46) { if (la.kind == 45) { lexer.NextToken(); -#line 1894 "VBNET.ATG" +#line 1664 "VBNET.ATG" op = BinaryOperatorType.BitwiseAnd; } else { lexer.NextToken(); -#line 1895 "VBNET.ATG" +#line 1665 "VBNET.ATG" op = BinaryOperatorType.LogicalAnd; } NotExpr( -#line 1897 "VBNET.ATG" +#line 1667 "VBNET.ATG" out expr); -#line 1897 "VBNET.ATG" +#line 1667 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void NotExpr( -#line 1901 "VBNET.ATG" +#line 1671 "VBNET.ATG" out Expression outExpr) { -#line 1902 "VBNET.ATG" +#line 1672 "VBNET.ATG" UnaryOperatorType uop = UnaryOperatorType.None; while (la.kind == 129) { lexer.NextToken(); -#line 1903 "VBNET.ATG" +#line 1673 "VBNET.ATG" uop = UnaryOperatorType.Not; } ComparisonExpr( -#line 1904 "VBNET.ATG" +#line 1674 "VBNET.ATG" out outExpr); -#line 1905 "VBNET.ATG" +#line 1675 "VBNET.ATG" if (uop != UnaryOperatorType.None) outExpr = new UnaryOperatorExpression(outExpr, uop); } void ComparisonExpr( -#line 1910 "VBNET.ATG" +#line 1680 "VBNET.ATG" out Expression outExpr) { -#line 1912 "VBNET.ATG" +#line 1682 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 1915 "VBNET.ATG" +#line 1685 "VBNET.ATG" out outExpr); while (StartOf(25)) { switch (la.kind) { case 27: { lexer.NextToken(); -#line 1918 "VBNET.ATG" +#line 1688 "VBNET.ATG" op = BinaryOperatorType.LessThan; break; } case 26: { lexer.NextToken(); -#line 1919 "VBNET.ATG" +#line 1689 "VBNET.ATG" op = BinaryOperatorType.GreaterThan; break; } case 30: { lexer.NextToken(); -#line 1920 "VBNET.ATG" +#line 1690 "VBNET.ATG" op = BinaryOperatorType.LessThanOrEqual; break; } case 29: { lexer.NextToken(); -#line 1921 "VBNET.ATG" +#line 1691 "VBNET.ATG" op = BinaryOperatorType.GreaterThanOrEqual; break; } case 28: { lexer.NextToken(); -#line 1922 "VBNET.ATG" +#line 1692 "VBNET.ATG" op = BinaryOperatorType.InEquality; break; } case 11: { lexer.NextToken(); -#line 1923 "VBNET.ATG" +#line 1693 "VBNET.ATG" op = BinaryOperatorType.Equality; break; } case 116: { lexer.NextToken(); -#line 1924 "VBNET.ATG" +#line 1694 "VBNET.ATG" op = BinaryOperatorType.Like; break; } case 113: { lexer.NextToken(); -#line 1925 "VBNET.ATG" +#line 1695 "VBNET.ATG" op = BinaryOperatorType.ReferenceEquality; break; } case 189: { lexer.NextToken(); -#line 1926 "VBNET.ATG" +#line 1696 "VBNET.ATG" op = BinaryOperatorType.ReferenceInequality; break; } } ShiftExpr( -#line 1928 "VBNET.ATG" +#line 1698 "VBNET.ATG" out expr); -#line 1928 "VBNET.ATG" +#line 1698 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void ShiftExpr( -#line 1932 "VBNET.ATG" +#line 1702 "VBNET.ATG" out Expression outExpr) { -#line 1934 "VBNET.ATG" +#line 1704 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ConcatenationExpr( -#line 1937 "VBNET.ATG" +#line 1707 "VBNET.ATG" out outExpr); while (la.kind == 31 || la.kind == 32) { if (la.kind == 31) { lexer.NextToken(); -#line 1940 "VBNET.ATG" +#line 1710 "VBNET.ATG" op = BinaryOperatorType.ShiftLeft; } else { lexer.NextToken(); -#line 1941 "VBNET.ATG" +#line 1711 "VBNET.ATG" op = BinaryOperatorType.ShiftRight; } ConcatenationExpr( -#line 1943 "VBNET.ATG" +#line 1713 "VBNET.ATG" out expr); -#line 1943 "VBNET.ATG" +#line 1713 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void ConcatenationExpr( -#line 1947 "VBNET.ATG" +#line 1717 "VBNET.ATG" out Expression outExpr) { -#line 1948 "VBNET.ATG" +#line 1718 "VBNET.ATG" Expression expr; AdditiveExpr( -#line 1950 "VBNET.ATG" +#line 1720 "VBNET.ATG" out outExpr); while (la.kind == 19) { lexer.NextToken(); AdditiveExpr( -#line 1950 "VBNET.ATG" +#line 1720 "VBNET.ATG" out expr); -#line 1950 "VBNET.ATG" +#line 1720 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Concat, expr); } } void AdditiveExpr( -#line 1953 "VBNET.ATG" +#line 1723 "VBNET.ATG" out Expression outExpr) { -#line 1955 "VBNET.ATG" +#line 1725 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ModuloExpr( -#line 1958 "VBNET.ATG" +#line 1728 "VBNET.ATG" out outExpr); while (la.kind == 14 || la.kind == 15) { if (la.kind == 14) { lexer.NextToken(); -#line 1961 "VBNET.ATG" +#line 1731 "VBNET.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 1962 "VBNET.ATG" +#line 1732 "VBNET.ATG" op = BinaryOperatorType.Subtract; } ModuloExpr( -#line 1964 "VBNET.ATG" +#line 1734 "VBNET.ATG" out expr); -#line 1964 "VBNET.ATG" +#line 1734 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void ModuloExpr( -#line 1968 "VBNET.ATG" +#line 1738 "VBNET.ATG" out Expression outExpr) { -#line 1969 "VBNET.ATG" +#line 1739 "VBNET.ATG" Expression expr; IntegerDivisionExpr( -#line 1971 "VBNET.ATG" +#line 1741 "VBNET.ATG" out outExpr); while (la.kind == 120) { lexer.NextToken(); IntegerDivisionExpr( -#line 1971 "VBNET.ATG" +#line 1741 "VBNET.ATG" out expr); -#line 1971 "VBNET.ATG" +#line 1741 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Modulus, expr); } } void IntegerDivisionExpr( -#line 1974 "VBNET.ATG" +#line 1744 "VBNET.ATG" out Expression outExpr) { -#line 1975 "VBNET.ATG" +#line 1745 "VBNET.ATG" Expression expr; MultiplicativeExpr( -#line 1977 "VBNET.ATG" +#line 1747 "VBNET.ATG" out outExpr); while (la.kind == 18) { lexer.NextToken(); MultiplicativeExpr( -#line 1977 "VBNET.ATG" +#line 1747 "VBNET.ATG" out expr); -#line 1977 "VBNET.ATG" +#line 1747 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.DivideInteger, expr); } } void MultiplicativeExpr( -#line 1980 "VBNET.ATG" +#line 1750 "VBNET.ATG" out Expression outExpr) { -#line 1982 "VBNET.ATG" +#line 1752 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; UnaryExpr( -#line 1985 "VBNET.ATG" +#line 1755 "VBNET.ATG" out outExpr); while (la.kind == 16 || la.kind == 17) { if (la.kind == 16) { lexer.NextToken(); -#line 1988 "VBNET.ATG" +#line 1758 "VBNET.ATG" op = BinaryOperatorType.Multiply; } else { lexer.NextToken(); -#line 1989 "VBNET.ATG" +#line 1759 "VBNET.ATG" op = BinaryOperatorType.Divide; } UnaryExpr( -#line 1991 "VBNET.ATG" +#line 1761 "VBNET.ATG" out expr); -#line 1991 "VBNET.ATG" +#line 1761 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void UnaryExpr( -#line 1995 "VBNET.ATG" +#line 1765 "VBNET.ATG" out Expression uExpr) { -#line 1997 "VBNET.ATG" +#line 1767 "VBNET.ATG" Expression expr; UnaryOperatorType uop = UnaryOperatorType.None; bool isUOp = false; @@ -4585,25 +4357,25 @@ out Expression uExpr) { if (la.kind == 14) { lexer.NextToken(); -#line 2001 "VBNET.ATG" +#line 1771 "VBNET.ATG" uop = UnaryOperatorType.Plus; isUOp = true; } else if (la.kind == 15) { lexer.NextToken(); -#line 2002 "VBNET.ATG" +#line 1772 "VBNET.ATG" uop = UnaryOperatorType.Minus; isUOp = true; } else { lexer.NextToken(); -#line 2003 "VBNET.ATG" +#line 1773 "VBNET.ATG" uop = UnaryOperatorType.Star; isUOp = true; } } ExponentiationExpr( -#line 2005 "VBNET.ATG" +#line 1775 "VBNET.ATG" out expr); -#line 2007 "VBNET.ATG" +#line 1777 "VBNET.ATG" if (isUOp) { uExpr = new UnaryOperatorExpression(expr, uop); } else { @@ -4613,50 +4385,50 @@ out expr); } void ExponentiationExpr( -#line 2015 "VBNET.ATG" +#line 1785 "VBNET.ATG" out Expression outExpr) { -#line 2016 "VBNET.ATG" +#line 1786 "VBNET.ATG" Expression expr; SimpleExpr( -#line 2018 "VBNET.ATG" +#line 1788 "VBNET.ATG" out outExpr); while (la.kind == 20) { lexer.NextToken(); SimpleExpr( -#line 2018 "VBNET.ATG" +#line 1788 "VBNET.ATG" out expr); -#line 2018 "VBNET.ATG" +#line 1788 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Power, expr); } } void ArrayTypeModifiers( -#line 2149 "VBNET.ATG" +#line 1919 "VBNET.ATG" out ArrayList arrayModifiers) { -#line 2151 "VBNET.ATG" +#line 1921 "VBNET.ATG" arrayModifiers = new ArrayList(); int i = 0; while ( -#line 2154 "VBNET.ATG" +#line 1924 "VBNET.ATG" IsDims()) { Expect(24); if (la.kind == 12 || la.kind == 25) { RankList( -#line 2156 "VBNET.ATG" +#line 1926 "VBNET.ATG" out i); } -#line 2158 "VBNET.ATG" +#line 1928 "VBNET.ATG" arrayModifiers.Add(i); Expect(25); } -#line 2163 "VBNET.ATG" +#line 1933 "VBNET.ATG" if(arrayModifiers.Count == 0) { arrayModifiers = null; } @@ -4664,69 +4436,69 @@ out i); } void Argument( -#line 2066 "VBNET.ATG" +#line 1836 "VBNET.ATG" out Expression argumentexpr) { -#line 2068 "VBNET.ATG" +#line 1838 "VBNET.ATG" Expression expr; argumentexpr = null; string name; if ( -#line 2072 "VBNET.ATG" +#line 1842 "VBNET.ATG" IsNamedAssign()) { Identifier(); -#line 2072 "VBNET.ATG" +#line 1842 "VBNET.ATG" name = t.val; Expect(13); Expect(11); Expr( -#line 2072 "VBNET.ATG" +#line 1842 "VBNET.ATG" out expr); -#line 2074 "VBNET.ATG" +#line 1844 "VBNET.ATG" argumentexpr = new NamedArgumentExpression(name, expr); } else if (StartOf(20)) { Expr( -#line 2077 "VBNET.ATG" +#line 1847 "VBNET.ATG" out argumentexpr); } else SynErr(247); } void QualIdentAndTypeArguments( -#line 2123 "VBNET.ATG" +#line 1893 "VBNET.ATG" out TypeReference typeref, bool canBeUnbound) { -#line 2124 "VBNET.ATG" +#line 1894 "VBNET.ATG" string name; typeref = null; Qualident( -#line 2126 "VBNET.ATG" +#line 1896 "VBNET.ATG" out name); -#line 2127 "VBNET.ATG" +#line 1897 "VBNET.ATG" typeref = new TypeReference(name); if ( -#line 2128 "VBNET.ATG" +#line 1898 "VBNET.ATG" la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { lexer.NextToken(); Expect(200); if ( -#line 2130 "VBNET.ATG" +#line 1900 "VBNET.ATG" canBeUnbound && (la.kind == Tokens.CloseParenthesis || la.kind == Tokens.Comma)) { -#line 2131 "VBNET.ATG" +#line 1901 "VBNET.ATG" typeref.GenericTypes.Add(NullTypeReference.Instance); while (la.kind == 12) { lexer.NextToken(); -#line 2132 "VBNET.ATG" +#line 1902 "VBNET.ATG" typeref.GenericTypes.Add(NullTypeReference.Instance); } } else if (StartOf(5)) { TypeArgumentList( -#line 2133 "VBNET.ATG" +#line 1903 "VBNET.ATG" typeref.GenericTypes); } else SynErr(248); Expect(25); @@ -4734,48 +4506,48 @@ typeref.GenericTypes); } void TypeArgumentList( -#line 2176 "VBNET.ATG" +#line 1946 "VBNET.ATG" List typeArguments) { -#line 2178 "VBNET.ATG" +#line 1948 "VBNET.ATG" TypeReference typeref; TypeName( -#line 2180 "VBNET.ATG" +#line 1950 "VBNET.ATG" out typeref); -#line 2180 "VBNET.ATG" +#line 1950 "VBNET.ATG" if (typeref != null) typeArguments.Add(typeref); while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 2183 "VBNET.ATG" +#line 1953 "VBNET.ATG" out typeref); -#line 2183 "VBNET.ATG" +#line 1953 "VBNET.ATG" if (typeref != null) typeArguments.Add(typeref); } } void RankList( -#line 2170 "VBNET.ATG" +#line 1940 "VBNET.ATG" out int i) { -#line 2171 "VBNET.ATG" +#line 1941 "VBNET.ATG" i = 0; while (la.kind == 12) { lexer.NextToken(); -#line 2172 "VBNET.ATG" +#line 1942 "VBNET.ATG" ++i; } } void Attribute( -#line 2208 "VBNET.ATG" +#line 1978 "VBNET.ATG" out ICSharpCode.NRefactory.Parser.AST.Attribute attribute) { -#line 2209 "VBNET.ATG" +#line 1979 "VBNET.ATG" string name; List positional = new List(); List named = new List(); @@ -4785,39 +4557,39 @@ out ICSharpCode.NRefactory.Parser.AST.Attribute attribute) { Expect(10); } Qualident( -#line 2214 "VBNET.ATG" +#line 1984 "VBNET.ATG" out name); if (la.kind == 24) { AttributeArguments( -#line 2215 "VBNET.ATG" +#line 1985 "VBNET.ATG" positional, named); } -#line 2216 "VBNET.ATG" +#line 1986 "VBNET.ATG" attribute = new ICSharpCode.NRefactory.Parser.AST.Attribute(name, positional, named); } void AttributeArguments( -#line 2220 "VBNET.ATG" +#line 1990 "VBNET.ATG" List positional, List named) { -#line 2222 "VBNET.ATG" +#line 1992 "VBNET.ATG" bool nameFound = false; string name = ""; Expression expr; Expect(24); if ( -#line 2228 "VBNET.ATG" +#line 1998 "VBNET.ATG" IsNotClosingParenthesis()) { if ( -#line 2230 "VBNET.ATG" +#line 2000 "VBNET.ATG" IsNamedAssign()) { -#line 2230 "VBNET.ATG" +#line 2000 "VBNET.ATG" nameFound = true; IdentifierOrKeyword( -#line 2231 "VBNET.ATG" +#line 2001 "VBNET.ATG" out name); if (la.kind == 13) { lexer.NextToken(); @@ -4825,10 +4597,10 @@ out name); Expect(11); } Expr( -#line 2233 "VBNET.ATG" +#line 2003 "VBNET.ATG" out expr); -#line 2235 "VBNET.ATG" +#line 2005 "VBNET.ATG" if (expr != null) { if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -4836,13 +4608,13 @@ out expr); while (la.kind == 12) { lexer.NextToken(); if ( -#line 2242 "VBNET.ATG" +#line 2012 "VBNET.ATG" IsNamedAssign()) { -#line 2242 "VBNET.ATG" +#line 2012 "VBNET.ATG" nameFound = true; IdentifierOrKeyword( -#line 2243 "VBNET.ATG" +#line 2013 "VBNET.ATG" out name); if (la.kind == 13) { lexer.NextToken(); @@ -4850,14 +4622,14 @@ out name); Expect(11); } else if (StartOf(20)) { -#line 2245 "VBNET.ATG" +#line 2015 "VBNET.ATG" if (nameFound) Error("no positional argument after named argument"); } else SynErr(249); Expr( -#line 2246 "VBNET.ATG" +#line 2016 "VBNET.ATG" out expr); -#line 2246 "VBNET.ATG" +#line 2016 "VBNET.ATG" if (expr != null) { if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -4868,10 +4640,10 @@ out expr); } void FormalParameter( -#line 2315 "VBNET.ATG" +#line 2085 "VBNET.ATG" out ParameterDeclarationExpression p) { -#line 2317 "VBNET.ATG" +#line 2087 "VBNET.ATG" TypeReference type = null; ParamModifiers mod = new ParamModifiers(this); Expression expr = null; @@ -4879,28 +4651,28 @@ out ParameterDeclarationExpression p) { while (StartOf(26)) { ParameterModifier( -#line 2322 "VBNET.ATG" +#line 2092 "VBNET.ATG" mod); } Identifier(); -#line 2323 "VBNET.ATG" +#line 2093 "VBNET.ATG" string parameterName = t.val; if ( -#line 2324 "VBNET.ATG" +#line 2094 "VBNET.ATG" IsDims()) { ArrayTypeModifiers( -#line 2324 "VBNET.ATG" +#line 2094 "VBNET.ATG" out arrayModifiers); } if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 2325 "VBNET.ATG" +#line 2095 "VBNET.ATG" out type); } -#line 2327 "VBNET.ATG" +#line 2097 "VBNET.ATG" if(type != null) { if (arrayModifiers != null) { if (type.RankSpecifier != null) { @@ -4916,45 +4688,45 @@ out type); if (la.kind == 11) { lexer.NextToken(); Expr( -#line 2339 "VBNET.ATG" +#line 2109 "VBNET.ATG" out expr); } -#line 2341 "VBNET.ATG" +#line 2111 "VBNET.ATG" mod.Check(); p = new ParameterDeclarationExpression(type, parameterName, mod.Modifier, expr); } void ParameterModifier( -#line 2969 "VBNET.ATG" +#line 2737 "VBNET.ATG" ParamModifiers m) { if (la.kind == 55) { lexer.NextToken(); -#line 2970 "VBNET.ATG" +#line 2738 "VBNET.ATG" m.Add(ParamModifier.In); } else if (la.kind == 53) { lexer.NextToken(); -#line 2971 "VBNET.ATG" +#line 2739 "VBNET.ATG" m.Add(ParamModifier.Ref); } else if (la.kind == 137) { lexer.NextToken(); -#line 2972 "VBNET.ATG" +#line 2740 "VBNET.ATG" m.Add(ParamModifier.Optional); } else if (la.kind == 143) { lexer.NextToken(); -#line 2973 "VBNET.ATG" +#line 2741 "VBNET.ATG" m.Add(ParamModifier.Params); } else SynErr(250); } void Statement() { -#line 2368 "VBNET.ATG" +#line 2138 "VBNET.ATG" Statement stmt = null; Location startPos = la.Location; string label = String.Empty; @@ -4962,34 +4734,34 @@ ParamModifiers m) { if (la.kind == 1 || la.kind == 13) { } else if ( -#line 2374 "VBNET.ATG" +#line 2144 "VBNET.ATG" IsLabel()) { LabelName( -#line 2374 "VBNET.ATG" +#line 2144 "VBNET.ATG" out label); -#line 2376 "VBNET.ATG" +#line 2146 "VBNET.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(13); Statement(); } else if (StartOf(27)) { EmbeddedStatement( -#line 2379 "VBNET.ATG" +#line 2149 "VBNET.ATG" out stmt); -#line 2379 "VBNET.ATG" +#line 2149 "VBNET.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(28)) { LocalDeclarationStatement( -#line 2380 "VBNET.ATG" +#line 2150 "VBNET.ATG" out stmt); -#line 2380 "VBNET.ATG" +#line 2150 "VBNET.ATG" compilationUnit.AddChild(stmt); } else SynErr(251); -#line 2383 "VBNET.ATG" +#line 2153 "VBNET.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.Location; @@ -4998,30 +4770,30 @@ out stmt); } void LabelName( -#line 2754 "VBNET.ATG" +#line 2524 "VBNET.ATG" out string name) { -#line 2756 "VBNET.ATG" +#line 2526 "VBNET.ATG" name = String.Empty; if (StartOf(12)) { Identifier(); -#line 2758 "VBNET.ATG" +#line 2528 "VBNET.ATG" name = t.val; } else if (la.kind == 5) { lexer.NextToken(); -#line 2759 "VBNET.ATG" +#line 2529 "VBNET.ATG" name = t.val; } else SynErr(252); } void EmbeddedStatement( -#line 2422 "VBNET.ATG" +#line 2192 "VBNET.ATG" out Statement statement) { -#line 2424 "VBNET.ATG" +#line 2194 "VBNET.ATG" Statement embeddedStatement = null; statement = null; Expression expr = null; @@ -5032,103 +4804,103 @@ out Statement statement) { case 94: { lexer.NextToken(); -#line 2430 "VBNET.ATG" +#line 2200 "VBNET.ATG" ExitType exitType = ExitType.None; switch (la.kind) { case 167: { lexer.NextToken(); -#line 2432 "VBNET.ATG" +#line 2202 "VBNET.ATG" exitType = ExitType.Sub; break; } case 100: { lexer.NextToken(); -#line 2434 "VBNET.ATG" +#line 2204 "VBNET.ATG" exitType = ExitType.Function; break; } case 146: { lexer.NextToken(); -#line 2436 "VBNET.ATG" +#line 2206 "VBNET.ATG" exitType = ExitType.Property; break; } case 83: { lexer.NextToken(); -#line 2438 "VBNET.ATG" +#line 2208 "VBNET.ATG" exitType = ExitType.Do; break; } case 98: { lexer.NextToken(); -#line 2440 "VBNET.ATG" +#line 2210 "VBNET.ATG" exitType = ExitType.For; break; } case 174: { lexer.NextToken(); -#line 2442 "VBNET.ATG" +#line 2212 "VBNET.ATG" exitType = ExitType.Try; break; } case 181: { lexer.NextToken(); -#line 2444 "VBNET.ATG" +#line 2214 "VBNET.ATG" exitType = ExitType.While; break; } case 155: { lexer.NextToken(); -#line 2446 "VBNET.ATG" +#line 2216 "VBNET.ATG" exitType = ExitType.Select; break; } default: SynErr(253); break; } -#line 2448 "VBNET.ATG" +#line 2218 "VBNET.ATG" statement = new ExitStatement(exitType); break; } case 174: { TryStatement( -#line 2449 "VBNET.ATG" +#line 2219 "VBNET.ATG" out statement); break; } case 186: { lexer.NextToken(); -#line 2450 "VBNET.ATG" +#line 2220 "VBNET.ATG" ContinueType continueType = ContinueType.None; if (la.kind == 83 || la.kind == 98 || la.kind == 181) { if (la.kind == 83) { lexer.NextToken(); -#line 2450 "VBNET.ATG" +#line 2220 "VBNET.ATG" continueType = ContinueType.Do; } else if (la.kind == 98) { lexer.NextToken(); -#line 2450 "VBNET.ATG" +#line 2220 "VBNET.ATG" continueType = ContinueType.For; } else { lexer.NextToken(); -#line 2450 "VBNET.ATG" +#line 2220 "VBNET.ATG" continueType = ContinueType.While; } } -#line 2450 "VBNET.ATG" +#line 2220 "VBNET.ATG" statement = new ContinueStatement(continueType); break; } @@ -5136,11 +4908,11 @@ out statement); lexer.NextToken(); if (StartOf(20)) { Expr( -#line 2452 "VBNET.ATG" +#line 2222 "VBNET.ATG" out expr); } -#line 2452 "VBNET.ATG" +#line 2222 "VBNET.ATG" statement = new ThrowStatement(expr); break; } @@ -5148,27 +4920,27 @@ out expr); lexer.NextToken(); if (StartOf(20)) { Expr( -#line 2454 "VBNET.ATG" +#line 2224 "VBNET.ATG" out expr); } -#line 2454 "VBNET.ATG" +#line 2224 "VBNET.ATG" statement = new ReturnStatement(expr); break; } case 168: { lexer.NextToken(); Expr( -#line 2456 "VBNET.ATG" +#line 2226 "VBNET.ATG" out expr); EndOfStmt(); Block( -#line 2456 "VBNET.ATG" +#line 2226 "VBNET.ATG" out embeddedStatement); Expect(88); Expect(168); -#line 2457 "VBNET.ATG" +#line 2227 "VBNET.ATG" statement = new LockStatement(expr, embeddedStatement); break; } @@ -5176,42 +4948,42 @@ out embeddedStatement); lexer.NextToken(); Identifier(); -#line 2459 "VBNET.ATG" +#line 2229 "VBNET.ATG" name = t.val; if (la.kind == 24) { lexer.NextToken(); if (StartOf(24)) { ArgumentList( -#line 2460 "VBNET.ATG" +#line 2230 "VBNET.ATG" out p); } Expect(25); } -#line 2461 "VBNET.ATG" +#line 2231 "VBNET.ATG" statement = new RaiseEventStatement(name, p); break; } case 182: { WithStatement( -#line 2463 "VBNET.ATG" +#line 2233 "VBNET.ATG" out statement); break; } case 42: { lexer.NextToken(); -#line 2465 "VBNET.ATG" +#line 2235 "VBNET.ATG" Expression handlerExpr = null; Expr( -#line 2466 "VBNET.ATG" +#line 2236 "VBNET.ATG" out expr); Expect(12); Expr( -#line 2466 "VBNET.ATG" +#line 2236 "VBNET.ATG" out handlerExpr); -#line 2468 "VBNET.ATG" +#line 2238 "VBNET.ATG" statement = new AddHandlerStatement(expr, handlerExpr); break; @@ -5219,17 +4991,17 @@ out handlerExpr); case 152: { lexer.NextToken(); -#line 2471 "VBNET.ATG" +#line 2241 "VBNET.ATG" Expression handlerExpr = null; Expr( -#line 2472 "VBNET.ATG" +#line 2242 "VBNET.ATG" out expr); Expect(12); Expr( -#line 2472 "VBNET.ATG" +#line 2242 "VBNET.ATG" out handlerExpr); -#line 2474 "VBNET.ATG" +#line 2244 "VBNET.ATG" statement = new RemoveHandlerStatement(expr, handlerExpr); break; @@ -5237,16 +5009,16 @@ out handlerExpr); case 181: { lexer.NextToken(); Expr( -#line 2477 "VBNET.ATG" +#line 2247 "VBNET.ATG" out expr); EndOfStmt(); Block( -#line 2478 "VBNET.ATG" +#line 2248 "VBNET.ATG" out embeddedStatement); Expect(88); Expect(181); -#line 2480 "VBNET.ATG" +#line 2250 "VBNET.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); break; @@ -5254,23 +5026,23 @@ out embeddedStatement); case 83: { lexer.NextToken(); -#line 2485 "VBNET.ATG" +#line 2255 "VBNET.ATG" ConditionType conditionType = ConditionType.None; if (la.kind == 177 || la.kind == 181) { WhileOrUntil( -#line 2488 "VBNET.ATG" +#line 2258 "VBNET.ATG" out conditionType); Expr( -#line 2488 "VBNET.ATG" +#line 2258 "VBNET.ATG" out expr); EndOfStmt(); Block( -#line 2489 "VBNET.ATG" +#line 2259 "VBNET.ATG" out embeddedStatement); Expect(118); -#line 2492 "VBNET.ATG" +#line 2262 "VBNET.ATG" statement = new DoLoopStatement(expr, embeddedStatement, conditionType == ConditionType.While ? ConditionType.DoWhile : conditionType, @@ -5279,19 +5051,19 @@ out embeddedStatement); } else if (la.kind == 1 || la.kind == 13) { EndOfStmt(); Block( -#line 2499 "VBNET.ATG" +#line 2269 "VBNET.ATG" out embeddedStatement); Expect(118); if (la.kind == 177 || la.kind == 181) { WhileOrUntil( -#line 2500 "VBNET.ATG" +#line 2270 "VBNET.ATG" out conditionType); Expr( -#line 2500 "VBNET.ATG" +#line 2270 "VBNET.ATG" out expr); } -#line 2502 "VBNET.ATG" +#line 2272 "VBNET.ATG" statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End); } else SynErr(254); @@ -5300,7 +5072,7 @@ out expr); case 98: { lexer.NextToken(); -#line 2507 "VBNET.ATG" +#line 2277 "VBNET.ATG" Expression group = null; TypeReference typeReference; string typeName; @@ -5309,24 +5081,24 @@ out expr); if (la.kind == 85) { lexer.NextToken(); LoopControlVariable( -#line 2514 "VBNET.ATG" +#line 2284 "VBNET.ATG" out typeReference, out typeName); Expect(109); Expr( -#line 2515 "VBNET.ATG" +#line 2285 "VBNET.ATG" out group); EndOfStmt(); Block( -#line 2516 "VBNET.ATG" +#line 2286 "VBNET.ATG" out embeddedStatement); Expect(128); if (StartOf(20)) { Expr( -#line 2517 "VBNET.ATG" +#line 2287 "VBNET.ATG" out expr); } -#line 2519 "VBNET.ATG" +#line 2289 "VBNET.ATG" statement = new ForeachStatement(typeReference, typeName, group, @@ -5338,53 +5110,53 @@ out expr); } else if (StartOf(12)) { -#line 2530 "VBNET.ATG" +#line 2300 "VBNET.ATG" Expression start = null; Expression end = null; Expression step = null; Expression nextExpr = null;List nextExpressions = null; LoopControlVariable( -#line 2535 "VBNET.ATG" +#line 2305 "VBNET.ATG" out typeReference, out typeName); Expect(11); Expr( -#line 2536 "VBNET.ATG" +#line 2306 "VBNET.ATG" out start); Expect(172); Expr( -#line 2536 "VBNET.ATG" +#line 2306 "VBNET.ATG" out end); if (la.kind == 162) { lexer.NextToken(); Expr( -#line 2536 "VBNET.ATG" +#line 2306 "VBNET.ATG" out step); } EndOfStmt(); Block( -#line 2537 "VBNET.ATG" +#line 2307 "VBNET.ATG" out embeddedStatement); Expect(128); if (StartOf(20)) { Expr( -#line 2540 "VBNET.ATG" +#line 2310 "VBNET.ATG" out nextExpr); -#line 2540 "VBNET.ATG" +#line 2310 "VBNET.ATG" nextExpressions = new List(); nextExpressions.Add(nextExpr); while (la.kind == 12) { lexer.NextToken(); Expr( -#line 2541 "VBNET.ATG" +#line 2311 "VBNET.ATG" out nextExpr); -#line 2541 "VBNET.ATG" +#line 2311 "VBNET.ATG" nextExpressions.Add(nextExpr); } } -#line 2544 "VBNET.ATG" +#line 2314 "VBNET.ATG" statement = new ForNextStatement(typeReference, typeName, start, end, step, embeddedStatement, nextExpressions); } else SynErr(255); @@ -5393,29 +5165,29 @@ out nextExpr); case 92: { lexer.NextToken(); Expr( -#line 2548 "VBNET.ATG" +#line 2318 "VBNET.ATG" out expr); -#line 2548 "VBNET.ATG" +#line 2318 "VBNET.ATG" statement = new ErrorStatement(expr); break; } case 151: { lexer.NextToken(); -#line 2550 "VBNET.ATG" +#line 2320 "VBNET.ATG" bool isPreserve = false; if (la.kind == 144) { lexer.NextToken(); -#line 2550 "VBNET.ATG" +#line 2320 "VBNET.ATG" isPreserve = true; } Expr( -#line 2551 "VBNET.ATG" +#line 2321 "VBNET.ATG" out expr); -#line 2553 "VBNET.ATG" +#line 2323 "VBNET.ATG" ReDimStatement reDimStatement = new ReDimStatement(isPreserve); statement = reDimStatement; InvocationExpression redimClause = expr as InvocationExpression; @@ -5424,13 +5196,13 @@ out expr); while (la.kind == 12) { lexer.NextToken(); Expr( -#line 2558 "VBNET.ATG" +#line 2328 "VBNET.ATG" out expr); -#line 2559 "VBNET.ATG" +#line 2329 "VBNET.ATG" redimClause = expr as InvocationExpression; -#line 2560 "VBNET.ATG" +#line 2330 "VBNET.ATG" if (redimClause != null) { reDimStatement.ReDimClauses.Add(redimClause); } } break; @@ -5438,10 +5210,10 @@ out expr); case 91: { lexer.NextToken(); Expr( -#line 2564 "VBNET.ATG" +#line 2334 "VBNET.ATG" out expr); -#line 2565 "VBNET.ATG" +#line 2335 "VBNET.ATG" List arrays = new List(); if (expr != null) { arrays.Add(expr);} EraseStatement eraseStatement = new EraseStatement(arrays); @@ -5450,53 +5222,53 @@ out expr); while (la.kind == 12) { lexer.NextToken(); Expr( -#line 2570 "VBNET.ATG" +#line 2340 "VBNET.ATG" out expr); -#line 2570 "VBNET.ATG" +#line 2340 "VBNET.ATG" if (expr != null) { arrays.Add(expr); } } -#line 2571 "VBNET.ATG" +#line 2341 "VBNET.ATG" statement = eraseStatement; break; } case 163: { lexer.NextToken(); -#line 2573 "VBNET.ATG" +#line 2343 "VBNET.ATG" statement = new StopStatement(); break; } case 106: { lexer.NextToken(); Expr( -#line 2575 "VBNET.ATG" +#line 2345 "VBNET.ATG" out expr); if (la.kind == 170) { lexer.NextToken(); } if ( -#line 2577 "VBNET.ATG" +#line 2347 "VBNET.ATG" IsEndStmtAhead()) { Expect(88); -#line 2577 "VBNET.ATG" +#line 2347 "VBNET.ATG" statement = new IfElseStatement(expr, new EndStatement()); } else if (la.kind == 1 || la.kind == 13) { EndOfStmt(); Block( -#line 2580 "VBNET.ATG" +#line 2350 "VBNET.ATG" out embeddedStatement); -#line 2582 "VBNET.ATG" +#line 2352 "VBNET.ATG" IfElseStatement ifStatement = new IfElseStatement(expr, embeddedStatement); while (la.kind == 87 || -#line 2586 "VBNET.ATG" +#line 2356 "VBNET.ATG" IsElseIf()) { if ( -#line 2586 "VBNET.ATG" +#line 2356 "VBNET.ATG" IsElseIf()) { Expect(86); Expect(106); @@ -5504,20 +5276,20 @@ IsElseIf()) { lexer.NextToken(); } -#line 2589 "VBNET.ATG" +#line 2359 "VBNET.ATG" Expression condition = null; Statement block = null; Expr( -#line 2590 "VBNET.ATG" +#line 2360 "VBNET.ATG" out condition); if (la.kind == 170) { lexer.NextToken(); } EndOfStmt(); Block( -#line 2591 "VBNET.ATG" +#line 2361 "VBNET.ATG" out block); -#line 2593 "VBNET.ATG" +#line 2363 "VBNET.ATG" ifStatement.ElseIfSections.Add(new ElseIfSection(condition, block)); } @@ -5525,59 +5297,59 @@ out block); lexer.NextToken(); EndOfStmt(); Block( -#line 2598 "VBNET.ATG" +#line 2368 "VBNET.ATG" out embeddedStatement); -#line 2600 "VBNET.ATG" +#line 2370 "VBNET.ATG" ifStatement.FalseStatement.Add(embeddedStatement); } Expect(88); Expect(106); -#line 2604 "VBNET.ATG" +#line 2374 "VBNET.ATG" statement = ifStatement; } else if (StartOf(27)) { EmbeddedStatement( -#line 2607 "VBNET.ATG" +#line 2377 "VBNET.ATG" out embeddedStatement); -#line 2609 "VBNET.ATG" +#line 2379 "VBNET.ATG" IfElseStatement ifStatement = new IfElseStatement(expr, embeddedStatement); while (la.kind == 13) { lexer.NextToken(); EmbeddedStatement( -#line 2611 "VBNET.ATG" +#line 2381 "VBNET.ATG" out embeddedStatement); -#line 2611 "VBNET.ATG" +#line 2381 "VBNET.ATG" ifStatement.TrueStatement.Add(embeddedStatement); } if (la.kind == 86) { lexer.NextToken(); if (StartOf(27)) { EmbeddedStatement( -#line 2613 "VBNET.ATG" +#line 2383 "VBNET.ATG" out embeddedStatement); } -#line 2615 "VBNET.ATG" +#line 2385 "VBNET.ATG" ifStatement.FalseStatement.Add(embeddedStatement); while (la.kind == 13) { lexer.NextToken(); EmbeddedStatement( -#line 2618 "VBNET.ATG" +#line 2388 "VBNET.ATG" out embeddedStatement); -#line 2619 "VBNET.ATG" +#line 2389 "VBNET.ATG" ifStatement.FalseStatement.Add(embeddedStatement); } } -#line 2622 "VBNET.ATG" +#line 2392 "VBNET.ATG" statement = ifStatement; } else SynErr(256); break; @@ -5588,43 +5360,43 @@ out embeddedStatement); lexer.NextToken(); } Expr( -#line 2625 "VBNET.ATG" +#line 2395 "VBNET.ATG" out expr); EndOfStmt(); -#line 2626 "VBNET.ATG" +#line 2396 "VBNET.ATG" List selectSections = new List(); Statement block = null; while (la.kind == 57) { -#line 2630 "VBNET.ATG" +#line 2400 "VBNET.ATG" List caseClauses = null; lexer.NextToken(); CaseClauses( -#line 2631 "VBNET.ATG" +#line 2401 "VBNET.ATG" out caseClauses); if ( -#line 2631 "VBNET.ATG" +#line 2401 "VBNET.ATG" IsNotStatementSeparator()) { lexer.NextToken(); } EndOfStmt(); -#line 2633 "VBNET.ATG" +#line 2403 "VBNET.ATG" SwitchSection selectSection = new SwitchSection(caseClauses); Block( -#line 2635 "VBNET.ATG" +#line 2405 "VBNET.ATG" out block); -#line 2637 "VBNET.ATG" +#line 2407 "VBNET.ATG" selectSection.Children = block.Children; selectSections.Add(selectSection); } -#line 2641 "VBNET.ATG" +#line 2411 "VBNET.ATG" statement = new SwitchStatement(expr, selectSections); Expect(88); Expect(155); @@ -5632,43 +5404,43 @@ out block); } case 135: { -#line 2643 "VBNET.ATG" +#line 2413 "VBNET.ATG" OnErrorStatement onErrorStatement = null; OnErrorStatement( -#line 2644 "VBNET.ATG" +#line 2414 "VBNET.ATG" out onErrorStatement); -#line 2644 "VBNET.ATG" +#line 2414 "VBNET.ATG" statement = onErrorStatement; break; } case 104: { -#line 2645 "VBNET.ATG" +#line 2415 "VBNET.ATG" GotoStatement goToStatement = null; GotoStatement( -#line 2646 "VBNET.ATG" +#line 2416 "VBNET.ATG" out goToStatement); -#line 2646 "VBNET.ATG" +#line 2416 "VBNET.ATG" statement = goToStatement; break; } case 153: { -#line 2647 "VBNET.ATG" +#line 2417 "VBNET.ATG" ResumeStatement resumeStatement = null; ResumeStatement( -#line 2648 "VBNET.ATG" +#line 2418 "VBNET.ATG" out resumeStatement); -#line 2648 "VBNET.ATG" +#line 2418 "VBNET.ATG" statement = resumeStatement; break; } case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 24: case 43: case 47: case 49: case 50: case 51: case 52: case 54: case 59: case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 68: case 69: case 70: case 72: case 73: case 74: case 75: case 76: case 77: case 82: case 84: case 96: case 102: case 111: case 117: case 119: case 124: case 125: case 127: case 130: case 133: case 144: case 159: case 160: case 165: case 169: case 173: case 175: case 176: case 177: case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: case 198: case 199: case 204: { -#line 2651 "VBNET.ATG" +#line 2421 "VBNET.ATG" Expression val = null; AssignmentOperatorType op; @@ -5676,25 +5448,25 @@ out resumeStatement); la.kind == Tokens.Not || la.kind == Tokens.Times; SimpleExpr( -#line 2657 "VBNET.ATG" +#line 2427 "VBNET.ATG" out expr); if (StartOf(29)) { AssignmentOperator( -#line 2659 "VBNET.ATG" +#line 2429 "VBNET.ATG" out op); Expr( -#line 2659 "VBNET.ATG" +#line 2429 "VBNET.ATG" out val); -#line 2659 "VBNET.ATG" +#line 2429 "VBNET.ATG" expr = new AssignmentExpression(expr, op, val); } else if (la.kind == 1 || la.kind == 13 || la.kind == 86) { -#line 2660 "VBNET.ATG" +#line 2430 "VBNET.ATG" if (mustBeAssignment) Error("error in assignment."); } else SynErr(257); -#line 2663 "VBNET.ATG" +#line 2433 "VBNET.ATG" // a field reference expression that stands alone is a // invocation expression without parantheses and arguments if(expr is FieldReferenceExpression || expr is IdentifierExpression) { @@ -5707,37 +5479,37 @@ out val); case 56: { lexer.NextToken(); SimpleExpr( -#line 2670 "VBNET.ATG" +#line 2440 "VBNET.ATG" out expr); -#line 2670 "VBNET.ATG" +#line 2440 "VBNET.ATG" statement = new StatementExpression(expr); break; } case 188: { lexer.NextToken(); -#line 2672 "VBNET.ATG" +#line 2442 "VBNET.ATG" LocalVariableDeclaration resourceAquisition = new LocalVariableDeclaration(Modifier.None); -#line 2673 "VBNET.ATG" +#line 2443 "VBNET.ATG" Statement block; VariableDeclarator( -#line 2674 "VBNET.ATG" +#line 2444 "VBNET.ATG" resourceAquisition.Variables); while (la.kind == 12) { lexer.NextToken(); VariableDeclarator( -#line 2676 "VBNET.ATG" +#line 2446 "VBNET.ATG" resourceAquisition.Variables); } Block( -#line 2678 "VBNET.ATG" +#line 2448 "VBNET.ATG" out block); Expect(88); Expect(188); -#line 2680 "VBNET.ATG" +#line 2450 "VBNET.ATG" statement = new UsingStatement(resourceAquisition, block); break; } @@ -5746,10 +5518,10 @@ out block); } void LocalDeclarationStatement( -#line 2391 "VBNET.ATG" +#line 2161 "VBNET.ATG" out Statement statement) { -#line 2393 "VBNET.ATG" +#line 2163 "VBNET.ATG" Modifiers m = new Modifiers(); LocalVariableDeclaration localVariableDeclaration; bool dimfound = false; @@ -5758,22 +5530,22 @@ out Statement statement) { if (la.kind == 71) { lexer.NextToken(); -#line 2399 "VBNET.ATG" +#line 2169 "VBNET.ATG" m.Add(Modifier.Const, t.Location); } else if (la.kind == 161) { lexer.NextToken(); -#line 2400 "VBNET.ATG" +#line 2170 "VBNET.ATG" m.Add(Modifier.Static, t.Location); } else { lexer.NextToken(); -#line 2401 "VBNET.ATG" +#line 2171 "VBNET.ATG" dimfound = true; } } -#line 2404 "VBNET.ATG" +#line 2174 "VBNET.ATG" if(dimfound && (m.Modifier & Modifier.Const) != 0) { Error("Dim is not allowed on constants."); } @@ -5786,137 +5558,135 @@ out Statement statement) { localVariableDeclaration.StartLocation = t.Location; VariableDeclarator( -#line 2415 "VBNET.ATG" +#line 2185 "VBNET.ATG" localVariableDeclaration.Variables); while (la.kind == 12) { lexer.NextToken(); VariableDeclarator( -#line 2416 "VBNET.ATG" +#line 2186 "VBNET.ATG" localVariableDeclaration.Variables); } -#line 2418 "VBNET.ATG" +#line 2188 "VBNET.ATG" statement = localVariableDeclaration; } void TryStatement( -#line 2866 "VBNET.ATG" +#line 2634 "VBNET.ATG" out Statement tryStatement) { -#line 2868 "VBNET.ATG" +#line 2636 "VBNET.ATG" Statement blockStmt = null, finallyStmt = null;List catchClauses = null; Expect(174); EndOfStmt(); Block( -#line 2871 "VBNET.ATG" +#line 2639 "VBNET.ATG" out blockStmt); if (la.kind == 58 || la.kind == 88 || la.kind == 97) { CatchClauses( -#line 2872 "VBNET.ATG" +#line 2640 "VBNET.ATG" out catchClauses); } if (la.kind == 97) { lexer.NextToken(); EndOfStmt(); Block( -#line 2873 "VBNET.ATG" +#line 2641 "VBNET.ATG" out finallyStmt); } Expect(88); Expect(174); -#line 2876 "VBNET.ATG" +#line 2644 "VBNET.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void WithStatement( -#line 2844 "VBNET.ATG" +#line 2614 "VBNET.ATG" out Statement withStatement) { -#line 2846 "VBNET.ATG" +#line 2616 "VBNET.ATG" Statement blockStmt = null; Expression expr = null; Expect(182); -#line 2849 "VBNET.ATG" +#line 2619 "VBNET.ATG" Location start = t.Location; Expr( -#line 2850 "VBNET.ATG" +#line 2620 "VBNET.ATG" out expr); EndOfStmt(); -#line 2852 "VBNET.ATG" +#line 2622 "VBNET.ATG" withStatement = new WithStatement(expr); withStatement.StartLocation = start; - withStatements.Push(withStatement); Block( -#line 2856 "VBNET.ATG" +#line 2625 "VBNET.ATG" out blockStmt); -#line 2858 "VBNET.ATG" +#line 2627 "VBNET.ATG" ((WithStatement)withStatement).Body = (BlockStatement)blockStmt; - withStatements.Pop(); Expect(88); Expect(182); -#line 2862 "VBNET.ATG" +#line 2630 "VBNET.ATG" withStatement.EndLocation = t.Location; } void WhileOrUntil( -#line 2837 "VBNET.ATG" +#line 2607 "VBNET.ATG" out ConditionType conditionType) { -#line 2838 "VBNET.ATG" +#line 2608 "VBNET.ATG" conditionType = ConditionType.None; if (la.kind == 181) { lexer.NextToken(); -#line 2839 "VBNET.ATG" +#line 2609 "VBNET.ATG" conditionType = ConditionType.While; } else if (la.kind == 177) { lexer.NextToken(); -#line 2840 "VBNET.ATG" +#line 2610 "VBNET.ATG" conditionType = ConditionType.Until; } else SynErr(259); } void LoopControlVariable( -#line 2684 "VBNET.ATG" +#line 2454 "VBNET.ATG" out TypeReference type, out string name) { -#line 2685 "VBNET.ATG" +#line 2455 "VBNET.ATG" ArrayList arrayModifiers = null; type = null; Qualident( -#line 2689 "VBNET.ATG" +#line 2459 "VBNET.ATG" out name); if ( -#line 2690 "VBNET.ATG" +#line 2460 "VBNET.ATG" IsDims()) { ArrayTypeModifiers( -#line 2690 "VBNET.ATG" +#line 2460 "VBNET.ATG" out arrayModifiers); } if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 2691 "VBNET.ATG" +#line 2461 "VBNET.ATG" out type); -#line 2691 "VBNET.ATG" +#line 2461 "VBNET.ATG" if (name.IndexOf('.') > 0) { Error("No type def for 'for each' member indexer allowed."); } } -#line 2693 "VBNET.ATG" +#line 2463 "VBNET.ATG" if (type != null) { if(type.RankSpecifier != null && arrayModifiers != null) { Error("array rank only allowed one time"); @@ -5928,48 +5698,48 @@ out type); } void CaseClauses( -#line 2797 "VBNET.ATG" +#line 2567 "VBNET.ATG" out List caseClauses) { -#line 2799 "VBNET.ATG" +#line 2569 "VBNET.ATG" caseClauses = new List(); CaseLabel caseClause = null; CaseClause( -#line 2802 "VBNET.ATG" +#line 2572 "VBNET.ATG" out caseClause); -#line 2802 "VBNET.ATG" +#line 2572 "VBNET.ATG" if (caseClause != null) { caseClauses.Add(caseClause); } while (la.kind == 12) { lexer.NextToken(); CaseClause( -#line 2803 "VBNET.ATG" +#line 2573 "VBNET.ATG" out caseClause); -#line 2803 "VBNET.ATG" +#line 2573 "VBNET.ATG" if (caseClause != null) { caseClauses.Add(caseClause); } } } void OnErrorStatement( -#line 2704 "VBNET.ATG" +#line 2474 "VBNET.ATG" out OnErrorStatement stmt) { -#line 2706 "VBNET.ATG" +#line 2476 "VBNET.ATG" stmt = null; GotoStatement goToStatement = null; Expect(135); Expect(92); if ( -#line 2712 "VBNET.ATG" +#line 2482 "VBNET.ATG" IsNegativeLabelName()) { Expect(104); Expect(15); Expect(5); -#line 2714 "VBNET.ATG" +#line 2484 "VBNET.ATG" long intLabel = Int64.Parse(t.val); if(intLabel != 1) { Error("invalid label in on error statement."); @@ -5978,10 +5748,10 @@ IsNegativeLabelName()) { } else if (la.kind == 104) { GotoStatement( -#line 2720 "VBNET.ATG" +#line 2490 "VBNET.ATG" out goToStatement); -#line 2722 "VBNET.ATG" +#line 2492 "VBNET.ATG" string val = goToStatement.Label; // if value is numeric, make sure that is 0 @@ -5998,63 +5768,63 @@ out goToStatement); lexer.NextToken(); Expect(128); -#line 2736 "VBNET.ATG" +#line 2506 "VBNET.ATG" stmt = new OnErrorStatement(new ResumeStatement(true)); } else SynErr(260); } void GotoStatement( -#line 2742 "VBNET.ATG" +#line 2512 "VBNET.ATG" out ICSharpCode.NRefactory.Parser.AST.GotoStatement goToStatement) { -#line 2744 "VBNET.ATG" +#line 2514 "VBNET.ATG" string label = String.Empty; Expect(104); LabelName( -#line 2747 "VBNET.ATG" +#line 2517 "VBNET.ATG" out label); -#line 2749 "VBNET.ATG" +#line 2519 "VBNET.ATG" goToStatement = new ICSharpCode.NRefactory.Parser.AST.GotoStatement(label); } void ResumeStatement( -#line 2786 "VBNET.ATG" +#line 2556 "VBNET.ATG" out ResumeStatement resumeStatement) { -#line 2788 "VBNET.ATG" +#line 2558 "VBNET.ATG" resumeStatement = null; string label = String.Empty; if ( -#line 2791 "VBNET.ATG" +#line 2561 "VBNET.ATG" IsResumeNext()) { Expect(153); Expect(128); -#line 2792 "VBNET.ATG" +#line 2562 "VBNET.ATG" resumeStatement = new ResumeStatement(true); } else if (la.kind == 153) { lexer.NextToken(); if (StartOf(30)) { LabelName( -#line 2793 "VBNET.ATG" +#line 2563 "VBNET.ATG" out label); } -#line 2793 "VBNET.ATG" +#line 2563 "VBNET.ATG" resumeStatement = new ResumeStatement(label); } else SynErr(261); } void CaseClause( -#line 2807 "VBNET.ATG" +#line 2577 "VBNET.ATG" out CaseLabel caseClause) { -#line 2809 "VBNET.ATG" +#line 2579 "VBNET.ATG" Expression expr = null; Expression sexpr = null; BinaryOperatorType op = BinaryOperatorType.None; @@ -6063,7 +5833,7 @@ out CaseLabel caseClause) { if (la.kind == 86) { lexer.NextToken(); -#line 2815 "VBNET.ATG" +#line 2585 "VBNET.ATG" caseClause = new CaseLabel(); } else if (StartOf(31)) { if (la.kind == 113) { @@ -6073,76 +5843,76 @@ out CaseLabel caseClause) { case 27: { lexer.NextToken(); -#line 2819 "VBNET.ATG" +#line 2589 "VBNET.ATG" op = BinaryOperatorType.LessThan; break; } case 26: { lexer.NextToken(); -#line 2820 "VBNET.ATG" +#line 2590 "VBNET.ATG" op = BinaryOperatorType.GreaterThan; break; } case 30: { lexer.NextToken(); -#line 2821 "VBNET.ATG" +#line 2591 "VBNET.ATG" op = BinaryOperatorType.LessThanOrEqual; break; } case 29: { lexer.NextToken(); -#line 2822 "VBNET.ATG" +#line 2592 "VBNET.ATG" op = BinaryOperatorType.GreaterThanOrEqual; break; } case 11: { lexer.NextToken(); -#line 2823 "VBNET.ATG" +#line 2593 "VBNET.ATG" op = BinaryOperatorType.Equality; break; } case 28: { lexer.NextToken(); -#line 2824 "VBNET.ATG" +#line 2594 "VBNET.ATG" op = BinaryOperatorType.InEquality; break; } default: SynErr(262); break; } Expr( -#line 2826 "VBNET.ATG" +#line 2596 "VBNET.ATG" out expr); -#line 2828 "VBNET.ATG" +#line 2598 "VBNET.ATG" caseClause = new CaseLabel(op, expr); } else if (StartOf(20)) { Expr( -#line 2830 "VBNET.ATG" +#line 2600 "VBNET.ATG" out expr); if (la.kind == 172) { lexer.NextToken(); Expr( -#line 2830 "VBNET.ATG" +#line 2600 "VBNET.ATG" out sexpr); } -#line 2832 "VBNET.ATG" +#line 2602 "VBNET.ATG" caseClause = new CaseLabel(expr, sexpr); } else SynErr(263); } void CatchClauses( -#line 2881 "VBNET.ATG" +#line 2649 "VBNET.ATG" out List catchClauses) { -#line 2883 "VBNET.ATG" +#line 2651 "VBNET.ATG" catchClauses = new List(); TypeReference type = null; Statement blockStmt = null; @@ -6154,35 +5924,32 @@ out List catchClauses) { if (StartOf(12)) { Identifier(); -#line 2891 "VBNET.ATG" +#line 2659 "VBNET.ATG" name = t.val; if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 2891 "VBNET.ATG" +#line 2659 "VBNET.ATG" out type); } } if (la.kind == 180) { lexer.NextToken(); Expr( -#line 2892 "VBNET.ATG" +#line 2660 "VBNET.ATG" out expr); } EndOfStmt(); Block( -#line 2894 "VBNET.ATG" +#line 2662 "VBNET.ATG" out blockStmt); -#line 2895 "VBNET.ATG" +#line 2663 "VBNET.ATG" catchClauses.Add(new CatchClause(type, name, blockStmt, expr)); } } - public Parser(ILexer lexer) : base(lexer) - { - } public override void Parse() { @@ -6190,39 +5957,6 @@ out blockStmt); } - protected void ExpectWeak(int n, int follow) - { - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - } else { - SynErr(n); - while (!StartOf(follow)) { - lexer.NextToken(); - } - } - } - - protected bool WeakSeparator(int n, int syFol, int repFol) - { - bool[] s = new bool[maxT + 1]; - - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - return true; - } else if (StartOf(repFol)) { - return false; - } else { - for (int i = 0; i <= maxT; i++) { - s[i] = set[syFol, i] || set[repFol, i] || set[0, i]; - } - SynErr(n); - while (!s[lexer.LookAhead.kind]) { - lexer.NextToken(); - } - return StartOf(syFol); - } - } - protected override void SynErr(int line, int col, int errorNumber) { errors.count++; @@ -6498,7 +6232,7 @@ out blockStmt); errors.Error(line, col, s); } - protected bool StartOf(int s) + private bool StartOf(int s) { return set[s, lexer.LookAhead.kind]; } @@ -6540,4 +6274,4 @@ out blockStmt); }; } // end Parser -} +} \ No newline at end of file diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG index 9a88f7d33c..cca33df2a2 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG @@ -8,252 +8,6 @@ using ASTAttribute = ICSharpCode.NRefactory.Parser.AST.Attribute; COMPILER VBNET -private Stack withStatements; -private StringBuilder qualidentBuilder = new StringBuilder(); - -Token t -{ - [System.Diagnostics.DebuggerStepThrough] - get { - return lexer.Token; - } -} -Token la -{ - [System.Diagnostics.DebuggerStepThrough] - get { - return lexer.LookAhead; - } -} - -/* Return the n-th token after the current lookahead token */ -void StartPeek() -{ - lexer.StartPeek(); -} - -Token Peek() -{ - return lexer.Peek(); -} - -Token Peek (int n) -{ - lexer.StartPeek(); - Token x = la; - while (n > 0) { - x = lexer.Peek(); - n--; - } - return x; -} - -public void Error(string s) -{ - if (errDist >= minErrDist) { - errors.Error(la.line, la.col, s); - } - errDist = 0; -} - -public override Expression ParseExpression() -{ - lexer.NextToken(); - Expression expr; - Expr(out expr); - return expr; -} - -bool LeaveBlock() -{ - int peek = Peek(1).kind; - return Tokens.BlockSucc[la.kind] && (la.kind != Tokens.End || peek == Tokens.EOL || peek == Tokens.Colon); -} - -/* True, if "." is followed by an ident */ -bool DotAndIdentOrKw () { - int peek = Peek(1).kind; - return la.kind == Tokens.Dot && (peek == Tokens.Identifier || peek >= Tokens.AddHandler); -} - -bool IsEndStmtAhead() -{ - int peek = Peek(1).kind; - return la.kind == Tokens.End && (peek == Tokens.EOL || peek == Tokens.Colon); -} - -bool IsNotClosingParenthesis() { - return la.kind != Tokens.CloseParenthesis; -} - -/* - True, if ident is followed by "=" -*/ -bool IdentAndAsgn () { - if(la.kind == Tokens.Identifier) { - if(Peek(1).kind == Tokens.Assign) return true; - if(Peek(1).kind == Tokens.Colon && Peek(2).kind == Tokens.Assign) return true; - } - return false; -} - -/* - True, if ident is followed by "=" or by ":" and "=" -*/ -bool IsNamedAssign() { -// if(Peek(1).kind == Tokens.Assign) return true; // removed: not in the lang spec - if(Peek(1).kind == Tokens.Colon && Peek(2).kind == Tokens.Assign) return true; - return false; -} - -bool IsObjectCreation() { - return la.kind == Tokens.As && Peek(1).kind == Tokens.New; -} - -/* - True, if "<" is followed by the ident "assembly" or "module" -*/ -bool IsGlobalAttrTarget () { - Token pt = Peek(1); - return la.kind == Tokens.LessThan && ( string.Equals(pt.val, "assembly", StringComparison.InvariantCultureIgnoreCase) || string.Equals(pt.val, "module", StringComparison.InvariantCultureIgnoreCase)); -} - -/* - True if the next token is a "(" and is followed by "," or ")" -*/ -bool IsDims() -{ - int peek = Peek(1).kind; - return la.kind == Tokens.OpenParenthesis - && (peek == Tokens.Comma || peek == Tokens.CloseParenthesis); -} - -bool IsSize() -{ - return la.kind == Tokens.OpenParenthesis; -} - -/* - True, if the comma is not a trailing one, - like the last one in: a, b, c, -*/ -bool NotFinalComma() { - int peek = Peek(1).kind; - return la.kind == Tokens.Comma && - peek != Tokens.CloseCurlyBrace; -} - -/* - True, if the next token is "Else" and this one - if followed by "If" -*/ -bool IsElseIf() -{ - int peek = Peek(1).kind; - return la.kind == Tokens.Else && peek == Tokens.If; -} - -/* - True if the next token is goto and this one is - followed by minus ("-") (this is allowd in in - error clauses) -*/ -bool IsNegativeLabelName() -{ - int peek = Peek(1).kind; - return la.kind == Tokens.GoTo && peek == Tokens.Minus; -} - -/* - True if the next statement is a "Resume next" statement -*/ -bool IsResumeNext() -{ - int peek = Peek(1).kind; - return la.kind == Tokens.Resume && peek == Tokens.Next; -} - -/* - True, if ident/literal integer is followed by ":" -*/ -bool IsLabel() -{ - return (la.kind == Tokens.Identifier || la.kind == Tokens.LiteralInteger) - && Peek(1).kind == Tokens.Colon; -} - -bool IsNotStatementSeparator() -{ - return la.kind == Tokens.Colon && Peek(1).kind == Tokens.EOL; -} - -bool IsAssignment () -{ - return IdentAndAsgn(); -} - -bool IsMustOverride(Modifiers m) -{ - return m.Contains(Modifier.Abstract); -} - -TypeReferenceExpression GetTypeReferenceExpression(Expression expr, List genericTypes) -{ - TypeReferenceExpression tre = expr as TypeReferenceExpression; - if (tre != null) { - return new TypeReferenceExpression(new TypeReference(tre.TypeReference.Type, tre.TypeReference.PointerNestingLevel, tre.TypeReference.RankSpecifier, genericTypes)); - } - StringBuilder b = new StringBuilder(); - if (!WriteFullTypeName(b, expr)) { - // there is some TypeReferenceExpression hidden in the expression - while (expr is FieldReferenceExpression) { - expr = ((FieldReferenceExpression)expr).TargetObject; - } - tre = expr as TypeReferenceExpression; - if (tre != null) { - TypeReference typeRef = tre.TypeReference; - if (typeRef.GenericTypes.Count == 0) { - typeRef = typeRef.Clone(); - typeRef.Type += "." + b.ToString(); - typeRef.GenericTypes.AddRange(genericTypes); - } else { - typeRef = new InnerClassTypeReference(typeRef, b.ToString(), genericTypes); - } - return new TypeReferenceExpression(typeRef); - } - } - return new TypeReferenceExpression(new TypeReference(b.ToString(), 0, null, genericTypes)); -} - -/* Writes the type name represented through the expression into the string builder. */ -/* Returns true when the expression was converted successfully, returns false when */ -/* There was an unknown expression (e.g. TypeReferenceExpression) in it */ -bool WriteFullTypeName(StringBuilder b, Expression expr) -{ - FieldReferenceExpression fre = expr as FieldReferenceExpression; - if (fre != null) { - bool result = WriteFullTypeName(b, fre.TargetObject); - if (b.Length > 0) b.Append('.'); - b.Append(fre.FieldName); - return result; - } else if (expr is IdentifierExpression) { - b.Append(((IdentifierExpression)expr).Identifier); - return true; - } else { - return false; - } -} - -/* - True, if lookahead is a local attribute target specifier, - i.e. one of "event", "return", "field", "method", - "module", "param", "property", or "type" -*/ -bool IsLocalAttrTarget() { - // TODO - return false; -} - /* START AUTOGENERATED TOKENS SECTION */ TOKENS /* ----- terminal classes ----- */ @@ -475,7 +229,6 @@ VBNET (. lexer.NextToken(); // get the first token compilationUnit = new CompilationUnit(); - withStatements = new Stack(); .) = { EOL } { OptionStmt } @@ -486,7 +239,7 @@ VBNET . OptionStmt (. INode node = null; bool val = true; .) = - "Option" (. Point startPos = t.Location; .) + "Option" (. Location startPos = t.Location; .) ( "Explicit" [ OptionValue ] (. node = new OptionDeclaration(OptionType.Explicit, val); .) @@ -527,7 +280,7 @@ ImportsStmt .) = "Imports" (. - Point startPos = t.Location; + Location startPos = t.Location; Using u; .) ImportClause (. if (u != null) { usings.Add(u); } .) @@ -572,7 +325,7 @@ NamespaceMemberDecl .) = "Namespace" (. - Point startPos = t.Location; + Location startPos = t.Location; .) Qualident (. @@ -959,7 +712,7 @@ StructureMemberDecl attributes> | /* 9.2.1 */ "Sub" (. - Point startPos = t.Location; + Location startPos = t.Location; .) ( (. @@ -981,7 +734,7 @@ StructureMemberDecl attributes> HandlesClause ) ] - (. Point endLocation = t.EndLocation; .) + (. Location endLocation = t.EndLocation; .) EOL ( /* abstract methods without a body */ @@ -1010,22 +763,38 @@ StructureMemberDecl attributes> methodDeclaration.InterfaceImplementations = implementsClause; compilationUnit.AddChild(methodDeclaration); - compilationUnit.BlockStart(methodDeclaration); .) - Block - (. - compilationUnit.BlockEnd(); - methodDeclaration.Body = (BlockStatement)stmt; + + (. if (parseMethodContents) { .) + Block + "End" "Sub" + (. } else { + // don't parse method body + lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); + if (t.kind != Tokens.Sub) throw new ApplicationException("Failed to skip sub"); + } .) - "End" "Sub" (. methodDeclaration.Body.EndLocation = t.EndLocation; .) EOL + + (. methodDeclaration.Body = (BlockStatement)stmt; .) + (. methodDeclaration.Body.EndLocation = t.EndLocation; .) EOL ) /* 9.3 */ | "New" [ "(" [ FormalParameterList

] ")" ] (. m.Check(Modifier.Constructors); .) - (. Point constructorEndLocation = t.EndLocation; .) + (. Location constructorEndLocation = t.EndLocation; .) EOL - Block - "End" "Sub" (. Point endLocation = t.EndLocation; .) EOL + + (. if (parseMethodContents) { .) + Block + "End" "Sub" + (. } else { + // don't parse method body + lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); + if (t.kind != Tokens.Sub) throw new ApplicationException("Failed to skip sub"); + } + .) + + (. Location endLocation = t.EndLocation; .) EOL (. ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); cd.StartLocation = m.GetDeclarationLocation(startPos); @@ -1041,7 +810,7 @@ StructureMemberDecl attributes> (. m.Check(Modifier.VBMethods); string name = String.Empty; - Point startPos = t.Location; + Location startPos = t.Location; MethodDeclaration methodDeclaration;List handlesClause = null; List implementsClause = null; AttributeSection returnTypeAttributeSection = null; @@ -1095,15 +864,16 @@ StructureMemberDecl attributes> } compilationUnit.AddChild(methodDeclaration); - compilationUnit.BlockStart(methodDeclaration); - .) - Block - (. - compilationUnit.BlockEnd(); - methodDeclaration.Body = (BlockStatement)stmt; - .) - "End" "Function" - (. + + if (parseMethodContents) { .) + Block + "End" "Function" + (. } else { + // don't parse method body + lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement(); + if (t.kind != Tokens.Function) throw new ApplicationException("Failed to skip function"); + } + methodDeclaration.Body = (BlockStatement)stmt; methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation; methodDeclaration.Body.EndLocation = t.EndLocation; .) @@ -1114,7 +884,7 @@ StructureMemberDecl attributes> "Declare" (. m.Check(Modifier.VBExternalMethods); - Point startPos = t.Location; + Location startPos = t.Location; CharsetModifier charsetModifer = CharsetModifier.None; string library = String.Empty; string alias = null; @@ -1154,7 +924,7 @@ StructureMemberDecl attributes> "Event" (. m.Check(Modifier.VBEvents); - Point startPos = t.Location; + Location startPos = t.Location; EventDeclaration eventDeclaration; string name = String.Empty; List implementsClause = null; @@ -1174,7 +944,7 @@ StructureMemberDecl attributes> .) EOL | /* 9.6 */ - (. Point startPos = t.Location; .) + (. Location startPos = t.Location; .) (. m.Check(Modifier.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); @@ -1212,7 +982,7 @@ StructureMemberDecl attributes> "Property" (. m.Check(Modifier.VBProperties); - Point startPos = t.Location; + Location startPos = t.Location; List implementsClause = null; .) Identifier (. string propertyName = t.val; .) @@ -1260,7 +1030,7 @@ StructureMemberDecl attributes> .) ) | - "Custom" (. Point startPos = t.Location; .) "Event" + "Custom" (. Location startPos = t.Location; .) "Event" (. m.Check(Modifier.VBCustomEvents); EventAddRemoveRegion eventAccessorDeclaration; @@ -1321,7 +1091,7 @@ StructureMemberDecl attributes> "Operator" (. m.Check(Modifier.VBOperators); - Point startPos = t.Location; + Location startPos = t.Location; TypeReference returnType = NullTypeReference.Instance; TypeReference operandType = NullTypeReference.Instance; string operandName; @@ -1342,7 +1112,7 @@ StructureMemberDecl attributes> (. parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParamModifier.In)); .) } ")" - (. Point endPos = t.EndLocation; .) + (. Location endPos = t.EndLocation; .) [ "As" { AttributeSection (. returnTypeAttributes.Add(section); .) } TypeName (. endPos = t.EndLocation; .) EOL ] Block "End" "Operator" EOL (. @@ -1487,7 +1257,7 @@ AccessorDecls GetAccessorDecl attributes> (. Statement stmt = null; .) = "Get" - (. Point startLocation = t.Location; .) + (. Location startLocation = t.Location; .) EOL Block (. getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); .) @@ -1502,7 +1272,7 @@ SetAccessorDecl attribute Statement stmt = null; List p = new List(); .) = "Set" - (. Point startLocation = t.Location; .) + (. Location startLocation = t.Location; .) [ "(" [ FormalParameterList

] ")" ] EOL Block @@ -1820,7 +1590,7 @@ InvocationExpression List parameters = null; TypeReference type; .) = - "(" (. Point start = t.Location; .) + "(" (. Location start = t.Location; .) ( "Of" TypeName (. if (type != null) typeParameters.Add(type); .) { @@ -2185,7 +1955,7 @@ TypeArgumentList typeArguments> . GlobalAttributeSection = - (. Point startPos = t.Location; .) + (. Location startPos = t.Location; .) "<" ("Assembly" | "Module") (. string attributeTarget = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture); List attributes = new List(); @@ -2260,7 +2030,7 @@ AttributeSection ASTAttribute attribute; .) = - "<" (. Point startPos = t.Location; .) + "<" (. Location startPos = t.Location; .) [ IF (IsLocalAttrTarget()) ( "Event" (. attributeTarget = "event";.) | "Return" (. attributeTarget = "return";.) @@ -2366,7 +2136,7 @@ Block Statement (. Statement stmt = null; - Point startPos = la.Location; + Location startPos = la.Location; string label = String.Empty; .) = @@ -2507,7 +2277,7 @@ EmbeddedStatement Expression group = null; TypeReference typeReference; string typeName; - Point startLocation = t.Location; + Location startLocation = t.Location; .) ( /* 10.9.3 */ @@ -2846,17 +2616,15 @@ WithStatement Statement blockStmt = null; Expression expr = null; .) = - "With" (. Point start = t.Location; .) + "With" (. Location start = t.Location; .) Expr EndOfStmt (. withStatement = new WithStatement(expr); withStatement.StartLocation = start; - withStatements.Push(withStatement); .) Block (. ((WithStatement)withStatement).Body = (BlockStatement)blockStmt; - withStatements.Pop(); .) "End" "With" (. withStatement.EndLocation = t.Location; .) diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs new file mode 100644 index 0000000000..ccfe0057ec --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs @@ -0,0 +1,269 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 16.07.2006 + * Time: 15:55 + */ + +using System; +using System.Text; +using System.Collections.Generic; +using ICSharpCode.NRefactory.Parser.AST; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + internal sealed partial class Parser : AbstractParser + { + Lexer lexer; + + public Parser(ILexer lexer) : base(lexer) + { + this.lexer = (Lexer)lexer; + } + + private StringBuilder qualidentBuilder = new StringBuilder(); + + Token t + { + [System.Diagnostics.DebuggerStepThrough] + get { + return lexer.Token; + } + } + Token la + { + [System.Diagnostics.DebuggerStepThrough] + get { + return lexer.LookAhead; + } + } + + /* Return the n-th token after the current lookahead token */ + void StartPeek() + { + lexer.StartPeek(); + } + + Token Peek() + { + return lexer.Peek(); + } + + Token Peek (int n) + { + lexer.StartPeek(); + Token x = la; + while (n > 0) { + x = lexer.Peek(); + n--; + } + return x; + } + + public void Error(string s) + { + if (errDist >= minErrDist) { + errors.Error(la.line, la.col, s); + } + errDist = 0; + } + + public override Expression ParseExpression() + { + lexer.NextToken(); + Expression expr; + Expr(out expr); + return expr; + } + + bool LeaveBlock() + { + int peek = Peek(1).kind; + return Tokens.BlockSucc[la.kind] && (la.kind != Tokens.End || peek == Tokens.EOL || peek == Tokens.Colon); + } + + /* True, if "." is followed by an ident */ + bool DotAndIdentOrKw () { + int peek = Peek(1).kind; + return la.kind == Tokens.Dot && (peek == Tokens.Identifier || peek >= Tokens.AddHandler); + } + + bool IsEndStmtAhead() + { + int peek = Peek(1).kind; + return la.kind == Tokens.End && (peek == Tokens.EOL || peek == Tokens.Colon); + } + + bool IsNotClosingParenthesis() { + return la.kind != Tokens.CloseParenthesis; + } + + /* + True, if ident is followed by "=" + */ + bool IdentAndAsgn () { + if(la.kind == Tokens.Identifier) { + if(Peek(1).kind == Tokens.Assign) return true; + if(Peek(1).kind == Tokens.Colon && Peek(2).kind == Tokens.Assign) return true; + } + return false; + } + + /* + True, if ident is followed by "=" or by ":" and "=" + */ + bool IsNamedAssign() { +// if(Peek(1).kind == Tokens.Assign) return true; // removed: not in the lang spec + if(Peek(1).kind == Tokens.Colon && Peek(2).kind == Tokens.Assign) return true; + return false; + } + + bool IsObjectCreation() { + return la.kind == Tokens.As && Peek(1).kind == Tokens.New; + } + + /* + True, if "<" is followed by the ident "assembly" or "module" + */ + bool IsGlobalAttrTarget () { + Token pt = Peek(1); + return la.kind == Tokens.LessThan && ( string.Equals(pt.val, "assembly", StringComparison.InvariantCultureIgnoreCase) || string.Equals(pt.val, "module", StringComparison.InvariantCultureIgnoreCase)); + } + + /* + True if the next token is a "(" and is followed by "," or ")" + */ + bool IsDims() + { + int peek = Peek(1).kind; + return la.kind == Tokens.OpenParenthesis + && (peek == Tokens.Comma || peek == Tokens.CloseParenthesis); + } + + bool IsSize() + { + return la.kind == Tokens.OpenParenthesis; + } + + /* + True, if the comma is not a trailing one, + like the last one in: a, b, c, + */ + bool NotFinalComma() { + int peek = Peek(1).kind; + return la.kind == Tokens.Comma && + peek != Tokens.CloseCurlyBrace; + } + + /* + True, if the next token is "Else" and this one + if followed by "If" + */ + bool IsElseIf() + { + int peek = Peek(1).kind; + return la.kind == Tokens.Else && peek == Tokens.If; + } + + /* + True if the next token is goto and this one is + followed by minus ("-") (this is allowd in in + error clauses) + */ + bool IsNegativeLabelName() + { + int peek = Peek(1).kind; + return la.kind == Tokens.GoTo && peek == Tokens.Minus; + } + + /* + True if the next statement is a "Resume next" statement + */ + bool IsResumeNext() + { + int peek = Peek(1).kind; + return la.kind == Tokens.Resume && peek == Tokens.Next; + } + + /* + True, if ident/literal integer is followed by ":" + */ + bool IsLabel() + { + return (la.kind == Tokens.Identifier || la.kind == Tokens.LiteralInteger) + && Peek(1).kind == Tokens.Colon; + } + + bool IsNotStatementSeparator() + { + return la.kind == Tokens.Colon && Peek(1).kind == Tokens.EOL; + } + + bool IsAssignment () + { + return IdentAndAsgn(); + } + + bool IsMustOverride(Modifiers m) + { + return m.Contains(Modifier.Abstract); + } + + TypeReferenceExpression GetTypeReferenceExpression(Expression expr, List genericTypes) + { + TypeReferenceExpression tre = expr as TypeReferenceExpression; + if (tre != null) { + return new TypeReferenceExpression(new TypeReference(tre.TypeReference.Type, tre.TypeReference.PointerNestingLevel, tre.TypeReference.RankSpecifier, genericTypes)); + } + StringBuilder b = new StringBuilder(); + if (!WriteFullTypeName(b, expr)) { + // there is some TypeReferenceExpression hidden in the expression + while (expr is FieldReferenceExpression) { + expr = ((FieldReferenceExpression)expr).TargetObject; + } + tre = expr as TypeReferenceExpression; + if (tre != null) { + TypeReference typeRef = tre.TypeReference; + if (typeRef.GenericTypes.Count == 0) { + typeRef = typeRef.Clone(); + typeRef.Type += "." + b.ToString(); + typeRef.GenericTypes.AddRange(genericTypes); + } else { + typeRef = new InnerClassTypeReference(typeRef, b.ToString(), genericTypes); + } + return new TypeReferenceExpression(typeRef); + } + } + return new TypeReferenceExpression(new TypeReference(b.ToString(), 0, null, genericTypes)); + } + + /* Writes the type name represented through the expression into the string builder. */ + /* Returns true when the expression was converted successfully, returns false when */ + /* There was an unknown expression (e.g. TypeReferenceExpression) in it */ + bool WriteFullTypeName(StringBuilder b, Expression expr) + { + FieldReferenceExpression fre = expr as FieldReferenceExpression; + if (fre != null) { + bool result = WriteFullTypeName(b, fre.TargetObject); + if (b.Length > 0) b.Append('.'); + b.Append(fre.FieldName); + return result; + } else if (expr is IdentifierExpression) { + b.Append(((IdentifierExpression)expr).Identifier); + return true; + } else { + return false; + } + } + + /* + True, if lookahead is a local attribute target specifier, + i.e. one of "event", "return", "field", "method", + "module", "param", "property", or "type" + */ + bool IsLocalAttrTarget() { + // TODO + return false; + } + } +} diff --git a/src/Libraries/NRefactory/Test/Lexer/CSharp/CustomLexerTests.cs b/src/Libraries/NRefactory/Test/Lexer/CSharp/CustomLexerTests.cs index 7447e1db13..386a45dc83 100644 --- a/src/Libraries/NRefactory/Test/Lexer/CSharp/CustomLexerTests.cs +++ b/src/Libraries/NRefactory/Test/Lexer/CSharp/CustomLexerTests.cs @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp ILexer lexer = GenerateLexer(new StringReader("{}+")); Assert.AreEqual(Tokens.OpenCurlyBrace, lexer.NextToken().kind); lexer.NextToken(); - lexer.SkipCurrentBlock(); + lexer.SkipCurrentBlock(Tokens.CloseCurlyBrace); Assert.AreEqual(Tokens.CloseCurlyBrace, lexer.LookAhead.kind); Assert.AreEqual(Tokens.Plus, lexer.NextToken().kind); Assert.AreEqual(Tokens.EOF, lexer.NextToken().kind); @@ -59,7 +59,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp ILexer lexer = GenerateLexer(new StringReader("{ TestMethod('}'); /* }}} */ while(1) {break;} }+")); Assert.AreEqual(Tokens.OpenCurlyBrace, lexer.NextToken().kind); lexer.NextToken(); - lexer.SkipCurrentBlock(); + lexer.SkipCurrentBlock(Tokens.CloseCurlyBrace); Assert.AreEqual(Tokens.CloseCurlyBrace, lexer.LookAhead.kind); Assert.AreEqual(Tokens.Plus, lexer.NextToken().kind); Assert.AreEqual(Tokens.EOF, lexer.NextToken().kind); @@ -76,7 +76,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp lexer.Peek(); lexer.Peek(); lexer.Peek(); - lexer.SkipCurrentBlock(); + lexer.SkipCurrentBlock(Tokens.CloseCurlyBrace); Assert.AreEqual(Tokens.CloseCurlyBrace, lexer.LookAhead.kind); Assert.AreEqual(Tokens.Plus, lexer.NextToken().kind); Assert.AreEqual(Tokens.EOF, lexer.NextToken().kind); @@ -92,7 +92,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp lexer.Peek(); lexer.Peek(); lexer.Peek(); - lexer.SkipCurrentBlock(); + lexer.SkipCurrentBlock(Tokens.CloseCurlyBrace); Assert.AreEqual(Tokens.CloseCurlyBrace, lexer.LookAhead.kind); Assert.AreEqual(Tokens.Plus, lexer.NextToken().kind); Assert.AreEqual(Tokens.EOF, lexer.NextToken().kind); diff --git a/src/Libraries/NRefactory/Test/Output/SpecialOutputVisitor.cs b/src/Libraries/NRefactory/Test/Output/SpecialOutputVisitor.cs index 78ea8d9efc..30d4905c58 100644 --- a/src/Libraries/NRefactory/Test/Output/SpecialOutputVisitor.cs +++ b/src/Libraries/NRefactory/Test/Output/SpecialOutputVisitor.cs @@ -162,5 +162,21 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter End Function End Class"); } + + [Test] + public void BlankLinesVB() + { + TestProgramVB("Imports System\n" + + "\n" + + "Imports System.IO"); + TestProgramVB("Imports System\n" + + "\n" + + "\n" + + "Imports System.IO"); + TestProgramVB("\n" + + "' Some comment\n" + + "\n" + + "Imports System.IO"); + } } }