Beispiel #1
0
 override public bool MoveNext()
 {
     if (iee.MoveNext())
     {
         System.Console.WriteLine(prefix + "Token: " + iee.Current.tag + (iee.Current.tag != iee.Current.str ? "," + iee.Current.str : ""));
         return(true);
     }
     return(false);
 }
Beispiel #2
0
    public Parser(InputElementEnumerator yylex)
    {
        this.yylex = yylex;

        yylex.MoveNext();

        wl = new System.Collections.Queue();
        wl.Enqueue(new startState());
        wl_next = new System.Collections.Queue();
    }
Beispiel #3
0
 override public bool MoveNext()
 {
     for (;;)
     {
         if (!iee.MoveNext())
         {
             return(false);
         }
         if (predicate())
         {
             return(true);
         }
     }
 }
Beispiel #4
0
    public nonterminalState parse(System.IO.TextWriter err)
    {
        nonterminalState _current = null;
        InputElement     cur      = yylex.Current;
        InputElement     prev     = null;

        while (wl.Count > 0)
        {
            foreach (state s in wl)
            {
                s.end = cur.coord;
            }
            while (wl.Count > 0)
            {
                state s = (state)wl.Dequeue();

                if (s.below != null && s.below.checkRejected())
                {
                    continue;
                }

                if (s.accepting)
                {
                    System.Diagnostics.Debug.Assert(_current == null);
                    _current = ((acceptingState)s).root;
                }
                else
                {
                    s.transitions(wl_next, cur, count);
                }
            }
            if (yylex.MoveNext())
            {
                count++;
                prev = cur;
                cur  = yylex.Current;
            }

            System.Collections.Queue tmp = wl;
            wl      = wl_next;
            wl_next = tmp;
        }
        if (_current == null)
        {
            err.WriteLine("\"" + prev.coord.file + "\" (" + prev.coord.line + "," + prev.coord.column + "): Syntax error on \"" + prev.str + "\"");
        }
        return(_current);
    }
Beispiel #5
0
    protected void doLine()
    {
        if (!tokens.MoveNext())
        {
            error("incomplete #line");
            return;
        }
        if (tokens.Current.tag != "integer-literal")
        {
            error("expecting integer");
            return;
        }
        string line = tokens.Current.str;

        if (emitting)
        {
            try {
                this.linedelta = System.Convert.ToInt32(line) - iee.Current.coord.line;
            } catch (System.OverflowException) {
                error("line number too big");
            }
        }
        if (!tokens.MoveNext())
        {
            return;
        }
        if (tokens.Current.tag == "<EOF>")
        {
            return;
        }
        if (tokens.Current.tag != "string-literal")
        {
            error("expecting string");
        }
        file = tokens.Current.str;
    }