From 86080232bf42e167513eb608330d5dffc401b24e Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 25 Apr 2024 13:11:24 +0530 Subject: [PATCH] fixed lexer grammar --- .../io/nosqlbench/cqlgen/grammars/CqlLexer.g4 | 12 +++++++++++ .../nosqlbench/cqlgen/grammars/CqlParser.g4 | 20 ++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/nb-adapters/adapter-cqld4/src/main/java/io/nosqlbench/cqlgen/grammars/CqlLexer.g4 b/nb-adapters/adapter-cqld4/src/main/java/io/nosqlbench/cqlgen/grammars/CqlLexer.g4 index 154a6e97a..8e6017059 100644 --- a/nb-adapters/adapter-cqld4/src/main/java/io/nosqlbench/cqlgen/grammars/CqlLexer.g4 +++ b/nb-adapters/adapter-cqld4/src/main/java/io/nosqlbench/cqlgen/grammars/CqlLexer.g4 @@ -123,6 +123,7 @@ K_ROLE: 'ROLE'; K_ROLES: 'ROLES'; K_SCHEMA: 'SCHEMA'; K_SELECT: 'SELECT'; +K_SET_WITH_OPERATOR_LT: K_SET SPACE? OPERATOR_LT -> pushMode(IDENTIFIER_MODE); K_SET: 'SET' -> pushMode(IDENTIFIER_MODE); K_SFUNC: 'SFUNC'; K_STATIC: 'STATIC'; @@ -131,6 +132,7 @@ K_STYPE: 'STYPE'; K_SUPERUSER: 'SUPERUSER'; K_TABLE: 'TABLE' -> pushMode(IDENTIFIER_MODE); K_THREE: 'THREE'; +K_TIMESTAMP_WITH_DECIMAL_LITERAL: K_TIMESTAMP SPACE DECIMAL_LITERAL; K_TIMESTAMP: 'TIMESTAMP'; K_TO: 'TO' -> pushMode(IDENTIFIER_MODE); K_TOKEN: 'TOKEN'; @@ -160,10 +162,13 @@ K_DATE: 'DATE'; K_DECIMAL: 'DECIMAL'; K_DOUBLE: 'DOUBLE'; K_FLOAT: 'FLOAT'; +K_FROZEN_WITH_OPERATOR_LT: K_FROZEN SPACE? OPERATOR_LT -> pushMode(IDENTIFIER_MODE); K_FROZEN: 'FROZEN'; K_INET: 'INET'; K_INT: 'INT'; +K_LIST_WITH_OPERATOR_LT: K_LIST SPACE? OPERATOR_LT -> pushMode(IDENTIFIER_MODE); K_LIST: 'LIST'; +K_MAP_WITH_OPERATOR_LT: K_MAP SPACE? OPERATOR_LT -> pushMode(IDENTIFIER_MODE); K_MAP: 'MAP'; K_SMALLINT: 'SMALLINT'; K_TEXT: 'TEXT'; @@ -297,6 +302,13 @@ K_USING_: K_USING -> type(K_USING), popMode; K_WHERE_: K_WHERE -> type(K_WHERE), popMode; K_WITH_: K_WITH -> type(K_WITH), popMode; +// handeling cases like 'frozen<','map<','list<','set<' and 'TIMETAMP WITH 1234' +K_MAP_WITH_OPERATOR_LT_: K_MAP_WITH_OPERATOR_LT -> type(K_MAP_WITH_OPERATOR_LT); +K_TIMESTAMP_WITH_DECIMAL_LITERAL_: K_TIMESTAMP_WITH_DECIMAL_LITERAL -> type(K_TIMESTAMP_WITH_DECIMAL_LITERAL); +K_FROZEN_WITH_OPERATOR_LT_: K_FROZEN_WITH_OPERATOR_LT -> type(K_FROZEN_WITH_OPERATOR_LT); +K_SET_WITH_OPERATOR_LT_: K_SET_WITH_OPERATOR_LT -> type(K_SET_WITH_OPERATOR_LT); +K_LIST_WITH_OPERATOR_LT_: K_LIST_WITH_OPERATOR_LT -> type(K_LIST_WITH_OPERATOR_LT); + OBJECT_NAME_ : OBJECT_NAME -> type(OBJECT_NAME), popMode; SPACE_: [ \t\r\n]+ -> channel (HIDDEN); diff --git a/nb-adapters/adapter-cqld4/src/main/java/io/nosqlbench/cqlgen/grammars/CqlParser.g4 b/nb-adapters/adapter-cqld4/src/main/java/io/nosqlbench/cqlgen/grammars/CqlParser.g4 index 23e8a135c..6103b5723 100644 --- a/nb-adapters/adapter-cqld4/src/main/java/io/nosqlbench/cqlgen/grammars/CqlParser.g4 +++ b/nb-adapters/adapter-cqld4/src/main/java/io/nosqlbench/cqlgen/grammars/CqlParser.g4 @@ -615,7 +615,7 @@ usingTtlTimestamp ; timestamp - : kwTimestamp decimalLiteral + : K_TIMESTAMP_WITH_DECIMAL_LITERAL ; ttl @@ -767,7 +767,6 @@ stringLiteral booleanLiteral : K_TRUE | K_FALSE - | OBJECT_NAME ; hexadecimalLiteral @@ -791,10 +790,10 @@ column dataType : dataTypeName - | kwFrozen syntaxBracketLa dataType syntaxBracketRa - | K_SET syntaxBracketLa dataType syntaxBracketRa - | K_LIST syntaxBracketLa dataType syntaxBracketRa - | K_MAP syntaxBracketLa dataType syntaxComma dataType syntaxBracketRa + | K_FROZEN_WITH_OPERATOR_LT dataType syntaxBracketRa + | K_SET_WITH_OPERATOR_LT dataType syntaxBracketRa + | K_LIST_WITH_OPERATOR_LT dataType syntaxBracketRa + | K_MAP_WITH_OPERATOR_LT dataType syntaxComma dataType syntaxBracketRa ; dataTypeName @@ -814,7 +813,7 @@ dataTypeName | K_INET | K_INT | K_LIST - | K_MAP +// | K_MAP | K_SMALLINT | K_TEXT | K_TIME @@ -917,11 +916,6 @@ kwAlter : K_ALTER ; -kwFrozen - : K_FROZEN - | OBJECT_NAME - ; - kwAnd : K_AND ; @@ -1108,7 +1102,6 @@ kwLogged kwLogin : K_LOGIN - | OBJECT_NAME ; kwMaterialized @@ -1217,7 +1210,6 @@ kwTable kwTimestamp : K_TIMESTAMP - | OBJECT_NAME ; kwTo