Ejemplo n.º 1
0
        public void UppercasePluginTest()
        {
            List <IPlugin> _plugins       = (List <IPlugin>)ConfigurationManager.GetSection("plugins");
            StringContext  _stringContext = new StringContext("This is only Rock'n'roll");

            _plugins[0].PerformAction(_stringContext); //Perform operation on data
            Assert.AreEqual("THIS IS ONLY ROCK'N'ROLL", _stringContext.Text);
        }
Ejemplo n.º 2
0
        public void LowercasePluginTest()
        {
            List <IPlugin> _plugins       = (List <IPlugin>)ConfigurationManager.GetSection("plugins");
            StringContext  _stringContext = new StringContext("ART OF FLYING");

            _plugins[1].PerformAction(_stringContext); //Perform operation on data
            Assert.AreEqual("art of flying", _stringContext.Text);
        }
Ejemplo n.º 3
0
        private void ExportMessageID(string outputDir)
        {
            StringContext context = new StringContext();

            context.Add(CONTEXT_SPACE_KEY, exportData.messageConfig.Space);

            ExportMessageID(outputDir, exportData.messageConfig.C2SGroup, context);
            ExportMessageID(outputDir, exportData.messageConfig.S2CGroup, context);

            context.Clear();
        }
Ejemplo n.º 4
0
            public void Invoke(StringContext context)
            {
                var placeList = new List <string> {
                    "广州"
                };

                foreach (var item in placeList)
                {
                    context.Content = context.Content.Replace(item, "***");
                }
            }
Ejemplo n.º 5
0
            public void Invoke(StringContext context)
            {
                var nameList = new List <string> {
                    "小明"
                };

                foreach (var item in nameList)
                {
                    context.Content = context.Content.Replace(item, "***");
                }
                context.IsFinish = true;
            }
Ejemplo n.º 6
0
        public override object VisitString([NotNull] StringContext context)
        {
            if (context.SINGLE_STRING() != null)
            {
                _output.Append(context.SINGLE_STRING());
            }
            else if (context.DOUBLE_STRING() != null)
            {
                _output.Append(context.DOUBLE_STRING());
            }

            return(null);
        }
Ejemplo n.º 7
0
 public override void ExitString([NotNull] StringContext context)
 {
     base.ExitString(context);
     Log("ExitString");
     if (phase == Phase.Building)
     {
         symbolTableCreator.ExitString(context);
     }
     else
     {
         symbolTableTraverser.ExitString(context);
         semanticErrorChecker.ExitString(context);
     }
 }
Ejemplo n.º 8
0
    public StringContext @string()
    {
        StringContext _localctx = new StringContext(Context, State);

        EnterRule(_localctx, 28, RULE_string);
        int _la;

        try {
            EnterOuterAlt(_localctx, 1);
            {
                State = 137; Match(T_ASPAS);
                State = 139;
                ErrorHandler.Sync(this);
                _la = TokenStream.LA(1);
                do
                {
                    {
                        {
                            State = 138;
                            _la   = TokenStream.LA(1);
                            if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NUM) | (1L << LETTER) | (1L << WS))) != 0)))
                            {
                                ErrorHandler.RecoverInline(this);
                            }
                            else
                            {
                                ErrorHandler.ReportMatch(this);
                                Consume();
                            }
                        }
                    }
                    State = 141;
                    ErrorHandler.Sync(this);
                    _la = TokenStream.LA(1);
                } while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NUM) | (1L << LETTER) | (1L << WS))) != 0));
                State = 143; Match(T_ASPAS);
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }
Ejemplo n.º 9
0
        private void ExportMessageID(string outputDir, MessageGroup group, StringContext context)
        {
            context.Add(CONTEXT_MESSAGE_GROUP_KEY, group);

            string outputFilePath = $"{outputDir}/{group.Name}_ID{GetExtension()}";
            string outputContent  = TemplateEngine.Execute(context, exportData.idTemplateContent, new string[] {
                typeof(MessageGroup).Assembly.Location
            });

            if (!string.IsNullOrEmpty(outputContent))
            {
                File.WriteAllText(outputFilePath, outputContent);
            }

            context.Remove(CONTEXT_MESSAGE_GROUP_KEY);
        }
