Exemplo n.º 1
0
        IEnumerable <Token> NewLexer(string expressionString)
        {
            var baseType = typeof(T);

            if (baseType.IsGenericType)
            {
                baseType = baseType.GetGenericTypeDefinition();
            }

            return(LexerFactory.NewLexer(baseType, expressionString, delegate(ref string s, Token token)
            {
                switch (token.TokenTypeName)
                {
                case "Whitespace":
                case "Whitespace2":
                    return null;

                case "EndOther":
                    s = null;
                    return null;

                case "StartOther":
                    s = "Other";
                    return null;

                case "EOF":
                    if (s == "Other")
                    {
                        return new Token("Error", "Unexpected EOF", token.FromPos, token.ToPos);
                    }

                    return token;

                case "Label":
                    if (s == "Other")
                    {
                        goto case "Label2";
                    }

                    return token;

                case "Label2": return new Token("OtherLabel", token.Value, token.FromPos, token.ToPos);

                default: return token;
                }
            }));
        }
Exemplo n.º 2
0
        IEnumerable <Token> NewLexer(string expressionString)
        {
            var baseType = typeof(T);

            if (baseType.IsGenericType)
            {
                baseType = baseType.GetGenericTypeDefinition();
            }

            return(LexerFactory.NewLexer(baseType, expressionString, delegate(ref string s, Token token)
            {
                switch (token.TokenTypeName)
                {
                case "Whitespace":
                    return null;

                default: return token;
                }
            }));
        }