Description
Hello,
I am trying to parse the SQLite3 grammar with LALRPOP here.
And some Lemon features do not seem to be avaible with LALRPOP.
Maybe I missed them while reading the documentation.
If they are not supported, it is not really important.
Many thanks for this great parser.
Partial parsing
SQLite parses one command at a time.
The user can choose to ignore the unparsed chunk (pzTail
).
Or choose to parse the next command.
Lemon grammar
cmdx ::= cmd. { sqlite3FinishCoding(pParse); }
For example, if the input is CREATE TABLE test (data); INSERT INTO test VALUES ('');
.
SQLite parses the first statement CREATE TABLE test (data);
and returns the unparsed chunk INSERT INTO test VALUES ('');
.
Fallback
SQLite makes possible to use some keywords without double-quoting them where an identifier is expected.
For example, CREATE TABLE test (view TEXT);
is a valid statement.
The view
keyword becomes a simple identifer.
Lemon grammar
// An IDENTIFIER can be a generic identifier, or one of several
// keywords. Any non-standard keyword can also be an identifier.
//
%token_class id ID|INDEXED.
// The following directive causes tokens ABORT, AFTER, ASC, etc. to
// fallback to ID if they will not parse as their original value.
// This obviates the need for the "id" nonterminal.
//
%fallback ID
ABORT ACTION AFTER ANALYZE ASC ATTACH BEFORE BEGIN BY CASCADE CAST COLUMNKW
CONFLICT DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL FOR
IGNORE IMMEDIATE INITIALLY INSTEAD LIKE_KW MATCH NO PLAN
QUERY KEY OF OFFSET PRAGMA RAISE RECURSIVE RELEASE REPLACE RESTRICT ROW
ROLLBACK SAVEPOINT TEMP TRIGGER VACUUM VIEW VIRTUAL WITH WITHOUT
EXCEPT INTERSECT UNION
REINDEX RENAME CTIME_KW IF
.
Wildcard
Lemon grammar
%wildcard ANY.
https://www.sqlite.org/src/doc/trunk/doc/lemon.html
The %wildcard directive is followed by a single token name and a period. This directive specifies that the identified token should match any input token.
When the generated parser has the choice of matching an input against the wildcard token and some other token, the other token is always used. The wildcard token is only matched if there are no other alternatives.