public override void VisitExpressionVariable(ExpressionVariable expressionVariable) { if (!expressionVariable.IsBound) { sb.AppendFormat("new ExpressionVariable(\"{0}\")", expressionVariable.Index); } else { sb.AppendFormat("pattern{0}.GetVariable(\"{1}\")", currentPatternIndex, expressionVariable.Index); } }
public static void CreateVariableNode(AstContext context, ParseTreeNode parseNode) { Variable varNode = null; foreach (ParseTreeNode nt in parseNode.ChildNodes) { // (e | s | t) if (varNode == null) { switch (nt.Term.Name) { case "s": varNode = new SymbolVariable(); break; case "e": varNode = new ExpressionVariable(); break; case "t": varNode = new TermVariable(); break; default: throw new ArgumentOutOfRangeException("Unknown variable type: " + nt.Term.Name); } continue; } if (nt.Term.Name == ".") { continue; } // Number | Identifier if (nt.AstNode is LiteralValueNode) { varNode.Index = (nt.AstNode as LiteralValueNode).Value.ToString(); } else if (nt.AstNode is IdentifierNode) { varNode.Index = (nt.AstNode as IdentifierNode).Symbol; } } varNode.Span = parseNode.Span; varNode.AsString = varNode.Index; parseNode.AstNode = varNode; }
public static void CreateVariableNode(ParsingContext context, ParseTreeNode parseNode) { Variable varNode = null; foreach (ParseTreeNode nt in parseNode.ChildNodes) { // (e | s | t) if (varNode == null) { switch (nt.Term.Name) { case "s": varNode = new SymbolVariable(); break; case "e": varNode = new ExpressionVariable(); break; case "t": varNode = new TermVariable(); break; default: throw new ArgumentOutOfRangeException("Unknown variable type: " + nt.Term.Name); } continue; } if (nt.Term.Name == ".") continue; // Number | Identifier if (nt.AstNode is LiteralValueNode) { varNode.Index = (nt.AstNode as LiteralValueNode).Value.ToString(); } else if (nt.AstNode is IdentifierNode) { varNode.Index = (nt.AstNode as IdentifierNode).Symbol; } } varNode.Span = parseNode.Span; varNode.AsString = varNode.Index; parseNode.AstNode = varNode; }
static void Variable(out Variable variable) { variable = null; if (la.kind == 31) { Get(); variable = new ExpressionVariable(); } else if (la.kind == 32) { Get(); variable = new SymbolVariable(); } else if (la.kind == 33) { Get(); variable = new TermVariable(); } else { SynErr(40); } if (la.kind == 4) { Get(); } else if (la.kind == 1) { Get(); } else { SynErr(41); } if (variable != null) { variable.Index = t.val; } }
public override void VisitExpressionVariable(ExpressionVariable expressionVariable) { sb.Append("e."); sb.Append(expressionVariable.Index); }
public abstract void VisitExpressionVariable(ExpressionVariable expressionVariable);
public override void VisitExpressionVariable(ExpressionVariable expressionVariable) { throw new NotImplementedException(); }