Exemple #1
0
        public virtual object ApplyOnce( object t, System.Func<TreeRuleReturnScope> whichRule )
        {
            if ( t == null )
                return null;

            try
            {
                // share TreeParser object but not parsing-related state
                state = new RecognizerSharedState();
                input = new CommonTreeNodeStream( originalAdaptor, t );
                ( (CommonTreeNodeStream)input ).TokenStream = originalTokenStream;
                BacktrackingLevel = 1;
                TreeRuleReturnScope r = whichRule();
                BacktrackingLevel = 0;
                if ( Failed )
                    return t;
                if ( r != null && !t.Equals( r.Tree ) && r.Tree != null )
                { // show any transformations
                    Console.Out.WriteLine( ( (CommonTree)t ).ToStringTree() + " -> " +
                                       ( (CommonTree)r.Tree ).ToStringTree() );
                }
                if ( r != null && r.Tree != null )
                    return r.Tree;
                else
                    return t;
            }
            catch ( RecognitionException )
            {
            }
            return t;
        }
Exemple #2
0
        public BrainfuckerParser(ITokenStream input, int port, RecognizerSharedState state)
            : base(input, state)
        {
            this.state.ruleMemo = new System.Collections.Generic.Dictionary <int, int> [11 + 1];


            ITreeAdaptor treeAdaptor = default(ITreeAdaptor);

            CreateTreeAdaptor(ref treeAdaptor);
            TreeAdaptor = treeAdaptor ?? new CommonTreeAdaptor();
            DebugEventSocketProxy proxy = new DebugEventSocketProxy(this, port, adaptor);

            DebugListener = proxy;
            ITokenStream  = new DebugITokenStream(input, proxy);
            try
            {
                proxy.Handshake();
            }
            catch (IOException ioe)
            {
                ReportError(ioe);
            }
            ITreeAdaptor adap = new CommonTreeAdaptor();

            TreeAdaptor       = adap;
            proxy.TreeAdaptor = adap;
        }
    public ProfileTreeGrammar(ITreeNodeStream input, IDebugEventListener dbg, RecognizerSharedState state)
        : base(input, dbg, state)
    {
        Profiler p = (Profiler)dbg;

        p.setParser(this);
    }
Exemple #4
0
        public virtual object ApplyOnce( object t, Func<TreeRuleReturnScope> whichRule )
        {
            if ( t == null )
                return null;

            try
            {
                // share TreeParser object but not parsing-related state
                state = new RecognizerSharedState();
                input = new CommonTreeNodeStream( originalAdaptor, t );
                ( (CommonTreeNodeStream)input ).TokenStream = originalTokenStream;
                BacktrackingLevel = 1;
                TreeRuleReturnScope r = whichRule();
                BacktrackingLevel = 0;
                if ( Failed() )
                    return t;
                if (showTransformations &&
                    r != null && !t.Equals(r.Tree) && r.Tree != null)
                {
                    ReportTransformation(t, r.Tree);
                }
                if (r != null && r.Tree != null)
                    return r.Tree;
                else
                    return t;
            }
            catch ( RecognitionException )
            {
            }
            return t;
        }
        public MySQLParserBase(ITokenStream input, RecognizerSharedState state) : base(input, state)
        {
            // default value
            mysqlVersion = 5.1;

            _blockStack.Push(BlockKind.None);
        }
Exemple #6
0
	public TypeSqlParser(ITokenStream input, RecognizerSharedState state)
		: base(input, state)
	{
		ITreeAdaptor treeAdaptor = default(ITreeAdaptor);
		CreateTreeAdaptor(ref treeAdaptor);
		TreeAdaptor = treeAdaptor ?? new CommonTreeAdaptor();
		OnCreated();
	}
Exemple #7
0
 public TreeRewriter(ITreeNodeStream input, RecognizerSharedState state)
     : base(input, state)
 {
     this.originalAdaptor     = input.TreeAdaptor;
     this.originalTokenStream = input.TokenStream;
     this.topdown_func        = (Func <IAstRuleReturnScope>)(() => this.Topdown());
     this.bottomup_func       = (Func <IAstRuleReturnScope>)(() => this.Bottomup());
 }
