public FormalArg Parse(ParserContext context) { // Parse the type. Type type = new TypeParser().Parse(context); // Create the formal argument entity. FormalArg arg = new FormalArg(type); // Capture the argument's name. string name = context.Stream.Get(TokenType.Identifier).Value; // Assign the argument's name. arg.SetName(name); // Skip the identifier token. context.Stream.Skip(); // Return the argument. return(arg); }
public GlobalVar Parse(ParserContext context) { // Invoke type parser. Type type = new TypeParser().Parse(context); // Expect current token to be symbol at. context.Stream.EnsureCurrent(TokenType.SymbolAt); // Skip symbol at token. context.Stream.Skip(); // Invoke identifier parser. string identifier = new IdentifierParser().Parse(context); // Create the global variable. GlobalVar globalVar = new GlobalVar(identifier, type); // Return the global variable. return(globalVar); }
public Type Parse(ParserContext context) { // Ensure current token is parentheses start. context.Stream.EnsureCurrent(TokenType.SymbolParenthesesL); // Skip parentheses start token. context.Stream.Skip(); // Invoke type parser. Type target = new TypeParser().Parse(context); // Ensure current token is parentheses end. context.Stream.EnsureCurrent(TokenType.SymbolParenthesesR); // Skip parentheses end token. context.Stream.Skip(); // Return the resulting target type. return(target); }