コード例 #1
0
        private static void AdjustSpan(TerminalNode comment, TerminalNode nodeToAdjust)
        {
            var min = Math.Min(nodeToAdjust.Span.Start, comment.Span.Start);
            var max = Math.Max(nodeToAdjust.Span.End, comment.Span.End);

            nodeToAdjust.Span = new CharacterSpan(min, max);
        }
コード例 #2
0
 public ExtraIdOrAssignmentRule(TerminalNode comma, IdOrAssignmentRule idOrAssignment,
                                ExtraIdOrAssignmentRule extraIdOrAssign)
 {
     Comma           = Guard.OneOf(() => comma, Token.Comma);
     IdOrAssignment  = Guard.NonNull(() => idOrAssignment);
     ExtraIdOrAssign = extraIdOrAssign;
 }
コード例 #3
0
 public ExtraConditionRule(TerminalNode booleanOperator, ConditionRule condition,
                           ExtraConditionRule extraCondition)
 {
     BooleanOperator = Guard.OneOf(() => booleanOperator, TokensGroups.BooleanOperators);
     Condition       = Guard.NonNull(() => condition);
     ExtraCondition  = extraCondition;
 }
コード例 #4
0
ファイル: CodeGen.cs プロジェクト: zjloscar/Dynamo
 FusionCore.DSASM.Operand buildOperand(TerminalNode node)
 {
     FusionCore.DSASM.Operand op = new FusionCore.DSASM.Operand();
     op.optype = getOpType((FusionCore.PrimitiveType)node.type);
     if (FusionCore.DSASM.AddressType.VarIndex == op.optype)
     {
         //FusionCore.DSASM.SymbolNode
         int size = symbols.symbolList.Count;
         for (int n = 0; n < size; ++n)
         {
             // TODO jun: Hash the string
             if (functionindex == symbols.symbolList[n].functionIndex && symbols.symbolList[n].name == node.Value)
             {
                 op.opdata = n; // symbols.symbolList[n].index;
                 break;
             }
         }
     }
     else if (FusionCore.DSASM.AddressType.Int == op.optype)
     {
         op.opdata = System.Convert.ToInt32(node.Value);
     }
     else if (FusionCore.DSASM.AddressType.Register == op.optype)
     {
         op.opdata = (int)FusionCore.DSASM.Registers.RX;
     }
     else
     {
         Debug.Assert(false);
     }
     return(op);
 }
コード例 #5
0
        private static ContainerOrTerminalNode GetNodeToAdjust(Container parent, TerminalNode comment, int index, int first, int last)
        {
            var containers = parent.Children;

            if (index == first && index == last)
            {
                return(parent);
            }

            if (index == first)
            {
                return(containers[index + 1]);
            }

            if (index == last)
            {
                return(containers[index - 1]);
            }

            var next   = containers[index + 1];
            var before = containers[index - 1];

            var trailing = comment.LocationSpan.Start.LineNumber == before.LocationSpan.End.LineNumber;

            return(trailing ? before : next);
        }
コード例 #6
0
ファイル: ExtraEquationRule.cs プロジェクト: zero-based/teeny
 public ExtraEquationRule(TerminalNode arithmeticOperator, EquationRule equation,
                          ExtraEquationRule extraEquation)
 {
     ArithmeticOperator = Guard.OneOf(() => arithmeticOperator, TokensGroups.ArithmeticOperators);
     Equation           = Guard.NonNull(() => equation);
     ExtraEquation      = extraEquation;
 }
コード例 #7
0
ファイル: FunctionBodyRule.cs プロジェクト: zero-based/teeny
 public FunctionBodyRule(TerminalNode leftCurlyBracket, ICollection <StatementRule> statements,
                         ReturnStatementRule returnStatement, TerminalNode rightCurlyBracket)
 {
     LeftCurlyBracket  = Guard.OneOf(() => leftCurlyBracket, Token.CurlyBracketLeft);
     Statements        = statements;
     ReturnStatement   = Guard.NonNull(() => returnStatement);
     RightCurlyBracket = Guard.OneOf(() => rightCurlyBracket, Token.CurlyBracketRight);
 }
コード例 #8
0
 public AssignmentStatementRule(TerminalNode identifier, TerminalNode assignmentOperator,
                                ExpressionRule expression, TerminalNode semicolon)
 {
     Identifier         = Guard.OneOf(() => identifier, Token.Identifier);
     AssignmentOperator = Guard.OneOf(() => assignmentOperator, Token.Assignment);
     Expression         = expression;
     Semicolon          = Guard.OneOf(() => semicolon, Token.Semicolon);
 }
