Closed 8150133 closed 3 years ago
I'm creating a jison grammar
I want that everytime user types for example List the parser returns Match because this is some king of database query generator...for example:
List Contracts Where C.price Lesser 500 Return C.price, EntityE.name
And then the parser should return me:
MATCH (E1:ENTIDADE)-[C:CONTRATO]->(E2:ENTIDADE) WHERE C.price < 500 RETURN C.price, E1.name
So far, this is my jison file:
/* lexical grammar */ %lex %% \s+ /* skip whitespace */ List return 'MATCH' Contracts return '(E1:ENTIDADE)-[C:CONTRATO]->(E2:ENTIDADE)' Where return 'WHERE' EntityE return 'E1' EntityA return 'E2' Contract return 'C' . return '.' Equals return '=' Contains return 'CONTAINS' Between return 'BETWEEN' Greater return '>' Lesser return '<' AND return 'AND' OR return 'OR' Return return 'RETURN' ; return 'ENDRULE' <<EOF>> return 'EOF' /lex %start expressions %% expressions : rule {$$ = $1 console.log("rule: " + $$)} ; rule: List Contracts Where { $$ = $1 + " " + $2 + " " + $3 + " " } ;
Am i doing it the right way?
I'm creating a jison grammar
I want that everytime user types for example List the parser returns Match because this is some king of database query generator...for example:
And then the parser should return me:
So far, this is my jison file:
Am i doing it the right way?