protected virtual ExpressionNode ParseNumber() { var current = _tokens.Current; if (Name == PascalTerms.Pointer) { Eat(PascalTerms.Pointer); return(new PointerNode(current)); } if (Name == PascalTerms.StringConst) { var s = new StringNode(Current); Eat(PascalTerms.StringConst); return(s); } if (current.Token.Name == PascalTerms.RealConst) { Eat(PascalTerms.RealConst); var value = new RealNode(current); return(value); } if (current.Token.Name == PascalTerms.IntegerConst) { Eat(PascalTerms.IntegerConst); var value = new IntegerNode(current); return(value); } Error("Number"); return(null); }
public Node ListNode() { var list = Current; Eat(PascalTerms.LeftBracket); var from = new StringNode(Current); Eat(PascalTerms.StringConst); if (Name == PascalTerms.Dot) { Eat(PascalTerms.Dot); Eat(PascalTerms.Dot); var to = new StringNode(Current); Eat(PascalTerms.StringConst); Eat(PascalTerms.RightBracket); return(new ListRangeExpressionNode(from, to, list)); } else { var items = new List <StringNode>() { from }; while (Name == PascalTerms.Comma) { Eat(PascalTerms.Comma); items.Add(new StringNode(Current)); Eat(PascalTerms.StringConst); } Eat(PascalTerms.RightBracket); return(new ListItemsExpressionNode(items, list)); } }
public ListRangeExpressionNode(StringNode fromNode, StringNode toNode, TokenItem tokenItem) { FromNode = fromNode; ToNode = toNode; TokenItem = tokenItem; }