public void SetName(SimpleName name) { Name = name; }
public GenericNameExpression(Statement statement, SimpleName left, GenericArguments arguments, SourceData sourceData) : base(statement, left, sourceData) { Arguments = arguments; }
private Statement ParseDeclareStmt() { TokenInfo token; SimpleName name; FullNamedExpression type; Expression expr; tokenQueue.Dequeue(); token = Tokenizer.PeekToken(); name = null; type = null; expr = null; var stmt = new DeclareStatement(block); statement = stmt; if (EatOptional(Token.Identifier)) { name = new SimpleName(statement, token.Value, new SourceData(token.GetSpan(token), SourceFile, statementSymbols)); if (EatOptional(Token.As)) { type = ParseFullName(); } TokenInfo token3 = Tokenizer.PeekToken(); if (EatOptional(Token.Equality)) { EatOptional(Token.EOL); expr = ParseExpression(); if (expr == null) { Report.AddItem(VBErrors.ExpressionExpected, SourceFile, token3.GetSpan(token3), statementSymbols); } } TokenInfo token4 = Tokenizer.PeekToken(); if (token4.Is(Token.EOL)) { //GetNextToken(); //* resetStmtTokens(); } else { ExpectEndOfStatementOrEat(); } } else { GetNextToken(); TokenInfo token2 = Tokenizer.PeekToken(); Report.AddItem(VBErrors.IdentifierExpected, SourceFile, new SourceSpan(token.GetSourceLocation(), token2.GetSourceLocation()), statementSymbols); EatToEOL(); } stmt.SetName(name); stmt.SetType(type); stmt.SetInitializationExpression(expr); return stmt; }
private void ParseField() { #region Old //bool b = Expect(Token.LeftSquareBracket); //TokenInfo token = Tokenizer.PeekToken(); //if (token.Is(Token.Identifier) || token.Is(Token.ReservedWord)) //{ //} //if (Expect(Token.As)) //{ // token = Tokenizer.PeekToken(); // if (Expect(Token.Identifier)) // { // } // else // { // } //} //else //{ //} //if (Expect(Token.Equality)) //{ // token = Tokenizer.PeekToken(); // if (Expect(Token.Identifier)) // { // } // else // { // } //} //else //{ //} #endregion TokenInfo token; Modifier modifiers; SimpleName name; FullNamedExpression type; Expression expr; modifiers = ParseMethodModifiers(); token = tokenQueue.Dequeue(); name = null; type = null; expr = null; if (token.Is(Token.Identifier)) { name = new SimpleName(statement, token.Value, new SourceData(token.GetSpan(token), SourceFile, statementSymbols)); if (EatOptional(Token.As)) { type = ParseFullName(); } TokenInfo token3 = Tokenizer.PeekToken(); if (EatOptional(Token.Equality)) { EatOptional(Token.EOL); //Set parse context to initializer MethodDef initializer; if ((modifiers & Modifier.Shared) == Modifier.Shared) { initializer = (MethodDef) this.type.GetTypeInitializer(); } else { initializer = (MethodDef) this.type.GetDefaultConstructor(); } //Initalize context method = initializer; block = method.Body; var assignStmt = new ExpressionStatement(initializer.Body); statement = assignStmt; //Parse initialization expression expr = ParseExpression(); //Build initialization expression statement assignStmt.SetExpression( new BinaryExpression(assignStmt, Operator.Assign, new VariableAccess(assignStmt, new SimpleName(assignStmt, name, null), null), expr, null)); //Add statement initializer.Body.AddStatement(assignStmt); //Reset context to null method = null; block = null; statement = null; if (expr == null) { Report.AddItem(VBErrors.ExpressionExpected, SourceFile, token3.GetSpan(token3), statementSymbols); } } TokenInfo token4 = Tokenizer.PeekToken(); if (token4.Is(Token.EOL)) { //GetNextToken(); //* resetStmtTokens(); } else { ExpectEndOfStatementOrEat(); } } else { GetNextToken(); TokenInfo token2 = Tokenizer.PeekToken(); Report.AddItem(VBErrors.IdentifierExpected, SourceFile, new SourceSpan(token.GetSourceLocation(), token2.GetSourceLocation()), statementSymbols); EatToEOL(); } var fieldDef = new FieldDef(this.type, name, type, modifiers); fieldDef.SetInitalizationExpression(expr); ((ClassStructOrModuleDef) this.type).AddField(fieldDef); }
private FullNamedExpression ParseFullName() { bool b = EatOptional(Token.LeftSquareBracket); TokenInfo token; FullNamedExpression name = null; token = Tokenizer.PeekToken(); while (true) { token = Tokenizer.PeekToken(); switch (token.Token) { case Token.Identifier: name = new SimpleName(statement, name, token.Value, new SourceData(token.GetSpan(token), SourceFile, statementSymbols)); GetNextToken(); //if(token.Is(Token.LeftParenthesis)) //{ // GetNextToken(); // GenericArguments args = ParseFullNameGenericArgs(); // SimpleName n = name as SimpleName; // name = new GenericNameExpression(statement, n, args, new SourceData(token.GetSpan(token), this.SourceFile, statementSymbols)); // goto end; //} goto end2; } if (Helpers.IsReservedWord(token)) { name = new SimpleName(statement, token.Value, b, new SourceData(token.GetSpan(token), SourceFile, statementSymbols)); GetNextToken(); if (b && !EatOptional(Token.RightSquareBracket)) { Report.AddItem(VBErrors.BracketedIdentifierIsMissingClosingRightSquareBracket, SourceFile, token.GetSpan(token), statementSymbols); EatToEOL(); goto end; } } end2: token = tokenizer.PeekToken(); if (token.Is(Token.Period)) { GetNextToken(); } else { goto end; } } end: return name; }