Exemple #1
0
 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);
     }
 }
Exemple #2
0
        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;
        }
Exemple #3
0
        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;
        }
Exemple #4
0
 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;
     }
 }
Exemple #5
0
 public override void VisitExpressionVariable(ExpressionVariable expressionVariable)
 {
     sb.Append("e.");
     sb.Append(expressionVariable.Index);
 }
Exemple #6
0
 public abstract void VisitExpressionVariable(ExpressionVariable expressionVariable);
Exemple #7
0
 public override void VisitExpressionVariable(ExpressionVariable expressionVariable)
 {
     throw new NotImplementedException();
 }