|
|
|
Re: Antlr Error with grammar [message #1733001 is a reply to message #1732997] |
Mon, 23 May 2016 16:40 |
|
Hi,
this grammar has multiple problems.
first of all there are keywords that occurr more than once in a KEYWORDXX rule.
what should be parsed in that case.
then you have the problem that you have the pattern
list+=Element*
Element: parts+=Part+;
if you have part1 part2 part3 should hat give 1 element with 3 parts or 3 elements with 1 part?
another pattern you have is to have
plId+=JPLID in DbmsStmt and in DbmsAssign where should it go to?
you have to decide
DbmsStatement:
'dbms' DbmsStmt;
DbmsStmt:
(
(DbmsAssign+=DbmsAssign) |
((=>jplId+=JPLID) (DbmsCommomn+=DbmsCommomn)) |
((=>DbmsKeys+=DbmsKeys) (DbmsCommomn+=DbmsCommomn)?)
)+;
DbmsAssign:
((jplId+=(JPLID | DbmsKeys) (',' jplId+=(JPLID | DbmsKeys))*)
(('=' | '==') (((DbmsDataTypes+=DbmsDataTypes) | (dbmsDecl+=DbmsDecl)) | ('(' DbmsStmt+=DbmsStmt ')')) (',')?)*);
DbmsDecl:
dbmsKeys+=DbmsKeys ('(' DbmsDataTypes+=DbmsDataTypes (','? DbmsDataTypes+=DbmsDataTypes)* ')')?;
DbmsCommomn:
('(' ((DbmsDataTypes+=DbmsDataTypes) | (dbmsDecl+=DbmsDecl)) (','? ((DbmsDataTypes+=DbmsDataTypes) |
(dbmsDecl+=DbmsDecl)))* ')');
DbmsDataTypes:
((jplId+=JPLID) | (str+=STRING) | (num+=NUMBER)) ('[' (jplId+=JPLID) ']')?;
JPLID:
name=ID;
NUMBER:
INT;
DbmsKeys:
dbmsKeyWords+=(DBMS_KEYWORD1 | DBMS_KEYWORD2 | DBMS_KEYWORD3 | DBMS_KEYWORD4 | DBMS_KEYWORD5 | DBMS_KEYWORD6 |
DBMS_KEYWORD7 | DBMS_KEYWORD8 | DBMS_KEYWORD9 |
DBMS_KEYWORD10 | DBMS_KEYWORD11 | DBMS_KEYWORD12 | DBMS_KEYWORD13 | DBMS_KEYWORD14 | DBMS_KEYWORD15 | DBMS_KEYWORD16);
DBMS_KEYWORD1: ('sql'|'insert'|'into'|'values'|'execute'|'cursor'|'delete'|'case'|'update');
DBMS_KEYWORD2 : ('set'|'select'|'distinct'|'from'|'where'|'char'|'datetime'|'temp');
DBMS_KEYWORD3: ('group'|'by'|'having'|'like'|'exists'|'in'|'is'|'completion'|'run');
DBMS_KEYWORD4: ('any'|'all'|'some'|'and'|'or'|'left'|'right'|'inner'|'outer'|'join');
DBMS_KEYWORD5: ('float'|'int'|'long'|'create'|'table'|'database'|'drop'|'max'|'sum');
DBMS_KEYWORD6: ('between'| 'escape'|'order'|'asc'|'desc'|'not'|'null'|'avg'|'min');
DBMS_KEYWORD7: ('primary'|'foreign'|'key'|'references'|'like'|'escape'|'with'|'for');
DBMS_KEYWORD8: ('engine'|'close'|'column_names'| 'connection'|'close_all_connections');
DBMS_KEYWORD9: ('using'|'rpc'|'alias'|'binary'|'catquery'| 'to'|'separator'|'COUNT');
DBMS_KEYWORD10: ('heading'| 'on'|'off'|'column'|'names'|'format'|'occur'|'start');
DBMS_KEYWORD11: ('unique'|'connected'|'continue_bottom'|'continue_down'| 'onexit');
DBMS_KEYWORD12: ('continue_top'|'continue_up'|'store'|'file'|'onentry'|'onerror');
DBMS_KEYWORD13: ('application' |'autocommit'|'begin'|'browse'|'cancel'|'commit');
DBMS_KEYWORD14: ('rollback'|'user'|'database'|'datasource'|'server'|'procedure');
DBMS_KEYWORD15: ('declare'|'cursors'|'continue'|'stored_sub');
DBMS_KEYWORD16: ('save'|'flush'|'timeout'|'transaction');
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06701 seconds