コード例 #1
0
ファイル: JSGFParser.cs プロジェクト: pgrudzien12/syn-speech
        public void RuleDeclaration(JSGFRuleGrammar grammar)
        {
            bool     pub = false;
            String   s;
            JSGFRule r;
            Token    t  = null;
            Token    t1 = null;

            switch ((_jj_ntk == -1) ? jj_ntk() : _jj_ntk)
            {
            case Public:
                t   = jj_consume_token(Public);
                pub = true;
                break;

            default:
                jj_la1[7] = jj_gen;
                break;
            }
            t1 = jj_consume_token(28);
            s  = RuleDef();
            jj_consume_token(31);
            jj_consume_token(32);
            r = Alternatives();
            jj_consume_token(26);
            try
            {
                if (grammar != null)
                {
                    grammar.SetRule(s, r, pub);
                    String docComment = null;
                    if ((t != null) && (t.SpecialToken != null) && (t.SpecialToken.Image != null))
                    {
                        docComment = t.SpecialToken.Image;
                    }
                    else if ((t1 != null) && (t1.SpecialToken != null) && (t1.SpecialToken.Image != null))
                    {
                        docComment = t1.SpecialToken.Image;
                    }
                    if (docComment != null && docComment.StartsWith("/**"))
                    {
                        ExtractKeywords(grammar, s, docComment);
                        grammar.AddRuleDocComment(s, docComment);
                    }
                }
            }
            catch (ArgumentException e)
            {
                Console.WriteLine("ERROR SETTING JSGFRule " + s);
            }
        }