Skip to content

Commit

Permalink
Use arrayList to make the rules about array better
Browse files Browse the repository at this point in the history
Signed-off-by: Kunlin Yu <[email protected]>
  • Loading branch information
kunlinyu committed Dec 31, 2024
1 parent 6f19f2d commit c0be73f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ set(BISON_FILE ${CMAKE_SOURCE_DIR}/src/cql2_parser.y)
set(BISON_OUTPUT ${CMAKE_BINARY_DIR}/cql2_parser_base.cc)
add_custom_command(
OUTPUT ${BISON_OUTPUT}
COMMAND bison -v -d -o ${BISON_OUTPUT} ${BISON_FILE}
COMMAND bison -v -d -o ${BISON_OUTPUT} ${BISON_FILE} -W -Wcounterexamples
DEPENDS ${BISON_FILE}
COMMENT "Generating ${BISON_OUTPUT} from ${BISON_FILE} using bison"
)
Expand Down
13 changes: 8 additions & 5 deletions src/cql2_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ void cql2cpp::Cql2ParserBase::error(const std::string& msg) {
%type <AstNode*> arrayExpression
%type <AstNode*> array
%type <AstNode*> arrayElement
%type <AstNode*> arrayList
%type <AstNode*> function
%type <AstNode*> argumentList
%type <AstNode*> argument
Expand All @@ -108,7 +109,6 @@ void cql2cpp::Cql2ParserBase::error(const std::string& msg) {

%left PLUS MINUS
%left MULT DIV
%left NOT AND OR

%define parse.trace
%%
Expand Down Expand Up @@ -223,21 +223,24 @@ arrayPredicate:
arrayFunction LPT arrayExpression COMMA arrayExpression RPT { $$ = new AstNode(ArrayPred, NameOp.at($1), {$3, $5}); }

arrayExpression:
LPT RPT { $$ = new AstNode(Array, NullOp, {}); }
array
| propertyName
| function
| LPT array RPT { $$ = $2; }

array:
LPT RPT { $$ = new AstNode(Array, NullOp, {}); }
| LPT arrayList RPT { $$ = $2; }

arrayList:
arrayElement { $$ = new AstNode(Array, NullOp, {$1}); }
| array COMMA arrayElement { $1->append($3); $$ = $1; }
| arrayList COMMA arrayElement { $1->append($3); $$ = $1; }

arrayElement:
characterClause
| numericLiteral
// | temporalInstance
| spatialInstance
// | array // shift/reduce conflict
| array // shift/reduce conflict
// | arithmeticExpression
| booleanExpression
| propertyName
Expand Down

0 comments on commit c0be73f

Please sign in to comment.