コード例 #9
0
ファイル: FunctionCallRule.cs プロジェクト: zero-based/teeny
 public FunctionCallRule(TerminalNode identifier, TerminalNode parenthesisLeft,
                         ArgumentsRule arguments, TerminalNode parenthesisRight)
 {
     Identifier       = Guard.OneOf(() => identifier, Token.Identifier);
     ParenthesisLeft  = Guard.OneOf(() => parenthesisLeft, Token.ParenthesisLeft);
     Arguments        = arguments;
     ParenthesisRight = Guard.OneOf(() => parenthesisRight, Token.ParenthesisRight);
 }
コード例 #10
0
 public EquationRule(TerminalNode parenthesisLeft, EquationRule equation,
                     TerminalNode parenthesisRight, ExtraEquationRule extraEquation)
 {
     ParenthesisLeft  = Guard.OneOf(() => parenthesisLeft, Token.ParenthesisLeft);
     Equation         = Guard.NonNull(() => equation);
     ParenthesisRight = Guard.OneOf(() => parenthesisRight, Token.ParenthesisRight);
     ExtraEquation    = extraEquation;
 }
コード例 #11
0
 public DeclarationStatementRule(TerminalNode dataType, IdOrAssignmentRule idOrAssignment,
                                 ExtraIdOrAssignmentRule extraIdOrAssignment, TerminalNode semicolon)
 {
     DataType            = Guard.OneOf(() => dataType, TokensGroups.DataTypes);
     IdOrAssignment      = Guard.NonNull(() => idOrAssignment);
     ExtraIdOrAssignment = extraIdOrAssignment;
     Semicolon           = Guard.OneOf(() => semicolon, Token.Semicolon);
 }
コード例 #12
0
 public RepeatStatementRule(TerminalNode repeat, ICollection <StatementRule> statements,
                            TerminalNode until, ConditionStatementRule conditionStatement)
 {
     Repeat             = Guard.OneOf(() => repeat, Token.Repeat);
     Statements         = statements;
     Until              = Guard.OneOf(() => until, Token.Until);
     ConditionStatement = Guard.NonNull(() => conditionStatement);
 }
コード例 #13
0
        private static void AdjustRoot(Container root, TerminalNode node)
        {
            var rootStart = node.LocationSpan.Start;

            // adjust positions
            root.LocationSpan = new LocationSpan(rootStart, root.LocationSpan.End);
            root.HeaderSpan   = new CharacterSpan(node.Span.Start, root.HeaderSpan.End);
        }
コード例 #14
0
 public ElseIfStatementRule(TerminalNode elseIf, ConditionStatementRule conditionStatement, TerminalNode then,
                            ICollection <StatementRule> statements, ExtraElseIfRule extraElseIf)
 {
     ElseIf             = Guard.OneOf(() => elseIf, Token.ElseIf);
     ConditionStatement = Guard.NonNull(() => conditionStatement);
     Then        = Guard.OneOf(() => then, Token.Then);
     Statements  = statements;
     ExtraElseIf = Guard.NonNull(() => extraElseIf);
 }
コード例 #15
0
 protected internal override void VisitTerminalNode(SnapshotBuilder builder, TerminalNode node)
 {
     if (builder.IsVisited(node))
     {
         return;
     }
     builder.AddNode(node, NodeInfo.Create);
     builder.AddLink(node, node.RuleNode);
     base.VisitTerminalNode(builder, node);
 }
コード例 #16
0
 public FunctionDeclarationRule(TerminalNode dataType, TerminalNode functionName,
                                TerminalNode leftParenthesis, ParametersRule parameters,
                                TerminalNode rightParenthesis)
 {
     DataType         = Guard.OneOf(() => dataType, TokensGroups.DataTypes);
     FunctionName     = Guard.OneOf(() => functionName, Token.Identifier);
     LeftParenthesis  = Guard.OneOf(() => leftParenthesis, Token.ParenthesisLeft);
     Parameters       = parameters;
     RightParenthesis = Guard.OneOf(() => rightParenthesis, Token.ParenthesisRight);
 }