Ejemplo n.º 10
0
            public string DoFilter(string str)
            {
                var context = new StringContext()
                {
                    Content = str
                };

                foreach (var item in _filters)
                {
                    item.Invoke(context);
                    if (context.IsFinish)
                    {
                        return(context.Content);
                    }
                }
                return(context.Content);
            }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            string templateContent =
                @"using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
<%
string spaceName = context.Get<string>(""spaceName"");
string className = context.Get<string>(""className"");
List<int> list = context.Get<List<int>>(""values"");
%>

<%+using System.Collections.Generic;%>
namespace <%=spaceName%>
{
    public class <%=className%>
    {
        public void Print()
        {
            int[] values = {<%foreach(var value in list){%><%=value%>,<%}%>};
            foreach(var value in values)
            {
                Console.WriteLine(value);
            }
        }
    }
}
";
            StringContext context = new StringContext();

            context.Add("spaceName", "Com.Test");
            context.Add("className", "TestClass");
            context.Add("values", new List <int>()
            {
                1, 2, 3, 4, 5, 6
            });

            string output = TemplateEngine.Execute(context, templateContent, null);

            File.WriteAllText("D:/t.cs", output);
        }
Ejemplo n.º 12
0
        public StringContext @string()
        {
            StringContext _localctx = new StringContext(Context, State);

            EnterRule(_localctx, 26, RULE_string);
            try {
                EnterOuterAlt(_localctx, 1);
                {
                    State = 123; Match(String);
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                ErrorHandler.ReportError(this, re);
                ErrorHandler.Recover(this, re);
            }
            finally {
                ExitRule();
            }
            return(_localctx);
        }
Ejemplo n.º 13
0
        private void ExportMessageParser(string outputDir)
        {
            StringContext context = new StringContext();

            context.Add(CONTEXT_SPACE_KEY, exportData.messageConfig.Space);

            if (exportData.platformType == OutputPlatformType.All || exportData.platformType == OutputPlatformType.Client)
            {
                context.Add(CONTEXT_PLATFORM_KEY, "Client");
                ExportMessageParser(outputDir, exportData.messageConfig.C2SGroup, exportData.messageConfig.S2CGroup, context);
                context.Remove(CONTEXT_PLATFORM_KEY);
            }

            if (exportData.platformType == OutputPlatformType.All || exportData.platformType == OutputPlatformType.Server)
            {
                context.Add(CONTEXT_PLATFORM_KEY, "Server");
                ExportMessageParser(outputDir, exportData.messageConfig.S2CGroup, exportData.messageConfig.C2SGroup, context);
                context.Remove(CONTEXT_PLATFORM_KEY);
            }

            context.Clear();
        }
Ejemplo n.º 14
0
        private ExpressionContext expression(int _p)
        {
            ParserRuleContext _parentctx = _ctx;
            int _parentState             = State;
            ExpressionContext _localctx  = new ExpressionContext(_ctx, _parentState);
            ExpressionContext _prevctx   = _localctx;
            int _startState = 2;

            EnterRecursionRule(_localctx, 2, RULE_expression, _p);
            int _la;

            try {
                int _alt;
                EnterOuterAlt(_localctx, 1);
                {
                    State = 27;
                    _errHandler.Sync(this);
                    switch (_input.La(1))
                    {
                    case SHIFT_RIGHT:
                    case SHIFT_LEFT:
                    {
                        _localctx = new ShiftContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;

                        State = 10;
                        ((ShiftContext)_localctx).op = _input.Lt(1);
                        _la = _input.La(1);
                        if (!(_la == SHIFT_RIGHT || _la == SHIFT_LEFT))
                        {
                            ((ShiftContext)_localctx).op = _errHandler.RecoverInline(this);
                        }
                        else
                        {
                            if (_input.La(1) == TokenConstants.Eof)
                            {
                                matchedEOF = true;
                            }

                            _errHandler.ReportMatch(this);
                            Consume();
                        }
                        State = 11; Match(NUMBER);
                        State = 12; expression(6);
                    }
                    break;

                    case UPPER:
                    case LOWER:
                    {
                        _localctx = new CaseContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 13;
                        ((CaseContext)_localctx).op = _input.Lt(1);
                        _la = _input.La(1);
                        if (!(_la == UPPER || _la == LOWER))
                        {
                            ((CaseContext)_localctx).op = _errHandler.RecoverInline(this);
                        }
                        else
                        {
                            if (_input.La(1) == TokenConstants.Eof)
                            {
                                matchedEOF = true;
                            }

                            _errHandler.ReportMatch(this);
                            Consume();
                        }
                        State = 14; expression(5);
                    }
                    break;

                    case SUBSTRING:
                    {
                        _localctx = new SubstringContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 15; Match(SUBSTRING);
                        State     = 16; Match(NUMBER);
                        State     = 19;
                        _errHandler.Sync(this);
                        _la = _input.La(1);
                        if (_la == COMMA)
                        {
                            {
                                State = 17; Match(COMMA);
                                State = 18; Match(NUMBER);
                            }
                        }

                        State = 21; expression(4);
                    }
                    break;

                    case OBRACKET:
                    {
                        _localctx = new BracketsContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 22; Match(OBRACKET);
                        State     = 23; expression(0);
                        State     = 24; Match(CBRACKET);
                    }
                    break;

                    case STRING:
                    {
                        _localctx = new StringContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 26; Match(STRING);
                    }
                    break;

                    default:
                        throw new NoViableAltException(this);
                    }
                    _ctx.stop = _input.Lt(-1);
                    State     = 34;
                    _errHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(_input, 3, _ctx);
                    while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber)
                    {
                        if (_alt == 1)
                        {
                            if (_parseListeners != null)
                            {
                                TriggerExitRuleEvent();
                            }
                            _prevctx = _localctx;
                            {
                                {
                                    _localctx = new Con_diffContext(new ExpressionContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expression);
                                    State = 29;
                                    if (!(Precpred(_ctx, 3)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(_ctx, 3)");
                                    }
                                    State = 30;
                                    ((Con_diffContext)_localctx).op = _input.Lt(1);
                                    _la = _input.La(1);
                                    if (!(_la == CONCANTENATE || _la == DIFFERENCE))
                                    {
                                        ((Con_diffContext)_localctx).op = _errHandler.RecoverInline(this);
                                    }
                                    else
                                    {
                                        if (_input.La(1) == TokenConstants.Eof)
                                        {
                                            matchedEOF = true;
                                        }

                                        _errHandler.ReportMatch(this);
                                        Consume();
                                    }
                                    State = 31; expression(4);
                                }
                            }
                        }
                        State = 36;
                        _errHandler.Sync(this);
                        _alt = Interpreter.AdaptivePredict(_input, 3, _ctx);
                    }
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                _errHandler.ReportError(this, re);
                _errHandler.Recover(this, re);
            }
            finally {
                UnrollRecursionContexts(_parentctx);
            }
            return(_localctx);
        }
Ejemplo n.º 15
0
	private ExprContext expr(int _p) {
		ParserRuleContext _parentctx = Context;
		int _parentState = State;
		ExprContext _localctx = new ExprContext(Context, _parentState);
		ExprContext _prevctx = _localctx;
		int _startState = 12;
		EnterRecursionRule(_localctx, 12, RULE_expr, _p);
		int _la;
		try {
			int _alt;
			EnterOuterAlt(_localctx, 1);
			{
			State = 120;
			ErrorHandler.Sync(this);
			switch ( Interpreter.AdaptivePredict(TokenStream,6,Context) ) {
			case 1:
				{
				_localctx = new Call_methodContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;

				State = 68; Match(ID);
				State = 69; Match(T__3);
				State = 70; args_call();
				State = 71; Match(T__4);
				}
				break;
			case 2:
				{
				_localctx = new IfContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 73; Match(IF);
				State = 74; expr(0);
				State = 75; Match(THEN);
				State = 76; expr(0);
				State = 77; Match(ELSE);
				State = 78; expr(0);
				State = 79; Match(FI);
				}
				break;
			case 3:
				{
				_localctx = new WhileContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 81; Match(WHILE);
				State = 82; expr(0);
				State = 83; Match(LOOP);
				State = 84; expr(0);
				State = 85; Match(POOL);
				}
				break;
			case 4:
				{
				_localctx = new BodyContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 87; Match(T__1);
				State = 88; expr_list();
				State = 89; Match(T__2);
				}
				break;
			case 5:
				{
				_localctx = new New_typeContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 91; Match(NEW);
				State = 92; Match(TYPE);
				}
				break;
			case 6:
				{
				_localctx = new IsvoidContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 93; Match(ISVOID);
				State = 94; expr(12);
				}
				break;
			case 7:
				{
				_localctx = new Unary_expContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 95;
				((Unary_expContext)_localctx).op = TokenStream.LT(1);
				_la = TokenStream.LA(1);
				if ( !(_la==T__16 || _la==NOT) ) {
					((Unary_expContext)_localctx).op = ErrorHandler.RecoverInline(this);
				}
				else {
					ErrorHandler.ReportMatch(this);
				    Consume();
				}
				State = 96; expr(8);
				}
				break;
			case 8:
				{
				_localctx = new ParentesisContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 97; Match(T__3);
				State = 98; expr(0);
				State = 99; Match(T__4);
				}
				break;
			case 9:
				{
				_localctx = new IntContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 101; Match(INTEGER);
				}
				break;
			case 10:
				{
				_localctx = new BoolContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 102;
				((BoolContext)_localctx).cons = TokenStream.LT(1);
				_la = TokenStream.LA(1);
				if ( !(_la==TRUE || _la==FALSE) ) {
					((BoolContext)_localctx).cons = ErrorHandler.RecoverInline(this);
				}
				else {
					ErrorHandler.ReportMatch(this);
				    Consume();
				}
				}
				break;
			case 11:
				{
				_localctx = new StringContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 103; Match(STR);
				}
				break;
			case 12:
				{
				_localctx = new AssignContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 104; Match(ID);
				State = 105; Match(T__6);
				State = 106; expr(3);
				}
				break;
			case 13:
				{
				_localctx = new LetContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 107; Match(LET);
				State = 108; attr();
				State = 113;
				ErrorHandler.Sync(this);
				_la = TokenStream.LA(1);
				while (_la==T__17) {
					{
					{
					State = 109; Match(T__17);
					State = 110; attr();
					}
					}
					State = 115;
					ErrorHandler.Sync(this);
					_la = TokenStream.LA(1);
				}
				State = 116; Match(IN);
				State = 117; expr(2);
				}
				break;
			case 14:
				{
				_localctx = new IdContext(_localctx);
				Context = _localctx;
				_prevctx = _localctx;
				State = 119; Match(ID);
				}
				break;
			}
			Context.Stop = TokenStream.LT(-1);
			State = 144;
			ErrorHandler.Sync(this);
			_alt = Interpreter.AdaptivePredict(TokenStream,9,Context);
			while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) {
				if ( _alt==1 ) {
					if ( ParseListeners!=null )
						TriggerExitRuleEvent();
					_prevctx = _localctx;
					{
					State = 142;
					ErrorHandler.Sync(this);
					switch ( Interpreter.AdaptivePredict(TokenStream,8,Context) ) {
					case 1:
						{
						_localctx = new MultdivContext(new ExprContext(_parentctx, _parentState));
						PushNewRecursionContext(_localctx, _startState, RULE_expr);
						State = 122;
						if (!(Precpred(Context, 11))) throw new FailedPredicateException(this, "Precpred(Context, 11)");
						State = 123;
						((MultdivContext)_localctx).op = TokenStream.LT(1);
						_la = TokenStream.LA(1);
						if ( !(_la==T__9 || _la==T__10) ) {
							((MultdivContext)_localctx).op = ErrorHandler.RecoverInline(this);
						}
						else {
							ErrorHandler.ReportMatch(this);
						    Consume();
						}
						State = 124; expr(12);
						}
						break;
					case 2:
						{
						_localctx = new SumarestaContext(new ExprContext(_parentctx, _parentState));
						PushNewRecursionContext(_localctx, _startState, RULE_expr);
						State = 125;
						if (!(Precpred(Context, 10))) throw new FailedPredicateException(this, "Precpred(Context, 10)");
						State = 126;
						((SumarestaContext)_localctx).op = TokenStream.LT(1);
						_la = TokenStream.LA(1);
						if ( !(_la==T__11 || _la==T__12) ) {
							((SumarestaContext)_localctx).op = ErrorHandler.RecoverInline(this);
						}
						else {
							ErrorHandler.ReportMatch(this);
						    Consume();
						}
						State = 127; expr(11);
						}
						break;
					case 3:
						{
						_localctx = new CompContext(new ExprContext(_parentctx, _parentState));
						PushNewRecursionContext(_localctx, _startState, RULE_expr);
						State = 128;
						if (!(Precpred(Context, 9))) throw new FailedPredicateException(this, "Precpred(Context, 9)");
						State = 129;
						((CompContext)_localctx).op = TokenStream.LT(1);
						_la = TokenStream.LA(1);
						if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__13) | (1L << T__14) | (1L << T__15))) != 0)) ) {
							((CompContext)_localctx).op = ErrorHandler.RecoverInline(this);
						}
						else {
							ErrorHandler.ReportMatch(this);
						    Consume();
						}
						State = 130; expr(10);
						}
						break;
					case 4:
						{
						_localctx = new DispatchContext(new ExprContext(_parentctx, _parentState));
						PushNewRecursionContext(_localctx, _startState, RULE_expr);
						State = 131;
						if (!(Precpred(Context, 18))) throw new FailedPredicateException(this, "Precpred(Context, 18)");
						State = 134;
						ErrorHandler.Sync(this);
						_la = TokenStream.LA(1);
						if (_la==T__7) {
							{
							State = 132; Match(T__7);
							State = 133; Match(TYPE);
							}
						}

						State = 136; Match(T__8);
						State = 137; Match(ID);
						State = 138; Match(T__3);
						State = 139; args_call();
						State = 140; Match(T__4);
						}
						break;
					}
					} 
				}
				State = 146;
				ErrorHandler.Sync(this);
				_alt = Interpreter.AdaptivePredict(TokenStream,9,Context);
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			UnrollRecursionContexts(_parentctx);
		}
		return _localctx;
	}
