Open KvanTTT opened 4 years ago
Also, take a look at this text in the official doc:
Reserved words can never be used as identifiers. Keywords can be used as identifiers, but this is not recommended.
It means that "Reserved Words" can not be regular_id
at all, "Keywords" can be.
But even so, a lot for keywords remains. And I'm suggesting not to introduce a token if it is used only at one time.
Remove excess keywords
Remove keywords from the lexer that are not presented in the official doc: https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/reservewords.htm and replace artificial keywords with context keywords.
For instance, consider the lexer rule
AUTONOMOUS_TRANSACTION
. Remove it from lexer:Replace this construction:
with the following:
where
p
is defined as follows inPlSqlParserBase.cs
:Also, if you want to distinguish context keywords and identifiers, you can use rule element labels:
I know, this is too excessively, but the feature for token value comparison is not implemented yet.
We've implemented the same approach for JavaScript.
Remove excess parse rules
Get rid of excess parsing rules. For instance, in the following case:
Rules
partition_name_old
andpartition_name
can be replaced withregular_id
and removed.Such optimizations (especially the first one) should significantly decrease the size of generated parse and maybe improve performance. Out of curiosity, check the size before and after and write about results here.
/cc @codeFather2