コード例 #17
0
ファイル: MainFunctionRule.cs プロジェクト: zero-based/teeny
 public MainFunctionRule(TerminalNode dataType, TerminalNode main,
                         TerminalNode leftParenthesis, TerminalNode rightParenthesis,
                         FunctionBodyRule functionBody)
 {
     DataType         = Guard.OneOf(() => dataType, TokensGroups.DataTypes);
     Main             = Guard.OneOf(() => main, Token.Main);
     LeftParenthesis  = Guard.OneOf(() => leftParenthesis, Token.ParenthesisLeft);
     RightParenthesis = Guard.OneOf(() => rightParenthesis, Token.ParenthesisRight);
     FunctionBody     = Guard.NonNull(() => functionBody);
 }
コード例 #18
0
        public void EnterEveryRule(ParserRuleContext ctx)
        {
            string ruleName             = ruleNames[ctx.RuleIndex];
            IList <TerminalNode> tnodes = getDirectTerminalChildren(ctx);
            // Find all ordered unique pairs of literals;
            // no (a,a) pairs and only literals like '{', 'begin', '}', ...
            // Add a for (a,a) into ruleToRepeatedTokensSet for later filtering
            RuleAltKey ruleAltKey = new RuleAltKey(ruleName, ctx.getAltNumber());

            for (int i = 0; i < tnodes.Count; i++)
            {
                for (int j = i + 1; j < tnodes.Count; j++)
                {
                    TerminalNode a     = tnodes[i];
                    TerminalNode b     = tnodes[j];
                    int          atype = a.Symbol.Type;
                    int          btype = b.Symbol.Type;

                    // KED: THIS CODE DOES NOT WORK WITH GRAMMARS CONTAINING FRAGMENTS.
                    // IN ANTLRV4LEXER.G4 THAT IS IN THIS DIRECTORY, THE GRAMMAR DOES NOT USE
                    // FRAGMENT FOR COLON. BUT THE G4 GRAMMAR IN THE ANTLR GRAMMARS-G4 EXAMPLES,
                    // IT DOES. CONSEQUENTLY, GETLITERALNAME RETURNS NULL!
                    // FRAGMENTS AREN'T PART OF THE VOCABULARY, SO THIS CODE DOES NOT WORK!!

                    // only include literals like '{' and ':' not IDENTIFIER etc...
                    if (vocab.GetLiteralName(atype) == null || vocab.GetLiteralName(btype) == null)
                    {
                        continue;
                    }

                    if (atype == btype)
                    {
                        ISet <int> repeatedTokensSet = null;
                        if (!ruleToRepeatedTokensSet.TryGetValue(ruleAltKey, out repeatedTokensSet))
                        {
                            repeatedTokensSet = new HashSet <int>();
                            ruleToRepeatedTokensSet[ruleAltKey] = repeatedTokensSet;
                        }
                        repeatedTokensSet.Add(atype);
                    }
                    else
                    {
                        org.antlr.codebuff.misc.Pair <int, int>         pair     = new org.antlr.codebuff.misc.Pair <int, int>(atype, btype);
                        ISet <org.antlr.codebuff.misc.Pair <int, int> > pairsBag = null;
                        if (!ruleToPairsBag.TryGetValue(ruleAltKey, out pairsBag))
                        {
                            pairsBag = new HashSet <org.antlr.codebuff.misc.Pair <int, int> >();
                            ruleToPairsBag[ruleAltKey] = pairsBag;
                        }
                        pairsBag.Add(pair);
                    }
                }
            }
        }
コード例 #19
0
ファイル: NodeTests.cs プロジェクト: ngdrascal/ebnfcompiler
        public void TerminalNode_WithString_ReturnsCorrectString()
        {
            // Arranged:
            var node = new TerminalNode(new Token(TokenKind.String, "a"), _tracer);

            // Act:
            var actual = node.ToString();

            // Assert:
            Assert.That(actual, Is.EqualTo("\"a\""));
        }
コード例 #20
0
 public FinalNode(TerminalNode data)
 {
     instructionBytes = data.Text.Bytes;
     if (data.Text != null)
     {
         dataString_Renamed = data.Text;
     }
     else if (data.Symbol.Text != null)
     {
         dataString_Renamed = data.Symbol.Text;
     }
 }
コード例 #21
0
    public void SaveTerminalData()
    {
        CreateTerminalNode();

        for (int i = 0; i < terminals.Length; i++)
        {
            TerminalNode        terminal            = new TerminalNode(GetXmlNode(terminals[i]));
            TerminalInformation terminalInformation = SingletonManager.MainTerminalController.GetTerminalInformation(i);
            terminal.SetActivated(terminalInformation.isActivated);
            terminal.SetCollected(terminalInformation.isCollected);
        }
    }