Ejemplo n.º 16
0
        private ExprContext expr(int _p)
        {
            ParserRuleContext _parentctx = Context;
            int         _parentState     = State;
            ExprContext _localctx        = new ExprContext(Context, _parentState);
            ExprContext _prevctx         = _localctx;
            int         _startState      = 2;

            EnterRecursionRule(_localctx, 2, RULE_expr, _p);
            int _la;

            try {
                int _alt;
                EnterOuterAlt(_localctx, 1);
                {
                    State = 34;
                    ErrorHandler.Sync(this);
                    switch (Interpreter.AdaptivePredict(TokenStream, 2, Context))
                    {
                    case 1:
                    {
                        _localctx = new UnaryContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;

                        State = 9;
                        ((UnaryContext)_localctx).sign = TokenStream.LT(1);
                        _la = TokenStream.LA(1);
                        if (!(_la == T__2 || _la == T__3))
                        {
                            ((UnaryContext)_localctx).sign = ErrorHandler.RecoverInline(this);
                        }
                        else
                        {
                            ErrorHandler.ReportMatch(this);
                            Consume();
                        }
                        State = 10; expr(16);
                    }
                    break;

                    case 2:
                    {
                        _localctx = new ParenthesisContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;
                        State     = 11; Match(T__14);
                        State     = 12; expr(0);
                        State     = 13; Match(T__15);
                    }
                    break;

                    case 3:
                    {
                        _localctx = new FunctionContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;
                        State     = 15; ((FunctionContext)_localctx).name = Match(NAME);
                        State     = 16; Match(T__14);
                        State     = 25;
                        ErrorHandler.Sync(this);
                        _la = TokenStream.LA(1);
                        if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__2) | (1L << T__3) | (1L << T__14) | (1L << STRING) | (1L << CELLREF) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME) | (1L << ERROR))) != 0))
                        {
                            {
                                State = 17; expr(0);
                                State = 22;
                                ErrorHandler.Sync(this);
                                _la = TokenStream.LA(1);
                                while (_la == T__16)
                                {
                                    {
                                        {
                                            State = 18; Match(T__16);
                                            State = 19; expr(0);
                                        }
                                    }
                                    State = 24;
                                    ErrorHandler.Sync(this);
                                    _la = TokenStream.LA(1);
                                }
                            }
                        }

                        State = 27; Match(T__15);
                    }
                    break;

                    case 4:
                    {
                        _localctx = new StringContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;
                        State     = 28; Match(STRING);
                    }
                    break;

                    case 5:
                    {
                        _localctx = new CellRefContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;
                        State     = 29; Match(CELLREF);
                    }
                    break;

                    case 6:
                    {
                        _localctx = new BooleanContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;
                        State     = 30; Match(BOOLEAN);
                    }
                    break;

                    case 7:
                    {
                        _localctx = new NumberContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;
                        State     = 31; Match(NUMBER);
                    }
                    break;

                    case 8:
                    {
                        _localctx = new NameContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;
                        State     = 32; Match(NAME);
                    }
                    break;

                    case 9:
                    {
                        _localctx = new ErrorContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;
                        State     = 33; Match(ERROR);
                    }
                    break;
                    }
                    Context.Stop = TokenStream.LT(-1);
                    State        = 61;
                    ErrorHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(TokenStream, 4, Context);
                    while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER)
                    {
                        if (_alt == 1)
                        {
                            if (ParseListeners != null)
                            {
                                TriggerExitRuleEvent();
                            }
                            _prevctx = _localctx;
                            {
                                State = 59;
                                ErrorHandler.Sync(this);
                                switch (Interpreter.AdaptivePredict(TokenStream, 3, Context))
                                {
                                case 1:
                                {
                                    _localctx = new RangeContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 36;
                                    if (!(Precpred(Context, 17)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(Context, 17)");
                                    }
                                    State = 37; Match(T__1);
                                    State = 38; expr(18);
                                }
                                break;

                                case 2:
                                {
                                    _localctx = new PowContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 39;
                                    if (!(Precpred(Context, 14)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(Context, 14)");
                                    }
                                    State = 40; Match(T__5);
                                    State = 41; expr(15);
                                }
                                break;

                                case 3:
                                {
                                    _localctx = new MulDivContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 42;
                                    if (!(Precpred(Context, 13)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(Context, 13)");
                                    }
                                    State = 43;
                                    ((MulDivContext)_localctx).op = TokenStream.LT(1);
                                    _la = TokenStream.LA(1);
                                    if (!(_la == T__6 || _la == T__7))
                                    {
                                        ((MulDivContext)_localctx).op = ErrorHandler.RecoverInline(this);
                                    }
                                    else
                                    {
                                        ErrorHandler.ReportMatch(this);
                                        Consume();
                                    }
                                    State = 44; expr(14);
                                }
                                break;

                                case 4:
                                {
                                    _localctx = new AddSubContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 45;
                                    if (!(Precpred(Context, 12)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(Context, 12)");
                                    }
                                    State = 46;
                                    ((AddSubContext)_localctx).op = TokenStream.LT(1);
                                    _la = TokenStream.LA(1);
                                    if (!(_la == T__2 || _la == T__3))
                                    {
                                        ((AddSubContext)_localctx).op = ErrorHandler.RecoverInline(this);
                                    }
                                    else
                                    {
                                        ErrorHandler.ReportMatch(this);
                                        Consume();
                                    }
                                    State = 47; expr(13);
                                }
                                break;

                                case 5:
                                {
                                    _localctx = new ConcatenateContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 48;
                                    if (!(Precpred(Context, 11)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(Context, 11)");
                                    }
                                    State = 49; Match(T__8);
                                    State = 50; expr(12);
                                }
                                break;

                                case 6:
                                {
                                    _localctx = new EqualityContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 51;
                                    if (!(Precpred(Context, 10)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(Context, 10)");
                                    }
                                    State = 52;
                                    ((EqualityContext)_localctx).op = TokenStream.LT(1);
                                    _la = TokenStream.LA(1);
                                    if (!(_la == T__0 || _la == T__9))
                                    {
                                        ((EqualityContext)_localctx).op = ErrorHandler.RecoverInline(this);
                                    }
                                    else
                                    {
                                        ErrorHandler.ReportMatch(this);
                                        Consume();
                                    }
                                    State = 53; expr(11);
                                }
                                break;

                                case 7:
                                {
                                    _localctx = new RelationalContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 54;
                                    if (!(Precpred(Context, 9)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(Context, 9)");
                                    }
                                    State = 55;
                                    ((RelationalContext)_localctx).op = TokenStream.LT(1);
                                    _la = TokenStream.LA(1);
                                    if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13))) != 0)))
                                    {
                                        ((RelationalContext)_localctx).op = ErrorHandler.RecoverInline(this);
                                    }
                                    else
                                    {
                                        ErrorHandler.ReportMatch(this);
                                        Consume();
                                    }
                                    State = 56; expr(10);
                                }
                                break;

                                case 8:
                                {
                                    _localctx = new PercentageContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 57;
                                    if (!(Precpred(Context, 15)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(Context, 15)");
                                    }
                                    State = 58; Match(T__4);
                                }
                                break;
                                }
                            }
                        }
                        State = 63;
                        ErrorHandler.Sync(this);
                        _alt = Interpreter.AdaptivePredict(TokenStream, 4, Context);
                    }
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                ErrorHandler.ReportError(this, re);
                ErrorHandler.Recover(this, re);
            }
            finally {
                UnrollRecursionContexts(_parentctx);
            }
            return(_localctx);
        }
 public override ASTN VisitString([NotNull] StringContext context) => new StringNode(context, context.GetText());
