mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
grammar: Fix parsing of complex expression
This fixes parsing of expressions of the form '(x) AND/OR y' and similar types. It also fixes expression of the '(x)' type and of the '(x op y AND z op w)' type. See issue #1454.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $ANTLR 2.7.7 (20160127): "sqlite3.g" -> "Sqlite3Lexer.cpp"$ */
|
||||
/* $ANTLR 2.7.7 (20171109): "sqlite3.g" -> "Sqlite3Lexer.cpp"$ */
|
||||
#include "Sqlite3Lexer.hpp"
|
||||
#include <antlr/CharBuffer.hpp>
|
||||
#include <antlr/TokenStreamException.hpp>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define INC_Sqlite3Lexer_hpp_
|
||||
|
||||
#include <antlr/config.hpp>
|
||||
/* $ANTLR 2.7.7 (20160127): "sqlite3.g" -> "Sqlite3Lexer.hpp"$ */
|
||||
/* $ANTLR 2.7.7 (20171109): "sqlite3.g" -> "Sqlite3Lexer.hpp"$ */
|
||||
#include <antlr/CommonToken.hpp>
|
||||
#include <antlr/InputBuffer.hpp>
|
||||
#include <antlr/BitSet.hpp>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
#define INC_Sqlite3Parser_hpp_
|
||||
|
||||
#include <antlr/config.hpp>
|
||||
/* $ANTLR 2.7.7 (20160127): "sqlite3.g" -> "Sqlite3Parser.hpp"$ */
|
||||
/* $ANTLR 2.7.7 (20171109): "sqlite3.g" -> "Sqlite3Parser.hpp"$ */
|
||||
#include <antlr/TokenStream.hpp>
|
||||
#include <antlr/TokenBuffer.hpp>
|
||||
#include "sqlite3TokenTypes.hpp"
|
||||
|
||||
@@ -431,7 +431,8 @@ functionname
|
||||
|
||||
expr
|
||||
:
|
||||
( LPAREN subexpr (COMMA subexpr)+ RPAREN binaryoperator LPAREN subexpr (COMMA subexpr)+ RPAREN )
|
||||
( LPAREN expr RPAREN ((AND | OR) expr)* )
|
||||
| ( LPAREN subexpr (COMMA subexpr)+ RPAREN binaryoperator LPAREN subexpr (COMMA subexpr)+ RPAREN )
|
||||
| ( subexpr ((binaryoperator | AND | OR) subexpr )* )
|
||||
;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef INC_sqlite3TokenTypes_hpp_
|
||||
#define INC_sqlite3TokenTypes_hpp_
|
||||
|
||||
/* $ANTLR 2.7.7 (20160127): "sqlite3.g" -> "sqlite3TokenTypes.hpp"$ */
|
||||
/* $ANTLR 2.7.7 (20171109): "sqlite3.g" -> "sqlite3TokenTypes.hpp"$ */
|
||||
|
||||
#ifndef CUSTOM_API
|
||||
# define CUSTOM_API
|
||||
|
||||
@@ -945,7 +945,10 @@ TablePtr CreateTableWalker::table()
|
||||
if(num_paren == 0)
|
||||
break;
|
||||
|
||||
expr.append(textAST(tc));
|
||||
if(tc->getType() == sqlite3TokenTypes::AND || tc->getType() == sqlite3TokenTypes::OR)
|
||||
expr.append(" " + textAST(tc) + " ");
|
||||
else
|
||||
expr.append(textAST(tc));
|
||||
|
||||
tc = tc->getNextSibling();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user