public override void VisitSymbolVariable(SymbolVariable symbolVariable) { if (!symbolVariable.IsBound) { sb.AppendFormat("new SymbolVariable(\"{0}\")", symbolVariable.Index); } else { sb.AppendFormat("pattern{0}.GetVariable(\"{1}\")", currentPatternIndex, symbolVariable.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 VisitSymbolVariable(SymbolVariable symbolVariable) { sb.Append("s."); sb.Append(symbolVariable.Index); }
public abstract void VisitSymbolVariable(SymbolVariable symbolVariable);
public override void VisitSymbolVariable(SymbolVariable symbolVariable) { throw new NotImplementedException(); }