Ejemplo n.º 18
0
 public override SymbolBase VisitString([NotNull] StringContext context) =>
 new StringSymbol(context.GetText());
Ejemplo n.º 19
0
 public AstLiteralString(StringContext context)
     : base(AstNodeKind.Literal)
 {
     Context = context;
     Value   = Parse(context.STRING().GetText());
 }
Ejemplo n.º 20
0
        private void ExportMessageParser(string outputDir, MessageGroup encodeGroup, MessageGroup decodeGroup, StringContext context)
        {
            context.Add(CONTEXT_ENCODE_MESSAGE_GROUP_KEY, encodeGroup);
            context.Add(CONTEXT_DECODE_MESSAGE_GROUP_KEY, decodeGroup);

            string outputFilePath = $"{outputDir}/{context.Get<string>(CONTEXT_PLATFORM_KEY)}MessageParser{GetExtension()}";
            string outputContent  = TemplateEngine.Execute(context, exportData.parserTemplateContent, new string[] {
                typeof(MessageConfig).Assembly.Location
            });

            if (!string.IsNullOrEmpty(outputContent))
            {
                File.WriteAllText(outputFilePath, outputContent);
            }

            context.Remove(CONTEXT_ENCODE_MESSAGE_GROUP_KEY);
            context.Remove(CONTEXT_DECODE_MESSAGE_GROUP_KEY);
        }
Ejemplo n.º 21
0
        public override void EnterString([NotNull] StringContext context)
        {
            string value = context.STRING_LITERAL().GetText().Replace("\"", "");

            this.Result.Insert(new ConstStringExpression(Result, context, value));
        }
Ejemplo n.º 22
0
 private HiddenData Create_HiddenData_from_string_context(StringContext context)
 {
     _expectedId = Reflection.GetPropertyName(() => context.Value).ToCamelCase();
     _expectedName = _expectedId;
     _expectedValue = context.Value;
     return Hidden.For(context, x => x.Value.ToString(), x => x.Value);
 }
Ejemplo n.º 23
0
 public override object VisitString([NotNull] StringContext context) => context.GetText().Substring(1, context.GetText().Length - 2);
Ejemplo n.º 24
0
	public StringContext @string() {
		StringContext _localctx = new StringContext(Context, State);
		EnterRule(_localctx, 162, RULE_string);
		int _la;
		try {
			EnterOuterAlt(_localctx, 1);
			{
			State = 1046;
			_la = TokenStream.La(1);
			if ( !(_la==STRING_LITERAL || _la==BYTES_LITERAL) ) {
			ErrorHandler.RecoverInline(this);
			}
			else {
			    Consume();
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}