Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create jison grammar #393

Closed
8150133 opened this issue Sep 14, 2020 · 0 comments
Closed

Create jison grammar #393

8150133 opened this issue Sep 14, 2020 · 0 comments

Comments

@8150133
Copy link

8150133 commented Sep 14, 2020

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?

@8150133 8150133 changed the title Could not parse jison grammar Create jison grammar Sep 14, 2020
@8150133 8150133 closed this as completed Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant