コード例 #1
0
ファイル: YyParser.cs プロジェクト: m33p/radegast
        public ParsingInfo GetSymbolInfo(string name, int num)
        {
            ParsingInfo parsingInfo = (ParsingInfo)this.symbolInfo[(object)num];

            if (parsingInfo == null)
            {
                this.symbolInfo[(object)num] = (object)(parsingInfo = new ParsingInfo(name, num));
            }
            return(parsingInfo);
        }
コード例 #2
0
ファイル: lexer.cs プロジェクト: cognitum-octopus/cognipy
        public virtual bool Pass(YyParser syms, int snum, out ParserEntry entry)
        {
            ParsingInfo pi = (ParsingInfo)syms.symbolInfo[yynum];

            if (pi == null)
            {
                string s = string.Format("No parsinginfo for symbol {0} {1}", yyname, yynum);
                syms.erh.Error(new CSToolsFatalException(9, yylx, yyname, s));
            }
            bool r = pi.m_parsetable.Contains(snum);

            entry = r ? ((ParserEntry)pi.m_parsetable[snum]) : null;
            return(r);
        }
コード例 #3
0
ファイル: SYMBOL.cs プロジェクト: m33p/radegast
        public virtual bool Pass(YyParser syms, int snum, out ParserEntry entry)
        {
            ParsingInfo parsingInfo = (ParsingInfo)syms.symbolInfo[(object)this.yynum];

            if (parsingInfo == null)
            {
                string s = string.Format("No parsinginfo for symbol {0} {1}", (object)this.yyname, (object)this.yynum);
                syms.erh.Error((CSToolsException) new CSToolsFatalException(9, this.yylx, this.yyname, s));
            }
            bool flag = parsingInfo.m_parsetable.Contains((object)snum);

            entry = !flag ? (ParserEntry)null : (ParserEntry)parsingInfo.m_parsetable[(object)snum];
            return(flag);
        }
コード例 #4
0
        private void PrintTransition(ParsingInfo pi)
        {
            ParserEntry parserEntry = (ParserEntry)pi.m_parsetable[(object)this.m_state];

            if (parserEntry == null)
            {
                return;
            }
            Console.Write("        {0}  {1}  ", (object)pi.m_name, (object)parserEntry.str);
            if (parserEntry.m_action != null)
            {
                parserEntry.m_action.Print();
            }
            Console.WriteLine();
        }
コード例 #5
0
ファイル: Transition.cs プロジェクト: m33p/radegast
        public static void BuildParseTable(Transition t)
        {
            YyParser     symbols       = t.m_ps.m_sgen.m_symbols;
            ParsingInfo  parsingInfo   = t.ParsingInfo;
            ParserReduce parserReduce1 = (ParserReduce)null;

            foreach (ParserReduce parserReduce2 in (IEnumerable)t.m_reduce.Values)
            {
                if ((!t.m_ps.m_sgen.m_lalrParser ? (parserReduce2.m_prod.m_lhs.m_follow.Contains(t.m_A) ? 1 : 0) : (parserReduce2.m_lookAhead.Contains(t.m_A) ? 1 : 0)) != 0)
                {
                    if (parserReduce1 != null)
                    {
                        symbols.erh.Error(new CSToolsException(12, string.Format("reduce/reduce conflict {0} vs {1}", (object)parserReduce1.m_prod.m_pno, (object)parserReduce2.m_prod.m_pno) + string.Format(" state {0} on {1}", (object)t.m_ps.m_state, (object)t.m_A.yytext)));
                    }
                    parserReduce1 = parserReduce2;
                }
            }
            if (t.m_next != null && t.m_A != symbols.EOFSymbol)
            {
                if (parserReduce1 == null)
                {
                    parsingInfo.m_parsetable[(object)t.m_ps.m_state] = (object)t.m_next;
                }
                else
                {
                    switch (t.m_A.ShiftPrecedence(parserReduce1.m_prod, t.m_ps))
                    {
                    case Precedence.PrecType.left:
                        parsingInfo.m_parsetable[(object)t.m_ps.m_state] = (object)t.m_next;
                        break;

                    case Precedence.PrecType.right:
                        parsingInfo.m_parsetable[(object)t.m_ps.m_state] = (object)parserReduce1;
                        break;
                    }
                }
            }
            else
            {
                if (parserReduce1 == null)
                {
                    return;
                }
                parsingInfo.m_parsetable[(object)t.m_ps.m_state] = (object)parserReduce1;
            }
        }
コード例 #6
0
        public override bool Pass(Symbols syms, int snum, out ParserEntry entry)
        {
            if (!yyname().Equals("TOKEN"))             // derived classes' parsetable do not depend on yytext
            {
                return(base.Pass(syms, snum, out entry));
            }
            //Console.WriteLine("Retrieving Parsetable for literal {0}",m_str);
            ParsingInfo pi = (ParsingInfo)syms.literalInfo[m_str];

            if (pi == null)
            {
                syms.erh.Error(new CSToolsException(10, yylx, m_str, String.Format("Parser does not recognise literal <{0}>", m_str)));
            }
            bool r = pi.m_parsetable.Contains(snum);

            entry = r?((ParserEntry)pi.m_parsetable[snum]):null;
            return(r);
        }
コード例 #7
0
        public static object Serialise(object o, Serialiser s)
        {
            if (s == null)
            {
                return((object)new ParsingInfo());
            }
            ParsingInfo parsingInfo = (ParsingInfo)o;

            if (s.Encode)
            {
                s.Serialise((object)parsingInfo.m_name);
                s.Serialise((object)parsingInfo.m_yynum);
                s.Serialise((object)parsingInfo.m_parsetable);
                return((object)null);
            }
            parsingInfo.m_name       = (string)s.Deserialise();
            parsingInfo.m_yynum      = (int)s.Deserialise();
            parsingInfo.m_parsetable = (Hashtable)s.Deserialise();
            return((object)parsingInfo);
        }
コード例 #8
0
ファイル: lexer.cs プロジェクト: cognitum-octopus/cognipy
        public override bool Pass(YyParser syms, int snum, out ParserEntry entry)
        {
            if (yynum == 1)
            {
                Literal lit = (Literal)syms.literals[yytext];
                if (lit != null)
                {
                    num = (int)lit.m_yynum;
                }
            }
            ParsingInfo pi = (ParsingInfo)syms.symbolInfo[yynum];

            if (pi == null)
            {
                string s = string.Format("Parser does not recognise literal {0}", yytext);
                syms.erh.Error(new CSToolsFatalException(9, yylx, yyname, s));
            }
            bool r = pi.m_parsetable.Contains(snum);

            entry = r ? ((ParserEntry)pi.m_parsetable[snum]) : null;
            return(r);
        }
コード例 #9
0
ファイル: TOKEN.cs プロジェクト: m33p/radegast
        public override bool Pass(YyParser syms, int snum, out ParserEntry entry)
        {
            if (this.yynum == 1)
            {
                Literal literal = (Literal)syms.literals[(object)this.yytext];
                if (literal != null)
                {
                    this.num = literal.m_yynum;
                }
            }
            ParsingInfo parsingInfo = (ParsingInfo)syms.symbolInfo[(object)this.yynum];

            if (parsingInfo == null)
            {
                string s = string.Format("Parser does not recognise literal {0}", (object)this.yytext);
                syms.erh.Error((CSToolsException) new CSToolsFatalException(9, this.yylx, this.yyname, s));
            }
            bool flag = parsingInfo.m_parsetable.Contains((object)snum);

            entry = !flag ? (ParserEntry)null : (ParserEntry)parsingInfo.m_parsetable[(object)snum];
            return(flag);
        }