Hi, 

I'd like to know how can I define reserved word in a Perl6 grammar. 

If you have a look at 
https://gist.github.com/anonymous/2c04533cb3a61a00b8822ea20237ba7e , you will 
find a small perl grammar for parsing from clause of sql statement. 

The issue is when I execute this testcase that the from clause cannot be parse 
correctly when there is no alias for the last table of the from clause as the 
"where" keyword is recognize as the alias ... 
The tracer shows very well the issue. 

TEST 
| from 
| | selectedtable 
| | | shema_name 
| | | | identifier 
| | | | * MATCH "table1" 
| | | * MATCH "table1" 
| | | tablename 
| | | | identifier 
| | | | * MATCH "table1" 
| | | * MATCH "table1" 
| | | alias 
| | | | identifier 
| | | | * FAIL 
| | | * FAIL 
| | * MATCH "table1 " 
| | selectedtable 
| | | shema_name 
| | | | identifier 
| | | | * MATCH "table2" 
| | | * MATCH "table2" 
| | | tablename 
| | | | identifier 
| | | | * MATCH "table2" 
| | | * MATCH "table2" 
| | | alias 
| | | | identifier 
| | | | * MATCH "WHERE" 
| | | * MATCH "WHERE" 
| | * MATCH "table2 WHERE " 
| * MATCH "FROM table1 ,table2 WHERE " 
| where 
| * FAIL 
* FAIL 
Nil 

So I'd like to defined "where" as a reserved word. Doing so, the alias cannot 
be evaluate as "where". Unfortunately, I didn't find the way to do it. So, I'll 
appreciate any suggestion. 

( I know that another solution could be to use backtracking in regex, but I'd 
like to be able to compare the two solutions. ) 

I hope my question is clear enough, feel free to ask clarifications if needed. 
Many thanks for your help. 

Best Regards, 
Jean-Pierre 

Reply via email to