示例#1
0
        public ArgContext arg()
        {
            ArgContext _localctx = new ArgContext(_ctx, State);

            EnterRule(_localctx, 8, RULE_arg);
            int _la;

            try {
                int _alt;
                EnterOuterAlt(_localctx, 1);
                {
                    State = 50; Match(WORD);
                    State = 59;
                    _errHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(_input, 7, _ctx);
                    while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber)
                    {
                        if (_alt == 1)
                        {
                            {
                                {
                                    State = 52;
                                    _errHandler.Sync(this);
                                    _la = _input.La(1);
                                    do
                                    {
                                        {
                                            {
                                                State = 51; Match(SPACE);
                                            }
                                        }
                                        State = 54;
                                        _errHandler.Sync(this);
                                        _la = _input.La(1);
                                    } while (_la == SPACE);
                                    State = 56; Match(WORD);
                                }
                            }
                        }
                        State = 61;
                        _errHandler.Sync(this);
                        _alt = Interpreter.AdaptivePredict(_input, 7, _ctx);
                    }
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                _errHandler.ReportError(this, re);
                _errHandler.Recover(this, re);
            }
            finally {
                ExitRule();
            }
            return(_localctx);
        }
示例#2
0
        public void ArgStringSingleQuoteTest()
        {
            ShellParser  shellParser = MakeParser("'string arg'");
            ArgContext   context     = shellParser.arg();
            ShellVisitor visitor     = new ShellVisitor();

            ParserResult result = visitor.Visit(context);

            result.IsArg.Should().BeTrue();
            result.ArgValue.Should().Be("string arg");
        }
示例#3
0
        public void ArgStringPipeTest()
        {
            ShellParser  shellParser = MakeParser("\"12345 | echo asdf\"");
            ArgContext   context     = shellParser.arg();
            ShellVisitor visitor     = new ShellVisitor();

            ParserResult result = visitor.Visit(context);

            result.IsArg.Should().BeTrue();
            result.ArgValue.Should().Be("12345 | echo asdf");
        }
示例#4
0
        public void ArgWordTest()
        {
            ShellParser  shellParser = MakeParser("wordarg");
            ArgContext   context     = shellParser.arg();
            ShellVisitor visitor     = new ShellVisitor();

            ParserResult result = visitor.Visit(context);

            result.IsArg.Should().BeTrue();
            result.ArgValue.Should().Be("wordarg");
        }
示例#5
0
        public override ParserResult VisitArg([NotNull] ArgContext context)
        {
            if (context.STRING() != null)
            {
                string parsedString = context.STRING().GetText();
                parsedString = parsedString.Substring(1, parsedString.Length - 2);

                ParserResult result = new ParserResult(parsedString);
                result.IsArg = true;

                return(result);
            }
            else
            {
                ParserResult result = new ParserResult(context.WORD().GetText());
                result.IsArg = true;

                return(result);
            }
        }
示例#6
0
	public ArgContext arg() {
		ArgContext _localctx = new ArgContext(Context, State);
		EnterRule(_localctx, 250, RULE_arg);
		int _la;
		try {
			EnterOuterAlt(_localctx, 1);
			{
			State = 2558;
			switch ( Interpreter.AdaptivePredict(TokenStream,422,Context) ) {
			case 1:
				{
				State = 2556; Match(OPTIONAL);
				State = 2557; Match(WS);
				}
				break;
			}
			State = 2562;
			switch ( Interpreter.AdaptivePredict(TokenStream,423,Context) ) {
			case 1:
				{
				State = 2560;
				_la = TokenStream.La(1);
				if ( !(_la==BYVAL || _la==BYREF) ) {
				ErrorHandler.RecoverInline(this);
				}
				else {
				    Consume();
				}
				State = 2561; Match(WS);
				}
				break;
			}
			State = 2566;
			switch ( Interpreter.AdaptivePredict(TokenStream,424,Context) ) {
			case 1:
				{
				State = 2564; Match(PARAMARRAY);
				State = 2565; Match(WS);
				}
				break;
			}
			State = 2568; ambiguousIdentifier();
			State = 2577;
			switch ( Interpreter.AdaptivePredict(TokenStream,427,Context) ) {
			case 1:
				{
				State = 2570;
				_la = TokenStream.La(1);
				if (_la==WS) {
					{
					State = 2569; Match(WS);
					}
				}

				State = 2572; Match(LPAREN);
				State = 2574;
				_la = TokenStream.La(1);
				if (_la==WS) {
					{
					State = 2573; Match(WS);
					}
				}

				State = 2576; Match(RPAREN);
				}
				break;
			}
			State = 2581;
			switch ( Interpreter.AdaptivePredict(TokenStream,428,Context) ) {
			case 1:
				{
				State = 2579; Match(WS);
				State = 2580; asTypeClause();
				}
				break;
			}
			State = 2587;
			switch ( Interpreter.AdaptivePredict(TokenStream,430,Context) ) {
			case 1:
				{
				State = 2584;
				_la = TokenStream.La(1);
				if (_la==WS) {
					{
					State = 2583; Match(WS);
					}
				}

				State = 2586; argDefaultValue();
				}
				break;
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}
示例#7
0
	public ArgContext arg() {
		ArgContext _localctx = new ArgContext(Context, State);
		EnterRule(_localctx, 14, RULE_arg);
		try {
			EnterOuterAlt(_localctx, 1);
			{
			State = 94;
			ErrorHandler.Sync(this);
			switch ( Interpreter.AdaptivePredict(TokenStream,5,Context) ) {
			case 1:
				{
				State = 87; register();
				}
				break;
			case 2:
				{
				State = 88; value();
				}
				break;
			case 3:
				{
				State = 89; negvalue();
				}
				break;
			case 4:
				{
				State = 90; flag();
				}
				break;
			case 5:
				{
				State = 91; offset();
				}
				break;
			case 6:
				{
				State = 92; jump();
				}
				break;
			case 7:
				{
				State = 93; memory();
				}
				break;
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}