Exemple #8
0
 public TreeFilter(ITreeNodeStream input, RecognizerSharedState state)
     : base(input, state)
 {
     originalAdaptor     = input.TreeAdaptor;
     originalTokenStream = input.TokenStream;
     topdown_action      = () => Topdown();
     bottomup_action     = () => Bottomup();
 }
Exemple #9
0
 public TreeRewriter( ITreeNodeStream input, RecognizerSharedState state )
     : base( input, state )
 {
     originalAdaptor = input.TreeAdaptor;
     originalTokenStream = input.TokenStream;
     topdown_func = () => Topdown();
     bottomup_func = () => Bottomup();
 }
 public SimpleExpressionParser(ITokenStream input, RecognizerSharedState state)
     : base(input, state)
 {
     InitializeTreeAdaptor();
     if (TreeAdaptor == null)
     {
         TreeAdaptor = new CommonTreeAdaptor();
     }
 }
Exemple #11
0
        public OslcOrderByParser(ITokenStream input, RecognizerSharedState state)
            : base(input, state)
        {
            ITreeAdaptor treeAdaptor = default(ITreeAdaptor);

            CreateTreeAdaptor(ref treeAdaptor);
            TreeAdaptor = treeAdaptor ?? new CommonTreeAdaptor();
            OnCreated();
        }
Exemple #12
0
        public SaqaParser(ITokenStream input, RecognizerSharedState state)
            : base(input, state)
        {
            ITreeAdaptor treeAdaptor = null;

            CreateTreeAdaptor(ref treeAdaptor);
            TreeAdaptor = treeAdaptor ?? new CommonTreeAdaptor();

            OnCreated();
        }
    public abevformulaParser(ITokenStream input, RecognizerSharedState state)
        : base(input, state)
    {
        this.state.ruleMemo = new System.Collections.Generic.Dictionary <int, int> [10 + 1];

        InitializeTreeAdaptor();
        if (TreeAdaptor == null)
        {
            TreeAdaptor = new CommonTreeAdaptor();
        }
    }
Exemple #14
0
    public TestParser(ITokenStream input, RecognizerSharedState state)
        : base(input, state)
    {
        this.state.ruleMemo = new System.Collections.Generic.Dictionary <int, int> [12 + 1];


        CstBuilderForAntlr3 treeAdaptor = default(CstBuilderForAntlr3);

        CreateTreeAdaptor(ref treeAdaptor);
        TreeAdaptor = treeAdaptor;
        OnCreated();
    }
Exemple #15
0
    public DebugTreeGrammar(ITreeNodeStream input, int port, RecognizerSharedState state)
        : base(input, state)
    {
        DebugEventSocketProxy proxy = new DebugEventSocketProxy(this, port, input.TreeAdaptor);

        DebugListener = proxy;
        try
        {
            proxy.Handshake();
        }
        catch (IOException ioe)
        {
            ReportError(ioe);
        }
    }
    public antlr2020Parser(ITokenStream input, int port, RecognizerSharedState state)
        : base(input, state)
    {
        DebugEventSocketProxy proxy = new DebugEventSocketProxy(this, port, null);

        DebugListener = proxy;
        try
        {
            proxy.Handshake();
        }
        catch (IOException ioe)
        {
            ReportError(ioe);
        }
    }
Exemple #17
0
        public virtual object ApplyOnce(object t, System.Func <IAstRuleReturnScope <TTree> > whichRule)
        {
            if (t == null)
            {
                return(null);
            }

            try
            {
                // share TreeParser object but not parsing-related state
                state = new RecognizerSharedState();
                input = new CommonTreeNodeStream(originalAdaptor, t);
                ((CommonTreeNodeStream)input).TokenStream = originalTokenStream;
                BacktrackingLevel = 1;
                IAstRuleReturnScope <TTree> r = whichRule();
                BacktrackingLevel = 0;
                if (Failed)
                {
                    return(t);
                }

                if (typeof(CommonTree).IsAssignableFrom(typeof(TTree)))
                {
                    if (r != null && !t.Equals(r.Tree) && r.Tree != null)
                    {
                        // show any transformations
                        Console.Out.WriteLine(((CommonTree)t).ToStringTree() + " -> " +
                                              ((CommonTree)(object)r.Tree).ToStringTree());
                    }
                }

                if (r != null && r.Tree != null)
                {
                    return(r.Tree);
                }
                else
                {
                    return(t);
                }
            }
            catch (RecognitionException)
            {
            }
            return(t);
        }