コード例 #22
0
 public void initializeProject()
 {
     this.Model.Clear();
     this.Nodes.Clear();
     BaseNode.Controller      = this;
     ConnectorNode.Controller = this;
     this.terminalS           = new TerminalNode(TerminalNode.TerminalType.Start);
     this.terminalE           = new TerminalNode(TerminalNode.TerminalType.End);
     this.terminalS.attachNode(terminalE);
     this.terminalE.ParentNode = terminalS;
     this.terminalS.addToModel();
     this.terminalE.addToModel();
 }
コード例 #23
0
        private static void AdjustLocationSpan(TerminalNode comment, ContainerOrTerminalNode nodeToAdjust)
        {
            var commentStart = comment.LocationSpan.Start;
            var commentEnd   = comment.LocationSpan.End;

            var nodeStart = nodeToAdjust.LocationSpan.Start;
            var nodeEnd   = nodeToAdjust.LocationSpan.End;

            var start = nodeStart < commentStart ? nodeStart : commentStart;
            var end   = nodeEnd < commentEnd ? commentEnd : nodeEnd;

            nodeToAdjust.LocationSpan = new LocationSpan(start, end);
        }
コード例 #24
0
        private static void Adjust(TerminalNode comment, ContainerOrTerminalNode nodeToAdjust)
        {
            AdjustLocationSpan(comment, nodeToAdjust);

            if (nodeToAdjust is TerminalNode t)
            {
                AdjustSpan(comment, t);
            }
            else if (nodeToAdjust is Container c)
            {
                AdjustSpan(comment, c);
            }
        }
コード例 #25
0
 /// <summary>
 /// Creates an expression node and adds it to the
 /// give tree.
 /// </summary>
 /// <param name="root">Root node of expression tree</param>
 /// <param name="term">Term for this node</param>
 /// <param name="termForm">Indicates form of this term</param>
 /// <param name="termExclude">Indicates if this is an excluded term</param>
 /// <param name="conjunction">Conjunction used to join with other nodes</param>
 /// <returns>The new root node</returns>
 protected INode AddNode(INode root, string term, TermForms termForm, bool termExclude, ConjunctionTypes conjunction)
 {
     if (term.Length > 0)
     {
         INode node = new TerminalNode
         {
             Term     = term,
             TermForm = termForm,
             Exclude  = termExclude
         };
         root = AddNode(root, node, conjunction);
     }
     return(root);
 }
コード例 #26
0
        //Parses the name of a variable, or throws an exception is token is not valid ID
        private Node ParseVarName()
        {
            var valid = CurrentToken.tokenType == TokenTypes.identity;

            if (!valid)
            {
                throw new ParserException("Line " + CurrentToken.lineNumber + ": Expected identifier; found " + CurrentToken.token);
            }
            else
            {
                var node = new TerminalNode(CurrentToken);
                Consume();
                return(node);
            }
        }
コード例 #27
0
        //Parses boolean, or throws an exception
        private Node ParseBool()
        {
            var valid = CurrentToken.tokenType == TokenTypes.boolean;

            if (!valid)
            {
                throw new ParserException("Line " + CurrentToken.lineNumber + ": Expected boolean; found " + CurrentToken.token);
            }
            else
            {
                var node = new TerminalNode(CurrentToken);
                Consume();
                return(node);
            }
        }
コード例 #28
0
        private static TerminalNode AddTerminalNode(Container parent, string type, string name, string content, LocationSpan locationSpan, CharacterSpan span)
        {
            var child = new TerminalNode
            {
                Type         = type,
                Name         = name,
                Content      = content,
                LocationSpan = locationSpan,
                Span         = span,
            };

            parent.Children.Add(child);

            return(child);
        }
コード例 #29
0
 public Project_Saver(Controller controller, TerminalNode start, TerminalNode end, String path)
 {
     Controller = controller;
     stringBuilder.Append(begin);
     stringBuilder.Append(getBlockXML(start, null));
     stringBuilder.Append(endStr);
     XmlString = stringBuilder.ToString();
     try
     {
         File.WriteAllText(path, xmlString);
     }
     catch (Exception ex) {
         Controller.showErrorMsg("File Not Found");
     }
 }
