Example #1
0
        /// <summary>
        /// Internal entry point
        /// </summary>
        private void internalParseEntryPoint()
        {
            _lexer = new CqlLexer(Query, ParserOptions);
#if ENTITYSQL_PARSER_YYDEBUG
            CqlLexer.Token tk = lexer.yylex();
            while (null != tk)
            {
                Console.WriteLine("{0} := {1}", tk.TokenId, lexer.yytext());
                tk = lexer.yylex();
            }
#endif
            yyparse();
        }
Example #2
0
        private void yyerror(string s)
        {
            if (s.Equals(_internalYaccSyntaxErrorMessage, StringComparison.Ordinal))
            {
                int    errorPosition     = _lexer.IPos;
                string syntaxContextInfo = null;
                string term = _lexer.YYText;
                if (!String.IsNullOrEmpty(term))
                {
                    syntaxContextInfo = System.Data.Entity.Strings.LocalizedTerm;
                    ErrorContext errCtx  = null;
                    Node         astNode = yylval as Node;
                    if (null != astNode && (null != astNode.ErrCtx) && (!String.IsNullOrEmpty(astNode.ErrCtx.ErrorContextInfo)))
                    {
                        errCtx        = astNode.ErrCtx;
                        errorPosition = Math.Min(errorPosition, errorPosition - term.Length);
                    }

                    if ((yylval is CqlLexer.TerminalToken) && CqlLexer.IsReservedKeyword(term) && !(astNode is Identifier))
                    {
                        syntaxContextInfo = System.Data.Entity.Strings.LocalizedKeyword;
                        term          = term.ToUpperInvariant();
                        errorPosition = Math.Min(errorPosition, errorPosition - term.Length);
                    }
                    else if (null != errCtx)
                    {
                        syntaxContextInfo = EntityRes.GetString(errCtx.ErrorContextInfo);
                    }

                    syntaxContextInfo = String.Format(CultureInfo.CurrentCulture, "{0} '{1}'", syntaxContextInfo, term);
                }

                throw EntityUtil.EntitySqlError(_query,
                                                System.Data.Entity.Strings.GenericSyntaxError,
                                                errorPosition,
                                                syntaxContextInfo,
                                                false /* loadErrorContextInfoFromResource */);
            }
            throw EntityUtil.EntitySqlError(_query, s, _lexer.IPos);
        }