コード例 #1
0
ファイル: Parser.cs プロジェクト: modulexcite/graveyard
        private static void ParseRule(Tree tree, Token token, Token[] tokens, ref int index)
        {
            if (token is Identifier)
            {
                var ruleToken = token;

                var rule = new Rule { Identifier = token.Value };

                token = NextToken(tokens, ref index);

                if (IsDefinition(token))
                {
                    token = NextToken(tokens, ref index);

                    rule.Expression = ParseExpression(tree, ref token, tokens, ref index, ';');

                    tree.Add(rule);
                }
                else
                {
                    ruleToken.Position += 2;
                    tree.Errors.Add(CreateError(ruleToken, string.Format(ErrorStrings.ExpectedDefinition, token == null ? "nothing" : token.Value)));
                }
            }
            else
            {
                tree.Errors.Add(CreateError(token, ErrorStrings.RulesMustBeginWithIdentifier));
            }
        }
コード例 #2
0
ファイル: Tree.cs プロジェクト: modulexcite/graveyard
 public void Add(Rule rule)
 {
     Rules.Add(rule);
 }