コード例 #30
0
ファイル: Formatter.cs プロジェクト: mhornsby/cs-codebuff
        public virtual TokenPositionAnalysis getTokenAnalysis(int[] features, int[] featuresForAlign, int tokenIndexInStream, int injectNL_WS, int alignOrIndent, bool collectAnalysis)
        {
            CommonToken  curToken = (CommonToken)originalDoc.tokens.Get(tokenIndexInStream);
            TerminalNode nodeWithOriginalToken = originalTokenToNodeMap[curToken];

            int    actualWS   = Trainer.getInjectWSCategory(originalTokens, tokenIndexInStream);
            string actualWSNL = getWSCategoryStr(actualWS);

            actualWSNL = !string.ReferenceEquals(actualWSNL, null) ? actualWSNL : string.Format("{0,8}", "none");

            string wsDisplay = getWSCategoryStr(injectNL_WS);

            if (string.ReferenceEquals(wsDisplay, null))
            {
                wsDisplay = string.Format("{0,8}", "none");
            }
            string alignDisplay = getHPosCategoryStr(alignOrIndent);

            if (string.ReferenceEquals(alignDisplay, null))
            {
                alignDisplay = string.Format("{0,8}", "none");
            }
            string newlinePredictionString = string.Format("### line {0:D}: predicted {1} actual {2}", curToken.Line, wsDisplay, actualWSNL);

            int    actualAlignCategory = Trainer.getAlignmentCategory(originalDoc, nodeWithOriginalToken, indentSize);
            string actualAlignDisplay  = getHPosCategoryStr(actualAlignCategory);

            actualAlignDisplay = !string.ReferenceEquals(actualAlignDisplay, null) ? actualAlignDisplay : string.Format("{0,8}", "none");

            string alignPredictionString = string.Format("### line {0:D}: predicted {1} actual {2}", curToken.Line, alignDisplay, actualAlignDisplay);

            string newlineAnalysis = "";
            string alignAnalysis   = "";

            if (collectAnalysis)
            {             // this can be slow
                newlineAnalysis = newlinePredictionString + "\n" + wsClassifier.getPredictionAnalysis(testDoc, k, features, corpus.injectWhitespace, Trainer.MAX_WS_CONTEXT_DIFF_THRESHOLD);
                if ((injectNL_WS & 0xFF) == Trainer.CAT_INJECT_NL)
                {
                    alignAnalysis = alignPredictionString + "\n" + hposClassifier.getPredictionAnalysis(testDoc, k, featuresForAlign, corpus.hpos, Trainer.MAX_ALIGN_CONTEXT_DIFF_THRESHOLD);
                }
            }
            TokenPositionAnalysis a = new TokenPositionAnalysis(curToken, injectNL_WS, newlineAnalysis, alignOrIndent, alignAnalysis);

            a.actualWS    = Trainer.getInjectWSCategory(originalTokens, tokenIndexInStream);
            a.actualAlign = actualAlignCategory;
            return(a);
        }
コード例 #31
0
 /// <summary>
 /// Creates an expression node and adds it to the
 /// give tree.
 /// </summary>
 /// <param name="root">Root node of expression tree</param>
 /// <param name="term">Term for this node</param>
 /// <param name="termForm">Indicates form of this term</param>
 /// <param name="termExclude">Indicates if this is an excluded term</param>
 /// <param name="conjunction">Conjunction used to join with other nodes</param>
 /// <returns>The new root node</returns>
 protected INode AddNode(INode root, string term, TermForms termForm, bool termExclude, ConjunctionTypes conjunction)
 {
     if (term.Length > 0)
     {
         INode node = new TerminalNode
         {
             Term = term,
             TermForm = termForm,
             Exclude = termExclude
         };
         root = AddNode(root, node, conjunction);
     }
     return root;
 }
コード例 #32
0
ファイル: CodeGen.cs プロジェクト: RobertiF/Dynamo
 FusionCore.DSASM.Operand buildOperand(TerminalNode node)
 {
     FusionCore.DSASM.Operand op = new FusionCore.DSASM.Operand();
     op.optype = getOpType((FusionCore.PrimitiveType)node.type);
     if (FusionCore.DSASM.AddressType.VarIndex == op.optype)
     {
         //FusionCore.DSASM.SymbolNode
         int size = symbols.symbolList.Count;
         for (int n = 0; n < size; ++n)
         {
             // TODO jun: Hash the string
             if (functionindex == symbols.symbolList[n].functionIndex && symbols.symbolList[n].name == node.Value)
             {
                 op.opdata = n; // symbols.symbolList[n].index;
                 break;
             }
         }
     }
     else if (FusionCore.DSASM.AddressType.Int == op.optype)
     {
         op.opdata = System.Convert.ToInt32(node.Value);
     }
     else if (FusionCore.DSASM.AddressType.Register == op.optype)
     {
         op.opdata = (int)FusionCore.DSASM.Registers.RX;
     }
     else
     {
         Debug.Assert(false);
     }
     return op;
 }