Exemple #18
0
        public virtual void ApplyOnce( object t, System.Action whichRule )
        {
            if ( t == null )
                return;

            try
            {
                // share TreeParser object but not parsing-related state
                state = new RecognizerSharedState();
                input = new CommonTreeNodeStream( originalAdaptor, t );
                ( (CommonTreeNodeStream)input ).TokenStream = originalTokenStream;
                BacktrackingLevel = 1;
                whichRule();
                BacktrackingLevel = 0;
            }
            catch ( RecognitionException )
            {
            }
        }
Exemple #19
0
        public virtual object ApplyOnce(object t, System.Func <IAstRuleReturnScope> whichRule)
        {
            if (t == null)
            {
                return(null);
            }

            try
            {
                // share TreeParser object but not parsing-related state
                state = new RecognizerSharedState();
                input = new CommonTreeNodeStream(originalAdaptor, t);
                ((CommonTreeNodeStream)input).TokenStream = originalTokenStream;
                BacktrackingLevel = 1;
                IAstRuleReturnScope r = whichRule();
                BacktrackingLevel = 0;
                if (Failed)
                {
                    return(t);
                }

                if (showTransformations && r != null && !t.Equals(r.Tree) && r.Tree != null)
                {
                    ReportTransformation(t, r.Tree);
                }

                if (r != null && r.Tree != null)
                {
                    return(r.Tree);
                }
                else
                {
                    return(t);
                }
            }
            catch (RecognitionException)
            {
            }

            return(t);
        }
Exemple #20
0
        public virtual void ApplyOnce(object t, System.Action whichRule)
        {
            if (t == null)
            {
                return;
            }

            try
            {
                // share TreeParser object but not parsing-related state
                state = new RecognizerSharedState();
                input = new CommonTreeNodeStream(originalAdaptor, t);
                ((CommonTreeNodeStream)input).TokenStream = originalTokenStream;
                BacktrackingLevel = 1;
                whichRule();
                BacktrackingLevel = 0;
            }
            catch (RecognitionException)
            {
            }
        }
Exemple #21
0
 public TreeFilter(ITreeNodeStream input, RecognizerSharedState state)
     : base(input, state)
 {
     originalAdaptor     = input.TreeAdaptor;
     originalTokenStream = input.TokenStream;
 }
 public pruebaLexer(ICharStream input, RecognizerSharedState state)
     : base(input, state)
 {
     OnCreated();
 }
Exemple #23
0
 public ChemProVTree(ITreeNodeStream input, RecognizerSharedState state)
     : base(input, state)
 {
     OnCreated();
 }
Exemple #24
0
 /** <summary>
  *  Create a normal parser except wrap the token stream in a debug
  *  proxy that fires consume events.
  *  </summary>
  */
 public DebugTreeParser(ITreeNodeStream input, IDebugEventListener dbg, RecognizerSharedState state)
     : base(input is DebugTreeNodeStream ? input : new DebugTreeNodeStream(input, dbg), state) {
     DebugListener = dbg;
 }
Exemple #25
0
 public ExprLexer(ICharStream input, RecognizerSharedState state)
     : base(input, state)
 {
 }
 public FastSimpleExpressionLexer(ICharStream input, RecognizerSharedState state)
     : base(input, state)
 {
 }
Exemple #27
0
 public Parser( ITokenStream input, RecognizerSharedState state )
     : base(state) // share the state object with another parser
 {
     this.input = input;
 }
Exemple #28
0
 public DebugParser(ITokenStream input, RecognizerSharedState state)
     : base(input is DebugTokenStream ? input : new DebugTokenStream(input, null), state) {
 }
 // share the state object with another parser
 public TreeParser( ITreeNodeStream input, RecognizerSharedState state )
     : base(state)
 {
     SetTreeNodeStream( input );
 }
Exemple #30
0
 public FuncProtoToShimParser(ITokenStream input, RecognizerSharedState state)
     : base(input, state)
 {
     OnCreated();
 }
Exemple #31
0
 // share the state object with another parser
 public Parser( ITokenStream input, RecognizerSharedState state )
     : base(state)
 {
     this.input = input;
 }
Exemple #32
0
 public DebugTreeParser(ITreeNodeStream input, RecognizerSharedState state)
     : base(input is DebugTreeNodeStream ? input : new DebugTreeNodeStream(input, null), state)
 {
 }
Exemple #33
0
 /// <summary>
 /// A simple constructor.
 /// </summary>
 /// <param name="input">The code to lex.</param>
 /// <param name="state">The <see cref="RecognizerSharedState"/> to use.</param>
 public AntlrLexerBase(ICharStream input, RecognizerSharedState state)
     : base(input, state)
 {
 }
Exemple #34
0
 public Parser( ITokenStream input, RecognizerSharedState state )
     : base( state )
 {
     //super(state); // share the state object with another parser
     TokenStream = input;
 }
 public GDBMILexer(ICharStream input, RecognizerSharedState state)
     : base(input, state)
 {
     InitializeCyclicDFAs();
 }
Exemple #36
0
 public TreeParser( ITreeNodeStream input, RecognizerSharedState state )
     : base( state ) // share the state object with another parser
 {
     SetTreeNodeStream( input );
 }
Exemple #37
0
 public TreeParser(ITreeNodeStream input, RecognizerSharedState state)
     : base(state)   // share the state object with another parser
 {
     this.input = input;
 }
Exemple #38
0
 // share the state object with another parser
 public TreeParser( ITreeNodeStream input, RecognizerSharedState state )
     : base(state)
 {
     this.input = input;
 }
Exemple #39
0
	public TypeSqlLexer(ICharStream input, RecognizerSharedState state)
		: base(input, state)
	{

		OnCreated();
	}
Exemple #40
0
 /** <summary>
  *  Create a normal parser except wrap the token stream in a debug
  *  proxy that fires consume events.
  *  </summary>
  */
 public DebugParser(ITokenStream input, IDebugEventListener dbg, RecognizerSharedState state)
     : base(input is DebugTokenStream ? input : new DebugTokenStream(input, dbg), state) {
     SetDebugListener(dbg);
 }
 public TreeFilter( ITreeNodeStream input, RecognizerSharedState state )
     : base( input, state )
 {
     originalAdaptor = input.TreeAdaptor;
     originalTokenStream = input.TokenStream;
 }
 public FuncProtoToShimLexer(ICharStream input, RecognizerSharedState state)
     : base(input, state)
 {
     OnCreated();
 }
Exemple #43
0
 public FigLeafPasswordRuleLexer(ICharStream input, RecognizerSharedState state)
     : base(input, state)
 {
     OnCreated();
 }
Exemple #44
0
 /** <summary>
  *  Create a normal parser except wrap the token stream in a debug
  *  proxy that fires consume events.
  *  </summary>
  */
 public DebugTreeParser(ITreeNodeStream input, IDebugEventListener dbg, RecognizerSharedState state)
     : base(input is DebugTreeNodeStream ? input : new DebugTreeNodeStream(input, dbg), state)
 {
     SetDebugListener(dbg);
 }
Exemple #45
0
 public virtual void SetState(RecognizerSharedState value)
 {
     this.state = value;
 }
Exemple #46
0
 public AntlrParser(ITokenStream input, RecognizerSharedState state)
     : base(input, state)
 {
 }
Exemple #47
0
 public BaseRecognizer( RecognizerSharedState state )
 {
     if ( state == null )
     {
         state = new RecognizerSharedState();
     }
     this.state = state;
     InitDFAs();
 }
Exemple #48
0
 public SimpleParser(ITokenStream input, RecognizerSharedState state)
     : base(input, state)
 {
     InitializeCyclicDFAs();
 }
Exemple #49
0
 public Lexer( ICharStream input, RecognizerSharedState state ) :
     base( state )
 {
     this.input = input;
 }