コード例 #33
0
 private TerminalNode NewTerminalNode(XmlQualifiedName qname) {
     TerminalNode t = new TerminalNode(qname);
     t.Pos = terminalNodes.Count;
     terminalNodes.Add(t);
     if (!qname.IsEmpty && symbolTable[qname] == null) {
         symbolTable.Add(qname, symbols.Count);
         symbols.Add(qname);
     }
     return t;
 }
コード例 #34
0
 internal CompiledContentModel( SchemaNames names ) {
     schemaNames = names;
     endNode = null;
 }
コード例 #35
0
        internal void    Finish(ValidationEventHandler eventHandler, bool compile) {
            stack = null;
            IsCompiled = !abnormalContent && compile;
            if (contentNode == null)
                return;

#if DEBUG
            StringBuilder bb = new StringBuilder();
            contentNode.Dump(bb);
            Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceVerbose, "\t\t\tContent: (" + bb.ToString() + ")");
#endif

            // add end node
            endNode = NewTerminalNode(XmlQualifiedName.Empty);
            contentNode = new InternalNode(contentNode, endNode, ContentNode.Type.Sequence);
            ((InternalNode)contentNode).LeftNode.ParentNode = contentNode;
            endNode.ParentNode = contentNode;

            if (!IsCompiled) {
                CheckXsdDeterministic(eventHandler);
                return;
            }

            if (nodeTable == null)
                nodeTable = new Hashtable();

            // calculate followpos
            int terminals = terminalNodes.Count;
            BitSet[] followpos = new BitSet[terminals];
            for (int i = 0; i < terminals; i++) {
                followpos[i] = new BitSet(terminals);
            }
            contentNode.CalcFollowpos(followpos);

            // state table
            ArrayList Dstates = new ArrayList(16);
            // transition table
            dtrans = new ArrayList(16);
            // lists unmarked states
            ArrayList unmarked = new ArrayList(16);
            // state lookup table
            Hashtable statetable = new Hashtable();

            BitSet empty = new BitSet(terminals);
            statetable.Add(empty, -1);

            // start with firstpos at the root
            BitSet set = contentNode.Firstpos(terminals);
            statetable.Add(set, Dstates.Count);
            unmarked.Add(set);
            Dstates.Add(set);

            int[] a = new int[symbols.Count + 1];
            dtrans.Add(a);
            if (set.Get(endNode.Pos)) {
                a[symbols.Count] = 1;   // accepting
            }

            // current state processed
            int state = 0;

            // check all unmarked states
            while (unmarked.Count > 0) {
                int[] t = (int[])dtrans[state];

                set = (BitSet)unmarked[0];
                CheckDeterministic(set, terminals, eventHandler);
                unmarked.RemoveAt(0);

                // check all input symbols
                for (int sym = 0; sym < symbols.Count; sym++) {
                    XmlQualifiedName n = (XmlQualifiedName)symbols[sym];
                    BitSet newset = new BitSet(terminals);

                    // if symbol is in the set add followpos to new set
                    for (int i = 0; i < terminals; i++) {
                        if (set.Get(i) && n.Equals(((TerminalNode)terminalNodes[i]).Name)) {
                            newset.Or(followpos[i]);
                        }
                    }

                    Object lookup = statetable[newset];
                    // this state will transition to
                    int transitionTo;
                    // if new set is not in states add it
                    if (lookup == null) {
                        transitionTo = Dstates.Count;
                        statetable.Add(newset, transitionTo);
                        unmarked.Add(newset);
                        Dstates.Add(newset);
                        a = new int[symbols.Count + 1];
                        dtrans.Add(a);
                        if (newset.Get(endNode.Pos)) {
                            a[symbols.Count] = 1;   // accepting
                        }
                    }
                    else {
                        transitionTo = (int)lookup;
                    }
                    // set the transition for the symbol
                    t[sym] = transitionTo;
                }
                state++;
            }

            nodeTable = null;
        }
コード例 #36
0
ファイル: NodeInfo.cs プロジェクト: hebert26/NRules
 internal static NodeInfo Create(TerminalNode node)
 {
     return new NodeInfo(NodeType.Terminal, string.Empty);
 }