id
int64 0
563
| file_name
stringlengths 4
38
| file_path
stringlengths 16
123
| content
stringlengths 126
1.72M
| size
int64 126
1.8M
| language
stringclasses 1
value | extension
stringclasses 1
value | total_lines
int64 4
74.3k
| avg_line_length
float64 6.01
89.8
| max_line_length
int64 33
3.68k
| alphanum_fraction
float64 0.33
0.95
| repo_name
stringclasses 95
values | repo_stars
int64 0
50
| repo_forks
int64 0
14
| repo_open_issues
int64 0
34
| repo_license
stringclasses 7
values | repo_extraction_date
stringclasses 11
values | sha
stringlengths 64
64
| exact_dupe_TheStackV2
bool 2
classes | exact_dupe_TheStack
bool 2
classes | exact_dupe_RedPajama
bool 2
classes | exact_dupe_GithubCode
bool 2
classes |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
117 | MySqlLexer.g4 | qiub649691422_demo-sharding/src/main/java/com/demo/sharding/advance/MySqlLexer.g4 | /*
MySQL (Positive Technologies) grammar
The MIT License (MIT).
Copyright (c) 2015-2017, Ivan Kochurkin ([email protected]), Positive Technologies.
Copyright (c) 2017, Ivan Khudyashev ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
lexer grammar MySqlLexer;
channels { MYSQLCOMMENT, ERRORCHANNEL }
// SKIP
SPACE: [ \t\r\n]+ -> channel(HIDDEN);
SPEC_MYSQL_COMMENT: '/*!' .+? '*/' -> channel(MYSQLCOMMENT);
COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN);
LINE_COMMENT: (
('-- ' | '#') ~[\r\n]* ('\r'? '\n' | EOF)
| '--' ('\r'? '\n' | EOF)
) -> channel(HIDDEN);
// Keywords
// Common Keywords
ADD: 'ADD';
ALL: 'ALL';
ALTER: 'ALTER';
ALWAYS: 'ALWAYS';
ANALYZE: 'ANALYZE';
AND: 'AND';
AS: 'AS';
ASC: 'ASC';
BEFORE: 'BEFORE';
BETWEEN: 'BETWEEN';
BOTH: 'BOTH';
BY: 'BY';
CALL: 'CALL';
CASCADE: 'CASCADE';
CASE: 'CASE';
CAST: 'CAST';
CHANGE: 'CHANGE';
CHARACTER: 'CHARACTER';
CHECK: 'CHECK';
COLLATE: 'COLLATE';
COLUMN: 'COLUMN';
CONDITION: 'CONDITION';
CONSTRAINT: 'CONSTRAINT';
CONTINUE: 'CONTINUE';
CONVERT: 'CONVERT';
CREATE: 'CREATE';
CROSS: 'CROSS';
CURRENT: 'CURRENT';
CURRENT_USER: 'CURRENT_USER';
CURSOR: 'CURSOR';
DATABASE: 'DATABASE';
DATABASES: 'DATABASES';
DECLARE: 'DECLARE';
DEFAULT: 'DEFAULT';
DELAYED: 'DELAYED';
DELETE: 'DELETE';
DESC: 'DESC';
DESCRIBE: 'DESCRIBE';
DETERMINISTIC: 'DETERMINISTIC';
DIAGNOSTICS: 'DIAGNOSTICS';
DISTINCT: 'DISTINCT';
DISTINCTROW: 'DISTINCTROW';
DROP: 'DROP';
EACH: 'EACH';
ELSE: 'ELSE';
ELSEIF: 'ELSEIF';
ENCLOSED: 'ENCLOSED';
ESCAPED: 'ESCAPED';
EXISTS: 'EXISTS';
EXIT: 'EXIT';
EXPLAIN: 'EXPLAIN';
FALSE: 'FALSE';
FETCH: 'FETCH';
FOR: 'FOR';
FORCE: 'FORCE';
FOREIGN: 'FOREIGN';
FROM: 'FROM';
FULLTEXT: 'FULLTEXT';
GENERATED: 'GENERATED';
GET: 'GET';
GRANT: 'GRANT';
GROUP: 'GROUP';
HAVING: 'HAVING';
HIGH_PRIORITY: 'HIGH_PRIORITY';
IF: 'IF';
IGNORE: 'IGNORE';
IN: 'IN';
INDEX: 'INDEX';
INFILE: 'INFILE';
INNER: 'INNER';
INOUT: 'INOUT';
INSERT: 'INSERT';
INTERVAL: 'INTERVAL';
INTO: 'INTO';
IS: 'IS';
ITERATE: 'ITERATE';
JOIN: 'JOIN';
KEY: 'KEY';
KEYS: 'KEYS';
KILL: 'KILL';
LEADING: 'LEADING';
LEAVE: 'LEAVE';
LEFT: 'LEFT';
LIKE: 'LIKE';
LIMIT: 'LIMIT';
LINEAR: 'LINEAR';
LINES: 'LINES';
LOAD: 'LOAD';
LOCK: 'LOCK';
LOOP: 'LOOP';
LOW_PRIORITY: 'LOW_PRIORITY';
MASTER_BIND: 'MASTER_BIND';
MASTER_SSL_VERIFY_SERVER_CERT: 'MASTER_SSL_VERIFY_SERVER_CERT';
MATCH: 'MATCH';
MAXVALUE: 'MAXVALUE';
MODIFIES: 'MODIFIES';
NATURAL: 'NATURAL';
NOT: 'NOT';
NO_WRITE_TO_BINLOG: 'NO_WRITE_TO_BINLOG';
NULL_LITERAL: 'NULL';
NUMBER: 'NUMBER';
ON: 'ON';
OPTIMIZE: 'OPTIMIZE';
OPTION: 'OPTION';
OPTIONALLY: 'OPTIONALLY';
OR: 'OR';
ORDER: 'ORDER';
OUT: 'OUT';
OUTER: 'OUTER';
OUTFILE: 'OUTFILE';
PARTITION: 'PARTITION';
PRIMARY: 'PRIMARY';
PROCEDURE: 'PROCEDURE';
PURGE: 'PURGE';
RANGE: 'RANGE';
READ: 'READ';
READS: 'READS';
REFERENCES: 'REFERENCES';
REGEXP: 'REGEXP';
RELEASE: 'RELEASE';
RENAME: 'RENAME';
REPEAT: 'REPEAT';
REPLACE: 'REPLACE';
REQUIRE: 'REQUIRE';
RESIGNAL: 'RESIGNAL';
RESTRICT: 'RESTRICT';
RETURN: 'RETURN';
REVOKE: 'REVOKE';
RIGHT: 'RIGHT';
RLIKE: 'RLIKE';
SCHEMA: 'SCHEMA';
SCHEMAS: 'SCHEMAS';
SELECT: 'SELECT';
SET: 'SET';
SEPARATOR: 'SEPARATOR';
SHOW: 'SHOW';
SIGNAL: 'SIGNAL';
SPATIAL: 'SPATIAL';
SQL: 'SQL';
SQLEXCEPTION: 'SQLEXCEPTION';
SQLSTATE: 'SQLSTATE';
SQLWARNING: 'SQLWARNING';
SQL_BIG_RESULT: 'SQL_BIG_RESULT';
SQL_CALC_FOUND_ROWS: 'SQL_CALC_FOUND_ROWS';
SQL_SMALL_RESULT: 'SQL_SMALL_RESULT';
SSL: 'SSL';
STACKED: 'STACKED';
STARTING: 'STARTING';
STRAIGHT_JOIN: 'STRAIGHT_JOIN';
TABLE: 'TABLE';
TERMINATED: 'TERMINATED';
THEN: 'THEN';
TO: 'TO';
TRAILING: 'TRAILING';
TRIGGER: 'TRIGGER';
TRUE: 'TRUE';
UNDO: 'UNDO';
UNION: 'UNION';
UNIQUE: 'UNIQUE';
UNLOCK: 'UNLOCK';
UNSIGNED: 'UNSIGNED';
UPDATE: 'UPDATE';
USAGE: 'USAGE';
USE: 'USE';
USING: 'USING';
VALUES: 'VALUES';
WHEN: 'WHEN';
WHERE: 'WHERE';
WHILE: 'WHILE';
WITH: 'WITH';
WRITE: 'WRITE';
XOR: 'XOR';
ZEROFILL: 'ZEROFILL';
// DATA TYPE Keywords
TINYINT: 'TINYINT';
SMALLINT: 'SMALLINT';
MEDIUMINT: 'MEDIUMINT';
INT: 'INT';
INTEGER: 'INTEGER';
BIGINT: 'BIGINT';
REAL: 'REAL';
DOUBLE: 'DOUBLE';
PRECISION: 'PRECISION';
FLOAT: 'FLOAT';
DECIMAL: 'DECIMAL';
DEC: 'DEC';
NUMERIC: 'NUMERIC';
DATE: 'DATE';
TIME: 'TIME';
TIMESTAMP: 'TIMESTAMP';
DATETIME: 'DATETIME';
YEAR: 'YEAR';
CHAR: 'CHAR';
VARCHAR: 'VARCHAR';
NVARCHAR: 'NVARCHAR';
NATIONAL: 'NATIONAL';
BINARY: 'BINARY';
VARBINARY: 'VARBINARY';
TINYBLOB: 'TINYBLOB';
BLOB: 'BLOB';
MEDIUMBLOB: 'MEDIUMBLOB';
LONGBLOB: 'LONGBLOB';
TINYTEXT: 'TINYTEXT';
TEXT: 'TEXT';
MEDIUMTEXT: 'MEDIUMTEXT';
LONGTEXT: 'LONGTEXT';
ENUM: 'ENUM';
VARYING: 'VARYING';
SERIAL: 'SERIAL';
// Interval type Keywords
YEAR_MONTH: 'YEAR_MONTH';
DAY_HOUR: 'DAY_HOUR';
DAY_MINUTE: 'DAY_MINUTE';
DAY_SECOND: 'DAY_SECOND';
HOUR_MINUTE: 'HOUR_MINUTE';
HOUR_SECOND: 'HOUR_SECOND';
MINUTE_SECOND: 'MINUTE_SECOND';
SECOND_MICROSECOND: 'SECOND_MICROSECOND';
MINUTE_MICROSECOND: 'MINUTE_MICROSECOND';
HOUR_MICROSECOND: 'HOUR_MICROSECOND';
DAY_MICROSECOND: 'DAY_MICROSECOND';
// Group function Keywords
AVG: 'AVG';
BIT_AND: 'BIT_AND';
BIT_OR: 'BIT_OR';
BIT_XOR: 'BIT_XOR';
COUNT: 'COUNT';
GROUP_CONCAT: 'GROUP_CONCAT';
MAX: 'MAX';
MIN: 'MIN';
STD: 'STD';
STDDEV: 'STDDEV';
STDDEV_POP: 'STDDEV_POP';
STDDEV_SAMP: 'STDDEV_SAMP';
SUM: 'SUM';
VAR_POP: 'VAR_POP';
VAR_SAMP: 'VAR_SAMP';
VARIANCE: 'VARIANCE';
// Common function Keywords
CURRENT_DATE: 'CURRENT_DATE';
CURRENT_TIME: 'CURRENT_TIME';
CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP';
LOCALTIME: 'LOCALTIME';
CURDATE: 'CURDATE';
CURTIME: 'CURTIME';
DATE_ADD: 'DATE_ADD';
DATE_SUB: 'DATE_SUB';
EXTRACT: 'EXTRACT';
LOCALTIMESTAMP: 'LOCALTIMESTAMP';
NOW: 'NOW';
POSITION: 'POSITION';
SUBSTR: 'SUBSTR';
SUBSTRING: 'SUBSTRING';
SYSDATE: 'SYSDATE';
TRIM: 'TRIM';
UTC_DATE: 'UTC_DATE';
UTC_TIME: 'UTC_TIME';
UTC_TIMESTAMP: 'UTC_TIMESTAMP';
// Keywords, but can be ID
// Common Keywords, but can be ID
ACCOUNT: 'ACCOUNT';
ACTION: 'ACTION';
AFTER: 'AFTER';
AGGREGATE: 'AGGREGATE';
ALGORITHM: 'ALGORITHM';
ANY: 'ANY';
AT: 'AT';
AUTHORS: 'AUTHORS';
AUTOCOMMIT: 'AUTOCOMMIT';
AUTOEXTEND_SIZE: 'AUTOEXTEND_SIZE';
AUTO_INCREMENT: 'AUTO_INCREMENT';
AVG_ROW_LENGTH: 'AVG_ROW_LENGTH';
BEGIN: 'BEGIN';
BINLOG: 'BINLOG';
BIT: 'BIT';
BLOCK: 'BLOCK';
BOOL: 'BOOL';
BOOLEAN: 'BOOLEAN';
BTREE: 'BTREE';
CACHE: 'CACHE';
CASCADED: 'CASCADED';
CHAIN: 'CHAIN';
CHANGED: 'CHANGED';
CHANNEL: 'CHANNEL';
CHECKSUM: 'CHECKSUM';
PAGE_CHECKSUM: 'PAGE_CHECKSUM';
CIPHER: 'CIPHER';
CLASS_ORIGIN: 'CLASS_ORIGIN';
CLIENT: 'CLIENT';
CLOSE: 'CLOSE';
COALESCE: 'COALESCE';
CODE: 'CODE';
COLUMNS: 'COLUMNS';
COLUMN_FORMAT: 'COLUMN_FORMAT';
COLUMN_NAME: 'COLUMN_NAME';
COMMENT: 'COMMENT';
COMMIT: 'COMMIT';
COMPACT: 'COMPACT';
COMPLETION: 'COMPLETION';
COMPRESSED: 'COMPRESSED';
COMPRESSION: 'COMPRESSION';
CONCURRENT: 'CONCURRENT';
CONNECTION: 'CONNECTION';
CONSISTENT: 'CONSISTENT';
CONSTRAINT_CATALOG: 'CONSTRAINT_CATALOG';
CONSTRAINT_SCHEMA: 'CONSTRAINT_SCHEMA';
CONSTRAINT_NAME: 'CONSTRAINT_NAME';
CONTAINS: 'CONTAINS';
CONTEXT: 'CONTEXT';
CONTRIBUTORS: 'CONTRIBUTORS';
COPY: 'COPY';
CPU: 'CPU';
CURSOR_NAME: 'CURSOR_NAME';
DATA: 'DATA';
DATAFILE: 'DATAFILE';
DEALLOCATE: 'DEALLOCATE';
DEFAULT_AUTH: 'DEFAULT_AUTH';
DEFINER: 'DEFINER';
DELAY_KEY_WRITE: 'DELAY_KEY_WRITE';
DES_KEY_FILE: 'DES_KEY_FILE';
DIRECTORY: 'DIRECTORY';
DISABLE: 'DISABLE';
DISCARD: 'DISCARD';
DISK: 'DISK';
DO: 'DO';
DUMPFILE: 'DUMPFILE';
DUPLICATE: 'DUPLICATE';
DYNAMIC: 'DYNAMIC';
ENABLE: 'ENABLE';
ENCRYPTION: 'ENCRYPTION';
END: 'END';
ENDS: 'ENDS';
ENGINE: 'ENGINE';
ENGINES: 'ENGINES';
ERROR: 'ERROR';
ERRORS: 'ERRORS';
ESCAPE: 'ESCAPE';
EVEN: 'EVEN';
EVENT: 'EVENT';
EVENTS: 'EVENTS';
EVERY: 'EVERY';
EXCHANGE: 'EXCHANGE';
EXCLUSIVE: 'EXCLUSIVE';
EXPIRE: 'EXPIRE';
EXPORT: 'EXPORT';
EXTENDED: 'EXTENDED';
EXTENT_SIZE: 'EXTENT_SIZE';
FAST: 'FAST';
FAULTS: 'FAULTS';
FIELDS: 'FIELDS';
FILE_BLOCK_SIZE: 'FILE_BLOCK_SIZE';
FILTER: 'FILTER';
FIRST: 'FIRST';
FIXED: 'FIXED';
FLUSH: 'FLUSH';
FOLLOWS: 'FOLLOWS';
FOUND: 'FOUND';
FULL: 'FULL';
FUNCTION: 'FUNCTION';
GENERAL: 'GENERAL';
GLOBAL: 'GLOBAL';
GRANTS: 'GRANTS';
GROUP_REPLICATION: 'GROUP_REPLICATION';
HANDLER: 'HANDLER';
HASH: 'HASH';
HELP: 'HELP';
HOST: 'HOST';
HOSTS: 'HOSTS';
IDENTIFIED: 'IDENTIFIED';
IGNORE_SERVER_IDS: 'IGNORE_SERVER_IDS';
IMPORT: 'IMPORT';
INDEXES: 'INDEXES';
INITIAL_SIZE: 'INITIAL_SIZE';
INPLACE: 'INPLACE';
INSERT_METHOD: 'INSERT_METHOD';
INSTALL: 'INSTALL';
INSTANCE: 'INSTANCE';
INVISIBLE: 'INVISIBLE';
INVOKER: 'INVOKER';
IO: 'IO';
IO_THREAD: 'IO_THREAD';
IPC: 'IPC';
ISOLATION: 'ISOLATION';
ISSUER: 'ISSUER';
JSON: 'JSON';
KEY_BLOCK_SIZE: 'KEY_BLOCK_SIZE';
LANGUAGE: 'LANGUAGE';
LAST: 'LAST';
LEAVES: 'LEAVES';
LESS: 'LESS';
LEVEL: 'LEVEL';
LIST: 'LIST';
LOCAL: 'LOCAL';
LOGFILE: 'LOGFILE';
LOGS: 'LOGS';
MASTER: 'MASTER';
MASTER_AUTO_POSITION: 'MASTER_AUTO_POSITION';
MASTER_CONNECT_RETRY: 'MASTER_CONNECT_RETRY';
MASTER_DELAY: 'MASTER_DELAY';
MASTER_HEARTBEAT_PERIOD: 'MASTER_HEARTBEAT_PERIOD';
MASTER_HOST: 'MASTER_HOST';
MASTER_LOG_FILE: 'MASTER_LOG_FILE';
MASTER_LOG_POS: 'MASTER_LOG_POS';
MASTER_PASSWORD: 'MASTER_PASSWORD';
MASTER_PORT: 'MASTER_PORT';
MASTER_RETRY_COUNT: 'MASTER_RETRY_COUNT';
MASTER_SSL: 'MASTER_SSL';
MASTER_SSL_CA: 'MASTER_SSL_CA';
MASTER_SSL_CAPATH: 'MASTER_SSL_CAPATH';
MASTER_SSL_CERT: 'MASTER_SSL_CERT';
MASTER_SSL_CIPHER: 'MASTER_SSL_CIPHER';
MASTER_SSL_CRL: 'MASTER_SSL_CRL';
MASTER_SSL_CRLPATH: 'MASTER_SSL_CRLPATH';
MASTER_SSL_KEY: 'MASTER_SSL_KEY';
MASTER_TLS_VERSION: 'MASTER_TLS_VERSION';
MASTER_USER: 'MASTER_USER';
MAX_CONNECTIONS_PER_HOUR: 'MAX_CONNECTIONS_PER_HOUR';
MAX_QUERIES_PER_HOUR: 'MAX_QUERIES_PER_HOUR';
MAX_ROWS: 'MAX_ROWS';
MAX_SIZE: 'MAX_SIZE';
MAX_UPDATES_PER_HOUR: 'MAX_UPDATES_PER_HOUR';
MAX_USER_CONNECTIONS: 'MAX_USER_CONNECTIONS';
MEDIUM: 'MEDIUM';
MERGE: 'MERGE';
MESSAGE_TEXT: 'MESSAGE_TEXT';
MID: 'MID';
MIGRATE: 'MIGRATE';
MIN_ROWS: 'MIN_ROWS';
MODE: 'MODE';
MODIFY: 'MODIFY';
MUTEX: 'MUTEX';
MYSQL: 'MYSQL';
MYSQL_ERRNO: 'MYSQL_ERRNO';
NAME: 'NAME';
NAMES: 'NAMES';
NCHAR: 'NCHAR';
NEVER: 'NEVER';
NEXT: 'NEXT';
NO: 'NO';
NODEGROUP: 'NODEGROUP';
NONE: 'NONE';
OFFLINE: 'OFFLINE';
OFFSET: 'OFFSET';
OJ: 'OJ';
OLD_PASSWORD: 'OLD_PASSWORD';
ONE: 'ONE';
ONLINE: 'ONLINE';
ONLY: 'ONLY';
OPEN: 'OPEN';
OPTIMIZER_COSTS: 'OPTIMIZER_COSTS';
OPTIONS: 'OPTIONS';
OWNER: 'OWNER';
PACK_KEYS: 'PACK_KEYS';
PAGE: 'PAGE';
PARSER: 'PARSER';
PARTIAL: 'PARTIAL';
PARTITIONING: 'PARTITIONING';
PARTITIONS: 'PARTITIONS';
PASSWORD: 'PASSWORD';
PHASE: 'PHASE';
PLUGIN: 'PLUGIN';
PLUGIN_DIR: 'PLUGIN_DIR';
PLUGINS: 'PLUGINS';
PORT: 'PORT';
PRECEDES: 'PRECEDES';
PREPARE: 'PREPARE';
PRESERVE: 'PRESERVE';
PREV: 'PREV';
PROCESSLIST: 'PROCESSLIST';
PROFILE: 'PROFILE';
PROFILES: 'PROFILES';
PROXY: 'PROXY';
QUERY: 'QUERY';
QUICK: 'QUICK';
REBUILD: 'REBUILD';
RECOVER: 'RECOVER';
REDO_BUFFER_SIZE: 'REDO_BUFFER_SIZE';
REDUNDANT: 'REDUNDANT';
RELAY: 'RELAY';
RELAY_LOG_FILE: 'RELAY_LOG_FILE';
RELAY_LOG_POS: 'RELAY_LOG_POS';
RELAYLOG: 'RELAYLOG';
REMOVE: 'REMOVE';
REORGANIZE: 'REORGANIZE';
REPAIR: 'REPAIR';
REPLICATE_DO_DB: 'REPLICATE_DO_DB';
REPLICATE_DO_TABLE: 'REPLICATE_DO_TABLE';
REPLICATE_IGNORE_DB: 'REPLICATE_IGNORE_DB';
REPLICATE_IGNORE_TABLE: 'REPLICATE_IGNORE_TABLE';
REPLICATE_REWRITE_DB: 'REPLICATE_REWRITE_DB';
REPLICATE_WILD_DO_TABLE: 'REPLICATE_WILD_DO_TABLE';
REPLICATE_WILD_IGNORE_TABLE: 'REPLICATE_WILD_IGNORE_TABLE';
REPLICATION: 'REPLICATION';
RESET: 'RESET';
RESUME: 'RESUME';
RETURNED_SQLSTATE: 'RETURNED_SQLSTATE';
RETURNS: 'RETURNS';
ROLLBACK: 'ROLLBACK';
ROLLUP: 'ROLLUP';
ROTATE: 'ROTATE';
ROW: 'ROW';
ROWS: 'ROWS';
ROW_FORMAT: 'ROW_FORMAT';
SAVEPOINT: 'SAVEPOINT';
SCHEDULE: 'SCHEDULE';
SECURITY: 'SECURITY';
SERVER: 'SERVER';
SESSION: 'SESSION';
SHARE: 'SHARE';
SHARED: 'SHARED';
SIGNED: 'SIGNED';
SIMPLE: 'SIMPLE';
SLAVE: 'SLAVE';
SLOW: 'SLOW';
SNAPSHOT: 'SNAPSHOT';
SOCKET: 'SOCKET';
SOME: 'SOME';
SONAME: 'SONAME';
SOUNDS: 'SOUNDS';
SOURCE: 'SOURCE';
SQL_AFTER_GTIDS: 'SQL_AFTER_GTIDS';
SQL_AFTER_MTS_GAPS: 'SQL_AFTER_MTS_GAPS';
SQL_BEFORE_GTIDS: 'SQL_BEFORE_GTIDS';
SQL_BUFFER_RESULT: 'SQL_BUFFER_RESULT';
SQL_CACHE: 'SQL_CACHE';
SQL_NO_CACHE: 'SQL_NO_CACHE';
SQL_THREAD: 'SQL_THREAD';
START: 'START';
STARTS: 'STARTS';
STATS_AUTO_RECALC: 'STATS_AUTO_RECALC';
STATS_PERSISTENT: 'STATS_PERSISTENT';
STATS_SAMPLE_PAGES: 'STATS_SAMPLE_PAGES';
STATUS: 'STATUS';
STOP: 'STOP';
STORAGE: 'STORAGE';
STORED: 'STORED';
STRING: 'STRING';
SUBCLASS_ORIGIN: 'SUBCLASS_ORIGIN';
SUBJECT: 'SUBJECT';
SUBPARTITION: 'SUBPARTITION';
SUBPARTITIONS: 'SUBPARTITIONS';
SUSPEND: 'SUSPEND';
SWAPS: 'SWAPS';
SWITCHES: 'SWITCHES';
TABLE_NAME: 'TABLE_NAME';
TABLESPACE: 'TABLESPACE';
TEMPORARY: 'TEMPORARY';
TEMPTABLE: 'TEMPTABLE';
THAN: 'THAN';
TRADITIONAL: 'TRADITIONAL';
TRANSACTION: 'TRANSACTION';
TRIGGERS: 'TRIGGERS';
TRUNCATE: 'TRUNCATE';
UNDEFINED: 'UNDEFINED';
UNDOFILE: 'UNDOFILE';
UNDO_BUFFER_SIZE: 'UNDO_BUFFER_SIZE';
UNINSTALL: 'UNINSTALL';
UNKNOWN: 'UNKNOWN';
UNTIL: 'UNTIL';
UPGRADE: 'UPGRADE';
USER: 'USER';
USE_FRM: 'USE_FRM';
USER_RESOURCES: 'USER_RESOURCES';
VALIDATION: 'VALIDATION';
VALUE: 'VALUE';
VARIABLES: 'VARIABLES';
VIEW: 'VIEW';
VIRTUAL: 'VIRTUAL';
VISIBLE: 'VISIBLE';
WAIT: 'WAIT';
WARNINGS: 'WARNINGS';
WITHOUT: 'WITHOUT';
WORK: 'WORK';
WRAPPER: 'WRAPPER';
X509: 'X509';
XA: 'XA';
XML: 'XML';
// Date format Keywords
EUR: 'EUR';
USA: 'USA';
JIS: 'JIS';
ISO: 'ISO';
INTERNAL: 'INTERNAL';
// Interval type Keywords
QUARTER: 'QUARTER';
MONTH: 'MONTH';
DAY: 'DAY';
HOUR: 'HOUR';
MINUTE: 'MINUTE';
WEEK: 'WEEK';
SECOND: 'SECOND';
MICROSECOND: 'MICROSECOND';
// PRIVILEGES
TABLES: 'TABLES';
ROUTINE: 'ROUTINE';
EXECUTE: 'EXECUTE';
FILE: 'FILE';
PROCESS: 'PROCESS';
RELOAD: 'RELOAD';
SHUTDOWN: 'SHUTDOWN';
SUPER: 'SUPER';
PRIVILEGES: 'PRIVILEGES';
SESSION_VARIABLES_ADMIN: QUOTE_SYMB? 'SESSION_VARIABLES_ADMIN' QUOTE_SYMB?;
// Charsets
ARMSCII8: 'ARMSCII8';
ASCII: 'ASCII';
BIG5: 'BIG5';
CP1250: 'CP1250';
CP1251: 'CP1251';
CP1256: 'CP1256';
CP1257: 'CP1257';
CP850: 'CP850';
CP852: 'CP852';
CP866: 'CP866';
CP932: 'CP932';
DEC8: 'DEC8';
EUCJPMS: 'EUCJPMS';
EUCKR: 'EUCKR';
GB2312: 'GB2312';
GBK: 'GBK';
GEOSTD8: 'GEOSTD8';
GREEK: 'GREEK';
HEBREW: 'HEBREW';
HP8: 'HP8';
KEYBCS2: 'KEYBCS2';
KOI8R: 'KOI8R';
KOI8U: 'KOI8U';
LATIN1: 'LATIN1';
LATIN2: 'LATIN2';
LATIN5: 'LATIN5';
LATIN7: 'LATIN7';
MACCE: 'MACCE';
MACROMAN: 'MACROMAN';
SJIS: 'SJIS';
SWE7: 'SWE7';
TIS620: 'TIS620';
UCS2: 'UCS2';
UJIS: 'UJIS';
UTF16: 'UTF16';
UTF16LE: 'UTF16LE';
UTF32: 'UTF32';
UTF8: 'UTF8';
UTF8MB3: 'UTF8MB3';
UTF8MB4: 'UTF8MB4';
// DB Engines
ARCHIVE: 'ARCHIVE';
BLACKHOLE: 'BLACKHOLE';
CSV: 'CSV';
FEDERATED: 'FEDERATED';
INNODB: 'INNODB';
MEMORY: 'MEMORY';
MRG_MYISAM: 'MRG_MYISAM';
MYISAM: 'MYISAM';
NDB: 'NDB';
NDBCLUSTER: 'NDBCLUSTER';
PERFORMANCE_SCHEMA: 'PERFORMANCE_SCHEMA';
TOKUDB: 'TOKUDB';
// Transaction Levels
REPEATABLE: 'REPEATABLE';
COMMITTED: 'COMMITTED';
UNCOMMITTED: 'UNCOMMITTED';
SERIALIZABLE: 'SERIALIZABLE';
// Spatial data types
GEOMETRYCOLLECTION: 'GEOMETRYCOLLECTION';
GEOMCOLLECTION: 'GEOMCOLLECTION';
GEOMETRY: 'GEOMETRY';
LINESTRING: 'LINESTRING';
MULTILINESTRING: 'MULTILINESTRING';
MULTIPOINT: 'MULTIPOINT';
MULTIPOLYGON: 'MULTIPOLYGON';
POINT: 'POINT';
POLYGON: 'POLYGON';
// Common function names
ABS: 'ABS';
ACOS: 'ACOS';
ADDDATE: 'ADDDATE';
ADDTIME: 'ADDTIME';
AES_DECRYPT: 'AES_DECRYPT';
AES_ENCRYPT: 'AES_ENCRYPT';
AREA: 'AREA';
ASBINARY: 'ASBINARY';
ASIN: 'ASIN';
ASTEXT: 'ASTEXT';
ASWKB: 'ASWKB';
ASWKT: 'ASWKT';
ASYMMETRIC_DECRYPT: 'ASYMMETRIC_DECRYPT';
ASYMMETRIC_DERIVE: 'ASYMMETRIC_DERIVE';
ASYMMETRIC_ENCRYPT: 'ASYMMETRIC_ENCRYPT';
ASYMMETRIC_SIGN: 'ASYMMETRIC_SIGN';
ASYMMETRIC_VERIFY: 'ASYMMETRIC_VERIFY';
ATAN: 'ATAN';
ATAN2: 'ATAN2';
BENCHMARK: 'BENCHMARK';
BIN: 'BIN';
BIT_COUNT: 'BIT_COUNT';
BIT_LENGTH: 'BIT_LENGTH';
BUFFER: 'BUFFER';
CATALOG_NAME: 'CATALOG_NAME';
CEIL: 'CEIL';
CEILING: 'CEILING';
CENTROID: 'CENTROID';
CHARACTER_LENGTH: 'CHARACTER_LENGTH';
CHARSET: 'CHARSET';
CHAR_LENGTH: 'CHAR_LENGTH';
COERCIBILITY: 'COERCIBILITY';
COLLATION: 'COLLATION';
COMPRESS: 'COMPRESS';
CONCAT: 'CONCAT';
CONCAT_WS: 'CONCAT_WS';
CONNECTION_ID: 'CONNECTION_ID';
CONV: 'CONV';
CONVERT_TZ: 'CONVERT_TZ';
COS: 'COS';
COT: 'COT';
CRC32: 'CRC32';
CREATE_ASYMMETRIC_PRIV_KEY: 'CREATE_ASYMMETRIC_PRIV_KEY';
CREATE_ASYMMETRIC_PUB_KEY: 'CREATE_ASYMMETRIC_PUB_KEY';
CREATE_DH_PARAMETERS: 'CREATE_DH_PARAMETERS';
CREATE_DIGEST: 'CREATE_DIGEST';
CROSSES: 'CROSSES';
DATEDIFF: 'DATEDIFF';
DATE_FORMAT: 'DATE_FORMAT';
DAYNAME: 'DAYNAME';
DAYOFMONTH: 'DAYOFMONTH';
DAYOFWEEK: 'DAYOFWEEK';
DAYOFYEAR: 'DAYOFYEAR';
DECODE: 'DECODE';
DEGREES: 'DEGREES';
DES_DECRYPT: 'DES_DECRYPT';
DES_ENCRYPT: 'DES_ENCRYPT';
DIMENSION: 'DIMENSION';
DISJOINT: 'DISJOINT';
ELT: 'ELT';
ENCODE: 'ENCODE';
ENCRYPT: 'ENCRYPT';
ENDPOINT: 'ENDPOINT';
ENVELOPE: 'ENVELOPE';
EQUALS: 'EQUALS';
EXP: 'EXP';
EXPORT_SET: 'EXPORT_SET';
EXTERIORRING: 'EXTERIORRING';
EXTRACTVALUE: 'EXTRACTVALUE';
FIELD: 'FIELD';
FIND_IN_SET: 'FIND_IN_SET';
FLOOR: 'FLOOR';
FORMAT: 'FORMAT';
FOUND_ROWS: 'FOUND_ROWS';
FROM_BASE64: 'FROM_BASE64';
FROM_DAYS: 'FROM_DAYS';
FROM_UNIXTIME: 'FROM_UNIXTIME';
GEOMCOLLFROMTEXT: 'GEOMCOLLFROMTEXT';
GEOMCOLLFROMWKB: 'GEOMCOLLFROMWKB';
GEOMETRYCOLLECTIONFROMTEXT: 'GEOMETRYCOLLECTIONFROMTEXT';
GEOMETRYCOLLECTIONFROMWKB: 'GEOMETRYCOLLECTIONFROMWKB';
GEOMETRYFROMTEXT: 'GEOMETRYFROMTEXT';
GEOMETRYFROMWKB: 'GEOMETRYFROMWKB';
GEOMETRYN: 'GEOMETRYN';
GEOMETRYTYPE: 'GEOMETRYTYPE';
GEOMFROMTEXT: 'GEOMFROMTEXT';
GEOMFROMWKB: 'GEOMFROMWKB';
GET_FORMAT: 'GET_FORMAT';
GET_LOCK: 'GET_LOCK';
GLENGTH: 'GLENGTH';
GREATEST: 'GREATEST';
GTID_SUBSET: 'GTID_SUBSET';
GTID_SUBTRACT: 'GTID_SUBTRACT';
HEX: 'HEX';
IFNULL: 'IFNULL';
INET6_ATON: 'INET6_ATON';
INET6_NTOA: 'INET6_NTOA';
INET_ATON: 'INET_ATON';
INET_NTOA: 'INET_NTOA';
INSTR: 'INSTR';
INTERIORRINGN: 'INTERIORRINGN';
INTERSECTS: 'INTERSECTS';
ISCLOSED: 'ISCLOSED';
ISEMPTY: 'ISEMPTY';
ISNULL: 'ISNULL';
ISSIMPLE: 'ISSIMPLE';
IS_FREE_LOCK: 'IS_FREE_LOCK';
IS_IPV4: 'IS_IPV4';
IS_IPV4_COMPAT: 'IS_IPV4_COMPAT';
IS_IPV4_MAPPED: 'IS_IPV4_MAPPED';
IS_IPV6: 'IS_IPV6';
IS_USED_LOCK: 'IS_USED_LOCK';
LAST_INSERT_ID: 'LAST_INSERT_ID';
LCASE: 'LCASE';
LEAST: 'LEAST';
LENGTH: 'LENGTH';
LINEFROMTEXT: 'LINEFROMTEXT';
LINEFROMWKB: 'LINEFROMWKB';
LINESTRINGFROMTEXT: 'LINESTRINGFROMTEXT';
LINESTRINGFROMWKB: 'LINESTRINGFROMWKB';
LN: 'LN';
LOAD_FILE: 'LOAD_FILE';
LOCATE: 'LOCATE';
LOG: 'LOG';
LOG10: 'LOG10';
LOG2: 'LOG2';
LOWER: 'LOWER';
LPAD: 'LPAD';
LTRIM: 'LTRIM';
MAKEDATE: 'MAKEDATE';
MAKETIME: 'MAKETIME';
MAKE_SET: 'MAKE_SET';
MASTER_POS_WAIT: 'MASTER_POS_WAIT';
MBRCONTAINS: 'MBRCONTAINS';
MBRDISJOINT: 'MBRDISJOINT';
MBREQUAL: 'MBREQUAL';
MBRINTERSECTS: 'MBRINTERSECTS';
MBROVERLAPS: 'MBROVERLAPS';
MBRTOUCHES: 'MBRTOUCHES';
MBRWITHIN: 'MBRWITHIN';
MD5: 'MD5';
MLINEFROMTEXT: 'MLINEFROMTEXT';
MLINEFROMWKB: 'MLINEFROMWKB';
MONTHNAME: 'MONTHNAME';
MPOINTFROMTEXT: 'MPOINTFROMTEXT';
MPOINTFROMWKB: 'MPOINTFROMWKB';
MPOLYFROMTEXT: 'MPOLYFROMTEXT';
MPOLYFROMWKB: 'MPOLYFROMWKB';
MULTILINESTRINGFROMTEXT: 'MULTILINESTRINGFROMTEXT';
MULTILINESTRINGFROMWKB: 'MULTILINESTRINGFROMWKB';
MULTIPOINTFROMTEXT: 'MULTIPOINTFROMTEXT';
MULTIPOINTFROMWKB: 'MULTIPOINTFROMWKB';
MULTIPOLYGONFROMTEXT: 'MULTIPOLYGONFROMTEXT';
MULTIPOLYGONFROMWKB: 'MULTIPOLYGONFROMWKB';
NAME_CONST: 'NAME_CONST';
NULLIF: 'NULLIF';
NUMGEOMETRIES: 'NUMGEOMETRIES';
NUMINTERIORRINGS: 'NUMINTERIORRINGS';
NUMPOINTS: 'NUMPOINTS';
OCT: 'OCT';
OCTET_LENGTH: 'OCTET_LENGTH';
ORD: 'ORD';
OVERLAPS: 'OVERLAPS';
PERIOD_ADD: 'PERIOD_ADD';
PERIOD_DIFF: 'PERIOD_DIFF';
PI: 'PI';
POINTFROMTEXT: 'POINTFROMTEXT';
POINTFROMWKB: 'POINTFROMWKB';
POINTN: 'POINTN';
POLYFROMTEXT: 'POLYFROMTEXT';
POLYFROMWKB: 'POLYFROMWKB';
POLYGONFROMTEXT: 'POLYGONFROMTEXT';
POLYGONFROMWKB: 'POLYGONFROMWKB';
POW: 'POW';
POWER: 'POWER';
QUOTE: 'QUOTE';
RADIANS: 'RADIANS';
RAND: 'RAND';
RANDOM_BYTES: 'RANDOM_BYTES';
RELEASE_LOCK: 'RELEASE_LOCK';
REVERSE: 'REVERSE';
ROUND: 'ROUND';
ROW_COUNT: 'ROW_COUNT';
RPAD: 'RPAD';
RTRIM: 'RTRIM';
SEC_TO_TIME: 'SEC_TO_TIME';
SESSION_USER: 'SESSION_USER';
SHA: 'SHA';
SHA1: 'SHA1';
SHA2: 'SHA2';
SCHEMA_NAME: 'SCHEMA_NAME';
SIGN: 'SIGN';
SIN: 'SIN';
SLEEP: 'SLEEP';
SOUNDEX: 'SOUNDEX';
SQL_THREAD_WAIT_AFTER_GTIDS: 'SQL_THREAD_WAIT_AFTER_GTIDS';
SQRT: 'SQRT';
SRID: 'SRID';
STARTPOINT: 'STARTPOINT';
STRCMP: 'STRCMP';
STR_TO_DATE: 'STR_TO_DATE';
ST_AREA: 'ST_AREA';
ST_ASBINARY: 'ST_ASBINARY';
ST_ASTEXT: 'ST_ASTEXT';
ST_ASWKB: 'ST_ASWKB';
ST_ASWKT: 'ST_ASWKT';
ST_BUFFER: 'ST_BUFFER';
ST_CENTROID: 'ST_CENTROID';
ST_CONTAINS: 'ST_CONTAINS';
ST_CROSSES: 'ST_CROSSES';
ST_DIFFERENCE: 'ST_DIFFERENCE';
ST_DIMENSION: 'ST_DIMENSION';
ST_DISJOINT: 'ST_DISJOINT';
ST_DISTANCE: 'ST_DISTANCE';
ST_ENDPOINT: 'ST_ENDPOINT';
ST_ENVELOPE: 'ST_ENVELOPE';
ST_EQUALS: 'ST_EQUALS';
ST_EXTERIORRING: 'ST_EXTERIORRING';
ST_GEOMCOLLFROMTEXT: 'ST_GEOMCOLLFROMTEXT';
ST_GEOMCOLLFROMTXT: 'ST_GEOMCOLLFROMTXT';
ST_GEOMCOLLFROMWKB: 'ST_GEOMCOLLFROMWKB';
ST_GEOMETRYCOLLECTIONFROMTEXT: 'ST_GEOMETRYCOLLECTIONFROMTEXT';
ST_GEOMETRYCOLLECTIONFROMWKB: 'ST_GEOMETRYCOLLECTIONFROMWKB';
ST_GEOMETRYFROMTEXT: 'ST_GEOMETRYFROMTEXT';
ST_GEOMETRYFROMWKB: 'ST_GEOMETRYFROMWKB';
ST_GEOMETRYN: 'ST_GEOMETRYN';
ST_GEOMETRYTYPE: 'ST_GEOMETRYTYPE';
ST_GEOMFROMTEXT: 'ST_GEOMFROMTEXT';
ST_GEOMFROMWKB: 'ST_GEOMFROMWKB';
ST_INTERIORRINGN: 'ST_INTERIORRINGN';
ST_INTERSECTION: 'ST_INTERSECTION';
ST_INTERSECTS: 'ST_INTERSECTS';
ST_ISCLOSED: 'ST_ISCLOSED';
ST_ISEMPTY: 'ST_ISEMPTY';
ST_ISSIMPLE: 'ST_ISSIMPLE';
ST_LINEFROMTEXT: 'ST_LINEFROMTEXT';
ST_LINEFROMWKB: 'ST_LINEFROMWKB';
ST_LINESTRINGFROMTEXT: 'ST_LINESTRINGFROMTEXT';
ST_LINESTRINGFROMWKB: 'ST_LINESTRINGFROMWKB';
ST_NUMGEOMETRIES: 'ST_NUMGEOMETRIES';
ST_NUMINTERIORRING: 'ST_NUMINTERIORRING';
ST_NUMINTERIORRINGS: 'ST_NUMINTERIORRINGS';
ST_NUMPOINTS: 'ST_NUMPOINTS';
ST_OVERLAPS: 'ST_OVERLAPS';
ST_POINTFROMTEXT: 'ST_POINTFROMTEXT';
ST_POINTFROMWKB: 'ST_POINTFROMWKB';
ST_POINTN: 'ST_POINTN';
ST_POLYFROMTEXT: 'ST_POLYFROMTEXT';
ST_POLYFROMWKB: 'ST_POLYFROMWKB';
ST_POLYGONFROMTEXT: 'ST_POLYGONFROMTEXT';
ST_POLYGONFROMWKB: 'ST_POLYGONFROMWKB';
ST_SRID: 'ST_SRID';
ST_STARTPOINT: 'ST_STARTPOINT';
ST_SYMDIFFERENCE: 'ST_SYMDIFFERENCE';
ST_TOUCHES: 'ST_TOUCHES';
ST_UNION: 'ST_UNION';
ST_WITHIN: 'ST_WITHIN';
ST_X: 'ST_X';
ST_Y: 'ST_Y';
SUBDATE: 'SUBDATE';
SUBSTRING_INDEX: 'SUBSTRING_INDEX';
SUBTIME: 'SUBTIME';
SYSTEM_USER: 'SYSTEM_USER';
TAN: 'TAN';
TIMEDIFF: 'TIMEDIFF';
TIMESTAMPADD: 'TIMESTAMPADD';
TIMESTAMPDIFF: 'TIMESTAMPDIFF';
TIME_FORMAT: 'TIME_FORMAT';
TIME_TO_SEC: 'TIME_TO_SEC';
TOUCHES: 'TOUCHES';
TO_BASE64: 'TO_BASE64';
TO_DAYS: 'TO_DAYS';
TO_SECONDS: 'TO_SECONDS';
UCASE: 'UCASE';
UNCOMPRESS: 'UNCOMPRESS';
UNCOMPRESSED_LENGTH: 'UNCOMPRESSED_LENGTH';
UNHEX: 'UNHEX';
UNIX_TIMESTAMP: 'UNIX_TIMESTAMP';
UPDATEXML: 'UPDATEXML';
UPPER: 'UPPER';
UUID: 'UUID';
UUID_SHORT: 'UUID_SHORT';
VALIDATE_PASSWORD_STRENGTH: 'VALIDATE_PASSWORD_STRENGTH';
VERSION: 'VERSION';
WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS: 'WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS';
WEEKDAY: 'WEEKDAY';
WEEKOFYEAR: 'WEEKOFYEAR';
WEIGHT_STRING: 'WEIGHT_STRING';
WITHIN: 'WITHIN';
YEARWEEK: 'YEARWEEK';
Y_FUNCTION: 'Y';
X_FUNCTION: 'X';
// Operators
// Operators. Assigns
VAR_ASSIGN: ':=';
PLUS_ASSIGN: '+=';
MINUS_ASSIGN: '-=';
MULT_ASSIGN: '*=';
DIV_ASSIGN: '/=';
MOD_ASSIGN: '%=';
AND_ASSIGN: '&=';
XOR_ASSIGN: '^=';
OR_ASSIGN: '|=';
// Operators. Arithmetics
STAR: '*';
DIVIDE: '/';
MODULE: '%';
PLUS: '+';
MINUSMINUS: '--';
MINUS: '-';
DIV: 'DIV';
MOD: 'MOD';
// Operators. Comparation
EQUAL_SYMBOL: '=';
GREATER_SYMBOL: '>';
LESS_SYMBOL: '<';
EXCLAMATION_SYMBOL: '!';
// Operators. Bit
BIT_NOT_OP: '~';
BIT_OR_OP: '|';
BIT_AND_OP: '&';
BIT_XOR_OP: '^';
// Constructors symbols
DOT: '.';
LR_BRACKET: '(';
RR_BRACKET: ')';
COMMA: ',';
SEMI: ';';
AT_SIGN: '@';
ZERO_DECIMAL: '0';
ONE_DECIMAL: '1';
TWO_DECIMAL: '2';
SINGLE_QUOTE_SYMB: '\'';
DOUBLE_QUOTE_SYMB: '"';
REVERSE_QUOTE_SYMB: '`';
COLON_SYMB: ':';
fragment QUOTE_SYMB
: SINGLE_QUOTE_SYMB | DOUBLE_QUOTE_SYMB | REVERSE_QUOTE_SYMB
;
// Charsets
CHARSET_REVERSE_QOUTE_STRING: '`' CHARSET_NAME '`';
// File's sizes
FILESIZE_LITERAL: DEC_DIGIT+ ('K'|'M'|'G'|'T');
// Literal Primitives
START_NATIONAL_STRING_LITERAL: 'N' SQUOTA_STRING;
STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING;
DECIMAL_LITERAL: DEC_DIGIT+;
HEXADECIMAL_LITERAL: 'X' '\'' (HEX_DIGIT HEX_DIGIT)+ '\''
| '0X' HEX_DIGIT+;
REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
| DEC_DIGIT+ '.' EXPONENT_NUM_PART
| (DEC_DIGIT+)? '.' (DEC_DIGIT+ EXPONENT_NUM_PART)
| DEC_DIGIT+ EXPONENT_NUM_PART;
NULL_SPEC_LITERAL: '\\' 'N';
BIT_STRING: BIT_STRING_L;
STRING_CHARSET_NAME: '_' CHARSET_NAME;
// Hack for dotID
// Prevent recognize string: .123somelatin AS ((.123), FLOAT_LITERAL), ((somelatin), ID)
// it must recoginze: .123somelatin AS ((.), DOT), (123somelatin, ID)
DOT_ID: '.' ID_LITERAL;
// Identifiers
ID: ID_LITERAL;
// DOUBLE_QUOTE_ID: '"' ~'"'+ '"';
REVERSE_QUOTE_ID: '`' ~'`'+ '`';
STRING_USER_NAME: (
SQUOTA_STRING | DQUOTA_STRING
| BQUOTA_STRING | ID_LITERAL
) '@'
(
SQUOTA_STRING | DQUOTA_STRING
| BQUOTA_STRING | ID_LITERAL
);
LOCAL_ID: '@'
(
[A-Z0-9._$]+
| SQUOTA_STRING
| DQUOTA_STRING
| BQUOTA_STRING
);
GLOBAL_ID: '@' '@'
(
[A-Z0-9._$]+
| BQUOTA_STRING
);
// Fragments for Literal primitives
fragment CHARSET_NAME: ARMSCII8 | ASCII | BIG5 | BINARY | CP1250
| CP1251 | CP1256 | CP1257 | CP850
| CP852 | CP866 | CP932 | DEC8 | EUCJPMS
| EUCKR | GB2312 | GBK | GEOSTD8 | GREEK
| HEBREW | HP8 | KEYBCS2 | KOI8R | KOI8U
| LATIN1 | LATIN2 | LATIN5 | LATIN7
| MACCE | MACROMAN | SJIS | SWE7 | TIS620
| UCS2 | UJIS | UTF16 | UTF16LE | UTF32
| UTF8 | UTF8MB3 | UTF8MB4;
fragment EXPONENT_NUM_PART: 'E' [-+]? DEC_DIGIT+;
fragment ID_LITERAL: [A-Z_$0-9]*?[A-Z_$]+?[A-Z_$0-9]*;
fragment DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"';
fragment SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\'';
fragment BQUOTA_STRING: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';
fragment HEX_DIGIT: [0-9A-F];
fragment DEC_DIGIT: [0-9];
fragment BIT_STRING_L: 'B' '\'' [01]+ '\'';
// Last tokens must generate Errors
ERROR_RECONGNIGION: . -> channel(ERRORCHANNEL); | 54,782 | ANTLR | .g4 | 1,110 | 47.217117 | 96 | 0.349217 | qiub649691422/demo-sharding | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | 6fb4fc2507aa2803e4874d8048af0b7d69528c3cfa33da6d2785c77686b4095d | true | true | false | false |
118 | MySqlParser.g4 | qiub649691422_demo-sharding/src/main/java/com/demo/sharding/advance/MySqlParser.g4 | parser grammar MySqlParser;
options { tokenVocab=MySqlLexer; }
// Top Level Description
root
: sqlStatements? MINUSMINUS? EOF
;
sqlStatements
: (sqlStatement MINUSMINUS? SEMI? | emptyStatement)*
(sqlStatement (MINUSMINUS? SEMI)? | emptyStatement)
;
sqlStatement
: ddlStatement | dmlStatement | transactionStatement
| replicationStatement | preparedStatement
| administrationStatement | utilityStatement
;
emptyStatement
: SEMI
;
ddlStatement
: createDatabase | createEvent | createIndex
| createLogfileGroup | createProcedure | createFunction
| createServer | createTable | createTablespaceInnodb
| createTablespaceNdb | createTrigger | createView
| alterDatabase | alterEvent | alterFunction
| alterInstance | alterLogfileGroup | alterProcedure
| alterServer | alterTable | alterTablespace | alterView
| dropDatabase | dropEvent | dropIndex
| dropLogfileGroup | dropProcedure | dropFunction
| dropServer | dropTable | dropTablespace
| dropTrigger | dropView
| renameTable | truncateTable
;
dmlStatement
: selectStatement | insertStatement | updateStatement
| deleteStatement | replaceStatement | callStatement
| loadDataStatement | loadXmlStatement | doStatement
| handlerStatement
;
transactionStatement
: startTransaction
| beginWork | commitWork | rollbackWork
| savepointStatement | rollbackStatement
| releaseStatement | lockTables | unlockTables
;
replicationStatement
: changeMaster | changeReplicationFilter | purgeBinaryLogs
| resetMaster | resetSlave | startSlave | stopSlave
| startGroupReplication | stopGroupReplication
| xaStartTransaction | xaEndTransaction | xaPrepareStatement
| xaCommitWork | xaRollbackWork | xaRecoverWork
;
preparedStatement
: prepareStatement | executeStatement | deallocatePrepare
;
// remark: NOT INCLUDED IN sqlStatement, but include in body
// of routine's statements
compoundStatement
: blockStatement
| caseStatement | ifStatement | leaveStatement
| loopStatement | repeatStatement | whileStatement
| iterateStatement | returnStatement | cursorStatement
;
administrationStatement
: alterUser | createUser | dropUser | grantStatement
| grantProxy | renameUser | revokeStatement
| revokeProxy | analyzeTable | checkTable
| checksumTable | optimizeTable | repairTable
| createUdfunction | installPlugin | uninstallPlugin
| setStatement | showStatement | binlogStatement
| cacheIndexStatement | flushStatement | killStatement
| loadIndexIntoCache | resetStatement
| shutdownStatement
;
utilityStatement
: simpleDescribeStatement | fullDescribeStatement
| helpStatement | useStatement | signalStatement
| resignalStatement | diagnosticsStatement
;
// Data Definition Language
// Create statements
createDatabase
: CREATE dbFormat=(DATABASE | SCHEMA)
ifNotExists? uid createDatabaseOption*
;
createEvent
: CREATE ownerStatement? EVENT ifNotExists? fullId
ON SCHEDULE scheduleExpression
(ON COMPLETION NOT? PRESERVE)? enableType?
(COMMENT STRING_LITERAL)?
DO routineBody
;
createIndex
: CREATE
intimeAction=(ONLINE | OFFLINE)?
indexCategory=(UNIQUE | FULLTEXT | SPATIAL)?
INDEX uid indexType?
ON tableName indexColumnNames
indexOption*
(
ALGORITHM '='? algType=(DEFAULT | INPLACE | COPY)
| LOCK '='?
lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE)
)*
;
createLogfileGroup
: CREATE LOGFILE GROUP uid
ADD UNDOFILE undoFile=STRING_LITERAL
(INITIAL_SIZE '='? initSize=fileSizeLiteral)?
(UNDO_BUFFER_SIZE '='? undoSize=fileSizeLiteral)?
(REDO_BUFFER_SIZE '='? redoSize=fileSizeLiteral)?
(NODEGROUP '='? uid)?
WAIT?
(COMMENT '='? comment=STRING_LITERAL)?
ENGINE '='? engineName
;
createProcedure
: CREATE ownerStatement?
PROCEDURE fullId
'(' procedureParameter? (',' procedureParameter)* ')'
routineOption*
routineBody
;
createFunction
: CREATE ownerStatement?
FUNCTION fullId
'(' functionParameter? (',' functionParameter)* ')'
RETURNS dataType
routineOption*
(routineBody | returnStatement)
;
createServer
: CREATE SERVER uid
FOREIGN DATA WRAPPER wrapperName=(MYSQL | STRING_LITERAL)
OPTIONS '(' serverOption (',' serverOption)* ')'
;
createTable
: CREATE TEMPORARY? TABLE ifNotExists?
tableName
(
LIKE tableName
| '(' LIKE parenthesisTable=tableName ')'
) #copyCreateTable
| CREATE TEMPORARY? TABLE ifNotExists?
tableName createDefinitions?
( tableOption (','? tableOption)* )?
partitionDefinitions? keyViolate=(IGNORE | REPLACE)?
AS? selectStatement #queryCreateTable
| CREATE TEMPORARY? TABLE ifNotExists?
tableName createDefinitions
( tableOption (','? tableOption)* )?
partitionDefinitions? #columnCreateTable
;
createTablespaceInnodb
: CREATE TABLESPACE uid
ADD DATAFILE datafile=STRING_LITERAL
(FILE_BLOCK_SIZE '=' fileBlockSize=fileSizeLiteral)?
(ENGINE '='? engineName)?
;
createTablespaceNdb
: CREATE TABLESPACE uid
ADD DATAFILE datafile=STRING_LITERAL
USE LOGFILE GROUP uid
(EXTENT_SIZE '='? extentSize=fileSizeLiteral)?
(INITIAL_SIZE '='? initialSize=fileSizeLiteral)?
(AUTOEXTEND_SIZE '='? autoextendSize=fileSizeLiteral)?
(MAX_SIZE '='? maxSize=fileSizeLiteral)?
(NODEGROUP '='? uid)?
WAIT?
(COMMENT '='? comment=STRING_LITERAL)?
ENGINE '='? engineName
;
createTrigger
: CREATE ownerStatement?
TRIGGER thisTrigger=fullId
triggerTime=(BEFORE | AFTER)
triggerEvent=(INSERT | UPDATE | DELETE)
ON tableName FOR EACH ROW
(triggerPlace=(FOLLOWS | PRECEDES) otherTrigger=fullId)?
routineBody
;
createView
: CREATE (OR REPLACE)?
(
ALGORITHM '=' algType=(UNDEFINED | MERGE | TEMPTABLE)
)?
ownerStatement?
(SQL SECURITY secContext=(DEFINER | INVOKER))?
VIEW fullId ('(' uidList ')')? AS selectStatement
(WITH checkOption=(CASCADED | LOCAL)? CHECK OPTION)?
;
// details
createDatabaseOption
: DEFAULT? (CHARACTER SET | CHARSET) '='? (charsetName | DEFAULT)
| DEFAULT? COLLATE '='? collationName
;
ownerStatement
: DEFINER '=' (userName | CURRENT_USER ( '(' ')')?)
;
scheduleExpression
: AT timestampValue intervalExpr* #preciseSchedule
| EVERY (decimalLiteral | expression) intervalType
(
STARTS startTimestamp=timestampValue
(startIntervals+=intervalExpr)*
)?
(
ENDS endTimestamp=timestampValue
(endIntervals+=intervalExpr)*
)? #intervalSchedule
;
timestampValue
: CURRENT_TIMESTAMP
| stringLiteral
| decimalLiteral
| expression
;
intervalExpr
: '+' INTERVAL (decimalLiteral | expression) intervalType
;
intervalType
: intervalTypeBase
| YEAR | YEAR_MONTH | DAY_HOUR | DAY_MINUTE
| DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND
| SECOND_MICROSECOND | MINUTE_MICROSECOND
| HOUR_MICROSECOND | DAY_MICROSECOND
;
enableType
: ENABLE | DISABLE | DISABLE ON SLAVE
;
indexType
: USING (BTREE | HASH)
;
indexOption
: KEY_BLOCK_SIZE '='? fileSizeLiteral
| indexType
| WITH PARSER uid
| COMMENT STRING_LITERAL
| INVISIBLE
| VISIBLE
;
procedureParameter
: direction=(IN | OUT | INOUT)? uid dataType
;
functionParameter
: uid dataType
;
routineOption
: COMMENT STRING_LITERAL #routineComment
| LANGUAGE SQL #routineLanguage
| NOT? DETERMINISTIC #routineBehavior
| (
CONTAINS SQL | NO SQL | READS SQL DATA
| MODIFIES SQL DATA
) #routineData
| SQL SECURITY context=(DEFINER | INVOKER) #routineSecurity
;
serverOption
: HOST STRING_LITERAL
| DATABASE STRING_LITERAL
| USER STRING_LITERAL
| PASSWORD STRING_LITERAL
| SOCKET STRING_LITERAL
| OWNER STRING_LITERAL
| PORT decimalLiteral
;
createDefinitions
: '(' createDefinition (',' createDefinition)* ')'
;
createDefinition
: uid columnDefinition #columnDeclaration
| tableConstraint #constraintDeclaration
| indexColumnDefinition #indexDeclaration
;
columnDefinition
: dataType columnConstraint*
;
columnConstraint
: nullNotnull #nullColumnConstraint
| DEFAULT defaultValue #defaultColumnConstraint
| (AUTO_INCREMENT | ON UPDATE currentTimestamp) #autoIncrementColumnConstraint
| PRIMARY? KEY #primaryKeyColumnConstraint
| UNIQUE KEY? #uniqueKeyColumnConstraint
| COMMENT STRING_LITERAL #commentColumnConstraint
| COLUMN_FORMAT colformat=(FIXED | DYNAMIC | DEFAULT) #formatColumnConstraint
| STORAGE storageval=(DISK | MEMORY | DEFAULT) #storageColumnConstraint
| referenceDefinition #referenceColumnConstraint
| COLLATE collationName #collateColumnConstraint
| (GENERATED ALWAYS)? AS '(' expression ')' (VIRTUAL | STORED)? #generatedColumnConstraint
| SERIAL DEFAULT VALUE #serialDefaultColumnConstraint
;
tableConstraint
: (CONSTRAINT name=uid?)?
PRIMARY KEY index=uid? indexType?
indexColumnNames indexOption* #primaryKeyTableConstraint
| (CONSTRAINT name=uid?)?
UNIQUE indexFormat=(INDEX | KEY)? index=uid?
indexType? indexColumnNames indexOption* #uniqueKeyTableConstraint
| (CONSTRAINT name=uid?)?
FOREIGN KEY index=uid? indexColumnNames
referenceDefinition #foreignKeyTableConstraint
| (CONSTRAINT name=uid?)?
CHECK '(' expression ')' #checkTableConstraint
;
referenceDefinition
: REFERENCES tableName indexColumnNames?
(MATCH matchType=(FULL | PARTIAL | SIMPLE))?
referenceAction?
;
referenceAction
: ON DELETE onDelete=referenceControlType
(
ON UPDATE onUpdate=referenceControlType
)?
| ON UPDATE onUpdate=referenceControlType
(
ON DELETE onDelete=referenceControlType
)?
;
referenceControlType
: RESTRICT | CASCADE | SET NULL_LITERAL | NO ACTION
;
indexColumnDefinition
: indexFormat=(INDEX | KEY) uid? indexType?
indexColumnNames indexOption* #simpleIndexDeclaration
| (FULLTEXT | SPATIAL)
indexFormat=(INDEX | KEY)? uid?
indexColumnNames indexOption* #specialIndexDeclaration
;
tableOption
: ENGINE '='? engineName #tableOptionEngine
| AUTO_INCREMENT '='? decimalLiteral #tableOptionAutoIncrement
| AVG_ROW_LENGTH '='? decimalLiteral #tableOptionAverage
| DEFAULT? (CHARACTER SET | CHARSET) '='? (charsetName|DEFAULT) #tableOptionCharset
| (CHECKSUM | PAGE_CHECKSUM) '='? boolValue=('0' | '1') #tableOptionChecksum
| DEFAULT? COLLATE '='? collationName #tableOptionCollate
| COMMENT '='? STRING_LITERAL #tableOptionComment
| COMPRESSION '='? (STRING_LITERAL | ID) #tableOptionCompression
| CONNECTION '='? STRING_LITERAL #tableOptionConnection
| DATA DIRECTORY '='? STRING_LITERAL #tableOptionDataDirectory
| DELAY_KEY_WRITE '='? boolValue=('0' | '1') #tableOptionDelay
| ENCRYPTION '='? STRING_LITERAL #tableOptionEncryption
| INDEX DIRECTORY '='? STRING_LITERAL #tableOptionIndexDirectory
| INSERT_METHOD '='? insertMethod=(NO | FIRST | LAST) #tableOptionInsertMethod
| KEY_BLOCK_SIZE '='? fileSizeLiteral #tableOptionKeyBlockSize
| MAX_ROWS '='? decimalLiteral #tableOptionMaxRows
| MIN_ROWS '='? decimalLiteral #tableOptionMinRows
| PACK_KEYS '='? extBoolValue=('0' | '1' | DEFAULT) #tableOptionPackKeys
| PASSWORD '='? STRING_LITERAL #tableOptionPassword
| ROW_FORMAT '='?
rowFormat=(
DEFAULT | DYNAMIC | FIXED | COMPRESSED
| REDUNDANT | COMPACT
) #tableOptionRowFormat
| STATS_AUTO_RECALC '='? extBoolValue=(DEFAULT | '0' | '1') #tableOptionRecalculation
| STATS_PERSISTENT '='? extBoolValue=(DEFAULT | '0' | '1') #tableOptionPersistent
| STATS_SAMPLE_PAGES '='? decimalLiteral #tableOptionSamplePage
| TABLESPACE uid tablespaceStorage? #tableOptionTablespace
| tablespaceStorage #tableOptionTablespace
| UNION '='? '(' tables ')' #tableOptionUnion
;
tablespaceStorage
: STORAGE (DISK | MEMORY | DEFAULT)
;
partitionDefinitions
: PARTITION BY partitionFunctionDefinition
(PARTITIONS count=decimalLiteral)?
(
SUBPARTITION BY subpartitionFunctionDefinition
(SUBPARTITIONS subCount=decimalLiteral)?
)?
('(' partitionDefinition (',' partitionDefinition)* ')')?
;
partitionFunctionDefinition
: LINEAR? HASH '(' expression ')' #partitionFunctionHash
| LINEAR? KEY (ALGORITHM '=' algType=('1' | '2'))?
'(' uidList ')' #partitionFunctionKey
| RANGE ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionRange
| LIST ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionList
;
subpartitionFunctionDefinition
: LINEAR? HASH '(' expression ')' #subPartitionFunctionHash
| LINEAR? KEY (ALGORITHM '=' algType=('1' | '2'))?
'(' uidList ')' #subPartitionFunctionKey
;
partitionDefinition
: PARTITION uid VALUES LESS THAN
'('
partitionDefinerAtom (',' partitionDefinerAtom)*
')'
partitionOption*
(subpartitionDefinition (',' subpartitionDefinition)*)? #partitionComparision
| PARTITION uid VALUES LESS THAN
partitionDefinerAtom partitionOption*
(subpartitionDefinition (',' subpartitionDefinition)*)? #partitionComparision
| PARTITION uid VALUES IN
'('
partitionDefinerAtom (',' partitionDefinerAtom)*
')'
partitionOption*
(subpartitionDefinition (',' subpartitionDefinition)*)? #partitionListAtom
| PARTITION uid VALUES IN
'('
partitionDefinerVector (',' partitionDefinerVector)*
')'
partitionOption*
(subpartitionDefinition (',' subpartitionDefinition)*)? #partitionListVector
| PARTITION uid partitionOption*
(subpartitionDefinition (',' subpartitionDefinition)*)? #partitionSimple
;
partitionDefinerAtom
: constant | expression | MAXVALUE
;
partitionDefinerVector
: '(' partitionDefinerAtom (',' partitionDefinerAtom)+ ')'
;
subpartitionDefinition
: SUBPARTITION uid partitionOption*
;
partitionOption
: STORAGE? ENGINE '='? engineName #partitionOptionEngine
| COMMENT '='? comment=STRING_LITERAL #partitionOptionComment
| DATA DIRECTORY '='? dataDirectory=STRING_LITERAL #partitionOptionDataDirectory
| INDEX DIRECTORY '='? indexDirectory=STRING_LITERAL #partitionOptionIndexDirectory
| MAX_ROWS '='? maxRows=decimalLiteral #partitionOptionMaxRows
| MIN_ROWS '='? minRows=decimalLiteral #partitionOptionMinRows
| TABLESPACE '='? tablespace=uid #partitionOptionTablespace
| NODEGROUP '='? nodegroup=uid #partitionOptionNodeGroup
;
// Alter statements
alterDatabase
: ALTER dbFormat=(DATABASE | SCHEMA) uid?
createDatabaseOption+ #alterSimpleDatabase
| ALTER dbFormat=(DATABASE | SCHEMA) uid
UPGRADE DATA DIRECTORY NAME #alterUpgradeName
;
alterEvent
: ALTER ownerStatement?
EVENT fullId
(ON SCHEDULE scheduleExpression)?
(ON COMPLETION NOT? PRESERVE)?
(RENAME TO fullId)? enableType?
(COMMENT STRING_LITERAL)?
(DO routineBody)?
;
alterFunction
: ALTER FUNCTION fullId routineOption*
;
alterInstance
: ALTER INSTANCE ROTATE INNODB MASTER KEY
;
alterLogfileGroup
: ALTER LOGFILE GROUP uid
ADD UNDOFILE STRING_LITERAL
(INITIAL_SIZE '='? fileSizeLiteral)?
WAIT? ENGINE '='? engineName
;
alterProcedure
: ALTER PROCEDURE fullId routineOption*
;
alterServer
: ALTER SERVER uid OPTIONS
'(' serverOption (',' serverOption)* ')'
;
alterTable
: ALTER intimeAction=(ONLINE | OFFLINE)?
IGNORE? TABLE tableName
(alterSpecification (',' alterSpecification)*)?
partitionDefinitions?
;
alterTablespace
: ALTER TABLESPACE uid
objectAction=(ADD | DROP) DATAFILE STRING_LITERAL
(INITIAL_SIZE '=' fileSizeLiteral)?
WAIT?
ENGINE '='? engineName
;
alterView
: ALTER
(
ALGORITHM '=' algType=(UNDEFINED | MERGE | TEMPTABLE)
)?
ownerStatement?
(SQL SECURITY secContext=(DEFINER | INVOKER))?
VIEW fullId ('(' uidList ')')? AS selectStatement
(WITH checkOpt=(CASCADED | LOCAL)? CHECK OPTION)?
;
// details
alterSpecification
: tableOption (','? tableOption)* #alterByTableOption
| ADD COLUMN? uid columnDefinition (FIRST | AFTER uid)? #alterByAddColumn
| ADD COLUMN?
'('
uid columnDefinition ( ',' uid columnDefinition)*
')' #alterByAddColumns
| ADD indexFormat=(INDEX | KEY) uid? indexType?
indexColumnNames indexOption* #alterByAddIndex
| ADD (CONSTRAINT name=uid?)? PRIMARY KEY index=uid?
indexType? indexColumnNames indexOption* #alterByAddPrimaryKey
| ADD (CONSTRAINT name=uid?)? UNIQUE
indexFormat=(INDEX | KEY)? indexName=uid?
indexType? indexColumnNames indexOption* #alterByAddUniqueKey
| ADD keyType=(FULLTEXT | SPATIAL)
indexFormat=(INDEX | KEY)? uid?
indexColumnNames indexOption* #alterByAddSpecialIndex
| ADD (CONSTRAINT name=uid?)? FOREIGN KEY
indexName=uid? indexColumnNames referenceDefinition #alterByAddForeignKey
| ADD (CONSTRAINT name=uid?)? CHECK '(' expression ')' #alterByAddCheckTableConstraint
| ALGORITHM '='? algType=(DEFAULT | INPLACE | COPY) #alterBySetAlgorithm
| ALTER COLUMN? uid
(SET DEFAULT defaultValue | DROP DEFAULT) #alterByChangeDefault
| CHANGE COLUMN? oldColumn=uid
newColumn=uid columnDefinition
(FIRST | AFTER afterColumn=uid)? #alterByChangeColumn
| RENAME COLUMN oldColumn=uid TO newColumn=uid #alterByRenameColumn
| LOCK '='? lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE) #alterByLock
| MODIFY COLUMN?
uid columnDefinition (FIRST | AFTER uid)? #alterByModifyColumn
| DROP COLUMN? uid RESTRICT? #alterByDropColumn
| DROP PRIMARY KEY #alterByDropPrimaryKey
| RENAME indexFormat=(INDEX | KEY) uid TO uid #alterByRenameIndex
| DROP indexFormat=(INDEX | KEY) uid #alterByDropIndex
| DROP FOREIGN KEY uid #alterByDropForeignKey
| DISABLE KEYS #alterByDisableKeys
| ENABLE KEYS #alterByEnableKeys
| RENAME renameFormat=(TO | AS)? (uid | fullId) #alterByRename
| ORDER BY uidList #alterByOrder
| CONVERT TO CHARACTER SET charsetName
(COLLATE collationName)? #alterByConvertCharset
| DEFAULT? CHARACTER SET '=' charsetName
(COLLATE '=' collationName)? #alterByDefaultCharset
| DISCARD TABLESPACE #alterByDiscardTablespace
| IMPORT TABLESPACE #alterByImportTablespace
| FORCE #alterByForce
| validationFormat=(WITHOUT | WITH) VALIDATION #alterByValidate
| ADD PARTITION
'('
partitionDefinition (',' partitionDefinition)*
')' #alterByAddPartition
| DROP PARTITION uidList #alterByDropPartition
| DISCARD PARTITION (uidList | ALL) TABLESPACE #alterByDiscardPartition
| IMPORT PARTITION (uidList | ALL) TABLESPACE #alterByImportPartition
| TRUNCATE PARTITION (uidList | ALL) #alterByTruncatePartition
| COALESCE PARTITION decimalLiteral #alterByCoalescePartition
| REORGANIZE PARTITION uidList
INTO '('
partitionDefinition (',' partitionDefinition)*
')' #alterByReorganizePartition
| EXCHANGE PARTITION uid WITH TABLE tableName
(validationFormat=(WITH | WITHOUT) VALIDATION)? #alterByExchangePartition
| ANALYZE PARTITION (uidList | ALL) #alterByAnalyzePartition
| CHECK PARTITION (uidList | ALL) #alterByCheckPartition
| OPTIMIZE PARTITION (uidList | ALL) #alterByOptimizePartition
| REBUILD PARTITION (uidList | ALL) #alterByRebuildPartition
| REPAIR PARTITION (uidList | ALL) #alterByRepairPartition
| REMOVE PARTITIONING #alterByRemovePartitioning
| UPGRADE PARTITIONING #alterByUpgradePartitioning
;
// Drop statements
dropDatabase
: DROP dbFormat=(DATABASE | SCHEMA) ifExists? uid
;
dropEvent
: DROP EVENT ifExists? fullId
;
dropIndex
: DROP INDEX intimeAction=(ONLINE | OFFLINE)?
uid ON tableName
(
ALGORITHM '='? algType=(DEFAULT | INPLACE | COPY)
| LOCK '='?
lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE)
)*
;
dropLogfileGroup
: DROP LOGFILE GROUP uid ENGINE '=' engineName
;
dropProcedure
: DROP PROCEDURE ifExists? fullId
;
dropFunction
: DROP FUNCTION ifExists? fullId
;
dropServer
: DROP SERVER ifExists? uid
;
dropTable
: DROP TEMPORARY? TABLE ifExists?
tables dropType=(RESTRICT | CASCADE)?
;
dropTablespace
: DROP TABLESPACE uid (ENGINE '='? engineName)?
;
dropTrigger
: DROP TRIGGER ifExists? fullId
;
dropView
: DROP VIEW ifExists?
fullId (',' fullId)* dropType=(RESTRICT | CASCADE)?
;
// Other DDL statements
renameTable
: RENAME TABLE
renameTableClause (',' renameTableClause)*
;
renameTableClause
: tableName TO tableName
;
truncateTable
: TRUNCATE TABLE? tableName
;
// Data Manipulation Language
// Primary DML Statements
callStatement
: CALL fullId
(
'(' (constants | expressions)? ')'
)?
;
deleteStatement
: singleDeleteStatement | multipleDeleteStatement
;
doStatement
: DO expressions
;
handlerStatement
: handlerOpenStatement
| handlerReadIndexStatement
| handlerReadStatement
| handlerCloseStatement
;
insertStatement
: INSERT
priority=(LOW_PRIORITY | DELAYED | HIGH_PRIORITY)?
IGNORE? INTO? tableName
(PARTITION '(' partitions=uidList? ')' )?
(
('(' columns=uidList ')')? insertStatementValue
| SET
setFirst=updatedElement
(',' setElements+=updatedElement)*
)
(
ON DUPLICATE KEY UPDATE
duplicatedFirst=updatedElement
(',' duplicatedElements+=updatedElement)*
)?
;
loadDataStatement
: LOAD DATA
priority=(LOW_PRIORITY | CONCURRENT)?
LOCAL? INFILE filename=STRING_LITERAL
violation=(REPLACE | IGNORE)?
INTO TABLE tableName
(PARTITION '(' uidList ')' )?
(CHARACTER SET charset=charsetName)?
(
fieldsFormat=(FIELDS | COLUMNS)
selectFieldsInto+
)?
(
LINES
selectLinesInto+
)?
(
IGNORE decimalLiteral linesFormat=(LINES | ROWS)
)?
( '(' assignmentField (',' assignmentField)* ')' )?
(SET updatedElement (',' updatedElement)*)?
;
loadXmlStatement
: LOAD XML
priority=(LOW_PRIORITY | CONCURRENT)?
LOCAL? INFILE filename=STRING_LITERAL
violation=(REPLACE | IGNORE)?
INTO TABLE tableName
(CHARACTER SET charset=charsetName)?
(ROWS IDENTIFIED BY '<' tag=STRING_LITERAL '>')?
( IGNORE decimalLiteral linesFormat=(LINES | ROWS) )?
( '(' assignmentField (',' assignmentField)* ')' )?
(SET updatedElement (',' updatedElement)*)?
;
replaceStatement
: REPLACE priority=(LOW_PRIORITY | DELAYED)?
INTO? tableName
(PARTITION '(' partitions=uidList ')' )?
(
('(' columns=uidList ')')? insertStatementValue
| SET
setFirst=updatedElement
(',' setElements+=updatedElement)*
)
;
selectStatement
: querySpecification lockClause? #simpleSelect
| queryExpression lockClause? #parenthesisSelect
| querySpecificationNointo unionStatement+
(
UNION unionType=(ALL | DISTINCT)?
(querySpecification | queryExpression)
)?
orderByClause? limitClause? lockClause? #unionSelect
| queryExpressionNointo unionParenthesis+
(
UNION unionType=(ALL | DISTINCT)?
queryExpression
)?
orderByClause? limitClause? lockClause? #unionParenthesisSelect
;
updateStatement
: singleUpdateStatement | multipleUpdateStatement
;
// details
insertStatementValue
: selectStatement
| insertFormat=(VALUES | VALUE)
'(' expressionsWithDefaults? ')'
(',' '(' expressionsWithDefaults? ')')*
;
updatedElement
: fullColumnName '=' (expression | DEFAULT)
;
assignmentField
: uid | LOCAL_ID
;
lockClause
: FOR UPDATE | LOCK IN SHARE MODE
;
// Detailed DML Statements
singleDeleteStatement
: DELETE priority=LOW_PRIORITY? QUICK? IGNORE?
FROM tableName
(PARTITION '(' uidList ')' )?
(WHERE expression)?
orderByClause? (LIMIT limitClauseAtom)?
;
multipleDeleteStatement
: DELETE priority=LOW_PRIORITY? QUICK? IGNORE?
(
tableName ('.' '*')? ( ',' tableName ('.' '*')? )*
FROM tableSources
| FROM
tableName ('.' '*')? ( ',' tableName ('.' '*')? )*
USING tableSources
)
(WHERE expression)?
;
handlerOpenStatement
: HANDLER tableName OPEN (AS? uid)?
;
handlerReadIndexStatement
: HANDLER tableName READ index=uid
(
comparisonOperator '(' constants ')'
| moveOrder=(FIRST | NEXT | PREV | LAST)
)
(WHERE expression)? (LIMIT limitClauseAtom)?
;
handlerReadStatement
: HANDLER tableName READ moveOrder=(FIRST | NEXT)
(WHERE expression)? (LIMIT limitClauseAtom)?
;
handlerCloseStatement
: HANDLER tableName CLOSE
;
singleUpdateStatement
: UPDATE priority=LOW_PRIORITY? IGNORE? tableName (AS? uid)?
SET updatedElement (',' updatedElement)*
(WHERE expression)? orderByClause? limitClause?
;
multipleUpdateStatement
: UPDATE priority=LOW_PRIORITY? IGNORE? tableSources
SET updatedElement (',' updatedElement)*
(WHERE expression)?
;
// details
orderByClause
: ORDER BY orderByExpression (',' orderByExpression)*
;
orderByExpression
: expression order=(ASC | DESC)?
;
tableSources
: tableSource (',' tableSource)*
;
tableSource
: tableSourceItem joinPart* #tableSourceBase
| '(' tableSourceItem joinPart* ')' #tableSourceNested
;
tableSourceItem
: tableName
(PARTITION '(' uidList ')' )? (AS? alias=uid)?
(indexHint (',' indexHint)* )? #atomTableItem
| (
selectStatement
| '(' parenthesisSubquery=selectStatement ')'
)
AS? alias=uid #subqueryTableItem
| '(' tableSources ')' #tableSourcesItem
;
indexHint
: indexHintAction=(USE | IGNORE | FORCE)
keyFormat=(INDEX|KEY) ( FOR indexHintType)?
'(' uidList ')'
;
indexHintType
: JOIN | ORDER BY | GROUP BY
;
joinPart
: (INNER | CROSS)? JOIN tableSourceItem
(
ON expression
| USING '(' uidList ')'
)? #innerJoin
| STRAIGHT_JOIN tableSourceItem (ON expression)? #straightJoin
| (LEFT | RIGHT) OUTER? JOIN tableSourceItem
(
ON expression
| USING '(' uidList ')'
) #outerJoin
| NATURAL ((LEFT | RIGHT) OUTER?)? JOIN tableSourceItem #naturalJoin
;
// Select Statement's Details
queryExpression
: '(' querySpecification ')'
| '(' queryExpression ')'
;
queryExpressionNointo
: '(' querySpecificationNointo ')'
| '(' queryExpressionNointo ')'
;
querySpecification
: SELECT selectSpec* selectElements selectIntoExpression?
fromClause? orderByClause? limitClause?
| SELECT selectSpec* selectElements
fromClause? orderByClause? limitClause? selectIntoExpression?
;
querySpecificationNointo
: SELECT selectSpec* selectElements
fromClause? orderByClause? limitClause?
;
unionParenthesis
: UNION unionType=(ALL | DISTINCT)? queryExpressionNointo
;
unionStatement
: UNION unionType=(ALL | DISTINCT)?
(querySpecificationNointo | queryExpressionNointo)
;
// details
selectSpec
: (ALL | DISTINCT | DISTINCTROW)
| HIGH_PRIORITY | STRAIGHT_JOIN | SQL_SMALL_RESULT
| SQL_BIG_RESULT | SQL_BUFFER_RESULT
| (SQL_CACHE | SQL_NO_CACHE)
| SQL_CALC_FOUND_ROWS
;
selectElements
: (star='*' | selectElement ) (',' selectElement)*
;
selectElement
: fullId '.' '*' #selectStarElement
| fullColumnName (AS? uid)? #selectColumnElement
| functionCall (AS? uid)? #selectFunctionElement
| (LOCAL_ID VAR_ASSIGN)? expression (AS? uid)? #selectExpressionElement
;
selectIntoExpression
: INTO assignmentField (',' assignmentField )* #selectIntoVariables
| INTO DUMPFILE STRING_LITERAL #selectIntoDumpFile
| (
INTO OUTFILE filename=STRING_LITERAL
(CHARACTER SET charset=charsetName)?
(
fieldsFormat=(FIELDS | COLUMNS)
selectFieldsInto+
)?
(
LINES selectLinesInto+
)?
) #selectIntoTextFile
;
selectFieldsInto
: TERMINATED BY terminationField=STRING_LITERAL
| OPTIONALLY? ENCLOSED BY enclosion=STRING_LITERAL
| ESCAPED BY escaping=STRING_LITERAL
;
selectLinesInto
: STARTING BY starting=STRING_LITERAL
| TERMINATED BY terminationLine=STRING_LITERAL
;
fromClause
: FROM tableSources
(WHERE whereExpr=expression)?
(
GROUP BY
groupByItem (',' groupByItem)*
(WITH ROLLUP)?
)?
(HAVING havingExpr=expression)?
;
groupByItem
: expression order=(ASC | DESC)?
;
limitClause
: LIMIT
(
(offset=limitClauseAtom ',')? limit=limitClauseAtom
| limit=limitClauseAtom OFFSET offset=limitClauseAtom
)
;
limitClauseAtom
: decimalLiteral | mysqlVariable
;
// Transaction's Statements
startTransaction
: START TRANSACTION (transactionMode (',' transactionMode)* )?
;
beginWork
: BEGIN WORK?
;
commitWork
: COMMIT WORK?
(AND nochain=NO? CHAIN)?
(norelease=NO? RELEASE)?
;
rollbackWork
: ROLLBACK WORK?
(AND nochain=NO? CHAIN)?
(norelease=NO? RELEASE)?
;
savepointStatement
: SAVEPOINT uid
;
rollbackStatement
: ROLLBACK WORK? TO SAVEPOINT? uid
;
releaseStatement
: RELEASE SAVEPOINT uid
;
lockTables
: LOCK TABLES lockTableElement (',' lockTableElement)*
;
unlockTables
: UNLOCK TABLES
;
// details
setAutocommitStatement
: SET AUTOCOMMIT '=' autocommitValue=('0' | '1')
;
setTransactionStatement
: SET transactionContext=(GLOBAL | SESSION)? TRANSACTION
transactionOption (',' transactionOption)*
;
transactionMode
: WITH CONSISTENT SNAPSHOT
| READ WRITE
| READ ONLY
;
lockTableElement
: tableName (AS? uid)? lockAction
;
lockAction
: READ LOCAL? | LOW_PRIORITY? WRITE
;
transactionOption
: ISOLATION LEVEL transactionLevel
| READ WRITE
| READ ONLY
;
transactionLevel
: REPEATABLE READ
| READ COMMITTED
| READ UNCOMMITTED
| SERIALIZABLE
;
// Replication's Statements
// Base Replication
changeMaster
: CHANGE MASTER TO
masterOption (',' masterOption)* channelOption?
;
changeReplicationFilter
: CHANGE REPLICATION FILTER
replicationFilter (',' replicationFilter)*
;
purgeBinaryLogs
: PURGE purgeFormat=(BINARY | MASTER) LOGS
(
TO fileName=STRING_LITERAL
| BEFORE timeValue=STRING_LITERAL
)
;
resetMaster
: RESET MASTER
;
resetSlave
: RESET SLAVE ALL? channelOption?
;
startSlave
: START SLAVE (threadType (',' threadType)*)?
(UNTIL untilOption)?
connectionOption* channelOption?
;
stopSlave
: STOP SLAVE (threadType (',' threadType)*)?
;
startGroupReplication
: START GROUP_REPLICATION
;
stopGroupReplication
: STOP GROUP_REPLICATION
;
// details
masterOption
: stringMasterOption '=' STRING_LITERAL #masterStringOption
| decimalMasterOption '=' decimalLiteral #masterDecimalOption
| boolMasterOption '=' boolVal=('0' | '1') #masterBoolOption
| MASTER_HEARTBEAT_PERIOD '=' REAL_LITERAL #masterRealOption
| IGNORE_SERVER_IDS '=' '(' (uid (',' uid)*)? ')' #masterUidListOption
;
stringMasterOption
: MASTER_BIND | MASTER_HOST | MASTER_USER | MASTER_PASSWORD
| MASTER_LOG_FILE | RELAY_LOG_FILE | MASTER_SSL_CA
| MASTER_SSL_CAPATH | MASTER_SSL_CERT | MASTER_SSL_CRL
| MASTER_SSL_CRLPATH | MASTER_SSL_KEY | MASTER_SSL_CIPHER
| MASTER_TLS_VERSION
;
decimalMasterOption
: MASTER_PORT | MASTER_CONNECT_RETRY | MASTER_RETRY_COUNT
| MASTER_DELAY | MASTER_LOG_POS | RELAY_LOG_POS
;
boolMasterOption
: MASTER_AUTO_POSITION | MASTER_SSL
| MASTER_SSL_VERIFY_SERVER_CERT
;
channelOption
: FOR CHANNEL STRING_LITERAL
;
replicationFilter
: REPLICATE_DO_DB '=' '(' uidList ')' #doDbReplication
| REPLICATE_IGNORE_DB '=' '(' uidList ')' #ignoreDbReplication
| REPLICATE_DO_TABLE '=' '(' tables ')' #doTableReplication
| REPLICATE_IGNORE_TABLE '=' '(' tables ')' #ignoreTableReplication
| REPLICATE_WILD_DO_TABLE '=' '(' simpleStrings ')' #wildDoTableReplication
| REPLICATE_WILD_IGNORE_TABLE
'=' '(' simpleStrings ')' #wildIgnoreTableReplication
| REPLICATE_REWRITE_DB '='
'(' tablePair (',' tablePair)* ')' #rewriteDbReplication
;
tablePair
: '(' firstTable=tableName ',' secondTable=tableName ')'
;
threadType
: IO_THREAD | SQL_THREAD
;
untilOption
: gtids=(SQL_BEFORE_GTIDS | SQL_AFTER_GTIDS)
'=' gtuidSet #gtidsUntilOption
| MASTER_LOG_FILE '=' STRING_LITERAL
',' MASTER_LOG_POS '=' decimalLiteral #masterLogUntilOption
| RELAY_LOG_FILE '=' STRING_LITERAL
',' RELAY_LOG_POS '=' decimalLiteral #relayLogUntilOption
| SQL_AFTER_MTS_GAPS #sqlGapsUntilOption
;
connectionOption
: USER '=' conOptUser=STRING_LITERAL #userConnectionOption
| PASSWORD '=' conOptPassword=STRING_LITERAL #passwordConnectionOption
| DEFAULT_AUTH '=' conOptDefAuth=STRING_LITERAL #defaultAuthConnectionOption
| PLUGIN_DIR '=' conOptPluginDir=STRING_LITERAL #pluginDirConnectionOption
;
gtuidSet
: uuidSet (',' uuidSet)*
| STRING_LITERAL
;
// XA Transactions
xaStartTransaction
: XA xaStart=(START | BEGIN) xid xaAction=(JOIN | RESUME)?
;
xaEndTransaction
: XA END xid (SUSPEND (FOR MIGRATE)?)?
;
xaPrepareStatement
: XA PREPARE xid
;
xaCommitWork
: XA COMMIT xid (ONE PHASE)?
;
xaRollbackWork
: XA ROLLBACK xid
;
xaRecoverWork
: XA RECOVER (CONVERT xid)?
;
// Prepared Statements
prepareStatement
: PREPARE uid FROM
(query=STRING_LITERAL | variable=LOCAL_ID)
;
executeStatement
: EXECUTE uid (USING userVariables)?
;
deallocatePrepare
: dropFormat=(DEALLOCATE | DROP) PREPARE uid
;
// Compound Statements
routineBody
: blockStatement | sqlStatement
;
// details
blockStatement
: (uid ':')? BEGIN
(
(declareVariable SEMI)*
(declareCondition SEMI)*
(declareCursor SEMI)*
(declareHandler SEMI)*
procedureSqlStatement*
)?
END uid?
;
caseStatement
: CASE (uid | expression)? caseAlternative+
(ELSE procedureSqlStatement+)?
END CASE
;
ifStatement
: IF expression
THEN thenStatements+=procedureSqlStatement+
elifAlternative*
(ELSE elseStatements+=procedureSqlStatement+ )?
END IF
;
iterateStatement
: ITERATE uid
;
leaveStatement
: LEAVE uid
;
loopStatement
: (uid ':')?
LOOP procedureSqlStatement+
END LOOP uid?
;
repeatStatement
: (uid ':')?
REPEAT procedureSqlStatement+
UNTIL expression
END REPEAT uid?
;
returnStatement
: RETURN expression
;
whileStatement
: (uid ':')?
WHILE expression
DO procedureSqlStatement+
END WHILE uid?
;
cursorStatement
: CLOSE uid #CloseCursor
| FETCH (NEXT? FROM)? uid INTO uidList #FetchCursor
| OPEN uid #OpenCursor
;
// details
declareVariable
: DECLARE uidList dataType (DEFAULT defaultValue)?
;
declareCondition
: DECLARE uid CONDITION FOR
( decimalLiteral | SQLSTATE VALUE? STRING_LITERAL)
;
declareCursor
: DECLARE uid CURSOR FOR selectStatement
;
declareHandler
: DECLARE handlerAction=(CONTINUE | EXIT | UNDO)
HANDLER FOR
handlerConditionValue (',' handlerConditionValue)*
routineBody
;
handlerConditionValue
: decimalLiteral #handlerConditionCode
| SQLSTATE VALUE? STRING_LITERAL #handlerConditionState
| uid #handlerConditionName
| SQLWARNING #handlerConditionWarning
| NOT FOUND #handlerConditionNotfound
| SQLEXCEPTION #handlerConditionException
;
procedureSqlStatement
: (compoundStatement | sqlStatement) SEMI
;
caseAlternative
: WHEN (constant | expression)
THEN procedureSqlStatement+
;
elifAlternative
: ELSEIF expression
THEN procedureSqlStatement+
;
// Administration Statements
// Account management statements
alterUser
: ALTER USER
userSpecification (',' userSpecification)* #alterUserMysqlV56
| ALTER USER ifExists?
userAuthOption (',' userAuthOption)*
(
REQUIRE
(tlsNone=NONE | tlsOption (AND? tlsOption)* )
)?
(WITH userResourceOption+)?
(userPasswordOption | userLockOption)* #alterUserMysqlV57
;
createUser
: CREATE USER userAuthOption (',' userAuthOption)* #createUserMysqlV56
| CREATE USER ifNotExists?
userAuthOption (',' userAuthOption)*
(
REQUIRE
(tlsNone=NONE | tlsOption (AND? tlsOption)* )
)?
(WITH userResourceOption+)?
(userPasswordOption | userLockOption)* #createUserMysqlV57
;
dropUser
: DROP USER ifExists? userName (',' userName)*
;
grantStatement
: GRANT privelegeClause (',' privelegeClause)*
ON
privilegeObject=(TABLE | FUNCTION | PROCEDURE)?
privilegeLevel
TO userAuthOption (',' userAuthOption)*
(
REQUIRE
(tlsNone=NONE | tlsOption (AND? tlsOption)* )
)?
(WITH (GRANT OPTION | userResourceOption)* )?
;
grantProxy
: GRANT PROXY ON fromFirst=userName
TO toFirst=userName (',' toOther+=userName)*
(WITH GRANT OPTION)?
;
renameUser
: RENAME USER
renameUserClause (',' renameUserClause)*
;
revokeStatement
: REVOKE privelegeClause (',' privelegeClause)*
ON
privilegeObject=(TABLE | FUNCTION | PROCEDURE)?
privilegeLevel
FROM userName (',' userName)* #detailRevoke
| REVOKE ALL PRIVILEGES? ',' GRANT OPTION
FROM userName (',' userName)* #shortRevoke
;
revokeProxy
: REVOKE PROXY ON onUser=userName
FROM fromFirst=userName (',' fromOther+=userName)*
;
setPasswordStatement
: SET PASSWORD (FOR userName)?
'=' ( passwordFunctionClause | STRING_LITERAL)
;
// details
userSpecification
: userName userPasswordOption
;
userAuthOption
: userName IDENTIFIED BY PASSWORD hashed=STRING_LITERAL #passwordAuthOption
| userName
IDENTIFIED (WITH authPlugin)? BY STRING_LITERAL #stringAuthOption
| userName
IDENTIFIED WITH authPlugin
(AS STRING_LITERAL)? #hashAuthOption
| userName #simpleAuthOption
;
tlsOption
: SSL
| X509
| CIPHER STRING_LITERAL
| ISSUER STRING_LITERAL
| SUBJECT STRING_LITERAL
;
userResourceOption
: MAX_QUERIES_PER_HOUR decimalLiteral
| MAX_UPDATES_PER_HOUR decimalLiteral
| MAX_CONNECTIONS_PER_HOUR decimalLiteral
| MAX_USER_CONNECTIONS decimalLiteral
;
userPasswordOption
: PASSWORD EXPIRE
(expireType=DEFAULT
| expireType=NEVER
| expireType=INTERVAL decimalLiteral DAY
)?
;
userLockOption
: ACCOUNT lockType=(LOCK | UNLOCK)
;
privelegeClause
: privilege ( '(' uidList ')' )?
;
privilege
: ALL PRIVILEGES?
| ALTER ROUTINE?
| CREATE
(TEMPORARY TABLES | ROUTINE | VIEW | USER | TABLESPACE)?
| DELETE | DROP | EVENT | EXECUTE | FILE | GRANT OPTION
| INDEX | INSERT | LOCK TABLES | PROCESS | PROXY
| REFERENCES | RELOAD
| REPLICATION (CLIENT | SLAVE)
| SELECT
| SHOW (VIEW | DATABASES)
| SHUTDOWN | SUPER | TRIGGER | UPDATE | USAGE
| SESSION_VARIABLES_ADMIN
;
privilegeLevel
: '*' #currentSchemaPriviLevel
| '*' '.' '*' #globalPrivLevel
| uid '.' '*' #definiteSchemaPrivLevel
| uid '.' uid #definiteFullTablePrivLevel
| uid dottedId #definiteFullTablePrivLevel2
| uid #definiteTablePrivLevel
;
renameUserClause
: fromFirst=userName TO toFirst=userName
;
// Table maintenance statements
analyzeTable
: ANALYZE actionOption=(NO_WRITE_TO_BINLOG | LOCAL)?
TABLE tables
;
checkTable
: CHECK TABLE tables checkTableOption*
;
checksumTable
: CHECKSUM TABLE tables actionOption=(QUICK | EXTENDED)?
;
optimizeTable
: OPTIMIZE actionOption=(NO_WRITE_TO_BINLOG | LOCAL)?
TABLE tables
;
repairTable
: REPAIR actionOption=(NO_WRITE_TO_BINLOG | LOCAL)?
TABLE tables
QUICK? EXTENDED? USE_FRM?
;
// details
checkTableOption
: FOR UPGRADE | QUICK | FAST | MEDIUM | EXTENDED | CHANGED
;
// Plugin and udf statements
createUdfunction
: CREATE AGGREGATE? FUNCTION uid
RETURNS returnType=(STRING | INTEGER | REAL | DECIMAL)
SONAME STRING_LITERAL
;
installPlugin
: INSTALL PLUGIN uid SONAME STRING_LITERAL
;
uninstallPlugin
: UNINSTALL PLUGIN uid
;
// Set and show statements
setStatement
: SET variableClause ('=' | ':=') expression
(',' variableClause ('=' | ':=') expression)* #setVariable
| SET (CHARACTER SET | CHARSET) (charsetName | DEFAULT) #setCharset
| SET NAMES
(charsetName (COLLATE collationName)? | DEFAULT) #setNames
| setPasswordStatement #setPassword
| setTransactionStatement #setTransaction
| setAutocommitStatement #setAutocommit
| SET fullId ('=' | ':=') expression #setNewValueInsideTrigger
;
showStatement
: SHOW logFormat=(BINARY | MASTER) LOGS #showMasterLogs
| SHOW logFormat=(BINLOG | RELAYLOG)
EVENTS (IN filename=STRING_LITERAL)?
(FROM fromPosition=decimalLiteral)?
(LIMIT
(offset=decimalLiteral ',')?
rowCount=decimalLiteral
)? #showLogEvents
| SHOW showCommonEntity showFilter? #showObjectFilter
| SHOW FULL? columnsFormat=(COLUMNS | FIELDS)
tableFormat=(FROM | IN) tableName
(schemaFormat=(FROM | IN) uid)? showFilter? #showColumns
| SHOW CREATE schemaFormat=(DATABASE | SCHEMA)
ifNotExists? uid #showCreateDb
| SHOW CREATE
namedEntity=(
EVENT | FUNCTION | PROCEDURE
| TABLE | TRIGGER | VIEW
)
fullId #showCreateFullIdObject
| SHOW CREATE USER userName #showCreateUser
| SHOW ENGINE engineName engineOption=(STATUS | MUTEX) #showEngine
| SHOW showGlobalInfoClause #showGlobalInfo
| SHOW errorFormat=(ERRORS | WARNINGS)
(LIMIT
(offset=decimalLiteral ',')?
rowCount=decimalLiteral
) #showErrors
| SHOW COUNT '(' '*' ')' errorFormat=(ERRORS | WARNINGS) #showCountErrors
| SHOW showSchemaEntity
(schemaFormat=(FROM | IN) uid)? showFilter? #showSchemaFilter
| SHOW routine=(FUNCTION | PROCEDURE) CODE fullId #showRoutine
| SHOW GRANTS (FOR userName)? #showGrants
| SHOW indexFormat=(INDEX | INDEXES | KEYS)
tableFormat=(FROM | IN) tableName
(schemaFormat=(FROM | IN) uid)? (WHERE expression)? #showIndexes
| SHOW OPEN TABLES ( schemaFormat=(FROM | IN) uid)?
showFilter? #showOpenTables
| SHOW PROFILE showProfileType (',' showProfileType)*
(FOR QUERY queryCount=decimalLiteral)?
(LIMIT
(offset=decimalLiteral ',')?
rowCount=decimalLiteral
) #showProfile
| SHOW SLAVE STATUS (FOR CHANNEL STRING_LITERAL)? #showSlaveStatus
;
// details
variableClause
: LOCAL_ID | GLOBAL_ID | ( ('@' '@')? (GLOBAL | SESSION | LOCAL) )? uid
;
showCommonEntity
: CHARACTER SET | COLLATION | DATABASES | SCHEMAS
| FUNCTION STATUS | PROCEDURE STATUS
| (GLOBAL | SESSION)? (STATUS | VARIABLES)
;
showFilter
: LIKE STRING_LITERAL
| WHERE expression
;
showGlobalInfoClause
: STORAGE? ENGINES | MASTER STATUS | PLUGINS
| PRIVILEGES | FULL? PROCESSLIST | PROFILES
| SLAVE HOSTS | AUTHORS | CONTRIBUTORS
;
showSchemaEntity
: EVENTS | TABLE STATUS | FULL? TABLES | TRIGGERS
;
showProfileType
: ALL | BLOCK IO | CONTEXT SWITCHES | CPU | IPC | MEMORY
| PAGE FAULTS | SOURCE | SWAPS
;
// Other administrative statements
binlogStatement
: BINLOG STRING_LITERAL
;
cacheIndexStatement
: CACHE INDEX tableIndexes (',' tableIndexes)*
( PARTITION '(' (uidList | ALL) ')' )?
IN schema=uid
;
flushStatement
: FLUSH flushFormat=(NO_WRITE_TO_BINLOG | LOCAL)?
flushOption (',' flushOption)*
;
killStatement
: KILL connectionFormat=(CONNECTION | QUERY)?
decimalLiteral+
;
loadIndexIntoCache
: LOAD INDEX INTO CACHE
loadedTableIndexes (',' loadedTableIndexes)*
;
// remark reset (maser | slave) describe in replication's
// statements section
resetStatement
: RESET QUERY CACHE
;
shutdownStatement
: SHUTDOWN
;
// details
tableIndexes
: tableName ( indexFormat=(INDEX | KEY)? '(' uidList ')' )?
;
flushOption
: (
DES_KEY_FILE | HOSTS
| (
BINARY | ENGINE | ERROR | GENERAL | RELAY | SLOW
)? LOGS
| OPTIMIZER_COSTS | PRIVILEGES | QUERY CACHE | STATUS
| USER_RESOURCES | TABLES (WITH READ LOCK)?
) #simpleFlushOption
| RELAY LOGS channelOption? #channelFlushOption
| TABLES tables flushTableOption? #tableFlushOption
;
flushTableOption
: WITH READ LOCK
| FOR EXPORT
;
loadedTableIndexes
: tableName
( PARTITION '(' (partitionList=uidList | ALL) ')' )?
( indexFormat=(INDEX | KEY)? '(' indexList=uidList ')' )?
(IGNORE LEAVES)?
;
// Utility Statements
simpleDescribeStatement
: command=(EXPLAIN | DESCRIBE | DESC) tableName
(column=uid | pattern=STRING_LITERAL)?
;
fullDescribeStatement
: command=(EXPLAIN | DESCRIBE | DESC)
(
formatType=(EXTENDED | PARTITIONS | FORMAT )
'='
formatValue=(TRADITIONAL | JSON)
)?
describeObjectClause
;
helpStatement
: HELP STRING_LITERAL
;
useStatement
: USE uid
;
signalStatement
: SIGNAL ( ( SQLSTATE VALUE? stringLiteral ) | ID | REVERSE_QUOTE_ID )
( SET signalConditionInformation ( ',' signalConditionInformation)* )?
;
resignalStatement
: RESIGNAL ( ( SQLSTATE VALUE? stringLiteral ) | ID | REVERSE_QUOTE_ID )?
( SET signalConditionInformation ( ',' signalConditionInformation)* )?
;
signalConditionInformation
: ( CLASS_ORIGIN
| SUBCLASS_ORIGIN
| MESSAGE_TEXT
| MYSQL_ERRNO
| CONSTRAINT_CATALOG
| CONSTRAINT_SCHEMA
| CONSTRAINT_NAME
| CATALOG_NAME
| SCHEMA_NAME
| TABLE_NAME
| COLUMN_NAME
| CURSOR_NAME
) '=' ( stringLiteral | DECIMAL_LITERAL )
;
diagnosticsStatement
: GET ( CURRENT | STACKED )? DIAGNOSTICS (
( variableClause '=' ( NUMBER | ROW_COUNT ) ( ',' variableClause '=' ( NUMBER | ROW_COUNT ) )* )
| ( CONDITION ( decimalLiteral | variableClause ) variableClause '=' diagnosticsConditionInformationName ( ',' variableClause '=' diagnosticsConditionInformationName )* )
)
;
diagnosticsConditionInformationName
: CLASS_ORIGIN
| SUBCLASS_ORIGIN
| RETURNED_SQLSTATE
| MESSAGE_TEXT
| MYSQL_ERRNO
| CONSTRAINT_CATALOG
| CONSTRAINT_SCHEMA
| CONSTRAINT_NAME
| CATALOG_NAME
| SCHEMA_NAME
| TABLE_NAME
| COLUMN_NAME
| CURSOR_NAME
;
// details
describeObjectClause
: (
selectStatement | deleteStatement | insertStatement
| replaceStatement | updateStatement
) #describeStatements
| FOR CONNECTION uid #describeConnection
;
// Common Clauses
// DB Objects
fullId
: uid (DOT_ID | '.' uid)?
;
tableName
: fullId
;
fullColumnName
: uid (dottedId dottedId? )?
;
indexColumnName
: (uid | STRING_LITERAL) ('(' decimalLiteral ')')? sortType=(ASC | DESC)?
;
userName
: STRING_USER_NAME | ID | STRING_LITERAL;
mysqlVariable
: LOCAL_ID
| GLOBAL_ID
;
charsetName
: BINARY
| charsetNameBase
| STRING_LITERAL
| CHARSET_REVERSE_QOUTE_STRING
;
collationName
: uid | STRING_LITERAL;
engineName
: ARCHIVE | BLACKHOLE | CSV | FEDERATED | INNODB | MEMORY
| MRG_MYISAM | MYISAM | NDB | NDBCLUSTER | PERFORMANCE_SCHEMA
| TOKUDB
| ID
| STRING_LITERAL | REVERSE_QUOTE_ID
;
uuidSet
: decimalLiteral '-' decimalLiteral '-' decimalLiteral
'-' decimalLiteral '-' decimalLiteral
(':' decimalLiteral '-' decimalLiteral)+
;
xid
: globalTableUid=xuidStringId
(
',' qualifier=xuidStringId
(',' idFormat=decimalLiteral)?
)?
;
xuidStringId
: STRING_LITERAL
| BIT_STRING
| HEXADECIMAL_LITERAL+
;
authPlugin
: uid | STRING_LITERAL
;
uid
: simpleId
//| DOUBLE_QUOTE_ID
| REVERSE_QUOTE_ID
| CHARSET_REVERSE_QOUTE_STRING
;
simpleId
: ID
| charsetNameBase
| transactionLevelBase
| engineName
| privilegesBase
| intervalTypeBase
| dataTypeBase
| keywordsCanBeId
| functionNameBase
;
dottedId
: DOT_ID
| '.' uid
;
// Literals
decimalLiteral
: DECIMAL_LITERAL | ZERO_DECIMAL | ONE_DECIMAL | TWO_DECIMAL
;
fileSizeLiteral
: FILESIZE_LITERAL | decimalLiteral;
stringLiteral
: (
STRING_CHARSET_NAME? STRING_LITERAL
| START_NATIONAL_STRING_LITERAL
) STRING_LITERAL+
| (
STRING_CHARSET_NAME? STRING_LITERAL
| START_NATIONAL_STRING_LITERAL
) (COLLATE collationName)?
;
booleanLiteral
: TRUE | FALSE;
hexadecimalLiteral
: STRING_CHARSET_NAME? HEXADECIMAL_LITERAL;
nullNotnull
: NOT? (NULL_LITERAL | NULL_SPEC_LITERAL)
;
constant
: stringLiteral | decimalLiteral
| '-' decimalLiteral
| hexadecimalLiteral | booleanLiteral
| REAL_LITERAL | BIT_STRING
| NOT? nullLiteral=(NULL_LITERAL | NULL_SPEC_LITERAL)
;
// Data Types
dataType
: typeName=(
CHAR | VARCHAR | TINYTEXT | TEXT | MEDIUMTEXT | LONGTEXT
| NCHAR | NVARCHAR
)
lengthOneDimension? BINARY?
((CHARACTER SET | CHARSET) charsetName)?
(COLLATE collationName)? #stringDataType
| NATIONAL typeName=(VARCHAR | CHARACTER)
lengthOneDimension? BINARY? #nationalStringDataType
| NCHAR typeName=VARCHAR
lengthOneDimension? BINARY? #nationalStringDataType
| NATIONAL typeName=(CHAR | CHARACTER) VARYING
lengthOneDimension? BINARY? #nationalVaryingStringDataType
| typeName=(
TINYINT | SMALLINT | MEDIUMINT | INT | INTEGER | BIGINT
)
lengthOneDimension? (SIGNED | UNSIGNED)? ZEROFILL? #dimensionDataType
| typeName=REAL
lengthTwoDimension? (SIGNED | UNSIGNED)? ZEROFILL? #dimensionDataType
| typeName=DOUBLE PRECISION?
lengthTwoDimension? (SIGNED | UNSIGNED)? ZEROFILL? #dimensionDataType
| typeName=(DECIMAL | DEC | FIXED | NUMERIC | FLOAT)
lengthTwoOptionalDimension? (SIGNED | UNSIGNED)? ZEROFILL? #dimensionDataType
| typeName=(
DATE | TINYBLOB | BLOB | MEDIUMBLOB | LONGBLOB
| BOOL | BOOLEAN | SERIAL
) #simpleDataType
| typeName=(
BIT | TIME | TIMESTAMP | DATETIME | BINARY
| VARBINARY | YEAR
)
lengthOneDimension? #dimensionDataType
| typeName=(ENUM | SET)
collectionOptions BINARY?
((CHARACTER SET | CHARSET) charsetName)? #collectionDataType
| typeName=(
GEOMETRYCOLLECTION | GEOMCOLLECTION | LINESTRING | MULTILINESTRING
| MULTIPOINT | MULTIPOLYGON | POINT | POLYGON | JSON | GEOMETRY
) #spatialDataType
;
collectionOptions
: '(' STRING_LITERAL (',' STRING_LITERAL)* ')'
;
convertedDataType
: typeName=(BINARY| NCHAR) lengthOneDimension?
| typeName=CHAR lengthOneDimension? ((CHARACTER SET | CHARSET) charsetName)?
| typeName=(DATE | DATETIME | TIME | JSON)
| typeName=DECIMAL lengthTwoDimension?
| (SIGNED | UNSIGNED) INTEGER?
;
lengthOneDimension
: '(' decimalLiteral ')'
;
lengthTwoDimension
: '(' decimalLiteral ',' decimalLiteral ')'
;
lengthTwoOptionalDimension
: '(' decimalLiteral (',' decimalLiteral)? ')'
;
// Common Lists
uidList
: uid (',' uid)*
;
tables
: tableName (',' tableName)*
;
indexColumnNames
: '(' indexColumnName (',' indexColumnName)* ')'
;
expressions
: expression (',' expression)*
;
expressionsWithDefaults
: expressionOrDefault (',' expressionOrDefault)*
;
constants
: constant (',' constant)*
;
simpleStrings
: STRING_LITERAL (',' STRING_LITERAL)*
;
userVariables
: LOCAL_ID (',' LOCAL_ID)*
;
// Common Expressons
defaultValue
: NULL_LITERAL
| unaryOperator? constant
| currentTimestamp (ON UPDATE currentTimestamp)?
;
currentTimestamp
:
(
(CURRENT_TIMESTAMP | LOCALTIME | LOCALTIMESTAMP) ('(' decimalLiteral? ')')?
| NOW '(' decimalLiteral? ')'
)
;
expressionOrDefault
: expression | DEFAULT
;
ifExists
: IF EXISTS;
ifNotExists
: IF NOT EXISTS;
// Functions
functionCall
: specificFunction #specificFunctionCall
| aggregateWindowedFunction #aggregateFunctionCall
| scalarFunctionName '(' functionArgs? ')' #scalarFunctionCall
| fullId '(' functionArgs? ')' #udfFunctionCall
| passwordFunctionClause #passwordFunctionCall
;
specificFunction
: (
CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP
| CURRENT_USER | LOCALTIME
) #simpleFunctionCall
| CONVERT '(' expression separator=',' convertedDataType ')' #dataTypeFunctionCall
| CONVERT '(' expression USING charsetName ')' #dataTypeFunctionCall
| CAST '(' expression AS convertedDataType ')' #dataTypeFunctionCall
| VALUES '(' fullColumnName ')' #valuesFunctionCall
| CASE expression caseFuncAlternative+
(ELSE elseArg=functionArg)? END #caseFunctionCall
| CASE caseFuncAlternative+
(ELSE elseArg=functionArg)? END #caseFunctionCall
| CHAR '(' functionArgs (USING charsetName)? ')' #charFunctionCall
| POSITION
'('
(
positionString=stringLiteral
| positionExpression=expression
)
IN
(
inString=stringLiteral
| inExpression=expression
)
')' #positionFunctionCall
| (SUBSTR | SUBSTRING)
'('
(
sourceString=stringLiteral
| sourceExpression=expression
) FROM
(
fromDecimal=decimalLiteral
| fromExpression=expression
)
(
FOR
(
forDecimal=decimalLiteral
| forExpression=expression
)
)?
')' #substrFunctionCall
| TRIM
'('
positioinForm=(BOTH | LEADING | TRAILING)
(
sourceString=stringLiteral
| sourceExpression=expression
)?
FROM
(
fromString=stringLiteral
| fromExpression=expression
)
')' #trimFunctionCall
| TRIM
'('
(
sourceString=stringLiteral
| sourceExpression=expression
)
FROM
(
fromString=stringLiteral
| fromExpression=expression
)
')' #trimFunctionCall
| WEIGHT_STRING
'('
(stringLiteral | expression)
(AS stringFormat=(CHAR | BINARY)
'(' decimalLiteral ')' )? levelsInWeightString?
')' #weightFunctionCall
| EXTRACT
'('
intervalType
FROM
(
sourceString=stringLiteral
| sourceExpression=expression
)
')' #extractFunctionCall
| GET_FORMAT
'('
datetimeFormat=(DATE | TIME | DATETIME)
',' stringLiteral
')' #getFormatFunctionCall
;
caseFuncAlternative
: WHEN condition=functionArg
THEN consequent=functionArg
;
levelsInWeightString
: LEVEL levelInWeightListElement
(',' levelInWeightListElement)* #levelWeightList
| LEVEL
firstLevel=decimalLiteral '-' lastLevel=decimalLiteral #levelWeightRange
;
levelInWeightListElement
: decimalLiteral orderType=(ASC | DESC | REVERSE)?
;
aggregateWindowedFunction
: (AVG | MAX | MIN | SUM)
'(' aggregator=(ALL | DISTINCT)? functionArg ')'
| COUNT '(' (starArg='*' | aggregator=ALL? functionArg) ')'
| COUNT '(' aggregator=DISTINCT functionArgs ')'
| (
BIT_AND | BIT_OR | BIT_XOR | STD | STDDEV | STDDEV_POP
| STDDEV_SAMP | VAR_POP | VAR_SAMP | VARIANCE
) '(' aggregator=ALL? functionArg ')'
| GROUP_CONCAT '('
aggregator=DISTINCT? functionArgs
(ORDER BY
orderByExpression (',' orderByExpression)*
)? (SEPARATOR separator=STRING_LITERAL)?
')'
;
scalarFunctionName
: functionNameBase
| ASCII | CURDATE | CURRENT_DATE | CURRENT_TIME
| CURRENT_TIMESTAMP | CURTIME | DATE_ADD | DATE_SUB
| IF | INSERT | LOCALTIME | LOCALTIMESTAMP | MID | NOW
| REPLACE | SUBSTR | SUBSTRING | SYSDATE | TRIM
| UTC_DATE | UTC_TIME | UTC_TIMESTAMP
;
passwordFunctionClause
: functionName=(PASSWORD | OLD_PASSWORD) '(' functionArg ')'
;
functionArgs
: (constant | fullColumnName | functionCall | expression)
(
','
(constant | fullColumnName | functionCall | expression)
)*
;
functionArg
: constant | fullColumnName | functionCall | expression
;
// Expressions, predicates
// Simplified approach for expression
expression
: notOperator=(NOT | '!') expression #notExpression
| expression logicalOperator expression #logicalExpression
| predicate IS NOT? testValue=(TRUE | FALSE | UNKNOWN) #isExpression
| predicate #predicateExpression
;
predicate
: predicate NOT? IN '(' (selectStatement | expressions) ')' #inPredicate
| predicate IS nullNotnull #isNullPredicate
| left=predicate comparisonOperator right=predicate #binaryComparasionPredicate
| predicate comparisonOperator
quantifier=(ALL | ANY | SOME) '(' selectStatement ')' #subqueryComparasionPredicate
| predicate NOT? BETWEEN predicate AND predicate #betweenPredicate
| predicate SOUNDS LIKE predicate #soundsLikePredicate
| predicate NOT? LIKE predicate (ESCAPE STRING_LITERAL)? #likePredicate
| predicate NOT? regex=(REGEXP | RLIKE) predicate #regexpPredicate
| (LOCAL_ID VAR_ASSIGN)? expressionAtom #expressionAtomPredicate
;
// Add in ASTVisitor nullNotnull in constant
expressionAtom
: constant #constantExpressionAtom
| fullColumnName #fullColumnNameExpressionAtom
| functionCall #functionCallExpressionAtom
| expressionAtom COLLATE collationName #collateExpressionAtom
| mysqlVariable #mysqlVariableExpressionAtom
| unaryOperator expressionAtom #unaryExpressionAtom
| BINARY expressionAtom #binaryExpressionAtom
| '(' expression (',' expression)* ')' #nestedExpressionAtom
| ROW '(' expression (',' expression)+ ')' #nestedRowExpressionAtom
| EXISTS '(' selectStatement ')' #existsExpessionAtom
| '(' selectStatement ')' #subqueryExpessionAtom
| INTERVAL expression intervalType #intervalExpressionAtom
| left=expressionAtom bitOperator right=expressionAtom #bitExpressionAtom
| left=expressionAtom mathOperator right=expressionAtom #mathExpressionAtom
;
unaryOperator
: '!' | '~' | '+' | '-' | NOT
;
comparisonOperator
: '=' | '>' | '<' | '<' '=' | '>' '='
| '<' '>' | '!' '=' | '<' '=' '>'
;
logicalOperator
: AND | '&' '&' | XOR | OR | '|' '|'
;
bitOperator
: '<' '<' | '>' '>' | '&' | '^' | '|'
;
mathOperator
: '*' | '/' | '%' | DIV | MOD | '+' | '-' | '--'
;
// Simple id sets
// (that keyword, which can be id)
charsetNameBase
: ARMSCII8 | ASCII | BIG5 | CP1250 | CP1251 | CP1256 | CP1257
| CP850 | CP852 | CP866 | CP932 | DEC8 | EUCJPMS | EUCKR
| GB2312 | GBK | GEOSTD8 | GREEK | HEBREW | HP8 | KEYBCS2
| KOI8R | KOI8U | LATIN1 | LATIN2 | LATIN5 | LATIN7 | MACCE
| MACROMAN | SJIS | SWE7 | TIS620 | UCS2 | UJIS | UTF16
| UTF16LE | UTF32 | UTF8 | UTF8MB3 | UTF8MB4
;
transactionLevelBase
: REPEATABLE | COMMITTED | UNCOMMITTED | SERIALIZABLE
;
privilegesBase
: TABLES | ROUTINE | EXECUTE | FILE | PROCESS
| RELOAD | SHUTDOWN | SUPER | PRIVILEGES
;
intervalTypeBase
: QUARTER | MONTH | DAY | HOUR
| MINUTE | WEEK | SECOND | MICROSECOND
;
dataTypeBase
: DATE | TIME | TIMESTAMP | DATETIME | YEAR | ENUM | TEXT
;
keywordsCanBeId
: ACCOUNT | ACTION | AFTER | AGGREGATE | ALGORITHM | ANY
| AT | AUTHORS | AUTOCOMMIT | AUTOEXTEND_SIZE
| AUTO_INCREMENT | AVG_ROW_LENGTH | BEGIN | BINLOG | BIT
| BLOCK | BOOL | BOOLEAN | BTREE | CACHE | CASCADED | CHAIN | CHANGED
| CHANNEL | CHECKSUM | PAGE_CHECKSUM | CATALOG_NAME | CIPHER
| CLASS_ORIGIN | CLIENT | CLOSE | COALESCE | CODE
| COLUMNS | COLUMN_FORMAT | COLUMN_NAME | COMMENT | COMMIT | COMPACT
| COMPLETION | COMPRESSED | COMPRESSION | CONCURRENT
| CONNECTION | CONSISTENT | CONSTRAINT_CATALOG | CONSTRAINT_NAME
| CONSTRAINT_SCHEMA | CONTAINS | CONTEXT
| CONTRIBUTORS | COPY | CPU | CURRENT | CURSOR_NAME
| DATA | DATAFILE | DEALLOCATE
| DEFAULT_AUTH | DEFINER | DELAY_KEY_WRITE | DES_KEY_FILE | DIAGNOSTICS | DIRECTORY
| DISABLE | DISCARD | DISK | DO | DUMPFILE | DUPLICATE
| DYNAMIC | ENABLE | ENCRYPTION | END | ENDS | ENGINE | ENGINES
| ERROR | ERRORS | ESCAPE | EVEN | EVENT | EVENTS | EVERY
| EXCHANGE | EXCLUSIVE | EXPIRE | EXPORT | EXTENDED | EXTENT_SIZE | FAST | FAULTS
| FIELDS | FILE_BLOCK_SIZE | FILTER | FIRST | FIXED | FLUSH
| FOLLOWS | FOUND | FULL | FUNCTION | GENERAL | GLOBAL | GRANTS
| GROUP_REPLICATION | HANDLER | HASH | HELP | HOST | HOSTS | IDENTIFIED
| IGNORE_SERVER_IDS | IMPORT | INDEXES | INITIAL_SIZE
| INPLACE | INSERT_METHOD | INSTALL | INSTANCE | INTERNAL | INVOKER | IO
| IO_THREAD | IPC | ISOLATION | ISSUER | JSON | KEY_BLOCK_SIZE
| LANGUAGE | LAST | LEAVES | LESS | LEVEL | LIST | LOCAL
| LOGFILE | LOGS | MASTER | MASTER_AUTO_POSITION
| MASTER_CONNECT_RETRY | MASTER_DELAY
| MASTER_HEARTBEAT_PERIOD | MASTER_HOST | MASTER_LOG_FILE
| MASTER_LOG_POS | MASTER_PASSWORD | MASTER_PORT
| MASTER_RETRY_COUNT | MASTER_SSL | MASTER_SSL_CA
| MASTER_SSL_CAPATH | MASTER_SSL_CERT | MASTER_SSL_CIPHER
| MASTER_SSL_CRL | MASTER_SSL_CRLPATH | MASTER_SSL_KEY
| MASTER_TLS_VERSION | MASTER_USER
| MAX_CONNECTIONS_PER_HOUR | MAX_QUERIES_PER_HOUR
| MAX_ROWS | MAX_SIZE | MAX_UPDATES_PER_HOUR
| MAX_USER_CONNECTIONS | MEDIUM | MEMORY | MERGE | MESSAGE_TEXT
| MID | MIGRATE
| MIN_ROWS | MODE | MODIFY | MUTEX | MYSQL | MYSQL_ERRNO | NAME | NAMES
| NCHAR | NEVER | NEXT | NO | NODEGROUP | NONE | NUMBER | OFFLINE | OFFSET
| OJ | OLD_PASSWORD | ONE | ONLINE | ONLY | OPEN | OPTIMIZER_COSTS
| OPTIONS | OWNER | PACK_KEYS | PAGE | PARSER | PARTIAL
| PARTITIONING | PARTITIONS | PASSWORD | PHASE | PLUGINS
| PLUGIN_DIR | PLUGIN | PORT | PRECEDES | PREPARE | PRESERVE | PREV
| PROCESSLIST | PROFILE | PROFILES | PROXY | QUERY | QUICK
| REBUILD | RECOVER | REDO_BUFFER_SIZE | REDUNDANT
| RELAY | RELAYLOG | RELAY_LOG_FILE | RELAY_LOG_POS | REMOVE
| REORGANIZE | REPAIR | REPLICATE_DO_DB | REPLICATE_DO_TABLE
| REPLICATE_IGNORE_DB | REPLICATE_IGNORE_TABLE
| REPLICATE_REWRITE_DB | REPLICATE_WILD_DO_TABLE
| REPLICATE_WILD_IGNORE_TABLE | REPLICATION | RESET | RESUME
| RETURNED_SQLSTATE | RETURNS | ROLLBACK | ROLLUP | ROTATE | ROW | ROWS
| ROW_FORMAT | SAVEPOINT | SCHEDULE | SCHEMA_NAME | SECURITY | SERIAL | SERVER
| SESSION | SHARE | SHARED | SIGNED | SIMPLE | SLAVE
| SLOW | SNAPSHOT | SOCKET | SOME | SONAME | SOUNDS | SOURCE
| SQL_AFTER_GTIDS | SQL_AFTER_MTS_GAPS | SQL_BEFORE_GTIDS
| SQL_BUFFER_RESULT | SQL_CACHE | SQL_NO_CACHE | SQL_THREAD
| STACKED | START | STARTS | STATS_AUTO_RECALC | STATS_PERSISTENT
| STATS_SAMPLE_PAGES | STATUS | STOP | STORAGE | STRING
| SUBCLASS_ORIGIN | SUBJECT | SUBPARTITION | SUBPARTITIONS | SUSPEND | SWAPS
| SWITCHES | TABLE_NAME | TABLESPACE | TEMPORARY | TEMPTABLE | THAN | TRADITIONAL
| TRANSACTION | TRIGGERS | TRUNCATE | UNDEFINED | UNDOFILE
| UNDO_BUFFER_SIZE | UNINSTALL | UNKNOWN | UNTIL | UPGRADE | USER | USE_FRM | USER_RESOURCES
| VALIDATION | VALUE | VARIABLES | VIEW | WAIT | WARNINGS | WITHOUT
| WORK | WRAPPER | X509 | XA | XML
;
functionNameBase
: ABS | ACOS | ADDDATE | ADDTIME | AES_DECRYPT | AES_ENCRYPT
| AREA | ASBINARY | ASIN | ASTEXT | ASWKB | ASWKT
| ASYMMETRIC_DECRYPT | ASYMMETRIC_DERIVE
| ASYMMETRIC_ENCRYPT | ASYMMETRIC_SIGN | ASYMMETRIC_VERIFY
| ATAN | ATAN2 | BENCHMARK | BIN | BIT_COUNT | BIT_LENGTH
| BUFFER | CEIL | CEILING | CENTROID | CHARACTER_LENGTH
| CHARSET | CHAR_LENGTH | COERCIBILITY | COLLATION
| COMPRESS | CONCAT | CONCAT_WS | CONNECTION_ID | CONV
| CONVERT_TZ | COS | COT | COUNT | CRC32
| CREATE_ASYMMETRIC_PRIV_KEY | CREATE_ASYMMETRIC_PUB_KEY
| CREATE_DH_PARAMETERS | CREATE_DIGEST | CROSSES | DATABASE | DATE
| DATEDIFF | DATE_FORMAT | DAY | DAYNAME | DAYOFMONTH
| DAYOFWEEK | DAYOFYEAR | DECODE | DEGREES | DES_DECRYPT
| DES_ENCRYPT | DIMENSION | DISJOINT | ELT | ENCODE
| ENCRYPT | ENDPOINT | ENVELOPE | EQUALS | EXP | EXPORT_SET
| EXTERIORRING | EXTRACTVALUE | FIELD | FIND_IN_SET | FLOOR
| FORMAT | FOUND_ROWS | FROM_BASE64 | FROM_DAYS
| FROM_UNIXTIME | GEOMCOLLFROMTEXT | GEOMCOLLFROMWKB
| GEOMETRYCOLLECTION | GEOMETRYCOLLECTIONFROMTEXT
| GEOMETRYCOLLECTIONFROMWKB | GEOMETRYFROMTEXT
| GEOMETRYFROMWKB | GEOMETRYN | GEOMETRYTYPE | GEOMFROMTEXT
| GEOMFROMWKB | GET_FORMAT | GET_LOCK | GLENGTH | GREATEST
| GTID_SUBSET | GTID_SUBTRACT | HEX | HOUR | IFNULL
| INET6_ATON | INET6_NTOA | INET_ATON | INET_NTOA | INSTR
| INTERIORRINGN | INTERSECTS | INVISIBLE
| ISCLOSED | ISEMPTY | ISNULL
| ISSIMPLE | IS_FREE_LOCK | IS_IPV4 | IS_IPV4_COMPAT
| IS_IPV4_MAPPED | IS_IPV6 | IS_USED_LOCK | LAST_INSERT_ID
| LCASE | LEAST | LEFT | LENGTH | LINEFROMTEXT | LINEFROMWKB
| LINESTRING | LINESTRINGFROMTEXT | LINESTRINGFROMWKB | LN
| LOAD_FILE | LOCATE | LOG | LOG10 | LOG2 | LOWER | LPAD
| LTRIM | MAKEDATE | MAKETIME | MAKE_SET | MASTER_POS_WAIT
| MBRCONTAINS | MBRDISJOINT | MBREQUAL | MBRINTERSECTS
| MBROVERLAPS | MBRTOUCHES | MBRWITHIN | MD5 | MICROSECOND
| MINUTE | MLINEFROMTEXT | MLINEFROMWKB | MONTH | MONTHNAME
| MPOINTFROMTEXT | MPOINTFROMWKB | MPOLYFROMTEXT
| MPOLYFROMWKB | MULTILINESTRING | MULTILINESTRINGFROMTEXT
| MULTILINESTRINGFROMWKB | MULTIPOINT | MULTIPOINTFROMTEXT
| MULTIPOINTFROMWKB | MULTIPOLYGON | MULTIPOLYGONFROMTEXT
| MULTIPOLYGONFROMWKB | NAME_CONST | NULLIF | NUMGEOMETRIES
| NUMINTERIORRINGS | NUMPOINTS | OCT | OCTET_LENGTH | ORD
| OVERLAPS | PERIOD_ADD | PERIOD_DIFF | PI | POINT
| POINTFROMTEXT | POINTFROMWKB | POINTN | POLYFROMTEXT
| POLYFROMWKB | POLYGON | POLYGONFROMTEXT | POLYGONFROMWKB
| POSITION| POW | POWER | QUARTER | QUOTE | RADIANS | RAND
| RANDOM_BYTES | RELEASE_LOCK | REVERSE | RIGHT | ROUND
| ROW_COUNT | RPAD | RTRIM | SECOND | SEC_TO_TIME
| SESSION_USER | SESSION_VARIABLES_ADMIN
| SHA | SHA1 | SHA2 | SIGN | SIN | SLEEP
| SOUNDEX | SQL_THREAD_WAIT_AFTER_GTIDS | SQRT | SRID
| STARTPOINT | STRCMP | STR_TO_DATE | ST_AREA | ST_ASBINARY
| ST_ASTEXT | ST_ASWKB | ST_ASWKT | ST_BUFFER | ST_CENTROID
| ST_CONTAINS | ST_CROSSES | ST_DIFFERENCE | ST_DIMENSION
| ST_DISJOINT | ST_DISTANCE | ST_ENDPOINT | ST_ENVELOPE
| ST_EQUALS | ST_EXTERIORRING | ST_GEOMCOLLFROMTEXT
| ST_GEOMCOLLFROMTXT | ST_GEOMCOLLFROMWKB
| ST_GEOMETRYCOLLECTIONFROMTEXT
| ST_GEOMETRYCOLLECTIONFROMWKB | ST_GEOMETRYFROMTEXT
| ST_GEOMETRYFROMWKB | ST_GEOMETRYN | ST_GEOMETRYTYPE
| ST_GEOMFROMTEXT | ST_GEOMFROMWKB | ST_INTERIORRINGN
| ST_INTERSECTION | ST_INTERSECTS | ST_ISCLOSED | ST_ISEMPTY
| ST_ISSIMPLE | ST_LINEFROMTEXT | ST_LINEFROMWKB
| ST_LINESTRINGFROMTEXT | ST_LINESTRINGFROMWKB
| ST_NUMGEOMETRIES | ST_NUMINTERIORRING
| ST_NUMINTERIORRINGS | ST_NUMPOINTS | ST_OVERLAPS
| ST_POINTFROMTEXT | ST_POINTFROMWKB | ST_POINTN
| ST_POLYFROMTEXT | ST_POLYFROMWKB | ST_POLYGONFROMTEXT
| ST_POLYGONFROMWKB | ST_SRID | ST_STARTPOINT
| ST_SYMDIFFERENCE | ST_TOUCHES | ST_UNION | ST_WITHIN
| ST_X | ST_Y | SUBDATE | SUBSTRING_INDEX | SUBTIME
| SYSTEM_USER | TAN | TIME | TIMEDIFF | TIMESTAMP
| TIMESTAMPADD | TIMESTAMPDIFF | TIME_FORMAT | TIME_TO_SEC
| TOUCHES | TO_BASE64 | TO_DAYS | TO_SECONDS | UCASE
| UNCOMPRESS | UNCOMPRESSED_LENGTH | UNHEX | UNIX_TIMESTAMP
| UPDATEXML | UPPER | UUID | UUID_SHORT
| VALIDATE_PASSWORD_STRENGTH | VERSION | VISIBLE
| WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS | WEEK | WEEKDAY
| WEEKOFYEAR | WEIGHT_STRING | WITHIN | YEAR | YEARWEEK
| Y_FUNCTION | X_FUNCTION
; | 78,747 | ANTLR | .g4 | 2,157 | 31.133055 | 179 | 0.601898 | qiub649691422/demo-sharding | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | 2474336dc577f0be8e3ea457744a7ba4c186bb0e25e0aa7646c6e61fcce611be | true | true | false | false |
119 | SelectExample.g4 | qiub649691422_demo-sharding/src/main/java/com/demo/sharding/advance/SelectExample.g4 | grammar SelectExample;
AS : A S;
SELECT : S E L E C T;
FROM : F R O M;
TABLE : T A B L E;
MAX : M A X;
SUM : S U M;
AVG : A V G;
MIN : M I N;
COUNT : C O U N T;
ALL : A L L;
DISTINCT : D I S T I N C T;
WHERE : W H E R E;
GROUP : G R O U P;
BY : B Y ;
ORDER : O R D E R;
HAVING : H A V I N G;
NOT : N O T;
IS : I S ;
TRUE : T R U E;
FALSE : F A L S E;
UNKNOWN : U N K N O W N;
BETWEEN : B E T W E E N;
AND : A N D;
IN : I N;
NULL : N U L L;
OR : O R ;
ASC : A S C;
DESC : D E S C;
LIMIT : L I M I T ;
OFFSET : O F F S E T;
fragment A : [aA];
fragment B : [bB];
fragment C : [cC];
fragment D : [dD];
fragment E : [eE];
fragment F : [fF];
fragment G : [gG];
fragment H : [hH];
fragment I : [iI];
fragment J : [jJ];
fragment K : [kK];
fragment L : [lL];
fragment M : [mM];
fragment N : [nN];
fragment O : [oO];
fragment P : [pP];
fragment Q : [qQ];
fragment R : [rR];
fragment S : [sS];
fragment T : [tT];
fragment U : [uU];
fragment V : [vV];
fragment W : [wW];
fragment X : [xX];
fragment Y : [yY];
fragment Z : [zZ];
fragment HEX_DIGIT: [0-9A-F];
fragment DEC_DIGIT: [0-9];
fragment LETTER: [a-zA-Z];
ID: ( 'A'..'Z' | 'a'..'z' | '_' | '$') ( 'A'..'Z' | 'a'..'z' | '_' | '$' | '0'..'9' )*;
TEXT_STRING : ( '\'' ( ('\\' '\\') | ('\'' '\'') | ('\\' '\'') | ~('\'') )* '\'' );
ID_LITERAL: '*'|('@'|'_'|LETTER)(LETTER|DEC_DIGIT|'_')*;
REVERSE_QUOTE_ID : '`' ~'`'+ '`';
DECIMAL_LITERAL: DEC_DIGIT+;
tableName : tmpName=ID;
column_name : ID;
function_name : tmpName=ID ;
selectStatement:
SELECT
selectElements
(
FROM tableSources
( whereClause )?
( groupByCaluse )?
( havingCaluse )?
) ?
( orderByClause )?
( limitClause )?
;
selectElements
: (star='*' | selectElement ) (',' selectElement)*
;
tableSources
: tableName (',' tableName)*
;
whereClause
: WHERE logicExpression
;
logicExpression
: logicExpression logicalOperator logicExpression
| fullColumnName comparisonOperator value
| fullColumnName BETWEEN value AND value
| fullColumnName NOT? IN '(' value (',' value)* ')'
| '(' logicExpression ')'
;
groupByCaluse
: GROUP BY groupByItem (',' groupByItem)*
;
havingCaluse
: HAVING logicExpression
;
orderByClause
: ORDER BY orderByExpression (',' orderByExpression)*
;
limitClause
: LIMIT
(
(offset=decimalLiteral ',')? limit=decimalLiteral
| limit=decimalLiteral OFFSET offset=decimalLiteral
)
;
orderByExpression
: fullColumnName order=(ASC | DESC)?
;
groupByItem
: fullColumnName order=(ASC | DESC)?
;
logicalOperator
: AND | '&' '&' | OR | '|' '|'
;
comparisonOperator
: '=' | '>' | '<' | '<' '=' | '>' '='
| '<' '>' | '!' '=' | '<' '=' '>'
;
value
: uid
| textLiteral
| decimalLiteral
;
decimalLiteral
: DECIMAL_LITERAL
;
textLiteral
: TEXT_STRING
;
selectElement
: fullColumnName (AS? uid)? #selectColumnElement
| functionCall (AS? uid)? #selectFunctionElement
;
fullColumnName
: column_name
;
functionCall
: aggregateWindowedFunction #aggregateFunctionCall
;
aggregateWindowedFunction
: (AVG | MAX | MIN | SUM) '(' functionArg ')'
| COUNT '(' (starArg='*' | functionArg?) ')'
| COUNT '(' aggregator=DISTINCT functionArgs ')'
;
functionArg
: column_name
;
functionArgs
: column_name (',' column_name)*
;
uid
: ID
;
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines | 4,334 | ANTLR | .g4 | 161 | 23.84472 | 104 | 0.466618 | qiub649691422/demo-sharding | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | 0f169945169c014905d14e5f76a5394d72058f2c08915d7f06b93905ceb251c3 | true | true | false | false |
120 | AnnotatedAspCore2ILFGrammar.g4 | tobiasberei_ts-aspcore2-parser/src/grammar/AnnotatedAspCore2ILFGrammar.g4 | grammar AnnotatedAspCore2ILFGrammar;
WS : [ \t\r\n] -> skip;
DIGIT : [0-9];
ANNOTATION_START : '%**';
ANNOTATION_END : '**%';
RULE : 'rule';
RULES: 'rules';
BLOCK : 'block';
NAME : 'name';
TEST : 'test';
CONSTRAINT: 'constraint';
SCOPE : 'scope';
PROGRAM_FILES: 'programFiles';
INPUT : 'input';
INPUT_FILES : 'inputFiles';
ASSERT : 'assert';
ATOMS : 'atoms';
COST : 'cost';
LEVEL : 'level';
PROGRAM : 'program';
ADD_FILES: 'additionalFiles';
NUM_STR : 'number';
ASSERT_NAS : 'noAnswerSet';
ASSERT_TIA : 'trueInAll';
ASSERT_TIAL : 'trueInAtLeast';
ASSERT_TIAM : 'trueInAtMost';
ASSERT_TIE : 'trueInExactly';
ASSERT_FIA : 'falseInAll';
ASSERT_FIAL : 'falseInAtLeast';
ASSERT_FIAM : 'falseInAtMost';
ASSERT_FIE : 'falseInExactly';
ASSERT_C : 'constraintForAll';
ASSERT_CIE : 'constraintInExactly';
ASSERT_CIAL : 'constraintInAtLeast';
ASSERT_CIAM : 'constraintInAtMost';
ASSERT_BMC : 'bestModelCost';
UPPERLETTER : [A-Z];
LOWERLETTER: [a-z];
NAF: 'not';
ID: LOWERLETTER (UPPERLETTER | LOWERLETTER | NUMBER | '_')*;
VARIABLE: UPPERLETTER (UPPERLETTER | LOWERLETTER | NUMBER | '_')*;
STRING: '\'' ~('\n' | '\r' | '\'')* '\'';
NUMBER: (DIGIT)+ ;
ANONYMOUS_VARIABLE : '_' ;
DOT: '.';
COMMA: ',';
QUERY_MARK: '?';
COLON: ':';
SEMICOLON: ';';
OR: '|';
CONS: ':-';
WCONS: ':~';
PLUS: '+';
MINUS: '-';
TIMES: '*';
DIV: '/';
AT: '@';
PAREN_OPEN: '(';
PAREN_CLOSE: ')';
SQUARE_OPEN: '[';
SQUARE_CLOSE: ']';
CURLY_OPEN: '{';
CURLY_CLOSE: '}';
EQUAL: '=';
UNEQUAL: '<>' | '!=';
LESS: '<';
GREATER: '>';
LESS_OR_EQ: '<=';
GREATER_OR_EQ: '>=';
AGGREGATE_COUNT: '#count';
AGGREGATE_SUM: '#sum';
AGGREGATE_MAX: '#max';
AGGREGATE_MIN: '#min';
MAXIMIZE: '#maximize';
MINIMIZE: '#minimize';
COMMENT: '%' ~('*') ~('\n' | '^')* (('\n'|'^')?);
MULTI_LINE_COMMENT_START: '%*' ~('*');
MULTI_LINE_COMMENT_END: '*%';
MULTI_LINE_COMMENT: MULTI_LINE_COMMENT_START ~('%')* MULTI_LINE_COMMENT_END;
annotatedAspCore2ILFGrammar
: program
;
program
: statements? query? EOF
;
statements
: statement statements?
;
query
: classicalLiteral QUERY_MARK
;
statement
: annotation
| comment
| CONS body? DOT // integrity constraint
| head (CONS body?)? DOT // rule/fact
| WCONS body? DOT SQUARE_OPEN weightAtLevel SQUARE_CLOSE
| optimize DOT
;
comment
: MULTI_LINE_COMMENT
| COMMENT
;
head
: disjunction
| choice
;
body
: nafLiteral
;
// :
// (
// nafLiteral
// | (nafAggregate | aggregate)
// )
// (COMMA body)?
// ;
disjunction
: classicalLiteral (OR disjunction)?
;
choice
: (term binop) ? CURLY_OPEN choiceElements? CURLY_CLOSE (binop term)?
;
choiceElements
: choiceElement (SEMICOLON choiceElements)?
;
choiceElement
: atom (COLON nafLiterals?)?
;
nafAggregate
: NAF? (term negativeBinop)? aggregateDefinition (negativeBinop term)?
;
aggregate
: (term EQUAL)? aggregateDefinition (EQUAL term)?
;
aggregateDefinition
: aggregateFunction CURLY_OPEN aggregateElements CURLY_CLOSE
;
aggregateElements
: aggregateElement (SEMICOLON aggregateElements)?
;
aggregateElement
: basicTerms? (COLON nafLiterals?)?
;
aggregateFunction
: AGGREGATE_COUNT
| AGGREGATE_MAX
| AGGREGATE_MIN
| AGGREGATE_SUM
;
optimize
: optimizeFunction CURLY_OPEN optimizeElements? CURLY_CLOSE
;
optimizeElements
: optimizeElement (SEMICOLON optimizeElements)?
;
optimizeElement
: weightAtLevel (COLON nafLiterals?)?
;
optimizeFunction
: MAXIMIZE
| MINIMIZE
;
weightAtLevel
: weakTerm (AT weakTerm)? (COMMA weakTerms)?
;
nafLiterals
: nafLiteral (COMMA nafLiterals)?
;
nafLiteral
:
// nafClassicalLiteral
// |
classicalLiteral
// | (NAF? negativeBuiltinAtom | builtinAtom)
;
nafClassicalLiteral
: NAF classicalLiteral
;
classicalLiteral
: MINUS? atom
;
atom
: atomName PAREN_OPEN terms? PAREN_CLOSE
;
negativeBuiltinAtom
: term negativeBinop term
;
builtinAtom
: term EQUAL term
;
negativeBinop
: UNEQUAL
| LESS
| GREATER
| LESS_OR_EQ
| GREATER_OR_EQ
;
binop
: EQUAL
| UNEQUAL
| LESS
| GREATER
| LESS_OR_EQ
| GREATER_OR_EQ
;
terms
: term COMMA terms
;
term
: (atomName PAREN_OPEN terms? PAREN_CLOSE)
| basicTerm
| (PAREN_OPEN term PAREN_CLOSE)
| (MINUS term)
;
groundTerm
: ID
| NUMBER
| STRING
;
variableTerm
: VARIABLE
| ANONYMOUS_VARIABLE
;
basicTerms
: basicTerm (COMMA basicTerms)?
;
basicTerm
: groundTerm
| variableTerm
;
weakTerms
: weakTerm (COMMA weakTerms)?
;
weakTerm
: term
| basicTerm
;
arithop
: PLUS
| MINUS
| TIMES
| DIV
;
atomName
: ID
;
/* ANNOTATION GRAMMAR */
annotation
: ANNOTATION_START annotationList ANNOTATION_END
;
annotationList
: annotationExpression annotationList?
;
annotationExpression
: ruleDefinition
| blockDefinition
| testDefinition
| programDefinition
;
ruleDefinition
: AT RULE PAREN_OPEN NAME EQUAL STRING (COMMA BLOCK EQUAL STRING)? PAREN_CLOSE
;
blockDefinition
: AT BLOCK PAREN_OPEN NAME EQUAL STRING (COMMA RULES EQUAL CURLY_OPEN ruleReferenceList CURLY_CLOSE)? PAREN_CLOSE
;
testDefinition
: AT TEST PAREN_OPEN NAME EQUAL STRING COMMA SCOPE EQUAL CURLY_OPEN referenceList CURLY_CLOSE COMMA
(PROGRAM_FILES EQUAL CURLY_OPEN programFilesList CURLY_CLOSE COMMA)?
(INPUT EQUAL STRING COMMA)?
(INPUT_FILES EQUAL CURLY_OPEN inputFilesList CURLY_CLOSE COMMA)?
ASSERT EQUAL CURLY_OPEN assertionList CURLY_CLOSE PAREN_CLOSE
;
programDefinition
: AT PROGRAM PAREN_OPEN NAME EQUAL STRING (COMMA ADD_FILES EQUAL STRING)? PAREN_CLOSE
;
ruleReferenceList
: ruleReference (COMMA ruleReferenceList)?
;
ruleReference
: STRING
;
programFilesList
: programFile (COMMA programFilesList)?
;
programFile
: STRING
;
inputFilesList
: inputFile (COMMA inputFilesList)?
;
inputFile
: STRING
;
referenceList
: reference (COMMA referenceList)?
;
reference
: STRING
;
assertionList
: assertion (COMMA assertionList)?
;
assertion
: AT assertType
;
assertType
: assertNoAnswerSet
| assertTrueInAll
| assertTrueInAtLeast
| assertTrueInAtMost
| assertTrueInExactly
| assertFalseInAll
| assertFalsInAtLeast
| assertFalseInAtMost
| assertFalseInExactly
| assertConstraint
| assertConstraintInExactly
| assertConstraintInAtLeast
| assertConstraintInAtMost
| assertBestModelCost
;
assertNoAnswerSet
: ASSERT_NAS
;
assertTrueInAll
: ASSERT_TIA PAREN_OPEN ATOMS EQUAL STRING PAREN_CLOSE
;
assertTrueInAtLeast
: ASSERT_TIAL PAREN_OPEN NUM_STR EQUAL NUMBER COMMA ATOMS EQUAL STRING PAREN_CLOSE
;
assertTrueInAtMost
: ASSERT_TIAM PAREN_OPEN NUM_STR EQUAL NUMBER COMMA ATOMS EQUAL STRING PAREN_CLOSE
;
assertTrueInExactly
: ASSERT_TIE PAREN_OPEN NUM_STR EQUAL NUMBER COMMA ATOMS EQUAL STRING PAREN_CLOSE
;
assertFalseInAll
: ASSERT_FIA PAREN_OPEN ATOMS EQUAL STRING PAREN_CLOSE
;
assertFalsInAtLeast
: ASSERT_FIAL PAREN_OPEN NUM_STR EQUAL NUMBER COMMA ATOMS EQUAL STRING PAREN_CLOSE
;
assertFalseInAtMost
: ASSERT_FIAM PAREN_OPEN NUM_STR EQUAL NUMBER COMMA ATOMS EQUAL STRING PAREN_CLOSE
;
assertFalseInExactly
: ASSERT_FIE PAREN_OPEN NUM_STR EQUAL NUMBER COMMA ATOMS EQUAL STRING PAREN_CLOSE
;
assertConstraint
: ASSERT_C PAREN_OPEN CONSTRAINT EQUAL STRING PAREN_CLOSE
;
assertConstraintInExactly
: ASSERT_CIE PAREN_OPEN NUM_STR EQUAL NUMBER COMMA CONSTRAINT EQUAL STRING PAREN_CLOSE
;
assertConstraintInAtLeast
: ASSERT_CIAL PAREN_OPEN NUM_STR EQUAL NUMBER COMMA CONSTRAINT EQUAL STRING PAREN_CLOSE
;
assertConstraintInAtMost
: ASSERT_CIAM PAREN_OPEN NUM_STR EQUAL NUMBER COMMA CONSTRAINT EQUAL STRING PAREN_CLOSE
;
assertBestModelCost
: ASSERT_BMC PAREN_OPEN COST EQUAL NUMBER COMMA LEVEL EQUAL NUMBER PAREN_CLOSE
;
| 8,235 | ANTLR | .g4 | 364 | 19.008242 | 117 | 0.690953 | tobiasberei/ts-aspcore2-parser | 1 | 0 | 12 | GPL-3.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | 44a061918f2b5af11b68295bf458f62b80143a831e28009f7428a02f922c63cf | false | false | false | false |
121 | AspCore2ILFGrammar.g4 | tobiasberei_ts-aspcore2-parser/src/grammar/AspCore2ILFGrammar.g4 | grammar AspCore2ILFGrammar;
WS : (' ' | '\t' | '\r' | '\n') -> skip;
fragment DIGIT : ('0'..'9');
ANNOTATION_START : '%**';
ANNOTATION_END : '**%';
RULE : 'rule';
RULES: 'rules';
BLOCK : 'block';
NAME : 'name';
TEST : 'test';
CONSTRAINT: 'constraint';
SCOPE : 'scope';
PROGRAM_FILES: 'programFiles';
INPUT : 'input';
INPUT_FILES : 'inputFiles';
ASSERT : 'assert';
ATOMS : 'atoms';
COST : 'cost';
LEVEL : 'level';
PROGRAM : 'program';
ADD_FILES: 'additionalFiles';
NUM_STR : 'number';
ASSERT_NAS : 'noAnswerSet';
ASSERT_TIA : 'trueInAll';
ASSERT_TIAL : 'trueInAtLeast';
ASSERT_TIAM : 'trueInAtMost';
ASSERT_TIE : 'trueInExactly';
ASSERT_FIA : 'falseInAll';
ASSERT_FIAL : 'falseInAtLeast';
ASSERT_FIAM : 'falseInAtMost';
ASSERT_FIE : 'falseInExactly';
ASSERT_C : 'constraintForAll';
ASSERT_CIE : 'constraintInExactly';
ASSERT_CIAL : 'constraintInAtLeast';
ASSERT_CIAM : 'constraintInAtMost';
ASSERT_BMC : 'bestModelCost';
fragment UPPERLETTER : ('A'..'Z');
fragment LOWERLETTER: ('a'..'z');
NAF: 'not';
ID: LOWERLETTER (UPPERLETTER | LOWERLETTER | NUMBER | '_')*;
VARIABLE: UPPERLETTER (UPPERLETTER | LOWERLETTER | NUMBER | '_')*;
STRING: '\'' ~('\n' | '\r' | '\'')* '\'';
NUMBER: DIGIT+ ;
ANONYMOUS_VARIABLE : '_' ;
DOT: '.';
COMMA: ',';
QUERY_MARK: '?';
COLON: ':';
SEMICOLON: ';';
OR: '|';
CONS: ':-';
WCONS: ':~';
PLUS: '+';
MINUS: '-';
TIMES: '*';
DIV: '/';
AT: '@';
PAREN_OPEN: '(';
PAREN_CLOSE: ')';
SQUARE_OPEN: '[';
SQUARE_CLOSE: ']';
CURLY_OPEN: '{';
CURLY_CLOSE: '}';
EQUAL: '=';
UNEQUAL: '<>' | '!=';
LESS: '<';
GREATER: '>';
LESS_OR_EQ: '<=';
GREATER_OR_EQ: '>=';
AGGREGATE_COUNT: '#count';
AGGREGATE_SUM: '#sum';
AGGREGATE_MAX: '#max';
AGGREGATE_MIN: '#min';
MAXIMIZE: '#maximize';
MINIMIZE: '#minimize';
COMMENT: '%' ~('*') ~('\n' | '^')* (('\n'|'^')?);
MULTI_LINE_COMMENT_START: '%*' ~('*');
MULTI_LINE_COMMENT_END: '*%';
MULTI_LINE_COMMENT: MULTI_LINE_COMMENT_START ~('%')* MULTI_LINE_COMMENT_END;
aspCore2ILFGrammar
: program
;
program
: statements? query? EOF
;
statements
: statement statements?
;
query
: classicalLiteral QUERY_MARK
;
statement
: CONS body? DOT // integrity constraint
| head (CONS body?)? DOT // rule/fact
| WCONS body? DOT SQUARE_OPEN weightAtLevel SQUARE_CLOSE
| optimize DOT
| comment // added comment (not present in ASPCore2)
;
comment
: MULTI_LINE_COMMENT
| COMMENT
;
head
: disjunction
| choice
;
body
: (nafLiteral | NAF? aggregate) (COMMA body)?;
disjunction
: classicalLiteral (OR disjunction)?
;
choice
: (term binop) ? CURLY_OPEN choiceElements? CURLY_CLOSE (binop term)?
;
choiceElements
: choiceElement (SEMICOLON choiceElements)?
;
choiceElement
: classicalLiteral (COLON nafLiterals?)?
;
aggregate
: (term binop)? aggregateDefinition (binop term)?
;
aggregateDefinition
: aggregateFunction CURLY_OPEN aggregateElements CURLY_CLOSE
;
aggregateElements
: aggregateElement (SEMICOLON aggregateElements)?
;
aggregateElement
: terms? (COLON nafLiterals?)?
;
aggregateFunction
: AGGREGATE_COUNT
| AGGREGATE_MAX
| AGGREGATE_MIN
| AGGREGATE_SUM
;
optimize
: optimizeFunction CURLY_OPEN optimizeElements? CURLY_CLOSE
;
optimizeElements
: optimizeElement (SEMICOLON optimizeElements)?
;
optimizeElement
: weightAtLevel (COLON nafLiterals?)?
;
optimizeFunction
: MAXIMIZE
| MINIMIZE
;
weightAtLevel
: term (AT term)? (COMMA terms)?
;
nafLiterals
: nafLiteral (COMMA nafLiterals)?
;
nafLiteral
:
NAF? (classicalLiteral | builtinAtom)
;
classicalLiteral
: MINUS? ID (PAREN_OPEN terms? PAREN_CLOSE)?
;
builtinAtom
: term binop term
;
binop
: EQUAL
| UNEQUAL
| LESS
| GREATER
| LESS_OR_EQ
| GREATER_OR_EQ
;
terms
: term (COMMA terms)?
;
term
: (ID (PAREN_OPEN terms? PAREN_CLOSE)?)
| NUMBER
| STRING
| VARIABLE
| ANONYMOUS_VARIABLE
| PAREN_OPEN term PAREN_CLOSE
| MINUS term
| term arithop term
;
arithop
: PLUS
| MINUS
| TIMES
| DIV
;
| 4,154 | ANTLR | .g4 | 194 | 18.474227 | 76 | 0.650955 | tobiasberei/ts-aspcore2-parser | 1 | 0 | 12 | GPL-3.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | 83c250f3c536c7611f98f42583dfad78468e0ae2a4b6623b343f3518314410e9 | false | false | false | false |
122 | Plantuml.g4 | yte424_plantuml-grammar/Plantuml.g4 | grammar Plantuml;
/*
* Parser Rules
*/
plantumlfile : STARTFILE title (umlclass)+ EMDFILE;
name : WORD ;
umlclass : class_declaration ;
/*
* Lexer Rules
*/
//https://github.com/antlr/grammars-v4/blob/master/csharp/CSharpLexer.g4
OPEN_BRACE : '{';
CLOSE_BRACE : '}';
PARENS: '()';
CLASS : 'class';
STARTFILE : '@startuml';
EMDFILE : '@enduml';
COLON : ':';
EXPLICIT_METHOD : '{method';
WHITESPACES: (Whitespace | NewLine)+ -> channel(HIDDEN);
WORD : [A-Za-z_][A-Za-z_0-9]* ;
TITELIdentifier : 'title';
title : TITELIdentifier WORD NewLine;
class_declaration : CLASS class_identifier OPEN_BRACE atttribute_def method_def* CLOSE_BRACE;
atttribute_def : (objecttype COLON WORD)*;
method_def
: (method_name COLON objecttype PARENS)
| (method_name PARENS )
;
method_name : WORD;
objecttype : WORD;
class_identifier : WORD;
identifier : WORD;
//TEXT : '"' .*? '"' ;
fragment NewLine
: '\r\n' | '\r' | '\n'
| '\u0085' // <Next Line CHARACTER (U+0085)>'
| '\u2028' //'<Line Separator CHARACTER (U+2028)>'
| '\u2029' //'<Paragraph Separator CHARACTER (U+2029)>'
;
fragment Whitespace
: UnicodeClassZS //'<Any Character With Unicode Class Zs>'
| '\u0009' //'<Horizontal Tab Character (U+0009)>'
| '\u000B' //'<Vertical Tab Character (U+000B)>'
| '\u000C' //'<Form Feed Character (U+000C)>'
;
fragment UnicodeClassZS
: '\u0020' // SPACE
| '\u00A0' // NO_BREAK SPACE
| '\u1680' // OGHAM SPACE MARK
| '\u180E' // MONGOLIAN VOWEL SEPARATOR
| '\u2000' // EN QUAD
| '\u2001' // EM QUAD
| '\u2002' // EN SPACE
| '\u2003' // EM SPACE
| '\u2004' // THREE_PER_EM SPACE
| '\u2005' // FOUR_PER_EM SPACE
| '\u2006' // SIX_PER_EM SPACE
| '\u2008' // PUNCTUATION SPACE
| '\u2009' // THIN SPACE
| '\u200A' // HAIR SPACE
| '\u202F' // NARROW NO_BREAK SPACE
| '\u3000' // IDEOGRAPHIC SPACE
| '\u205F' // MEDIUM MATHEMATICAL SPACE
;
| 2,009 | ANTLR | .g4 | 65 | 28.8 | 95 | 0.610881 | yte424/plantuml-grammar | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | ec69fdf4bbddb0e42a476e41d84507ac3573c75a7cb66a2a5a489a20fea0a730 | false | false | false | false |
123 | MySqlLexer.g4 | slifin_honeySQL-parser/src/sql_translation/MySqlLexer.g4 | /*
MySQL (Positive Technologies) grammar
The MIT License (MIT).
Copyright (c) 2015-2017, Ivan Kochurkin ([email protected]), Positive Technologies.
Copyright (c) 2017, Ivan Khudyashev ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
lexer grammar MySqlLexer;
channels { MYSQLCOMMENT, ERRORCHANNEL }
// SKIP
SPACE: [ \t\r\n]+ -> channel(HIDDEN);
SPEC_MYSQL_COMMENT: '/*!' .+? '*/' -> channel(MYSQLCOMMENT);
COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN);
LINE_COMMENT: (
('-- ' | '#') ~[\r\n]* ('\r'? '\n' | EOF)
| '--' ('\r'? '\n' | EOF)
) -> channel(HIDDEN);
// Keywords
// Common Keywords
ADD: 'ADD';
ALL: 'ALL';
ALTER: 'ALTER';
ANALYZE: 'ANALYZE';
AND: 'AND';
AS: 'AS';
ASC: 'ASC';
BEFORE: 'BEFORE';
BETWEEN: 'BETWEEN';
BOTH: 'BOTH';
BY: 'BY';
CALL: 'CALL';
CASCADE: 'CASCADE';
CASE: 'CASE';
CAST: 'CAST';
CHANGE: 'CHANGE';
CHARACTER: 'CHARACTER';
CHECK: 'CHECK';
COLLATE: 'COLLATE';
COLUMN: 'COLUMN';
CONDITION: 'CONDITION';
CONSTRAINT: 'CONSTRAINT';
CONTINUE: 'CONTINUE';
CONVERT: 'CONVERT';
CREATE: 'CREATE';
CROSS: 'CROSS';
CURRENT_USER: 'CURRENT_USER';
CURSOR: 'CURSOR';
DATABASE: 'DATABASE';
DATABASES: 'DATABASES';
DECLARE: 'DECLARE';
DEFAULT: 'DEFAULT';
DELAYED: 'DELAYED';
DELETE: 'DELETE';
DESC: 'DESC';
DESCRIBE: 'DESCRIBE';
DETERMINISTIC: 'DETERMINISTIC';
DISTINCT: 'DISTINCT';
DISTINCTROW: 'DISTINCTROW';
DROP: 'DROP';
EACH: 'EACH';
ELSE: 'ELSE';
ELSEIF: 'ELSEIF';
ENCLOSED: 'ENCLOSED';
ESCAPED: 'ESCAPED';
EXISTS: 'EXISTS';
EXIT: 'EXIT';
EXPLAIN: 'EXPLAIN';
FALSE: 'FALSE';
FETCH: 'FETCH';
FOR: 'FOR';
FORCE: 'FORCE';
FOREIGN: 'FOREIGN';
FROM: 'FROM';
FULLTEXT: 'FULLTEXT';
GRANT: 'GRANT';
GROUP: 'GROUP';
HAVING: 'HAVING';
HIGH_PRIORITY: 'HIGH_PRIORITY';
IF: 'IF';
IGNORE: 'IGNORE';
IN: 'IN';
INDEX: 'INDEX';
INFILE: 'INFILE';
INNER: 'INNER';
INOUT: 'INOUT';
INSERT: 'INSERT';
INTERVAL: 'INTERVAL';
INTO: 'INTO';
IS: 'IS';
ITERATE: 'ITERATE';
JOIN: 'JOIN';
KEY: 'KEY';
KEYS: 'KEYS';
KILL: 'KILL';
LEADING: 'LEADING';
LEAVE: 'LEAVE';
LEFT: 'LEFT';
LIKE: 'LIKE';
LIMIT: 'LIMIT';
LINEAR: 'LINEAR';
LINES: 'LINES';
LOAD: 'LOAD';
LOCK: 'LOCK';
LOOP: 'LOOP';
LOW_PRIORITY: 'LOW_PRIORITY';
MASTER_BIND: 'MASTER_BIND';
MASTER_SSL_VERIFY_SERVER_CERT: 'MASTER_SSL_VERIFY_SERVER_CERT';
MATCH: 'MATCH';
MAXVALUE: 'MAXVALUE';
MODIFIES: 'MODIFIES';
NATURAL: 'NATURAL';
NOT: 'NOT';
NO_WRITE_TO_BINLOG: 'NO_WRITE_TO_BINLOG';
NULL_LITERAL: 'NULL';
ON: 'ON';
OPTIMIZE: 'OPTIMIZE';
OPTION: 'OPTION';
OPTIONALLY: 'OPTIONALLY';
OR: 'OR';
ORDER: 'ORDER';
OUT: 'OUT';
OUTER: 'OUTER';
OUTFILE: 'OUTFILE';
PARTITION: 'PARTITION';
PRIMARY: 'PRIMARY';
PROCEDURE: 'PROCEDURE';
PURGE: 'PURGE';
RANGE: 'RANGE';
READ: 'READ';
READS: 'READS';
REFERENCES: 'REFERENCES';
REGEXP: 'REGEXP';
RELEASE: 'RELEASE';
RENAME: 'RENAME';
REPEAT: 'REPEAT';
REPLACE: 'REPLACE';
REQUIRE: 'REQUIRE';
RESTRICT: 'RESTRICT';
RETURN: 'RETURN';
REVOKE: 'REVOKE';
RIGHT: 'RIGHT';
RLIKE: 'RLIKE';
SCHEMA: 'SCHEMA';
SCHEMAS: 'SCHEMAS';
SELECT: 'SELECT';
SET: 'SET';
SEPARATOR: 'SEPARATOR';
SHOW: 'SHOW';
SPATIAL: 'SPATIAL';
SQL: 'SQL';
SQLEXCEPTION: 'SQLEXCEPTION';
SQLSTATE: 'SQLSTATE';
SQLWARNING: 'SQLWARNING';
SQL_BIG_RESULT: 'SQL_BIG_RESULT';
SQL_CALC_FOUND_ROWS: 'SQL_CALC_FOUND_ROWS';
SQL_SMALL_RESULT: 'SQL_SMALL_RESULT';
SSL: 'SSL';
STARTING: 'STARTING';
STRAIGHT_JOIN: 'STRAIGHT_JOIN';
TABLE: 'TABLE';
TERMINATED: 'TERMINATED';
THEN: 'THEN';
TO: 'TO';
TRAILING: 'TRAILING';
TRIGGER: 'TRIGGER';
TRUE: 'TRUE';
UNDO: 'UNDO';
UNION: 'UNION';
UNIQUE: 'UNIQUE';
UNLOCK: 'UNLOCK';
UNSIGNED: 'UNSIGNED';
UPDATE: 'UPDATE';
USAGE: 'USAGE';
USE: 'USE';
USING: 'USING';
VALUES: 'VALUES';
WHEN: 'WHEN';
WHERE: 'WHERE';
WHILE: 'WHILE';
WITH: 'WITH';
WRITE: 'WRITE';
XOR: 'XOR';
ZEROFILL: 'ZEROFILL';
// DATA TYPE Keywords
TINYINT: 'TINYINT';
SMALLINT: 'SMALLINT';
MEDIUMINT: 'MEDIUMINT';
INT: 'INT';
INTEGER: 'INTEGER';
BIGINT: 'BIGINT';
REAL: 'REAL';
DOUBLE: 'DOUBLE';
FLOAT: 'FLOAT';
DECIMAL: 'DECIMAL';
NUMERIC: 'NUMERIC';
DATE: 'DATE';
TIME: 'TIME';
TIMESTAMP: 'TIMESTAMP';
DATETIME: 'DATETIME';
YEAR: 'YEAR';
CHAR: 'CHAR';
VARCHAR: 'VARCHAR';
BINARY: 'BINARY';
VARBINARY: 'VARBINARY';
TINYBLOB: 'TINYBLOB';
BLOB: 'BLOB';
MEDIUMBLOB: 'MEDIUMBLOB';
LONGBLOB: 'LONGBLOB';
TINYTEXT: 'TINYTEXT';
TEXT: 'TEXT';
MEDIUMTEXT: 'MEDIUMTEXT';
LONGTEXT: 'LONGTEXT';
ENUM: 'ENUM';
// Interval type Keywords
YEAR_MONTH: 'YEAR_MONTH';
DAY_HOUR: 'DAY_HOUR';
DAY_MINUTE: 'DAY_MINUTE';
DAY_SECOND: 'DAY_SECOND';
HOUR_MINUTE: 'HOUR_MINUTE';
HOUR_SECOND: 'HOUR_SECOND';
MINUTE_SECOND: 'MINUTE_SECOND';
SECOND_MICROSECOND: 'SECOND_MICROSECOND';
MINUTE_MICROSECOND: 'MINUTE_MICROSECOND';
HOUR_MICROSECOND: 'HOUR_MICROSECOND';
DAY_MICROSECOND: 'DAY_MICROSECOND';
// Group function Keywords
AVG: 'AVG';
BIT_AND: 'BIT_AND';
BIT_OR: 'BIT_OR';
BIT_XOR: 'BIT_XOR';
COUNT: 'COUNT';
GROUP_CONCAT: 'GROUP_CONCAT';
MAX: 'MAX';
MIN: 'MIN';
STD: 'STD';
STDDEV: 'STDDEV';
STDDEV_POP: 'STDDEV_POP';
STDDEV_SAMP: 'STDDEV_SAMP';
SUM: 'SUM';
VAR_POP: 'VAR_POP';
VAR_SAMP: 'VAR_SAMP';
VARIANCE: 'VARIANCE';
// Common function Keywords
CURRENT_DATE: 'CURRENT_DATE';
CURRENT_TIME: 'CURRENT_TIME';
CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP';
LOCALTIME: 'LOCALTIME';
CURDATE: 'CURDATE';
CURTIME: 'CURTIME';
DATE_ADD: 'DATE_ADD';
DATE_SUB: 'DATE_SUB';
EXTRACT: 'EXTRACT';
LOCALTIMESTAMP: 'LOCALTIMESTAMP';
NOW: 'NOW';
POSITION: 'POSITION';
SUBSTR: 'SUBSTR';
SUBSTRING: 'SUBSTRING';
SYSDATE: 'SYSDATE';
TRIM: 'TRIM';
UTC_DATE: 'UTC_DATE';
UTC_TIME: 'UTC_TIME';
UTC_TIMESTAMP: 'UTC_TIMESTAMP';
// Keywords, but can be ID
// Common Keywords, but can be ID
ACCOUNT: 'ACCOUNT';
ACTION: 'ACTION';
AFTER: 'AFTER';
AGGREGATE: 'AGGREGATE';
ALGORITHM: 'ALGORITHM';
ANY: 'ANY';
AT: 'AT';
AUTHORS: 'AUTHORS';
AUTOCOMMIT: 'AUTOCOMMIT';
AUTOEXTEND_SIZE: 'AUTOEXTEND_SIZE';
AUTO_INCREMENT: 'AUTO_INCREMENT';
AVG_ROW_LENGTH: 'AVG_ROW_LENGTH';
BEGIN: 'BEGIN';
BINLOG: 'BINLOG';
BIT: 'BIT';
BLOCK: 'BLOCK';
BOOL: 'BOOL';
BOOLEAN: 'BOOLEAN';
BTREE: 'BTREE';
CACHE: 'CACHE';
CASCADED: 'CASCADED';
CHAIN: 'CHAIN';
CHANGED: 'CHANGED';
CHANNEL: 'CHANNEL';
CHECKSUM: 'CHECKSUM';
CIPHER: 'CIPHER';
CLIENT: 'CLIENT';
CLOSE: 'CLOSE';
COALESCE: 'COALESCE';
CODE: 'CODE';
COLUMNS: 'COLUMNS';
COLUMN_FORMAT: 'COLUMN_FORMAT';
COMMENT: 'COMMENT';
COMMIT: 'COMMIT';
COMPACT: 'COMPACT';
COMPLETION: 'COMPLETION';
COMPRESSED: 'COMPRESSED';
COMPRESSION: 'COMPRESSION';
CONCURRENT: 'CONCURRENT';
CONNECTION: 'CONNECTION';
CONSISTENT: 'CONSISTENT';
CONTAINS: 'CONTAINS';
CONTEXT: 'CONTEXT';
CONTRIBUTORS: 'CONTRIBUTORS';
COPY: 'COPY';
CPU: 'CPU';
DATA: 'DATA';
DATAFILE: 'DATAFILE';
DEALLOCATE: 'DEALLOCATE';
DEFAULT_AUTH: 'DEFAULT_AUTH';
DEFINER: 'DEFINER';
DELAY_KEY_WRITE: 'DELAY_KEY_WRITE';
DES_KEY_FILE: 'DES_KEY_FILE';
DIRECTORY: 'DIRECTORY';
DISABLE: 'DISABLE';
DISCARD: 'DISCARD';
DISK: 'DISK';
DO: 'DO';
DUMPFILE: 'DUMPFILE';
DUPLICATE: 'DUPLICATE';
DYNAMIC: 'DYNAMIC';
ENABLE: 'ENABLE';
ENCRYPTION: 'ENCRYPTION';
END: 'END';
ENDS: 'ENDS';
ENGINE: 'ENGINE';
ENGINES: 'ENGINES';
ERROR: 'ERROR';
ERRORS: 'ERRORS';
ESCAPE: 'ESCAPE';
EVEN: 'EVEN';
EVENT: 'EVENT';
EVENTS: 'EVENTS';
EVERY: 'EVERY';
EXCHANGE: 'EXCHANGE';
EXCLUSIVE: 'EXCLUSIVE';
EXPIRE: 'EXPIRE';
EXPORT: 'EXPORT';
EXTENDED: 'EXTENDED';
EXTENT_SIZE: 'EXTENT_SIZE';
FAST: 'FAST';
FAULTS: 'FAULTS';
FIELDS: 'FIELDS';
FILE_BLOCK_SIZE: 'FILE_BLOCK_SIZE';
FILTER: 'FILTER';
FIRST: 'FIRST';
FIXED: 'FIXED';
FLUSH: 'FLUSH';
FOLLOWS: 'FOLLOWS';
FOUND: 'FOUND';
FULL: 'FULL';
FUNCTION: 'FUNCTION';
GENERAL: 'GENERAL';
GLOBAL: 'GLOBAL';
GRANTS: 'GRANTS';
GROUP_REPLICATION: 'GROUP_REPLICATION';
HANDLER: 'HANDLER';
HASH: 'HASH';
HELP: 'HELP';
HOST: 'HOST';
HOSTS: 'HOSTS';
IDENTIFIED: 'IDENTIFIED';
IGNORE_SERVER_IDS: 'IGNORE_SERVER_IDS';
IMPORT: 'IMPORT';
INDEXES: 'INDEXES';
INITIAL_SIZE: 'INITIAL_SIZE';
INPLACE: 'INPLACE';
INSERT_METHOD: 'INSERT_METHOD';
INSTALL: 'INSTALL';
INSTANCE: 'INSTANCE';
INVOKER: 'INVOKER';
IO: 'IO';
IO_THREAD: 'IO_THREAD';
IPC: 'IPC';
ISOLATION: 'ISOLATION';
ISSUER: 'ISSUER';
JSON: 'JSON';
KEY_BLOCK_SIZE: 'KEY_BLOCK_SIZE';
LANGUAGE: 'LANGUAGE';
LAST: 'LAST';
LEAVES: 'LEAVES';
LESS: 'LESS';
LEVEL: 'LEVEL';
LIST: 'LIST';
LOCAL: 'LOCAL';
LOGFILE: 'LOGFILE';
LOGS: 'LOGS';
MASTER: 'MASTER';
MASTER_AUTO_POSITION: 'MASTER_AUTO_POSITION';
MASTER_CONNECT_RETRY: 'MASTER_CONNECT_RETRY';
MASTER_DELAY: 'MASTER_DELAY';
MASTER_HEARTBEAT_PERIOD: 'MASTER_HEARTBEAT_PERIOD';
MASTER_HOST: 'MASTER_HOST';
MASTER_LOG_FILE: 'MASTER_LOG_FILE';
MASTER_LOG_POS: 'MASTER_LOG_POS';
MASTER_PASSWORD: 'MASTER_PASSWORD';
MASTER_PORT: 'MASTER_PORT';
MASTER_RETRY_COUNT: 'MASTER_RETRY_COUNT';
MASTER_SSL: 'MASTER_SSL';
MASTER_SSL_CA: 'MASTER_SSL_CA';
MASTER_SSL_CAPATH: 'MASTER_SSL_CAPATH';
MASTER_SSL_CERT: 'MASTER_SSL_CERT';
MASTER_SSL_CIPHER: 'MASTER_SSL_CIPHER';
MASTER_SSL_CRL: 'MASTER_SSL_CRL';
MASTER_SSL_CRLPATH: 'MASTER_SSL_CRLPATH';
MASTER_SSL_KEY: 'MASTER_SSL_KEY';
MASTER_TLS_VERSION: 'MASTER_TLS_VERSION';
MASTER_USER: 'MASTER_USER';
MAX_CONNECTIONS_PER_HOUR: 'MAX_CONNECTIONS_PER_HOUR';
MAX_QUERIES_PER_HOUR: 'MAX_QUERIES_PER_HOUR';
MAX_ROWS: 'MAX_ROWS';
MAX_SIZE: 'MAX_SIZE';
MAX_UPDATES_PER_HOUR: 'MAX_UPDATES_PER_HOUR';
MAX_USER_CONNECTIONS: 'MAX_USER_CONNECTIONS';
MEDIUM: 'MEDIUM';
MERGE: 'MERGE';
MID: 'MID';
MIGRATE: 'MIGRATE';
MIN_ROWS: 'MIN_ROWS';
MODE: 'MODE';
MODIFY: 'MODIFY';
MUTEX: 'MUTEX';
MYSQL: 'MYSQL';
NAME: 'NAME';
NAMES: 'NAMES';
NCHAR: 'NCHAR';
NEVER: 'NEVER';
NEXT: 'NEXT';
NO: 'NO';
NODEGROUP: 'NODEGROUP';
NONE: 'NONE';
OFFLINE: 'OFFLINE';
OFFSET: 'OFFSET';
OJ: 'OJ';
OLD_PASSWORD: 'OLD_PASSWORD';
ONE: 'ONE';
ONLINE: 'ONLINE';
ONLY: 'ONLY';
OPEN: 'OPEN';
OPTIMIZER_COSTS: 'OPTIMIZER_COSTS';
OPTIONS: 'OPTIONS';
OWNER: 'OWNER';
PACK_KEYS: 'PACK_KEYS';
PAGE: 'PAGE';
PARSER: 'PARSER';
PARTIAL: 'PARTIAL';
PARTITIONING: 'PARTITIONING';
PARTITIONS: 'PARTITIONS';
PASSWORD: 'PASSWORD';
PHASE: 'PHASE';
PLUGIN: 'PLUGIN';
PLUGIN_DIR: 'PLUGIN_DIR';
PLUGINS: 'PLUGINS';
PORT: 'PORT';
PRECEDES: 'PRECEDES';
PREPARE: 'PREPARE';
PRESERVE: 'PRESERVE';
PREV: 'PREV';
PROCESSLIST: 'PROCESSLIST';
PROFILE: 'PROFILE';
PROFILES: 'PROFILES';
PROXY: 'PROXY';
QUERY: 'QUERY';
QUICK: 'QUICK';
REBUILD: 'REBUILD';
RECOVER: 'RECOVER';
REDO_BUFFER_SIZE: 'REDO_BUFFER_SIZE';
REDUNDANT: 'REDUNDANT';
RELAY: 'RELAY';
RELAY_LOG_FILE: 'RELAY_LOG_FILE';
RELAY_LOG_POS: 'RELAY_LOG_POS';
RELAYLOG: 'RELAYLOG';
REMOVE: 'REMOVE';
REORGANIZE: 'REORGANIZE';
REPAIR: 'REPAIR';
REPLICATE_DO_DB: 'REPLICATE_DO_DB';
REPLICATE_DO_TABLE: 'REPLICATE_DO_TABLE';
REPLICATE_IGNORE_DB: 'REPLICATE_IGNORE_DB';
REPLICATE_IGNORE_TABLE: 'REPLICATE_IGNORE_TABLE';
REPLICATE_REWRITE_DB: 'REPLICATE_REWRITE_DB';
REPLICATE_WILD_DO_TABLE: 'REPLICATE_WILD_DO_TABLE';
REPLICATE_WILD_IGNORE_TABLE: 'REPLICATE_WILD_IGNORE_TABLE';
REPLICATION: 'REPLICATION';
RESET: 'RESET';
RESUME: 'RESUME';
RETURNS: 'RETURNS';
ROLLBACK: 'ROLLBACK';
ROLLUP: 'ROLLUP';
ROTATE: 'ROTATE';
ROW: 'ROW';
ROWS: 'ROWS';
ROW_FORMAT: 'ROW_FORMAT';
SAVEPOINT: 'SAVEPOINT';
SCHEDULE: 'SCHEDULE';
SECURITY: 'SECURITY';
SERVER: 'SERVER';
SESSION: 'SESSION';
SHARE: 'SHARE';
SHARED: 'SHARED';
SIGNED: 'SIGNED';
SIMPLE: 'SIMPLE';
SLAVE: 'SLAVE';
SLOW: 'SLOW';
SNAPSHOT: 'SNAPSHOT';
SOCKET: 'SOCKET';
SOME: 'SOME';
SONAME: 'SONAME';
SOUNDS: 'SOUNDS';
SOURCE: 'SOURCE';
SQL_AFTER_GTIDS: 'SQL_AFTER_GTIDS';
SQL_AFTER_MTS_GAPS: 'SQL_AFTER_MTS_GAPS';
SQL_BEFORE_GTIDS: 'SQL_BEFORE_GTIDS';
SQL_BUFFER_RESULT: 'SQL_BUFFER_RESULT';
SQL_CACHE: 'SQL_CACHE';
SQL_NO_CACHE: 'SQL_NO_CACHE';
SQL_THREAD: 'SQL_THREAD';
START: 'START';
STARTS: 'STARTS';
STATS_AUTO_RECALC: 'STATS_AUTO_RECALC';
STATS_PERSISTENT: 'STATS_PERSISTENT';
STATS_SAMPLE_PAGES: 'STATS_SAMPLE_PAGES';
STATUS: 'STATUS';
STOP: 'STOP';
STORAGE: 'STORAGE';
STRING: 'STRING';
SUBJECT: 'SUBJECT';
SUBPARTITION: 'SUBPARTITION';
SUBPARTITIONS: 'SUBPARTITIONS';
SUSPEND: 'SUSPEND';
SWAPS: 'SWAPS';
SWITCHES: 'SWITCHES';
TABLESPACE: 'TABLESPACE';
TEMPORARY: 'TEMPORARY';
TEMPTABLE: 'TEMPTABLE';
THAN: 'THAN';
TRADITIONAL: 'TRADITIONAL';
TRANSACTION: 'TRANSACTION';
TRIGGERS: 'TRIGGERS';
TRUNCATE: 'TRUNCATE';
UNDEFINED: 'UNDEFINED';
UNDOFILE: 'UNDOFILE';
UNDO_BUFFER_SIZE: 'UNDO_BUFFER_SIZE';
UNINSTALL: 'UNINSTALL';
UNKNOWN: 'UNKNOWN';
UNTIL: 'UNTIL';
UPGRADE: 'UPGRADE';
USER: 'USER';
USE_FRM: 'USE_FRM';
USER_RESOURCES: 'USER_RESOURCES';
VALIDATION: 'VALIDATION';
VALUE: 'VALUE';
VARIABLES: 'VARIABLES';
VIEW: 'VIEW';
WAIT: 'WAIT';
WARNINGS: 'WARNINGS';
WITHOUT: 'WITHOUT';
WORK: 'WORK';
WRAPPER: 'WRAPPER';
X509: 'X509';
XA: 'XA';
XML: 'XML';
// Date format Keywords
EUR: 'EUR';
USA: 'USA';
JIS: 'JIS';
ISO: 'ISO';
INTERNAL: 'INTERNAL';
// Interval type Keywords
QUARTER: 'QUARTER';
MONTH: 'MONTH';
DAY: 'DAY';
HOUR: 'HOUR';
MINUTE: 'MINUTE';
WEEK: 'WEEK';
SECOND: 'SECOND';
MICROSECOND: 'MICROSECOND';
// PRIVILEGES
TABLES: 'TABLES';
ROUTINE: 'ROUTINE';
EXECUTE: 'EXECUTE';
FILE: 'FILE';
PROCESS: 'PROCESS';
RELOAD: 'RELOAD';
SHUTDOWN: 'SHUTDOWN';
SUPER: 'SUPER';
PRIVILEGES: 'PRIVILEGES';
// Charsets
ARMSCII8: 'ARMSCII8';
ASCII: 'ASCII';
BIG5: 'BIG5';
CP1250: 'CP1250';
CP1251: 'CP1251';
CP1256: 'CP1256';
CP1257: 'CP1257';
CP850: 'CP850';
CP852: 'CP852';
CP866: 'CP866';
CP932: 'CP932';
DEC8: 'DEC8';
EUCJPMS: 'EUCJPMS';
EUCKR: 'EUCKR';
GB2312: 'GB2312';
GBK: 'GBK';
GEOSTD8: 'GEOSTD8';
GREEK: 'GREEK';
HEBREW: 'HEBREW';
HP8: 'HP8';
KEYBCS2: 'KEYBCS2';
KOI8R: 'KOI8R';
KOI8U: 'KOI8U';
LATIN1: 'LATIN1';
LATIN2: 'LATIN2';
LATIN5: 'LATIN5';
LATIN7: 'LATIN7';
MACCE: 'MACCE';
MACROMAN: 'MACROMAN';
SJIS: 'SJIS';
SWE7: 'SWE7';
TIS620: 'TIS620';
UCS2: 'UCS2';
UJIS: 'UJIS';
UTF16: 'UTF16';
UTF16LE: 'UTF16LE';
UTF32: 'UTF32';
UTF8: 'UTF8';
UTF8MB3: 'UTF8MB3';
UTF8MB4: 'UTF8MB4';
// DB Engines
ARCHIVE: 'ARCHIVE';
BLACKHOLE: 'BLACKHOLE';
CSV: 'CSV';
FEDERATED: 'FEDERATED';
INNODB: 'INNODB';
MEMORY: 'MEMORY';
MRG_MYISAM: 'MRG_MYISAM';
MYISAM: 'MYISAM';
NDB: 'NDB';
NDBCLUSTER: 'NDBCLUSTER';
PERFOMANCE_SCHEMA: 'PERFOMANCE_SCHEMA';
// Transaction Levels
REPEATABLE: 'REPEATABLE';
COMMITTED: 'COMMITTED';
UNCOMMITTED: 'UNCOMMITTED';
SERIALIZABLE: 'SERIALIZABLE';
// Spatial data types
GEOMETRYCOLLECTION: 'GEOMETRYCOLLECTION';
LINESTRING: 'LINESTRING';
MULTILINESTRING: 'MULTILINESTRING';
MULTIPOINT: 'MULTIPOINT';
MULTIPOLYGON: 'MULTIPOLYGON';
POINT: 'POINT';
POLYGON: 'POLYGON';
// Common function names
ABS: 'ABS';
ACOS: 'ACOS';
ADDDATE: 'ADDDATE';
ADDTIME: 'ADDTIME';
AES_DECRYPT: 'AES_DECRYPT';
AES_ENCRYPT: 'AES_ENCRYPT';
AREA: 'AREA';
ASBINARY: 'ASBINARY';
ASIN: 'ASIN';
ASTEXT: 'ASTEXT';
ASWKB: 'ASWKB';
ASWKT: 'ASWKT';
ASYMMETRIC_DECRYPT: 'ASYMMETRIC_DECRYPT';
ASYMMETRIC_DERIVE: 'ASYMMETRIC_DERIVE';
ASYMMETRIC_ENCRYPT: 'ASYMMETRIC_ENCRYPT';
ASYMMETRIC_SIGN: 'ASYMMETRIC_SIGN';
ASYMMETRIC_VERIFY: 'ASYMMETRIC_VERIFY';
ATAN: 'ATAN';
ATAN2: 'ATAN2';
BENCHMARK: 'BENCHMARK';
BIN: 'BIN';
BIT_COUNT: 'BIT_COUNT';
BIT_LENGTH: 'BIT_LENGTH';
BUFFER: 'BUFFER';
CEIL: 'CEIL';
CEILING: 'CEILING';
CENTROID: 'CENTROID';
CHARACTER_LENGTH: 'CHARACTER_LENGTH';
CHARSET: 'CHARSET';
CHAR_LENGTH: 'CHAR_LENGTH';
COERCIBILITY: 'COERCIBILITY';
COLLATION: 'COLLATION';
COMPRESS: 'COMPRESS';
CONCAT: 'CONCAT';
CONCAT_WS: 'CONCAT_WS';
CONNECTION_ID: 'CONNECTION_ID';
CONV: 'CONV';
CONVERT_TZ: 'CONVERT_TZ';
COS: 'COS';
COT: 'COT';
CRC32: 'CRC32';
CREATE_ASYMMETRIC_PRIV_KEY: 'CREATE_ASYMMETRIC_PRIV_KEY';
CREATE_ASYMMETRIC_PUB_KEY: 'CREATE_ASYMMETRIC_PUB_KEY';
CREATE_DH_PARAMETERS: 'CREATE_DH_PARAMETERS';
CREATE_DIGEST: 'CREATE_DIGEST';
CROSSES: 'CROSSES';
DATEDIFF: 'DATEDIFF';
DATE_FORMAT: 'DATE_FORMAT';
DAYNAME: 'DAYNAME';
DAYOFMONTH: 'DAYOFMONTH';
DAYOFWEEK: 'DAYOFWEEK';
DAYOFYEAR: 'DAYOFYEAR';
DECODE: 'DECODE';
DEGREES: 'DEGREES';
DES_DECRYPT: 'DES_DECRYPT';
DES_ENCRYPT: 'DES_ENCRYPT';
DIMENSION: 'DIMENSION';
DISJOINT: 'DISJOINT';
ELT: 'ELT';
ENCODE: 'ENCODE';
ENCRYPT: 'ENCRYPT';
ENDPOINT: 'ENDPOINT';
ENVELOPE: 'ENVELOPE';
EQUALS: 'EQUALS';
EXP: 'EXP';
EXPORT_SET: 'EXPORT_SET';
EXTERIORRING: 'EXTERIORRING';
EXTRACTVALUE: 'EXTRACTVALUE';
FIELD: 'FIELD';
FIND_IN_SET: 'FIND_IN_SET';
FLOOR: 'FLOOR';
FORMAT: 'FORMAT';
FOUND_ROWS: 'FOUND_ROWS';
FROM_BASE64: 'FROM_BASE64';
FROM_DAYS: 'FROM_DAYS';
FROM_UNIXTIME: 'FROM_UNIXTIME';
GEOMCOLLFROMTEXT: 'GEOMCOLLFROMTEXT';
GEOMCOLLFROMWKB: 'GEOMCOLLFROMWKB';
GEOMETRYCOLLECTIONFROMTEXT: 'GEOMETRYCOLLECTIONFROMTEXT';
GEOMETRYCOLLECTIONFROMWKB: 'GEOMETRYCOLLECTIONFROMWKB';
GEOMETRYFROMTEXT: 'GEOMETRYFROMTEXT';
GEOMETRYFROMWKB: 'GEOMETRYFROMWKB';
GEOMETRYN: 'GEOMETRYN';
GEOMETRYTYPE: 'GEOMETRYTYPE';
GEOMFROMTEXT: 'GEOMFROMTEXT';
GEOMFROMWKB: 'GEOMFROMWKB';
GET_FORMAT: 'GET_FORMAT';
GET_LOCK: 'GET_LOCK';
GLENGTH: 'GLENGTH';
GREATEST: 'GREATEST';
GTID_SUBSET: 'GTID_SUBSET';
GTID_SUBTRACT: 'GTID_SUBTRACT';
HEX: 'HEX';
IFNULL: 'IFNULL';
INET6_ATON: 'INET6_ATON';
INET6_NTOA: 'INET6_NTOA';
INET_ATON: 'INET_ATON';
INET_NTOA: 'INET_NTOA';
INSTR: 'INSTR';
INTERIORRINGN: 'INTERIORRINGN';
INTERSECTS: 'INTERSECTS';
ISCLOSED: 'ISCLOSED';
ISEMPTY: 'ISEMPTY';
ISNULL: 'ISNULL';
ISSIMPLE: 'ISSIMPLE';
IS_FREE_LOCK: 'IS_FREE_LOCK';
IS_IPV4: 'IS_IPV4';
IS_IPV4_COMPAT: 'IS_IPV4_COMPAT';
IS_IPV4_MAPPED: 'IS_IPV4_MAPPED';
IS_IPV6: 'IS_IPV6';
IS_USED_LOCK: 'IS_USED_LOCK';
LAST_INSERT_ID: 'LAST_INSERT_ID';
LCASE: 'LCASE';
LEAST: 'LEAST';
LENGTH: 'LENGTH';
LINEFROMTEXT: 'LINEFROMTEXT';
LINEFROMWKB: 'LINEFROMWKB';
LINESTRINGFROMTEXT: 'LINESTRINGFROMTEXT';
LINESTRINGFROMWKB: 'LINESTRINGFROMWKB';
LN: 'LN';
LOAD_FILE: 'LOAD_FILE';
LOCATE: 'LOCATE';
LOG: 'LOG';
LOG10: 'LOG10';
LOG2: 'LOG2';
LOWER: 'LOWER';
LPAD: 'LPAD';
LTRIM: 'LTRIM';
MAKEDATE: 'MAKEDATE';
MAKETIME: 'MAKETIME';
MAKE_SET: 'MAKE_SET';
MASTER_POS_WAIT: 'MASTER_POS_WAIT';
MBRCONTAINS: 'MBRCONTAINS';
MBRDISJOINT: 'MBRDISJOINT';
MBREQUAL: 'MBREQUAL';
MBRINTERSECTS: 'MBRINTERSECTS';
MBROVERLAPS: 'MBROVERLAPS';
MBRTOUCHES: 'MBRTOUCHES';
MBRWITHIN: 'MBRWITHIN';
MD5: 'MD5';
MLINEFROMTEXT: 'MLINEFROMTEXT';
MLINEFROMWKB: 'MLINEFROMWKB';
MONTHNAME: 'MONTHNAME';
MPOINTFROMTEXT: 'MPOINTFROMTEXT';
MPOINTFROMWKB: 'MPOINTFROMWKB';
MPOLYFROMTEXT: 'MPOLYFROMTEXT';
MPOLYFROMWKB: 'MPOLYFROMWKB';
MULTILINESTRINGFROMTEXT: 'MULTILINESTRINGFROMTEXT';
MULTILINESTRINGFROMWKB: 'MULTILINESTRINGFROMWKB';
MULTIPOINTFROMTEXT: 'MULTIPOINTFROMTEXT';
MULTIPOINTFROMWKB: 'MULTIPOINTFROMWKB';
MULTIPOLYGONFROMTEXT: 'MULTIPOLYGONFROMTEXT';
MULTIPOLYGONFROMWKB: 'MULTIPOLYGONFROMWKB';
NAME_CONST: 'NAME_CONST';
NULLIF: 'NULLIF';
NUMGEOMETRIES: 'NUMGEOMETRIES';
NUMINTERIORRINGS: 'NUMINTERIORRINGS';
NUMPOINTS: 'NUMPOINTS';
OCT: 'OCT';
OCTET_LENGTH: 'OCTET_LENGTH';
ORD: 'ORD';
OVERLAPS: 'OVERLAPS';
PERIOD_ADD: 'PERIOD_ADD';
PERIOD_DIFF: 'PERIOD_DIFF';
PI: 'PI';
POINTFROMTEXT: 'POINTFROMTEXT';
POINTFROMWKB: 'POINTFROMWKB';
POINTN: 'POINTN';
POLYFROMTEXT: 'POLYFROMTEXT';
POLYFROMWKB: 'POLYFROMWKB';
POLYGONFROMTEXT: 'POLYGONFROMTEXT';
POLYGONFROMWKB: 'POLYGONFROMWKB';
POW: 'POW';
POWER: 'POWER';
QUOTE: 'QUOTE';
RADIANS: 'RADIANS';
RAND: 'RAND';
RANDOM_BYTES: 'RANDOM_BYTES';
RELEASE_LOCK: 'RELEASE_LOCK';
REVERSE: 'REVERSE';
ROUND: 'ROUND';
ROW_COUNT: 'ROW_COUNT';
RPAD: 'RPAD';
RTRIM: 'RTRIM';
SEC_TO_TIME: 'SEC_TO_TIME';
SESSION_USER: 'SESSION_USER';
SHA: 'SHA';
SHA1: 'SHA1';
SHA2: 'SHA2';
SIGN: 'SIGN';
SIN: 'SIN';
SLEEP: 'SLEEP';
SOUNDEX: 'SOUNDEX';
SQL_THREAD_WAIT_AFTER_GTIDS: 'SQL_THREAD_WAIT_AFTER_GTIDS';
SQRT: 'SQRT';
SRID: 'SRID';
STARTPOINT: 'STARTPOINT';
STRCMP: 'STRCMP';
STR_TO_DATE: 'STR_TO_DATE';
ST_AREA: 'ST_AREA';
ST_ASBINARY: 'ST_ASBINARY';
ST_ASTEXT: 'ST_ASTEXT';
ST_ASWKB: 'ST_ASWKB';
ST_ASWKT: 'ST_ASWKT';
ST_BUFFER: 'ST_BUFFER';
ST_CENTROID: 'ST_CENTROID';
ST_CONTAINS: 'ST_CONTAINS';
ST_CROSSES: 'ST_CROSSES';
ST_DIFFERENCE: 'ST_DIFFERENCE';
ST_DIMENSION: 'ST_DIMENSION';
ST_DISJOINT: 'ST_DISJOINT';
ST_DISTANCE: 'ST_DISTANCE';
ST_ENDPOINT: 'ST_ENDPOINT';
ST_ENVELOPE: 'ST_ENVELOPE';
ST_EQUALS: 'ST_EQUALS';
ST_EXTERIORRING: 'ST_EXTERIORRING';
ST_GEOMCOLLFROMTEXT: 'ST_GEOMCOLLFROMTEXT';
ST_GEOMCOLLFROMTXT: 'ST_GEOMCOLLFROMTXT';
ST_GEOMCOLLFROMWKB: 'ST_GEOMCOLLFROMWKB';
ST_GEOMETRYCOLLECTIONFROMTEXT: 'ST_GEOMETRYCOLLECTIONFROMTEXT';
ST_GEOMETRYCOLLECTIONFROMWKB: 'ST_GEOMETRYCOLLECTIONFROMWKB';
ST_GEOMETRYFROMTEXT: 'ST_GEOMETRYFROMTEXT';
ST_GEOMETRYFROMWKB: 'ST_GEOMETRYFROMWKB';
ST_GEOMETRYN: 'ST_GEOMETRYN';
ST_GEOMETRYTYPE: 'ST_GEOMETRYTYPE';
ST_GEOMFROMTEXT: 'ST_GEOMFROMTEXT';
ST_GEOMFROMWKB: 'ST_GEOMFROMWKB';
ST_INTERIORRINGN: 'ST_INTERIORRINGN';
ST_INTERSECTION: 'ST_INTERSECTION';
ST_INTERSECTS: 'ST_INTERSECTS';
ST_ISCLOSED: 'ST_ISCLOSED';
ST_ISEMPTY: 'ST_ISEMPTY';
ST_ISSIMPLE: 'ST_ISSIMPLE';
ST_LINEFROMTEXT: 'ST_LINEFROMTEXT';
ST_LINEFROMWKB: 'ST_LINEFROMWKB';
ST_LINESTRINGFROMTEXT: 'ST_LINESTRINGFROMTEXT';
ST_LINESTRINGFROMWKB: 'ST_LINESTRINGFROMWKB';
ST_NUMGEOMETRIES: 'ST_NUMGEOMETRIES';
ST_NUMINTERIORRING: 'ST_NUMINTERIORRING';
ST_NUMINTERIORRINGS: 'ST_NUMINTERIORRINGS';
ST_NUMPOINTS: 'ST_NUMPOINTS';
ST_OVERLAPS: 'ST_OVERLAPS';
ST_POINTFROMTEXT: 'ST_POINTFROMTEXT';
ST_POINTFROMWKB: 'ST_POINTFROMWKB';
ST_POINTN: 'ST_POINTN';
ST_POLYFROMTEXT: 'ST_POLYFROMTEXT';
ST_POLYFROMWKB: 'ST_POLYFROMWKB';
ST_POLYGONFROMTEXT: 'ST_POLYGONFROMTEXT';
ST_POLYGONFROMWKB: 'ST_POLYGONFROMWKB';
ST_SRID: 'ST_SRID';
ST_STARTPOINT: 'ST_STARTPOINT';
ST_SYMDIFFERENCE: 'ST_SYMDIFFERENCE';
ST_TOUCHES: 'ST_TOUCHES';
ST_UNION: 'ST_UNION';
ST_WITHIN: 'ST_WITHIN';
ST_X: 'ST_X';
ST_Y: 'ST_Y';
SUBDATE: 'SUBDATE';
SUBSTRING_INDEX: 'SUBSTRING_INDEX';
SUBTIME: 'SUBTIME';
SYSTEM_USER: 'SYSTEM_USER';
TAN: 'TAN';
TIMEDIFF: 'TIMEDIFF';
TIMESTAMPADD: 'TIMESTAMPADD';
TIMESTAMPDIFF: 'TIMESTAMPDIFF';
TIME_FORMAT: 'TIME_FORMAT';
TIME_TO_SEC: 'TIME_TO_SEC';
TOUCHES: 'TOUCHES';
TO_BASE64: 'TO_BASE64';
TO_DAYS: 'TO_DAYS';
TO_SECONDS: 'TO_SECONDS';
UCASE: 'UCASE';
UNCOMPRESS: 'UNCOMPRESS';
UNCOMPRESSED_LENGTH: 'UNCOMPRESSED_LENGTH';
UNHEX: 'UNHEX';
UNIX_TIMESTAMP: 'UNIX_TIMESTAMP';
UPDATEXML: 'UPDATEXML';
UPPER: 'UPPER';
UUID: 'UUID';
UUID_SHORT: 'UUID_SHORT';
VALIDATE_PASSWORD_STRENGTH: 'VALIDATE_PASSWORD_STRENGTH';
VERSION: 'VERSION';
WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS: 'WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS';
WEEKDAY: 'WEEKDAY';
WEEKOFYEAR: 'WEEKOFYEAR';
WEIGHT_STRING: 'WEIGHT_STRING';
WITHIN: 'WITHIN';
YEARWEEK: 'YEARWEEK';
Y_FUNCTION: 'Y';
X_FUNCTION: 'X';
// Operators
// Operators. Assigns
VAR_ASSIGN: ':=';
PLUS_ASSIGN: '+=';
MINUS_ASSIGN: '-=';
MULT_ASSIGN: '*=';
DIV_ASSIGN: '/=';
MOD_ASSIGN: '%=';
AND_ASSIGN: '&=';
XOR_ASSIGN: '^=';
OR_ASSIGN: '|=';
// Operators. Arithmetics
STAR: '*';
DIVIDE: '/';
MODULE: '%';
PLUS: '+';
MINUSMINUS: '--';
MINUS: '-';
DIV: 'DIV';
MOD: 'MOD';
// Operators. Comparation
EQUAL_SYMBOL: '=';
GREATER_SYMBOL: '>';
LESS_SYMBOL: '<';
EXCLAMATION_SYMBOL: '!';
// Operators. Bit
BIT_NOT_OP: '~';
BIT_OR_OP: '|';
BIT_AND_OP: '&';
BIT_XOR_OP: '^';
// Constructors symbols
DOT: '.';
LR_BRACKET: '(';
RR_BRACKET: ')';
COMMA: ',';
SEMI: ';';
AT_SIGN: '@';
ZERO_DECIMAL: '0';
ONE_DECIMAL: '1';
TWO_DECIMAL: '2';
SINGLE_QUOTE_SYMB: '\'';
DOUBLE_QUOTE_SYMB: '"';
REVERSE_QUOTE_SYMB: '`';
COLON_SYMB: ':';
// Charsets
CHARSET_REVERSE_QOUTE_STRING: '`' CHARSET_NAME '`';
// File's sizes
FILESIZE_LITERAL: DEC_DIGIT+ ('K'|'M'|'G'|'T');
// Literal Primitives
START_NATIONAL_STRING_LITERAL: 'N' SQUOTA_STRING;
STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING;
DECIMAL_LITERAL: DEC_DIGIT+;
HEXADECIMAL_LITERAL: 'X' '\'' (HEX_DIGIT HEX_DIGIT)+ '\''
| '0X' HEX_DIGIT+;
REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
| DEC_DIGIT+ '.' EXPONENT_NUM_PART
| (DEC_DIGIT+)? '.' (DEC_DIGIT+ EXPONENT_NUM_PART)
| DEC_DIGIT+ EXPONENT_NUM_PART;
NULL_SPEC_LITERAL: '\\' 'N';
BIT_STRING: BIT_STRING_L;
STRING_CHARSET_NAME: '_' CHARSET_NAME;
// Hack for dotID
// Prevent recognize string: .123somelatin AS ((.123), FLOAT_LITERAL), ((somelatin), ID)
// it must recoginze: .123somelatin AS ((.), DOT), (123somelatin, ID)
DOT_ID: '.' ID_LITERAL;
// Identifiers
ID: ID_LITERAL;
// DOUBLE_QUOTE_ID: '"' ~'"'+ '"';
REVERSE_QUOTE_ID: '`' ~'`'+ '`';
STRING_USER_NAME: (
SQUOTA_STRING | DQUOTA_STRING
| BQUOTA_STRING | ID_LITERAL
) '@'
(
SQUOTA_STRING | DQUOTA_STRING
| BQUOTA_STRING | ID_LITERAL
);
LOCAL_ID: '@'
(
[A-Z0-9._$]+
| SQUOTA_STRING
| DQUOTA_STRING
| BQUOTA_STRING
);
GLOBAL_ID: '@' '@'
(
[A-Z0-9._$]+
| BQUOTA_STRING
);
// Fragments for Literal primitives
fragment CHARSET_NAME: ARMSCII8 | ASCII | BIG5 | BINARY | CP1250
| CP1251 | CP1256 | CP1257 | CP850
| CP852 | CP866 | CP932 | DEC8 | EUCJPMS
| EUCKR | GB2312 | GBK | GEOSTD8 | GREEK
| HEBREW | HP8 | KEYBCS2 | KOI8R | KOI8U
| LATIN1 | LATIN2 | LATIN5 | LATIN7
| MACCE | MACROMAN | SJIS | SWE7 | TIS620
| UCS2 | UJIS | UTF16 | UTF16LE | UTF32
| UTF8 | UTF8MB4;
fragment EXPONENT_NUM_PART: 'E' '-'? DEC_DIGIT+;
fragment ID_LITERAL: [A-Z_$0-9]*?[A-Z_$]+?[A-Z_$0-9]*;
fragment DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"';
fragment SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\'';
fragment BQUOTA_STRING: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';
fragment HEX_DIGIT: [0-9A-F];
fragment DEC_DIGIT: [0-9];
fragment BIT_STRING_L: 'B' '\'' [01]+ '\'';
// Last tokens must generate Errors
ERROR_RECONGNIGION: . -> channel(ERRORCHANNEL);
| 52,756 | ANTLR | .g4 | 1,070 | 47.130841 | 96 | 0.347019 | slifin/honeySQL-parser | 1 | 0 | 0 | EPL-1.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | a7e1c6880b125ae0488b4cf78855eb803233b27771822f11249837f05fa9c96a | true | true | false | false |
124 | MySqlParser.g4 | slifin_honeySQL-parser/src/sql_translation/MySqlParser.g4 | /*
MySQL (Positive Technologies) grammar
The MIT License (MIT).
Copyright (c) 2015-2017, Ivan Kochurkin ([email protected]), Positive Technologies.
Copyright (c) 2017, Ivan Khudyashev ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
parser grammar MySqlParser;
options { tokenVocab=MySqlLexer; }
// Top Level Description
root
: sqlStatements? MINUSMINUS? EOF
;
sqlStatements
: (sqlStatement MINUSMINUS? SEMI | emptyStatement)*
(sqlStatement (MINUSMINUS? SEMI)? | emptyStatement)
;
sqlStatement
: ddlStatement | dmlStatement | transactionStatement
| replicationStatement | preparedStatement
| administrationStatement | utilityStatement
;
emptyStatement
: SEMI
;
ddlStatement
: createDatabase | createEvent | createIndex
| createLogfileGroup | createProcedure | createFunction
| createServer | createTable | createTablespaceInnodb
| createTablespaceNdb | createTrigger | createView
| alterDatabase | alterEvent | alterFunction
| alterInstance | alterLogfileGroup | alterProcedure
| alterServer | alterTable | alterTablespace | alterView
| dropDatabase | dropEvent | dropIndex
| dropLogfileGroup | dropProcedure | dropFunction
| dropServer | dropTable | dropTablespace
| dropTrigger | dropView
| renameTable | truncateTable
;
dmlStatement
: selectStatement | insertStatement | updateStatement
| deleteStatement | replaceStatement | callStatement
| loadDataStatement | loadXmlStatement | doStatement
| handlerStatement
;
transactionStatement
: startTransaction
| beginWork | commitWork | rollbackWork
| savepointStatement | rollbackStatement
| releaseStatement | lockTables | unlockTables
;
replicationStatement
: changeMaster | changeReplicationFilter | purgeBinaryLogs
| resetMaster | resetSlave | startSlave | stopSlave
| startGroupReplication | stopGroupReplication
| xaStartTransaction | xaEndTransaction | xaPrepareStatement
| xaCommitWork | xaRollbackWork | xaRecoverWork
;
preparedStatement
: prepareStatement | executeStatement | deallocatePrepare
;
// remark: NOT INCLUDED IN sqlStatement, but include in body
// of routine's statements
compoundStatement
: blockStatement
| caseStatement | ifStatement | leaveStatement
| loopStatement | repeatStatement | whileStatement
| iterateStatement | returnStatement | cursorStatement
;
administrationStatement
: alterUser | createUser | dropUser | grantStatement
| grantProxy | renameUser | revokeStatement
| revokeProxy | analyzeTable | checkTable
| checksumTable | optimizeTable | repairTable
| createUdfunction | installPlugin | uninstallPlugin
| setStatement | showStatement | binlogStatement
| cacheIndexStatement | flushStatement | killStatement
| loadIndexIntoCache | resetStatement
| shutdownStatement
;
utilityStatement
: simpleDescribeStatement | fullDescribeStatement
| helpStatement | useStatement
;
// Data Definition Language
// Create statements
createDatabase
: CREATE dbFormat=(DATABASE | SCHEMA)
ifNotExists? uid createDatabaseOption*
;
createEvent
: CREATE ownerStatement? EVENT ifNotExists? fullId
ON SCHEDULE scheduleExpression
(ON COMPLETION NOT? PRESERVE)? enableType?
(COMMENT STRING_LITERAL)?
DO routineBody
;
createIndex
: CREATE
intimeAction=(ONLINE | OFFLINE)?
indexCategory=(UNIQUE | FULLTEXT | SPATIAL)?
INDEX uid indexType?
ON tableName indexColumnNames
indexOption*
(
ALGORITHM '='? algType=(DEFAULT | INPLACE | COPY)
| LOCK '='?
lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE)
)?
;
createLogfileGroup
: CREATE LOGFILE GROUP uid
ADD UNDOFILE undoFile=STRING_LITERAL
(INITIAL_SIZE '='? initSize=fileSizeLiteral)?
(UNDO_BUFFER_SIZE '='? undoSize=fileSizeLiteral)?
(REDO_BUFFER_SIZE '='? redoSize=fileSizeLiteral)?
(NODEGROUP '='? uid)?
WAIT?
(COMMENT '='? comment=STRING_LITERAL)?
ENGINE '='? engineName
;
createProcedure
: CREATE ownerStatement?
PROCEDURE fullId
'(' procedureParameter? (',' procedureParameter)* ')'
routineOption*
routineBody
;
createFunction
: CREATE ownerStatement?
FUNCTION fullId
'(' functionParameter? (',' functionParameter)* ')'
RETURNS dataType
routineOption*
routineBody
;
createServer
: CREATE SERVER uid
FOREIGN DATA WRAPPER wrapperName=(MYSQL | STRING_LITERAL)
OPTIONS '(' serverOption (',' serverOption)* ')'
;
createTable
: CREATE TEMPORARY? TABLE ifNotExists?
tableName
(
LIKE tableName
| '(' LIKE parenthesisTable=tableName ')'
) #copyCreateTable
| CREATE TEMPORARY? TABLE ifNotExists?
tableName createDefinitions?
( tableOption (','? tableOption)* )?
partitionDefinitions? keyViolate=(IGNORE | REPLACE)?
AS? selectStatement #queryCreateTable
| CREATE TEMPORARY? TABLE ifNotExists?
tableName createDefinitions
( tableOption (','? tableOption)* )?
partitionDefinitions? #columnCreateTable
;
createTablespaceInnodb
: CREATE TABLESPACE uid
ADD DATAFILE datafile=STRING_LITERAL
(FILE_BLOCK_SIZE '=' fileBlockSize=fileSizeLiteral)?
(ENGINE '='? engineName)?
;
createTablespaceNdb
: CREATE TABLESPACE uid
ADD DATAFILE datafile=STRING_LITERAL
USE LOGFILE GROUP uid
(EXTENT_SIZE '='? extentSize=fileSizeLiteral)?
(INITIAL_SIZE '='? initialSize=fileSizeLiteral)?
(AUTOEXTEND_SIZE '='? autoextendSize=fileSizeLiteral)?
(MAX_SIZE '='? maxSize=fileSizeLiteral)?
(NODEGROUP '='? uid)?
WAIT?
(COMMENT '='? comment=STRING_LITERAL)?
ENGINE '='? engineName
;
createTrigger
: CREATE ownerStatement?
TRIGGER thisTrigger=fullId
triggerTime=(BEFORE | AFTER)
triggerEvent=(INSERT | UPDATE | DELETE)
ON tableName FOR EACH ROW
(triggerPlace=(FOLLOWS | PRECEDES) otherTrigger=fullId)?
routineBody
;
createView
: CREATE (OR REPLACE)?
(
ALGORITHM '=' algType=(UNDEFINED | MERGE | TEMPTABLE)
)?
ownerStatement?
(SQL SECURITY secContext=(DEFINER | INVOKER))?
VIEW fullId ('(' uidList ')')? AS selectStatement
(WITH checkOption=(CASCADED | LOCAL)? CHECK OPTION)?
;
// details
createDatabaseOption
: DEFAULT? (CHARACTER SET | CHARSET) '='? charsetName
| DEFAULT? COLLATE '='? collationName
;
ownerStatement
: DEFINER '=' (userName | CURRENT_USER ( '(' ')')?)
;
scheduleExpression
: AT timestampValue intervalExpr* #preciseSchedule
| EVERY (decimalLiteral | expression) intervalType
(
STARTS start=timestampValue
(startIntervals+=intervalExpr)*
)?
(
ENDS end=timestampValue
(endIntervals+=intervalExpr)*
)? #intervalSchedule
;
timestampValue
: CURRENT_TIMESTAMP
| stringLiteral
| decimalLiteral
| expression
;
intervalExpr
: '+' INTERVAL (decimalLiteral | expression) intervalType
;
intervalType
: intervalTypeBase
| YEAR | YEAR_MONTH | DAY_HOUR | DAY_MINUTE
| DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND
| SECOND_MICROSECOND | MINUTE_MICROSECOND
| HOUR_MICROSECOND | DAY_MICROSECOND
;
enableType
: ENABLE | DISABLE | DISABLE ON SLAVE
;
indexType
: USING (BTREE | HASH)
;
indexOption
: KEY_BLOCK_SIZE '='? fileSizeLiteral
| indexType
| WITH PARSER uid
| COMMENT STRING_LITERAL
;
procedureParameter
: direction=(IN | OUT | INOUT) uid dataType
;
functionParameter
: uid dataType
;
routineOption
: COMMENT STRING_LITERAL #routineComment
| LANGUAGE SQL #routineLanguage
| NOT? DETERMINISTIC #routineBehavior
| (
CONTAINS SQL | NO SQL | READS SQL DATA
| MODIFIES SQL DATA
) #routineData
| SQL SECURITY context=(DEFINER | INVOKER) #routineSecurity
;
serverOption
: HOST STRING_LITERAL
| DATABASE STRING_LITERAL
| USER STRING_LITERAL
| PASSWORD STRING_LITERAL
| SOCKET STRING_LITERAL
| OWNER STRING_LITERAL
| PORT decimalLiteral
;
createDefinitions
: '(' createDefinition (',' createDefinition)* ')'
;
createDefinition
: uid columnDefinition #columnDeclaration
| tableConstraint #constraintDeclaration
| indexColumnDefinition #indexDeclaration
;
columnDefinition
: dataType columnConstraint*
;
columnConstraint
: nullNotnull #nullColumnConstraint
| DEFAULT defaultValue #defaultColumnConstraint
| AUTO_INCREMENT #autoIncrementColumnConstraint
| PRIMARY? KEY #primaryKeyColumnConstraint
| UNIQUE KEY? #uniqueKeyColumnConstraint
| COMMENT STRING_LITERAL #commentColumnConstraint
| COLUMN_FORMAT colformat=(FIXED | DYNAMIC | DEFAULT) #formatColumnConstraint
| STORAGE storageval=(DISK | MEMORY | DEFAULT) #storageColumnConstraint
| referenceDefinition #referenceColumnConstraint
;
tableConstraint
: (CONSTRAINT name=uid?)?
PRIMARY KEY indexType? indexColumnNames indexOption* #primaryKeyTableConstraint
| (CONSTRAINT name=uid?)?
UNIQUE indexFormat=(INDEX | KEY)? index=uid?
indexType? indexColumnNames indexOption* #uniqueKeyTableConstraint
| (CONSTRAINT name=uid?)?
FOREIGN KEY index=uid? indexColumnNames
referenceDefinition #foreignKeyTableConstraint
| CHECK '(' expression ')' #checkTableConstraint
;
referenceDefinition
: REFERENCES tableName indexColumnNames
(MATCH matchType=(FULL | PARTIAL | SIMPLE))?
referenceAction?
;
referenceAction
: ON DELETE onDelete=referenceControlType
(
ON UPDATE onUpdate=referenceControlType
)?
| ON UPDATE onUpdate=referenceControlType
(
ON DELETE onDelete=referenceControlType
)?
;
referenceControlType
: RESTRICT | CASCADE | SET NULL_LITERAL | NO ACTION
;
indexColumnDefinition
: indexFormat=(INDEX | KEY) uid? indexType?
indexColumnNames indexOption* #simpleIndexDeclaration
| (FULLTEXT | SPATIAL)
indexFormat=(INDEX | KEY)? uid?
indexColumnNames indexOption* #specialIndexDeclaration
;
tableOption
: ENGINE '='? engineName #tableOptionEngine
| AUTO_INCREMENT '='? decimalLiteral #tableOptionAutoIncrement
| AVG_ROW_LENGTH '='? decimalLiteral #tableOptionAverage
| DEFAULT? (CHARACTER SET | CHARSET) '='? charsetName #tableOptionCharset
| CHECKSUM '='? boolValue=('0' | '1') #tableOptionChecksum
| DEFAULT? COLLATE '='? collationName #tableOptionCollate
| COMMENT '='? STRING_LITERAL #tableOptionComment
| COMPRESSION '='? STRING_LITERAL #tableOptionCompression
| CONNECTION '='? STRING_LITERAL #tableOptionConnection
| DATA DIRECTORY '='? STRING_LITERAL #tableOptionDataDirectory
| DELAY_KEY_WRITE '='? boolValue=('0' | '1') #tableOptionDelay
| ENCRYPTION '='? STRING_LITERAL #tableOptionEncryption
| INDEX DIRECTORY '='? STRING_LITERAL #tableOptionIndexDirectory
| INSERT_METHOD '='? insertMethod=(NO | FIRST | LAST) #tableOptionInsertMethod
| KEY_BLOCK_SIZE '='? fileSizeLiteral #tableOptionKeyBlockSize
| MAX_ROWS '='? decimalLiteral #tableOptionMaxRows
| MIN_ROWS '='? decimalLiteral #tableOptionMinRows
| PACK_KEYS '='? extBoolValue=('0' | '1' | DEFAULT) #tableOptionPackKeys
| PASSWORD '='? STRING_LITERAL #tableOptionPassword
| ROW_FORMAT '='?
rowFormat=(
DEFAULT | DYNAMIC | FIXED | COMPRESSED
| REDUNDANT | COMPACT
) #tableOptionRowFormat
| STATS_AUTO_RECALC '='? extBoolValue=(DEFAULT | '0' | '1') #tableOptionRecalculation
| STATS_PERSISTENT '='? extBoolValue=(DEFAULT | '0' | '1') #tableOptionPersistent
| STATS_SAMPLE_PAGES '='? decimalLiteral #tableOptionSamplePage
| TABLESPACE uid tablespaceStorage? #tableOptionTablespace
| UNION '='? '(' tables ')' #tableOptionUnion
;
tablespaceStorage
: STORAGE (DISK | MEMORY | DEFAULT)
;
partitionDefinitions
: PARTITION BY partitionFunctionDefinition
(PARTITIONS count=decimalLiteral)?
(
SUBPARTITION BY subpartitionFunctionDefinition
(SUBPARTITIONS subCount=decimalLiteral)?
)?
('(' partitionDefinition (',' partitionDefinition)* ')')?
;
partitionFunctionDefinition
: LINEAR? HASH '(' expression ')' #partitionFunctionHash
| LINEAR? KEY (ALGORITHM '=' algType=('1' | '2'))?
'(' uidList ')' #partitionFunctionKey
| RANGE ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionRange
| LIST ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionList
;
subpartitionFunctionDefinition
: LINEAR? HASH '(' expression ')' #subPartitionFunctionHash
| LINEAR? KEY (ALGORITHM '=' algType=('1' | '2'))?
'(' uidList ')' #subPartitionFunctionKey
;
partitionDefinition
: PARTITION uid VALUES LESS THAN
'('
partitionDefinerAtom (',' partitionDefinerAtom)*
')'
partitionOption*
(subpartitionDefinition (',' subpartitionDefinition)*)? #partitionComparision
| PARTITION uid VALUES IN
'('
partitionDefinerAtom (',' partitionDefinerAtom)*
')'
partitionOption*
(subpartitionDefinition (',' subpartitionDefinition)*)? #partitionListAtom
| PARTITION uid VALUES IN
'('
partitionDefinerVector (',' partitionDefinerVector)*
')'
partitionOption*
(subpartitionDefinition (',' subpartitionDefinition)*)? #partitionListVector
| PARTITION uid partitionOption*
(subpartitionDefinition (',' subpartitionDefinition)*)? #partitionSimple
;
partitionDefinerAtom
: constant | MAXVALUE | expression
;
partitionDefinerVector
: '(' partitionDefinerAtom (',' partitionDefinerAtom)+ ')'
;
subpartitionDefinition
: SUBPARTITION uid partitionOption*
;
partitionOption
: STORAGE? ENGINE '='? engineName #partitionOptionEngine
| COMMENT '='? comment=STRING_LITERAL #partitionOptionComment
| DATA DIRECTORY '='? dataDirectory=STRING_LITERAL #partitionOptionDataDirectory
| INDEX DIRECTORY '='? indexDirectory=STRING_LITERAL #partitionOptionIndexDirectory
| MAX_ROWS '='? maxRows=decimalLiteral #partitionOptionMaxRows
| MIN_ROWS '='? minRows=decimalLiteral #partitionOptionMinRows
| TABLESPACE '='? tablespace=uid #partitionOptionTablespace
| NODEGROUP '='? nodegroup=uid #partitionOptionNodeGroup
;
// Alter statements
alterDatabase
: ALTER dbFormat=(DATABASE | SCHEMA) uid?
createDatabaseOption+ #alterSimpleDatabase
| ALTER dbFormat=(DATABASE | SCHEMA) uid
UPGRADE DATA DIRECTORY NAME #alterUpgradeName
;
alterEvent
: ALTER ownerStatement?
EVENT fullId
(ON SCHEDULE scheduleExpression)?
(ON COMPLETION NOT? PRESERVE)?
(RENAME TO fullId)? enableType?
(COMMENT STRING_LITERAL)?
(DO routineBody)?
;
alterFunction
: ALTER FUNCTION fullId routineOption*
;
alterInstance
: ALTER INSTANCE ROTATE INNODB MASTER KEY
;
alterLogfileGroup
: ALTER LOGFILE GROUP uid
ADD UNDOFILE STRING_LITERAL
(INITIAL_SIZE '='? fileSizeLiteral)?
WAIT? ENGINE '='? engineName
;
alterProcedure
: ALTER PROCEDURE fullId routineOption*
;
alterServer
: ALTER SERVER uid OPTIONS
'(' serverOption (',' serverOption)* ')'
;
alterTable
: ALTER intimeAction=(ONLINE | OFFLINE)?
IGNORE? TABLE tableName
alterSpecification (',' alterSpecification)*
partitionDefinitions?
;
alterTablespace
: ALTER TABLESPACE uid
objectAction=(ADD | DROP) DATAFILE STRING_LITERAL
(INITIAL_SIZE '=' fileSizeLiteral)?
WAIT?
ENGINE '='? engineName
;
alterView
: ALTER
(
ALGORITHM '=' algType=(UNDEFINED | MERGE | TEMPTABLE)
)?
ownerStatement?
(SQL SECURITY secContext=(DEFINER | INVOKER))?
VIEW fullId ('(' uidList ')')? AS selectStatement
(WITH checkOpt=(CASCADED | LOCAL)? CHECK OPTION)?
;
// details
alterSpecification
: tableOption #alterByTableOption
| ADD COLUMN? uid columnDefinition (FIRST | AFTER uid)? #alterByAddColumn
| ADD COLUMN?
'('
uid columnDefinition ( ',' uid columnDefinition)*
')' #alterByAddColumns
| ADD indexFormat=(INDEX | KEY) uid? indexType?
indexColumnNames indexOption* #alterByAddIndex
| ADD (CONSTRAINT name=uid?)? PRIMARY KEY
indexType? indexColumnNames indexOption* #alterByAddPrimaryKey
| ADD (CONSTRAINT name=uid?)? UNIQUE
indexFormat=(INDEX | KEY)? indexName=uid?
indexType? indexColumnNames indexOption* #alterByAddUniqueKey
| ADD keyType=(FULLTEXT | SPATIAL)
indexFormat=(INDEX | KEY)? uid?
indexColumnNames indexOption* #alterByAddSpecialIndex
| ADD (CONSTRAINT name=uid?)? FOREIGN KEY
indexName=uid? indexColumnNames referenceDefinition #alterByAddForeignKey
| ALGORITHM '='? algType=(DEFAULT | INPLACE | COPY) #alterBySetAlgorithm
| ALTER COLUMN? uid
(SET DEFAULT defaultValue | DROP DEFAULT) #alterByChangeDefault
| CHANGE COLUMN? oldColumn=uid
newColumn=uid columnDefinition
(FIRST | AFTER afterColumn=uid)? #alterByChangeColumn
| LOCK '='? lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE) #alterByLock
| MODIFY COLUMN?
uid columnDefinition (FIRST | AFTER uid)? #alterByModifyColumn
| DROP COLUMN? uid #alterByDropColumn
| DROP PRIMARY KEY #alterByDropPrimaryKey
| DROP indexFormat=(INDEX | KEY) uid #alterByDropIndex
| DROP FOREIGN KEY uid #alterByDropForeignKey
| DISABLE KEYS #alterByDisableKeys
| ENABLE KEYS #alterByEnableKeys
| RENAME renameFormat=(TO | AS)? uid #alterByRename
| ORDER BY uidList #alterByOrder
| CONVERT TO CHARACTER SET charsetName
(COLLATE collationName)? #alterByConvertCharset
| DEFAULT? CHARACTER SET '=' charsetName
(COLLATE '=' collationName)? #alterByDefaultCharset
| DISCARD TABLESPACE #alterByDiscardTablespace
| IMPORT TABLESPACE #alterByImportTablespace
| FORCE #alterByForce
| validationFormat=(WITHOUT | WITH) VALIDATION #alterByValidate
| ADD PARTITION partitionDefinition #alterByAddPartition
| DROP PARTITION uidList #alterByDropPartition
| DISCARD PARTITION (uidList | ALL) TABLESPACE #alterByDiscardPartition
| IMPORT PARTITION (uidList | ALL) TABLESPACE #alterByImportPartition
| TRUNCATE PARTITION (uidList | ALL) #alterByTruncatePartition
| COALESCE PARTITION decimalLiteral #alterByCoalescePartition
| REORGANIZE PARTITION uidList
INTO '('
partitionDefinition (',' partitionDefinition)*
')' #alterByReorganizePartition
| EXCHANGE PARTITION uid WITH TABLE tableName
(validationFormat=(WITH | WITHOUT) VALIDATION)? #alterByExchangePartition
| ANALYZE PARTITION (uidList | ALL) #alterByAnalyzePartitiion
| CHECK PARTITION (uidList | ALL) #alterByCheckPartition
| OPTIMIZE PARTITION (uidList | ALL) #alterByOptimizePartition
| REBUILD PARTITION (uidList | ALL) #alterByRebuildPartition
| REPAIR PARTITION (uidList | ALL) #alterByRepairPartition
| REMOVE PARTITIONING #alterByRemovePartitioning
| UPGRADE PARTITIONING #alterByUpgradePartitioning
;
// Drop statements
dropDatabase
: DROP dbFormat=(DATABASE | SCHEMA) ifExists? uid
;
dropEvent
: DROP EVENT ifExists? fullId
;
dropIndex
: DROP INDEX intimeAction=(ONLINE | OFFLINE)?
uid ON tableName
(
ALGORITHM '='? algType=(DEFAULT | INPLACE | COPY)
)?
(
LOCK '='? lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE)
)?
;
dropLogfileGroup
: DROP LOGFILE GROUP uid ENGINE '=' engineName
;
dropProcedure
: DROP PROCEDURE ifExists? fullId
;
dropFunction
: DROP FUNCTION ifExists? fullId
;
dropServer
: DROP SERVER ifExists? uid
;
dropTable
: DROP TEMPORARY? TABLE ifExists?
tables dropType=(RESTRICT | CASCADE)?
;
dropTablespace
: DROP TABLESPACE uid (ENGINE '='? engineName)?
;
dropTrigger
: DROP TRIGGER ifExists? fullId
;
dropView
: DROP VIEW ifExists?
fullId (',' fullId)* dropType=(RESTRICT | CASCADE)?
;
// Other DDL statements
renameTable
: RENAME TABLE
renameTableClause (',' renameTableClause)*
;
renameTableClause
: tableName TO tableName
;
truncateTable
: TRUNCATE TABLE? tableName
;
// Data Manipulation Language
// Primary DML Statements
callStatement
: CALL fullId
(
'(' (constants | expressions)? ')'
)?
;
deleteStatement
: singleDeleteStatement | multipleDeleteStatement
;
doStatement
: DO expressions
;
handlerStatement
: handlerOpenStatement
| handlerReadIndexStatement
| handlerReadStatement
| handlerCloseStatement
;
insertStatement
: INSERT
priority=(LOW_PRIORITY | DELAYED | HIGH_PRIORITY)?
IGNORE? INTO? tableName
(PARTITION '(' partitions=uidList ')' )?
(
('(' columns=uidList ')')? insertStatementValue
| SET
setFirst=updatedElement
(',' setElements+=updatedElement)*
)
(
ON DUPLICATE KEY UPDATE
duplicatedFirst=updatedElement
(',' duplicatedElements+=updatedElement)*
)?
;
loadDataStatement
: LOAD DATA
priority=(LOW_PRIORITY | CONCURRENT)?
LOCAL? INFILE filename=STRING_LITERAL
violation=(REPLACE | IGNORE)?
INTO TABLE tableName
(PARTITION '(' uidList ')' )?
(CHARACTER SET charset=charsetName)?
(
fieldsFormat=(FIELDS | COLUMNS)
selectFieldsInto+
)?
(
LINES
selectLinesInto+
)?
(
IGNORE decimalLiteral linesFormat=(LINES | ROWS)
)?
( '(' assignmentField (',' assignmentField)* ')' )?
(SET updatedElement (',' updatedElement)*)?
;
loadXmlStatement
: LOAD XML
priority=(LOW_PRIORITY | CONCURRENT)?
LOCAL? INFILE filename=STRING_LITERAL
violation=(REPLACE | IGNORE)?
INTO TABLE tableName
(CHARACTER SET charset=charsetName)?
(ROWS IDENTIFIED BY '<' tag=STRING_LITERAL '>')?
( IGNORE decimalLiteral linesFormat=(LINES | ROWS) )?
( '(' assignmentField (',' assignmentField)* ')' )?
(SET updatedElement (',' updatedElement)*)?
;
replaceStatement
: REPLACE priority=(LOW_PRIORITY | DELAYED)?
INTO? tableName
(PARTITION '(' partitions=uidList ')' )?
(
('(' columns=uidList ')')? insertStatementValue
| SET
setFirst=updatedElement
(',' setElements+=updatedElement)*
)
;
selectStatement
: querySpecification lockClause? #simpleSelect
| queryExpression lockClause? #parenthesisSelect
| querySpecificationNointo unionStatement+
(
UNION unionType=(ALL | DISTINCT)?
(querySpecification | queryExpression)
)?
orderByClause? limitClause? lockClause? #unionSelect
| queryExpressionNointo unionParenthesis+
(
UNION unionType=(ALL | DISTINCT)?
queryExpression
)?
orderByClause? limitClause? lockClause? #unionParenthesisSelect
;
updateStatement
: singleUpdateStatement | multipleUpdateStatement
;
// details
insertStatementValue
: selectStatement
| insertFormat=(VALUES | VALUE)
'(' expressionsWithDefaults ')'
(',' '(' expressionsWithDefaults ')')*
;
updatedElement
: fullColumnName '=' (expression | DEFAULT)
;
assignmentField
: uid | LOCAL_ID
;
lockClause
: FOR UPDATE | LOCK IN SHARE MODE
;
// Detailed DML Statements
singleDeleteStatement
: DELETE priority=LOW_PRIORITY? QUICK? IGNORE?
FROM tableName
(PARTITION '(' uidList ')' )?
(WHERE expression)?
orderByClause? (LIMIT decimalLiteral)?
;
multipleDeleteStatement
: DELETE priority=LOW_PRIORITY? QUICK? IGNORE?
(
tableName ('.' '*')? ( ',' tableName ('.' '*')? )*
FROM tableSources
| FROM
tableName ('.' '*')? ( ',' tableName ('.' '*')? )*
USING tableSources
)
(WHERE expression)?
;
handlerOpenStatement
: HANDLER tableName OPEN (AS? uid)?
;
handlerReadIndexStatement
: HANDLER tableName READ index=uid
(
comparisonOperator '(' constants ')'
| moveOrder=(FIRST | NEXT | PREV | LAST)
)
(WHERE expression)? (LIMIT decimalLiteral)?
;
handlerReadStatement
: HANDLER tableName READ moveOrder=(FIRST | NEXT)
(WHERE expression)? (LIMIT decimalLiteral)?
;
handlerCloseStatement
: HANDLER tableName CLOSE
;
singleUpdateStatement
: UPDATE priority=LOW_PRIORITY? IGNORE? tableName (AS? uid)?
SET updatedElement (',' updatedElement)*
(WHERE expression)? orderByClause? limitClause?
;
multipleUpdateStatement
: UPDATE priority=LOW_PRIORITY? IGNORE? tableSources
SET updatedElement (',' updatedElement)*
(WHERE expression)?
;
// details
orderByClause
: ORDER BY orderByExpression (',' orderByExpression)*
;
orderByExpression
: expression order=(ASC | DESC)?
;
tableSources
: tableSource (',' tableSource)*
;
tableSource
: tableSourceItem joinPart* #tableSourceBase
| '(' tableSourceItem joinPart* ')' #tableSourceNested
;
tableSourceItem
: tableName
(PARTITION '(' uidList ')' )? (AS? alias=uid)?
(indexHint (',' indexHint)* )? #atomTableItem
| (
selectStatement
| '(' parenthesisSubquery=selectStatement ')'
)
AS? alias=uid #subqueryTableItem
| '(' tableSources ')' #tableSourcesItem
;
indexHint
: indexHintAction=(USE | IGNORE | FORCE)
keyFormat=(INDEX|KEY) ( FOR indexHintType)?
'(' uidList ')'
;
indexHintType
: JOIN | ORDER BY | GROUP BY
;
joinPart
: (INNER | CROSS)? JOIN tableSourceItem
(
ON expression
| USING '(' uidList ')'
)? #innerJoin
| STRAIGHT_JOIN tableSourceItem (ON expression)? #straightJoin
| (LEFT | RIGHT) OUTER? JOIN tableSourceItem
(
ON expression
| USING '(' uidList ')'
) #outerJoin
| NATURAL ((LEFT | RIGHT) OUTER?)? JOIN tableSourceItem #naturalJoin
;
// Select Statement's Details
queryExpression
: '(' querySpecification ')'
| '(' queryExpression ')'
;
queryExpressionNointo
: '(' querySpecificationNointo ')'
| '(' queryExpressionNointo ')'
;
querySpecification
: SELECT selectSpec* selectElements selectIntoExpression?
fromClause? orderByClause? limitClause?
| SELECT selectSpec* selectElements
fromClause? orderByClause? limitClause? selectIntoExpression?
;
querySpecificationNointo
: SELECT selectSpec* selectElements
fromClause? orderByClause? limitClause?
;
unionParenthesis
: UNION unionType=(ALL | DISTINCT)? queryExpressionNointo
;
unionStatement
: UNION unionType=(ALL | DISTINCT)?
(querySpecificationNointo | queryExpressionNointo)
;
// details
selectSpec
: (ALL | DISTINCT | DISTINCTROW)
| HIGH_PRIORITY | STRAIGHT_JOIN | SQL_SMALL_RESULT
| SQL_BIG_RESULT | SQL_BUFFER_RESULT
| (SQL_CACHE | SQL_NO_CACHE)
| SQL_CALC_FOUND_ROWS
;
selectElements
: (star='*' | selectElement ) (',' selectElement)*
;
selectElement
: fullId '.' '*' #selectStarElement
| fullColumnName (AS? uid)? #selectColumnElement
| functionCall (AS? uid)? #selectFunctionElement
| (LOCAL_ID VAR_ASSIGN)? expression (AS? uid)? #selectExpressionElement
;
selectIntoExpression
: INTO assignmentField (',' assignmentField )* #selectIntoVariables
| INTO DUMPFILE STRING_LITERAL #selectIntoDumpFile
| (
INTO OUTFILE filename=STRING_LITERAL
(CHARACTER SET charset=charsetName)?
(
fieldsFormat=(FIELDS | COLUMNS)
selectFieldsInto+
)?
(
LINES selectLinesInto+
)?
) #selectIntoTextFile
;
selectFieldsInto
: TERMINATED BY terminationField=STRING_LITERAL
| OPTIONALLY? ENCLOSED BY enclosion=STRING_LITERAL
| ESCAPED BY escaping=STRING_LITERAL
;
selectLinesInto
: STARTING BY starting=STRING_LITERAL
| TERMINATED BY terminationLine=STRING_LITERAL
;
fromClause
: FROM tableSources
(WHERE whereExpr=expression)?
(
GROUP BY
groupByItem (',' groupByItem)*
(WITH ROLLUP)?
)?
(HAVING havingExpr=expression)?
;
groupByItem
: expression order=(ASC | DESC)?
;
limitClause
: LIMIT
(
(offset=decimalLiteral ',')? limit=decimalLiteral
| limit=decimalLiteral OFFSET offset=decimalLiteral
)
;
// Transaction's Statements
startTransaction
: START TRANSACTION (transactionMode (',' transactionMode)* )?
;
beginWork
: BEGIN WORK?
;
commitWork
: COMMIT WORK?
(AND nochain=NO? CHAIN)?
(norelease=NO? RELEASE)?
;
rollbackWork
: ROLLBACK WORK?
(AND nochain=NO? CHAIN)?
(norelease=NO? RELEASE)?
;
savepointStatement
: SAVEPOINT uid
;
rollbackStatement
: ROLLBACK WORK? TO SAVEPOINT? uid
;
releaseStatement
: RELEASE SAVEPOINT uid
;
lockTables
: LOCK TABLES lockTableElement (',' lockTableElement)*
;
unlockTables
: UNLOCK TABLES
;
// details
setAutocommitStatement
: SET AUTOCOMMIT '=' autocommitValue=('0' | '1')
;
setTransactionStatement
: SET transactionContext=(GLOBAL | SESSION)? TRANSACTION
transactionOption (',' transactionOption)*
;
transactionMode
: WITH CONSISTENT SNAPSHOT
| READ WRITE
| READ ONLY
;
lockTableElement
: tableName (AS? uid)? lockAction
;
lockAction
: READ LOCAL? | LOW_PRIORITY? WRITE
;
transactionOption
: ISOLATION LEVEL transactionLevel
| READ WRITE
| READ ONLY
;
transactionLevel
: REPEATABLE READ
| READ COMMITTED
| READ UNCOMMITTED
| SERIALIZABLE
;
// Replication's Statements
// Base Replication
changeMaster
: CHANGE MASTER TO
masterOption (',' masterOption)* channelOption?
;
changeReplicationFilter
: CHANGE REPLICATION FILTER
replicationFilter (',' replicationFilter)*
;
purgeBinaryLogs
: PURGE purgeFormat=(BINARY | MASTER) LOGS
(
TO fileName=STRING_LITERAL
| BEFORE timeValue=STRING_LITERAL
)
;
resetMaster
: RESET MASTER
;
resetSlave
: RESET SLAVE ALL? channelOption?
;
startSlave
: START SLAVE (threadType (',' threadType)*)?
(UNTIL untilOption)?
connectionOption* channelOption?
;
stopSlave
: STOP SLAVE (threadType (',' threadType)*)?
;
startGroupReplication
: START GROUP_REPLICATION
;
stopGroupReplication
: STOP GROUP_REPLICATION
;
// details
masterOption
: stringMasterOption '=' STRING_LITERAL #masterStringOption
| decimalMasterOption '=' decimalLiteral #masterDecimalOption
| boolMasterOption '=' boolVal=('0' | '1') #masterBoolOption
| MASTER_HEARTBEAT_PERIOD '=' REAL_LITERAL #masterRealOption
| IGNORE_SERVER_IDS '=' '(' (uid (',' uid)*)? ')' #masterUidListOption
;
stringMasterOption
: MASTER_BIND | MASTER_HOST | MASTER_USER | MASTER_PASSWORD
| MASTER_LOG_FILE | RELAY_LOG_FILE | MASTER_SSL_CA
| MASTER_SSL_CAPATH | MASTER_SSL_CERT | MASTER_SSL_CRL
| MASTER_SSL_CRLPATH | MASTER_SSL_KEY | MASTER_SSL_CIPHER
| MASTER_TLS_VERSION
;
decimalMasterOption
: MASTER_PORT | MASTER_CONNECT_RETRY | MASTER_RETRY_COUNT
| MASTER_DELAY | MASTER_LOG_POS | RELAY_LOG_POS
;
boolMasterOption
: MASTER_AUTO_POSITION | MASTER_SSL
| MASTER_SSL_VERIFY_SERVER_CERT
;
channelOption
: FOR CHANNEL STRING_LITERAL
;
replicationFilter
: REPLICATE_DO_DB '=' '(' uidList ')' #doDbReplication
| REPLICATE_IGNORE_DB '=' '(' uidList ')' #ignoreDbReplication
| REPLICATE_DO_TABLE '=' '(' tables ')' #doTableReplication
| REPLICATE_IGNORE_TABLE '=' '(' tables ')' #ignoreTableReplication
| REPLICATE_WILD_DO_TABLE '=' '(' simpleStrings ')' #wildDoTableReplication
| REPLICATE_WILD_IGNORE_TABLE
'=' '(' simpleStrings ')' #wildIgnoreTableReplication
| REPLICATE_REWRITE_DB '='
'(' tablePair (',' tablePair)* ')' #rewriteDbReplication
;
tablePair
: '(' firstTable=tableName ',' secondTable=tableName ')'
;
threadType
: IO_THREAD | SQL_THREAD
;
untilOption
: gtids=(SQL_BEFORE_GTIDS | SQL_AFTER_GTIDS)
'=' gtuidSet #gtidsUntilOption
| MASTER_LOG_FILE '=' STRING_LITERAL
',' MASTER_LOG_POS '=' decimalLiteral #masterLogUntilOption
| RELAY_LOG_FILE '=' STRING_LITERAL
',' RELAY_LOG_POS '=' decimalLiteral #relayLogUntilOption
| SQL_AFTER_MTS_GAPS #sqlGapsUntilOption
;
connectionOption
: USER '=' conOptUser=STRING_LITERAL #userConnectionOption
| PASSWORD '=' conOptPassword=STRING_LITERAL #passwordConnectionOption
| DEFAULT_AUTH '=' conOptDefAuth=STRING_LITERAL #defaultAuthConnectionOption
| PLUGIN_DIR '=' conOptPluginDir=STRING_LITERAL #pluginDirConnectionOption
;
gtuidSet
: uuidSet (',' uuidSet)*
| STRING_LITERAL
;
// XA Transactions
xaStartTransaction
: XA xaStart=(START | BEGIN) xid xaAction=(JOIN | RESUME)?
;
xaEndTransaction
: XA END xid (SUSPEND (FOR MIGRATE)?)?
;
xaPrepareStatement
: XA PREPARE xid
;
xaCommitWork
: XA COMMIT xid (ONE PHASE)?
;
xaRollbackWork
: XA ROLLBACK xid
;
xaRecoverWork
: XA RECOVER (CONVERT xid)?
;
// Prepared Statements
prepareStatement
: PREPARE uid FROM
(query=STRING_LITERAL | variable=LOCAL_ID)
;
executeStatement
: EXECUTE uid (USING userVariables)?
;
deallocatePrepare
: dropFormat=(DEALLOCATE | DROP) PREPARE uid
;
// Compound Statements
routineBody
: blockStatement | sqlStatement
;
// details
blockStatement
: (uid ':')? BEGIN
(
(declareVariable SEMI)*
(declareCondition SEMI)*
(declareCursor SEMI)*
(declareHandler SEMI)*
procedureSqlStatement+
)?
END uid?
;
caseStatement
: CASE (uid | expression)? caseAlternative+
(ELSE procedureSqlStatement+)?
END CASE
;
ifStatement
: IF expression
THEN thenStatements+=procedureSqlStatement+
elifAlternative*
(ELSE elseStatements+=procedureSqlStatement+ )?
END IF
;
iterateStatement
: ITERATE uid
;
leaveStatement
: LEAVE uid
;
loopStatement
: (uid ':')?
LOOP procedureSqlStatement+
END LOOP uid?
;
repeatStatement
: (uid ':')?
REPEAT procedureSqlStatement+
UNTIL expression
END REPEAT uid?
;
returnStatement
: RETURN expression
;
whileStatement
: (uid ':')?
WHILE expression
DO procedureSqlStatement+
END WHILE uid?
;
cursorStatement
: CLOSE uid #CloseCursor
| FETCH (NEXT? FROM)? uid INTO uidList #FetchCursor
| OPEN uid #OpenCursor
;
// details
declareVariable
: DECLARE uidList dataType (DEFAULT defaultValue)?
;
declareCondition
: DECLARE uid CONDITION FOR
( decimalLiteral | SQLSTATE VALUE? STRING_LITERAL)
;
declareCursor
: DECLARE uid CURSOR FOR selectStatement
;
declareHandler
: DECLARE handlerAction=(CONTINUE | EXIT | UNDO)
HANDLER FOR
handlerConditionValue (',' handlerConditionValue)*
routineBody
;
handlerConditionValue
: decimalLiteral #handlerConditionCode
| SQLSTATE VALUE? STRING_LITERAL #handlerConditionState
| uid #handlerConditionName
| SQLWARNING #handlerConditionWarning
| NOT FOUND #handlerConditionNotfound
| SQLEXCEPTION #handlerConditionException
;
procedureSqlStatement
: (compoundStatement | sqlStatement) SEMI
;
caseAlternative
: WHEN (constant | expression)
THEN procedureSqlStatement+
;
elifAlternative
: ELSEIF expression
THEN procedureSqlStatement+
;
// Administration Statements
// Account management statements
alterUser
: ALTER USER
userSpecification (',' userSpecification)* #alterUserMysqlV56
| ALTER USER ifExists?
userAuthOption (',' userAuthOption)*
(
REQUIRE
(tlsNone=NONE | tlsOption (AND? tlsOption)* )
)?
(WITH userResourceOption+)?
(userPasswordOption | userLockOption)* #alterUserMysqlV57
;
createUser
: CREATE USER userAuthOption (',' userAuthOption)* #createUserMysqlV56
| CREATE USER ifNotExists?
userAuthOption (',' userAuthOption)*
(
REQUIRE
(tlsNone=NONE | tlsOption (AND? tlsOption)* )
)?
(WITH userResourceOption+)?
(userPasswordOption | userLockOption)* #createUserMysqlV57
;
dropUser
: DROP USER ifExists? userName (',' userName)*
;
grantStatement
: GRANT privelegeClause (',' privelegeClause)*
ON
privilegeObject=(TABLE | FUNCTION | PROCEDURE)?
privilegeLevel
TO userAuthOption (',' userAuthOption)*
(
REQUIRE
(tlsNone=NONE | tlsOption (AND? tlsOption)* )
)?
(WITH (GRANT OPTION | userResourceOption)* )?
;
grantProxy
: GRANT PROXY ON fromFirst=userName
TO toFirst=userName (',' toOther+=userName)*
(WITH GRANT OPTION)?
;
renameUser
: RENAME USER
renameUserClause (',' renameUserClause)*
;
revokeStatement
: REVOKE privelegeClause (',' privelegeClause)*
ON
privilegeObject=(TABLE | FUNCTION | PROCEDURE)?
privilegeLevel
FROM userName (',' userName)* #detailRevoke
| REVOKE ALL PRIVILEGES? ',' GRANT OPTION
FROM userName (',' userName)* #shortRevoke
;
revokeProxy
: REVOKE PROXY ON onUser=userName
FROM fromFirst=userName (',' fromOther+=userName)*
;
setPasswordStatement
: SET PASSWORD (FOR userName)?
'=' ( passwordFunctionClause | STRING_LITERAL)
;
// details
userSpecification
: userName userPasswordOption
;
userAuthOption
: userName IDENTIFIED BY PASSWORD hashed=STRING_LITERAL #passwordAuthOption
| userName
IDENTIFIED (WITH authPlugin)? BY STRING_LITERAL #stringAuthOption
| userName
IDENTIFIED WITH authPlugin
(AS STRING_LITERAL)? #hashAuthOption
| userName #simpleAuthOption
;
tlsOption
: SSL
| X509
| CIPHER STRING_LITERAL
| ISSUER STRING_LITERAL
| SUBJECT STRING_LITERAL
;
userResourceOption
: MAX_QUERIES_PER_HOUR decimalLiteral
| MAX_UPDATES_PER_HOUR decimalLiteral
| MAX_CONNECTIONS_PER_HOUR decimalLiteral
| MAX_USER_CONNECTIONS decimalLiteral
;
userPasswordOption
: PASSWORD EXPIRE
(expireType=DEFAULT
| expireType=NEVER
| expireType=INTERVAL decimalLiteral DAY
)?
;
userLockOption
: ACCOUNT lockType=(LOCK | UNLOCK)
;
privelegeClause
: privilege ( '(' uidList ')' )?
;
privilege
: ALL PRIVILEGES?
| ALTER ROUTINE?
| CREATE
(TEMPORARY TABLES | ROUTINE | VIEW | USER | TABLESPACE)?
| DELETE | DROP | EVENT | EXECUTE | FILE | GRANT OPTION
| INDEX | INSERT | LOCK TABLES | PROCESS | PROXY
| REFERENCES | RELOAD
| REPLICATION (CLIENT | SLAVE)
| SELECT
| SHOW (VIEW | DATABASES)
| SHUTDOWN | SUPER | TRIGGER | UPDATE | USAGE
;
privilegeLevel
: '*' #currentSchemaPriviLevel
| '*' '.' '*' #globalPrivLevel
| uid '.' '*' #definiteSchemaPrivLevel
| uid '.' uid #definiteFullTablePrivLevel
| uid #definiteTablePrivLevel
;
renameUserClause
: fromFirst=userName TO toFirst=userName
;
// Table maintenance statements
analyzeTable
: ANALYZE actionOption=(NO_WRITE_TO_BINLOG | LOCAL)?
TABLE tables
;
checkTable
: CHECK TABLE tables checkTableOption*
;
checksumTable
: CHECKSUM TABLE tables actionOption=(QUICK | EXTENDED)?
;
optimizeTable
: OPTIMIZE actionOption=(NO_WRITE_TO_BINLOG | LOCAL)?
TABLE tables
;
repairTable
: REPAIR actionOption=(NO_WRITE_TO_BINLOG | LOCAL)?
TABLE tables
QUICK? EXTENDED? USE_FRM?
;
// details
checkTableOption
: FOR UPGRADE | QUICK | FAST | MEDIUM | EXTENDED | CHANGED
;
// Plugin and udf statements
createUdfunction
: CREATE AGGREGATE? FUNCTION uid
RETURNS returnType=(STRING | INTEGER | REAL | DECIMAL)
SONAME STRING_LITERAL
;
installPlugin
: INSTALL PLUGIN uid SONAME STRING_LITERAL
;
uninstallPlugin
: UNINSTALL PLUGIN uid
;
// Set and show statements
setStatement
: SET variableClause '=' expression
(',' variableClause '=' expression)* #setVariable
| SET (CHARACTER SET | CHARSET) (charsetName | DEFAULT) #setCharset
| SET NAMES
(charsetName (COLLATE collationName)? | DEFAULT) #setNames
| setPasswordStatement #setPassword
| setTransactionStatement #setTransaction
| setAutocommitStatement #setAutocommit
;
showStatement
: SHOW logFormat=(BINARY | MASTER) LOGS #showMasterLogs
| SHOW logFormat=(BINLOG | RELAYLOG)
EVENTS (IN filename=STRING_LITERAL)?
(FROM fromPosition=decimalLiteral)?
(LIMIT
(offset=decimalLiteral ',')?
rowCount=decimalLiteral
)? #showLogEvents
| SHOW showCommonEntity showFilter? #showObjectFilter
| SHOW FULL? columnsFormat=(COLUMNS | FIELDS)
tableFormat=(FROM | IN) tableName
(schemaFormat=(FROM | IN) uid)? showFilter? #showColumns
| SHOW CREATE schemaFormat=(DATABASE | SCHEMA)
ifNotExists? uid #showCreateDb
| SHOW CREATE
namedEntity=(
EVENT | FUNCTION | PROCEDURE
| TABLE | TRIGGER | VIEW
)
fullId #showCreateFullIdObject
| SHOW CREATE USER userName #showCreateUser
| SHOW ENGINE engineName engineOption=(STATUS | MUTEX) #showEngine
| SHOW showGlobalInfoClause #showGlobalInfo
| SHOW errorFormat=(ERRORS | WARNINGS)
(LIMIT
(offset=decimalLiteral ',')?
rowCount=decimalLiteral
) #showErrors
| SHOW COUNT '(' '*' ')' errorFormat=(ERRORS | WARNINGS) #showCountErrors
| SHOW showSchemaEntity
(schemaFormat=(FROM | IN) uid)? showFilter? #showSchemaFilter
| SHOW routine=(FUNCTION | PROCEDURE) CODE fullId #showRoutine
| SHOW GRANTS (FOR userName)? #showGrants
| SHOW indexFormat=(INDEX | INDEXES | KEYS)
tableFormat=(FROM | IN) tableName
(schemaFormat=(FROM | IN) uid)? (WHERE expression)? #showIndexes
| SHOW OPEN TABLES ( schemaFormat=(FROM | IN) uid)?
showFilter? #showOpenTables
| SHOW PROFILE showProfileType (',' showProfileType)*
(FOR QUERY queryCount=decimalLiteral)?
(LIMIT
(offset=decimalLiteral ',')?
rowCount=decimalLiteral
) #showProfile
| SHOW SLAVE STATUS (FOR CHANNEL STRING_LITERAL)? #showSlaveStatus
;
// details
variableClause
: LOCAL_ID | GLOBAL_ID | ( ('@' '@')? (GLOBAL | SESSION) )? uid
;
showCommonEntity
: CHARACTER SET | COLLATION | DATABASES | SCHEMAS
| FUNCTION STATUS | PROCEDURE STATUS
| (GLOBAL | SESSION)? (STATUS | VARIABLES)
;
showFilter
: LIKE STRING_LITERAL
| WHERE expression
;
showGlobalInfoClause
: STORAGE? ENGINES | MASTER STATUS | PLUGINS
| PRIVILEGES | FULL? PROCESSLIST | PROFILES
| SLAVE HOSTS | AUTHORS | CONTRIBUTORS
;
showSchemaEntity
: EVENTS | TABLE STATUS | FULL? TABLES | TRIGGERS
;
showProfileType
: ALL | BLOCK IO | CONTEXT SWITCHES | CPU | IPC | MEMORY
| PAGE FAULTS | SOURCE | SWAPS
;
// Other administrative statements
binlogStatement
: BINLOG STRING_LITERAL
;
cacheIndexStatement
: CACHE INDEX tableIndexes (',' tableIndexes)*
( PARTITION '(' (uidList | ALL) ')' )?
IN schema=uid
;
flushStatement
: FLUSH flushFormat=(NO_WRITE_TO_BINLOG | LOCAL)?
flushOption (',' flushOption)*
;
killStatement
: KILL connectionFormat=(CONNECTION | QUERY)?
decimalLiteral+
;
loadIndexIntoCache
: LOAD INDEX INTO CACHE
loadedTableIndexes (',' loadedTableIndexes)*
;
// remark reset (maser | slave) describe in replication's
// statements section
resetStatement
: RESET QUERY CACHE
;
shutdownStatement
: SHUTDOWN
;
// details
tableIndexes
: tableName ( indexFormat=(INDEX | KEY)? '(' uidList ')' )?
;
flushOption
: (
DES_KEY_FILE | HOSTS
| (
BINARY | ENGINE | ERROR | GENERAL | RELAY | SLOW
)? LOGS
| OPTIMIZER_COSTS | PRIVILEGES | QUERY CACHE | STATUS
| USER_RESOURCES | TABLES (WITH READ LOCK)?
) #simpleFlushOption
| RELAY LOGS channelOption? #channelFlushOption
| TABLES tables flushTableOption? #tableFlushOption
;
flushTableOption
: WITH READ LOCK
| FOR EXPORT
;
loadedTableIndexes
: tableName
( PARTITION '(' (partitionList=uidList | ALL) ')' )?
( indexFormat=(INDEX | KEY)? '(' indexList=uidList ')' )?
(IGNORE LEAVES)?
;
// Utility Statements
simpleDescribeStatement
: command=(EXPLAIN | DESCRIBE | DESC) tableName
(column=uid | pattern=STRING_LITERAL)?
;
fullDescribeStatement
: command=(EXPLAIN | DESCRIBE | DESC)
(
formatType=(EXTENDED | PARTITIONS | FORMAT )
'='
formatValue=(TRADITIONAL | JSON)
)?
describeObjectClause
;
helpStatement
: HELP STRING_LITERAL
;
useStatement
: USE uid
;
// details
describeObjectClause
: (
selectStatement | deleteStatement | insertStatement
| replaceStatement | updateStatement
) #describeStatements
| FOR CONNECTION uid #describeConnection
;
// Common Clauses
// DB Objects
fullId
: uid (DOT_ID | '.' uid)?
;
tableName
: fullId
;
fullColumnName
: uid (dottedId dottedId? )?
;
indexColumnName
: uid ('(' decimalLiteral ')')? sortType=(ASC | DESC)?
;
userName
: STRING_USER_NAME | ID;
mysqlVariable
: LOCAL_ID
| GLOBAL_ID
;
charsetName
: BINARY
| charsetNameBase
| STRING_LITERAL
| CHARSET_REVERSE_QOUTE_STRING
;
collationName
: uid | STRING_LITERAL;
engineName
: ARCHIVE | BLACKHOLE | CSV | FEDERATED | INNODB | MEMORY
| MRG_MYISAM | MYISAM | NDB | NDBCLUSTER | PERFOMANCE_SCHEMA
;
uuidSet
: decimalLiteral '-' decimalLiteral '-' decimalLiteral
'-' decimalLiteral '-' decimalLiteral
(':' decimalLiteral '-' decimalLiteral)+
;
xid
: globalTableUid=xuidStringId
(
',' qualifier=xuidStringId
(',' idFormat=decimalLiteral)?
)?
;
xuidStringId
: STRING_LITERAL
| BIT_STRING
| HEXADECIMAL_LITERAL+
;
authPlugin
: uid | STRING_LITERAL
;
uid
: simpleId
//| DOUBLE_QUOTE_ID
| REVERSE_QUOTE_ID
| CHARSET_REVERSE_QOUTE_STRING
;
simpleId
: ID
| charsetNameBase
| transactionLevelBase
| engineName
| privilegesBase
| intervalTypeBase
| dataTypeBase
| keywordsCanBeId
| functionNameBase
;
dottedId
: DOT_ID
| '.' uid
;
// Literals
decimalLiteral
: DECIMAL_LITERAL | ZERO_DECIMAL | ONE_DECIMAL | TWO_DECIMAL
;
fileSizeLiteral
: FILESIZE_LITERAL | decimalLiteral;
stringLiteral
: (
STRING_CHARSET_NAME? STRING_LITERAL
| START_NATIONAL_STRING_LITERAL
) STRING_LITERAL+
| (
STRING_CHARSET_NAME? STRING_LITERAL
| START_NATIONAL_STRING_LITERAL
) (COLLATE collationName)?
;
booleanLiteral
: TRUE | FALSE;
hexadecimalLiteral
: STRING_CHARSET_NAME? HEXADECIMAL_LITERAL;
nullNotnull
: NOT? (NULL_LITERAL | NULL_SPEC_LITERAL)
;
constant
: stringLiteral | decimalLiteral
| '-' decimalLiteral
| hexadecimalLiteral | booleanLiteral
| REAL_LITERAL | BIT_STRING
| NOT? nullLiteral=(NULL_LITERAL | NULL_SPEC_LITERAL)
;
// Data Types
dataType
: typeName=(
CHAR | VARCHAR | TINYTEXT | TEXT | MEDIUMTEXT | LONGTEXT
)
lengthOneDimension? BINARY?
(CHARACTER SET charsetName)? (COLLATE collationName)? #stringDataType
| typeName=(
TINYINT | SMALLINT | MEDIUMINT | INT | INTEGER | BIGINT
)
lengthOneDimension? UNSIGNED? ZEROFILL? #dimensionDataType
| typeName=(REAL | DOUBLE | FLOAT)
lengthTwoDimension? UNSIGNED? ZEROFILL? #dimensionDataType
| typeName=(DECIMAL | NUMERIC)
lengthTwoOptionalDimension? UNSIGNED? ZEROFILL? #dimensionDataType
| typeName=(
DATE | TINYBLOB | BLOB | MEDIUMBLOB | LONGBLOB
| BOOL | BOOLEAN
) #simpleDataType
| typeName=(
BIT | TIME | TIMESTAMP | DATETIME | BINARY
| VARBINARY | YEAR
)
lengthOneDimension? #dimensionDataType
| typeName=(ENUM | SET)
'(' STRING_LITERAL (',' STRING_LITERAL)* ')' BINARY?
(CHARACTER SET charsetName)? (COLLATE collationName)? #collectionDataType
| typeName=(
GEOMETRYCOLLECTION | LINESTRING | MULTILINESTRING
| MULTIPOINT | MULTIPOLYGON | POINT | POLYGON
) #spatialDataType
;
convertedDataType
: typeName=(BINARY| NCHAR) lengthOneDimension?
| typeName=CHAR lengthOneDimension? (CHARACTER SET charsetName)?
| typeName=(DATE | DATETIME | TIME)
| typeName=DECIMAL lengthTwoDimension?
| (SIGNED | UNSIGNED) INTEGER?
;
lengthOneDimension
: '(' decimalLiteral ')'
;
lengthTwoDimension
: '(' decimalLiteral ',' decimalLiteral ')'
;
lengthTwoOptionalDimension
: '(' decimalLiteral (',' decimalLiteral)? ')'
;
// Common Lists
uidList
: uid (',' uid)*
;
tables
: tableName (',' tableName)*
;
indexColumnNames
: '(' indexColumnName (',' indexColumnName)* ')'
;
expressions
: expression (',' expression)*
;
expressionsWithDefaults
: expressionOrDefault (',' expressionOrDefault)*
;
constants
: constant (',' constant)*
;
simpleStrings
: STRING_LITERAL (',' STRING_LITERAL)*
;
userVariables
: LOCAL_ID (',' LOCAL_ID)*
;
// Common Expressons
defaultValue
: NULL_LITERAL
| constant
| currentTimestamp (ON UPDATE currentTimestamp)?
;
currentTimestamp
:
(
(CURRENT_TIMESTAMP | LOCALTIME | LOCALTIMESTAMP) ('(' decimalLiteral? ')')?
| NOW '(' decimalLiteral? ')'
)
;
expressionOrDefault
: expression | DEFAULT
;
ifExists
: IF EXISTS;
ifNotExists
: IF NOT EXISTS;
// Functions
functionCall
: specificFunction #specificFunctionCall
| aggregateWindowedFunction #aggregateFunctionCall
| scalarFunctionName '(' functionArgs? ')' #scalarFunctionCall
| fullId '(' functionArgs? ')' #udfFunctionCall
| passwordFunctionClause #passwordFunctionCall
;
specificFunction
: (
CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP
| CURRENT_USER | LOCALTIME
) #simpleFunctionCall
| CONVERT '(' expression separator=',' convertedDataType ')' #dataTypeFunctionCall
| CONVERT '(' expression USING charsetName ')' #dataTypeFunctionCall
| CAST '(' expression AS convertedDataType ')' #dataTypeFunctionCall
| VALUES '(' fullColumnName ')' #valuesFunctionCall
| CASE expression caseFuncAlternative+
(ELSE elseArg=functionArg)? END #caseFunctionCall
| CASE caseFuncAlternative+
(ELSE elseArg=functionArg)? END #caseFunctionCall
| CHAR '(' functionArgs (USING charsetName)? ')' #charFunctionCall
| POSITION
'('
(
positionString=stringLiteral
| positionExpression=expression
)
IN
(
inString=stringLiteral
| inExpression=expression
)
')' #positionFunctionCall
| (SUBSTR | SUBSTRING)
'('
(
sourceString=stringLiteral
| sourceExpression=expression
) FROM
(
fromDecimal=decimalLiteral
| fromExpression=expression
)
(
FOR
(
forDecimal=decimalLiteral
| forExpression=expression
)
)?
')' #substrFunctionCall
| TRIM
'('
positioinForm=(BOTH | LEADING | TRAILING)
(
sourceString=stringLiteral
| sourceExpression=expression
)?
FROM
(
fromString=stringLiteral
| fromExpression=expression
)
')' #trimFunctionCall
| TRIM
'('
(
sourceString=stringLiteral
| sourceExpression=expression
)
FROM
(
fromString=stringLiteral
| fromExpression=expression
)
')' #trimFunctionCall
| WEIGHT_STRING
'('
(stringLiteral | expression)
(AS stringFormat=(CHAR | BINARY)
'(' decimalLiteral ')' )? levelsInWeightString?
')' #weightFunctionCall
| EXTRACT
'('
intervalType
FROM
(
sourceString=stringLiteral
| sourceExpression=expression
)
')' #extractFunctionCall
| GET_FORMAT
'('
datetimeFormat=(DATE | TIME | DATETIME)
',' stringLiteral
')' #getFormatFunctionCall
;
caseFuncAlternative
: WHEN condition=functionArg
THEN consequent=functionArg
;
levelsInWeightString
: LEVEL levelInWeightListElement
(',' levelInWeightListElement)* #levelWeightList
| LEVEL
firstLevel=decimalLiteral '-' lastLevel=decimalLiteral #levelWeightRange
;
levelInWeightListElement
: decimalLiteral orderType=(ASC | DESC | REVERSE)?
;
aggregateWindowedFunction
: (AVG | MAX | MIN | SUM)
'(' aggregator=(ALL | DISTINCT)? functionArg ')'
| COUNT '(' (starArg='*' | aggregator=ALL? functionArg) ')'
| COUNT '(' aggregator=DISTINCT functionArgs ')'
| (
BIT_AND | BIT_OR | BIT_XOR | STD | STDDEV | STDDEV_POP
| STDDEV_SAMP | VAR_POP | VAR_SAMP | VARIANCE
) '(' aggregator=ALL? functionArg ')'
| GROUP_CONCAT '('
aggregator=DISTINCT? functionArgs
(ORDER BY
orderByExpression (',' orderByExpression)*
)? (SEPARATOR separator=STRING_LITERAL)?
')'
;
scalarFunctionName
: functionNameBase
| ASCII | CURDATE | CURRENT_DATE | CURRENT_TIME
| CURRENT_TIMESTAMP | CURTIME | DATE_ADD | DATE_SUB
| IF | INSERT | LOCALTIME | LOCALTIMESTAMP | MID | NOW
| REPLACE | SUBSTR | SUBSTRING | SYSDATE | TRIM
| UTC_DATE | UTC_TIME | UTC_TIMESTAMP
;
passwordFunctionClause
: functionName=(PASSWORD | OLD_PASSWORD) '(' functionArg ')'
;
functionArgs
: (constant | fullColumnName | functionCall | expression)
(
','
(constant | fullColumnName | functionCall | expression)
)*
;
functionArg
: constant | fullColumnName | functionCall | expression
;
// Expressions, predicates
// Simplified approach for expression
expression
: notOperator=(NOT | '!') expression #notExpression
| expression logicalOperator expression #logicalExpression
| predicate IS NOT? testValue=(TRUE | FALSE | UNKNOWN) #isExpression
| predicate #predicateExpression
;
predicate
: predicate NOT? IN '(' (selectStatement | expressions) ')' #inPredicate
| predicate IS nullNotnull #isNullPredicate
| left=predicate comparisonOperator right=predicate #binaryComparasionPredicate
| predicate comparisonOperator
quantifier=(ALL | ANY | SOME) '(' selectStatement ')' #subqueryComparasionPredicate
| predicate NOT? BETWEEN predicate AND predicate #betweenPredicate
| predicate SOUNDS LIKE predicate #soundsLikePredicate
| predicate NOT? LIKE predicate (ESCAPE STRING_LITERAL)? #likePredicate
| predicate NOT? regex=(REGEXP | RLIKE) predicate #regexpPredicate
| (LOCAL_ID VAR_ASSIGN)? expressionAtom #expressionAtomPredicate
;
// Add in ASTVisitor nullNotnull in constant
expressionAtom
: constant #constantExpressionAtom
| fullColumnName #fullColumnNameExpressionAtom
| functionCall #functionCallExpressionAtom
| expressionAtom COLLATE collationName #collateExpressionAtom
| mysqlVariable #mysqlVariableExpressionAtom
| unaryOperator expressionAtom #unaryExpressionAtom
| BINARY expressionAtom #binaryExpressionAtom
| '(' expression (',' expression)* ')' #nestedExpressionAtom
| ROW '(' expression (',' expression)+ ')' #nestedRowExpressionAtom
| EXISTS '(' selectStatement ')' #existsExpessionAtom
| '(' selectStatement ')' #subqueryExpessionAtom
| INTERVAL expression intervalType #intervalExpressionAtom
| left=expressionAtom bitOperator right=expressionAtom #bitExpressionAtom
| left=expressionAtom mathOperator right=expressionAtom #mathExpressionAtom
;
unaryOperator
: '!' | '~' | '+' | '-' | NOT
;
comparisonOperator
: '=' | '>' | '<' | '<' '=' | '>' '='
| '<' '>' | '!' '=' | '<' '=' '>'
;
logicalOperator
: AND | '&' '&' | XOR | OR | '|' '|'
;
bitOperator
: '<' '<' | '>' '>' | '&' | '^' | '|'
;
mathOperator
: '*' | '/' | '%' | DIV | MOD | '+' | '-' | '--'
;
// Simple id sets
// (that keyword, which can be id)
charsetNameBase
: ARMSCII8 | ASCII | BIG5 | CP1250 | CP1251 | CP1256 | CP1257
| CP850 | CP852 | CP866 | CP932 | DEC8 | EUCJPMS | EUCKR
| GB2312 | GBK | GEOSTD8 | GREEK | HEBREW | HP8 | KEYBCS2
| KOI8R | KOI8U | LATIN1 | LATIN2 | LATIN5 | LATIN7 | MACCE
| MACROMAN | SJIS | SWE7 | TIS620 | UCS2 | UJIS | UTF16
| UTF16LE | UTF32 | UTF8 | UTF8MB3 | UTF8MB4
;
transactionLevelBase
: REPEATABLE | COMMITTED | UNCOMMITTED | SERIALIZABLE
;
privilegesBase
: TABLES | ROUTINE | EXECUTE | FILE | PROCESS
| RELOAD | SHUTDOWN | SUPER | PRIVILEGES
;
intervalTypeBase
: QUARTER | MONTH | DAY | HOUR
| MINUTE | WEEK | SECOND | MICROSECOND
;
dataTypeBase
: DATE | TIME | TIMESTAMP | DATETIME | YEAR | ENUM | TEXT
;
keywordsCanBeId
: ACCOUNT | ACTION | AFTER | AGGREGATE | ALGORITHM | ANY
| AT | AUTHORS | AUTOCOMMIT | AUTOEXTEND_SIZE
| AUTO_INCREMENT | AVG_ROW_LENGTH | BEGIN | BINLOG | BIT
| BLOCK | BOOL | BOOLEAN | BTREE | CASCADED | CHAIN
| CHANNEL | CHECKSUM | CIPHER | CLIENT | COALESCE | CODE
| COLUMNS | COLUMN_FORMAT | COMMENT | COMMIT | COMPACT
| COMPLETION | COMPRESSED | COMPRESSION | CONCURRENT
| CONNECTION | CONSISTENT | CONTAINS | CONTEXT
| CONTRIBUTORS | COPY | CPU | DATA | DATAFILE | DEALLOCATE
| DEFAULT_AUTH | DEFINER | DELAY_KEY_WRITE | DIRECTORY
| DISABLE | DISCARD | DISK | DO | DUMPFILE | DUPLICATE
| DYNAMIC | ENABLE | ENCRYPTION | ENDS | ENGINE | ENGINES
| ERROR | ERRORS | ESCAPE | EVEN | EVENT | EVENTS | EVERY
| EXCHANGE | EXCLUSIVE | EXPIRE | EXTENT_SIZE | FAULTS
| FIELDS | FILE_BLOCK_SIZE | FILTER | FIRST | FIXED
| FOLLOWS | FULL | FUNCTION | GLOBAL | GRANTS
| GROUP_REPLICATION | HASH | HOST | IDENTIFIED
| IGNORE_SERVER_IDS | IMPORT | INDEXES | INITIAL_SIZE
| INPLACE | INSERT_METHOD | INSTANCE | INVOKER | IO
| IO_THREAD | IPC | ISOLATION | ISSUER | KEY_BLOCK_SIZE
| LANGUAGE | LAST | LEAVES | LESS | LEVEL | LIST | LOCAL
| LOGFILE | LOGS | MASTER | MASTER_AUTO_POSITION
| MASTER_CONNECT_RETRY | MASTER_DELAY
| MASTER_HEARTBEAT_PERIOD | MASTER_HOST | MASTER_LOG_FILE
| MASTER_LOG_POS | MASTER_PASSWORD | MASTER_PORT
| MASTER_RETRY_COUNT | MASTER_SSL | MASTER_SSL_CA
| MASTER_SSL_CAPATH | MASTER_SSL_CERT | MASTER_SSL_CIPHER
| MASTER_SSL_CRL | MASTER_SSL_CRLPATH | MASTER_SSL_KEY
| MASTER_TLS_VERSION | MASTER_USER
| MAX_CONNECTIONS_PER_HOUR | MAX_QUERIES_PER_HOUR
| MAX_ROWS | MAX_SIZE | MAX_UPDATES_PER_HOUR
| MAX_USER_CONNECTIONS | MEMORY | MERGE | MID | MIGRATE
| MIN_ROWS | MODIFY | MUTEX | MYSQL | NAME | NAMES
| NCHAR | NEVER | NO | NODEGROUP | NONE | OFFLINE | OFFSET
| OJ | OLD_PASSWORD | ONE | ONLINE | ONLY | OPTIMIZER_COSTS
| OPTIONS | OWNER | PACK_KEYS | PAGE | PARSER | PARTIAL
| PARTITIONING | PARTITIONS | PASSWORD | PHASE | PLUGINS
| PLUGIN_DIR | PORT | PRECEDES | PREPARE | PRESERVE | PREV
| PROCESSLIST | PROFILE | PROFILES | PROXY | QUERY | QUICK
| REBUILD | RECOVER | REDO_BUFFER_SIZE | REDUNDANT
| RELAYLOG | RELAY_LOG_FILE | RELAY_LOG_POS | REMOVE
| REORGANIZE | REPAIR | REPLICATE_DO_DB | REPLICATE_DO_TABLE
| REPLICATE_IGNORE_DB | REPLICATE_IGNORE_TABLE
| REPLICATE_REWRITE_DB | REPLICATE_WILD_DO_TABLE
| REPLICATE_WILD_IGNORE_TABLE | REPLICATION | RESUME
| RETURNS | ROLLBACK | ROLLUP | ROTATE | ROW | ROWS
| ROW_FORMAT | SAVEPOINT | SCHEDULE | SECURITY | SERVER
| SESSION | SHARE | SHARED | SIGNED | SIMPLE | SLAVE
| SNAPSHOT | SOCKET | SOME | SOUNDS | SOURCE
| SQL_AFTER_GTIDS | SQL_AFTER_MTS_GAPS | SQL_BEFORE_GTIDS
| SQL_BUFFER_RESULT | SQL_CACHE | SQL_NO_CACHE | SQL_THREAD
| START | STARTS | STATS_AUTO_RECALC | STATS_PERSISTENT
| STATS_SAMPLE_PAGES | STATUS | STOP | STORAGE | STRING
| SUBJECT | SUBPARTITION | SUBPARTITIONS | SUSPEND | SWAPS
| SWITCHES | TABLESPACE | TEMPORARY | TEMPTABLE | THAN
| TRANSACTION | TRUNCATE | UNDEFINED | UNDOFILE
| UNDO_BUFFER_SIZE | UNKNOWN | UPGRADE | USER | VALIDATION
| VALUE | VARIABLES | VIEW | WAIT | WARNINGS | WITHOUT
| WORK | WRAPPER | X509 | XA | XML
;
functionNameBase
: ABS | ACOS | ADDDATE | ADDTIME | AES_DECRYPT | AES_ENCRYPT
| AREA | ASBINARY | ASIN | ASTEXT | ASWKB | ASWKT
| ASYMMETRIC_DECRYPT | ASYMMETRIC_DERIVE
| ASYMMETRIC_ENCRYPT | ASYMMETRIC_SIGN | ASYMMETRIC_VERIFY
| ATAN | ATAN2 | BENCHMARK | BIN | BIT_COUNT | BIT_LENGTH
| BUFFER | CEIL | CEILING | CENTROID | CHARACTER_LENGTH
| CHARSET | CHAR_LENGTH | COERCIBILITY | COLLATION
| COMPRESS | CONCAT | CONCAT_WS | CONNECTION_ID | CONV
| CONVERT_TZ | COS | COT | COUNT | CRC32
| CREATE_ASYMMETRIC_PRIV_KEY | CREATE_ASYMMETRIC_PUB_KEY
| CREATE_DH_PARAMETERS | CREATE_DIGEST | CROSSES | DATABASE | DATE
| DATEDIFF | DATE_FORMAT | DAY | DAYNAME | DAYOFMONTH
| DAYOFWEEK | DAYOFYEAR | DECODE | DEGREES | DES_DECRYPT
| DES_ENCRYPT | DIMENSION | DISJOINT | ELT | ENCODE
| ENCRYPT | ENDPOINT | ENVELOPE | EQUALS | EXP | EXPORT_SET
| EXTERIORRING | EXTRACTVALUE | FIELD | FIND_IN_SET | FLOOR
| FORMAT | FOUND_ROWS | FROM_BASE64 | FROM_DAYS
| FROM_UNIXTIME | GEOMCOLLFROMTEXT | GEOMCOLLFROMWKB
| GEOMETRYCOLLECTION | GEOMETRYCOLLECTIONFROMTEXT
| GEOMETRYCOLLECTIONFROMWKB | GEOMETRYFROMTEXT
| GEOMETRYFROMWKB | GEOMETRYN | GEOMETRYTYPE | GEOMFROMTEXT
| GEOMFROMWKB | GET_FORMAT | GET_LOCK | GLENGTH | GREATEST
| GTID_SUBSET | GTID_SUBTRACT | HEX | HOUR | IFNULL
| INET6_ATON | INET6_NTOA | INET_ATON | INET_NTOA | INSTR
| INTERIORRINGN | INTERSECTS | ISCLOSED | ISEMPTY | ISNULL
| ISSIMPLE | IS_FREE_LOCK | IS_IPV4 | IS_IPV4_COMPAT
| IS_IPV4_MAPPED | IS_IPV6 | IS_USED_LOCK | LAST_INSERT_ID
| LCASE | LEAST | LEFT | LENGTH | LINEFROMTEXT | LINEFROMWKB
| LINESTRING | LINESTRINGFROMTEXT | LINESTRINGFROMWKB | LN
| LOAD_FILE | LOCATE | LOG | LOG10 | LOG2 | LOWER | LPAD
| LTRIM | MAKEDATE | MAKETIME | MAKE_SET | MASTER_POS_WAIT
| MBRCONTAINS | MBRDISJOINT | MBREQUAL | MBRINTERSECTS
| MBROVERLAPS | MBRTOUCHES | MBRWITHIN | MD5 | MICROSECOND
| MINUTE | MLINEFROMTEXT | MLINEFROMWKB | MONTH | MONTHNAME
| MPOINTFROMTEXT | MPOINTFROMWKB | MPOLYFROMTEXT
| MPOLYFROMWKB | MULTILINESTRING | MULTILINESTRINGFROMTEXT
| MULTILINESTRINGFROMWKB | MULTIPOINT | MULTIPOINTFROMTEXT
| MULTIPOINTFROMWKB | MULTIPOLYGON | MULTIPOLYGONFROMTEXT
| MULTIPOLYGONFROMWKB | NAME_CONST | NULLIF | NUMGEOMETRIES
| NUMINTERIORRINGS | NUMPOINTS | OCT | OCTET_LENGTH | ORD
| OVERLAPS | PERIOD_ADD | PERIOD_DIFF | PI | POINT
| POINTFROMTEXT | POINTFROMWKB | POINTN | POLYFROMTEXT
| POLYFROMWKB | POLYGON | POLYGONFROMTEXT | POLYGONFROMWKB
| POSITION| POW | POWER | QUARTER | QUOTE | RADIANS | RAND
| RANDOM_BYTES | RELEASE_LOCK | REVERSE | RIGHT | ROUND
| ROW_COUNT | RPAD | RTRIM | SECOND | SEC_TO_TIME
| SESSION_USER | SHA | SHA1 | SHA2 | SIGN | SIN | SLEEP
| SOUNDEX | SQL_THREAD_WAIT_AFTER_GTIDS | SQRT | SRID
| STARTPOINT | STRCMP | STR_TO_DATE | ST_AREA | ST_ASBINARY
| ST_ASTEXT | ST_ASWKB | ST_ASWKT | ST_BUFFER | ST_CENTROID
| ST_CONTAINS | ST_CROSSES | ST_DIFFERENCE | ST_DIMENSION
| ST_DISJOINT | ST_DISTANCE | ST_ENDPOINT | ST_ENVELOPE
| ST_EQUALS | ST_EXTERIORRING | ST_GEOMCOLLFROMTEXT
| ST_GEOMCOLLFROMTXT | ST_GEOMCOLLFROMWKB
| ST_GEOMETRYCOLLECTIONFROMTEXT
| ST_GEOMETRYCOLLECTIONFROMWKB | ST_GEOMETRYFROMTEXT
| ST_GEOMETRYFROMWKB | ST_GEOMETRYN | ST_GEOMETRYTYPE
| ST_GEOMFROMTEXT | ST_GEOMFROMWKB | ST_INTERIORRINGN
| ST_INTERSECTION | ST_INTERSECTS | ST_ISCLOSED | ST_ISEMPTY
| ST_ISSIMPLE | ST_LINEFROMTEXT | ST_LINEFROMWKB
| ST_LINESTRINGFROMTEXT | ST_LINESTRINGFROMWKB
| ST_NUMGEOMETRIES | ST_NUMINTERIORRING
| ST_NUMINTERIORRINGS | ST_NUMPOINTS | ST_OVERLAPS
| ST_POINTFROMTEXT | ST_POINTFROMWKB | ST_POINTN
| ST_POLYFROMTEXT | ST_POLYFROMWKB | ST_POLYGONFROMTEXT
| ST_POLYGONFROMWKB | ST_SRID | ST_STARTPOINT
| ST_SYMDIFFERENCE | ST_TOUCHES | ST_UNION | ST_WITHIN
| ST_X | ST_Y | SUBDATE | SUBSTRING_INDEX | SUBTIME
| SYSTEM_USER | TAN | TIME | TIMEDIFF | TIMESTAMP
| TIMESTAMPADD | TIMESTAMPDIFF | TIME_FORMAT | TIME_TO_SEC
| TOUCHES | TO_BASE64 | TO_DAYS | TO_SECONDS | UCASE
| UNCOMPRESS | UNCOMPRESSED_LENGTH | UNHEX | UNIX_TIMESTAMP
| UPDATEXML | UPPER | UUID | UUID_SHORT
| VALIDATE_PASSWORD_STRENGTH | VERSION
| WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS | WEEK | WEEKDAY
| WEEKOFYEAR | WEIGHT_STRING | WITHIN | YEAR | YEARWEEK
| Y_FUNCTION | X_FUNCTION
;
| 75,637 | ANTLR | .g4 | 2,089 | 30.90809 | 98 | 0.603849 | slifin/honeySQL-parser | 1 | 0 | 0 | EPL-1.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | f4bb3770516a6a9ebdfe3b30a44a4b790c86ef7823b203ea184703a1856180d4 | false | false | false | false |
125 | Python3.g4 | ablozhou_apple/test/Python3.g4 | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 Bart Kiers Copyright (c) 2019 Robert Einhorn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Project : Python3-parser; an ANTLR4 grammar for Python 3 https://github.com/bkiers/Python3-parser
* Developed by : Bart Kiers, [email protected]
*
* Project : an ANTLR4 grammar for Tiny Python with embedded actions
* https://github.com/antlr/grammars-v4/tree/master/python/tiny-python/tiny-grammar-with-actions
* Developed by : Robert Einhorn, [email protected]
*/
// Based on the Bart Kiers's ANTLR4 Python 3.3 grammar: https://github.com/bkiers/Python3-parser and
// the Python 3.3.7 Language Reference: https://docs.python.org/3.3/reference/grammar.html
grammar Python3; // tiny version
tokens {
INDENT,
DEDENT
}
// this embedded code section will be copied to the generated file: Python3Lexer.java
@lexer::header { //*** https://github.com/antlr/antlr4/blob/master/doc/grammars.md#actions-at-the-grammar-level
import org.antlr.v4.runtime.misc.Interval;
import java.util.*;
}
// this embedded code section will be copied to the generated file: Python3Lexer.java
@lexer::members {
// The stack that keeps track of the indentation lengths
private Stack<Integer> indentLengths = new Stack<>();
// A linked list where extra tokens are pushed on
private LinkedList<Token> pendingTokens = new LinkedList<>();
// An int that stores the last pending token type (including the inserted INDENT/DEDENT/NEWLINE token types also)
private int lastPendingTokenType;
// The amount of opened braces, brackets and parenthesis
private int opened = 0;
// Was there space char in the indentations?
private boolean wasSpaceIndentation = false;
// Was there tab char in the indentations?
private boolean wasTabIndentation = false;
// A String list that stores the lexer warnings
private List<String> warnings = new ArrayList<>();
// A String list that stores the lexer error messages
private List<String> errors = new ArrayList<>();
// Patterns for the custom error listener to recognize error messages
public static final String TEXT_LEXER = "lexer --> ";
public static final String TEXT_INSERTED_INDENT = "inserted INDENT";
@Override
public Token nextToken() {
if (_input.size() == 0) {
return new CommonToken(EOF, "<EOF>"); // processing of the input stream until the first returning EOF
} else {
checkNextToken();
return this.pendingTokens.pollFirst(); // append the token stream with the upcoming pending token
}
}
private void checkNextToken() {
if (this.indentLengths != null) { // after the first incoming EOF token the indentLengths stack will be set to null
final int startSize = this.pendingTokens.size();
Token curToken;
do {
curToken = super.nextToken(); // get the next token from the input stream
checkStartOfInput(curToken);
switch (curToken.getType()) {
case OPEN_PAREN:
case OPEN_BRACK:
case OPEN_BRACE:
this.opened++;
this.pendingTokens.addLast(curToken);
break;
case CLOSE_PAREN:
case CLOSE_BRACK:
case CLOSE_BRACE:
this.opened--;
this.pendingTokens.addLast(curToken);
break;
case NEWLINE:
handleNewLineToken(curToken);
break;
case EOF:
handleEofToken(curToken); // indentLengths stack will be set to null
break;
default:
this.pendingTokens.addLast(curToken); // insert the current token
}
} while (this.pendingTokens.size() == startSize);
this.lastPendingTokenType = curToken.getType();
}
}
private void checkStartOfInput(Token curToken) {
if (indentLengths.size() == 0) { // We're at the first token
indentLengths.push(0); // initialize the stack with default 0 indentation length
if (_input.getText(new Interval(0, 0)).trim().length() == 0) { // the first char of the input is a whitespace
this.insertLeadingTokens(curToken.getType(), curToken.getStartIndex());
}
}
}
private void handleNewLineToken(Token curToken) {
if (this.opened == 0) { //*** https://docs.python.org/3/reference/lexical_analysis.html#implicit-line-joining
switch (_input.LA(1) /* next symbol */) { //*** https://www.antlr.org/api/Java/org/antlr/v4/runtime/IntStream.html#LA(int)
case '\r':
case '\n':
case '\f':
case '#': //*** https://docs.python.org/3/reference/lexical_analysis.html#blank-lines
case EOF: // skip the trailing inconsistent dedent or the trailing unexpected indent (or the trailing indent)
return; // We're on a blank line or before a comment or before the EOF, skip the NEWLINE token
default:
this.pendingTokens.addLast(curToken); // insert the current NEWLINE token
this.insertIndentDedentTokens(this.getIndentationLength(curToken.getText())); //*** https://docs.python.org/3/reference/lexical_analysis.html#indentation
}
}
}
private void handleEofToken(Token curToken) {
this.insertTrailingTokens(this.lastPendingTokenType); // indentLengths stack will be null!
this.pendingTokens.addLast(curToken); // insert the current EOF token
this.checkSpaceAndTabIndentation();
}
private void insertLeadingTokens(int type, int startIndex) {
if (type != NEWLINE && type != EOF) { // (after a whitespace) The first token is visible, so We insert a NEWLINE and an INDENT token before it to raise an 'unexpected indent' error later by the parser
this.insertToken(0, startIndex - 1, "<inserted leading NEWLINE>" + " ".repeat(startIndex), NEWLINE, 1, 0);
this.insertToken(startIndex, startIndex - 1, "<" + TEXT_INSERTED_INDENT + ", " + this.getIndentationDescription(startIndex) + ">", Python3Parser.INDENT, 1, startIndex);
this.indentLengths.push(startIndex);
}
}
private void insertIndentDedentTokens(int curIndentLength) {
int prevIndentLength = this.indentLengths.peek();
if (curIndentLength > prevIndentLength) { // insert an INDENT token
this.insertToken("<" + TEXT_INSERTED_INDENT + ", " + this.getIndentationDescription(curIndentLength) + ">", Python3Parser.INDENT);
this.indentLengths.push(curIndentLength);
} else {
while (curIndentLength < prevIndentLength) { // More than 1 DEDENT token may be inserted
this.indentLengths.pop();
prevIndentLength = this.indentLengths.peek();
if (curIndentLength <= prevIndentLength) {
this.insertToken("<inserted DEDENT, " + this.getIndentationDescription(prevIndentLength) + ">", Python3Parser.DEDENT);
} else {
this.insertToken("<inserted inconsistent DEDENT, " + "length=" + curIndentLength + ">", Python3Parser.DEDENT);
this.errors.add(TEXT_LEXER + "line " + getLine() + ":" + getCharPositionInLine() + "\t IndentationError: unindent does not match any outer indentation level");
}
}
}
}
private void insertTrailingTokens(int type) {
if (type != NEWLINE && type != Python3Parser.DEDENT) { // If the last pending token was not a NEWLINE and not a DEDENT then
this.insertToken("<inserted trailing NEWLINE>", NEWLINE); // insert an extra trailing NEWLINE token that serves as the end of the statement
}
while (this.indentLengths.size() > 1) { // Now insert as much trailing DEDENT tokens as needed
this.insertToken("<inserted trailing DEDENT, " + this.getIndentationDescription(this.indentLengths.pop()) + ">", Python3Parser.DEDENT);
}
this.indentLengths = null; // there will be no more token read from the input stream
}
private String getIndentationDescription(int lengthOfIndent) {
return "length=" + lengthOfIndent + ", level=" + this.indentLengths.size();
}
private void insertToken(String text, int type) {
final int startIndex = _tokenStartCharIndex + getText().length(); //*** https://www.antlr.org/api/Java/org/antlr/v4/runtime/Lexer.html#_tokenStartCharIndex
this.insertToken(startIndex, startIndex - 1, text, type, getLine(), getCharPositionInLine());
}
private void insertToken(int startIndex, int stopIndex, String text, int type, int line, int charPositionInLine) {
CommonToken token = new CommonToken(_tokenFactorySourcePair, type, DEFAULT_TOKEN_CHANNEL, startIndex, stopIndex); //*** https://www.antlr.org/api/Java/org/antlr/v4/runtime/CommonToken.html
token.setText(text);
token.setLine(line);
token.setCharPositionInLine(charPositionInLine);
this.pendingTokens.addLast(token);
}
// Calculates the indentation of the provided spaces, taking the
// following rules into account:
//
// "Tabs are replaced (from left to right) by one to eight spaces
// such that the total number of characters up to and including
// the replacement is a multiple of eight [...]"
//
// -- https://docs.python.org/3.1/reference/lexical_analysis.html#indentation
private int getIndentationLength(String textOfMatchedNEWLINE) {
int count = 0;
for (char ch : textOfMatchedNEWLINE.toCharArray()) {
switch (ch) {
case ' ': // A normal space char
this.wasSpaceIndentation = true;
count++;
break;
case '\t':
this.wasTabIndentation = true;
count += 8 - (count % 8);
break;
}
}
return count;
}
private void checkSpaceAndTabIndentation() {
if (this.wasSpaceIndentation && this.wasTabIndentation) {
this.warnings.add("Mixture of space and tab were used for indentation.");
}
}
public List<String> getWarnings() {
return this.warnings;
}
public List<String> getErrorMessages() {
return this.errors;
}
}
/*
* parser rules
*/
// startRules:
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE;
file_input: (NEWLINE | stmt)* EOF;
stmt: simple_stmt | compound_stmt;
simple_stmt: small_stmt NEWLINE;
small_stmt: assignment_stmt | flow_stmt | print_stmt;
assignment_stmt: NAME '=' expr;
flow_stmt: break_stmt | continue_stmt;
break_stmt: 'break';
continue_stmt: 'continue';
compound_stmt: if_stmt | while_stmt;
if_stmt:
'if' test ':' suite ('elif' test ':' suite)* (
'else' ':' suite
)?;
while_stmt: 'while' test ':' suite;
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT;
test:
expr (comp_op expr)*; // differents from the original grammar
print_stmt:
'print' OPEN_PAREN STRING CLOSE_PAREN
| OPEN_PAREN expr CLOSE_PAREN; // only for demonstration
comp_op: '<' | '>' | '==' | '>=' | '<=' | '!=';
expr: expr (( '+' | '-') expr)+ | NAME | NUMBER | '(' expr ')';
/*
* lexer rules
*/
STRING: STRING_LITERAL;
NUMBER: INTEGER;
INTEGER: DECIMAL_INTEGER;
NEWLINE: ( '\r'? '\n' | '\r' | '\f') SPACES?;
NAME: ID_START ID_CONTINUE*;
STRING_LITERAL: '"' .*? '"';
DECIMAL_INTEGER: NON_ZERO_DIGIT DIGIT* | '0'+;
OPEN_PAREN: '(';
CLOSE_PAREN: ')';
OPEN_BRACK: '[';
CLOSE_BRACK: ']';
OPEN_BRACE: '{';
CLOSE_BRACE: '}';
SKIP_: ( SPACES | COMMENT | LINE_JOINING) -> skip;
UNKNOWN_CHAR: .;
/*
* fragments
*/
fragment NON_ZERO_DIGIT: [1-9];
fragment DIGIT: [0-9];
fragment SPACES: [ \t]+;
fragment COMMENT: '#' ~[\r\n\f]*;
fragment LINE_JOINING: '\\' SPACES? ( '\r'? '\n' | '\r' | '\f');
fragment ID_START: '_' | [A-Z] | [a-z];
fragment ID_CONTINUE: ID_START | [0-9]; | 12,705 | ANTLR | .g4 | 269 | 41.67658 | 204 | 0.682383 | ablozhou/apple | 1 | 0 | 2 | GPL-3.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | 12be79969f5beb6db86f66cd366d2459dedbf7d0a5431e7f627012ad3db33195 | false | false | false | false |
126 | Hello.g4 | ablozhou_apple/test/Hello.g4 | grammar Hello;
r: 'hello' ID; // match keyword hello followed by an identifier
ID: [a-z]+; // match lower-case identifiers
WS: [ \t\r\n]+ -> skip; // skip spaces, tabs, newlines | 177 | ANTLR | .g4 | 4 | 43.5 | 63 | 0.683908 | ablozhou/apple | 1 | 0 | 2 | GPL-3.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | 77f85daa5c88da7cc0542b7e47afd361ea893749b05dfcd82baa9d5e83baf08a | true | true | false | false |
127 | Apple.g4 | ablozhou_apple/antlr/src/main/antlr4/Apple.g4 | grammar Apple;
// Author: Andy zhou <[email protected]>
// Date 2019.8.15
@header {package com.abloz.antlr;}
prog: (stmt)*;
stmt: expr ((NEWLINE|';'))* # express
| NEWLINE # newLine
;
expr: expr op=(MUL|DIV) expr # MulDiv
| expr op=(ADD|SUB) expr # AddSub
| INT # int
| ID # id
| ID '=' expr # assign
| '(' expr ')' # parens
;
NEWLINE : [\r\n]+ ;
INT : [0-9]+ ;
MUL : '*' ;
DIV : '/' ;
ADD : '+' ;
SUB : '-' ;
ID : [_a-zA-Z0-9]+ ; // match alpha,digital,_ identifiers
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
SPACES
: [ \t]+
;
COMMENT
: '//' ~[\r\n\f]*
;
BLOCK_COMMENT
: '/*' .*? '*/'
;
LINE_JOINING
: '\\' SPACES? ( '\r'? '\n' | '\r' | '\f')
;
SKIPS: (WS|COMMENT|BLOCK_COMMENT|LINE_JOINING)+ -> skip;
| 866 | ANTLR | .g4 | 36 | 21.611111 | 69 | 0.470231 | ablozhou/apple | 1 | 0 | 2 | GPL-3.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | a64cd7e80f325aed9604ac63498ffbfe87038e3ebb4068f8787a777c9f83aac7 | false | false | false | false |
128 | langGrammar.g4 | Af4rinz_antlr-parser/langGrammar.g4 | grammar langGrammar;
program: (preProcess)* (classDec | varDec)* EOF;
preProcess: (
(VAR '=' REQUIRE VAR)
| (VAR '=' FROM VAR REQUIRE VAR)
) ';';
statement: assignExp';'
| varDec
| forRange
| forIt
| whileLoop
| ifStatement
| switchStatement
| doWhileLoop
| incDecStatement
| (functionCall';')
| block
;
classDec: CLASS VAR (EXTENDS VAR)? implementExp? '{' (varDec | function | assignExp)* '}' ';'?;
function: (TYPE | VOID) VAR '=' '(' ((TYPE) VAR (',' TYPE VAR)* )? ')' '=>' '{' statement*
(RETURN exp? ';') '}' ';'?;
functionCall: VAR '(' (exp (',' exp)*)? ')';
implementExp: IMPLEMENTS VAR (',' VAR)*;
varDec: (LET | CONST) TYPE ('[]')? varAssign (',' varAssign)* (';');
varAssign: VAR (('=' VAR)* '=' (SCIENTIFIC_NUMBER | exp ))?; //only to use in var declaration
//support for code blocks in program
block: '{' statement* '}';
//switch statement include 0+ cases and may include one default case
switchStatement: SWITCH '(' VAR ')' '{' (CASE (('\'' VAR '\'') | NUMBER | BOOL) ':' (('{' statement* '}') | statement*) (BREAK ';')?)*
(DEFAULT ':'(('{' statement* '}') | statement*) (BREAK ';')?)? '}';
//range-based for, range is given in init:fin format with steps
forRange: FOR '(' VAR IN ((VAR|NUMBER)':'(VAR|NUMBER)) STEP (NUMBER|VAR) ')' (('{' statement* '}') | statement);
//iterative for using var IN iterator format
forIt: FOR '(' AUTO VAR IN VAR ')' (('{' statement* '}') | statement);
whileLoop: WHILE '(' exp ')' (('{' statement* '}') | statement);
doWhileLoop: DO (('{' statement* '}') | statement) WHILE '(' exp ')';
ifStatement:
IF '(' exp ')' (('{' statement* '}') | statement)
( ELSE (('{' statement* '}') | statement))? ;
incDecStatement: ((('--' | '++') VAR) | (VAR ('--' | '++'))) ';';
/*----- EXPRESSIONS -----*/
assignExp: VAR ('*' | '/' | '%' | '//' | '+' | '-' | '**')? '=' (exp | SCIENTIFIC_NUMBER);
exp: '(' exp ')'
| exp ('**') exp //power
| ('~') exp //unary bit op
| ('+'|'-') exp //unary sign op
| exp ('*' | '/' | '%' | '//') exp //mul/div op
| exp ('+' | '-') exp //sum/sub op
|('--' | '++') exp //inc/decrement
| exp ('--' | '++')
| exp ('<<' | '>>' ) exp //shift
| exp ('^' | '|' | '&') exp //bit op
| exp ('==' | '!=' | '<>') exp //equality op
| exp ('>' | '<' | '>=' | '<=') exp //inequality op
| NOT exp
| exp (OR | AND) exp
| atom;
atom: (('-' | '+')? (NUMBER | VAR)) | BOOL | IOTA | functionCall;
// NL: [\r\n]+;
LCOMMENT: '#' ~[\r\n]* -> skip; //skip single-line comments starting with #
MCOMMENT: '/*' .*? '*/' -> skip; //skip multiline comments in /*..*/ format
WS: [ \t\r\n]+ -> skip; // skip spaces and tabs
/*----- RESERVED KEYWORDS -----*/
//defined before the general word/var form to take
//precedence in parsing i.e. the keywords will
//not be recognised as variables/words
TYPE: BOOLEAN | INT | FLOAT;
REQUIRE: 'require';
CONST: 'const';
FROM: 'from';
CLASS: 'class';
EXTENDS: 'extends';
IMPLEMENTS: 'implements';
LET: 'let';
INT: 'int';
FLOAT: 'float';
VOID: 'void';
IOTA: 'iota';
NULL: 'null' | 'NULL';
RETURN: 'return';
IN: 'in';
FOR: 'for';
IF: 'if';
STEP: 'step';
AUTO: 'auto';
WHILE: 'while';
SWITCH: 'switch';
CASE: 'case';
DEFAULT: 'default';
BREAK: 'break';
ELSE: 'else';
DO: 'do';
NOT: 'not';
AND: 'and';
OR: 'or';
BOOLEAN: 'boolean';
BOOL: 'true' | 'false';
/*----- GENRAL COMPONENTS -----*/
fragment UPPERCASE: [A-Z];
fragment LOWERCASE: [a-z];
fragment DIGIT: [0-9];
fragment LETTER: [a-zA-Z];
//variables are 2+ characters, not starting with numerals
VAR: (LETTER | '_')(LETTER | '_' | NUMBER)+;
NUMBER: DIGIT+([.,] DIGIT+)?;
SCIENTIFIC_NUMBER: NUMBER ('e' ('+'|'-')? NUMBER);
| 3,619 | ANTLR | .g4 | 106 | 32.424528 | 135 | 0.566189 | Af4rinz/antlr-parser | 1 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:26 PM (Europe/Amsterdam) | 98fe6ef1b6cb8981732c4a07ec6251e17c74e66ee7412f61dc7032e33083106c | false | false | false | false |
129 | As3.g4 | dservgun_as3g4/codegen/src/grammars/As3.g4 | /**
Conversion effort to convert the g3 file to g4
*/
/*
* AS3.g3
*
* Copyright (c) 2005 Martin Schnabel
* Copyright (c) 2006-2008 David Holroyd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
grammar As3;
@header {
//Generated code sits here.
package org.as3g4.codegen;
}
// Originally derived from the ANTLRv2 ActionScript grammar by
// Martin Schnabel, included in the ASDT project,
// http://www.asdt.org
// http://sourceforge.net/projects/aseclipseplugin/
/*
Throws NPE when options are empty
//https://github.com/antlr/antlr4/issues/194
options {
//What is this option?
//Do we need these options in g4?
//k = 2;
//output=AST;
//ASTLabelType=LinkedListTree;
}
*/
/*
* What is the purpose of this scope operator.
* How do we port it over?
scope InOperator {
boolean allowed;
}
*/
tokens {
//These re-write rules have missing tokens: I need to find out
// what they do
COMPILATION_UNIT,
TYPE_BLOCK, METHOD_DEF, VAR_DEF,
//
ANNOTATIONS, ANNOTATION, ANNOTATION_PARAMS,
MODIFIERS, NAMESPACE_DEF,
ACCESSOR_ROLE,
CLASS_DEF, INTERFACE_DEF,
PARAMS,
PARAM, TYPE_SPEC,
BLOCK, ELIST,
CONDITION, ARGUMENTS,
EXPR_STMNT,
ENCPS_EXPR,
VAR_INIT,
METHOD_CALL, PROPERTY_OR_IDENTIFIER, PROPERTY_ACCESS, TYPE_NAME,
ARRAY_ACC,
MULT,
UNARY_PLUS, UNARY_MINUS, POST_INC, POST_DEC, PRE_INC, PRE_DEC,
ARRAY_LITERAL,
OBJECT_LITERAL,
OBJECT_FIELD, FUNC_DEF,
FOR_INIT, FOR_CONDITION, FOR_ITERATOR,
FOR_EACH, FOR_IN,
SWITCH_STATEMENT_LIST,
IDENTIFIER, IDENTIFIER_STAR,
DEFAULT_XML_NAMESPACE,
XML_LITERAL, REGEXP_LITERAL,
E4X_FILTER,
E4X_ATTRI_PROPERTY, E4X_ATTRI_STAR, E4X_ATTRI_EXPR,
VIRTUAL_PLACEHOLDER
}
compilationUnit : as2CompilationUnit | as3CompilationUnit;
//AS2 support is probably only provided for backward compatibility
//We need to handle as2.
as2CompilationUnit : importDefinition* as2Type;
as2Type: as2ClassDefinition | as2InterfaceDefinition;
as3CompilationUnit: packageDecl packageBlockEntry EOF;
packageDecl : PACKAGE identifier? packageBlock;
packageBlock : LCURLY packageBlockEntry* RCURLY;
packageBlockEntry
: ( importDefinition
| annotations
modifiers
( classDefinition
| interfaceDefinition
| variableDefinition
| methodDefinition
| namespaceDefinition
| useNamespaceDirective
)
| SEMI
)
;
importDefinition : IMPORT identifierStar semi ;
classDefinition: CLASS ident
classExtendsClause
implementsClause
typeBlock;
as2ClassDefinition : CLASS identifier
classExtendsClause
implementsClause
typeBlock;
interfaceDefinition: INTERFACE ident
interfaceExtendsClause
typeBlock;
as2InterfaceDefinition : INTERFACE identifier
interfaceExtendsClause
typeBlock;
classExtendsClause : EXTENDS identifier;
interfaceExtendsClause : (EXTENDS identifier ( COMMA identifier)*)?;
implementsClause : (IMPLEMENTS identifier (COMMA identifier)*)?;
typeBlock :
LCURLY
typeBlockEntry*
RCURLY;
typeBlockEntry :
annotations modifiers (variableDefinition
| methodDefinition)
| importDefinition
|as2IncludeDirective;
as2IncludeDirective : INCLUDE_DIRECTIVE | STRING_LITERAL;
includeDirective: 'include' STRING_LITERAL SEMI;
methodDefinition : FUNCTION
optionalAccessorRole
ident
parameterDeclarationList
typeExpression?
(block| semi);
optionalAccessorRole : accessorRole?;
accessorRole : GET | SET;
namespaceDefinition : NAMESPACE ident;
useNamespaceDirective: USE NAMESPACE ident semi;
declaration : varOrConst variableDeclarator declarationTail;
variableDefinition : varOrConst variableDeclarator (COMMA variableDeclarator)* semi;
variableDeclarator : ident typeExpression? variableInitializer;
declarationTail : (COMMA variableDeclarator)*;
variableInitializer : ASSIGN assignmentExpression;
varOrConst : VAR | CONST;
parameterDeclarationList : LPAREN (parameterDeclaration (COMMA parameterDeclaration)*)? RPAREN;
parameterDeclaration: basicParameterDeclaration | parameterRestDeclaration;
basicParameterDeclaration: CONST? ident typeExpression? parameterDefault?;
parameterDefault : ASSIGN assignmentExpression;
//REST -> ... multiple parameter list??
parameterRestDeclaration: REST ident?;
block : LCURLY statement* RCURLY;
condition: LPAREN expression RPAREN;
statement : superStatement
| block
| declarationStatement
| expressionStatement
| ifStatement
| forEachStatement
| forStatement
| whileStatement
| doWhileStatement
| withStatement
| switchStatement
| breakStatement
| continueStatement
| returnStatement
| throwStatement
| tryStatement
| defaultXMLNamespaceStatement
| semi
;
superStatement : SUPER arguments semi;
declarationStatement : declaration semi;
expressionStatement : expressionList semi;
ifStatement : IF condition statement (ELSE elseClause)?;
elseClause : ELSE^ statement;
throwStatement : THROW expression SEMI;
tryStatement : TRY
block
(finallyBlock
| catchBlock+
finallyBlock
)?;
catchBlock : CATCH LPAREN ident typeExpression? RPAREN
block;
finallyBlock : FINALLY block;
returnStatement : RETURN expression? semi;
continueStatement : CONTINUE semi;
breakStatement : BREAK semi;
switchStatement : SWITCH condition
switchBlock;
switchBlock : LCURLY
(caseStatement)*
(defaultStatement)?
RCURLY;
caseStatement : CASE expression COLON switchStatementList;
defaultStatement : DEFAULT COLON switchStatementList;
switchStatementList: statement*;
//Why should the for statement have only one statemen??
forStatement : LPAREN forInClause statement RPAREN | LPAREN traditionalForClause statement RPAREN;
forEachStatement :
FOR EACH LPAREN forInClause RPAREN statement;
traditionalForClause :
forInit forCond forIter;
forInClause: forInClauseDecl IN forInClauseTail;
forInClauseDecl : declaration | ident;
forInClauseTail : expressionList;
forInit : (declaration | expressionList)?;
forCond : expressionList?;
forIter : expressionList?;
whileStatement : WHILE condition statement;
doWhileStatement : DO statement WHILE condition semi;
withStatement : WITH condition statement;
defaultXMLNamespaceStatement : DEFAULT XML NAMESPACE ASSIGN expression semi;
typeExpression : COLON (identifier | VOID | STAR);
identifier : qualifiedIdent | propOrIdent;
propertyIdentifier : STAR | ident;
qualifier: (propertyIdentifier | reservedNamespace);
simpleQualifiedIdentifier: propertyIdentifier |
qualifier DBL_COLON
(propertyIdentifier
| brackets
)
;
expressionQualifiedIdentifier:
encapsulatedExpression DBL_COLON
(propertyIdentifier
| brackets)
;
nonAttributeQualifiedIdentifier:
simpleQualifiedIdentifier
| expressionQualifiedIdentifier;
qualifiedIdentifier:
e4xAttributeIdentifier
| nonAttributeQualifiedIdentifier;
qualifiedIdent : (namespaceName DBL_COLON)? ident;
namespaceName : IDENT | reservedNamespace;
reservedNamespace: PUBLIC | PRIVATE | PROTECTED |INTERNAL ;
identifierStar : ident (DOT IDENT*)? (DOT STAR)?;
annotations : (annotation | includeDirective)*;
annotation : LBRACK ident annotationParamList? RBRACK;
annotationParamList : LPAREN (annotationParam (COMMA annotationParam)*)? RPAREN;
annotationParam : ident ASSIGN constant
| constant
| ident
;
modifiers : modifier*;
modifier : namespaceName | STATIC | FINAL |ENUMERABLE | EXPLICIT | OVERRIDE |
DYNAMIC | INTRINSIC ;
arguments : LPAREN expressionList RPAREN
| LPAREN RPAREN;
arrayLiteral : LBRACK elementList? RBRACK;
elementList: COMMA | nonEmptyElementList;
nonEmptyElementList : assignmentExpression (COMMA assignmentExpression)* ;
element: assignmentExpression;
objectLiteral : LCURLY fieldList? RCURLY;
//The source has a slightly different definition:
//This could be a difference between g3 and g4 grammar
//syntax??
//literalField (COMMA! literalField?)*
fieldList : literalField (COMMA literalField)*;
literalField : fieldName COLON element;
fieldName : ident | number;
expression : assignmentExpression;
expressionList: assignmentExpression (COMMA assignmentExpression)*;
assignmentExpression: conditionalExpression (assignmentOperator assignmentExpression)*;
assignmentOperator : ASSIGN
| STAR_ASSIGN
| DIV_ASSIGN
| MOD_ASSIGN
| PLUS_ASSIGN
| MINUS_ASSIGN
| SL_ASSIGN
| BSR_ASSIGN
| BAND_ASSIGN
| BXOR_ASSIGN
| BOR_ASSIGN
| LAND_ASSIGN
| LOR_ASSIGN
;
conditionalExpression: logicalOrExpression (QUESTION conditionalSubExpression)?;
conditionalSubExpression: assignmentExpression COLON assignmentExpression;
logicalOrExpression : logicalAndExpression (logicalOrOperator logicalAndExpression)*;
logicalOrOperator : LOR | OR;
logicalAndExpression : bitwiseOrExpression (logicalAndOperator bitwiseOrExpression)*;
logicalAndOperator : LAND | AND;
bitwiseOrExpression : bitwiseXorExpression (BOR bitwiseXorExpression)*;
bitwiseXorExpression : bitwiseAndExpression (BXOR bitwiseAndExpression)*;
bitwiseAndExpression : equalityExpression (BAND equalityExpression)*;
equalityExpression: relationalExpression (equalityOperator relationalExpression)*;
equalityOperator: STRICT_EQUAL | STRICT_NOT_EQUAL| NOT_EQUAL | EQUAL;
relationalExpression: shiftExpression (relationalOperator shiftExpression)*;
relationalOperator : LT | GT | LE | GE | IS | AS | INSTANCEOF;
shiftExpression : additiveExpression (shiftOperator additiveExpression)*;
shiftOperator : SL | SR | BSR;
additiveExpression: multiplicativeExpression (additiveOperator multiplicativeExpression)*;
additiveOperator : PLUS | MINUS;
multiplicativeExpression: unaryExpression (multiplicativeOperator unaryExpression)*;
multiplicativeOperator : STAR | DIV | MOD ;
unaryExpression: INC | DEC | MINUS | PLUS | unaryExpressionNotPlusMinus;
unaryExpressionNotPlusMinus : DELETE postfixExpression |
VOID unaryExpression
| TYPEOF unaryExpression
| LNOT unaryExpression
| BNOT unaryExpression
| postfixExpression;
postfixExpression: (primaryExpression
| propOrIdent
| LBRACK expression RBRACK
| E4X_DESC qualifiedIdentifier
| e4xAttributeIdentifier
| DOT STAR
| arguments)*
(INC | DEC)?
;
e4xAttributeIdentifier : E4X_ATTRI (
qualifiedIdent
| STAR
| LBRACK expression RBRACK);
primaryExpression :
UNDEFINED
| constant
| arrayLiteral
| objectLiteral
| functionExpression
| newExpression
| encapsulatedExpression
| e4xAttributeIdentifier
| qualifiedIdent;
propOrIdent : qualifiedIdent;
constant : xmlLiteral
| regexpLiteral
| number
| STRING_LITERAL
| TRUE
| FALSE
| NULL
;
number : HEX_LITERAL
| DECIMAL_LITERAL
| OCTAL_LITERAL
| FLOAT_LITERAL;
//Need to handle island grammar for xml literals
// and regexp literals within
//as code.
xmlLiteral : STRING_LITERAL;
regexpLiteral : STRING_LITERAL;
newExpression: NEW fullNewSubexpression;
fullNewSubexpression : primaryExpression
//Need to handle this.
// |( (DOT)=> d=DOT qualifiedIdent -> ^(PROPERTY_OR_IDENTIFIER[$d] $fullNewSubexpression qualifiedIdent)
// | brackets)*
;
propertyOperator : DOT qualifiedIdent
| brackets;
brackets : LBRACK expressionList RBRACK ;
superExpression : SUPER arguments?;
encapsulatedExpression : LPAREN assignmentExpression RPAREN;
functionSignature : parameterDeclarationList typeExpression?;
functionCommon : functionSignature (block)*;
functionExpression : FUNCTION IDENT? functionCommon;
//Lexer
semi : SEMI;
ident
: IDENT
| USE IDENT
| XML IDENT
| DYNAMIC IDENT
| NAMESPACE IDENT
| IS IDENT
| AS IDENT
| GET IDENT
| SET IDENT
;
PACKAGE : 'package';
PUBLIC : 'public';
PRIVATE : 'private';
PROTECTED : 'protected';
INTERNAL : 'internal';
OVERRIDE : 'override';
FUNCTION : 'function';
EXTENDS : 'extends';
IMPLEMENTS : 'implements';
VAR : 'var';
STATIC : 'static';
IF : 'if';
IMPORT : 'import';
FOR : 'for';
EACH : 'each';
IN : 'in';
WHILE : 'while';
DO : 'do';
SWITCH : 'switch';
CASE : 'case';
DEFAULT : 'default';
ELSE : 'else';
CONST : 'const';
CLASS : 'class';
INTERFACE : 'interface';
TRUE : 'true';
FALSE : 'false';
DYNAMIC : 'dynamic';
USE : 'use';
XML : 'xml';
NAMESPACE : 'namespace';
IS : 'is';
AS : 'as';
GET : 'get';
SET : 'set';
WITH : 'with';
RETURN : 'return';
CONTINUE : 'continue';
BREAK : 'break';
NULL : 'null';
NEW : 'new';
SUPER : 'super';
INSTANCEOF : 'instanceof';
DELETE : 'delete';
VOID : 'void';
TYPEOF : 'typeof';
TRY : 'try';
CATCH : 'catch';
FINALLY : 'finally';
UNDEFINED : 'undefined';
THROW : 'throw';
FINAL : 'final';
// OPERATORS
QUESTION : '?' ;
LPAREN : '(' ;
RPAREN : ')' ;
LBRACK : '[' ;
RBRACK : ']' ;
LCURLY : '{' ;
RCURLY : '}' ;
COLON : ':' ;
DBL_COLON : '::' ;
COMMA : ',' ;
ASSIGN : '=' ;
EQUAL : '==' ;
STRICT_EQUAL : '===' ;
LNOT : '!' ;
BNOT : '~' ;
NOT_EQUAL : '!=' ;
STRICT_NOT_EQUAL : '!==' ;
DIV : '/' ;
DIV_ASSIGN : '/=' ;
PLUS : '+' ;
PLUS_ASSIGN : '+=' ;
INC : '++' ;
MINUS : '-' ;
MINUS_ASSIGN : '-=' ;
DEC : '--' ;
STAR : '*' ;
STAR_ASSIGN : '*=' ;
MOD : '%' ;
MOD_ASSIGN : '%=' ;
SR : '>>' ;
SR_ASSIGN : '>>=' ;
BSR : '>>>' ;
BSR_ASSIGN : '>>>=' ;
GE : '>=' ;
GT : '>' ;
SL : '<<' ;
SL_ASSIGN : '<<=' ;
LE : '<=' ;
LT : '<' ;
BXOR : '^' ;
BXOR_ASSIGN : '^=' ;
BOR : '|' ;
BOR_ASSIGN : '|=' ;
LOR : '||' ;
BAND : '&' ;
BAND_ASSIGN : '&=' ;
LAND : '&&' ;
LAND_ASSIGN : '&&=' ;
LOR_ASSIGN : '||=' ;
E4X_ATTRI : '@' ;
SEMI : ';' ;
DOT : '.' ;
E4X_DESC : '..' ;
REST : '...' ;
IDENT
: UNICODE_IDENTIFIER_START
UNICODE_IDENTIFIER_PART*
;
// The UNICODE_IDENTIFIER_START and UNICODE_IDENTIFIER_PART rules where machine-
// generated by testing all characters from \0000 to \ffff using the methods
// of the UCharacter class from the ICU framework.
fragment UNICODE_IDENTIFIER_START
: '\u0041'..'\u005a' | '\u005f' | '\u0061'..'\u007a' |
'\u00aa' | '\u00b5' | '\u00ba' | '\u00c0'..'\u00d6' |
'\u00d8'..'\u00f6' | '\u00f8'..'\u02c1' | '\u02c6'..'\u02d1' |
'\u02e0'..'\u02e4' | '\u02ee' | '\u037a'..'\u037d' | '\u0386' |
'\u0388'..'\u038a' | '\u038c' | '\u038e'..'\u03a1' |
'\u03a3'..'\u03ce' | '\u03d0'..'\u03f5' | '\u03f7'..'\u0481' |
'\u048a'..'\u0513' | '\u0531'..'\u0556' | '\u0559' |
'\u0561'..'\u0587' | '\u05d0'..'\u05ea' | '\u05f0'..'\u05f2' |
'\u0621'..'\u063a' | '\u0640'..'\u064a' | '\u066e'..'\u066f' |
'\u0671'..'\u06d3' | '\u06d5' | '\u06e5'..'\u06e6' |
'\u06ee'..'\u06ef' | '\u06fa'..'\u06fc' | '\u06ff' | '\u0710' |
'\u0712'..'\u072f' | '\u074d'..'\u076d' | '\u0780'..'\u07a5' |
'\u07b1' | '\u07ca'..'\u07ea' | '\u07f4'..'\u07f5' | '\u07fa' |
'\u0904'..'\u0939' | '\u093d' | '\u0950' | '\u0958'..'\u0961' |
'\u097b'..'\u097f' | '\u0985'..'\u098c' | '\u098f'..'\u0990' |
'\u0993'..'\u09a8' | '\u09aa'..'\u09b0' | '\u09b2' |
'\u09b6'..'\u09b9' | '\u09bd' | '\u09ce' | '\u09dc'..'\u09dd' |
'\u09df'..'\u09e1' | '\u09f0'..'\u09f1' | '\u0a05'..'\u0a0a' |
'\u0a0f'..'\u0a10' | '\u0a13'..'\u0a28' | '\u0a2a'..'\u0a30' |
'\u0a32'..'\u0a33' | '\u0a35'..'\u0a36' | '\u0a38'..'\u0a39' |
'\u0a59'..'\u0a5c' | '\u0a5e' | '\u0a72'..'\u0a74' |
'\u0a85'..'\u0a8d' | '\u0a8f'..'\u0a91' | '\u0a93'..'\u0aa8' |
'\u0aaa'..'\u0ab0' | '\u0ab2'..'\u0ab3' | '\u0ab5'..'\u0ab9' |
'\u0abd' | '\u0ad0' | '\u0ae0'..'\u0ae1' | '\u0b05'..'\u0b0c' |
'\u0b0f'..'\u0b10' | '\u0b13'..'\u0b28' | '\u0b2a'..'\u0b30' |
'\u0b32'..'\u0b33' | '\u0b35'..'\u0b39' | '\u0b3d' |
'\u0b5c'..'\u0b5d' | '\u0b5f'..'\u0b61' | '\u0b71' | '\u0b83' |
'\u0b85'..'\u0b8a' | '\u0b8e'..'\u0b90' | '\u0b92'..'\u0b95' |
'\u0b99'..'\u0b9a' | '\u0b9c' | '\u0b9e'..'\u0b9f' |
'\u0ba3'..'\u0ba4' | '\u0ba8'..'\u0baa' | '\u0bae'..'\u0bb9' |
'\u0c05'..'\u0c0c' | '\u0c0e'..'\u0c10' | '\u0c12'..'\u0c28' |
'\u0c2a'..'\u0c33' | '\u0c35'..'\u0c39' | '\u0c60'..'\u0c61' |
'\u0c85'..'\u0c8c' | '\u0c8e'..'\u0c90' | '\u0c92'..'\u0ca8' |
'\u0caa'..'\u0cb3' | '\u0cb5'..'\u0cb9' | '\u0cbd' | '\u0cde' |
'\u0ce0'..'\u0ce1' | '\u0d05'..'\u0d0c' | '\u0d0e'..'\u0d10' |
'\u0d12'..'\u0d28' | '\u0d2a'..'\u0d39' | '\u0d60'..'\u0d61' |
'\u0d85'..'\u0d96' | '\u0d9a'..'\u0db1' | '\u0db3'..'\u0dbb' |
'\u0dbd' | '\u0dc0'..'\u0dc6' | '\u0e01'..'\u0e30' |
'\u0e32'..'\u0e33' | '\u0e40'..'\u0e46' | '\u0e81'..'\u0e82' |
'\u0e84' | '\u0e87'..'\u0e88' | '\u0e8a' | '\u0e8d' |
'\u0e94'..'\u0e97' | '\u0e99'..'\u0e9f' | '\u0ea1'..'\u0ea3' |
'\u0ea5' | '\u0ea7' | '\u0eaa'..'\u0eab' | '\u0ead'..'\u0eb0' |
'\u0eb2'..'\u0eb3' | '\u0ebd' | '\u0ec0'..'\u0ec4' | '\u0ec6' |
'\u0edc'..'\u0edd' | '\u0f00' | '\u0f40'..'\u0f47' |
'\u0f49'..'\u0f6a' | '\u0f88'..'\u0f8b' | '\u1000'..'\u1021' |
'\u1023'..'\u1027' | '\u1029'..'\u102a' | '\u1050'..'\u1055' |
'\u10a0'..'\u10c5' | '\u10d0'..'\u10fa' | '\u10fc' |
'\u1100'..'\u1159' | '\u115f'..'\u11a2' | '\u11a8'..'\u11f9' |
'\u1200'..'\u1248' | '\u124a'..'\u124d' | '\u1250'..'\u1256' |
'\u1258' | '\u125a'..'\u125d' | '\u1260'..'\u1288' |
'\u128a'..'\u128d' | '\u1290'..'\u12b0' | '\u12b2'..'\u12b5' |
'\u12b8'..'\u12be' | '\u12c0' | '\u12c2'..'\u12c5' |
'\u12c8'..'\u12d6' | '\u12d8'..'\u1310' | '\u1312'..'\u1315' |
'\u1318'..'\u135a' | '\u1380'..'\u138f' | '\u13a0'..'\u13f4' |
'\u1401'..'\u166c' | '\u166f'..'\u1676' | '\u1681'..'\u169a' |
'\u16a0'..'\u16ea' | '\u16ee'..'\u16f0' | '\u1700'..'\u170c' |
'\u170e'..'\u1711' | '\u1720'..'\u1731' | '\u1740'..'\u1751' |
'\u1760'..'\u176c' | '\u176e'..'\u1770' | '\u1780'..'\u17b3' |
'\u17d7' | '\u17dc' | '\u1820'..'\u1877' | '\u1880'..'\u18a8' |
'\u1900'..'\u191c' | '\u1950'..'\u196d' | '\u1970'..'\u1974' |
'\u1980'..'\u19a9' | '\u19c1'..'\u19c7' | '\u1a00'..'\u1a16' |
'\u1b05'..'\u1b33' | '\u1b45'..'\u1b4b' | '\u1d00'..'\u1dbf' |
'\u1e00'..'\u1e9b' | '\u1ea0'..'\u1ef9' | '\u1f00'..'\u1f15' |
'\u1f18'..'\u1f1d' | '\u1f20'..'\u1f45' | '\u1f48'..'\u1f4d' |
'\u1f50'..'\u1f57' | '\u1f59' | '\u1f5b' | '\u1f5d' |
'\u1f5f'..'\u1f7d' | '\u1f80'..'\u1fb4' | '\u1fb6'..'\u1fbc' |
'\u1fbe' | '\u1fc2'..'\u1fc4' | '\u1fc6'..'\u1fcc' |
'\u1fd0'..'\u1fd3' | '\u1fd6'..'\u1fdb' | '\u1fe0'..'\u1fec' |
'\u1ff2'..'\u1ff4' | '\u1ff6'..'\u1ffc' | '\u2071' | '\u207f' |
'\u2090'..'\u2094' | '\u2102' | '\u2107' | '\u210a'..'\u2113' |
'\u2115' | '\u2119'..'\u211d' | '\u2124' | '\u2126' | '\u2128'
| '\u212a'..'\u212d' | '\u212f'..'\u2139' | '\u213c'..'\u213f'
| '\u2145'..'\u2149' | '\u214e' | '\u2160'..'\u2184' |
'\u2c00'..'\u2c2e' | '\u2c30'..'\u2c5e' | '\u2c60'..'\u2c6c' |
'\u2c74'..'\u2c77' | '\u2c80'..'\u2ce4' | '\u2d00'..'\u2d25' |
'\u2d30'..'\u2d65' | '\u2d6f' | '\u2d80'..'\u2d96' |
'\u2da0'..'\u2da6' | '\u2da8'..'\u2dae' | '\u2db0'..'\u2db6' |
'\u2db8'..'\u2dbe' | '\u2dc0'..'\u2dc6' | '\u2dc8'..'\u2dce' |
'\u2dd0'..'\u2dd6' | '\u2dd8'..'\u2dde' | '\u3005'..'\u3007' |
'\u3021'..'\u3029' | '\u3031'..'\u3035' | '\u3038'..'\u303c' |
'\u3041'..'\u3096' | '\u309d'..'\u309f' | '\u30a1'..'\u30fa' |
'\u30fc'..'\u30ff' | '\u3105'..'\u312c' | '\u3131'..'\u318e' |
'\u31a0'..'\u31b7' | '\u31f0'..'\u31ff' | '\u3400'..'\u4db5' |
'\u4e00'..'\u9fbb' | '\ua000'..'\ua48c' | '\ua717'..'\ua71a' |
'\ua800'..'\ua801' | '\ua803'..'\ua805' | '\ua807'..'\ua80a' |
'\ua80c'..'\ua822' | '\ua840'..'\ua873' | '\uac00'..'\ud7a3' |
'\uf900'..'\ufa2d' | '\ufa30'..'\ufa6a' | '\ufa70'..'\ufad9' |
'\ufb00'..'\ufb06' | '\ufb13'..'\ufb17' | '\ufb1d' |
'\ufb1f'..'\ufb28' | '\ufb2a'..'\ufb36' | '\ufb38'..'\ufb3c' |
'\ufb3e' | '\ufb40'..'\ufb41' | '\ufb43'..'\ufb44' |
'\ufb46'..'\ufbb1' | '\ufbd3'..'\ufd3d' | '\ufd50'..'\ufd8f' |
'\ufd92'..'\ufdc7' | '\ufdf0'..'\ufdfb' | '\ufe70'..'\ufe74' |
'\ufe76'..'\ufefc' | '\uff21'..'\uff3a' | '\uff41'..'\uff5a' |
'\uff66'..'\uffbe' | '\uffc2'..'\uffc7' | '\uffca'..'\uffcf' |
'\uffd2'..'\uffd7' | '\uffda'..'\uffdc'
;
fragment UNICODE_IDENTIFIER_PART
: '\u0000'..'\u0008' | '\u000e'..'\u001b' |
'\u0030'..'\u0039' | '\u0041'..'\u005a' | '\u005f' |
'\u0061'..'\u007a' | '\u007f'..'\u009f' | '\u00aa' | '\u00ad' |
'\u00b5' | '\u00ba' | '\u00c0'..'\u00d6' | '\u00d8'..'\u00f6' |
'\u00f8'..'\u02c1' | '\u02c6'..'\u02d1' | '\u02e0'..'\u02e4' |
'\u02ee' | '\u0300'..'\u036f' | '\u037a'..'\u037d' | '\u0386' |
'\u0388'..'\u038a' | '\u038c' | '\u038e'..'\u03a1' |
'\u03a3'..'\u03ce' | '\u03d0'..'\u03f5' | '\u03f7'..'\u0481' |
'\u0483'..'\u0486' | '\u048a'..'\u0513' | '\u0531'..'\u0556' |
'\u0559' | '\u0561'..'\u0587' | '\u0591'..'\u05bd' | '\u05bf' |
'\u05c1'..'\u05c2' | '\u05c4'..'\u05c5' | '\u05c7' |
'\u05d0'..'\u05ea' | '\u05f0'..'\u05f2' | '\u0600'..'\u0603' |
'\u0610'..'\u0615' | '\u0621'..'\u063a' | '\u0640'..'\u065e' |
'\u0660'..'\u0669' | '\u066e'..'\u06d3' | '\u06d5'..'\u06dd' |
'\u06df'..'\u06e8' | '\u06ea'..'\u06fc' | '\u06ff' |
'\u070f'..'\u074a' | '\u074d'..'\u076d' | '\u0780'..'\u07b1' |
'\u07c0'..'\u07f5' | '\u07fa' | '\u0901'..'\u0939' |
'\u093c'..'\u094d' | '\u0950'..'\u0954' | '\u0958'..'\u0963' |
'\u0966'..'\u096f' | '\u097b'..'\u097f' | '\u0981'..'\u0983' |
'\u0985'..'\u098c' | '\u098f'..'\u0990' | '\u0993'..'\u09a8' |
'\u09aa'..'\u09b0' | '\u09b2' | '\u09b6'..'\u09b9' |
'\u09bc'..'\u09c4' | '\u09c7'..'\u09c8' | '\u09cb'..'\u09ce' |
'\u09d7' | '\u09dc'..'\u09dd' | '\u09df'..'\u09e3' |
'\u09e6'..'\u09f1' | '\u0a01'..'\u0a03' | '\u0a05'..'\u0a0a' |
'\u0a0f'..'\u0a10' | '\u0a13'..'\u0a28' | '\u0a2a'..'\u0a30' |
'\u0a32'..'\u0a33' | '\u0a35'..'\u0a36' | '\u0a38'..'\u0a39' |
'\u0a3c' | '\u0a3e'..'\u0a42' | '\u0a47'..'\u0a48' |
'\u0a4b'..'\u0a4d' | '\u0a59'..'\u0a5c' | '\u0a5e' |
'\u0a66'..'\u0a74' | '\u0a81'..'\u0a83' | '\u0a85'..'\u0a8d' |
'\u0a8f'..'\u0a91' | '\u0a93'..'\u0aa8' | '\u0aaa'..'\u0ab0' |
'\u0ab2'..'\u0ab3' | '\u0ab5'..'\u0ab9' | '\u0abc'..'\u0ac5' |
'\u0ac7'..'\u0ac9' | '\u0acb'..'\u0acd' | '\u0ad0' |
'\u0ae0'..'\u0ae3' | '\u0ae6'..'\u0aef' | '\u0b01'..'\u0b03' |
'\u0b05'..'\u0b0c' | '\u0b0f'..'\u0b10' | '\u0b13'..'\u0b28' |
'\u0b2a'..'\u0b30' | '\u0b32'..'\u0b33' | '\u0b35'..'\u0b39' |
'\u0b3c'..'\u0b43' | '\u0b47'..'\u0b48' | '\u0b4b'..'\u0b4d' |
'\u0b56'..'\u0b57' | '\u0b5c'..'\u0b5d' | '\u0b5f'..'\u0b61' |
'\u0b66'..'\u0b6f' | '\u0b71' | '\u0b82'..'\u0b83' |
'\u0b85'..'\u0b8a' | '\u0b8e'..'\u0b90' | '\u0b92'..'\u0b95' |
'\u0b99'..'\u0b9a' | '\u0b9c' | '\u0b9e'..'\u0b9f' |
'\u0ba3'..'\u0ba4' | '\u0ba8'..'\u0baa' | '\u0bae'..'\u0bb9' |
'\u0bbe'..'\u0bc2' | '\u0bc6'..'\u0bc8' | '\u0bca'..'\u0bcd' |
'\u0bd7' | '\u0be6'..'\u0bef' | '\u0c01'..'\u0c03' |
'\u0c05'..'\u0c0c' | '\u0c0e'..'\u0c10' | '\u0c12'..'\u0c28' |
'\u0c2a'..'\u0c33' | '\u0c35'..'\u0c39' | '\u0c3e'..'\u0c44' |
'\u0c46'..'\u0c48' | '\u0c4a'..'\u0c4d' | '\u0c55'..'\u0c56' |
'\u0c60'..'\u0c61' | '\u0c66'..'\u0c6f' | '\u0c82'..'\u0c83' |
'\u0c85'..'\u0c8c' | '\u0c8e'..'\u0c90' | '\u0c92'..'\u0ca8' |
'\u0caa'..'\u0cb3' | '\u0cb5'..'\u0cb9' | '\u0cbc'..'\u0cc4' |
'\u0cc6'..'\u0cc8' | '\u0cca'..'\u0ccd' | '\u0cd5'..'\u0cd6' |
'\u0cde' | '\u0ce0'..'\u0ce3' | '\u0ce6'..'\u0cef' |
'\u0d02'..'\u0d03' | '\u0d05'..'\u0d0c' | '\u0d0e'..'\u0d10' |
'\u0d12'..'\u0d28' | '\u0d2a'..'\u0d39' | '\u0d3e'..'\u0d43' |
'\u0d46'..'\u0d48' | '\u0d4a'..'\u0d4d' | '\u0d57' |
'\u0d60'..'\u0d61' | '\u0d66'..'\u0d6f' | '\u0d82'..'\u0d83' |
'\u0d85'..'\u0d96' | '\u0d9a'..'\u0db1' | '\u0db3'..'\u0dbb' |
'\u0dbd' | '\u0dc0'..'\u0dc6' | '\u0dca' | '\u0dcf'..'\u0dd4' |
'\u0dd6' | '\u0dd8'..'\u0ddf' | '\u0df2'..'\u0df3' |
'\u0e01'..'\u0e3a' | '\u0e40'..'\u0e4e' | '\u0e50'..'\u0e59' |
'\u0e81'..'\u0e82' | '\u0e84' | '\u0e87'..'\u0e88' | '\u0e8a' |
'\u0e8d' | '\u0e94'..'\u0e97' | '\u0e99'..'\u0e9f' |
'\u0ea1'..'\u0ea3' | '\u0ea5' | '\u0ea7' | '\u0eaa'..'\u0eab' |
'\u0ead'..'\u0eb9' | '\u0ebb'..'\u0ebd' | '\u0ec0'..'\u0ec4' |
'\u0ec6' | '\u0ec8'..'\u0ecd' | '\u0ed0'..'\u0ed9' |
'\u0edc'..'\u0edd' | '\u0f00' | '\u0f18'..'\u0f19' |
'\u0f20'..'\u0f29' | '\u0f35' | '\u0f37' | '\u0f39' |
'\u0f3e'..'\u0f47' | '\u0f49'..'\u0f6a' | '\u0f71'..'\u0f84' |
'\u0f86'..'\u0f8b' | '\u0f90'..'\u0f97' | '\u0f99'..'\u0fbc' |
'\u0fc6' | '\u1000'..'\u1021' | '\u1023'..'\u1027' |
'\u1029'..'\u102a' | '\u102c'..'\u1032' | '\u1036'..'\u1039' |
'\u1040'..'\u1049' | '\u1050'..'\u1059' | '\u10a0'..'\u10c5' |
'\u10d0'..'\u10fa' | '\u10fc' | '\u1100'..'\u1159' |
'\u115f'..'\u11a2' | '\u11a8'..'\u11f9' | '\u1200'..'\u1248' |
'\u124a'..'\u124d' | '\u1250'..'\u1256' | '\u1258' |
'\u125a'..'\u125d' | '\u1260'..'\u1288' | '\u128a'..'\u128d' |
'\u1290'..'\u12b0' | '\u12b2'..'\u12b5' | '\u12b8'..'\u12be' |
'\u12c0' | '\u12c2'..'\u12c5' | '\u12c8'..'\u12d6' |
'\u12d8'..'\u1310' | '\u1312'..'\u1315' | '\u1318'..'\u135a' |
'\u135f' | '\u1380'..'\u138f' | '\u13a0'..'\u13f4' |
'\u1401'..'\u166c' | '\u166f'..'\u1676' | '\u1681'..'\u169a' |
'\u16a0'..'\u16ea' | '\u16ee'..'\u16f0' | '\u1700'..'\u170c' |
'\u170e'..'\u1714' | '\u1720'..'\u1734' | '\u1740'..'\u1753' |
'\u1760'..'\u176c' | '\u176e'..'\u1770' | '\u1772'..'\u1773' |
'\u1780'..'\u17d3' | '\u17d7' | '\u17dc'..'\u17dd' |
'\u17e0'..'\u17e9' | '\u180b'..'\u180d' | '\u1810'..'\u1819' |
'\u1820'..'\u1877' | '\u1880'..'\u18a9' | '\u1900'..'\u191c' |
'\u1920'..'\u192b' | '\u1930'..'\u193b' | '\u1946'..'\u196d' |
'\u1970'..'\u1974' | '\u1980'..'\u19a9' | '\u19b0'..'\u19c9' |
'\u19d0'..'\u19d9' | '\u1a00'..'\u1a1b' | '\u1b00'..'\u1b4b' |
'\u1b50'..'\u1b59' | '\u1b6b'..'\u1b73' | '\u1d00'..'\u1dca' |
'\u1dfe'..'\u1e9b' | '\u1ea0'..'\u1ef9' | '\u1f00'..'\u1f15' |
'\u1f18'..'\u1f1d' | '\u1f20'..'\u1f45' | '\u1f48'..'\u1f4d' |
'\u1f50'..'\u1f57' | '\u1f59' | '\u1f5b' | '\u1f5d' |
'\u1f5f'..'\u1f7d' | '\u1f80'..'\u1fb4' | '\u1fb6'..'\u1fbc' |
'\u1fbe' | '\u1fc2'..'\u1fc4' | '\u1fc6'..'\u1fcc' |
'\u1fd0'..'\u1fd3' | '\u1fd6'..'\u1fdb' | '\u1fe0'..'\u1fec' |
'\u1ff2'..'\u1ff4' | '\u1ff6'..'\u1ffc' | '\u200b'..'\u200f' |
'\u202a'..'\u202e' | '\u203f'..'\u2040' | '\u2054' |
'\u2060'..'\u2063' | '\u206a'..'\u206f' | '\u2071' | '\u207f' |
'\u2090'..'\u2094' | '\u20d0'..'\u20dc' | '\u20e1' |
'\u20e5'..'\u20ef' | '\u2102' | '\u2107' | '\u210a'..'\u2113' |
'\u2115' | '\u2119'..'\u211d' | '\u2124' | '\u2126' | '\u2128'
| '\u212a'..'\u212d' | '\u212f'..'\u2139' | '\u213c'..'\u213f'
| '\u2145'..'\u2149' | '\u214e' | '\u2160'..'\u2184' |
'\u2c00'..'\u2c2e' | '\u2c30'..'\u2c5e' | '\u2c60'..'\u2c6c' |
'\u2c74'..'\u2c77' | '\u2c80'..'\u2ce4' | '\u2d00'..'\u2d25' |
'\u2d30'..'\u2d65' | '\u2d6f' | '\u2d80'..'\u2d96' |
'\u2da0'..'\u2da6' | '\u2da8'..'\u2dae' | '\u2db0'..'\u2db6' |
'\u2db8'..'\u2dbe' | '\u2dc0'..'\u2dc6' | '\u2dc8'..'\u2dce' |
'\u2dd0'..'\u2dd6' | '\u2dd8'..'\u2dde' | '\u3005'..'\u3007' |
'\u3021'..'\u302f' | '\u3031'..'\u3035' | '\u3038'..'\u303c' |
'\u3041'..'\u3096' | '\u3099'..'\u309a' | '\u309d'..'\u309f' |
'\u30a1'..'\u30fa' | '\u30fc'..'\u30ff' | '\u3105'..'\u312c' |
'\u3131'..'\u318e' | '\u31a0'..'\u31b7' | '\u31f0'..'\u31ff' |
'\u3400'..'\u4db5' | '\u4e00'..'\u9fbb' | '\ua000'..'\ua48c' |
'\ua717'..'\ua71a' | '\ua800'..'\ua827' | '\ua840'..'\ua873' |
'\uac00'..'\ud7a3' | '\uf900'..'\ufa2d' | '\ufa30'..'\ufa6a' |
'\ufa70'..'\ufad9' | '\ufb00'..'\ufb06' | '\ufb13'..'\ufb17' |
'\ufb1d'..'\ufb28' | '\ufb2a'..'\ufb36' | '\ufb38'..'\ufb3c' |
'\ufb3e' | '\ufb40'..'\ufb41' | '\ufb43'..'\ufb44' |
'\ufb46'..'\ufbb1' | '\ufbd3'..'\ufd3d' | '\ufd50'..'\ufd8f' |
'\ufd92'..'\ufdc7' | '\ufdf0'..'\ufdfb' | '\ufe00'..'\ufe0f' |
'\ufe20'..'\ufe23' | '\ufe33'..'\ufe34' | '\ufe4d'..'\ufe4f' |
'\ufe70'..'\ufe74' | '\ufe76'..'\ufefc' | '\ufeff' |
'\uff10'..'\uff19' | '\uff21'..'\uff3a' | '\uff3f' |
'\uff41'..'\uff5a' | '\uff66'..'\uffbe' | '\uffc2'..'\uffc7' |
'\uffca'..'\uffcf' | '\uffd2'..'\uffd7' | '\uffda'..'\uffdc' |
'\ufff9'..'\ufffb'
;
STRING_LITERAL
: '"' (ESC|~('"'|'\\'|'\n'|'\r'))* '"'
| '\'' (ESC|~('\''|'\\'|'\n'|'\r'))* '\''
;
HEX_LITERAL : '0' ('x'|'X') HEX_DIGIT+ ;
DECIMAL_LITERAL : ('0' | '1'..'9' '0'..'9'*) ;
OCTAL_LITERAL : '0' ('0'..'7')+ ;
FLOAT_LITERAL
: ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
| '.' ('0'..'9')+ EXPONENT?
;
// whitespace -- ignored
WS : [ \r\t\u000C\n]+ -> channel(HIDDEN)
;
NL
: (
'\r' '\n' // DOS
| '\r' // Mac
| '\n' // Unix
)
-> channel(HIDDEN)
;
// skip BOM bytes
BOM : ( '\u00EF' '\u00BB' '\u00BF'
| '\uFEFF'
)
-> channel(HIDDEN)
;
// might be better to filter this out as a preprocessing step
INCLUDE_DIRECTIVE
: '#include'
;
// single-line comments
SL_COMMENT
: '//' (~('\n'|'\r'))* ('\n'|'\r'('\n')?)?
;
// multiple-line comments
ML_COMMENT
: '/*' .*? '*/' -> channel(HIDDEN) // match anything between /* and */
;
fragment EXPONENT
: ('e'|'E') ('+'|'-')? ('0'..'9')+
;
fragment HEX_DIGIT
: ('0'..'9'|'A'..'F'|'a'..'f')
;
fragment OCT_DIGIT
: '0'..'7'
;
fragment ESC
: CTRLCHAR_ESC
| UNICODE_ESC
| OCTAL_ESC
;
fragment CTRLCHAR_ESC
: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
;
fragment OCTAL_ESC
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
| '\\' ('0'..'7') ('0'..'7')
| '\\' ('0'..'7')
;
fragment UNICODE_ESC
: '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
; | 31,021 | ANTLR | .g4 | 785 | 35.243312 | 105 | 0.57542 | dservgun/as3g4 | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 24b68f37b579e2be0c34cd0c283f4e2e7b508f9b421f5f51a9cb0c0a88182609 | false | false | false | false |
130 | PlSqlLexer.g4 | sqlest_sql-parser/src/main/resources/org/ej/parser/sql/oracle/PlSqlLexer.g4 | /**
* Oracle(c) PL/SQL 11g Parser
*
* Copyright (c) 2009-2011 Alexandre Porcelli <[email protected]>
* Copyright (c) 2015-2017 Ivan Kochurkin (KvanTTT, [email protected], Positive Technologies).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
lexer grammar PlSqlLexer;
// ABORT: 'ABORT';
// ABS: 'ABS';
// ACCESS: 'ACCESS';
// ACCESSED: 'ACCESSED';
// ACCOUNT: 'ACCOUNT';
// ACL: 'ACL';
// ACOS: 'ACOS';
// ACTION: 'ACTION';
// ACTIONS: 'ACTIONS';
// ACTIVATE: 'ACTIVATE';
// ACTIVE: 'ACTIVE';
// ACTIVE_COMPONENT: 'ACTIVE_COMPONENT';
// ACTIVE_DATA: 'ACTIVE_DATA';
// ACTIVE_FUNCTION: 'ACTIVE_FUNCTION';
// ACTIVE_TAG: 'ACTIVE_TAG';
// ACTIVITY: 'ACTIVITY';
// ADAPTIVE_PLAN: 'ADAPTIVE_PLAN';
ADD: 'ADD';
// ADD_COLUMN: 'ADD_COLUMN';
// ADD_GROUP: 'ADD_GROUP';
// ADD_MONTHS: 'ADD_MONTHS';
// ADJ_DATE: 'ADJ_DATE';
// ADMIN: 'ADMIN';
// ADMINISTER: 'ADMINISTER';
// ADMINISTRATOR: 'ADMINISTRATOR';
// ADVANCED: 'ADVANCED';
// ADVISE: 'ADVISE';
// ADVISOR: 'ADVISOR';
// AFD_DISKSTRING: 'AFD_DISKSTRING';
AFTER: 'AFTER';
AGENT: 'AGENT';
AGGREGATE: 'AGGREGATE';
A_LETTER: 'A';
// ALIAS: 'ALIAS';
ALL: 'ALL';
// ALLOCATE: 'ALLOCATE';
// ALLOW: 'ALLOW';
// ALL_ROWS: 'ALL_ROWS';
ALTER: 'ALTER';
// ALWAYS: 'ALWAYS';
ANALYZE: 'ANALYZE';
// ANCILLARY: 'ANCILLARY';
AND: 'AND';
// AND_EQUAL: 'AND_EQUAL';
// ANOMALY: 'ANOMALY';
// ANSI_REARCH: 'ANSI_REARCH';
// ANTIJOIN: 'ANTIJOIN';
ANY: 'ANY';
// ANYSCHEMA: 'ANYSCHEMA';
// APPEND: 'APPEND';
// APPENDCHILDXML: 'APPENDCHILDXML';
// APPEND_VALUES: 'APPEND_VALUES';
// APPLICATION: 'APPLICATION';
// APPLY: 'APPLY';
// APPROX_COUNT_DISTINCT: 'APPROX_COUNT_DISTINCT';
// ARCHIVAL: 'ARCHIVAL';
ARCHIVE: 'ARCHIVE';
// ARCHIVED: 'ARCHIVED';
// ARCHIVELOG: 'ARCHIVELOG';
ARRAY: 'ARRAY';
AS: 'AS';
ASC: 'ASC';
// ASCII: 'ASCII';
// ASCIISTR: 'ASCIISTR';
// ASIN: 'ASIN';
// ASIS: 'ASIS';
// ASSEMBLY: 'ASSEMBLY';
// ASSIGN: 'ASSIGN';
ASSOCIATE: 'ASSOCIATE';
// ASYNC: 'ASYNC';
// ASYNCHRONOUS: 'ASYNCHRONOUS';
// ATAN2: 'ATAN2';
// ATAN: 'ATAN';
AT: 'AT';
ATTRIBUTE: 'ATTRIBUTE';
// ATTRIBUTES: 'ATTRIBUTES';
AUDIT: 'AUDIT';
// AUTHENTICATED: 'AUTHENTICATED';
// AUTHENTICATION: 'AUTHENTICATION';
AUTHID: 'AUTHID';
// AUTHORIZATION: 'AUTHORIZATION';
// AUTOALLOCATE: 'AUTOALLOCATE';
AUTO: 'AUTO';
// AUTOEXTEND: 'AUTOEXTEND';
// AUTO_LOGIN: 'AUTO_LOGIN';
AUTOMATIC: 'AUTOMATIC';
AUTONOMOUS_TRANSACTION: 'AUTONOMOUS_TRANSACTION';
// AUTO_REOPTIMIZE: 'AUTO_REOPTIMIZE';
// AVAILABILITY: 'AVAILABILITY';
// AVRO: 'AVRO';
// BACKGROUND: 'BACKGROUND';
// BACKUP: 'BACKUP';
BASIC: 'BASIC';
// BASICFILE: 'BASICFILE';
BATCH: 'BATCH';
// BATCHSIZE: 'BATCHSIZE';
// BATCH_TABLE_ACCESS_BY_ROWID: 'BATCH_TABLE_ACCESS_BY_ROWID';
// BECOME: 'BECOME';
BEFORE: 'BEFORE';
BEGIN: 'BEGIN';
// BEGINNING: 'BEGINNING';
// BEGIN_OUTLINE_DATA: 'BEGIN_OUTLINE_DATA';
// BEHALF: 'BEHALF';
// BEQUEATH: 'BEQUEATH';
BETWEEN: 'BETWEEN';
BFILE: 'BFILE';
// BFILENAME: 'BFILENAME';
// BIGFILE: 'BIGFILE';
// BINARY: 'BINARY';
BINARY_DOUBLE: 'BINARY_DOUBLE';
// BINARY_DOUBLE_INFINITY: 'BINARY_DOUBLE_INFINITY';
// BINARY_DOUBLE_NAN: 'BINARY_DOUBLE_NAN';
BINARY_FLOAT: 'BINARY_FLOAT';
// BINARY_FLOAT_INFINITY: 'BINARY_FLOAT_INFINITY';
// BINARY_FLOAT_NAN: 'BINARY_FLOAT_NAN';
BINARY_INTEGER: 'BINARY_INTEGER';
// BIND_AWARE: 'BIND_AWARE';
// BINDING: 'BINDING';
// BIN_TO_NUM: 'BIN_TO_NUM';
// BITAND: 'BITAND';
// BITMAP_AND: 'BITMAP_AND';
// BITMAP: 'BITMAP';
// BITMAPS: 'BITMAPS';
// BITMAP_TREE: 'BITMAP_TREE';
// BITS: 'BITS';
BLOB: 'BLOB';
BLOCK: 'BLOCK';
// BLOCK_RANGE: 'BLOCK_RANGE';
// BLOCKS: 'BLOCKS';
// BLOCKSIZE: 'BLOCKSIZE';
BODY: 'BODY';
BOOLEAN: 'BOOLEAN';
BOTH: 'BOTH';
// BOUND: 'BOUND';
// BRANCH: 'BRANCH';
BREADTH: 'BREADTH';
// BROADCAST: 'BROADCAST';
// BSON: 'BSON';
// BUFFER: 'BUFFER';
// BUFFER_CACHE: 'BUFFER_CACHE';
BUFFER_POOL: 'BUFFER_POOL';
// BUILD: 'BUILD';
BULK: 'BULK';
BY: 'BY';
// BYPASS_RECURSIVE_CHECK: 'BYPASS_RECURSIVE_CHECK';
// BYPASS_UJVC: 'BYPASS_UJVC';
BYTE: 'BYTE';
CACHE: 'CACHE';
// CACHE_CB: 'CACHE_CB';
// CACHE_INSTANCES: 'CACHE_INSTANCES';
// CACHE_TEMP_TABLE: 'CACHE_TEMP_TABLE';
// CACHING: 'CACHING';
// CALCULATED: 'CALCULATED';
// CALLBACK: 'CALLBACK';
CALL: 'CALL';
// CANCEL: 'CANCEL';
CANONICAL: 'CANONICAL';
// CAPACITY: 'CAPACITY';
// CARDINALITY: 'CARDINALITY';
CASCADE: 'CASCADE';
CASE: 'CASE';
CAST: 'CAST';
// CATEGORY: 'CATEGORY';
// CDBDEFAULT: 'CDB$DEFAULT';
// CEIL: 'CEIL';
// CELL_FLASH_CACHE: 'CELL_FLASH_CACHE';
// CERTIFICATE: 'CERTIFICATE';
// CFILE: 'CFILE';
// CHAINED: 'CHAINED';
// CHANGE: 'CHANGE';
// CHANGE_DUPKEY_ERROR_INDEX: 'CHANGE_DUPKEY_ERROR_INDEX';
CHARACTER: 'CHARACTER';
CHAR: 'CHAR';
CHAR_CS: 'CHAR_CS';
// CHARTOROWID: 'CHARTOROWID';
// CHECK_ACL_REWRITE: 'CHECK_ACL_REWRITE';
CHECK: 'CHECK';
// CHECKPOINT: 'CHECKPOINT';
// CHILD: 'CHILD';
// CHOOSE: 'CHOOSE';
CHR: 'CHR';
// CHUNK: 'CHUNK';
// CLASS: 'CLASS';
// CLASSIFIER: 'CLASSIFIER';
// CLEANUP: 'CLEANUP';
// CLEAR: 'CLEAR';
C_LETTER: 'C';
// CLIENT: 'CLIENT';
CLOB: 'CLOB';
// CLONE: 'CLONE';
// CLOSE_CACHED_OPEN_CURSORS: 'CLOSE_CACHED_OPEN_CURSORS';
CLOSE: 'CLOSE';
// CLUSTER_BY_ROWID: 'CLUSTER_BY_ROWID';
CLUSTER: 'CLUSTER';
// CLUSTER_DETAILS: 'CLUSTER_DETAILS';
// CLUSTER_DISTANCE: 'CLUSTER_DISTANCE';
// CLUSTER_ID: 'CLUSTER_ID';
// CLUSTERING: 'CLUSTERING';
// CLUSTERING_FACTOR: 'CLUSTERING_FACTOR';
// CLUSTER_PROBABILITY: 'CLUSTER_PROBABILITY';
// CLUSTER_SET: 'CLUSTER_SET';
COALESCE: 'COALESCE';
// COALESCE_SQ: 'COALESCE_SQ';
// COARSE: 'COARSE';
// CO_AUTH_IND: 'CO_AUTH_IND';
// COLD: 'COLD';
COLLECT: 'COLLECT';
// COLUMNAR: 'COLUMNAR';
// COLUMN_AUTH_INDICATOR: 'COLUMN_AUTH_INDICATOR';
COLUMN: 'COLUMN';
COLUMNS: 'COLUMNS';
// COLUMN_STATS: 'COLUMN_STATS';
// COLUMN_VALUE: 'COLUMN_VALUE';
COMMENT: 'COMMENT';
COMMIT: 'COMMIT';
COMMITTED: 'COMMITTED';
// COMMON_DATA: 'COMMON_DATA';
// COMPACT: 'COMPACT';
COMPATIBILITY: 'COMPATIBILITY';
COMPILE: 'COMPILE';
// COMPLETE: 'COMPLETE';
// COMPLIANCE: 'COMPLIANCE';
// COMPONENT: 'COMPONENT';
// COMPONENTS: 'COMPONENTS';
// COMPOSE: 'COMPOSE';
// COMPOSITE: 'COMPOSITE';
// COMPOSITE_LIMIT: 'COMPOSITE_LIMIT';
COMPOUND: 'COMPOUND';
COMPRESS: 'COMPRESS';
COMPUTE: 'COMPUTE';
// CONCAT: 'CONCAT';
// CON_DBID_TO_ID: 'CON_DBID_TO_ID';
// CONDITIONAL: 'CONDITIONAL';
// CONDITION: 'CONDITION';
// CONFIRM: 'CONFIRM';
// CONFORMING: 'CONFORMING';
// CON_GUID_TO_ID: 'CON_GUID_TO_ID';
// CON_ID: 'CON_ID';
// CON_NAME_TO_ID: 'CON_NAME_TO_ID';
// CONNECT_BY_CB_WHR_ONLY: 'CONNECT_BY_CB_WHR_ONLY';
// CONNECT_BY_COMBINE_SW: 'CONNECT_BY_COMBINE_SW';
// CONNECT_BY_COST_BASED: 'CONNECT_BY_COST_BASED';
// CONNECT_BY_ELIM_DUPS: 'CONNECT_BY_ELIM_DUPS';
// CONNECT_BY_FILTERING: 'CONNECT_BY_FILTERING';
// CONNECT_BY_ISCYCLE: 'CONNECT_BY_ISCYCLE';
// CONNECT_BY_ISLEAF: 'CONNECT_BY_ISLEAF';
CONNECT_BY_ROOT: 'CONNECT_BY_ROOT';
CONNECT: 'CONNECT';
// CONNECT_TIME: 'CONNECT_TIME';
// CONSIDER: 'CONSIDER';
// CONSISTENT: 'CONSISTENT';
CONSTANT: 'CONSTANT';
// CONST: 'CONST';
CONSTRAINT: 'CONSTRAINT';
CONSTRAINTS: 'CONSTRAINTS';
CONSTRUCTOR: 'CONSTRUCTOR';
// CONTAINER: 'CONTAINER';
// CONTAINER_DATA: 'CONTAINER_DATA';
// CONTAINERS: 'CONTAINERS';
CONTENT: 'CONTENT';
// CONTENTS: 'CONTENTS';
CONTEXT: 'CONTEXT';
CONTINUE: 'CONTINUE';
// CONTROLFILE: 'CONTROLFILE';
// CON_UID_TO_ID: 'CON_UID_TO_ID';
CONVERT: 'CONVERT';
// COOKIE: 'COOKIE';
// COPY: 'COPY';
// CORR_K: 'CORR_K';
// CORR_S: 'CORR_S';
// CORRUPTION: 'CORRUPTION';
CORRUPT_XID_ALL: 'CORRUPT_XID_ALL';
CORRUPT_XID: 'CORRUPT_XID';
// COS: 'COS';
// COSH: 'COSH';
COST: 'COST';
// COST_XML_QUERY_REWRITE: 'COST_XML_QUERY_REWRITE';
COUNT: 'COUNT';
// COVAR_POP: 'COVAR_POP';
// COVAR_SAMP: 'COVAR_SAMP';
// CPU_COSTING: 'CPU_COSTING';
// CPU_PER_CALL: 'CPU_PER_CALL';
// CPU_PER_SESSION: 'CPU_PER_SESSION';
// CRASH: 'CRASH';
CREATE: 'CREATE';
// CREATE_FILE_DEST: 'CREATE_FILE_DEST';
// CREATE_STORED_OUTLINES: 'CREATE_STORED_OUTLINES';
CREATION: 'CREATION';
// CREDENTIAL: 'CREDENTIAL';
// CRITICAL: 'CRITICAL';
CROSS: 'CROSS';
// CROSSEDITION: 'CROSSEDITION';
// CSCONVERT: 'CSCONVERT';
// CUBE_AJ: 'CUBE_AJ';
CUBE: 'CUBE';
// CUBE_GB: 'CUBE_GB';
// CUBE_SJ: 'CUBE_SJ';
// CUME_DISTM: 'CUME_DISTM';
CURRENT: 'CURRENT';
// CURRENT_DATE: 'CURRENT_DATE';
// CURRENT_SCHEMA: 'CURRENT_SCHEMA';
// CURRENT_TIME: 'CURRENT_TIME';
// CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP';
CURRENT_USER: 'CURRENT_USER';
// CURRENTV: 'CURRENTV';
CURSOR: 'CURSOR';
// CURSOR_SHARING_EXACT: 'CURSOR_SHARING_EXACT';
// CURSOR_SPECIFIC_SEGMENT: 'CURSOR_SPECIFIC_SEGMENT';
CUSTOMDATUM: 'CUSTOMDATUM';
// CV: 'CV';
CYCLE: 'CYCLE';
// DANGLING: 'DANGLING';
DATABASE: 'DATABASE';
DATA: 'DATA';
// DATAFILE: 'DATAFILE';
// DATAFILES: 'DATAFILES';
// DATAMOVEMENT: 'DATAMOVEMENT';
// DATAOBJNO: 'DATAOBJNO';
// DATAOBJ_TO_MAT_PARTITION: 'DATAOBJ_TO_MAT_PARTITION';
// DATAOBJ_TO_PARTITION: 'DATAOBJ_TO_PARTITION';
// DATAPUMP: 'DATAPUMP';
// DATA_SECURITY_REWRITE_LIMIT: 'DATA_SECURITY_REWRITE_LIMIT';
DATE: 'DATE';
// DATE_MODE: 'DATE_MODE';
DAY: 'DAY';
// DAYS: 'DAYS';
// DBA: 'DBA';
// DBA_RECYCLEBIN: 'DBA_RECYCLEBIN';
// DBMS_STATS: 'DBMS_STATS';
DB_ROLE_CHANGE: 'DB_ROLE_CHANGE';
DBTIMEZONE: 'DBTIMEZONE';
// DB_UNIQUE_NAME: 'DB_UNIQUE_NAME';
// DB_VERSION: 'DB_VERSION';
DDL: 'DDL';
// DEALLOCATE: 'DEALLOCATE';
DEBUG: 'DEBUG';
// DEBUGGER: 'DEBUGGER';
DEC: 'DEC';
DECIMAL: 'DECIMAL';
DECLARE: 'DECLARE';
DECOMPOSE: 'DECOMPOSE';
// DECORRELATE: 'DECORRELATE';
// DECR: 'DECR';
DECREMENT: 'DECREMENT';
// DECRYPT: 'DECRYPT';
// DEDUPLICATE: 'DEDUPLICATE';
DEFAULT: 'DEFAULT';
DEFAULTS: 'DEFAULTS';
// DEFERRABLE: 'DEFERRABLE';
DEFERRED: 'DEFERRED';
// DEFINED: 'DEFINED';
// DEFINE: 'DEFINE';
DEFINER: 'DEFINER';
// DEGREE: 'DEGREE';
// DELAY: 'DELAY';
// DELEGATE: 'DELEGATE';
// DELETE_ALL: 'DELETE_ALL';
DELETE: 'DELETE';
// DELETEXML: 'DELETEXML';
// DEMAND: 'DEMAND';
// DENSE_RANKM: 'DENSE_RANKM';
// DEPENDENT: 'DEPENDENT';
DEPTH: 'DEPTH';
// DEQUEUE: 'DEQUEUE';
// DEREF: 'DEREF';
// DEREF_NO_REWRITE: 'DEREF_NO_REWRITE';
DESC: 'DESC';
// DESTROY: 'DESTROY';
// DETACHED: 'DETACHED';
// DETERMINES: 'DETERMINES';
DETERMINISTIC: 'DETERMINISTIC';
// DICTIONARY: 'DICTIONARY';
DIMENSION: 'DIMENSION';
// DIMENSIONS: 'DIMENSIONS';
// DIRECT_LOAD: 'DIRECT_LOAD';
// DIRECTORY: 'DIRECTORY';
// DIRECT_PATH: 'DIRECT_PATH';
// DISABLE_ALL: 'DISABLE_ALL';
DISABLE: 'DISABLE';
// DISABLE_PARALLEL_DML: 'DISABLE_PARALLEL_DML';
// DISABLE_PRESET: 'DISABLE_PRESET';
// DISABLE_RPKE: 'DISABLE_RPKE';
// DISALLOW: 'DISALLOW';
DISASSOCIATE: 'DISASSOCIATE';
// DISCARD: 'DISCARD';
// DISCONNECT: 'DISCONNECT';
// DISK: 'DISK';
// DISKGROUP: 'DISKGROUP';
// DISKS: 'DISKS';
// DISMOUNT: 'DISMOUNT';
DISTINCT: 'DISTINCT';
// DISTINGUISHED: 'DISTINGUISHED';
// DISTRIBUTED: 'DISTRIBUTED';
// DISTRIBUTE: 'DISTRIBUTE';
// DML: 'DML';
// DML_UPDATE: 'DML_UPDATE';
// DOCFIDELITY: 'DOCFIDELITY';
DOCUMENT: 'DOCUMENT';
// DOMAIN_INDEX_FILTER: 'DOMAIN_INDEX_FILTER';
// DOMAIN_INDEX_NO_SORT: 'DOMAIN_INDEX_NO_SORT';
// DOMAIN_INDEX_SORT: 'DOMAIN_INDEX_SORT';
DOUBLE: 'DOUBLE';
// DOWNGRADE: 'DOWNGRADE';
// DRIVING_SITE: 'DRIVING_SITE';
// DROP_COLUMN: 'DROP_COLUMN';
DROP: 'DROP';
// DROP_GROUP: 'DROP_GROUP';
DSINTERVAL_UNCONSTRAINED: 'DSINTERVAL_UNCONSTRAINED';
// DST_UPGRADE_INSERT_CONV: 'DST_UPGRADE_INSERT_CONV';
// DUMP: 'DUMP';
// DUPLICATE: 'DUPLICATE';
// DV: 'DV';
// DYNAMIC: 'DYNAMIC';
// DYNAMIC_SAMPLING: 'DYNAMIC_SAMPLING';
// DYNAMIC_SAMPLING_EST_CDN: 'DYNAMIC_SAMPLING_EST_CDN';
EACH: 'EACH';
// EDITIONABLE: 'EDITIONABLE';
// EDITION: 'EDITION';
// EDITIONING: 'EDITIONING';
// EDITIONS: 'EDITIONS';
ELEMENT: 'ELEMENT';
// ELIM_GROUPBY: 'ELIM_GROUPBY';
// ELIMINATE_JOIN: 'ELIMINATE_JOIN';
// ELIMINATE_OBY: 'ELIMINATE_OBY';
// ELIMINATE_OUTER_JOIN: 'ELIMINATE_OUTER_JOIN';
ELSE: 'ELSE';
ELSIF: 'ELSIF';
// EM: 'EM';
// EMPTY_BLOB: 'EMPTY_BLOB';
// EMPTY_CLOB: 'EMPTY_CLOB';
EMPTY: 'EMPTY';
// ENABLE_ALL: 'ENABLE_ALL';
ENABLE: 'ENABLE';
// ENABLE_PARALLEL_DML: 'ENABLE_PARALLEL_DML';
// ENABLE_PRESET: 'ENABLE_PRESET';
ENCODING: 'ENCODING';
ENCRYPT: 'ENCRYPT';
// ENCRYPTION: 'ENCRYPTION';
END: 'END';
// END_OUTLINE_DATA: 'END_OUTLINE_DATA';
// ENFORCED: 'ENFORCED';
// ENFORCE: 'ENFORCE';
// ENQUEUE: 'ENQUEUE';
// ENTERPRISE: 'ENTERPRISE';
ENTITYESCAPING: 'ENTITYESCAPING';
// ENTRY: 'ENTRY';
// EQUIPART: 'EQUIPART';
ERR: 'ERR';
// ERROR_ARGUMENT: 'ERROR_ARGUMENT';
// ERROR: 'ERROR';
// ERROR_ON_OVERLAP_TIME: 'ERROR_ON_OVERLAP_TIME';
ERRORS: 'ERRORS';
ESCAPE: 'ESCAPE';
// ESTIMATE: 'ESTIMATE';
// EVAL: 'EVAL';
EVALNAME: 'EVALNAME';
// EVALUATE: 'EVALUATE';
// EVALUATION: 'EVALUATION';
// EVENTS: 'EVENTS';
// EVERY: 'EVERY';
// EXCEPT: 'EXCEPT';
EXCEPTION: 'EXCEPTION';
EXCEPTION_INIT: 'EXCEPTION_INIT';
EXCEPTIONS: 'EXCEPTIONS';
// EXCHANGE: 'EXCHANGE';
EXCLUDE: 'EXCLUDE';
// EXCLUDING: 'EXCLUDING';
EXCLUSIVE: 'EXCLUSIVE';
EXECUTE: 'EXECUTE';
// EXEMPT: 'EXEMPT';
// EXISTING: 'EXISTING';
EXISTS: 'EXISTS';
// EXISTSNODE: 'EXISTSNODE';
EXIT: 'EXIT';
// EXPAND_GSET_TO_UNION: 'EXPAND_GSET_TO_UNION';
// EXPAND_TABLE: 'EXPAND_TABLE';
// EXP: 'EXP';
// EXPIRE: 'EXPIRE';
EXPLAIN: 'EXPLAIN';
// EXPLOSION: 'EXPLOSION';
// EXPORT: 'EXPORT';
// EXPR_CORR_CHECK: 'EXPR_CORR_CHECK';
// EXPRESS: 'EXPRESS';
// EXTENDS: 'EXTENDS';
// EXTENT: 'EXTENT';
// EXTENTS: 'EXTENTS';
EXTERNAL: 'EXTERNAL';
// EXTERNALLY: 'EXTERNALLY';
// EXTRACTCLOBXML: 'EXTRACTCLOBXML';
EXTRACT: 'EXTRACT';
// EXTRACTVALUE: 'EXTRACTVALUE';
// EXTRA: 'EXTRA';
// FACILITY: 'FACILITY';
// FACT: 'FACT';
// FACTOR: 'FACTOR';
// FACTORIZE_JOIN: 'FACTORIZE_JOIN';
// FAILED: 'FAILED';
// FAILED_LOGIN_ATTEMPTS: 'FAILED_LOGIN_ATTEMPTS';
// FAILGROUP: 'FAILGROUP';
// FAILOVER: 'FAILOVER';
FAILURE: 'FAILURE';
FALSE: 'FALSE';
// FAMILY: 'FAMILY';
// FAR: 'FAR';
// FAST: 'FAST';
// FASTSTART: 'FASTSTART';
// FBTSCAN: 'FBTSCAN';
// FEATURE_DETAILS: 'FEATURE_DETAILS';
// FEATURE_ID: 'FEATURE_ID';
// FEATURE_SET: 'FEATURE_SET';
// FEATURE_VALUE: 'FEATURE_VALUE';
FETCH: 'FETCH';
// FILE: 'FILE';
// FILE_NAME_CONVERT: 'FILE_NAME_CONVERT';
FILESYSTEM_LIKE_LOGGING: 'FILESYSTEM_LIKE_LOGGING';
// FILTER: 'FILTER';
FINAL: 'FINAL';
// FINE: 'FINE';
// FINISH: 'FINISH';
FIRST: 'FIRST';
// FIRSTM: 'FIRSTM';
// FIRST_ROWS: 'FIRST_ROWS';
FIRST_VALUE: 'FIRST_VALUE';
// FIXED_VIEW_DATA: 'FIXED_VIEW_DATA';
// FLAGGER: 'FLAGGER';
// FLASHBACK: 'FLASHBACK';
FLASH_CACHE: 'FLASH_CACHE';
FLOAT: 'FLOAT';
// FLOB: 'FLOB';
// FLOOR: 'FLOOR';
// FLUSH: 'FLUSH';
// FOLDER: 'FOLDER';
FOLLOWING: 'FOLLOWING';
FOLLOWS: 'FOLLOWS';
FORALL: 'FORALL';
FORCE: 'FORCE';
// FORCE_XML_QUERY_REWRITE: 'FORCE_XML_QUERY_REWRITE';
FOREIGN: 'FOREIGN';
// FOREVER: 'FOREVER';
FOR: 'FOR';
// FORMAT: 'FORMAT';
// FORWARD: 'FORWARD';
// FRAGMENT_NUMBER: 'FRAGMENT_NUMBER';
FREELIST: 'FREELIST';
FREELISTS: 'FREELISTS';
// FREEPOOLS: 'FREEPOOLS';
// FRESH: 'FRESH';
FROM: 'FROM';
// FROM_TZ: 'FROM_TZ';
FULL: 'FULL';
// FULL_OUTER_JOIN_TO_OUTER: 'FULL_OUTER_JOIN_TO_OUTER';
FUNCTION: 'FUNCTION';
// FUNCTIONS: 'FUNCTIONS';
// GATHER_OPTIMIZER_STATISTICS: 'GATHER_OPTIMIZER_STATISTICS';
// GATHER_PLAN_STATISTICS: 'GATHER_PLAN_STATISTICS';
// GBY_CONC_ROLLUP: 'GBY_CONC_ROLLUP';
// GBY_PUSHDOWN: 'GBY_PUSHDOWN';
// GENERATED: 'GENERATED';
// GET: 'GET';
GLOBAL: 'GLOBAL';
// GLOBALLY: 'GLOBALLY';
// GLOBAL_NAME: 'GLOBAL_NAME';
// GLOBAL_TOPIC_ENABLED: 'GLOBAL_TOPIC_ENABLED';
GOTO: 'GOTO';
GRANT: 'GRANT';
// GROUP_BY: 'GROUP_BY';
GROUP: 'GROUP';
// GROUP_ID: 'GROUP_ID';
GROUPING: 'GROUPING';
// GROUPING_ID: 'GROUPING_ID';
GROUPS: 'GROUPS';
// GUARANTEED: 'GUARANTEED';
// GUARANTEE: 'GUARANTEE';
// GUARD: 'GUARD';
// HASH_AJ: 'HASH_AJ';
HASH: 'HASH';
// HASHKEYS: 'HASHKEYS';
// HASH_SJ: 'HASH_SJ';
HAVING: 'HAVING';
// HEADER: 'HEADER';
// HEAP: 'HEAP';
// HELP: 'HELP';
// HEXTORAW: 'HEXTORAW';
// HEXTOREF: 'HEXTOREF';
// HIDDEN_KEYWORD: 'HIDDEN';
HIDE: 'HIDE';
// HIERARCHY: 'HIERARCHY';
HIGH: 'HIGH';
// HINTSET_BEGIN: 'HINTSET_BEGIN';
// HINTSET_END: 'HINTSET_END';
// HOT: 'HOT';
HOUR: 'HOUR';
// HWM_BROKERED: 'HWM_BROKERED';
// HYBRID: 'HYBRID';
// IDENTIFIED: 'IDENTIFIED';
// IDENTIFIER: 'IDENTIFIER';
// IDENTITY: 'IDENTITY';
// IDGENERATORS: 'IDGENERATORS';
// ID: 'ID';
// IDLE_TIME: 'IDLE_TIME';
IF: 'IF';
IGNORE: 'IGNORE';
// IGNORE_OPTIM_EMBEDDED_HINTS: 'IGNORE_OPTIM_EMBEDDED_HINTS';
// IGNORE_ROW_ON_DUPKEY_INDEX: 'IGNORE_ROW_ON_DUPKEY_INDEX';
// IGNORE_WHERE_CLAUSE: 'IGNORE_WHERE_CLAUSE';
// ILM: 'ILM';
IMMEDIATE: 'IMMEDIATE';
// IMPACT: 'IMPACT';
// IMPORT: 'IMPORT';
// INACTIVE: 'INACTIVE';
INCLUDE: 'INCLUDE';
// INCLUDE_VERSION: 'INCLUDE_VERSION';
INCLUDING: 'INCLUDING';
// INCREMENTAL: 'INCREMENTAL';
INCREMENT: 'INCREMENT';
// INCR: 'INCR';
INDENT: 'INDENT';
// INDEX_ASC: 'INDEX_ASC';
// INDEX_COMBINE: 'INDEX_COMBINE';
// INDEX_DESC: 'INDEX_DESC';
INDEXED: 'INDEXED';
// INDEXES: 'INDEXES';
// INDEX_FFS: 'INDEX_FFS';
// INDEX_FILTER: 'INDEX_FILTER';
INDEX: 'INDEX';
// INDEXING: 'INDEXING';
// INDEX_JOIN: 'INDEX_JOIN';
// INDEX_ROWS: 'INDEX_ROWS';
// INDEX_RRS: 'INDEX_RRS';
// INDEX_RS_ASC: 'INDEX_RS_ASC';
// INDEX_RS_DESC: 'INDEX_RS_DESC';
// INDEX_RS: 'INDEX_RS';
// INDEX_SCAN: 'INDEX_SCAN';
// INDEX_SKIP_SCAN: 'INDEX_SKIP_SCAN';
// INDEX_SS_ASC: 'INDEX_SS_ASC';
// INDEX_SS_DESC: 'INDEX_SS_DESC';
// INDEX_SS: 'INDEX_SS';
// INDEX_STATS: 'INDEX_STATS';
// INDEXTYPE: 'INDEXTYPE';
// INDEXTYPES: 'INDEXTYPES';
INDICATOR: 'INDICATOR';
INDICES: 'INDICES';
INFINITE: 'INFINITE';
// INFORMATIONAL: 'INFORMATIONAL';
// INHERIT: 'INHERIT';
IN: 'IN';
// INITCAP: 'INITCAP';
INITIAL: 'INITIAL';
// INITIALIZED: 'INITIALIZED';
// INITIALLY: 'INITIALLY';
INITRANS: 'INITRANS';
INLINE: 'INLINE';
// INLINE_XMLTYPE_NT: 'INLINE_XMLTYPE_NT';
// INMEMORY: 'INMEMORY';
// IN_MEMORY_METADATA: 'IN_MEMORY_METADATA';
// INMEMORY_PRUNING: 'INMEMORY_PRUNING';
INNER: 'INNER';
INOUT: 'INOUT';
// INPLACE: 'INPLACE';
// INSERTCHILDXMLAFTER: 'INSERTCHILDXMLAFTER';
// INSERTCHILDXMLBEFORE: 'INSERTCHILDXMLBEFORE';
// INSERTCHILDXML: 'INSERTCHILDXML';
INSERT: 'INSERT';
// INSERTXMLAFTER: 'INSERTXMLAFTER';
// INSERTXMLBEFORE: 'INSERTXMLBEFORE';
// INSTANCE: 'INSTANCE';
// INSTANCES: 'INSTANCES';
INSTANTIABLE: 'INSTANTIABLE';
// INSTANTLY: 'INSTANTLY';
INSTEAD: 'INSTEAD';
// INSTR2: 'INSTR2';
// INSTR4: 'INSTR4';
// INSTRB: 'INSTRB';
// INSTRC: 'INSTRC';
// INSTR: 'INSTR';
INTEGER: 'INTEGER';
// INTERLEAVED: 'INTERLEAVED';
// INTERMEDIATE: 'INTERMEDIATE';
// INTERNAL_CONVERT: 'INTERNAL_CONVERT';
// INTERNAL_USE: 'INTERNAL_USE';
// INTERPRETED: 'INTERPRETED';
INTERSECT: 'INTERSECT';
INTERVAL: 'INTERVAL';
INT: 'INT';
INTO: 'INTO';
INVALIDATE: 'INVALIDATE';
// INVISIBLE: 'INVISIBLE';
// IN_XQUERY: 'IN_XQUERY';
IS: 'IS';
ISOLATION: 'ISOLATION';
// ISOLATION_LEVEL: 'ISOLATION_LEVEL';
ITERATE: 'ITERATE';
// ITERATION_NUMBER: 'ITERATION_NUMBER';
JAVA: 'JAVA';
// JOB: 'JOB';
JOIN: 'JOIN';
// JSON_ARRAYAGG: 'JSON_ARRAYAGG';
// JSON_ARRAY: 'JSON_ARRAY';
// JSON_EQUAL: 'JSON_EQUAL';
// JSON_EXISTS2: 'JSON_EXISTS2';
// JSON_EXISTS: 'JSON_EXISTS';
// JSONGET: 'JSONGET';
// JSON: 'JSON';
// JSON_OBJECTAGG: 'JSON_OBJECTAGG';
// JSON_OBJECT: 'JSON_OBJECT';
// JSONPARSE: 'JSONPARSE';
// JSON_QUERY: 'JSON_QUERY';
// JSON_SERIALIZE: 'JSON_SERIALIZE';
// JSON_TABLE: 'JSON_TABLE';
// JSON_TEXTCONTAINS2: 'JSON_TEXTCONTAINS2';
// JSON_TEXTCONTAINS: 'JSON_TEXTCONTAINS';
// JSON_VALUE: 'JSON_VALUE';
// KEEP_DUPLICATES: 'KEEP_DUPLICATES';
KEEP: 'KEEP';
// KERBEROS: 'KERBEROS';
KEY: 'KEY';
// KEY_LENGTH: 'KEY_LENGTH';
// KEYSIZE: 'KEYSIZE';
// KEYS: 'KEYS';
// KEYSTORE: 'KEYSTORE';
// KILL: 'KILL';
// LABEL: 'LABEL';
LANGUAGE: 'LANGUAGE';
// LAST_DAY: 'LAST_DAY';
LAST: 'LAST';
LAST_VALUE: 'LAST_VALUE';
// LATERAL: 'LATERAL';
// LAX: 'LAX';
// LAYER: 'LAYER';
// LDAP_REGISTRATION_ENABLED: 'LDAP_REGISTRATION_ENABLED';
// LDAP_REGISTRATION: 'LDAP_REGISTRATION';
// LDAP_REG_SYNC_INTERVAL: 'LDAP_REG_SYNC_INTERVAL';
LEADING: 'LEADING';
LEFT: 'LEFT';
// LENGTH2: 'LENGTH2';
// LENGTH4: 'LENGTH4';
// LENGTHB: 'LENGTHB';
// LENGTHC: 'LENGTHC';
// LENGTH: 'LENGTH';
// LESS: 'LESS';
LEVEL: 'LEVEL';
// LEVELS: 'LEVELS';
LIBRARY: 'LIBRARY';
// LIFECYCLE: 'LIFECYCLE';
// LIFE: 'LIFE';
// LIFETIME: 'LIFETIME';
LIKE2: 'LIKE2';
LIKE4: 'LIKE4';
LIKEC: 'LIKEC';
// LIKE_EXPAND: 'LIKE_EXPAND';
LIKE: 'LIKE';
LIMIT: 'LIMIT';
// LINEAR: 'LINEAR';
// LINK: 'LINK';
LIST: 'LIST';
// LN: 'LN';
// LNNVL: 'LNNVL';
// LOAD: 'LOAD';
// LOB: 'LOB';
// LOBNVL: 'LOBNVL';
// LOBS: 'LOBS';
// LOCAL_INDEXES: 'LOCAL_INDEXES';
LOCAL: 'LOCAL';
// LOCALTIME: 'LOCALTIME';
// LOCALTIMESTAMP: 'LOCALTIMESTAMP';
// LOCATION: 'LOCATION';
// LOCATOR: 'LOCATOR';
LOCKED: 'LOCKED';
// LOCKING: 'LOCKING';
LOCK: 'LOCK';
// LOGFILE: 'LOGFILE';
// LOGFILES: 'LOGFILES';
LOGGING: 'LOGGING';
// LOGICAL: 'LOGICAL';
// LOGICAL_READS_PER_CALL: 'LOGICAL_READS_PER_CALL';
// LOGICAL_READS_PER_SESSION: 'LOGICAL_READS_PER_SESSION';
LOG: 'LOG';
// LOGMINING: 'LOGMINING';
LOGOFF: 'LOGOFF';
LOGON: 'LOGON';
// LOG_READ_ONLY_VIOLATIONS: 'LOG_READ_ONLY_VIOLATIONS';
LONG: 'LONG';
LOOP: 'LOOP';
// LOWER: 'LOWER';
LOW: 'LOW';
// LPAD: 'LPAD';
// LTRIM: 'LTRIM';
MAIN: 'MAIN';
// MAKE_REF: 'MAKE_REF';
// MANAGED: 'MANAGED';
// MANAGE: 'MANAGE';
// MANAGEMENT: 'MANAGEMENT';
// MANAGER: 'MANAGER';
// MANUAL: 'MANUAL';
MAP: 'MAP';
// MAPPING: 'MAPPING';
// MASTER: 'MASTER';
MATCHED: 'MATCHED';
// MATCHES: 'MATCHES';
// MATCH: 'MATCH';
// MATCH_NUMBER: 'MATCH_NUMBER';
// MATCH_RECOGNIZE: 'MATCH_RECOGNIZE';
// MATERIALIZED: 'MATERIALIZED';
// MATERIALIZE: 'MATERIALIZE';
// MAXARCHLOGS: 'MAXARCHLOGS';
// MAXDATAFILES: 'MAXDATAFILES';
// MAXEXTENTS: 'MAXEXTENTS';
// MAXIMIZE: 'MAXIMIZE';
// MAXINSTANCES: 'MAXINSTANCES';
// MAXLOGFILES: 'MAXLOGFILES';
// MAXLOGHISTORY: 'MAXLOGHISTORY';
// MAXLOGMEMBERS: 'MAXLOGMEMBERS';
// MAX_SHARED_TEMP_SIZE: 'MAX_SHARED_TEMP_SIZE';
// MAXSIZE: 'MAXSIZE';
// MAXTRANS: 'MAXTRANS';
MAXVALUE: 'MAXVALUE';
// MEASURE: 'MEASURE';
MEASURES: 'MEASURES';
// MEDIUM: 'MEDIUM';
MEMBER: 'MEMBER';
// MEMCOMPRESS: 'MEMCOMPRESS';
// MEMORY: 'MEMORY';
// MERGEACTIONS: 'MERGE$ACTIONS';
// MERGE_AJ: 'MERGE_AJ';
// MERGE_CONST_ON: 'MERGE_CONST_ON';
MERGE: 'MERGE';
// MERGE_SJ: 'MERGE_SJ';
// METADATA: 'METADATA';
// METHOD: 'METHOD';
// MIGRATE: 'MIGRATE';
// MIGRATION: 'MIGRATION';
MINEXTENTS: 'MINEXTENTS';
// MINIMIZE: 'MINIMIZE';
// MINIMUM: 'MINIMUM';
// MINING: 'MINING';
MINUS: 'MINUS';
// MINUS_NULL: 'MINUS_NULL';
MINUTE: 'MINUTE';
MINVALUE: 'MINVALUE';
// MIRRORCOLD: 'MIRRORCOLD';
// MIRRORHOT: 'MIRRORHOT';
// MIRROR: 'MIRROR';
MLSLABEL: 'MLSLABEL';
// MODEL_COMPILE_SUBQUERY: 'MODEL_COMPILE_SUBQUERY';
// MODEL_DONTVERIFY_UNIQUENESS: 'MODEL_DONTVERIFY_UNIQUENESS';
// MODEL_DYNAMIC_SUBQUERY: 'MODEL_DYNAMIC_SUBQUERY';
// MODEL_MIN_ANALYSIS: 'MODEL_MIN_ANALYSIS';
MODEL: 'MODEL';
// MODEL_NB: 'MODEL_NB';
// MODEL_NO_ANALYSIS: 'MODEL_NO_ANALYSIS';
// MODEL_PBY: 'MODEL_PBY';
// MODEL_PUSH_REF: 'MODEL_PUSH_REF';
// MODEL_SV: 'MODEL_SV';
MODE: 'MODE';
// MODIFICATION: 'MODIFICATION';
// MODIFY_COLUMN_TYPE: 'MODIFY_COLUMN_TYPE';
MODIFY: 'MODIFY';
// MOD: 'MOD';
// MODULE: 'MODULE';
// MONITORING: 'MONITORING';
// MONITOR: 'MONITOR';
MONTH: 'MONTH';
// MONTHS_BETWEEN: 'MONTHS_BETWEEN';
// MONTHS: 'MONTHS';
// MOUNT: 'MOUNT';
// MOUNTPATH: 'MOUNTPATH';
// MOVEMENT: 'MOVEMENT';
// MOVE: 'MOVE';
// MULTIDIMENSIONAL: 'MULTIDIMENSIONAL';
MULTISET: 'MULTISET';
// MV_MERGE: 'MV_MERGE';
// NAMED: 'NAMED';
NAME: 'NAME';
// NAMESPACE: 'NAMESPACE';
NAN: 'NAN';
// NANVL: 'NANVL';
// NATIONAL: 'NATIONAL';
// NATIVE_FULL_OUTER_JOIN: 'NATIVE_FULL_OUTER_JOIN';
// NATIVE: 'NATIVE';
NATURAL: 'NATURAL';
NATURALN: 'NATURALN';
NAV: 'NAV';
NCHAR_CS: 'NCHAR_CS';
NCHAR: 'NCHAR';
// NCHR: 'NCHR';
NCLOB: 'NCLOB';
// NEEDED: 'NEEDED';
// NEG: 'NEG';
NESTED: 'NESTED';
// NESTED_TABLE_FAST_INSERT: 'NESTED_TABLE_FAST_INSERT';
// NESTED_TABLE_GET_REFS: 'NESTED_TABLE_GET_REFS';
// NESTED_TABLE_ID: 'NESTED_TABLE_ID';
// NESTED_TABLE_SET_REFS: 'NESTED_TABLE_SET_REFS';
// NESTED_TABLE_SET_SETID: 'NESTED_TABLE_SET_SETID';
// NETWORK: 'NETWORK';
// NEVER: 'NEVER';
NEW: 'NEW';
// NEW_TIME: 'NEW_TIME';
// NEXT_DAY: 'NEXT_DAY';
NEXT: 'NEXT';
// NL_AJ: 'NL_AJ';
// NLJ_BATCHING: 'NLJ_BATCHING';
// NLJ_INDEX_FILTER: 'NLJ_INDEX_FILTER';
// NLJ_INDEX_SCAN: 'NLJ_INDEX_SCAN';
// NLJ_PREFETCH: 'NLJ_PREFETCH';
// NLS_CALENDAR: 'NLS_CALENDAR';
// NLS_CHARACTERSET: 'NLS_CHARACTERSET';
// NLS_CHARSET_DECL_LEN: 'NLS_CHARSET_DECL_LEN';
// NLS_CHARSET_ID: 'NLS_CHARSET_ID';
// NLS_CHARSET_NAME: 'NLS_CHARSET_NAME';
// NLS_COMP: 'NLS_COMP';
// NLS_CURRENCY: 'NLS_CURRENCY';
// NLS_DATE_FORMAT: 'NLS_DATE_FORMAT';
// NLS_DATE_LANGUAGE: 'NLS_DATE_LANGUAGE';
// NLS_INITCAP: 'NLS_INITCAP';
// NLS_ISO_CURRENCY: 'NLS_ISO_CURRENCY';
// NL_SJ: 'NL_SJ';
// NLS_LANG: 'NLS_LANG';
// NLS_LANGUAGE: 'NLS_LANGUAGE';
// NLS_LENGTH_SEMANTICS: 'NLS_LENGTH_SEMANTICS';
// NLS_LOWER: 'NLS_LOWER';
// NLS_NCHAR_CONV_EXCP: 'NLS_NCHAR_CONV_EXCP';
// NLS_NUMERIC_CHARACTERS: 'NLS_NUMERIC_CHARACTERS';
// NLS_SORT: 'NLS_SORT';
// NLSSORT: 'NLSSORT';
// NLS_SPECIAL_CHARS: 'NLS_SPECIAL_CHARS';
// NLS_TERRITORY: 'NLS_TERRITORY';
// NLS_UPPER: 'NLS_UPPER';
// NO_ACCESS: 'NO_ACCESS';
// NO_ADAPTIVE_PLAN: 'NO_ADAPTIVE_PLAN';
// NO_ANSI_REARCH: 'NO_ANSI_REARCH';
// NOAPPEND: 'NOAPPEND';
// NOARCHIVELOG: 'NOARCHIVELOG';
NOAUDIT: 'NOAUDIT';
// NO_AUTO_REOPTIMIZE: 'NO_AUTO_REOPTIMIZE';
// NO_BASETABLE_MULTIMV_REWRITE: 'NO_BASETABLE_MULTIMV_REWRITE';
// NO_BATCH_TABLE_ACCESS_BY_ROWID: 'NO_BATCH_TABLE_ACCESS_BY_ROWID';
// NO_BIND_AWARE: 'NO_BIND_AWARE';
// NO_BUFFER: 'NO_BUFFER';
NOCACHE: 'NOCACHE';
// NO_CARTESIAN: 'NO_CARTESIAN';
// NO_CHECK_ACL_REWRITE: 'NO_CHECK_ACL_REWRITE';
// NO_CLUSTER_BY_ROWID: 'NO_CLUSTER_BY_ROWID';
// NO_CLUSTERING: 'NO_CLUSTERING';
// NO_COALESCE_SQ: 'NO_COALESCE_SQ';
// NO_COMMON_DATA: 'NO_COMMON_DATA';
NOCOMPRESS: 'NOCOMPRESS';
// NO_CONNECT_BY_CB_WHR_ONLY: 'NO_CONNECT_BY_CB_WHR_ONLY';
// NO_CONNECT_BY_COMBINE_SW: 'NO_CONNECT_BY_COMBINE_SW';
// NO_CONNECT_BY_COST_BASED: 'NO_CONNECT_BY_COST_BASED';
// NO_CONNECT_BY_ELIM_DUPS: 'NO_CONNECT_BY_ELIM_DUPS';
// NO_CONNECT_BY_FILTERING: 'NO_CONNECT_BY_FILTERING';
NOCOPY: 'NOCOPY';
// NO_COST_XML_QUERY_REWRITE: 'NO_COST_XML_QUERY_REWRITE';
// NO_CPU_COSTING: 'NO_CPU_COSTING';
// NOCPU_COSTING: 'NOCPU_COSTING';
NOCYCLE: 'NOCYCLE';
// NO_DATA_SECURITY_REWRITE: 'NO_DATA_SECURITY_REWRITE';
// NO_DECORRELATE: 'NO_DECORRELATE';
// NODELAY: 'NODELAY';
// NO_DOMAIN_INDEX_FILTER: 'NO_DOMAIN_INDEX_FILTER';
// NO_DST_UPGRADE_INSERT_CONV: 'NO_DST_UPGRADE_INSERT_CONV';
// NO_ELIM_GROUPBY: 'NO_ELIM_GROUPBY';
// NO_ELIMINATE_JOIN: 'NO_ELIMINATE_JOIN';
// NO_ELIMINATE_OBY: 'NO_ELIMINATE_OBY';
// NO_ELIMINATE_OUTER_JOIN: 'NO_ELIMINATE_OUTER_JOIN';
NOENTITYESCAPING: 'NOENTITYESCAPING';
// NO_EXPAND_GSET_TO_UNION: 'NO_EXPAND_GSET_TO_UNION';
// NO_EXPAND: 'NO_EXPAND';
// NO_EXPAND_TABLE: 'NO_EXPAND_TABLE';
// NO_FACT: 'NO_FACT';
// NO_FACTORIZE_JOIN: 'NO_FACTORIZE_JOIN';
// NO_FILTERING: 'NO_FILTERING';
// NOFORCE: 'NOFORCE';
// NO_FULL_OUTER_JOIN_TO_OUTER: 'NO_FULL_OUTER_JOIN_TO_OUTER';
// NO_GATHER_OPTIMIZER_STATISTICS: 'NO_GATHER_OPTIMIZER_STATISTICS';
// NO_GBY_PUSHDOWN: 'NO_GBY_PUSHDOWN';
// NOGUARANTEE: 'NOGUARANTEE';
// NO_INDEX_FFS: 'NO_INDEX_FFS';
// NO_INDEX: 'NO_INDEX';
// NO_INDEX_SS: 'NO_INDEX_SS';
// NO_INMEMORY: 'NO_INMEMORY';
// NO_INMEMORY_PRUNING: 'NO_INMEMORY_PRUNING';
// NOKEEP: 'NOKEEP';
// NO_LOAD: 'NO_LOAD';
// NOLOCAL: 'NOLOCAL';
NOLOGGING: 'NOLOGGING';
// NOMAPPING: 'NOMAPPING';
NOMAXVALUE: 'NOMAXVALUE';
// NO_MERGE: 'NO_MERGE';
// NOMINIMIZE: 'NOMINIMIZE';
NOMINVALUE: 'NOMINVALUE';
// NO_MODEL_PUSH_REF: 'NO_MODEL_PUSH_REF';
// NO_MONITORING: 'NO_MONITORING';
// NOMONITORING: 'NOMONITORING';
// NO_MONITOR: 'NO_MONITOR';
// NO_MULTIMV_REWRITE: 'NO_MULTIMV_REWRITE';
// NO_NATIVE_FULL_OUTER_JOIN: 'NO_NATIVE_FULL_OUTER_JOIN';
// NONBLOCKING: 'NONBLOCKING';
// NONEDITIONABLE: 'NONEDITIONABLE';
NONE: 'NONE';
// NO_NLJ_BATCHING: 'NO_NLJ_BATCHING';
// NO_NLJ_PREFETCH: 'NO_NLJ_PREFETCH';
NO: 'NO';
// NONSCHEMA: 'NONSCHEMA';
// NO_OBJECT_LINK: 'NO_OBJECT_LINK';
NOORDER: 'NOORDER';
// NO_ORDER_ROLLUPS: 'NO_ORDER_ROLLUPS';
// NO_OUTER_JOIN_TO_ANTI: 'NO_OUTER_JOIN_TO_ANTI';
// NO_OUTER_JOIN_TO_INNER: 'NO_OUTER_JOIN_TO_INNER';
// NOOVERRIDE: 'NOOVERRIDE';
// NO_PARALLEL_INDEX: 'NO_PARALLEL_INDEX';
// NOPARALLEL_INDEX: 'NOPARALLEL_INDEX';
// NO_PARALLEL: 'NO_PARALLEL';
// NOPARALLEL: 'NOPARALLEL';
// NO_PARTIAL_COMMIT: 'NO_PARTIAL_COMMIT';
// NO_PARTIAL_JOIN: 'NO_PARTIAL_JOIN';
// NO_PARTIAL_ROLLUP_PUSHDOWN: 'NO_PARTIAL_ROLLUP_PUSHDOWN';
// NOPARTITION: 'NOPARTITION';
// NO_PLACE_DISTINCT: 'NO_PLACE_DISTINCT';
// NO_PLACE_GROUP_BY: 'NO_PLACE_GROUP_BY';
// NO_PQ_CONCURRENT_UNION: 'NO_PQ_CONCURRENT_UNION';
// NO_PQ_MAP: 'NO_PQ_MAP';
// NO_PQ_REPLICATE: 'NO_PQ_REPLICATE';
// NO_PQ_SKEW: 'NO_PQ_SKEW';
// NO_PRUNE_GSETS: 'NO_PRUNE_GSETS';
// NO_PULL_PRED: 'NO_PULL_PRED';
// NO_PUSH_PRED: 'NO_PUSH_PRED';
// NO_PUSH_SUBQ: 'NO_PUSH_SUBQ';
// NO_PX_FAULT_TOLERANCE: 'NO_PX_FAULT_TOLERANCE';
// NO_PX_JOIN_FILTER: 'NO_PX_JOIN_FILTER';
// NO_QKN_BUFF: 'NO_QKN_BUFF';
// NO_QUERY_TRANSFORMATION: 'NO_QUERY_TRANSFORMATION';
// NO_REF_CASCADE: 'NO_REF_CASCADE';
// NORELOCATE: 'NORELOCATE';
// NORELY: 'NORELY';
// NOREPAIR: 'NOREPAIR';
// NOREPLAY: 'NOREPLAY';
// NORESETLOGS: 'NORESETLOGS';
// NO_RESULT_CACHE: 'NO_RESULT_CACHE';
// NOREVERSE: 'NOREVERSE';
// NO_REWRITE: 'NO_REWRITE';
// NOREWRITE: 'NOREWRITE';
// NORMAL: 'NORMAL';
// NO_ROOT_SW_FOR_LOCAL: 'NO_ROOT_SW_FOR_LOCAL';
// NOROWDEPENDENCIES: 'NOROWDEPENDENCIES';
NOSCHEMACHECK: 'NOSCHEMACHECK';
// NOSEGMENT: 'NOSEGMENT';
// NO_SEMIJOIN: 'NO_SEMIJOIN';
// NO_SEMI_TO_INNER: 'NO_SEMI_TO_INNER';
// NO_SET_TO_JOIN: 'NO_SET_TO_JOIN';
// NOSORT: 'NOSORT';
// NO_SQL_TRANSLATION: 'NO_SQL_TRANSLATION';
// NO_SQL_TUNE: 'NO_SQL_TUNE';
// NO_STAR_TRANSFORMATION: 'NO_STAR_TRANSFORMATION';
// NO_STATEMENT_QUEUING: 'NO_STATEMENT_QUEUING';
// NO_STATS_GSETS: 'NO_STATS_GSETS';
// NOSTRICT: 'NOSTRICT';
// NO_SUBQUERY_PRUNING: 'NO_SUBQUERY_PRUNING';
// NO_SUBSTRB_PAD: 'NO_SUBSTRB_PAD';
// NO_SWAP_JOIN_INPUTS: 'NO_SWAP_JOIN_INPUTS';
// NOSWITCH: 'NOSWITCH';
// NO_TABLE_LOOKUP_BY_NL: 'NO_TABLE_LOOKUP_BY_NL';
// NO_TEMP_TABLE: 'NO_TEMP_TABLE';
// NOTHING: 'NOTHING';
// NOTIFICATION: 'NOTIFICATION';
NOT: 'NOT';
// NO_TRANSFORM_DISTINCT_AGG: 'NO_TRANSFORM_DISTINCT_AGG';
// NO_UNNEST: 'NO_UNNEST';
// NO_USE_CUBE: 'NO_USE_CUBE';
// NO_USE_HASH_AGGREGATION: 'NO_USE_HASH_AGGREGATION';
// NO_USE_HASH_GBY_FOR_PUSHDOWN: 'NO_USE_HASH_GBY_FOR_PUSHDOWN';
// NO_USE_HASH: 'NO_USE_HASH';
// NO_USE_INVISIBLE_INDEXES: 'NO_USE_INVISIBLE_INDEXES';
// NO_USE_MERGE: 'NO_USE_MERGE';
// NO_USE_NL: 'NO_USE_NL';
// NO_USE_VECTOR_AGGREGATION: 'NO_USE_VECTOR_AGGREGATION';
// NOVALIDATE: 'NOVALIDATE';
// NO_VECTOR_TRANSFORM_DIMS: 'NO_VECTOR_TRANSFORM_DIMS';
// NO_VECTOR_TRANSFORM_FACT: 'NO_VECTOR_TRANSFORM_FACT';
// NO_VECTOR_TRANSFORM: 'NO_VECTOR_TRANSFORM';
NOWAIT: 'NOWAIT';
// NO_XDB_FASTPATH_INSERT: 'NO_XDB_FASTPATH_INSERT';
// NO_XML_DML_REWRITE: 'NO_XML_DML_REWRITE';
// NO_XMLINDEX_REWRITE_IN_SELECT: 'NO_XMLINDEX_REWRITE_IN_SELECT';
// NO_XMLINDEX_REWRITE: 'NO_XMLINDEX_REWRITE';
// NO_XML_QUERY_REWRITE: 'NO_XML_QUERY_REWRITE';
// NO_ZONEMAP: 'NO_ZONEMAP';
// NTH_VALUE: 'NTH_VALUE';
// NULLIF: 'NULLIF';
NULL: 'NULL';
NULLS: 'NULLS';
NUMBER: 'NUMBER';
NUMERIC: 'NUMERIC';
// NUM_INDEX_KEYS: 'NUM_INDEX_KEYS';
// NUMTODSINTERVAL: 'NUMTODSINTERVAL';
// NUMTOYMINTERVAL: 'NUMTOYMINTERVAL';
NVARCHAR2: 'NVARCHAR2';
// NVL2: 'NVL2';
// OBJECT2XML: 'OBJECT2XML';
OBJECT: 'OBJECT';
// OBJ_ID: 'OBJ_ID';
// OBJNO: 'OBJNO';
// OBJNO_REUSE: 'OBJNO_REUSE';
// OCCURENCES: 'OCCURENCES';
// OFFLINE: 'OFFLINE';
OFF: 'OFF';
// OFFSET: 'OFFSET';
OF: 'OF';
// OIDINDEX: 'OIDINDEX';
OID: 'OID';
// OLAP: 'OLAP';
OLD: 'OLD';
// OLD_PUSH_PRED: 'OLD_PUSH_PRED';
// OLS: 'OLS';
OLTP: 'OLTP';
// OMIT: 'OMIT';
// ONE: 'ONE';
// ONLINE: 'ONLINE';
ONLY: 'ONLY';
ON: 'ON';
// OPAQUE: 'OPAQUE';
// OPAQUE_TRANSFORM: 'OPAQUE_TRANSFORM';
// OPAQUE_XCANONICAL: 'OPAQUE_XCANONICAL';
// OPCODE: 'OPCODE';
OPEN: 'OPEN';
// OPERATIONS: 'OPERATIONS';
// OPERATOR: 'OPERATOR';
// OPT_ESTIMATE: 'OPT_ESTIMATE';
OPTIMAL: 'OPTIMAL';
// OPTIMIZE: 'OPTIMIZE';
// OPTIMIZER_FEATURES_ENABLE: 'OPTIMIZER_FEATURES_ENABLE';
// OPTIMIZER_GOAL: 'OPTIMIZER_GOAL';
OPTION: 'OPTION';
// OPT_PARAM: 'OPT_PARAM';
// ORA_BRANCH: 'ORA_BRANCH';
// ORA_CHECK_ACL: 'ORA_CHECK_ACL';
// ORA_CHECK_PRIVILEGE: 'ORA_CHECK_PRIVILEGE';
// ORA_CLUSTERING: 'ORA_CLUSTERING';
ORADATA: 'ORADATA';
// ORADEBUG: 'ORADEBUG';
// ORA_DST_AFFECTED: 'ORA_DST_AFFECTED';
// ORA_DST_CONVERT: 'ORA_DST_CONVERT';
// ORA_DST_ERROR: 'ORA_DST_ERROR';
// ORA_GET_ACLIDS: 'ORA_GET_ACLIDS';
// ORA_GET_PRIVILEGES: 'ORA_GET_PRIVILEGES';
// ORA_HASH: 'ORA_HASH';
// ORA_INVOKING_USERID: 'ORA_INVOKING_USERID';
// ORA_INVOKING_USER: 'ORA_INVOKING_USER';
// ORA_INVOKING_XS_USER_GUID: 'ORA_INVOKING_XS_USER_GUID';
// ORA_INVOKING_XS_USER: 'ORA_INVOKING_XS_USER';
// ORA_RAWCOMPARE: 'ORA_RAWCOMPARE';
// ORA_RAWCONCAT: 'ORA_RAWCONCAT';
// ORA_ROWSCN: 'ORA_ROWSCN';
// ORA_ROWSCN_RAW: 'ORA_ROWSCN_RAW';
// ORA_ROWVERSION: 'ORA_ROWVERSION';
// ORA_TABVERSION: 'ORA_TABVERSION';
// ORA_WRITE_TIME: 'ORA_WRITE_TIME';
// ORDERED: 'ORDERED';
// ORDERED_PREDICATES: 'ORDERED_PREDICATES';
ORDER: 'ORDER';
ORDINALITY: 'ORDINALITY';
// OR_EXPAND: 'OR_EXPAND';
// ORGANIZATION: 'ORGANIZATION';
OR: 'OR';
// OR_PREDICATES: 'OR_PREDICATES';
OSERROR: 'OSERROR';
// OTHER: 'OTHER';
// OUTER_JOIN_TO_ANTI: 'OUTER_JOIN_TO_ANTI';
// OUTER_JOIN_TO_INNER: 'OUTER_JOIN_TO_INNER';
OUTER: 'OUTER';
// OUTLINE_LEAF: 'OUTLINE_LEAF';
// OUTLINE: 'OUTLINE';
// OUT_OF_LINE: 'OUT_OF_LINE';
OUT: 'OUT';
// OVERFLOW_NOMOVE: 'OVERFLOW_NOMOVE';
// OVERFLOW: 'OVERFLOW';
// OVERLAPS: 'OVERLAPS';
OVER: 'OVER';
OVERRIDING: 'OVERRIDING';
// OWNER: 'OWNER';
// OWNERSHIP: 'OWNERSHIP';
// OWN: 'OWN';
PACKAGE: 'PACKAGE';
// PACKAGES: 'PACKAGES';
PARALLEL_ENABLE: 'PARALLEL_ENABLE';
// PARALLEL_INDEX: 'PARALLEL_INDEX';
// PARALLEL: 'PARALLEL';
PARAMETERS: 'PARAMETERS';
// PARAM: 'PARAM';
PARENT: 'PARENT';
// PARITY: 'PARITY';
// PARTIAL_JOIN: 'PARTIAL_JOIN';
// PARTIALLY: 'PARTIALLY';
// PARTIAL: 'PARTIAL';
// PARTIAL_ROLLUP_PUSHDOWN: 'PARTIAL_ROLLUP_PUSHDOWN';
// PARTITION_HASH: 'PARTITION_HASH';
// PARTITION_LIST: 'PARTITION_LIST';
PARTITION: 'PARTITION';
// PARTITION_RANGE: 'PARTITION_RANGE';
// PARTITIONS: 'PARTITIONS';
// PARTNUMINST: 'PART$NUM$INST';
PASSING: 'PASSING';
// PASSWORD_GRACE_TIME: 'PASSWORD_GRACE_TIME';
// PASSWORD_LIFE_TIME: 'PASSWORD_LIFE_TIME';
// PASSWORD_LOCK_TIME: 'PASSWORD_LOCK_TIME';
// PASSWORD: 'PASSWORD';
// PASSWORD_REUSE_MAX: 'PASSWORD_REUSE_MAX';
// PASSWORD_REUSE_TIME: 'PASSWORD_REUSE_TIME';
// PASSWORD_VERIFY_FUNCTION: 'PASSWORD_VERIFY_FUNCTION';
// PAST: 'PAST';
// PATCH: 'PATCH';
PATH: 'PATH';
// PATH_PREFIX: 'PATH_PREFIX';
// PATHS: 'PATHS';
// PATTERN: 'PATTERN';
// PBL_HS_BEGIN: 'PBL_HS_BEGIN';
// PBL_HS_END: 'PBL_HS_END';
PCTFREE: 'PCTFREE';
PCTINCREASE: 'PCTINCREASE';
// PCTTHRESHOLD: 'PCTTHRESHOLD';
PCTUSED: 'PCTUSED';
// PCTVERSION: 'PCTVERSION';
// PENDING: 'PENDING';
PERCENT_FOUND: '%FOUND';
PERCENT_ISOPEN: '%ISOPEN';
PERCENT_NOTFOUND: '%NOTFOUND';
// PERCENT_KEYWORD: 'PERCENT';
// PERCENT_RANKM: 'PERCENT_RANKM';
PERCENT_ROWCOUNT: '%ROWCOUNT';
PERCENT_ROWTYPE: '%ROWTYPE';
PERCENT_TYPE: '%TYPE';
// PERFORMANCE: 'PERFORMANCE';
// PERIOD_KEYWORD: 'PERIOD';
// PERMANENT: 'PERMANENT';
// PERMISSION: 'PERMISSION';
// PERMUTE: 'PERMUTE';
// PER: 'PER';
// PFILE: 'PFILE';
// PHYSICAL: 'PHYSICAL';
// PIKEY: 'PIKEY';
PIPELINED: 'PIPELINED';
PIPE: 'PIPE';
// PIV_GB: 'PIV_GB';
PIVOT: 'PIVOT';
// PIV_SSF: 'PIV_SSF';
// PLACE_DISTINCT: 'PLACE_DISTINCT';
// PLACE_GROUP_BY: 'PLACE_GROUP_BY';
PLAN: 'PLAN';
// PLSCOPE_SETTINGS: 'PLSCOPE_SETTINGS';
PLS_INTEGER: 'PLS_INTEGER';
// PLSQL_CCFLAGS: 'PLSQL_CCFLAGS';
// PLSQL_CODE_TYPE: 'PLSQL_CODE_TYPE';
// PLSQL_DEBUG: 'PLSQL_DEBUG';
// PLSQL_OPTIMIZE_LEVEL: 'PLSQL_OPTIMIZE_LEVEL';
// PLSQL_WARNINGS: 'PLSQL_WARNINGS';
// PLUGGABLE: 'PLUGGABLE';
// POINT: 'POINT';
// POLICY: 'POLICY';
// POOL_16K: 'POOL_16K';
// POOL_2K: 'POOL_2K';
// POOL_32K: 'POOL_32K';
// POOL_4K: 'POOL_4K';
// POOL_8K: 'POOL_8K';
POSITIVEN: 'POSITIVEN';
POSITIVE: 'POSITIVE';
// POST_TRANSACTION: 'POST_TRANSACTION';
// POWERMULTISET_BY_CARDINALITY: 'POWERMULTISET_BY_CARDINALITY';
// POWERMULTISET: 'POWERMULTISET';
// POWER: 'POWER';
// PQ_CONCURRENT_UNION: 'PQ_CONCURRENT_UNION';
// PQ_DISTRIBUTE: 'PQ_DISTRIBUTE';
// PQ_DISTRIBUTE_WINDOW: 'PQ_DISTRIBUTE_WINDOW';
// PQ_FILTER: 'PQ_FILTER';
// PQ_MAP: 'PQ_MAP';
// PQ_NOMAP: 'PQ_NOMAP';
// PQ_REPLICATE: 'PQ_REPLICATE';
// PQ_SKEW: 'PQ_SKEW';
PRAGMA: 'PRAGMA';
// PREBUILT: 'PREBUILT';
// PRECEDES: 'PRECEDES';
PRECEDING: 'PRECEDING';
PRECISION: 'PRECISION';
// PRECOMPUTE_SUBQUERY: 'PRECOMPUTE_SUBQUERY';
// PREDICATE_REORDERS: 'PREDICATE_REORDERS';
// PRELOAD: 'PRELOAD';
// PREPARE: 'PREPARE';
// PRESENTNNV: 'PRESENTNNV';
PRESENT: 'PRESENT';
// PRESENTV: 'PRESENTV';
// PRESERVE_OID: 'PRESERVE_OID';
PRESERVE: 'PRESERVE';
// PRETTY: 'PRETTY';
// PREVIOUS: 'PREVIOUS';
// PREV: 'PREV';
PRIMARY: 'PRIMARY';
// PRINTBLOBTOCLOB: 'PRINTBLOBTOCLOB';
// PRIORITY: 'PRIORITY';
PRIOR: 'PRIOR';
// PRIVATE: 'PRIVATE';
// PRIVATE_SGA: 'PRIVATE_SGA';
// PRIVILEGED: 'PRIVILEGED';
// PRIVILEGE: 'PRIVILEGE';
// PRIVILEGES: 'PRIVILEGES';
// PROCEDURAL: 'PROCEDURAL';
PROCEDURE: 'PROCEDURE';
// PROCESS: 'PROCESS';
// PROFILE: 'PROFILE';
// PROGRAM: 'PROGRAM';
// PROJECT: 'PROJECT';
// PROPAGATE: 'PROPAGATE';
// PROTECTED: 'PROTECTED';
// PROTECTION: 'PROTECTION';
// PROXY: 'PROXY';
// PRUNING: 'PRUNING';
PUBLIC: 'PUBLIC';
// PULL_PRED: 'PULL_PRED';
// PURGE: 'PURGE';
// PUSH_PRED: 'PUSH_PRED';
// PUSH_SUBQ: 'PUSH_SUBQ';
// PX_FAULT_TOLERANCE: 'PX_FAULT_TOLERANCE';
// PX_GRANULE: 'PX_GRANULE';
// PX_JOIN_FILTER: 'PX_JOIN_FILTER';
// QB_NAME: 'QB_NAME';
// QUERY_BLOCK: 'QUERY_BLOCK';
QUERY: 'QUERY';
// QUEUE_CURR: 'QUEUE_CURR';
// QUEUE: 'QUEUE';
// QUEUE_ROWP: 'QUEUE_ROWP';
// QUIESCE: 'QUIESCE';
// QUORUM: 'QUORUM';
// QUOTA: 'QUOTA';
RAISE: 'RAISE';
// RANDOM_LOCAL: 'RANDOM_LOCAL';
// RANDOM: 'RANDOM';
RANGE: 'RANGE';
// RANKM: 'RANKM';
// RAPIDLY: 'RAPIDLY';
RAW: 'RAW';
// RAWTOHEX: 'RAWTOHEX';
// RAWTONHEX: 'RAWTONHEX';
// RBA: 'RBA';
// RBO_OUTLINE: 'RBO_OUTLINE';
// RDBA: 'RDBA';
READ: 'READ';
// READS: 'READS';
// REALM: 'REALM';
REAL: 'REAL';
// REBALANCE: 'REBALANCE';
// REBUILD: 'REBUILD';
RECORD: 'RECORD';
// RECORDS_PER_BLOCK: 'RECORDS_PER_BLOCK';
// RECOVERABLE: 'RECOVERABLE';
// RECOVER: 'RECOVER';
// RECOVERY: 'RECOVERY';
// RECYCLEBIN: 'RECYCLEBIN';
RECYCLE: 'RECYCLE';
// REDACTION: 'REDACTION';
// REDEFINE: 'REDEFINE';
// REDO: 'REDO';
// REDUCED: 'REDUCED';
// REDUNDANCY: 'REDUNDANCY';
// REF_CASCADE_CURSOR: 'REF_CASCADE_CURSOR';
// REFERENCED: 'REFERENCED';
REFERENCE: 'REFERENCE';
REFERENCES: 'REFERENCES';
REFERENCING: 'REFERENCING';
REF: 'REF';
// REFRESH: 'REFRESH';
// REFTOHEX: 'REFTOHEX';
// REGEXP_COUNT: 'REGEXP_COUNT';
// REGEXP_INSTR: 'REGEXP_INSTR';
// REGEXP_LIKE: 'REGEXP_LIKE';
// REGEXP_REPLACE: 'REGEXP_REPLACE';
// REGEXP_SUBSTR: 'REGEXP_SUBSTR';
// REGISTER: 'REGISTER';
// REGR_AVGX: 'REGR_AVGX';
// REGR_AVGY: 'REGR_AVGY';
// REGR_COUNT: 'REGR_COUNT';
// REGR_INTERCEPT: 'REGR_INTERCEPT';
// REGR_R2: 'REGR_R2';
// REGR_SLOPE: 'REGR_SLOPE';
// REGR_SXX: 'REGR_SXX';
// REGR_SXY: 'REGR_SXY';
// REGR_SYY: 'REGR_SYY';
// REGULAR: 'REGULAR';
REJECT: 'REJECT';
// REKEY: 'REKEY';
// RELATIONAL: 'RELATIONAL';
RELIES_ON: 'RELIES_ON';
// RELOCATE: 'RELOCATE';
// RELY: 'RELY';
// REMAINDER: 'REMAINDER';
// REMOTE_MAPPED: 'REMOTE_MAPPED';
// REMOVE: 'REMOVE';
RENAME: 'RENAME';
// REPAIR: 'REPAIR';
// REPEAT: 'REPEAT';
REPLACE: 'REPLACE';
// REPLICATION: 'REPLICATION';
// REQUIRED: 'REQUIRED';
// RESETLOGS: 'RESETLOGS';
// RESET: 'RESET';
// RESIZE: 'RESIZE';
// RESOLVE: 'RESOLVE';
// RESOLVER: 'RESOLVER';
// RESOURCE: 'RESOURCE';
RESPECT: 'RESPECT';
// RESTART: 'RESTART';
// RESTORE_AS_INTERVALS: 'RESTORE_AS_INTERVALS';
// RESTORE: 'RESTORE';
// RESTRICT_ALL_REF_CONS: 'RESTRICT_ALL_REF_CONS';
// RESTRICTED: 'RESTRICTED';
RESTRICT_REFERENCES: 'RESTRICT_REFERENCES';
// RESTRICT: 'RESTRICT';
RESULT_CACHE: 'RESULT_CACHE';
RESULT: 'RESULT';
// RESUMABLE: 'RESUMABLE';
// RESUME: 'RESUME';
// RETENTION: 'RETENTION';
// RETRY_ON_ROW_CHANGE: 'RETRY_ON_ROW_CHANGE';
RETURNING: 'RETURNING';
RETURN: 'RETURN';
REUSE: 'REUSE';
REVERSE: 'REVERSE';
REVOKE: 'REVOKE';
// REWRITE_OR_ERROR: 'REWRITE_OR_ERROR';
// REWRITE: 'REWRITE';
RIGHT: 'RIGHT';
// ROLE: 'ROLE';
// ROLESET: 'ROLESET';
// ROLES: 'ROLES';
ROLLBACK: 'ROLLBACK';
// ROLLING: 'ROLLING';
ROLLUP: 'ROLLUP';
// ROWDEPENDENCIES: 'ROWDEPENDENCIES';
// ROWID_MAPPING_TABLE: 'ROWID_MAPPING_TABLE';
ROWID: 'ROWID';
// ROWIDTOCHAR: 'ROWIDTOCHAR';
// ROWIDTONCHAR: 'ROWIDTONCHAR';
// ROW_LENGTH: 'ROW_LENGTH';
// ROWNUM: 'ROWNUM';
ROW: 'ROW';
ROWS: 'ROWS';
// RPAD: 'RPAD';
// RTRIM: 'RTRIM';
// RULE: 'RULE';
RULES: 'RULES';
// RUNNING: 'RUNNING';
// SALT: 'SALT';
SAMPLE: 'SAMPLE';
// SAVE_AS_INTERVALS: 'SAVE_AS_INTERVALS';
SAVEPOINT: 'SAVEPOINT';
SAVE: 'SAVE';
// SB4: 'SB4';
// SCALE_ROWS: 'SCALE_ROWS';
// SCALE: 'SCALE';
// SCAN_INSTANCES: 'SCAN_INSTANCES';
// SCAN: 'SCAN';
// SCHEDULER: 'SCHEDULER';
SCHEMACHECK: 'SCHEMACHECK';
SCHEMA: 'SCHEMA';
// SCN_ASCENDING: 'SCN_ASCENDING';
SCN: 'SCN';
// SCOPE: 'SCOPE';
// SCRUB: 'SCRUB';
// SD_ALL: 'SD_ALL';
// SD_INHIBIT: 'SD_INHIBIT';
// SDO_GEOM_MBR: 'SDO_GEOM_MBR';
// SD_SHOW: 'SD_SHOW';
SEARCH: 'SEARCH';
SECOND: 'SECOND';
// SECRET: 'SECRET';
// SECUREFILE_DBA: 'SECUREFILE_DBA';
// SECUREFILE: 'SECUREFILE';
// SECURITY: 'SECURITY';
SEED: 'SEED';
// SEG_BLOCK: 'SEG_BLOCK';
// SEG_FILE: 'SEG_FILE';
SEGMENT: 'SEGMENT';
// SELECTIVITY: 'SELECTIVITY';
SELECT: 'SELECT';
SELF: 'SELF';
// SEMIJOIN_DRIVER: 'SEMIJOIN_DRIVER';
// SEMIJOIN: 'SEMIJOIN';
// SEMI_TO_INNER: 'SEMI_TO_INNER';
// SEQUENCED: 'SEQUENCED';
SEQUENCE: 'SEQUENCE';
SEQUENTIAL: 'SEQUENTIAL';
SERIALIZABLE: 'SERIALIZABLE';
SERIALLY_REUSABLE: 'SERIALLY_REUSABLE';
// SERIAL: 'SERIAL';
SERVERERROR: 'SERVERERROR';
// SERVICE_NAME_CONVERT: 'SERVICE_NAME_CONVERT';
// SERVICES: 'SERVICES';
// SESSION_CACHED_CURSORS: 'SESSION_CACHED_CURSORS';
// SESSION: 'SESSION';
// SESSIONS_PER_USER: 'SESSIONS_PER_USER';
SESSIONTIMEZONE: 'SESSIONTIMEZONE';
// SESSIONTZNAME: 'SESSIONTZNAME';
SET: 'SET';
SETS: 'SETS';
SETTINGS: 'SETTINGS';
// SET_TO_JOIN: 'SET_TO_JOIN';
// SEVERE: 'SEVERE';
// SHARED_POOL: 'SHARED_POOL';
// SHARED: 'SHARED';
SHARE: 'SHARE';
// SHARING: 'SHARING';
// SHELFLIFE: 'SHELFLIFE';
SHOW: 'SHOW';
// SHRINK: 'SHRINK';
SHUTDOWN: 'SHUTDOWN';
SIBLINGS: 'SIBLINGS';
// SID: 'SID';
// SIGNAL_COMPONENT: 'SIGNAL_COMPONENT';
// SIGNAL_FUNCTION: 'SIGNAL_FUNCTION';
// SIGN: 'SIGN';
SIGNTYPE: 'SIGNTYPE';
SIMPLE_INTEGER: 'SIMPLE_INTEGER';
// SIMPLE: 'SIMPLE';
SINGLE: 'SINGLE';
// SINGLETASK: 'SINGLETASK';
// SINH: 'SINH';
// SIN: 'SIN';
SIZE: 'SIZE';
// SKIP_EXT_OPTIMIZER: 'SKIP_EXT_OPTIMIZER';
SKIP_: 'SKIP';
// SKIP_UNQ_UNUSABLE_IDX: 'SKIP_UNQ_UNUSABLE_IDX';
// SKIP_UNUSABLE_INDEXES: 'SKIP_UNUSABLE_INDEXES';
// SMALLFILE: 'SMALLFILE';
SMALLINT: 'SMALLINT';
SNAPSHOT: 'SNAPSHOT';
SOME: 'SOME';
// SORT: 'SORT';
// SOUNDEX: 'SOUNDEX';
// SOURCE_FILE_DIRECTORY: 'SOURCE_FILE_DIRECTORY';
// SOURCE_FILE_NAME_CONVERT: 'SOURCE_FILE_NAME_CONVERT';
// SOURCE: 'SOURCE';
// SPACE_KEYWORD: 'SPACE';
SPECIFICATION: 'SPECIFICATION';
// SPFILE: 'SPFILE';
// SPLIT: 'SPLIT';
// SPREADSHEET: 'SPREADSHEET';
SQLDATA: 'SQLDATA';
SQLERROR: 'SQLERROR';
// SQLLDR: 'SQLLDR';
// SQL: 'SQL';
// SQL_TRACE: 'SQL_TRACE';
// SQL_TRANSLATION_PROFILE: 'SQL_TRANSLATION_PROFILE';
// SQRT: 'SQRT';
// STALE: 'STALE';
STANDALONE: 'STANDALONE';
// STANDARD_HASH: 'STANDARD_HASH';
// STANDBY_MAX_DATA_DELAY: 'STANDBY_MAX_DATA_DELAY';
// STANDBYS: 'STANDBYS';
// STANDBY: 'STANDBY';
// STAR: 'STAR';
// STAR_TRANSFORMATION: 'STAR_TRANSFORMATION';
START: 'START';
STARTUP: 'STARTUP';
STATEMENT_ID: 'STATEMENT_ID';
// STATEMENT_QUEUING: 'STATEMENT_QUEUING';
// STATEMENTS: 'STATEMENTS';
STATEMENT: 'STATEMENT';
// STATE: 'STATE';
STATIC: 'STATIC';
STATISTICS: 'STATISTICS';
// STATS_BINOMIAL_TEST: 'STATS_BINOMIAL_TEST';
// STATS_CROSSTAB: 'STATS_CROSSTAB';
// STATS_F_TEST: 'STATS_F_TEST';
// STATS_KS_TEST: 'STATS_KS_TEST';
// STATS_MODE: 'STATS_MODE';
// STATS_MW_TEST: 'STATS_MW_TEST';
// STATS_ONE_WAY_ANOVA: 'STATS_ONE_WAY_ANOVA';
// STATS_T_TEST_INDEP: 'STATS_T_TEST_INDEP';
// STATS_T_TEST_INDEPU: 'STATS_T_TEST_INDEPU';
// STATS_T_TEST_ONE: 'STATS_T_TEST_ONE';
// STATS_T_TEST_PAIRED: 'STATS_T_TEST_PAIRED';
// STATS_WSR_TEST: 'STATS_WSR_TEST';
// STDDEV_POP: 'STDDEV_POP';
// STDDEV_SAMP: 'STDDEV_SAMP';
// STOP: 'STOP';
STORAGE: 'STORAGE';
// STORE: 'STORE';
// STREAMS: 'STREAMS';
// STREAM: 'STREAM';
// STRICT: 'STRICT';
STRING: 'STRING';
// STRIPE_COLUMNS: 'STRIPE_COLUMNS';
// STRIPE_WIDTH: 'STRIPE_WIDTH';
// STRIP: 'STRIP';
// STRUCTURE: 'STRUCTURE';
SUBMULTISET: 'SUBMULTISET';
// SUBPARTITION_REL: 'SUBPARTITION_REL';
// SUBPARTITIONS: 'SUBPARTITIONS';
SUBPARTITION: 'SUBPARTITION';
// SUBQUERIES: 'SUBQUERIES';
// SUBQUERY_PRUNING: 'SUBQUERY_PRUNING';
// SUBSCRIBE: 'SUBSCRIBE';
// SUBSET: 'SUBSET';
SUBSTITUTABLE: 'SUBSTITUTABLE';
// SUBSTR2: 'SUBSTR2';
// SUBSTR4: 'SUBSTR4';
// SUBSTRB: 'SUBSTRB';
// SUBSTRC: 'SUBSTRC';
SUBTYPE: 'SUBTYPE';
// SUCCESSFUL: 'SUCCESSFUL';
SUCCESS: 'SUCCESS';
// SUMMARY: 'SUMMARY';
// SUPPLEMENTAL: 'SUPPLEMENTAL';
SUSPEND: 'SUSPEND';
// SWAP_JOIN_INPUTS: 'SWAP_JOIN_INPUTS';
// SWITCHOVER: 'SWITCHOVER';
// SWITCH: 'SWITCH';
// SYNCHRONOUS: 'SYNCHRONOUS';
// SYNC: 'SYNC';
SYNONYM: 'SYNONYM';
// SYSASM: 'SYSASM';
// SYS_AUDIT: 'SYS_AUDIT';
// SYSAUX: 'SYSAUX';
// SYSBACKUP: 'SYSBACKUP';
// SYS_CHECKACL: 'SYS_CHECKACL';
// SYS_CHECK_PRIVILEGE: 'SYS_CHECK_PRIVILEGE';
// SYS_CONNECT_BY_PATH: 'SYS_CONNECT_BY_PATH';
// SYS_CONTEXT: 'SYS_CONTEXT';
// SYSDATE: 'SYSDATE';
// SYSDBA: 'SYSDBA';
// SYS_DBURIGEN: 'SYS_DBURIGEN';
// SYSDG: 'SYSDG';
// SYS_DL_CURSOR: 'SYS_DL_CURSOR';
// SYS_DM_RXFORM_CHR: 'SYS_DM_RXFORM_CHR';
// SYS_DM_RXFORM_NUM: 'SYS_DM_RXFORM_NUM';
// SYS_DOM_COMPARE: 'SYS_DOM_COMPARE';
// SYS_DST_PRIM2SEC: 'SYS_DST_PRIM2SEC';
// SYS_DST_SEC2PRIM: 'SYS_DST_SEC2PRIM';
// SYS_ET_BFILE_TO_RAW: 'SYS_ET_BFILE_TO_RAW';
// SYS_ET_BLOB_TO_IMAGE: 'SYS_ET_BLOB_TO_IMAGE';
// SYS_ET_IMAGE_TO_BLOB: 'SYS_ET_IMAGE_TO_BLOB';
// SYS_ET_RAW_TO_BFILE: 'SYS_ET_RAW_TO_BFILE';
// SYS_EXTPDTXT: 'SYS_EXTPDTXT';
// SYS_EXTRACT_UTC: 'SYS_EXTRACT_UTC';
// SYS_FBT_INSDEL: 'SYS_FBT_INSDEL';
// SYS_FILTER_ACLS: 'SYS_FILTER_ACLS';
// SYS_FNMATCHES: 'SYS_FNMATCHES';
// SYS_FNREPLACE: 'SYS_FNREPLACE';
// SYS_GET_ACLIDS: 'SYS_GET_ACLIDS';
// SYS_GET_COL_ACLIDS: 'SYS_GET_COL_ACLIDS';
// SYS_GET_PRIVILEGES: 'SYS_GET_PRIVILEGES';
// SYS_GETTOKENID: 'SYS_GETTOKENID';
// SYS_GETXTIVAL: 'SYS_GETXTIVAL';
// SYS_GUID: 'SYS_GUID';
// SYSGUID: 'SYSGUID';
// SYSKM: 'SYSKM';
// SYS_MAKE_XMLNODEID: 'SYS_MAKE_XMLNODEID';
// SYS_MAKEXML: 'SYS_MAKEXML';
// SYS_MKXMLATTR: 'SYS_MKXMLATTR';
// SYS_MKXTI: 'SYS_MKXTI';
// SYSOBJ: 'SYSOBJ';
// SYS_OP_ADT2BIN: 'SYS_OP_ADT2BIN';
// SYS_OP_ADTCONS: 'SYS_OP_ADTCONS';
// SYS_OP_ALSCRVAL: 'SYS_OP_ALSCRVAL';
// SYS_OP_ATG: 'SYS_OP_ATG';
// SYS_OP_BIN2ADT: 'SYS_OP_BIN2ADT';
// SYS_OP_BITVEC: 'SYS_OP_BITVEC';
// SYS_OP_BL2R: 'SYS_OP_BL2R';
// SYS_OP_BLOOM_FILTER_LIST: 'SYS_OP_BLOOM_FILTER_LIST';
// SYS_OP_BLOOM_FILTER: 'SYS_OP_BLOOM_FILTER';
// SYS_OP_C2C: 'SYS_OP_C2C';
// SYS_OP_CAST: 'SYS_OP_CAST';
// SYS_OP_CEG: 'SYS_OP_CEG';
// SYS_OP_CL2C: 'SYS_OP_CL2C';
// SYS_OP_COMBINED_HASH: 'SYS_OP_COMBINED_HASH';
// SYS_OP_COMP: 'SYS_OP_COMP';
// SYS_OP_CONVERT: 'SYS_OP_CONVERT';
// SYS_OP_COUNTCHG: 'SYS_OP_COUNTCHG';
// SYS_OP_CSCONV: 'SYS_OP_CSCONV';
// SYS_OP_CSCONVTEST: 'SYS_OP_CSCONVTEST';
// SYS_OP_CSR: 'SYS_OP_CSR';
// SYS_OP_CSX_PATCH: 'SYS_OP_CSX_PATCH';
// SYS_OP_CYCLED_SEQ: 'SYS_OP_CYCLED_SEQ';
// SYS_OP_DECOMP: 'SYS_OP_DECOMP';
// SYS_OP_DESCEND: 'SYS_OP_DESCEND';
// SYS_OP_DISTINCT: 'SYS_OP_DISTINCT';
// SYS_OP_DRA: 'SYS_OP_DRA';
// SYS_OP_DUMP: 'SYS_OP_DUMP';
// SYS_OP_DV_CHECK: 'SYS_OP_DV_CHECK';
// SYS_OP_ENFORCE_NOT_NULL: 'SYS_OP_ENFORCE_NOT_NULL$';
// SYSOPER: 'SYSOPER';
// SYS_OP_EXTRACT: 'SYS_OP_EXTRACT';
// SYS_OP_GROUPING: 'SYS_OP_GROUPING';
// SYS_OP_GUID: 'SYS_OP_GUID';
// SYS_OP_HASH: 'SYS_OP_HASH';
// SYS_OP_IIX: 'SYS_OP_IIX';
// SYS_OP_ITR: 'SYS_OP_ITR';
// SYS_OP_KEY_VECTOR_CREATE: 'SYS_OP_KEY_VECTOR_CREATE';
// SYS_OP_KEY_VECTOR_FILTER_LIST: 'SYS_OP_KEY_VECTOR_FILTER_LIST';
// SYS_OP_KEY_VECTOR_FILTER: 'SYS_OP_KEY_VECTOR_FILTER';
// SYS_OP_KEY_VECTOR_SUCCEEDED: 'SYS_OP_KEY_VECTOR_SUCCEEDED';
// SYS_OP_KEY_VECTOR_USE: 'SYS_OP_KEY_VECTOR_USE';
// SYS_OP_LBID: 'SYS_OP_LBID';
// SYS_OP_LOBLOC2BLOB: 'SYS_OP_LOBLOC2BLOB';
// SYS_OP_LOBLOC2CLOB: 'SYS_OP_LOBLOC2CLOB';
// SYS_OP_LOBLOC2ID: 'SYS_OP_LOBLOC2ID';
// SYS_OP_LOBLOC2NCLOB: 'SYS_OP_LOBLOC2NCLOB';
// SYS_OP_LOBLOC2TYP: 'SYS_OP_LOBLOC2TYP';
// SYS_OP_LSVI: 'SYS_OP_LSVI';
// SYS_OP_LVL: 'SYS_OP_LVL';
// SYS_OP_MAKEOID: 'SYS_OP_MAKEOID';
// SYS_OP_MAP_NONNULL: 'SYS_OP_MAP_NONNULL';
// SYS_OP_MSR: 'SYS_OP_MSR';
// SYS_OP_NICOMBINE: 'SYS_OP_NICOMBINE';
// SYS_OP_NIEXTRACT: 'SYS_OP_NIEXTRACT';
// SYS_OP_NII: 'SYS_OP_NII';
// SYS_OP_NIX: 'SYS_OP_NIX';
// SYS_OP_NOEXPAND: 'SYS_OP_NOEXPAND';
// SYS_OP_NTCIMG: 'SYS_OP_NTCIMG$';
// SYS_OP_NUMTORAW: 'SYS_OP_NUMTORAW';
// SYS_OP_OIDVALUE: 'SYS_OP_OIDVALUE';
// SYS_OP_OPNSIZE: 'SYS_OP_OPNSIZE';
// SYS_OP_PAR_1: 'SYS_OP_PAR_1';
// SYS_OP_PARGID_1: 'SYS_OP_PARGID_1';
// SYS_OP_PARGID: 'SYS_OP_PARGID';
// SYS_OP_PAR: 'SYS_OP_PAR';
// SYS_OP_PART_ID: 'SYS_OP_PART_ID';
// SYS_OP_PIVOT: 'SYS_OP_PIVOT';
// SYS_OP_R2O: 'SYS_OP_R2O';
// SYS_OP_RAWTONUM: 'SYS_OP_RAWTONUM';
// SYS_OP_RDTM: 'SYS_OP_RDTM';
// SYS_OP_REF: 'SYS_OP_REF';
// SYS_OP_RMTD: 'SYS_OP_RMTD';
// SYS_OP_ROWIDTOOBJ: 'SYS_OP_ROWIDTOOBJ';
// SYS_OP_RPB: 'SYS_OP_RPB';
// SYS_OPTLOBPRBSC: 'SYS_OPTLOBPRBSC';
// SYS_OP_TOSETID: 'SYS_OP_TOSETID';
// SYS_OP_TPR: 'SYS_OP_TPR';
// SYS_OP_TRTB: 'SYS_OP_TRTB';
// SYS_OPTXICMP: 'SYS_OPTXICMP';
// SYS_OPTXQCASTASNQ: 'SYS_OPTXQCASTASNQ';
// SYS_OP_UNDESCEND: 'SYS_OP_UNDESCEND';
// SYS_OP_VECAND: 'SYS_OP_VECAND';
// SYS_OP_VECBIT: 'SYS_OP_VECBIT';
// SYS_OP_VECOR: 'SYS_OP_VECOR';
// SYS_OP_VECXOR: 'SYS_OP_VECXOR';
// SYS_OP_VERSION: 'SYS_OP_VERSION';
// SYS_OP_VREF: 'SYS_OP_VREF';
// SYS_OP_VVD: 'SYS_OP_VVD';
// SYS_OP_XMLCONS_FOR_CSX: 'SYS_OP_XMLCONS_FOR_CSX';
// SYS_OP_XPTHATG: 'SYS_OP_XPTHATG';
// SYS_OP_XPTHIDX: 'SYS_OP_XPTHIDX';
// SYS_OP_XPTHOP: 'SYS_OP_XPTHOP';
// SYS_OP_XTXT2SQLT: 'SYS_OP_XTXT2SQLT';
// SYS_OP_ZONE_ID: 'SYS_OP_ZONE_ID';
// SYS_ORDERKEY_DEPTH: 'SYS_ORDERKEY_DEPTH';
// SYS_ORDERKEY_MAXCHILD: 'SYS_ORDERKEY_MAXCHILD';
// SYS_ORDERKEY_PARENT: 'SYS_ORDERKEY_PARENT';
// SYS_PARALLEL_TXN: 'SYS_PARALLEL_TXN';
// SYS_PATHID_IS_ATTR: 'SYS_PATHID_IS_ATTR';
// SYS_PATHID_IS_NMSPC: 'SYS_PATHID_IS_NMSPC';
// SYS_PATHID_LASTNAME: 'SYS_PATHID_LASTNAME';
// SYS_PATHID_LASTNMSPC: 'SYS_PATHID_LASTNMSPC';
// SYS_PATH_REVERSE: 'SYS_PATH_REVERSE';
// SYS_PXQEXTRACT: 'SYS_PXQEXTRACT';
// SYS_RAW_TO_XSID: 'SYS_RAW_TO_XSID';
// SYS_RID_ORDER: 'SYS_RID_ORDER';
// SYS_ROW_DELTA: 'SYS_ROW_DELTA';
// SYS_SC_2_XMLT: 'SYS_SC_2_XMLT';
// SYS_SYNRCIREDO: 'SYS_SYNRCIREDO';
// SYSTEM_DEFINED: 'SYSTEM_DEFINED';
// SYSTEM: 'SYSTEM';
// SYSTIMESTAMP: 'SYSTIMESTAMP';
// SYS_TYPEID: 'SYS_TYPEID';
// SYS_UMAKEXML: 'SYS_UMAKEXML';
// SYS_XMLANALYZE: 'SYS_XMLANALYZE';
// SYS_XMLCONTAINS: 'SYS_XMLCONTAINS';
// SYS_XMLCONV: 'SYS_XMLCONV';
// SYS_XMLEXNSURI: 'SYS_XMLEXNSURI';
// SYS_XMLGEN: 'SYS_XMLGEN';
// SYS_XMLI_LOC_ISNODE: 'SYS_XMLI_LOC_ISNODE';
// SYS_XMLI_LOC_ISTEXT: 'SYS_XMLI_LOC_ISTEXT';
// SYS_XMLINSTR: 'SYS_XMLINSTR';
// SYS_XMLLOCATOR_GETSVAL: 'SYS_XMLLOCATOR_GETSVAL';
// SYS_XMLNODEID_GETCID: 'SYS_XMLNODEID_GETCID';
// SYS_XMLNODEID_GETLOCATOR: 'SYS_XMLNODEID_GETLOCATOR';
// SYS_XMLNODEID_GETOKEY: 'SYS_XMLNODEID_GETOKEY';
// SYS_XMLNODEID_GETPATHID: 'SYS_XMLNODEID_GETPATHID';
// SYS_XMLNODEID_GETPTRID: 'SYS_XMLNODEID_GETPTRID';
// SYS_XMLNODEID_GETRID: 'SYS_XMLNODEID_GETRID';
// SYS_XMLNODEID_GETSVAL: 'SYS_XMLNODEID_GETSVAL';
// SYS_XMLNODEID_GETTID: 'SYS_XMLNODEID_GETTID';
// SYS_XMLNODEID: 'SYS_XMLNODEID';
// SYS_XMLT_2_SC: 'SYS_XMLT_2_SC';
// SYS_XMLTRANSLATE: 'SYS_XMLTRANSLATE';
// SYS_XMLTYPE2SQL: 'SYS_XMLTYPE2SQL';
// SYS_XQ_ASQLCNV: 'SYS_XQ_ASQLCNV';
// SYS_XQ_ATOMCNVCHK: 'SYS_XQ_ATOMCNVCHK';
// SYS_XQBASEURI: 'SYS_XQBASEURI';
// SYS_XQCASTABLEERRH: 'SYS_XQCASTABLEERRH';
// SYS_XQCODEP2STR: 'SYS_XQCODEP2STR';
// SYS_XQCODEPEQ: 'SYS_XQCODEPEQ';
// SYS_XQCON2SEQ: 'SYS_XQCON2SEQ';
// SYS_XQCONCAT: 'SYS_XQCONCAT';
// SYS_XQDELETE: 'SYS_XQDELETE';
// SYS_XQDFLTCOLATION: 'SYS_XQDFLTCOLATION';
// SYS_XQDOC: 'SYS_XQDOC';
// SYS_XQDOCURI: 'SYS_XQDOCURI';
// SYS_XQDURDIV: 'SYS_XQDURDIV';
// SYS_XQED4URI: 'SYS_XQED4URI';
// SYS_XQENDSWITH: 'SYS_XQENDSWITH';
// SYS_XQERRH: 'SYS_XQERRH';
// SYS_XQERR: 'SYS_XQERR';
// SYS_XQESHTMLURI: 'SYS_XQESHTMLURI';
// SYS_XQEXLOBVAL: 'SYS_XQEXLOBVAL';
// SYS_XQEXSTWRP: 'SYS_XQEXSTWRP';
// SYS_XQEXTRACT: 'SYS_XQEXTRACT';
// SYS_XQEXTRREF: 'SYS_XQEXTRREF';
// SYS_XQEXVAL: 'SYS_XQEXVAL';
// SYS_XQFB2STR: 'SYS_XQFB2STR';
// SYS_XQFNBOOL: 'SYS_XQFNBOOL';
// SYS_XQFNCMP: 'SYS_XQFNCMP';
// SYS_XQFNDATIM: 'SYS_XQFNDATIM';
// SYS_XQFNLNAME: 'SYS_XQFNLNAME';
// SYS_XQFNNM: 'SYS_XQFNNM';
// SYS_XQFNNSURI: 'SYS_XQFNNSURI';
// SYS_XQFNPREDTRUTH: 'SYS_XQFNPREDTRUTH';
// SYS_XQFNQNM: 'SYS_XQFNQNM';
// SYS_XQFNROOT: 'SYS_XQFNROOT';
// SYS_XQFORMATNUM: 'SYS_XQFORMATNUM';
// SYS_XQFTCONTAIN: 'SYS_XQFTCONTAIN';
// SYS_XQFUNCR: 'SYS_XQFUNCR';
// SYS_XQGETCONTENT: 'SYS_XQGETCONTENT';
// SYS_XQINDXOF: 'SYS_XQINDXOF';
// SYS_XQINSERT: 'SYS_XQINSERT';
// SYS_XQINSPFX: 'SYS_XQINSPFX';
// SYS_XQIRI2URI: 'SYS_XQIRI2URI';
// SYS_XQLANG: 'SYS_XQLANG';
// SYS_XQLLNMFRMQNM: 'SYS_XQLLNMFRMQNM';
// SYS_XQMKNODEREF: 'SYS_XQMKNODEREF';
// SYS_XQNILLED: 'SYS_XQNILLED';
// SYS_XQNODENAME: 'SYS_XQNODENAME';
// SYS_XQNORMSPACE: 'SYS_XQNORMSPACE';
// SYS_XQNORMUCODE: 'SYS_XQNORMUCODE';
// SYS_XQ_NRNG: 'SYS_XQ_NRNG';
// SYS_XQNSP4PFX: 'SYS_XQNSP4PFX';
// SYS_XQNSPFRMQNM: 'SYS_XQNSPFRMQNM';
// SYS_XQPFXFRMQNM: 'SYS_XQPFXFRMQNM';
// SYS_XQ_PKSQL2XML: 'SYS_XQ_PKSQL2XML';
// SYS_XQPOLYABS: 'SYS_XQPOLYABS';
// SYS_XQPOLYADD: 'SYS_XQPOLYADD';
// SYS_XQPOLYCEL: 'SYS_XQPOLYCEL';
// SYS_XQPOLYCSTBL: 'SYS_XQPOLYCSTBL';
// SYS_XQPOLYCST: 'SYS_XQPOLYCST';
// SYS_XQPOLYDIV: 'SYS_XQPOLYDIV';
// SYS_XQPOLYFLR: 'SYS_XQPOLYFLR';
// SYS_XQPOLYMOD: 'SYS_XQPOLYMOD';
// SYS_XQPOLYMUL: 'SYS_XQPOLYMUL';
// SYS_XQPOLYRND: 'SYS_XQPOLYRND';
// SYS_XQPOLYSQRT: 'SYS_XQPOLYSQRT';
// SYS_XQPOLYSUB: 'SYS_XQPOLYSUB';
// SYS_XQPOLYUMUS: 'SYS_XQPOLYUMUS';
// SYS_XQPOLYUPLS: 'SYS_XQPOLYUPLS';
// SYS_XQPOLYVEQ: 'SYS_XQPOLYVEQ';
// SYS_XQPOLYVGE: 'SYS_XQPOLYVGE';
// SYS_XQPOLYVGT: 'SYS_XQPOLYVGT';
// SYS_XQPOLYVLE: 'SYS_XQPOLYVLE';
// SYS_XQPOLYVLT: 'SYS_XQPOLYVLT';
// SYS_XQPOLYVNE: 'SYS_XQPOLYVNE';
// SYS_XQREF2VAL: 'SYS_XQREF2VAL';
// SYS_XQRENAME: 'SYS_XQRENAME';
// SYS_XQREPLACE: 'SYS_XQREPLACE';
// SYS_XQRESVURI: 'SYS_XQRESVURI';
// SYS_XQRNDHALF2EVN: 'SYS_XQRNDHALF2EVN';
// SYS_XQRSLVQNM: 'SYS_XQRSLVQNM';
// SYS_XQRYENVPGET: 'SYS_XQRYENVPGET';
// SYS_XQRYVARGET: 'SYS_XQRYVARGET';
// SYS_XQRYWRP: 'SYS_XQRYWRP';
// SYS_XQSEQ2CON4XC: 'SYS_XQSEQ2CON4XC';
// SYS_XQSEQ2CON: 'SYS_XQSEQ2CON';
// SYS_XQSEQDEEPEQ: 'SYS_XQSEQDEEPEQ';
// SYS_XQSEQINSB: 'SYS_XQSEQINSB';
// SYS_XQSEQRM: 'SYS_XQSEQRM';
// SYS_XQSEQRVS: 'SYS_XQSEQRVS';
// SYS_XQSEQSUB: 'SYS_XQSEQSUB';
// SYS_XQSEQTYPMATCH: 'SYS_XQSEQTYPMATCH';
// SYS_XQSTARTSWITH: 'SYS_XQSTARTSWITH';
// SYS_XQSTATBURI: 'SYS_XQSTATBURI';
// SYS_XQSTR2CODEP: 'SYS_XQSTR2CODEP';
// SYS_XQSTRJOIN: 'SYS_XQSTRJOIN';
// SYS_XQSUBSTRAFT: 'SYS_XQSUBSTRAFT';
// SYS_XQSUBSTRBEF: 'SYS_XQSUBSTRBEF';
// SYS_XQTOKENIZE: 'SYS_XQTOKENIZE';
// SYS_XQTREATAS: 'SYS_XQTREATAS';
// SYS_XQ_UPKXML2SQL: 'SYS_XQ_UPKXML2SQL';
// SYS_XQXFORM: 'SYS_XQXFORM';
// SYS_XSID_TO_RAW: 'SYS_XSID_TO_RAW';
// SYS_ZMAP_FILTER: 'SYS_ZMAP_FILTER';
// SYS_ZMAP_REFRESH: 'SYS_ZMAP_REFRESH';
// TABLE_LOOKUP_BY_NL: 'TABLE_LOOKUP_BY_NL';
// TABLESPACE_NO: 'TABLESPACE_NO';
TABLESPACE: 'TABLESPACE';
// TABLES: 'TABLES';
// TABLE_STATS: 'TABLE_STATS';
TABLE: 'TABLE';
// TABNO: 'TABNO';
// TAG: 'TAG';
// TANH: 'TANH';
// TAN: 'TAN';
// TBLORIDXPARTNUM: 'TBL$OR$IDX$PART$NUM';
// TEMPFILE: 'TEMPFILE';
// TEMPLATE: 'TEMPLATE';
TEMPORARY: 'TEMPORARY';
// TEMP_TABLE: 'TEMP_TABLE';
// TEST: 'TEST';
// TEXT: 'TEXT';
// THAN: 'THAN';
THEN: 'THEN';
THE: 'THE';
// THREAD: 'THREAD';
// THROUGH: 'THROUGH';
// TIER: 'TIER';
// TIES: 'TIES';
// TIMEOUT: 'TIMEOUT';
TIMESTAMP_LTZ_UNCONSTRAINED: 'TIMESTAMP_LTZ_UNCONSTRAINED';
TIMESTAMP: 'TIMESTAMP';
TIMESTAMP_TZ_UNCONSTRAINED: 'TIMESTAMP_TZ_UNCONSTRAINED';
TIMESTAMP_UNCONSTRAINED: 'TIMESTAMP_UNCONSTRAINED';
// TIMES: 'TIMES';
TIME: 'TIME';
TIMEZONE_ABBR: 'TIMEZONE_ABBR';
TIMEZONE_HOUR: 'TIMEZONE_HOUR';
TIMEZONE_MINUTE: 'TIMEZONE_MINUTE';
// TIMEZONE_OFFSET: 'TIMEZONE_OFFSET';
TIMEZONE_REGION: 'TIMEZONE_REGION';
// TIME_ZONE: 'TIME_ZONE';
// TIV_GB: 'TIV_GB';
// TIV_SSF: 'TIV_SSF';
// TO_ACLID: 'TO_ACLID';
// TO_BINARY_DOUBLE: 'TO_BINARY_DOUBLE';
// TO_BINARY_FLOAT: 'TO_BINARY_FLOAT';
// TO_BLOB: 'TO_BLOB';
// TO_CLOB: 'TO_CLOB';
// TO_DSINTERVAL: 'TO_DSINTERVAL';
// TO_LOB: 'TO_LOB';
// TO_MULTI_BYTE: 'TO_MULTI_BYTE';
// TO_NCHAR: 'TO_NCHAR';
// TO_NCLOB: 'TO_NCLOB';
// TO_NUMBER: 'TO_NUMBER';
// TOPLEVEL: 'TOPLEVEL';
// TO_SINGLE_BYTE: 'TO_SINGLE_BYTE';
// TO_TIMESTAMP: 'TO_TIMESTAMP';
// TO_TIMESTAMP_TZ: 'TO_TIMESTAMP_TZ';
// TO_TIME: 'TO_TIME';
// TO_TIME_TZ: 'TO_TIME_TZ';
TO: 'TO';
// TO_YMINTERVAL: 'TO_YMINTERVAL';
// TRACE: 'TRACE';
// TRACING: 'TRACING';
// TRACKING: 'TRACKING';
TRAILING: 'TRAILING';
TRANSACTION: 'TRANSACTION';
// TRANSFORM_DISTINCT_AGG: 'TRANSFORM_DISTINCT_AGG';
// TRANSITIONAL: 'TRANSITIONAL';
// TRANSITION: 'TRANSITION';
TRANSLATE: 'TRANSLATE';
// TRANSLATION: 'TRANSLATION';
TREAT: 'TREAT';
// TRIGGERS: 'TRIGGERS';
TRIGGER: 'TRIGGER';
TRUE: 'TRUE';
TRUNCATE: 'TRUNCATE';
// TRUNC: 'TRUNC';
// TRUSTED: 'TRUSTED';
// TRUST: 'TRUST';
// TUNING: 'TUNING';
// TX: 'TX';
// TYPES: 'TYPES';
TYPE: 'TYPE';
// TZ_OFFSET: 'TZ_OFFSET';
// UB2: 'UB2';
// UBA: 'UBA';
// UCS2: 'UCS2';
// UID: 'UID';
// UNARCHIVED: 'UNARCHIVED';
UNBOUNDED: 'UNBOUNDED';
// UNBOUND: 'UNBOUND';
// UNCONDITIONAL: 'UNCONDITIONAL';
UNDER: 'UNDER';
// UNDO: 'UNDO';
// UNDROP: 'UNDROP';
// UNIFORM: 'UNIFORM';
UNION: 'UNION';
UNIQUE: 'UNIQUE';
// UNISTR: 'UNISTR';
UNLIMITED: 'UNLIMITED';
// UNLOAD: 'UNLOAD';
// UNLOCK: 'UNLOCK';
// UNMATCHED: 'UNMATCHED';
// UNNEST_INNERJ_DISTINCT_VIEW: 'UNNEST_INNERJ_DISTINCT_VIEW';
// UNNEST_NOSEMIJ_NODISTINCTVIEW: 'UNNEST_NOSEMIJ_NODISTINCTVIEW';
// UNNEST_SEMIJ_VIEW: 'UNNEST_SEMIJ_VIEW';
// UNNEST: 'UNNEST';
// UNPACKED: 'UNPACKED';
UNPIVOT: 'UNPIVOT';
// UNPLUG: 'UNPLUG';
// UNPROTECTED: 'UNPROTECTED';
// UNQUIESCE: 'UNQUIESCE';
// UNRECOVERABLE: 'UNRECOVERABLE';
// UNRESTRICTED: 'UNRESTRICTED';
// UNSUBSCRIBE: 'UNSUBSCRIBE';
UNTIL: 'UNTIL';
// UNUSABLE: 'UNUSABLE';
// UNUSED: 'UNUSED';
// UPDATABLE: 'UPDATABLE';
UPDATED: 'UPDATED';
UPDATE: 'UPDATE';
// UPDATEXML: 'UPDATEXML';
// UPD_INDEXES: 'UPD_INDEXES';
// UPD_JOININDEX: 'UPD_JOININDEX';
// UPGRADE: 'UPGRADE';
// UPPER: 'UPPER';
UPSERT: 'UPSERT';
UROWID: 'UROWID';
// USABLE: 'USABLE';
// USAGE: 'USAGE';
// USE_ANTI: 'USE_ANTI';
// USE_CONCAT: 'USE_CONCAT';
// USE_CUBE: 'USE_CUBE';
// USE_HASH_AGGREGATION: 'USE_HASH_AGGREGATION';
// USE_HASH_GBY_FOR_PUSHDOWN: 'USE_HASH_GBY_FOR_PUSHDOWN';
// USE_HASH: 'USE_HASH';
// USE_HIDDEN_PARTITIONS: 'USE_HIDDEN_PARTITIONS';
// USE_INVISIBLE_INDEXES: 'USE_INVISIBLE_INDEXES';
// USE_MERGE_CARTESIAN: 'USE_MERGE_CARTESIAN';
// USE_MERGE: 'USE_MERGE';
// USE_NL: 'USE_NL';
// USE_NL_WITH_INDEX: 'USE_NL_WITH_INDEX';
// USE_PRIVATE_OUTLINES: 'USE_PRIVATE_OUTLINES';
// USER_DATA: 'USER_DATA';
// USER_DEFINED: 'USER_DEFINED';
// USERENV: 'USERENV';
// USERGROUP: 'USERGROUP';
// USER_RECYCLEBIN: 'USER_RECYCLEBIN';
// USERS: 'USERS';
// USER_TABLESPACES: 'USER_TABLESPACES';
// USER: 'USER';
// USE_SEMI: 'USE_SEMI';
// USE_STORED_OUTLINES: 'USE_STORED_OUTLINES';
// USE_TTT_FOR_GSETS: 'USE_TTT_FOR_GSETS';
USE: 'USE';
// USE_VECTOR_AGGREGATION: 'USE_VECTOR_AGGREGATION';
// USE_WEAK_NAME_RESL: 'USE_WEAK_NAME_RESL';
// USING_NO_EXPAND: 'USING_NO_EXPAND';
USING: 'USING';
// UTF16BE: 'UTF16BE';
// UTF16LE: 'UTF16LE';
// UTF32: 'UTF32';
// UTF8: 'UTF8';
// V1: 'V1';
// V2: 'V2';
VALIDATE: 'VALIDATE';
// VALIDATION: 'VALIDATION';
// VALID_TIME_END: 'VALID_TIME_END';
VALUES: 'VALUES';
VALUE: 'VALUE';
VARCHAR2: 'VARCHAR2';
VARCHAR: 'VARCHAR';
VARIABLE: 'VARIABLE';
// VAR_POP: 'VAR_POP';
// VARRAYS: 'VARRAYS';
VARRAY: 'VARRAY';
// VAR_SAMP: 'VAR_SAMP';
VARYING: 'VARYING';
// VECTOR_READ_TRACE: 'VECTOR_READ_TRACE';
// VECTOR_READ: 'VECTOR_READ';
// VECTOR_TRANSFORM_DIMS: 'VECTOR_TRANSFORM_DIMS';
// VECTOR_TRANSFORM_FACT: 'VECTOR_TRANSFORM_FACT';
// VECTOR_TRANSFORM: 'VECTOR_TRANSFORM';
// VERIFIER: 'VERIFIER';
// VERIFY: 'VERIFY';
// VERSIONING: 'VERSIONING';
// VERSIONS_ENDSCN: 'VERSIONS_ENDSCN';
// VERSIONS_ENDTIME: 'VERSIONS_ENDTIME';
// VERSIONS_OPERATION: 'VERSIONS_OPERATION';
// VERSIONS_STARTSCN: 'VERSIONS_STARTSCN';
// VERSIONS_STARTTIME: 'VERSIONS_STARTTIME';
VERSIONS: 'VERSIONS';
// VERSIONS_XID: 'VERSIONS_XID';
VERSION: 'VERSION';
// VIEW: 'VIEW';
// VIOLATION: 'VIOLATION';
// VIRTUAL: 'VIRTUAL';
// VISIBILITY: 'VISIBILITY';
// VISIBLE: 'VISIBLE';
// VOLUME: 'VOLUME';
// VSIZE: 'VSIZE';
WAIT: 'WAIT';
// WALLET: 'WALLET';
WARNING: 'WARNING';
// WEEKS: 'WEEKS';
// WEEK: 'WEEK';
WELLFORMED: 'WELLFORMED';
WHENEVER: 'WHENEVER';
WHEN: 'WHEN';
WHERE: 'WHERE';
WHILE: 'WHILE';
// WHITESPACE: 'WHITESPACE';
// WIDTH_BUCKET: 'WIDTH_BUCKET';
WITHIN: 'WITHIN';
// WITHOUT: 'WITHOUT';
// WITH_PLSQL: 'WITH_PLSQL';
WITH: 'WITH';
WORK: 'WORK';
// WRAPPED: 'WRAPPED';
// WRAPPER: 'WRAPPER';
WRITE: 'WRITE';
// XDB_FASTPATH_INSERT: 'XDB_FASTPATH_INSERT';
// X_DYN_PRUNE: 'X_DYN_PRUNE';
// XID: 'XID';
// XML2OBJECT: 'XML2OBJECT';
XMLAGG: 'XMLAGG';
XMLATTRIBUTES: 'XMLATTRIBUTES';
XMLCAST: 'XMLCAST';
// XMLCDATA: 'XMLCDATA';
XMLCOLATTVAL: 'XMLCOLATTVAL';
// XMLCOMMENT: 'XMLCOMMENT';
// XMLCONCAT: 'XMLCONCAT';
// XMLDIFF: 'XMLDIFF';
// XML_DML_RWT_STMT: 'XML_DML_RWT_STMT';
XMLELEMENT: 'XMLELEMENT';
// XMLEXISTS2: 'XMLEXISTS2';
XMLEXISTS: 'XMLEXISTS';
XMLFOREST: 'XMLFOREST';
// XMLINDEX_REWRITE_IN_SELECT: 'XMLINDEX_REWRITE_IN_SELECT';
// XMLINDEX_REWRITE: 'XMLINDEX_REWRITE';
// XMLINDEX_SEL_IDX_TBL: 'XMLINDEX_SEL_IDX_TBL';
// XMLISNODE: 'XMLISNODE';
// XMLISVALID: 'XMLISVALID';
XMLNAMESPACES: 'XMLNAMESPACES';
XMLPARSE: 'XMLPARSE';
// XMLPATCH: 'XMLPATCH';
XMLPI: 'XMLPI';
// XMLQUERYVAL: 'XMLQUERYVAL';
XMLQUERY: 'XMLQUERY';
XMLROOT: 'XMLROOT';
// XMLSCHEMA: 'XMLSCHEMA';
XMLSERIALIZE: 'XMLSERIALIZE';
XMLTABLE: 'XMLTABLE';
// XMLTRANSFORMBLOB: 'XMLTRANSFORMBLOB';
// XMLTRANSFORM: 'XMLTRANSFORM';
// XMLTYPE: 'XMLTYPE';
XML: 'XML';
// XPATHTABLE: 'XPATHTABLE';
// XS_SYS_CONTEXT: 'XS_SYS_CONTEXT';
// XS: 'XS';
// YEARS: 'YEARS';
YEAR: 'YEAR';
YES: 'YES';
YMINTERVAL_UNCONSTRAINED: 'YMINTERVAL_UNCONSTRAINED';
// ZONEMAP: 'ZONEMAP';
ZONE: 'ZONE';
PREDICTION: 'PREDICTION';
PREDICTION_BOUNDS: 'PREDICTION_BOUNDS';
PREDICTION_COST: 'PREDICTION_COST';
PREDICTION_DETAILS: 'PREDICTION_DETAILS';
PREDICTION_PROBABILITY: 'PREDICTION_PROBABILITY';
PREDICTION_SET: 'PREDICTION_SET';
CUME_DIST: 'CUME_DIST';
DENSE_RANK: 'DENSE_RANK';
LISTAGG: 'LISTAGG';
PERCENT_RANK: 'PERCENT_RANK';
PERCENTILE_CONT: 'PERCENTILE_CONT';
PERCENTILE_DISC: 'PERCENTILE_DISC';
RANK: 'RANK';
AVG: 'AVG';
CORR: 'CORR';
COVAR_: 'COVAR_';
DECODE: 'DECODE';
LAG: 'LAG';
LEAD: 'LEAD';
MAX: 'MAX';
MEDIAN: 'MEDIAN';
MIN: 'MIN';
NTILE: 'NTILE';
NVL: 'NVL';
RATIO_TO_REPORT: 'RATIO_TO_REPORT';
REGR_: 'REGR_';
ROUND: 'ROUND';
ROW_NUMBER: 'ROW_NUMBER';
SUBSTR: 'SUBSTR';
TO_CHAR: 'TO_CHAR';
TRIM: 'TRIM';
SUM: 'SUM';
STDDEV: 'STDDEV';
VAR_: 'VAR_';
VARIANCE: 'VARIANCE';
LEAST: 'LEAST';
GREATEST: 'GREATEST';
TO_DATE: 'TO_DATE';
// Rule #358 <NATIONAL_CHAR_STRING_LIT> - subtoken typecast in <REGULAR_ID>, it also incorporates <character_representation>
// Lowercase 'n' is a usual addition to the standard
NATIONAL_CHAR_STRING_LIT: 'N' '\'' (~('\'' | '\r' | '\n' ) | '\'' '\'' | NEWLINE)* '\'';
// Rule #040 <BIT_STRING_LIT> - subtoken typecast in <REGULAR_ID>
// Lowercase 'b' is a usual addition to the standard
BIT_STRING_LIT: 'B' ('\'' [01]* '\'')+;
// Rule #284 <HEX_STRING_LIT> - subtoken typecast in <REGULAR_ID>
// Lowercase 'x' is a usual addition to the standard
HEX_STRING_LIT: 'X' ('\'' [A-F0-9]* '\'')+;
DOUBLE_PERIOD: '..';
PERIOD: '.';
//{ Rule #238 <EXACT_NUM_LIT>
// This rule is a bit tricky - it resolves the ambiguity with <PERIOD>
// It also incorporates <mantisa> and <exponent> for the <APPROXIMATE_NUM_LIT>
// Rule #501 <signed_integer> was incorporated directly in the token <APPROXIMATE_NUM_LIT>
// See also the rule #617 <unsigned_num_lit>
/*
: (
UNSIGNED_INTEGER
( '.' UNSIGNED_INTEGER
| {$type = UNSIGNED_INTEGER;}
) ( E ('+' | '-')? UNSIGNED_INTEGER {$type = APPROXIMATE_NUM_LIT;} )?
| '.' UNSIGNED_INTEGER ( E ('+' | '-')? UNSIGNED_INTEGER {$type = APPROXIMATE_NUM_LIT;} )?
)
(D | F)?
;*/
UNSIGNED_INTEGER: [0-9]+;
APPROXIMATE_NUM_LIT: FLOAT_FRAGMENT ('E' ('+'|'-')? (FLOAT_FRAGMENT | [0-9]+))? ('D' | 'F')?;
// Rule #--- <CHAR_STRING> is a base for Rule #065 <char_string_lit> , it incorporates <character_representation>
// and a superfluous subtoken typecasting of the "QUOTE"
CHAR_STRING: '\'' (~('\'' | '\r' | '\n') | '\'' '\'' | NEWLINE)* '\'';
// Perl-style quoted string, see Oracle SQL reference, chapter String Literals
CHAR_STRING_PERL : 'Q' ( QS_ANGLE | QS_BRACE | QS_BRACK | QS_PAREN) -> type(CHAR_STRING);
fragment QUOTE : '\'' ;
fragment QS_ANGLE : QUOTE '<' .*? '>' QUOTE ;
fragment QS_BRACE : QUOTE '{' .*? '}' QUOTE ;
fragment QS_BRACK : QUOTE '[' .*? ']' QUOTE ;
fragment QS_PAREN : QUOTE '(' .*? ')' QUOTE ;
fragment QS_OTHER_CH: ~('<' | '{' | '[' | '(' | ' ' | '\t' | '\n' | '\r');
DELIMITED_ID: '"' (~('"' | '\r' | '\n') | '"' '"')+ '"' ;
// SQL_SPECIAL_CHAR was split into single rules
PERCENT: '%';
AMPERSAND: '&';
LEFT_PAREN: '(';
RIGHT_PAREN: ')';
DOUBLE_ASTERISK: '**';
ASTERISK: '*';
PLUS_SIGN: '+';
MINUS_SIGN: '-';
COMMA: ',';
SOLIDUS: '/';
AT_SIGN: '@';
ASSIGN_OP: ':=';
// See OCI reference for more information about this
BINDVAR
: ':' SIMPLE_LETTER (SIMPLE_LETTER | [0-9] | '_')*
| ':' DELIMITED_ID // not used in SQL but spotted in v$sqltext when using cursor_sharing
| ':' UNSIGNED_INTEGER
| QUESTION_MARK // not in SQL, not in Oracle, not in OCI, use this for JDBC
;
NOT_EQUAL_OP: '!='
| '<>'
| '^='
| '~='
;
CARRET_OPERATOR_PART: '^';
TILDE_OPERATOR_PART: '~';
EXCLAMATION_OPERATOR_PART: '!';
GREATER_THAN_OP: '>';
LESS_THAN_OP: '<';
COLON: ':';
SEMICOLON: ';';
fragment
QUESTION_MARK: '?';
// protected UNDERSCORE : '_' SEPARATOR ; // subtoken typecast within <INTRODUCER>
BAR: '|';
EQUALS_OP: '=';
// Rule #532 <SQL_EMBDD_LANGUAGE_CHAR> was split into single rules:
LEFT_BRACKET: '[';
RIGHT_BRACKET: ']';
//{ Rule #319 <INTRODUCER>
INTRODUCER
: '_' //(SEPARATOR {$type = UNDERSCORE;})?
;
//{ Rule #479 <SEPARATOR>
// It was originally a protected rule set to be filtered out but the <COMMENT> and <'-'> clashed.
/*SEPARATOR
: '-' -> type('-')
| COMMENT -> channel(HIDDEN)
| (SPACE | NEWLINE)+ -> channel(HIDDEN)
;*/
//}
SPACES: [ \t\r\n]+ -> skip;
// Rule #504 <SIMPLE_LETTER> - simple_latin _letter was generalised into SIMPLE_LETTER
// Unicode is yet to be implemented - see NSF0
fragment
SIMPLE_LETTER
: [A-Z]
;
fragment
FLOAT_FRAGMENT
: UNSIGNED_INTEGER* '.'? UNSIGNED_INTEGER+
;
// Rule #097 <COMMENT>
SINGLE_LINE_COMMENT: '--' ~('\r' | '\n')* (NEWLINE | EOF) -> channel(HIDDEN);
MULTI_LINE_COMMENT: '/*' .*? '*/' -> channel(HIDDEN);
// SQL*Plus prompt
// TODO should be grammar rule, but tricky to implement
PROMPT
: 'prompt' SPACE ( ~('\r' | '\n') )* (NEWLINE|EOF)
;
START_CMD
// TODO When using full word START there is a conflict with START WITH in sequences and CONNECT BY queries
// 'start' SPACE ( ~( '\r' | '\n') )* (NEWLINE|EOF)
: 'sta' SPACE ( ~('\r' | '\n') )* (NEWLINE|EOF)
// TODO Single @ conflicts with a database link name, like employees@remote
// | '@' ( ~('\r' | '\n') )* (NEWLINE|EOF)
| '@@' ( ~('\r' | '\n') )* (NEWLINE|EOF)
;
fragment
NEWLINE: '\r'? '\n';
fragment
SPACE: [ \t];
//{ Rule #442 <REGULAR_ID> additionally encapsulates a few STRING_LITs.
// Within testLiterals all reserved and non-reserved words are being resolved
REGULAR_ID: SIMPLE_LETTER (SIMPLE_LETTER | '$' | '_' | '#' | [0-9])*;
ZV: '@!' -> channel(HIDDEN);
| 108,240 | ANTLR | .g4 | 2,344 | 45.058874 | 124 | 0.427458 | sqlest/sql-parser | 0 | 0 | 0 | LGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | d2fe2b442ff5cc41bdd8658644cfb2d40b86e5910d699b7835af394339a61891 | true | true | false | false |
131 | PlSqlParser.g4 | sqlest_sql-parser/src/main/resources/org/ej/parser/sql/oracle/PlSqlParser.g4 | /**
* Oracle(c) PL/SQL 11g Parser
*
* Copyright (c) 2009-2011 Alexandre Porcelli <[email protected]>
* Copyright (c) 2015-2017 Ivan Kochurkin (KvanTTT, [email protected], Positive Technologies).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
parser grammar PlSqlParser;
options { tokenVocab=PlSqlLexer; }
sql_script
: ((unit_statement | sql_plus_command) SEMICOLON?)* EOF
;
unit_statement
: alter_function
| alter_package
| alter_procedure
| alter_sequence
| alter_trigger
| alter_type
| alter_table
| alter_index
| create_function_body
| create_procedure_body
| create_package
| create_package_body
| create_index
| create_table
// | create_view //TODO
// | create_directory //TODO
// | create_materialized_view //TODO
| create_sequence
| create_trigger
| create_type
| create_synonym
| drop_function
| drop_package
| drop_procedure
| drop_sequence
| drop_trigger
| drop_type
| data_manipulation_language_statements
| drop_table
| drop_index
| comment_on_column
| comment_on_table
| anonymous_block
;
// DDL -> SQL Statements for Stored PL/SQL Units
// Function DDLs
drop_function
: DROP FUNCTION function_name ';'
;
alter_function
: ALTER FUNCTION function_name COMPILE DEBUG? compiler_parameters_clause* (REUSE SETTINGS)? ';'
;
create_function_body
: CREATE (OR REPLACE)? FUNCTION function_name ('(' parameter (',' parameter)* ')')?
RETURN type_spec (invoker_rights_clause | parallel_enable_clause | result_cache_clause | DETERMINISTIC)*
((PIPELINED? (IS | AS) (DECLARE? declare_spec* body | call_spec)) | (PIPELINED | AGGREGATE) USING implementation_type_name) ';'
;
// Creation Function - Specific Clauses
parallel_enable_clause
: PARALLEL_ENABLE partition_by_clause?
;
partition_by_clause
: '(' PARTITION expression BY (ANY | (HASH | RANGE| LIST) '(' column_name (',' column_name)* ')')streaming_clause? ')'
;
result_cache_clause
: RESULT_CACHE relies_on_part?
;
relies_on_part
: RELIES_ON '(' tableview_name (',' tableview_name)* ')'
;
streaming_clause
: (ORDER | CLUSTER) expression BY '(' column_name (',' column_name)* ')'
;
// Package DDLs
drop_package
: DROP PACKAGE BODY? (schema_object_name '.')? package_name ';'
;
alter_package
: ALTER PACKAGE package_name COMPILE DEBUG? (PACKAGE | BODY | SPECIFICATION)? compiler_parameters_clause* (REUSE SETTINGS)? ';'
;
create_package
: CREATE (OR REPLACE)? PACKAGE (schema_object_name '.')? package_name invoker_rights_clause? (IS | AS) package_obj_spec* END package_name? ';'
;
create_package_body
: CREATE (OR REPLACE)? PACKAGE BODY (schema_object_name '.')? package_name (IS | AS) package_obj_body* (BEGIN seq_of_statements | END package_name?) ';'
;
// Create Package Specific Clauses
package_obj_spec
: variable_declaration
| subtype_declaration
| cursor_declaration
| exception_declaration
| pragma_declaration
| type_declaration
| procedure_spec
| function_spec
;
procedure_spec
: PROCEDURE identifier ('(' parameter ( ',' parameter )* ')')? ';'
;
function_spec
: FUNCTION identifier ('(' parameter ( ',' parameter)* ')')?
RETURN type_spec (DETERMINISTIC)? (RESULT_CACHE)? ';'
;
package_obj_body
: variable_declaration
| subtype_declaration
| cursor_declaration
| exception_declaration
| type_declaration
| procedure_body
| function_body
| procedure_spec
| function_spec
;
// Procedure DDLs
drop_procedure
: DROP PROCEDURE procedure_name ';'
;
alter_procedure
: ALTER PROCEDURE procedure_name COMPILE DEBUG? compiler_parameters_clause* (REUSE SETTINGS)? ';'
;
function_body
: FUNCTION identifier ('(' parameter (',' parameter)* ')')?
RETURN type_spec (invoker_rights_clause | parallel_enable_clause | result_cache_clause | DETERMINISTIC)*
((PIPELINED? (IS | AS) (DECLARE? declare_spec* body | call_spec)) | (PIPELINED | AGGREGATE) USING implementation_type_name) ';'
;
procedure_body
: PROCEDURE identifier ('(' parameter (',' parameter)* ')')? (IS | AS)
(DECLARE? declare_spec* body | call_spec | EXTERNAL) ';'
;
create_procedure_body
: CREATE (OR REPLACE)? PROCEDURE procedure_name ('(' parameter (',' parameter)* ')')?
invoker_rights_clause? (IS | AS)
(DECLARE? declare_spec* body | call_spec | EXTERNAL) ';'
;
// Trigger DDLs
drop_trigger
: DROP TRIGGER trigger_name ';'
;
alter_trigger
: ALTER TRIGGER alter_trigger_name=trigger_name
((ENABLE | DISABLE) | RENAME TO rename_trigger_name=trigger_name | COMPILE DEBUG? compiler_parameters_clause* (REUSE SETTINGS)?) ';'
;
create_trigger
: CREATE ( OR REPLACE )? TRIGGER trigger_name
(simple_dml_trigger | compound_dml_trigger | non_dml_trigger)
trigger_follows_clause? (ENABLE | DISABLE)? trigger_when_clause? trigger_body ';'
;
trigger_follows_clause
: FOLLOWS trigger_name (',' trigger_name)*
;
trigger_when_clause
: WHEN '(' condition ')'
;
// Create Trigger Specific Clauses
simple_dml_trigger
: (BEFORE | AFTER | INSTEAD OF) dml_event_clause referencing_clause? for_each_row?
;
for_each_row
: FOR EACH ROW
;
compound_dml_trigger
: FOR dml_event_clause referencing_clause?
;
non_dml_trigger
: (BEFORE | AFTER) non_dml_event (OR non_dml_event)* ON (DATABASE | (schema_name '.')? SCHEMA)
;
trigger_body
: COMPOUND TRIGGER
| CALL identifier
| trigger_block
;
routine_clause
: routine_name function_argument?
;
compound_trigger_block
: COMPOUND TRIGGER declare_spec* timing_point_section+ END trigger_name
;
timing_point_section
: bk=BEFORE STATEMENT IS trigger_block BEFORE STATEMENT ';'
| bk=BEFORE EACH ROW IS trigger_block BEFORE EACH ROW ';'
| ak=AFTER STATEMENT IS trigger_block AFTER STATEMENT ';'
| ak=AFTER EACH ROW IS trigger_block AFTER EACH ROW ';'
;
non_dml_event
: ALTER
| ANALYZE
| ASSOCIATE STATISTICS
| AUDIT
| COMMENT
| CREATE
| DISASSOCIATE STATISTICS
| DROP
| GRANT
| NOAUDIT
| RENAME
| REVOKE
| TRUNCATE
| DDL
| STARTUP
| SHUTDOWN
| DB_ROLE_CHANGE
| LOGON
| LOGOFF
| SERVERERROR
| SUSPEND
| DATABASE
| SCHEMA
| FOLLOWS
;
dml_event_clause
: dml_event_element (OR dml_event_element)* ON dml_event_nested_clause? tableview_name
;
dml_event_element
: (DELETE | INSERT | UPDATE) (OF column_name (',' column_name)*)?
;
dml_event_nested_clause
: NESTED TABLE tableview_name OF
;
referencing_clause
: REFERENCING referencing_element+
;
referencing_element
: (NEW | OLD | PARENT) column_alias
;
// DDLs
drop_type
: DROP TYPE BODY? type_name (FORCE | VALIDATE)? ';'
;
alter_type
: ALTER TYPE type_name
(compile_type_clause
| replace_type_clause
//TODO | {input.LT(2).getText().equalsIgnoreCase("attribute")}? alter_attribute_definition
| alter_method_spec
| alter_collection_clauses
| modifier_clause
) dependent_handling_clause? ';'
;
// Alter Type Specific Clauses
compile_type_clause
: COMPILE DEBUG? (SPECIFICATION | BODY)? compiler_parameters_clause* (REUSE SETTINGS)?
;
replace_type_clause
: REPLACE invoker_rights_clause? AS OBJECT '(' object_member_spec (',' object_member_spec)* ')'
;
alter_method_spec
: alter_method_element (',' alter_method_element)*
;
alter_method_element
: (ADD | DROP) (map_order_function_spec | subprogram_spec)
;
alter_attribute_definition
: (ADD | MODIFY | DROP) ATTRIBUTE (attribute_definition | '(' attribute_definition (',' attribute_definition)* ')')
;
attribute_definition
: attribute_name type_spec?
;
alter_collection_clauses
: MODIFY (LIMIT expression | ELEMENT TYPE type_spec)
;
dependent_handling_clause
: INVALIDATE
| CASCADE (CONVERT TO SUBSTITUTABLE | NOT? INCLUDING TABLE DATA)? dependent_exceptions_part?
;
dependent_exceptions_part
: FORCE? EXCEPTIONS INTO tableview_name
;
create_type
: CREATE (OR REPLACE)? TYPE (type_definition | type_body) ';'
;
// Create Type Specific Clauses
type_definition
: type_name (OID CHAR_STRING)? object_type_def?
;
object_type_def
: invoker_rights_clause? (object_as_part | object_under_part) sqlj_object_type?
('(' object_member_spec (',' object_member_spec)* ')')? modifier_clause*
;
object_as_part
: (IS | AS) (OBJECT | varray_type_def | nested_table_type_def)
;
object_under_part
: UNDER type_spec
;
nested_table_type_def
: TABLE OF type_spec (NOT NULL)?
;
sqlj_object_type
: EXTERNAL NAME expression LANGUAGE JAVA USING (SQLDATA | CUSTOMDATUM | ORADATA)
;
type_body
: BODY type_name (IS | AS) (type_body_elements)+ END
;
type_body_elements
: map_order_func_declaration
| subprog_decl_in_type
;
map_order_func_declaration
: (MAP | ORDER) MEMBER func_decl_in_type
;
subprog_decl_in_type
: (MEMBER | STATIC) (proc_decl_in_type | func_decl_in_type | constructor_declaration)
;
proc_decl_in_type
: PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')'
(IS | AS) (call_spec | DECLARE? declare_spec* body ';')
;
func_decl_in_type
: FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')?
RETURN type_spec (IS | AS) (call_spec | DECLARE? declare_spec* body ';')
;
constructor_declaration
: FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION type_spec
('(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')')?
RETURN SELF AS RESULT (IS | AS) (call_spec | DECLARE? declare_spec* body ';')
;
// Common Type Clauses
modifier_clause
: NOT? (INSTANTIABLE | FINAL | OVERRIDING)
;
object_member_spec
: identifier type_spec sqlj_object_type_attr?
| element_spec
;
sqlj_object_type_attr
: EXTERNAL NAME expression
;
element_spec
: modifier_clause? element_spec_options+ (',' pragma_clause)?
;
element_spec_options
: subprogram_spec
| constructor_spec
| map_order_function_spec
;
subprogram_spec
: (MEMBER | STATIC) (type_procedure_spec | type_function_spec)
;
type_procedure_spec
: PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')' ((IS | AS) call_spec)?
;
type_function_spec
: FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')?
RETURN (type_spec | SELF AS RESULT) ((IS | AS) call_spec | EXTERNAL VARIABLE? NAME expression)?
;
constructor_spec
: FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION
type_spec ('(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')')?
RETURN SELF AS RESULT ((IS | AS) call_spec)?
;
map_order_function_spec
: (MAP | ORDER) MEMBER type_function_spec
;
pragma_clause
: PRAGMA RESTRICT_REFERENCES '(' pragma_elements (',' pragma_elements)* ')'
;
pragma_elements
: identifier
| DEFAULT
;
type_elements_parameter
: parameter_name type_spec
;
// Sequence DDLs
drop_sequence
: DROP SEQUENCE sequence_name ';'
;
alter_sequence
: ALTER SEQUENCE sequence_name sequence_spec+ ';'
;
create_sequence
: CREATE SEQUENCE sequence_name (sequence_start_clause | sequence_spec)* ';'
;
// Common Sequence
sequence_spec
: INCREMENT BY UNSIGNED_INTEGER
| MAXVALUE UNSIGNED_INTEGER
| NOMAXVALUE
| MINVALUE UNSIGNED_INTEGER
| NOMINVALUE
| CYCLE
| NOCYCLE
| CACHE UNSIGNED_INTEGER
| NOCACHE
| ORDER
| NOORDER
;
sequence_start_clause
: START WITH UNSIGNED_INTEGER
;
create_index
: CREATE UNIQUE? INDEX index_name ON tableview_name '(' column_name (',' column_name)* ')' (COMPUTE STATISTICS)? ';'
;
alter_index
: ALTER INDEX old_index_name=index_name RENAME TO new_index_name=index_name ';'
;
drop_index
: DROP INDEX index_name ';'
;
create_table
: CREATE (GLOBAL TEMPORARY)? TABLE tableview_name
LEFT_PAREN column_name datatype (',' column_name datatype)*
RIGHT_PAREN
(ON COMMIT (DELETE | PRESERVE) ROWS)?
(SEGMENT CREATION (IMMEDIATE | DEFERRED))?
(PCTFREE pctfree=UNSIGNED_INTEGER
| PCTUSED pctused=UNSIGNED_INTEGER
| INITRANS inittrans=UNSIGNED_INTEGER
)*
( STORAGE LEFT_PAREN
( INITIAL initial=size_clause
| NEXT next=size_clause
| MINEXTENTS minextents=(UNSIGNED_INTEGER | UNLIMITED)
| PCTINCREASE pctincrease=UNSIGNED_INTEGER
| FREELISTS freelists=UNSIGNED_INTEGER
| FREELIST GROUPS freelist_groups=UNSIGNED_INTEGER
| OPTIMAL (size_clause | NULL )
| BUFFER_POOL (KEEP | RECYCLE | DEFAULT)
| FLASH_CACHE (KEEP | NONE | DEFAULT)
| ENCRYPT
)+
RIGHT_PAREN
)?
(TABLESPACE tablespace_name=REGULAR_ID)?
(LOGGING | NOLOGGING | FILESYSTEM_LIKE_LOGGING)?
( COMPRESS
(BASIC
| FOR (OLTP
| (QUERY | ARCHIVE) (LOW | HIGH)?
)
)?
| NOCOMPRESS
)?
// Column_properties clause goes here
// Partition clause goes here
// Many more varations to capture
SEMICOLON
;
size_clause
: UNSIGNED_INTEGER REGULAR_ID
;
drop_table
: DROP TABLE tableview_name SEMICOLON
;
comment_on_column
: COMMENT ON COLUMN tableview_name PERIOD column_name IS quoted_string
;
// Synonym DDL Clauses
create_synonym
// Synonym's schema cannot be specified for public synonyms
: CREATE (OR REPLACE)? PUBLIC SYNONYM synonym_name FOR (schema_name PERIOD)? schema_object_name (AT_SIGN link_name)?
| CREATE (OR REPLACE)? SYNONYM (schema_name PERIOD)? synonym_name FOR (schema_name PERIOD)? schema_object_name (AT_SIGN link_name)?
;
comment_on_table
: COMMENT ON TABLE tableview_name IS quoted_string
;
alter_table
: ALTER TABLE tableview_name
( add_constraint
| drop_constraint
| enable_constraint
| disable_constraint
)
;
add_constraint
: ADD (CONSTRAINT constraint_name)?
( primary_key_clause
| foreign_key_clause
| unique_key_clause
| check_constraint
)
;
check_constraint
: CHECK '(' condition ')' DISABLE?
;
drop_constraint
: DROP CONSTRAINT constraint_name
;
enable_constraint
: ENABLE CONSTRAINT constraint_name
;
disable_constraint
: DISABLE CONSTRAINT constraint_name
;
foreign_key_clause
: FOREIGN KEY LEFT_PAREN column_name (',' column_name)* RIGHT_PAREN references_clause on_delete_clause?
;
references_clause
: REFERENCES tableview_name LEFT_PAREN column_name (',' column_name)* RIGHT_PAREN
;
on_delete_clause
: ON DELETE (CASCADE | SET NULL)
;
unique_key_clause
: UNIQUE LEFT_PAREN column_name (',' column_name)* RIGHT_PAREN
// TODO implement USING INDEX clause
;
primary_key_clause
: PRIMARY KEY LEFT_PAREN column_name (',' column_name)* RIGHT_PAREN
// TODO implement USING INDEX clause
;
// Anonymous PL/SQL code block
anonymous_block
: BEGIN seq_of_statements END SEMICOLON
;
// Common DDL Clauses
invoker_rights_clause
: AUTHID (CURRENT_USER | DEFINER)
;
compiler_parameters_clause
: identifier '=' expression
;
call_spec
: LANGUAGE (java_spec | c_spec)
;
// Call Spec Specific Clauses
java_spec
: JAVA NAME CHAR_STRING
;
c_spec
: C_LETTER (NAME CHAR_STRING)? LIBRARY identifier c_agent_in_clause? (WITH CONTEXT)? c_parameters_clause?
;
c_agent_in_clause
: AGENT IN '(' expressions ')'
;
c_parameters_clause
: PARAMETERS '(' (expressions | '.' '.' '.') ')'
;
parameter
: parameter_name (IN | OUT | INOUT | NOCOPY)* type_spec? default_value_part?
;
default_value_part
: (ASSIGN_OP | DEFAULT) expression
;
// Elements Declarations
declare_spec
: variable_declaration
| subtype_declaration
| cursor_declaration
| exception_declaration
| pragma_declaration
| type_declaration
| procedure_spec
| function_spec
| procedure_body
| function_body
;
// incorporates constant_declaration
variable_declaration
: identifier CONSTANT? type_spec (NOT NULL)? default_value_part? ';'
;
subtype_declaration
: SUBTYPE identifier IS type_spec (RANGE expression '..' expression)? (NOT NULL)? ';'
;
// cursor_declaration incorportates curscursor_body and cursor_spec
cursor_declaration
: CURSOR identifier ('(' parameter_spec (',' parameter_spec)* ')' )? (RETURN type_spec)? (IS select_statement)? ';'
;
parameter_spec
: parameter_name (IN? type_spec)? default_value_part?
;
exception_declaration
: identifier EXCEPTION ';'
;
pragma_declaration
: PRAGMA (SERIALLY_REUSABLE
| AUTONOMOUS_TRANSACTION
| EXCEPTION_INIT '(' exception_name ',' numeric_negative ')'
| INLINE '(' id1=identifier ',' expression ')'
| RESTRICT_REFERENCES '(' (identifier | DEFAULT) (',' identifier)+ ')') ';'
;
// Record Declaration Specific Clauses
// incorporates ref_cursor_type_definition
record_type_def
: RECORD '(' field_spec (',' field_spec)* ')'
;
field_spec
: column_name type_spec? (NOT NULL)? default_value_part?
;
ref_cursor_type_def
: REF CURSOR (RETURN type_spec)?
;
type_declaration
: TYPE identifier IS (table_type_def | varray_type_def | record_type_def | ref_cursor_type_def) ';'
;
table_type_def
: TABLE OF type_spec table_indexed_by_part? (NOT NULL)?
;
table_indexed_by_part
: (idx1=INDEXED | idx2=INDEX) BY type_spec
;
varray_type_def
: (VARRAY | VARYING ARRAY) '(' expression ')' OF type_spec (NOT NULL)?
;
// Statements
seq_of_statements
: (statement (';' | EOF) | label_declaration)+
;
label_declaration
: ltp1= '<' '<' label_name '>' '>'
;
statement
: CREATE swallow_to_semi
| ALTER swallow_to_semi
| GRANT ALL? swallow_to_semi
| TRUNCATE swallow_to_semi
| body
| block
| assignment_statement
| continue_statement
| exit_statement
| goto_statement
| if_statement
| loop_statement
| forall_statement
| null_statement
| raise_statement
| return_statement
| case_statement/*[true]*/
| sql_statement
| function_call
| pipe_row_statement
;
swallow_to_semi
: ~';'+
;
assignment_statement
: (general_element | bind_variable) ASSIGN_OP expression
;
continue_statement
: CONTINUE label_name? (WHEN condition)?
;
exit_statement
: EXIT label_name? (WHEN condition)?
;
goto_statement
: GOTO label_name
;
if_statement
: IF condition THEN seq_of_statements elsif_part* else_part? END IF
;
elsif_part
: ELSIF condition THEN seq_of_statements
;
else_part
: ELSE seq_of_statements
;
loop_statement
: label_name? (WHILE condition | FOR cursor_loop_param)? LOOP seq_of_statements END LOOP label_name?
;
// Loop Specific Clause
cursor_loop_param
: index_name IN REVERSE? lower_bound range='..' upper_bound
| record_name IN (cursor_name ('(' expressions? ')')? | '(' select_statement ')')
;
forall_statement
: FORALL index_name IN bounds_clause sql_statement (SAVE EXCEPTIONS)?
;
bounds_clause
: lower_bound '..' upper_bound
| INDICES OF collection_name between_bound?
| VALUES OF index_name
;
between_bound
: BETWEEN lower_bound AND upper_bound
;
lower_bound
: concatenation
;
upper_bound
: concatenation
;
null_statement
: NULL
;
raise_statement
: RAISE exception_name?
;
return_statement
: RETURN expression?
;
function_call
: CALL? routine_name function_argument?
;
pipe_row_statement
: PIPE ROW '(' expression ')';
body
: BEGIN seq_of_statements (EXCEPTION exception_handler+)? END label_name?
;
// Body Specific Clause
exception_handler
: WHEN exception_name (OR exception_name)* THEN seq_of_statements
;
trigger_block
: (DECLARE? declare_spec+)? body
;
block
: DECLARE? declare_spec+ body
;
// SQL Statements
sql_statement
: execute_immediate
| data_manipulation_language_statements
| cursor_manipulation_statements
| transaction_control_statements
;
execute_immediate
: EXECUTE IMMEDIATE expression (into_clause using_clause? | using_clause dynamic_returning_clause? | dynamic_returning_clause)?
;
// Execute Immediate Specific Clause
dynamic_returning_clause
: (RETURNING | RETURN) into_clause
;
// DML Statements
data_manipulation_language_statements
: merge_statement
| lock_table_statement
| select_statement
| update_statement
| delete_statement
| insert_statement
| explain_statement
;
// Cursor Manipulation Statements
cursor_manipulation_statements
: close_statement
| open_statement
| fetch_statement
| open_for_statement
;
close_statement
: CLOSE cursor_name
;
open_statement
: OPEN cursor_name ('(' expressions? ')')?
;
fetch_statement
: FETCH cursor_name (it1=INTO variable_name (',' variable_name )* | BULK COLLECT INTO variable_name (',' variable_name )*)
;
open_for_statement
: OPEN variable_name FOR (select_statement | expression) using_clause?
;
// Transaction Control SQL Statements
transaction_control_statements
: set_transaction_command
| set_constraint_command
| commit_statement
| rollback_statement
| savepoint_statement
;
set_transaction_command
: SET TRANSACTION
(READ (ONLY | WRITE) | ISOLATION LEVEL (SERIALIZABLE | READ COMMITTED) | USE ROLLBACK SEGMENT rollback_segment_name)?
(NAME quoted_string)?
;
set_constraint_command
: SET (CONSTRAINT | CONSTRAINTS) (ALL | constraint_name (',' constraint_name)*) (IMMEDIATE | DEFERRED)
;
commit_statement
: COMMIT WORK?
(COMMENT expression | FORCE (CORRUPT_XID expression | CORRUPT_XID_ALL | expression (',' expression)?))?
write_clause?
;
write_clause
: WRITE (WAIT | NOWAIT)? (IMMEDIATE | BATCH)?
;
rollback_statement
: ROLLBACK WORK? (TO SAVEPOINT? savepoint_name | FORCE quoted_string)?
;
savepoint_statement
: SAVEPOINT savepoint_name
;
// Dml
//SHOULD BE OVERRIDEN!
compilation_unit
: sql_script
;
/*
//SHOULD BE OVERRIDEN!
seq_of_statements
: select_statement
| update_statement
| delete_statement
| insert_statement
| lock_table_statement
| merge_statement
| explain_statement
// | case_statement[true]
;
*/
explain_statement
: EXPLAIN PLAN (SET STATEMENT_ID '=' quoted_string)? (INTO tableview_name)?
FOR (select_statement | update_statement | delete_statement | insert_statement | merge_statement)
;
select_statement
: subquery_factoring_clause? subquery (for_update_clause | order_by_clause)*
;
// Select Specific Clauses
subquery_factoring_clause
: WITH factoring_element (',' factoring_element)*
;
factoring_element
: query_name ('(' column_name (',' column_name)* ')')? AS '(' subquery order_by_clause? ')'
search_clause? cycle_clause?
;
search_clause
: SEARCH (DEPTH | BREADTH) FIRST BY column_name ASC? DESC? (NULLS FIRST)? (NULLS LAST)?
(',' column_name ASC? DESC? (NULLS FIRST)? (NULLS LAST)?)* SET column_name
;
cycle_clause
: CYCLE column_name (',' column_name)* SET column_name TO expression DEFAULT expression
;
subquery
: subquery_basic_elements subquery_operation_part*
;
subquery_basic_elements
: query_block
| '(' subquery ')'
;
subquery_operation_part
: (UNION ALL? | INTERSECT | MINUS) subquery_basic_elements
;
query_block
: SELECT (DISTINCT | UNIQUE | ALL)? ('*' | selected_element (',' selected_element)*)
into_clause? from_clause where_clause? hierarchical_query_clause? group_by_clause? model_clause?
;
selected_element
: select_list_elements column_alias?
;
from_clause
: FROM table_ref_list
;
select_list_elements
: tableview_name '.' '*'
| (regular_id '.')? expression
;
table_ref_list
: table_ref (',' table_ref)*
;
// NOTE to PIVOT clause
// according the SQL reference this should not be possible
// according to he reality it is. Here we probably apply pivot/unpivot onto whole join clause
// eventhough it is not enclosed in parenthesis. See pivot examples 09,10,11
table_ref
: table_ref_aux join_clause* (pivot_clause | unpivot_clause)?
;
table_ref_aux
: table_ref_aux_internal flashback_query_clause* (/*{isTableAlias()}?*/ table_alias)?
;
table_ref_aux_internal
: dml_table_expression_clause (pivot_clause | unpivot_clause)? # table_ref_aux_internal_one
| '(' table_ref subquery_operation_part* ')' (pivot_clause | unpivot_clause)? # table_ref_aux_internal_two
| ONLY '(' dml_table_expression_clause ')' # table_ref_aux_internal_three
;
join_clause
: query_partition_clause? (CROSS | NATURAL)? (INNER | outer_join_type)?
JOIN table_ref_aux query_partition_clause? (join_on_part | join_using_part)*
;
join_on_part
: ON condition
;
join_using_part
: USING '(' column_name (',' column_name)* ')'
;
outer_join_type
: (FULL | LEFT | RIGHT) OUTER?
;
query_partition_clause
: PARTITION BY (('(' (subquery | expressions)? ')') | expressions)
;
flashback_query_clause
: VERSIONS BETWEEN (SCN | TIMESTAMP) expression
| AS OF (SCN | TIMESTAMP | SNAPSHOT) expression
;
pivot_clause
: PIVOT XML? '(' pivot_element (',' pivot_element)* pivot_for_clause pivot_in_clause ')'
;
pivot_element
: aggregate_function_name '(' expression ')' column_alias?
;
pivot_for_clause
: FOR (column_name | '(' column_name (',' column_name)* ')')
;
pivot_in_clause
: IN '(' (subquery | ANY (',' ANY)* | pivot_in_clause_element (',' pivot_in_clause_element)*) ')'
;
pivot_in_clause_element
: pivot_in_clause_elements column_alias?
;
pivot_in_clause_elements
: expression
| '(' expressions? ')'
;
unpivot_clause
: UNPIVOT ((INCLUDE | EXCLUDE) NULLS)?
'(' (column_name | '(' column_name (',' column_name)* ')') pivot_for_clause unpivot_in_clause ')'
;
unpivot_in_clause
: IN '(' unpivot_in_elements (',' unpivot_in_elements)* ')'
;
unpivot_in_elements
: (column_name | '(' column_name (',' column_name)* ')')
(AS (constant | '(' constant (',' constant)* ')'))?
;
hierarchical_query_clause
: CONNECT BY NOCYCLE? condition start_part?
| start_part CONNECT BY NOCYCLE? condition
;
start_part
: START WITH condition
;
group_by_clause
: GROUP BY group_by_elements (',' group_by_elements)* having_clause?
| having_clause (GROUP BY group_by_elements (',' group_by_elements)*)?
;
group_by_elements
: grouping_sets_clause
| rollup_cube_clause
| expression
;
rollup_cube_clause
: (ROLLUP | CUBE) '(' grouping_sets_elements (',' grouping_sets_elements)* ')'
;
grouping_sets_clause
: GROUPING SETS '(' grouping_sets_elements (',' grouping_sets_elements)* ')'
;
grouping_sets_elements
: rollup_cube_clause
| '(' expressions? ')'
| expression
;
having_clause
: HAVING condition
;
model_clause
: MODEL cell_reference_options* return_rows_clause? reference_model* main_model
;
cell_reference_options
: (IGNORE | KEEP) NAV
| UNIQUE (DIMENSION | SINGLE REFERENCE)
;
return_rows_clause
: RETURN (UPDATED | ALL) ROWS
;
reference_model
: REFERENCE reference_model_name ON '(' subquery ')' model_column_clauses cell_reference_options*
;
main_model
: (MAIN main_model_name)? model_column_clauses cell_reference_options* model_rules_clause
;
model_column_clauses
: model_column_partition_part? DIMENSION BY model_column_list MEASURES model_column_list
;
model_column_partition_part
: PARTITION BY model_column_list
;
model_column_list
: '(' model_column (',' model_column)* ')'
;
model_column
: (expression | query_block) column_alias?
;
model_rules_clause
: model_rules_part? '(' (model_rules_element (',' model_rules_element)*)? ')'
;
model_rules_part
: RULES (UPDATE | UPSERT ALL?)? ((AUTOMATIC | SEQUENTIAL) ORDER)? model_iterate_clause?
;
model_rules_element
: (UPDATE | UPSERT ALL?)? cell_assignment order_by_clause? '=' expression
;
cell_assignment
: model_expression
;
model_iterate_clause
: ITERATE '(' expression ')' until_part?
;
until_part
: UNTIL '(' condition ')'
;
order_by_clause
: ORDER SIBLINGS? BY order_by_elements (',' order_by_elements)*
;
order_by_elements
: expression (ASC | DESC)? (NULLS (FIRST | LAST))?
;
for_update_clause
: FOR UPDATE for_update_of_part? for_update_options?
;
for_update_of_part
: OF column_name (',' column_name)*
;
for_update_options
: SKIP_ LOCKED
| NOWAIT
| WAIT expression
;
update_statement
: UPDATE general_table_ref update_set_clause where_clause? static_returning_clause? error_logging_clause?
;
// Update Specific Clauses
update_set_clause
: SET
(column_based_update_set_clause (',' column_based_update_set_clause)* | VALUE '(' identifier ')' '=' expression)
;
column_based_update_set_clause
: column_name '=' expression
| '(' column_name (',' column_name)* ')' '=' subquery
;
delete_statement
: DELETE FROM? general_table_ref where_clause? static_returning_clause? error_logging_clause?
;
insert_statement
: INSERT (single_table_insert | multi_table_insert)
;
// Insert Specific Clauses
single_table_insert
: insert_into_clause (values_clause static_returning_clause? | select_statement) error_logging_clause?
;
multi_table_insert
: (ALL multi_table_element+ | conditional_insert_clause) select_statement
;
multi_table_element
: insert_into_clause values_clause? error_logging_clause?
;
conditional_insert_clause
: (ALL | FIRST)? conditional_insert_when_part+ conditional_insert_else_part?
;
conditional_insert_when_part
: WHEN condition THEN multi_table_element+
;
conditional_insert_else_part
: ELSE multi_table_element+
;
insert_into_clause
: INTO general_table_ref ('(' column_name (',' column_name)* ')')?
;
values_clause
: VALUES '(' expressions? ')'
;
merge_statement
: MERGE INTO tableview_name table_alias? USING selected_tableview ON '(' condition ')'
(merge_update_clause merge_insert_clause? | merge_insert_clause merge_update_clause?)?
error_logging_clause?
;
// Merge Specific Clauses
merge_update_clause
: WHEN MATCHED THEN UPDATE SET merge_element (',' merge_element)* where_clause? merge_update_delete_part?
;
merge_element
: column_name '=' expression
;
merge_update_delete_part
: DELETE where_clause
;
merge_insert_clause
: WHEN NOT MATCHED THEN INSERT ('(' column_name (',' column_name)* ')')?
VALUES '(' expressions? ')' where_clause?
;
selected_tableview
: (tableview_name | '(' select_statement ')') table_alias?
;
lock_table_statement
: LOCK TABLE lock_table_element (',' lock_table_element)* IN lock_mode MODE wait_nowait_part?
;
wait_nowait_part
: WAIT expression
| NOWAIT
;
// Lock Specific Clauses
lock_table_element
: tableview_name partition_extension_clause?
;
lock_mode
: ROW SHARE
| ROW EXCLUSIVE
| SHARE UPDATE?
| SHARE ROW EXCLUSIVE
| EXCLUSIVE
;
// Common DDL Clauses
general_table_ref
: (dml_table_expression_clause | ONLY '(' dml_table_expression_clause ')') table_alias?
;
static_returning_clause
: (RETURNING | RETURN) expressions into_clause
;
error_logging_clause
: LOG ERRORS error_logging_into_part? expression? error_logging_reject_part?
;
error_logging_into_part
: INTO tableview_name
;
error_logging_reject_part
: REJECT LIMIT (UNLIMITED | expression)
;
dml_table_expression_clause
: table_collection_expression
| '(' select_statement subquery_restriction_clause? ')'
| tableview_name sample_clause?
;
table_collection_expression
: (TABLE | THE) ('(' subquery ')' | '(' expression ')' ('(' '+' ')')?)
;
subquery_restriction_clause
: WITH (READ ONLY | CHECK OPTION (CONSTRAINT constraint_name)?)
;
sample_clause
: SAMPLE BLOCK? '(' expression (',' expression)? ')' seed_part?
;
seed_part
: SEED '(' expression ')'
;
// Expression & Condition
condition
: expression
;
expressions
: expression (',' expression)*
;
expression
: cursor_expression
| logical_expression
;
cursor_expression
: CURSOR '(' subquery ')'
;
logical_expression
: multiset_expression (IS NOT?
(NULL | NAN | PRESENT | INFINITE | A_LETTER SET | EMPTY | OF TYPE?
'(' ONLY? type_spec (',' type_spec)* ')'))*
| NOT logical_expression
| logical_expression AND logical_expression
| logical_expression OR logical_expression
;
multiset_expression
: relational_expression (multiset_type=(MEMBER | SUBMULTISET) OF? concatenation)?
;
relational_expression
: relational_expression relational_operator relational_expression
| compound_expression
;
compound_expression
: concatenation
(NOT? ( IN in_elements
| BETWEEN between_elements
| like_type=(LIKE | LIKEC | LIKE2 | LIKE4) concatenation (ESCAPE concatenation)?))?
;
relational_operator
: '='
| (NOT_EQUAL_OP | '<' '>' | '!' '=' | '^' '=')
| ('<' | '>') '='?
;
in_elements
: '(' subquery ')'
| '(' concatenation (',' concatenation)* ')'
| constant
| bind_variable
| general_element
;
between_elements
: concatenation AND concatenation
;
concatenation
: model_expression
(AT (LOCAL | TIME ZONE concatenation) | interval_expression)?
| concatenation op=(ASTERISK | SOLIDUS) concatenation
| concatenation op=(PLUS_SIGN | MINUS_SIGN) concatenation
| concatenation BAR BAR concatenation
;
interval_expression
: DAY ('(' concatenation ')')? TO SECOND ('(' concatenation ')')?
| YEAR ('(' concatenation ')')? TO MONTH
;
model_expression
: unary_expression ('[' model_expression_element ']')?
;
model_expression_element
: (ANY | expression) (',' (ANY | expression))*
| single_column_for_loop (',' single_column_for_loop)*
| multi_column_for_loop
;
single_column_for_loop
: FOR column_name
( IN '(' expressions? ')'
| (LIKE expression)? FROM fromExpr=expression TO toExpr=expression
action_type=(INCREMENT | DECREMENT) action_expr=expression)
;
multi_column_for_loop
: FOR '(' column_name (',' column_name)* ')'
IN '(' (subquery | '(' expressions? ')') ')'
;
unary_expression
: ('-' | '+') unary_expression
| PRIOR unary_expression
| CONNECT_BY_ROOT unary_expression
| /*TODO {input.LT(1).getText().equalsIgnoreCase("new") && !input.LT(2).getText().equals(".")}?*/ NEW unary_expression
| DISTINCT unary_expression
| ALL unary_expression
| /*TODO{(input.LA(1) == CASE || input.LA(2) == CASE)}?*/ case_statement/*[false]*/
| quantified_expression
| standard_function
| atom
;
case_statement /*TODO [boolean isStatementParameter]
TODO scope {
boolean isStatement;
}
@init {$case_statement::isStatement = $isStatementParameter;}*/
: searched_case_statement
| simple_case_statement
;
// CASE
simple_case_statement
: label_name? ck1=CASE expression simple_case_when_part+ case_else_part? END CASE? label_name?
;
simple_case_when_part
: WHEN expression THEN (/*TODO{$case_statement::isStatement}?*/ seq_of_statements | expression)
;
searched_case_statement
: label_name? ck1=CASE searched_case_when_part+ case_else_part? END CASE? label_name?
;
searched_case_when_part
: WHEN expression THEN (/*TODO{$case_statement::isStatement}?*/ seq_of_statements | expression)
;
case_else_part
: ELSE (/*{$case_statement::isStatement}?*/ seq_of_statements | expression)
;
atom
: table_element outer_join_sign
| bind_variable
| constant
| general_element
| '(' subquery ')' subquery_operation_part*
| '(' expressions ')'
;
quantified_expression
: (SOME | EXISTS | ALL | ANY) ('(' subquery ')' | '(' expression ')')
;
string_function
: SUBSTR '(' expression ',' expression (',' expression)? ')'
| TO_CHAR '(' (table_element | standard_function | expression)
(',' quoted_string)? (',' quoted_string)? ')'
| DECODE '(' expressions ')'
| CHR '(' concatenation USING NCHAR_CS ')'
| NVL '(' expression ',' expression ')'
| TRIM '(' ((LEADING | TRAILING | BOTH)? quoted_string? FROM)? concatenation ')'
| TO_DATE '(' expression (',' quoted_string)? ')'
;
standard_function
: string_function
| numeric_function_wrapper
| other_function
;
numeric_function_wrapper
: numeric_function (single_column_for_loop | multi_column_for_loop)?
;
numeric_function
: SUM '(' (DISTINCT | ALL)? expression ')'
| COUNT '(' ( '*' | ((DISTINCT | UNIQUE | ALL)? concatenation)? ) ')' over_clause?
| ROUND '(' expression (',' UNSIGNED_INTEGER)? ')'
| AVG '(' (DISTINCT | ALL)? expression ')'
| MAX '(' (DISTINCT | ALL)? expression ')'
| LEAST '(' expressions ')'
| GREATEST '(' expressions ')'
;
other_function
: over_clause_keyword function_argument_analytic over_clause?
| /*TODO stantard_function_enabling_using*/ regular_id function_argument_modeling using_clause?
| COUNT '(' ( '*' | (DISTINCT | UNIQUE | ALL)? concatenation) ')' over_clause?
| (CAST | XMLCAST) '(' (MULTISET '(' subquery ')' | concatenation) AS type_spec ')'
| COALESCE '(' table_element (',' (numeric | quoted_string))? ')'
| COLLECT '(' (DISTINCT | UNIQUE)? concatenation collect_order_by_part? ')'
| within_or_over_clause_keyword function_argument within_or_over_part+
| cursor_name ( PERCENT_ISOPEN | PERCENT_FOUND | PERCENT_NOTFOUND | PERCENT_ROWCOUNT )
| DECOMPOSE '(' concatenation (CANONICAL | COMPATIBILITY)? ')'
| EXTRACT '(' regular_id FROM concatenation ')'
| (FIRST_VALUE | LAST_VALUE) function_argument_analytic respect_or_ignore_nulls? over_clause
| standard_prediction_function_keyword
'(' expressions cost_matrix_clause? using_clause? ')'
| TRANSLATE '(' expression (USING (CHAR_CS | NCHAR_CS))? (',' expression)* ')'
| TREAT '(' expression AS REF? type_spec ')'
| TRIM '(' ((LEADING | TRAILING | BOTH)? quoted_string? FROM)? concatenation ')'
| XMLAGG '(' expression order_by_clause? ')' ('.' general_element_part)?
| (XMLCOLATTVAL | XMLFOREST)
'(' xml_multiuse_expression_element (',' xml_multiuse_expression_element)* ')' ('.' general_element_part)?
| XMLELEMENT
'(' (ENTITYESCAPING | NOENTITYESCAPING)? (NAME | EVALNAME)? expression
(/*TODO{input.LT(2).getText().equalsIgnoreCase("xmlattributes")}?*/ ',' xml_attributes_clause)?
(',' expression column_alias?)* ')' ('.' general_element_part)?
| XMLEXISTS '(' expression xml_passing_clause? ')'
| XMLPARSE '(' (DOCUMENT | CONTENT) concatenation WELLFORMED? ')' ('.' general_element_part)?
| XMLPI
'(' (NAME identifier | EVALNAME concatenation) (',' concatenation)? ')' ('.' general_element_part)?
| XMLQUERY
'(' concatenation xml_passing_clause? RETURNING CONTENT (NULL ON EMPTY)? ')' ('.' general_element_part)?
| XMLROOT
'(' concatenation (',' xmlroot_param_version_part)? (',' xmlroot_param_standalone_part)? ')' ('.' general_element_part)?
| XMLSERIALIZE
'(' (DOCUMENT | CONTENT) concatenation (AS type_spec)?
xmlserialize_param_enconding_part? xmlserialize_param_version_part? xmlserialize_param_ident_part? ((HIDE | SHOW) DEFAULTS)? ')'
('.' general_element_part)?
| XMLTABLE
'(' xml_namespaces_clause? concatenation xml_passing_clause? (COLUMNS xml_table_column (',' xml_table_column))? ')' ('.' general_element_part)?
;
over_clause_keyword
: AVG
| CORR
| LAG
| LEAD
| MAX
| MEDIAN
| MIN
| NTILE
| RATIO_TO_REPORT
| ROW_NUMBER
| SUM
| VARIANCE
| REGR_
| STDDEV
| VAR_
| COVAR_
;
within_or_over_clause_keyword
: CUME_DIST
| DENSE_RANK
| LISTAGG
| PERCENT_RANK
| PERCENTILE_CONT
| PERCENTILE_DISC
| RANK
;
standard_prediction_function_keyword
: PREDICTION
| PREDICTION_BOUNDS
| PREDICTION_COST
| PREDICTION_DETAILS
| PREDICTION_PROBABILITY
| PREDICTION_SET
;
over_clause
: OVER '(' query_partition_clause? (order_by_clause windowing_clause?)? ')'
;
windowing_clause
: windowing_type
(BETWEEN windowing_elements AND windowing_elements | windowing_elements)
;
windowing_type
: ROWS
| RANGE
;
windowing_elements
: UNBOUNDED PRECEDING
| CURRENT ROW
| concatenation (PRECEDING | FOLLOWING)
;
using_clause
: USING ('*' | using_element (',' using_element)*)
;
using_element
: (IN OUT? | OUT)? select_list_elements column_alias?
;
collect_order_by_part
: ORDER BY concatenation
;
within_or_over_part
: WITHIN GROUP '(' order_by_clause ')'
| over_clause
;
cost_matrix_clause
: COST (MODEL AUTO? | '(' cost_class_name (',' cost_class_name)* ')' VALUES '(' expressions? ')')
;
xml_passing_clause
: PASSING (BY VALUE)? expression column_alias? (',' expression column_alias?)
;
xml_attributes_clause
: XMLATTRIBUTES
'(' (ENTITYESCAPING | NOENTITYESCAPING)? (SCHEMACHECK | NOSCHEMACHECK)?
xml_multiuse_expression_element (',' xml_multiuse_expression_element)* ')'
;
xml_namespaces_clause
: XMLNAMESPACES
'(' (concatenation column_alias)? (',' concatenation column_alias)*
xml_general_default_part? ')'
;
xml_table_column
: xml_column_name
(FOR ORDINALITY | type_spec (PATH concatenation)? xml_general_default_part?)
;
xml_general_default_part
: DEFAULT concatenation
;
xml_multiuse_expression_element
: expression (AS (id_expression | EVALNAME concatenation))?
;
xmlroot_param_version_part
: VERSION (NO VALUE | expression)
;
xmlroot_param_standalone_part
: STANDALONE (YES | NO VALUE?)
;
xmlserialize_param_enconding_part
: ENCODING concatenation
;
xmlserialize_param_version_part
: VERSION concatenation
;
xmlserialize_param_ident_part
: NO INDENT
| INDENT (SIZE '=' concatenation)?
;
// SqlPlus
sql_plus_command
: '/'
| EXIT
| PROMPT
| SHOW (ERR | ERRORS)
| START_CMD
| whenever_command
| set_command
;
whenever_command
: WHENEVER (SQLERROR | OSERROR)
( EXIT (SUCCESS | FAILURE | WARNING) (COMMIT | ROLLBACK)
| CONTINUE (COMMIT | ROLLBACK | NONE))
;
set_command
: SET regular_id (CHAR_STRING | ON | OFF | /*EXACT_NUM_LIT*/numeric | regular_id)
;
// Common
partition_extension_clause
: (SUBPARTITION | PARTITION) FOR? '(' expressions? ')'
;
column_alias
: AS? (identifier | quoted_string)
| AS
;
table_alias
: identifier
| quoted_string
;
where_clause
: WHERE (CURRENT OF cursor_name | expression)
;
into_clause
: (BULK COLLECT)? INTO variable_name (',' variable_name)*
;
// Common Named Elements
xml_column_name
: identifier
| quoted_string
;
cost_class_name
: identifier
;
attribute_name
: identifier
;
savepoint_name
: identifier
;
rollback_segment_name
: identifier
;
table_var_name
: identifier
;
schema_name
: identifier
;
routine_name
: identifier ('.' id_expression)* ('@' link_name)?
;
package_name
: identifier
;
implementation_type_name
: identifier ('.' id_expression)?
;
parameter_name
: identifier
;
reference_model_name
: identifier
;
main_model_name
: identifier
;
aggregate_function_name
: identifier ('.' id_expression)*
;
query_name
: identifier
;
constraint_name
: identifier ('.' id_expression)* ('@' link_name)?
;
label_name
: id_expression
;
type_name
: id_expression ('.' id_expression)*
;
sequence_name
: id_expression ('.' id_expression)*
;
exception_name
: identifier ('.' id_expression)*
;
function_name
: identifier ('.' id_expression)?
;
procedure_name
: identifier ('.' id_expression)?
;
trigger_name
: identifier ('.' id_expression)?
;
variable_name
: (INTRODUCER char_set_name)? id_expression ('.' id_expression)?
| bind_variable
;
index_name
: identifier
;
cursor_name
: identifier
| bind_variable
;
record_name
: identifier
| bind_variable
;
collection_name
: identifier ('.' id_expression)?
;
link_name
: identifier
;
column_name
: identifier ('.' id_expression)*
;
tableview_name
: identifier ('.' id_expression)?
('@' link_name | /*TODO{!(input.LA(2) == BY)}?*/ partition_extension_clause)?
;
char_set_name
: id_expression ('.' id_expression)*
;
synonym_name
: identifier
;
// Represents a valid DB object name in DDL commands which are valid for several DB (or schema) objects.
// For instance, create synonym ... for <DB object name>, or rename <old DB object name> to <new DB object name>.
// Both are valid for seuqences, tables, views etc.
schema_object_name
: id_expression
;
// PL/SQL Specs
// NOTE: In reality this applies to aggregate functions only
keep_clause
: KEEP '(' DENSE_RANK (FIRST | LAST) order_by_clause ')' over_clause?
;
function_argument
: '(' argument? (',' argument )* ')' keep_clause?
;
function_argument_analytic
: '(' (argument respect_or_ignore_nulls?)? (',' argument respect_or_ignore_nulls?)* ')' keep_clause?
;
function_argument_modeling
: '(' column_name (',' (numeric | NULL) (',' (numeric | NULL))?)?
USING (tableview_name '.' '*' | '*' | expression column_alias? (',' expression column_alias?)*)
')' keep_clause?
;
respect_or_ignore_nulls
: (RESPECT | IGNORE) NULLS
;
argument
: (identifier '=' '>')? expression
;
type_spec
: datatype
| REF? type_name (PERCENT_ROWTYPE | PERCENT_TYPE)?
;
datatype
: native_datatype_element precision_part? (WITH LOCAL? TIME ZONE | CHARACTER SET char_set_name)?
| INTERVAL (YEAR | DAY) ('(' expression ')')? TO (MONTH | SECOND) ('(' expression ')')?
;
precision_part
: '(' numeric (',' numeric)? (CHAR | BYTE)? ')'
;
native_datatype_element
: BINARY_INTEGER
| PLS_INTEGER
| NATURAL
| BINARY_FLOAT
| BINARY_DOUBLE
| NATURALN
| POSITIVE
| POSITIVEN
| SIGNTYPE
| SIMPLE_INTEGER
| NVARCHAR2
| DEC
| INTEGER
| INT
| NUMERIC
| SMALLINT
| NUMBER
| DECIMAL
| DOUBLE PRECISION?
| FLOAT
| REAL
| NCHAR
| LONG RAW?
| CHAR
| CHARACTER
| VARCHAR2
| VARCHAR
| STRING
| RAW
| BOOLEAN
| DATE
| ROWID
| UROWID
| YEAR
| MONTH
| DAY
| HOUR
| MINUTE
| SECOND
| TIMEZONE_HOUR
| TIMEZONE_MINUTE
| TIMEZONE_REGION
| TIMEZONE_ABBR
| TIMESTAMP
| TIMESTAMP_UNCONSTRAINED
| TIMESTAMP_TZ_UNCONSTRAINED
| TIMESTAMP_LTZ_UNCONSTRAINED
| YMINTERVAL_UNCONSTRAINED
| DSINTERVAL_UNCONSTRAINED
| BFILE
| BLOB
| CLOB
| NCLOB
| MLSLABEL
;
bind_variable
: (BINDVAR | ':' UNSIGNED_INTEGER)
// Pro*C/C++ indicator variables
(INDICATOR? (BINDVAR | ':' UNSIGNED_INTEGER))?
('.' general_element_part)*
;
general_element
: general_element_part ('.' general_element_part)*
;
general_element_part
: (INTRODUCER char_set_name)? id_expression ('.' id_expression)* ('@' link_name)? function_argument?
;
table_element
: (INTRODUCER char_set_name)? id_expression ('.' id_expression)*
;
// $>
// $<Lexer Mappings
constant
: TIMESTAMP (quoted_string | bind_variable) (AT TIME ZONE quoted_string)?
| INTERVAL (quoted_string | bind_variable | general_element_part)
(YEAR | MONTH | DAY | HOUR | MINUTE | SECOND)
('(' (UNSIGNED_INTEGER | bind_variable) (',' (UNSIGNED_INTEGER | bind_variable) )? ')')?
(TO ( DAY | HOUR | MINUTE | SECOND ('(' (UNSIGNED_INTEGER | bind_variable) ')')?))?
| numeric
| DATE quoted_string
| quoted_string
| NULL
| TRUE
| FALSE
| DBTIMEZONE
| SESSIONTIMEZONE
| MINVALUE
| MAXVALUE
| DEFAULT
;
numeric
: UNSIGNED_INTEGER
| APPROXIMATE_NUM_LIT
;
numeric_negative
: MINUS_SIGN numeric
;
quoted_string
: CHAR_STRING
//| CHAR_STRING_PERL
| NATIONAL_CHAR_STRING_LIT
;
identifier
: (INTRODUCER char_set_name)? id_expression
;
id_expression
: regular_id
| DELIMITED_ID
;
outer_join_sign
: '(' '+' ')'
;
regular_id
: REGULAR_ID
| A_LETTER
| ADD
| AFTER
| AGENT
| AGGREGATE
//| ALL
//| ALTER
| ANALYZE
//| AND
//| ANY
| ARRAY
// | AS
//| ASC
| ASSOCIATE
| AT
| ATTRIBUTE
| AUDIT
| AUTHID
| AUTO
| AUTOMATIC
| AUTONOMOUS_TRANSACTION
| BATCH
| BEFORE
//| BEGIN
// | BETWEEN
| BFILE
| BINARY_DOUBLE
| BINARY_FLOAT
| BINARY_INTEGER
| BLOB
| BLOCK
| BODY
| BOOLEAN
| BOTH
// | BREADTH
| BULK
// | BY
| BYTE
| C_LETTER
// | CACHE
| CALL
| CANONICAL
| CASCADE
//| CASE
| CAST
| CHAR
| CHAR_CS
| CHARACTER
//| CHECK
| CHR
| CLOB
| CLOSE
| CLUSTER
| COLLECT
| COLUMNS
| COMMENT
| COMMIT
| COMMITTED
| COMPATIBILITY
| COMPILE
| COMPOUND
//| CONNECT
//| CONNECT_BY_ROOT
| CONSTANT
| CONSTRAINT
| CONSTRAINTS
| CONSTRUCTOR
| CONTENT
| CONTEXT
| CONTINUE
| CONVERT
| CORRUPT_XID
| CORRUPT_XID_ALL
| COST
| COUNT
//| CREATE
| CROSS
| CUBE
//| CURRENT
| CURRENT_USER
| CURSOR
| CUSTOMDATUM
| CYCLE
| DATA
| DATABASE
//| DATE
| DAY
| DB_ROLE_CHANGE
| DBTIMEZONE
| DDL
| DEBUG
| DEC
| DECIMAL
//| DECLARE
| DECOMPOSE
| DECREMENT
//| DEFAULT
| DEFAULTS
| DEFERRED
| DEFINER
| DELETE
// | DEPTH
//| DESC
| DETERMINISTIC
| DIMENSION
| DISABLE
| DISASSOCIATE
//| DISTINCT
| DOCUMENT
| DOUBLE
//| DROP
| DSINTERVAL_UNCONSTRAINED
| EACH
| ELEMENT
//| ELSE
//| ELSIF
| EMPTY
| ENABLE
| ENCODING
//| END
| ENTITYESCAPING
| ERR
| ERRORS
| ESCAPE
| EVALNAME
| EXCEPTION
| EXCEPTION_INIT
| EXCEPTIONS
| EXCLUDE
//| EXCLUSIVE
| EXECUTE
//| EXISTS
| EXIT
| EXPLAIN
| EXTERNAL
| EXTRACT
| FAILURE
//| FALSE
//| FETCH
| FINAL
| FIRST
| FIRST_VALUE
| FLOAT
| FOLLOWING
| FOLLOWS
//| FOR
| FORALL
| FORCE
// | FROM
| FULL
| FUNCTION
//| GOTO
//| GRANT
//| GROUP
| GROUPING
| HASH
//| HAVING
| HIDE
| HOUR
//| IF
| IGNORE
| IMMEDIATE
// | IN
| INCLUDE
| INCLUDING
| INCREMENT
| INDENT
//| INDEX
| INDEXED
| INDICATOR
| INDICES
| INFINITE
| INLINE
| INNER
| INOUT
//| INSERT
| INSTANTIABLE
| INSTEAD
| INT
| INTEGER
//| INTERSECT
| INTERVAL
// | INTO
| INVALIDATE
//| IS
| ISOLATION
| ITERATE
| JAVA
| JOIN
| KEEP
| KEY
| LANGUAGE
| LAST
| LAST_VALUE
| LEADING
| LEFT
| LEVEL
| LIBRARY
// | LIKE
| LIKE2
| LIKE4
| LIKEC
| LIMIT
| LOCAL
//| LOCK
| LOCKED
| LOG
| LOGOFF
| LOGON
| LONG
| LOOP
| MAIN
| MAP
| MATCHED
| MAXVALUE
| MEASURES
| MEMBER
| MERGE
//| MINUS
| MINUTE
| MINVALUE
| MLSLABEL
//| MODE
| MODEL
| MODIFY
| MONTH
| MULTISET
| NAME
| NAN
| NATURAL
| NATURALN
| NAV
| NCHAR
| NCHAR_CS
| NCLOB
| NESTED
| NEW
| NO
| NOAUDIT
// | NOCACHE
| NOCOPY
| NOCYCLE
| NOENTITYESCAPING
//| NOMAXVALUE
//| NOMINVALUE
| NONE
// | NOORDER
| NOSCHEMACHECK
//| NOT
//| NOWAIT
// | NULL
| NULLS
| NUMBER
| NUMERIC
| NVARCHAR2
| OBJECT
//| OF
| OFF
| OID
| OLD
//| ON
| ONLY
| OPEN
//| OPTION
//| OR
| ORADATA
//| ORDER
| ORDINALITY
| OSERROR
| OUT
| OUTER
| OVER
| OVERRIDING
| PACKAGE
| PARALLEL_ENABLE
| PARAMETERS
| PARENT
| PARTITION
| PASSING
| PATH
//| PERCENT_ROWTYPE
//| PERCENT_TYPE
| PIPELINED
//| PIVOT
| PLAN
| PLS_INTEGER
| POSITIVE
| POSITIVEN
| PRAGMA
| PRECEDING
| PRECISION
| PRESENT
//| PRIOR
//| PROCEDURE
| RAISE
| RANGE
| RAW
| READ
| REAL
| RECORD
| REF
| REFERENCE
| REFERENCING
| REJECT
| RELIES_ON
| RENAME
| REPLACE
| RESPECT
| RESTRICT_REFERENCES
| RESULT
| RESULT_CACHE
| RETURN
| RETURNING
| REUSE
| REVERSE
//| REVOKE
| RIGHT
| ROLLBACK
| ROLLUP
| ROW
| ROWID
| ROWS
| RULES
| SAMPLE
| SAVE
| SAVEPOINT
| SCHEMA
| SCHEMACHECK
| SCN
// | SEARCH
| SECOND
| SEED
| SEGMENT
// | SELECT
| SELF
// | SEQUENCE
| SEQUENTIAL
| SERIALIZABLE
| SERIALLY_REUSABLE
| SERVERERROR
| SESSIONTIMEZONE
| SET
| SETS
| SETTINGS
//| SHARE
| SHOW
| SHUTDOWN
| SIBLINGS
| SIGNTYPE
| SIMPLE_INTEGER
| SINGLE
//| SIZE
| SKIP_
| SMALLINT
| SNAPSHOT
| SOME
| SPECIFICATION
| SQLDATA
| SQLERROR
| STANDALONE
//| START
| STARTUP
| STATEMENT
| STATEMENT_ID
| STATIC
| STATISTICS
| STRING
| SUBSTR
| SUBMULTISET
| SUBPARTITION
| SUBSTITUTABLE
| SUBTYPE
| SUCCESS
| SUSPEND
| TEMPORARY
//| TABLE
//| THE
//| THEN
| TIME
| TIMESTAMP
| TIMESTAMP_LTZ_UNCONSTRAINED
| TIMESTAMP_TZ_UNCONSTRAINED
| TIMESTAMP_UNCONSTRAINED
| TIMEZONE_ABBR
| TIMEZONE_HOUR
| TIMEZONE_MINUTE
| TIMEZONE_REGION
//| TO
| TRAILING
| TRANSACTION
| TRANSLATE
| TREAT
| TRIGGER
| TRIM
//| TRUE
| TRUNCATE
| TYPE
| UNBOUNDED
| UNDER
//| UNION
//| UNIQUE
| UNLIMITED
//| UNPIVOT
| UNTIL
//| UPDATE
| UPDATED
| UPSERT
| UROWID
| USE
//| USING
| VALIDATE
| VALUE
//| VALUES
| VARCHAR
| VARCHAR2
| VARIABLE
| VARRAY
| VARYING
| VERSION
| VERSIONS
| WAIT
| WARNING
| WELLFORMED
// | WHEN
| WHENEVER
// | WHERE
| WHILE
//| WITH
| WITHIN
| WORK
| WRITE
| XML
| XMLAGG
| XMLATTRIBUTES
| XMLCAST
| XMLCOLATTVAL
| XMLELEMENT
| XMLEXISTS
| XMLFOREST
| XMLNAMESPACES
| XMLPARSE
| XMLPI
| XMLQUERY
| XMLROOT
| XMLSERIALIZE
| XMLTABLE
| YEAR
| YES
| YMINTERVAL_UNCONSTRAINED
| ZONE
| PREDICTION
| PREDICTION_BOUNDS
| PREDICTION_COST
| PREDICTION_DETAILS
| PREDICTION_PROBABILITY
| PREDICTION_SET
| CUME_DIST
| DENSE_RANK
| LISTAGG
| PERCENT_RANK
| PERCENTILE_CONT
| PERCENTILE_DISC
| RANK
| AVG
| CORR
| LAG
| LEAD
| MAX
| MEDIAN
| MIN
| NTILE
| RATIO_TO_REPORT
| ROW_NUMBER
| SUM
| VARIANCE
| REGR_
| STDDEV
| VAR_
| COVAR_
;
string_function_name
: CHR
| DECODE
| SUBSTR
| TO_CHAR
| TRIM
;
numeric_function_name
: AVG
| COUNT
| NVL
| ROUND
| SUM
;
| 57,334 | ANTLR | .g4 | 2,216 | 21.33574 | 156 | 0.644633 | sqlest/sql-parser | 0 | 0 | 0 | LGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | dd96fe6f7cae2faf74af60ed11b854119c69ba6bdffc1d43dcaec418873639db | false | false | false | false |
132 | C.g4 | raduiosif_c-expr/C.g4 | /*
[The "BSD licence"]
Copyright (c) 2013 Sam Harwell
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** C 2011 grammar built from the C11 Spec */
grammar C;
primaryExpression returns[ExprType type]
: Identifier {
if ($Identifier.text.endsWith("alloc") || $Identifier.text.equals("free")) {
$type = new ExprType(ExprType.POINT);
} else {
$type = new ExprType(ExprType.VAR);
}
}
| Constant { $type = new ExprType(ExprType.CONST); }
| StringLiteral+ { $type = new ExprType(ExprType.VOID); }
| '(' e=expression ')' { $type = $e.type; }
| g=genericSelection { $type = $g.type; }
| '__extension__'? '(' compoundStatement ')' { $type = new ExprType(ExprType.VOID); } // Blocks (GCC extension)
| '__builtin_va_arg' '(' e1=unaryExpression ',' typeName ')' { $type = $e1.type; }
| '__builtin_offsetof' '(' typeName ',' e1=unaryExpression ')' { $type = $e1.type; }
;
genericSelection returns[ExprType type]
: '_Generic' '(' e=assignmentExpression ',' genericAssocList ')' { $type = $e.type; }
;
genericAssocList
: genericAssociation
| genericAssocList ',' genericAssociation
;
genericAssociation
: typeName ':' assignmentExpression
| 'default' ':' assignmentExpression
;
postfixExpression returns [ExprType type]
: e=primaryExpression { $type = $e.type; }
| p=postfixExpression '[' e1=expression ']' { $type = new ExprType($p.type, $e1.type); $type.setArray(); }
| p=postfixExpression '(' ')' { $type = $p.type; }
| p=postfixExpression '(' l=argumentExpressionList ')' { $type = new ExprType($p.type, $l.type); }
| p=postfixExpression '.' Identifier { $type = $p.type; }
| p=postfixExpression '->' Identifier { $type = $p.type; $type.setPointer(); }
| p=postfixExpression '++' { $type = $p.type; }
| p=postfixExpression '--' { $type = $p.type; }
| '(' typeName ')' '{' initializerList '}' { $type = new ExprType(ExprType.VOID); }
| '(' typeName ')' '{' initializerList ',' '}' { $type = new ExprType(ExprType.VOID); }
| '__extension__' '(' typeName ')' '{' initializerList '}' { $type = new ExprType(ExprType.VOID); }
| '__extension__' '(' typeName ')' '{' initializerList ',' '}' { $type = new ExprType(ExprType.VOID); }
;
argumentExpressionList returns[ExprType type]
: e=assignmentExpression { $type = $e.type; }
| l=argumentExpressionList ',' e=assignmentExpression { $type = new ExprType($l.type, $e.type); }
;
unaryExpression returns [ExprType type]
: e=postfixExpression { $type = $e.type; }
| '++' e1=unaryExpression { $type = $e1.type; }
| '--' e1=unaryExpression { $type = $e1.type; }
| unaryOperator e2=castExpression { $type = $e2.type; }
| 'sizeof' unaryExpression { $type = new ExprType(ExprType.CONST); }
| 'sizeof' '(' typeName ')' { $type = new ExprType(ExprType.CONST); }
| '_Alignof' '(' typeName ')' { $type = new ExprType(ExprType.CONST); }
| '&&' Identifier { $type = new ExprType(ExprType.CONST); } // GCC extension address of label
;
unaryOperator
: '&' | '*' | '+' | '-' | '~' | '!'
;
castExpression returns [ExprType type]
: '(' typeName ')' e=castExpression { $type = $e.type; }
| '__extension__' '(' typeName ')' e=castExpression { $type = $e.type; }
| e1=unaryExpression { $type = $e1.type; }
| DigitSequence { $type = new ExprType(ExprType.CONST); } // for
;
multiplicativeExpression returns [ExprType type]
: e=castExpression { $type = $e.type; }
| e1=multiplicativeExpression op='*' e2=castExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
| e1=multiplicativeExpression op='/' e2=castExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
| e1=multiplicativeExpression op='%' e2=castExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
;
additiveExpression returns [ExprType type]
: e=multiplicativeExpression { $type = $e.type; }
| e1=additiveExpression op='+' e2=multiplicativeExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
| e1=additiveExpression op='-' e2=multiplicativeExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
;
shiftExpression returns [ExprType type]
: e=additiveExpression { $type = $e.type; }
| e1=shiftExpression op='<<' e2=additiveExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
| e1=shiftExpression op='>>' e2=additiveExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
;
relationalExpression returns [ExprType type]
: e=shiftExpression { $type = $e.type; }
| e1=relationalExpression op='<' e2=shiftExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
| e1=relationalExpression op='>' e2=shiftExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
| e1=relationalExpression op='<=' e2=shiftExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
| e1=relationalExpression op='>=' e2=shiftExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
;
equalityExpression returns [ExprType type]
: e=relationalExpression { $type = $e.type; }
| e1=equalityExpression op='==' e2=relationalExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
| e1=equalityExpression op='!=' e2=relationalExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
;
andExpression returns [ExprType type]
: e=equalityExpression { $type = $e.type; }
| e1=andExpression op='&' e2=equalityExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
;
exclusiveOrExpression returns [ExprType type]
: e=andExpression { $type = $e.type; }
| e1=exclusiveOrExpression op='^' e2=andExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
;
inclusiveOrExpression returns [ExprType type]
: e=exclusiveOrExpression { $type = $e.type; }
| e1=inclusiveOrExpression op='|' e2=exclusiveOrExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
;
logicalAndExpression returns [ExprType type]
: e=inclusiveOrExpression { $type = $e.type; }
| e1=logicalAndExpression op='&&' e2=inclusiveOrExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
;
logicalOrExpression returns [ExprType type]
: e=logicalAndExpression { $type = $e.type; }
| e1=logicalOrExpression op='||' e2=logicalAndExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
;
conditionalExpression returns [ExprType type]
: e1=logicalOrExpression { $type = $e1.type; }
| e1=logicalOrExpression '?' e2=expression ':' e3=conditionalExpression {
$type = new ExprType($e1.type, new ExprType($e2.type, $e3.type));
}
;
assignmentExpression returns [ExprType type]
: e=conditionalExpression { $type = $e.type; }
| e1=unaryExpression op=assignmentOperator e2=assignmentExpression { $type = new ExprType($e1.type, $e2.type, $op.text); }
| DigitSequence { $type = new ExprType(ExprType.CONST); } // for
;
assignmentOperator
: '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|='
;
expression returns [ExprType type]
: e=assignmentExpression { $type = $e.type; }
| e1=expression ',' e2=assignmentExpression { $type = new ExprType($e1.type, $e2.type); }
;
constantExpression returns [ExprType type]
: e=conditionalExpression { $type = $e.type; }
;
declaration
: declarationSpecifiers initDeclaratorList ';'
| declarationSpecifiers ';'
| staticAssertDeclaration
;
declarationSpecifiers
: declarationSpecifier+
;
declarationSpecifiers2
: declarationSpecifier+
;
declarationSpecifier
: storageClassSpecifier
| typeSpecifier
| typeQualifier
| functionSpecifier
| alignmentSpecifier
;
initDeclaratorList
: initDeclarator
| initDeclaratorList ',' initDeclarator
;
initDeclarator
: declarator
| declarator '=' initializer
;
storageClassSpecifier
: 'typedef'
| 'extern'
| 'static'
| '_Thread_local'
| 'auto'
| 'register'
;
typeSpecifier
: ('void'
| 'char'
| 'short'
| 'int'
| 'long'
| 'float'
| 'double'
| 'signed'
| 'unsigned'
| '_Bool'
| '_Complex'
| '__m128'
| '__m128d'
| '__m128i')
| '__extension__' '(' ('__m128' | '__m128d' | '__m128i') ')'
| atomicTypeSpecifier
| structOrUnionSpecifier
| enumSpecifier
| typedefName
| '__typeof__' '(' constantExpression ')' // GCC extension
| typeSpecifier pointer
;
structOrUnionSpecifier
: structOrUnion Identifier? '{' structDeclarationList '}'
| structOrUnion Identifier
;
structOrUnion
: 'struct'
| 'union'
;
structDeclarationList
: structDeclaration
| structDeclarationList structDeclaration
;
structDeclaration
: specifierQualifierList structDeclaratorList? ';'
| staticAssertDeclaration
;
specifierQualifierList
: typeSpecifier specifierQualifierList?
| typeQualifier specifierQualifierList?
;
structDeclaratorList
: structDeclarator
| structDeclaratorList ',' structDeclarator
;
structDeclarator
: declarator
| declarator? ':' constantExpression
;
enumSpecifier
: 'enum' Identifier? '{' enumeratorList '}'
| 'enum' Identifier? '{' enumeratorList ',' '}'
| 'enum' Identifier
;
enumeratorList
: enumerator
| enumeratorList ',' enumerator
;
enumerator
: enumerationConstant
| enumerationConstant '=' constantExpression
;
enumerationConstant
: Identifier
;
atomicTypeSpecifier
: '_Atomic' '(' typeName ')'
;
typeQualifier
: 'const'
| 'restrict'
| 'volatile'
| '_Atomic'
;
functionSpecifier
: ('inline'
| '_Noreturn'
| '__inline__' // GCC extension
| '__stdcall')
| gccAttributeSpecifier
| '__declspec' '(' Identifier ')'
;
alignmentSpecifier
: '_Alignas' '(' typeName ')'
| '_Alignas' '(' constantExpression ')'
;
declarator
: pointer? directDeclarator gccDeclaratorExtension*
;
directDeclarator
: Identifier
| '(' declarator ')'
| directDeclarator '[' typeQualifierList? ']'
| directDeclarator tok='[' typeQualifierList? e=assignmentExpression ']' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| directDeclarator '[' tok='static' typeQualifierList? e=assignmentExpression ']' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| directDeclarator '[' typeQualifierList tok='static' e=assignmentExpression ']' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| directDeclarator '[' typeQualifierList? '*' ']'
| directDeclarator '(' parameterTypeList ')'
| directDeclarator '(' identifierList? ')'
| Identifier ':' DigitSequence // bit field
| '(' typeSpecifier? pointer directDeclarator ')' // function pointer like: (__cdecl *f)
;
gccDeclaratorExtension
: '__asm' '(' StringLiteral+ ')'
| gccAttributeSpecifier
;
gccAttributeSpecifier
: '__attribute__' '(' '(' gccAttributeList ')' ')'
;
gccAttributeList
: gccAttribute (',' gccAttribute)*
| // empty
;
gccAttribute
: ~(',' | '(' | ')') // relaxed def for "identifier or reserved word"
('(' argumentExpressionList? ')')?
| // empty
;
nestedParenthesesBlock
: ( ~('(' | ')')
| '(' nestedParenthesesBlock ')'
)*
;
pointer
: '*' typeQualifierList?
| '*' typeQualifierList? pointer
| '^' typeQualifierList? // Blocks language extension
| '^' typeQualifierList? pointer // Blocks language extension
;
typeQualifierList
: typeQualifier
| typeQualifierList typeQualifier
;
parameterTypeList
: parameterList
| parameterList ',' '...'
;
parameterList
: parameterDeclaration
| parameterList ',' parameterDeclaration
;
parameterDeclaration
: declarationSpecifiers declarator
| declarationSpecifiers2 abstractDeclarator?
;
identifierList
: Identifier
| identifierList ',' Identifier
;
typeName
: specifierQualifierList abstractDeclarator?
;
abstractDeclarator
: pointer
| pointer? directAbstractDeclarator gccDeclaratorExtension*
;
directAbstractDeclarator
: '(' abstractDeclarator ')' gccDeclaratorExtension*
| '[' typeQualifierList? ']'
| tok='[' typeQualifierList? e=assignmentExpression ']' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| '[' tok='static' typeQualifierList? e=assignmentExpression ']' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| '[' typeQualifierList tok='static' e=assignmentExpression ']' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| '[' '*' ']'
| '(' parameterTypeList? ')' gccDeclaratorExtension*
| directAbstractDeclarator '[' typeQualifierList? ']'
| directAbstractDeclarator tok='[' typeQualifierList? e=assignmentExpression ']' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| directAbstractDeclarator '[' tok='static' typeQualifierList? e=assignmentExpression ']' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| directAbstractDeclarator '[' typeQualifierList tok='static' e=assignmentExpression ']' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| directAbstractDeclarator '[' '*' ']'
| directAbstractDeclarator '(' parameterTypeList? ')' gccDeclaratorExtension*
;
typedefName
: Identifier
;
initializer
: e=assignmentExpression { ExprTypeCounter.incType($e.type, 0); }
| '{' initializerList '}'
| '{' initializerList ',' '}'
;
initializerList
: designation? initializer
| initializerList ',' designation? initializer
;
designation
: designatorList '='
;
designatorList
: designator
| designatorList designator
;
designator
: '[' constantExpression ']'
| '.' Identifier
;
staticAssertDeclaration
: '_Static_assert' '(' constantExpression ',' StringLiteral+ ')' ';'
;
statement
: labeledStatement
| compoundStatement
| expressionStatement
| selectionStatement
| iterationStatement
| jumpStatement
| ('__asm' | '__asm__') ('volatile' | '__volatile__') '(' (logicalOrExpression (',' logicalOrExpression)*)? (':' (logicalOrExpression (',' logicalOrExpression)*)?)* ')' ';'
;
labeledStatement
: Identifier ':' statement
| 'case' constantExpression ':' statement
| 'default' ':' statement
;
compoundStatement
: '{' blockItemList? '}'
;
blockItemList
: blockItem
| blockItemList blockItem
;
blockItem
: statement
| declaration
;
expressionStatement
: ';'
| { ExprType.expression = true; } e=expression tok=';' { ExprTypeCounter.incType($e.type, $tok.getLine()); ExprType.expression = false; }
;
selectionStatement
: tok='if' '(' e=expression ')' statement ('else' statement)? { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| tok='switch' '(' e=expression ')' statement { ExprTypeCounter.incType($e.type, $tok.getLine()); }
;
iterationStatement
: tok=While '(' e=expression ')' statement { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| tok=Do statement While '(' e=expression ')' ';' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| For '(' forCondition ')' statement
;
forCondition
: forDeclaration ';' forExpression? ';' forExpression?
| expression? ';' forExpression? ';' forExpression?
;
forDeclaration
: declarationSpecifiers initDeclaratorList
| declarationSpecifiers
;
forExpression
: e=assignmentExpression { ExprTypeCounter.incType($e.type, 0); }
| forExpression tok=',' e=assignmentExpression { ExprTypeCounter.incType($e.type, $tok.getLine()); }
;
jumpStatement
: 'goto' Identifier ';'
| 'continue' ';'
| 'break' ';'
| 'return' ';'
| tok='return' e=expression ';' { ExprTypeCounter.incType($e.type, $tok.getLine()); }
| 'goto' unaryExpression ';' // GCC extension
;
compilationUnit
: translationUnit? EOF { ExprTypeCounter.incLines($EOF.getLine()); }
;
translationUnit
: externalDeclaration
| translationUnit externalDeclaration
;
externalDeclaration
: functionDefinition
| declaration
| ';' // stray ;
;
functionDefinition
: declarationSpecifiers? declarator declarationList? compoundStatement
;
declarationList
: declaration
| declarationList declaration
;
Auto : 'auto';
Break : 'break';
Case : 'case';
Char : 'char';
Const : 'const';
Continue : 'continue';
Default : 'default';
Do : 'do';
Double : 'double';
Else : 'else';
Enum : 'enum';
Extern : 'extern';
Float : 'float';
For : 'for';
Goto : 'goto';
If : 'if';
Inline : 'inline';
Int : 'int';
Long : 'long';
Register : 'register';
Restrict : 'restrict';
Return : 'return';
Short : 'short';
Signed : 'signed';
Sizeof : 'sizeof';
Static : 'static';
Struct : 'struct';
Switch : 'switch';
Typedef : 'typedef';
Union : 'union';
Unsigned : 'unsigned';
Void : 'void';
Volatile : 'volatile';
While : 'while';
Alignas : '_Alignas';
Alignof : '_Alignof';
Atomic : '_Atomic';
Bool : '_Bool';
Complex : '_Complex';
Generic : '_Generic';
Imaginary : '_Imaginary';
Noreturn : '_Noreturn';
StaticAssert : '_Static_assert';
ThreadLocal : '_Thread_local';
LeftParen : '(';
RightParen : ')';
LeftBracket : '[';
RightBracket : ']';
LeftBrace : '{';
RightBrace : '}';
Less : '<';
LessEqual : '<=';
Greater : '>';
GreaterEqual : '>=';
LeftShift : '<<';
RightShift : '>>';
Plus : '+';
PlusPlus : '++';
Minus : '-';
MinusMinus : '--';
Star : '*';
Div : '/';
Mod : '%';
And : '&';
Or : '|';
AndAnd : '&&';
OrOr : '||';
Caret : '^';
Not : '!';
Tilde : '~';
Question : '?';
Colon : ':';
Semi : ';';
Comma : ',';
Assign : '=';
// '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|='
StarAssign : '*=';
DivAssign : '/=';
ModAssign : '%=';
PlusAssign : '+=';
MinusAssign : '-=';
LeftShiftAssign : '<<=';
RightShiftAssign : '>>=';
AndAssign : '&=';
XorAssign : '^=';
OrAssign : '|=';
Equal : '==';
NotEqual : '!=';
Arrow : '->';
Dot : '.';
Ellipsis : '...';
Identifier
: IdentifierNondigit
( IdentifierNondigit
| Digit
)*
;
fragment
IdentifierNondigit
: Nondigit
| UniversalCharacterName
//| // other implementation-defined characters...
;
fragment
Nondigit
: [a-zA-Z_]
;
fragment
Digit
: [0-9]
;
fragment
UniversalCharacterName
: '\\u' HexQuad
| '\\U' HexQuad HexQuad
;
fragment
HexQuad
: HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit
;
Constant
: IntegerConstant
| FloatingConstant
//| EnumerationConstant
| CharacterConstant
;
fragment
IntegerConstant
: DecimalConstant IntegerSuffix?
| OctalConstant IntegerSuffix?
| HexadecimalConstant IntegerSuffix?
| BinaryConstant
;
fragment
BinaryConstant
: '0' [bB] [0-1]+
;
fragment
DecimalConstant
: NonzeroDigit Digit*
;
fragment
OctalConstant
: '0' OctalDigit*
;
fragment
HexadecimalConstant
: HexadecimalPrefix HexadecimalDigit+
;
fragment
HexadecimalPrefix
: '0' [xX]
;
fragment
NonzeroDigit
: [1-9]
;
fragment
OctalDigit
: [0-7]
;
fragment
HexadecimalDigit
: [0-9a-fA-F]
;
fragment
IntegerSuffix
: UnsignedSuffix LongSuffix?
| UnsignedSuffix LongLongSuffix
| LongSuffix UnsignedSuffix?
| LongLongSuffix UnsignedSuffix?
;
fragment
UnsignedSuffix
: [uU]
;
fragment
LongSuffix
: [lL]
;
fragment
LongLongSuffix
: 'll' | 'LL'
;
fragment
FloatingConstant
: DecimalFloatingConstant
| HexadecimalFloatingConstant
;
fragment
DecimalFloatingConstant
: FractionalConstant ExponentPart? FloatingSuffix?
| DigitSequence ExponentPart FloatingSuffix?
;
fragment
HexadecimalFloatingConstant
: HexadecimalPrefix HexadecimalFractionalConstant BinaryExponentPart FloatingSuffix?
| HexadecimalPrefix HexadecimalDigitSequence BinaryExponentPart FloatingSuffix?
;
fragment
FractionalConstant
: DigitSequence? '.' DigitSequence
| DigitSequence '.'
;
fragment
ExponentPart
: 'e' Sign? DigitSequence
| 'E' Sign? DigitSequence
;
fragment
Sign
: '+' | '-'
;
DigitSequence
: Digit+
;
fragment
HexadecimalFractionalConstant
: HexadecimalDigitSequence? '.' HexadecimalDigitSequence
| HexadecimalDigitSequence '.'
;
fragment
BinaryExponentPart
: 'p' Sign? DigitSequence
| 'P' Sign? DigitSequence
;
fragment
HexadecimalDigitSequence
: HexadecimalDigit+
;
fragment
FloatingSuffix
: 'f' | 'l' | 'F' | 'L'
;
fragment
CharacterConstant
: '\'' CCharSequence '\''
| 'L\'' CCharSequence '\''
| 'u\'' CCharSequence '\''
| 'U\'' CCharSequence '\''
;
fragment
CCharSequence
: CChar+
;
fragment
CChar
: ~['\\\r\n]
| EscapeSequence
;
fragment
EscapeSequence
: SimpleEscapeSequence
| OctalEscapeSequence
| HexadecimalEscapeSequence
| UniversalCharacterName
;
fragment
SimpleEscapeSequence
: '\\' ['"?abfnrtv\\]
;
fragment
OctalEscapeSequence
: '\\' OctalDigit
| '\\' OctalDigit OctalDigit
| '\\' OctalDigit OctalDigit OctalDigit
;
fragment
HexadecimalEscapeSequence
: '\\x' HexadecimalDigit+
;
StringLiteral
: EncodingPrefix? '"' SCharSequence? '"'
;
fragment
EncodingPrefix
: 'u8'
| 'u'
| 'U'
| 'L'
;
fragment
SCharSequence
: SChar+
;
fragment
SChar
: ~["\\\r\n]
| EscapeSequence
| '\\\n' // Added line
| '\\\r\n' // Added line
;
ComplexDefine
: '#' Whitespace? 'define' ~[#]*
-> skip
;
// ignore the following asm blocks:
/*
asm
{
mfspr x, 286;
}
*/
AsmBlock
: 'asm' ~'{'* '{' ~'}'* '}'
-> skip
;
// ignore the lines generated by c preprocessor
// sample line : '#line 1 "/home/dm/files/dk1.h" 1'
LineAfterPreprocessing
: '#line' Whitespace* ~[\r\n]*
-> skip
;
LineDirective
: '#' Whitespace? DecimalConstant Whitespace? StringLiteral ~[\r\n]*
-> skip
;
PragmaDirective
: '#' Whitespace? 'pragma' Whitespace ~[\r\n]*
-> skip
;
Whitespace
: [ \t]+
-> skip
;
Newline
: ( '\r' '\n'?
| '\n'
)
-> skip
;
BlockComment
: '/*' .*? '*/'
-> skip
;
LineComment
: '//' ~[\r\n]*
-> skip
;
PreProcessing
: '#' ~[\r\n]*
-> skip
;
| 24,664 | ANTLR | .g4 | 813 | 26.426814 | 178 | 0.637496 | raduiosif/c-expr | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 1b2530d807d942bf5fb7e6d58957b5082971a34db6ecd594e0574289745334a2 | false | false | false | false |
133 | Lua.g4 | FCChinen_T1Compiladores/Lua.g4 | grammar Lua;
@members {
public static String grupo="<496235 558400>";
}
/*
-------------------------------------------------------------------------
Regras léxicas
-------------------------------------------------------------------------
*/
// Regra para pular fim de linha e espaços
WS
: (' '
| '\t'
| '\r'
| '\n'
) {skip();};
// Regra para palavras reservadas
AND : 'and';
BREAK : 'break';
DO : 'do';
ELSE : 'else';
ELSEIF : 'elseif';
END : 'end';
FALSE : 'false';
FOR : 'for';
FUNCTION : 'function';
IF : 'if';
IN : 'in';
LOCAL : 'local';
NIL : 'nil';
NOT : 'not';
OR : 'or';
REPEAT : 'repeat';
RETURN : 'return';
THEN : 'then';
TRUE : 'true';
UNTIL : 'until';
WHILE : 'while';
// Operadores
SOMA : '+';
SUB : '-';
MULT : '*';
DIV : '/';
MOD : '%';
EXP : '^';
COMP : '#';
IGUAL : '==';
DIF : '~=';
MENORIGUAL : '<=';
MAIORIGUAL : '>=';
MENOR : '<';
MAIOR : '>';
ATRI : '=';
ABREPAR : '(';
FECHAPAR : ')';
ABRECOL : '{';
FECHACOL : '}';
ABREBRACKETS : '[';
FECHABRACKETS : ']';
PONTOVIRGULA : ';';
DOISPONTOS : ':';
PONTO : '.';
DOISP : '..';
TRESP : '...';
// Regra para variáveis globais
VARIAVEISGLOBAIS : '_' ('A' .. 'Z')*;
// Regra para nomes
NOME : ('A' .. 'Z' | 'a' .. 'z') ('A' .. 'Z' | 'a' .. 'z' | '_' | '0' .. '9')*;
// Regra para cadeia de caractéres
/*
Note que estamos retirando a sequência de escape \\\
*/
CADEIA : '\'' ~('\'' | '\\')* '\''
| '"' ~('"' | '\\')* '"';
//Regra para números
NUM : ('0' .. '9')+ ('.' ('0' .. '9')+)?;
// Regra para comentário
COMENTARIO : '-' '-' ~('\n'|'\r')* '\r'? '\n' {skip();} | '-' '-' .*? '-' '-';
/*
-------------------------------------------------------------------------
Regras do parser
-------------------------------------------------------------------------
*/
// Regra para rodar o parser
programa : trecho EOF;
trecho : (comando (';')?)* (ultimocomando (';')?)?;
bloco : trecho;
comando : listavar '=' listaexp
| chamadadefuncao
| 'do' bloco 'end'
| 'while' exp 'do' bloco 'end'
| 'repeat' bloco 'until' exp
| 'if' exp 'then' bloco ('elseif' exp 'then' bloco)* ('else' bloco)? 'end'
| 'for' NOME '=' exp ',' exp (',' exp)? 'do' bloco 'end'
| 'for' listadenomes 'in' listaexp 'do' bloco 'end'
| 'function' nomedafuncao corpodafuncao
| 'local' 'function' NOME corpodafuncao
| 'local' listadenomes ('=' listaexp);
ultimocomando : 'return' (listaexp)? | 'break';
nomedafuncao : NOME ('.' NOME)* (':' NOME)?{ TabelaDeSimbolos.adicionarSimbolo($NOME.text,Tipo.FUNCAO);};
listavar : var (',' var)*;
// PROBLEMA: Havia recursão não-imediata com as funções: var, expprefixo e chamadadefunção
// SOL: Copia das funções no lugar da chamada das funções
var : NOME { TabelaDeSimbolos.adicionarSimbolo($NOME.text,Tipo.VARIAVEL);}
| expprefixo '[' exp ']'
| expprefixo '.' NOME { TabelaDeSimbolos.adicionarSimbolo($NOME.text,Tipo.FUNCAO);};
expprefixo :
//Parte da var
NOME
| expprefixo '[' exp ']'
| expprefixo '.' NOME { TabelaDeSimbolos.adicionarSimbolo($NOME.text,Tipo.FUNCAO);}
// Parte da chamadadefuncao
| expprefixo args | expprefixo ':' NOME{ TabelaDeSimbolos.adicionarSimbolo($NOME.text,Tipo.FUNCAO);}
| '(' exp ')';
chamadadefuncao : expprefixo args | expprefixo ':' NOME args { TabelaDeSimbolos.adicionarSimbolo($NOME.text,Tipo.FUNCAO);};
listadenomes : NOME (',' NOME)*{ TabelaDeSimbolos.adicionarSimbolo($NOME.text,Tipo.VARIAVEL);};
listaexp : (exp ',')* exp;
exp : 'nil' | 'false' | 'true' | NUM | CADEIA | '...' | funcao | expprefixo
| construtortabela | exp opbin exp | opunaria exp;
args : '(' (listaexp)? ')' | construtortabela | CADEIA;
funcao : 'function' corpodafuncao;
corpodafuncao : '(' (listapar)* ')' bloco 'end';
listapar : listadenomes (',' '...')? | '...';
construtortabela : '{' (listadecampos)? '}';
listadecampos : campo (separadordecampos campo)* (separadordecampos)?;
campo : '[' exp ']' '=' exp | NOME '=' exp { TabelaDeSimbolos.adicionarSimbolo($NOME.text,Tipo.VARIAVEL);}
| exp;
separadordecampos : ',' | ';';
opbin : '+' | '-' | '*' | '/' | '^'| '%' | '..' | '<'
| '<=' | '>' | '>=' | '==' | '~=' | 'and' | 'or';
opunaria : '-' | 'not' | '#'; | 4,310 | ANTLR | .g4 | 131 | 29.877863 | 124 | 0.530523 | FCChinen/T1Compiladores | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 284885be6f3c03ccda9227872c25c291379def76d948d9342bd4dd021b982538 | false | false | false | false |
134 | Anasint.g4 | pl-project-etsii_procesador/src/Anasint.g4 | parser grammar Anasint;
options{
tokenVocab=Analex;
}
sentencia : variables asignaciones iteraciones EOF; //añadir secciones de subprogramas e instrucciones
variables : VARIABLES (lista_variables)+;
lista_variables : IDENT COMA lista_variables
| IDENT DP tipo PyC
;
tipo : SEQ PA tipo PC //al ser recursivo se podría dar el caso de una secuencia dentro de una secuencia?
|NUM
|LOG
;
//NO SE ADMITEN ASIGNACIONES SIN VALOR A UNA VARIABLE
//Asignaciones multiples? Interpretacion parelela o secuencial? como asigno la prioridad a la operacion POR???
asignaciones: ASIGNACIONES (asignacion)* ;
asignacion : IDENT (COMA IDENT)* IGUAL expresion PyC;
expresion : expresion_entera | expresion_logica | expresion_no_elemental ;
funcion_entera: POR
| MAS
| MENOS
;
expresion_entera : NUMERO
| IDENT
| funcion_entera PA expresion_entera PC
| (COMA expresion_entera)*
;
expresion_logica : TRUE
| FALSE
| NO PA (expresion_logica) PC
;
expresion_no_elemental : CA (secuencia) CC //Si pongo (secuencia)? me da error (hablar de las funciones)
| IDENT
;
secuencia: (expresion_entera | expresion_logica) (COMA expresion_entera | expresion_logica)* ;
// Instrucciones: iteracion
iteraciones: ITERACIONES (iteracion)* ;
iteracion: variables // printExpr
| asignaciones // assign
| loop // whileLoop
;
relational: variables op=(MAYORQ|MENORQ) variables // GreaterEqual
;
loop: WHILE PA expresion_logica PA ? BA iteracion* BC ; // while
| 1,562 | ANTLR | .g4 | 44 | 32.204545 | 110 | 0.718375 | pl-project-etsii/procesador | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 8ba28fc4ebc40cf76af4559264e30ad158b6b14fb687abb8353fe3f7020f9095 | false | false | false | false |
135 | Analex.g4 | pl-project-etsii_procesador/src/Analex.g4 | lexer grammar Analex;
BLANCO: ' ' ->skip;
TABULADOR: '\t'->skip;
FIN_LINEA: '\r'?'\n' ->skip;
fragment DIGITO: [0-9];
fragment LETRA:[a-zA-Z];
NUM: 'NUM';
VARIABLES: 'VARIABLES';
ASIGNACIONES : 'ASIGNACIONES';
ITERACIONES: 'ITERACIONES';
LOG: 'LOG';
SEQ: 'SEQ';
NUMERO : ('-')?DIGITO+;
IDENT : LETRA(LETRA|DIGITO)*;
MAYORQ : '>' ;
MENORQ : '<' ;
PA : '(';
PC : ')';
BA: '{';
BC: '}';
PyC : ';';
COMA : ',';
DP : ':';
MAS: '+';
MENOS: '-';
POR: '*';
IGUAL : '=';
CA : '[' ;
CC : ']' ;
TRUE : 'true';
FALSE : 'false';
WHILE: 'while';
NO: 'not';
COMENTARIO_BLOQUE : '/*' .*? '*/' -> skip ;
COMENTARIO_LINEA : '//' .*? FIN_LINEA -> skip ; | 634 | ANTLR | .g4 | 35 | 17.142857 | 47 | 0.555 | pl-project-etsii/procesador | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | a8973cb51fa3aed10f702211710086e41442e31cd60712b8ed92651738b70cee | false | false | false | false |
136 | dash.g4 | danielverh_VmProgrammingLanguage/grammar/dash.g4 | grammar dash;
statement: expression ';' | operation | block;
operation: ifOp;
ifOp: IF expression SELECT statement
(|(ELSEIF expression SELECT statement))
(|(ELSE SELECT statement));
block: L_CURLY_BRACKET statement* R_CURLY_BRACKET;
expression:
INT |
FLOAT
;
ELSEIF: 'else if';
IF: 'if';
ELSE: 'else';
SELECT: '=>';
L_CURLY_BRACKET: '{';
R_CURLY_BRACKET: '}';
DECIMAL: '.';
// Operators
ADD: '+';
SUB: '-';
MUL: '*';
DIV: '/';
NOT: '!';
INT: [0-9]+;
FLOAT: [0-9]* DECIMAL [0-9]+;
ID: ([a-zA-Z_])+ ([a-zA-Z_] | [0-9])*;
WS: [\n\t\r]+->skip;
COMMENT: '/*' .*? '*/' -> skip;
LINE_COMMENT: '//' ~[\r\n]* -> skip; | 636 | ANTLR | .g4 | 30 | 19.333333 | 50 | 0.59129 | danielverh/VmProgrammingLanguage | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | aa85ab6d6431a50ec15106efd783da3397fa019a41cbe0df5bb5e21e0e8d07ee | false | false | false | false |
137 | FCSParser.g4 | clarin-eric_fcs-ql/src/main/antlr4/eu/clarin/sru/fcs/qlparser/FCSParser.g4 | parser grammar FCSParser;
options { tokenVocab=FCSLexer; }
/*
* Parser for FCS Core FCS-QL version 2.0
* 20150501- /ljo
*/
query
: main_query (WITHIN within_part)? EOF
;
main_query
: query_simple
| query_group
| query_sequence
| query_disjunction
;
query_disjunction
: (query_simple | query_sequence | query_group)
(OR (query_simple | query_sequence | query_group))+
;
query_sequence
: (query_simple | query_group)+
;
query_group
: L_PAREN (query_disjunction | query_sequence) R_PAREN quantifier?
;
query_simple
: (query_implicit | query_segment) quantifier?
;
quantifier
: (Q_ONE_OR_MORE | Q_ZERO_OR_MORE | Q_ZERO_OR_ONE |
( L_CURLY_BRACKET
(INTEGER |
INTEGER? Q_COMMA INTEGER |
INTEGER Q_COMMA INTEGER?) R_CURLY_BRACKET))
;
query_implicit
: regexp
;
query_segment
: L_SQUARE_BRACKET expression? R_SQUARE_BRACKET /* [ expression? ] */
;
within_part
: within_part_simple
;
within_part_simple
: SIMPLE_WITHIN_SCOPE
;
expression
: expression_basic
| expression_not
| expression_group
| expression_or
| expression_and
;
expression_or
: (expression_basic | expression_group | expression_not | expression_and)
(OR (expression_basic | expression_group | expression_not | expression_and))+
;
expression_and
: (expression_basic | expression_group | expression_not)
(AND (expression_basic | expression_group | expression_not))+
;
expression_group
: L_PAREN (expression_basic | expression_not | expression_or | expression_and) R_PAREN
;
expression_not
: NOT (expression_basic | expression_not | expression_or | expression_and)
;
expression_basic
: attribute (OPERATOR_EQ | OPERATOR_NE) regexp
;
attribute
: (qualifier COLON)? identifier
;
qualifier
: (IDENTIFIER | WITHIN | SIMPLE_WITHIN_SCOPE | REGEXP_FLAGS)
;
identifier
: (IDENTIFIER | WITHIN | SIMPLE_WITHIN_SCOPE | REGEXP_FLAGS)
;
regexp
: regexp_pattern (FWD_SLASH regexp_flag)?
;
regexp_pattern
: REGEXP
;
regexp_flag
: REGEXP_FLAGS
;
| 2,234 | ANTLR | .g4 | 89 | 20.191011 | 90 | 0.657932 | clarin-eric/fcs-ql | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 05e469f2ece104cfff6376aeeff4731d4ff5cbb9f896386d2022487bd8e6ea5b | false | false | false | false |
138 | FCSLexer.g4 | clarin-eric_fcs-ql/src/main/antlr4/eu/clarin/sru/fcs/qlparser/FCSLexer.g4 | lexer grammar FCSLexer;
/*
* Lexer part of parser for FCS Core FCS-QL version 2.0
* default mode
* 20150501- /ljo
*/
L_PAREN: '(';
R_PAREN: ')';
L_SQUARE_BRACKET: '[';
R_SQUARE_BRACKET: ']';
OR: '|';
AND: '&';
NOT: '!';
FWD_SLASH: '/';
L_CURLY_BRACKET: '{';
R_CURLY_BRACKET: '}';
Q_ONE_OR_MORE: '+';
Q_ZERO_OR_MORE: '*';
Q_ZERO_OR_ONE: '?';
Q_COMMA: ',';
OPERATOR_EQ: '=';
OPERATOR_NE: '!=';
COLON: ':';
WITHIN: 'within';
SIMPLE_WITHIN_SCOPE
: 'sentence'
| 's'
| 'utterance'
| 'u'
| 'paragraph'
| 'p'
| 'turn'
| 't'
| 'text'
| 'session'
;
REGEXP_FLAGS
: ( 'i' /* case-insensitive; Poliqarp/Perl compat */
| 'I' /* case-sensitive; Poliqarp compat */
| 'c' /* case-insensitive, CQP compat */
| 'C' /* case-sensitive */
| 'l' /* literal matching, CQP compat*/
| 'd')+ /* diacritic agnostic matching, CQP compat */
;
fragment IDENTIFIER_FIRST_CHAR
: [a-zA-Z]
;
fragment IDENTIFIER_LAST_CHAR
: [a-zA-Z0-9]
;
fragment IDENTIFIER_CHAR
: [a-zA-Z0-9\-]
;
IDENTIFIER
: IDENTIFIER_FIRST_CHAR (IDENTIFIER_CHAR* IDENTIFIER_LAST_CHAR)?
;
INTEGER
: [0-9]+
;
REGEXP
: QUOTED_STRING
;
/* // doesnt work
QUOTED_STRING
: '\'' (CHAR | WS)*? '\''
| '"' (CHAR | WS)*? '"'
;
*/
QUOTED_STRING
: '\'' (ESCAPED_CHAR | ~['\\])* '\''
| '"' (ESCAPED_CHAR | ~["\\])* '"'
;
fragment CHAR
: ESCAPED_CHAR
| ~('\u0009' | '\u000A' | '\u000B' | '\u000C' | '\u000D' | '\u0020' | '\u0085'
| '\u00A0' | '\u1680' | '\u2000' | '\u2001' | '\u2002' | '\u2003' | '\u2004'
| '\u2005' | '\u2006' | '\u2007' | '\u2008' | '\u2009' | '\u200A' | '\u2028'
| '\u2029' | '\u202F' | '\u205F' | '\u3000' ) //anything but white space
;
/* any unicode whitespace */
fragment WS: '\u0009' | '\u000A' | '\u000B' | '\u000C' | '\u000D' | '\u0020' | '\u0085'
| '\u00A0' | '\u1680' | '\u2000' | '\u2001' | '\u2002' | '\u2003' | '\u2004'
| '\u2005' | '\u2006' | '\u2007' | '\u2008' | '\u2009' | '\u200A' | '\u2028'
| '\u2029' | '\u202F' | '\u205F' | '\u3000'
;
fragment ESCAPED_CHAR
: '\\'
( '\\'
| '\''
| '"'
| 'n'
| 't'
| '.'
| '^'
| '$'
| '*'
| '+'
| '?'
| '('
| ')'
| '{'
| '['
| '|'
| 'x' HEX HEX
| 'u' HEX HEX HEX HEX
| 'U' HEX HEX HEX HEX HEX HEX HEX HEX
)
;
fragment HEX
: [0-9a-fA-F]
;
Space
: WS -> skip
;
| 2,597 | ANTLR | .g4 | 114 | 18.017544 | 87 | 0.466011 | clarin-eric/fcs-ql | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 8f76f7c40e7885e6fb2f7fd5fe7039ee69d58d21534844e25898d03c7c147945 | false | false | false | false |
139 | LexBasic.g4 | cjsoftware-plugin_Antlr4SyntaxRailroadDiagram/antlrshared/LexBasic.g4 | /*
* [The "BSD license"]
* Copyright (c) 2014-2015 Gerald Rosenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* A generally reusable set of fragments for import in to Lexer grammars.
*
* Modified 2015.06.16 gbr -
* -- generalized for inclusion into the ANTLRv4 grammar distribution
*
*/
lexer grammar LexBasic;
// ======================================================
// Lexer fragments
//
// -----------------------------------
// Whitespace & Comments
fragment Ws
: Hws
| Vws
;
fragment Hws
: [ \t]
;
fragment Vws
: [\r\n\f]
;
fragment BlockComment
: '/*' .*? ('*/' | EOF)
;
fragment DocComment
: '/**' .*? ('*/' | EOF)
;
fragment LineComment
: '//' ~ [\r\n]*
;
// -----------------------------------
// Escapes
// Any kind of escaped character that we can embed within ANTLR literal strings.
fragment EscSeq
: Esc ([btnfr"'\\] | UnicodeEsc | . | EOF)
;
fragment EscAny
: Esc .
;
fragment UnicodeEsc
: 'u' (HexDigit (HexDigit (HexDigit HexDigit?)?)?)?
;
// -----------------------------------
// Numerals
fragment DecimalNumeral
: '0'
| [1-9] DecDigit*
;
// -----------------------------------
// Digits
fragment HexDigit
: [0-9a-fA-F]
;
fragment DecDigit
: [0-9]
;
// -----------------------------------
// Literals
fragment BoolLiteral
: 'true'
| 'false'
;
fragment CharLiteral
: SQuote (EscSeq | ~ ['\r\n\\]) SQuote
;
fragment SQuoteLiteral
: SQuote (EscSeq | ~ ['\r\n\\])* SQuote
;
fragment DQuoteLiteral
: DQuote (EscSeq | ~ ["\r\n\\])* DQuote
;
fragment USQuoteLiteral
: SQuote (EscSeq | ~ ['\r\n\\])*
;
// -----------------------------------
// Character ranges
fragment NameChar
: NameStartChar
| '0' .. '9'
| Underscore
| '\u00B7'
| '\u0300' .. '\u036F'
| '\u203F' .. '\u2040'
;
fragment NameStartChar
: 'A' .. 'Z'
| 'a' .. 'z'
| '\u00C0' .. '\u00D6'
| '\u00D8' .. '\u00F6'
| '\u00F8' .. '\u02FF'
| '\u0370' .. '\u037D'
| '\u037F' .. '\u1FFF'
| '\u200C' .. '\u200D'
| '\u2070' .. '\u218F'
| '\u2C00' .. '\u2FEF'
| '\u3001' .. '\uD7FF'
| '\uF900' .. '\uFDCF'
| '\uFDF0' .. '\uFFFD'
;
// ignores | ['\u10000-'\uEFFFF] ;
// -----------------------------------
// Types
fragment Int
: 'int'
;
// -----------------------------------
// Symbols
fragment Esc
: '\\'
;
fragment Colon
: ':'
;
fragment DColon
: '::'
;
fragment SQuote
: '\''
;
fragment DQuote
: '"'
;
fragment LParen
: '('
;
fragment RParen
: ')'
;
fragment LBrace
: '{'
;
fragment RBrace
: '}'
;
fragment LBrack
: '['
;
fragment RBrack
: ']'
;
fragment RArrow
: '->'
;
fragment Lt
: '<'
;
fragment Gt
: '>'
;
fragment Equal
: '='
;
fragment Question
: '?'
;
fragment Star
: '*'
;
fragment Plus
: '+'
;
fragment PlusAssign
: '+='
;
fragment Underscore
: '_'
;
fragment Pipe
: '|'
;
fragment Dollar
: '$'
;
fragment Comma
: ','
;
fragment Semi
: ';'
;
fragment Dot
: '.'
;
fragment Range
: '..'
;
fragment At
: '@'
;
fragment Pound
: '#'
;
fragment Tilde
: '~'
;
| 4,714 | ANTLR | .g4 | 224 | 17.852679 | 83 | 0.571332 | cjsoftware-plugin/Antlr4SyntaxRailroadDiagram | 0 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 13e455c56fadb9395292dbf75268e17165c06a252c28285068d89d95dc9a5e7f | true | true | false | false |
141 | KotlinLexer.g4 | cjsoftware-plugin_Antlr4SyntaxRailroadDiagram/src/test/resources/antlr_kotlin/KotlinLexer.g4 | /**
* Kotlin Grammar for ANTLR v4
*
* Based on:
* http://jetbrains.github.io/kotlin-spec/#_grammars_and_parsing
* and
* http://kotlinlang.org/docs/reference/grammar.html
*
* Tested on
* https://github.com/JetBrains/kotlin/tree/master/compiler/testData/psi
*/
lexer grammar KotlinLexer;
import UnicodeClasses;
ShebangLine
: '#!' ~[\u000A\u000D]*
-> channel(HIDDEN)
;
DelimitedComment
: '/*' ( DelimitedComment | . )*? '*/'
-> channel(HIDDEN)
;
LineComment
: '//' ~[\u000A\u000D]*
-> channel(HIDDEN)
;
WS
: [\u0020\u0009\u000C]
-> skip
;
NL: '\u000A' | '\u000D' '\u000A' ;
//SEPARATORS & OPERATIONS
RESERVED: '...' ;
DOT: '.' ;
COMMA: ',' ;
LPAREN: '(' -> pushMode(Inside) ;
RPAREN: ')' ;
LSQUARE: '[' -> pushMode(Inside) ;
RSQUARE: ']' ;
LCURL: '{' ;
RCURL: '}' ;
MULT: '*' ;
MOD: '%' ;
DIV: '/' ;
ADD: '+' ;
SUB: '-' ;
INCR: '++' ;
DECR: '--' ;
CONJ: '&&' ;
DISJ: '||' ;
EXCL: '!' ;
COLON: ':' ;
SEMICOLON: ';' ;
ASSIGNMENT: '=' ;
ADD_ASSIGNMENT: '+=' ;
SUB_ASSIGNMENT: '-=' ;
MULT_ASSIGNMENT: '*=' ;
DIV_ASSIGNMENT: '/=' ;
MOD_ASSIGNMENT: '%=' ;
ARROW: '->' ;
DOUBLE_ARROW: '=>' ;
RANGE: '..' ;
COLONCOLON: '::' ;
Q_COLONCOLON: '?::' ;
DOUBLE_SEMICOLON: ';;' ;
HASH: '#' ;
AT: '@' ;
QUEST: '?' ;
ELVIS: '?:' ;
LANGLE: '<' ;
RANGLE: '>' ;
LE: '<=' ;
GE: '>=' ;
EXCL_EQ: '!=' ;
EXCL_EQEQ: '!==' ;
AS_SAFE: 'as?' ;
EQEQ: '==' ;
EQEQEQ: '===' ;
SINGLE_QUOTE: '\'' ;
//KEYWORDS
RETURN_AT: 'return@' Identifier ;
CONTINUE_AT: 'continue@' Identifier ;
BREAK_AT: 'break@' Identifier ;
FILE: '@file' ;
PACKAGE: 'package' ;
IMPORT: 'import' ;
CLASS: 'class' ;
INTERFACE: 'interface' ;
FUN: 'fun' ;
OBJECT: 'object' ;
VAL: 'val' ;
VAR: 'var' ;
TYPE_ALIAS: 'typealias' ;
CONSTRUCTOR: 'constructor' ;
BY: 'by' ;
COMPANION: 'companion' ;
INIT: 'init' ;
THIS: 'this' ;
SUPER: 'super' ;
TYPEOF: 'typeof' ;
WHERE: 'where' ;
IF: 'if' ;
ELSE: 'else' ;
WHEN: 'when' ;
TRY: 'try' ;
CATCH: 'catch' ;
FINALLY: 'finally' ;
FOR: 'for' ;
DO: 'do' ;
WHILE: 'while' ;
THROW: 'throw' ;
RETURN: 'return' ;
CONTINUE: 'continue' ;
BREAK: 'break' ;
AS: 'as' ;
IS: 'is' ;
IN: 'in' ;
NOT_IS: '!is' (WS | NL)+ ;
NOT_IN: '!in' (WS | NL)+ ;
OUT: 'out' ;
FIELD: '@field' ;
PROPERTY: '@property' ;
GET: '@get' ;
SET: '@set' ;
GETTER: 'get' ;
SETTER: 'set' ;
RECEIVER: '@receiver' ;
PARAM: '@param' ;
SETPARAM: '@setparam' ;
DELEGATE: '@delegate' ;
DYNAMIC: 'dynamic' ;
//MODIFIERS
PUBLIC: 'public' ;
PRIVATE: 'private' ;
PROTECTED: 'protected' ;
INTERNAL: 'internal' ;
ENUM: 'enum' ;
SEALED: 'sealed' ;
ANNOTATION: 'annotation' ;
DATA: 'data' ;
INNER: 'inner' ;
TAILREC: 'tailrec' ;
OPERATOR: 'operator' ;
INLINE: 'inline' ;
INFIX: 'infix' ;
EXTERNAL: 'external' ;
SUSPEND: 'suspend' ;
OVERRIDE: 'override' ;
ABSTRACT: 'abstract' ;
FINAL: 'final' ;
OPEN: 'open' ;
CONST: 'const' ;
LATEINIT: 'lateinit' ;
VARARG: 'vararg' ;
NOINLINE: 'noinline' ;
CROSSINLINE: 'crossinline' ;
REIFIED: 'reified' ;
//
QUOTE_OPEN: '"' -> pushMode(LineString) ;
TRIPLE_QUOTE_OPEN: '"""' -> pushMode(MultiLineString) ;
RealLiteral
: FloatLiteral
| DoubleLiteral
;
FloatLiteral
: (DoubleLiteral | IntegerLiteral) [fF]
;
DoubleLiteral
: ( (DecDigitNoZero DecDigit* | '0')? '.'
| (DecDigitNoZero (DecDigit | '_')* DecDigit)? '.')
( DecDigit+
| DecDigit (DecDigit | '_')+ DecDigit
| DecDigit+ [eE] ('+' | '-')? DecDigit+
| DecDigit+ [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit
| DecDigit (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit+
| DecDigit (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit
)
;
LongLiteral
: (IntegerLiteral | HexLiteral | BinLiteral) 'L'
;
IntegerLiteral
: ('0'
| DecDigitNoZero DecDigit*
| DecDigitNoZero (DecDigit | '_')+ DecDigit
| DecDigitNoZero DecDigit* [eE] ('+' | '-')? DecDigit+
| DecDigitNoZero DecDigit* [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit
| DecDigitNoZero (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit+
| DecDigitNoZero (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit
)
;
fragment DecDigit
: UNICODE_CLASS_ND
;
fragment DecDigitNoZero
: UNICODE_CLASS_ND_NoZeros
;
fragment UNICODE_CLASS_ND_NoZeros
: '\u0031'..'\u0039'
| '\u0661'..'\u0669'
| '\u06f1'..'\u06f9'
| '\u07c1'..'\u07c9'
| '\u0967'..'\u096f'
| '\u09e7'..'\u09ef'
| '\u0a67'..'\u0a6f'
| '\u0ae7'..'\u0aef'
| '\u0b67'..'\u0b6f'
| '\u0be7'..'\u0bef'
| '\u0c67'..'\u0c6f'
| '\u0ce7'..'\u0cef'
| '\u0d67'..'\u0d6f'
| '\u0de7'..'\u0def'
| '\u0e51'..'\u0e59'
| '\u0ed1'..'\u0ed9'
| '\u0f21'..'\u0f29'
| '\u1041'..'\u1049'
| '\u1091'..'\u1099'
| '\u17e1'..'\u17e9'
| '\u1811'..'\u1819'
| '\u1947'..'\u194f'
| '\u19d1'..'\u19d9'
| '\u1a81'..'\u1a89'
| '\u1a91'..'\u1a99'
| '\u1b51'..'\u1b59'
| '\u1bb1'..'\u1bb9'
| '\u1c41'..'\u1c49'
| '\u1c51'..'\u1c59'
| '\ua621'..'\ua629'
| '\ua8d1'..'\ua8d9'
| '\ua901'..'\ua909'
| '\ua9d1'..'\ua9d9'
| '\ua9f1'..'\ua9f9'
| '\uaa51'..'\uaa59'
| '\uabf1'..'\uabf9'
| '\uff11'..'\uff19'
;
HexLiteral
: '0' [xX] HexDigit (HexDigit | '_')*
;
fragment HexDigit
: [0-9a-fA-F]
;
BinLiteral
: '0' [bB] BinDigit (BinDigit | '_')*
;
fragment BinDigit
: [01]
;
BooleanLiteral
: 'true'
| 'false'
;
NullLiteral
: 'null'
;
Identifier
: (Letter | '_') (Letter | '_' | DecDigit)*
| '`' ~('`')+ '`'
;
LabelReference
: '@' Identifier
;
LabelDefinition
: Identifier '@'
;
FieldIdentifier
: '$' Identifier
;
CharacterLiteral
: '\'' (EscapeSeq | .) '\''
;
fragment EscapeSeq
: UniCharacterLiteral
| EscapedIdentifier
;
fragment UniCharacterLiteral
: '\\' 'u' HexDigit HexDigit HexDigit HexDigit
;
fragment EscapedIdentifier
: '\\' ('t' | 'b' | 'r' | 'n' | '\'' | '"' | '\\' | '$')
;
fragment Letter
: UNICODE_CLASS_LL
| UNICODE_CLASS_LM
| UNICODE_CLASS_LO
| UNICODE_CLASS_LT
| UNICODE_CLASS_LU
| UNICODE_CLASS_NL
;
mode Inside ;
Inside_RPAREN: ')' -> popMode, type(RPAREN) ;
Inside_RSQUARE: ']' -> popMode, type(RSQUARE);
Inside_LPAREN: LPAREN -> pushMode(Inside), type(LPAREN) ;
Inside_LSQUARE: LSQUARE -> pushMode(Inside), type(LSQUARE) ;
Inside_LCURL: LCURL -> type(LCURL) ;
Inside_RCURL: RCURL -> type(RCURL) ;
Inside_DOT: DOT -> type(DOT) ;
Inside_COMMA: COMMA -> type(COMMA) ;
Inside_MULT: MULT -> type(MULT) ;
Inside_MOD: MOD -> type(MOD) ;
Inside_DIV: DIV -> type(DIV) ;
Inside_ADD: ADD -> type(ADD) ;
Inside_SUB: SUB -> type(SUB) ;
Inside_INCR: INCR -> type(INCR) ;
Inside_DECR: DECR -> type(DECR) ;
Inside_CONJ: CONJ -> type(CONJ) ;
Inside_DISJ: DISJ -> type(DISJ) ;
Inside_EXCL: EXCL -> type(EXCL) ;
Inside_COLON: COLON -> type(COLON) ;
Inside_SEMICOLON: SEMICOLON -> type(SEMICOLON) ;
Inside_ASSIGNMENT: ASSIGNMENT -> type(ASSIGNMENT) ;
Inside_ADD_ASSIGNMENT: ADD_ASSIGNMENT -> type(ADD_ASSIGNMENT) ;
Inside_SUB_ASSIGNMENT: SUB_ASSIGNMENT -> type(SUB_ASSIGNMENT) ;
Inside_MULT_ASSIGNMENT: MULT_ASSIGNMENT -> type(MULT_ASSIGNMENT) ;
Inside_DIV_ASSIGNMENT: DIV_ASSIGNMENT -> type(DIV_ASSIGNMENT) ;
Inside_MOD_ASSIGNMENT: MOD_ASSIGNMENT -> type(MOD_ASSIGNMENT) ;
Inside_ARROW: ARROW -> type(ARROW) ;
Inside_DOUBLE_ARROW: DOUBLE_ARROW -> type(DOUBLE_ARROW) ;
Inside_RANGE: RANGE -> type(RANGE) ;
Inside_RESERVED: RESERVED -> type(RESERVED) ;
Inside_COLONCOLON: COLONCOLON -> type(COLONCOLON) ;
Inside_Q_COLONCOLON: Q_COLONCOLON -> type(Q_COLONCOLON) ;
Inside_DOUBLE_SEMICOLON: DOUBLE_SEMICOLON -> type(DOUBLE_SEMICOLON) ;
Inside_HASH: HASH -> type(HASH) ;
Inside_AT: AT -> type(AT) ;
Inside_QUEST: QUEST -> type(QUEST) ;
Inside_ELVIS: ELVIS -> type(ELVIS) ;
Inside_LANGLE: LANGLE -> type(LANGLE) ;
Inside_RANGLE: RANGLE -> type(RANGLE) ;
Inside_LE: LE -> type(LE) ;
Inside_GE: GE -> type(GE) ;
Inside_EXCL_EQ: EXCL_EQ -> type(EXCL_EQ) ;
Inside_EXCL_EQEQ: EXCL_EQEQ -> type(EXCL_EQEQ) ;
Inside_NOT_IS: NOT_IS -> type(NOT_IS) ;
Inside_NOT_IN: NOT_IN -> type(NOT_IN) ;
Inside_AS_SAFE: AS_SAFE -> type(AS_SAFE) ;
Inside_EQEQ: EQEQ -> type(EQEQ) ;
Inside_EQEQEQ: EQEQEQ -> type(EQEQEQ) ;
Inside_SINGLE_QUOTE: SINGLE_QUOTE -> type(SINGLE_QUOTE) ;
Inside_QUOTE_OPEN: QUOTE_OPEN -> pushMode(LineString), type(QUOTE_OPEN) ;
Inside_TRIPLE_QUOTE_OPEN: TRIPLE_QUOTE_OPEN -> pushMode(MultiLineString), type(TRIPLE_QUOTE_OPEN) ;
Inside_VAL: VAL -> type(VAL) ;
Inside_VAR: VAR -> type(VAR) ;
Inside_OBJECT: OBJECT -> type(OBJECT) ;
Inside_SUPER: SUPER -> type(SUPER) ;
Inside_IN: IN -> type(IN) ;
Inside_OUT: OUT -> type(OUT) ;
Inside_FIELD: FIELD -> type(FIELD) ;
Inside_FILE: FILE -> type(FILE) ;
Inside_PROPERTY: PROPERTY -> type(PROPERTY) ;
Inside_GET: GET -> type(GET) ;
Inside_SET: SET -> type(SET) ;
Inside_RECEIVER: RECEIVER -> type(RECEIVER) ;
Inside_PARAM: PARAM -> type(PARAM) ;
Inside_SETPARAM: SETPARAM -> type(SETPARAM) ;
Inside_DELEGATE: DELEGATE -> type(DELEGATE) ;
Inside_THROW: THROW -> type(THROW) ;
Inside_RETURN: RETURN -> type(RETURN) ;
Inside_CONTINUE: CONTINUE -> type(CONTINUE) ;
Inside_BREAK: BREAK -> type(BREAK) ;
Inside_RETURN_AT: RETURN_AT -> type(RETURN_AT) ;
Inside_CONTINUE_AT: CONTINUE_AT -> type(CONTINUE_AT) ;
Inside_BREAK_AT: BREAK_AT -> type(BREAK_AT) ;
Inside_IF: IF -> type(IF) ;
Inside_ELSE: ELSE -> type(ELSE) ;
Inside_WHEN: WHEN -> type(WHEN) ;
Inside_TRY: TRY -> type(TRY) ;
Inside_CATCH: CATCH -> type(CATCH) ;
Inside_FINALLY: FINALLY -> type(FINALLY) ;
Inside_FOR: FOR -> type(FOR) ;
Inside_DO: DO -> type(DO) ;
Inside_WHILE: WHILE -> type(WHILE) ;
Inside_PUBLIC: PUBLIC -> type(PUBLIC) ;
Inside_PRIVATE: PRIVATE -> type(PRIVATE) ;
Inside_PROTECTED: PROTECTED -> type(PROTECTED) ;
Inside_INTERNAL: INTERNAL -> type(INTERNAL) ;
Inside_ENUM: ENUM -> type(ENUM) ;
Inside_SEALED: SEALED -> type(SEALED) ;
Inside_ANNOTATION: ANNOTATION -> type(ANNOTATION) ;
Inside_DATA: DATA -> type(DATA) ;
Inside_INNER: INNER -> type(INNER) ;
Inside_TAILREC: TAILREC -> type(TAILREC) ;
Inside_OPERATOR: OPERATOR -> type(OPERATOR) ;
Inside_INLINE: INLINE -> type(INLINE) ;
Inside_INFIX: INFIX -> type(INFIX) ;
Inside_EXTERNAL: EXTERNAL -> type(EXTERNAL) ;
Inside_SUSPEND: SUSPEND -> type(SUSPEND) ;
Inside_OVERRIDE: OVERRIDE -> type(OVERRIDE) ;
Inside_ABSTRACT: ABSTRACT -> type(ABSTRACT) ;
Inside_FINAL: FINAL -> type(FINAL) ;
Inside_OPEN: OPEN -> type(OPEN) ;
Inside_CONST: CONST -> type(CONST) ;
Inside_LATEINIT: LATEINIT -> type(LATEINIT) ;
Inside_VARARG: VARARG -> type(VARARG) ;
Inside_NOINLINE: NOINLINE -> type(NOINLINE) ;
Inside_CROSSINLINE: CROSSINLINE -> type(CROSSINLINE) ;
Inside_REIFIED: REIFIED -> type(REIFIED) ;
Inside_BooleanLiteral: BooleanLiteral -> type(BooleanLiteral) ;
Inside_IntegerLiteral: IntegerLiteral -> type(IntegerLiteral) ;
Inside_HexLiteral: HexLiteral -> type(HexLiteral) ;
Inside_BinLiteral: BinLiteral -> type(BinLiteral) ;
Inside_CharacterLiteral: CharacterLiteral -> type(CharacterLiteral) ;
Inside_RealLiteral: RealLiteral -> type(RealLiteral) ;
Inside_NullLiteral: NullLiteral -> type(NullLiteral) ;
Inside_LongLiteral: LongLiteral -> type(LongLiteral) ;
Inside_Identifier: Identifier -> type(Identifier) ;
Inside_LabelReference: LabelReference -> type(LabelReference) ;
Inside_LabelDefinition: LabelDefinition -> type(LabelDefinition) ;
Inside_Comment: (LineComment | DelimitedComment) -> channel(HIDDEN) ;
Inside_WS: WS -> skip ;
Inside_NL: NL -> skip ;
mode LineString ;
QUOTE_CLOSE
: '"' -> popMode
;
LineStrRef
: FieldIdentifier
;
LineStrText
: ~('\\' | '"' | '$')+ | '$'
;
LineStrEscapedChar
: '\\' .
| UniCharacterLiteral
;
LineStrExprStart
: '${' -> pushMode(StringExpression)
;
mode MultiLineString ;
TRIPLE_QUOTE_CLOSE
: MultiLineStringQuote? '"""' -> popMode
;
MultiLineStringQuote
: '"'+
;
MultiLineStrRef
: FieldIdentifier
;
MultiLineStrText
: ~('\\' | '"' | '$')+ | '$'
;
MultiLineStrEscapedChar
: '\\' .
;
MultiLineStrExprStart
: '${' -> pushMode(StringExpression)
;
MultiLineNL: NL -> skip ;
mode StringExpression ;
StrExpr_RCURL: RCURL -> popMode, type(RCURL) ;
StrExpr_LPAREN: LPAREN -> pushMode(Inside), type(LPAREN) ;
StrExpr_LSQUARE: LSQUARE -> pushMode(Inside), type(LSQUARE) ;
StrExpr_RPAREN: ')' -> type(RPAREN) ;
StrExpr_RSQUARE: ']' -> type(RSQUARE);
StrExpr_LCURL: LCURL -> pushMode(StringExpression), type(LCURL) ;
StrExpr_DOT: DOT -> type(DOT) ;
StrExpr_COMMA: COMMA -> type(COMMA) ;
StrExpr_MULT: MULT -> type(MULT) ;
StrExpr_MOD: MOD -> type(MOD) ;
StrExpr_DIV: DIV -> type(DIV) ;
StrExpr_ADD: ADD -> type(ADD) ;
StrExpr_SUB: SUB -> type(SUB) ;
StrExpr_INCR: INCR -> type(INCR) ;
StrExpr_DECR: DECR -> type(DECR) ;
StrExpr_CONJ: CONJ -> type(CONJ) ;
StrExpr_DISJ: DISJ -> type(DISJ) ;
StrExpr_EXCL: EXCL -> type(EXCL) ;
StrExpr_COLON: COLON -> type(COLON) ;
StrExpr_SEMICOLON: SEMICOLON -> type(SEMICOLON) ;
StrExpr_ASSIGNMENT: ASSIGNMENT -> type(ASSIGNMENT) ;
StrExpr_ADD_ASSIGNMENT: ADD_ASSIGNMENT -> type(ADD_ASSIGNMENT) ;
StrExpr_SUB_ASSIGNMENT: SUB_ASSIGNMENT -> type(SUB_ASSIGNMENT) ;
StrExpr_MULT_ASSIGNMENT: MULT_ASSIGNMENT -> type(MULT_ASSIGNMENT) ;
StrExpr_DIV_ASSIGNMENT: DIV_ASSIGNMENT -> type(DIV_ASSIGNMENT) ;
StrExpr_MOD_ASSIGNMENT: MOD_ASSIGNMENT -> type(MOD_ASSIGNMENT) ;
StrExpr_ARROW: ARROW -> type(ARROW) ;
StrExpr_DOUBLE_ARROW: DOUBLE_ARROW -> type(DOUBLE_ARROW) ;
StrExpr_RANGE: RANGE -> type(RANGE) ;
StrExpr_COLONCOLON: COLONCOLON -> type(COLONCOLON) ;
StrExpr_Q_COLONCOLON: Q_COLONCOLON -> type(Q_COLONCOLON) ;
StrExpr_DOUBLE_SEMICOLON: DOUBLE_SEMICOLON -> type(DOUBLE_SEMICOLON) ;
StrExpr_HASH: HASH -> type(HASH) ;
StrExpr_AT: AT -> type(AT) ;
StrExpr_QUEST: QUEST -> type(QUEST) ;
StrExpr_ELVIS: ELVIS -> type(ELVIS) ;
StrExpr_LANGLE: LANGLE -> type(LANGLE) ;
StrExpr_RANGLE: RANGLE -> type(RANGLE) ;
StrExpr_LE: LE -> type(LE) ;
StrExpr_GE: GE -> type(GE) ;
StrExpr_EXCL_EQ: EXCL_EQ -> type(EXCL_EQ) ;
StrExpr_EXCL_EQEQ: EXCL_EQEQ -> type(EXCL_EQEQ) ;
StrExpr_AS: AS -> type(IS) ;
StrExpr_IS: IS -> type(IN) ;
StrExpr_IN: IN ;
StrExpr_NOT_IS: NOT_IS -> type(NOT_IS) ;
StrExpr_NOT_IN: NOT_IN -> type(NOT_IN) ;
StrExpr_AS_SAFE: AS_SAFE -> type(AS_SAFE) ;
StrExpr_EQEQ: EQEQ -> type(EQEQ) ;
StrExpr_EQEQEQ: EQEQEQ -> type(EQEQEQ) ;
StrExpr_SINGLE_QUOTE: SINGLE_QUOTE -> type(SINGLE_QUOTE) ;
StrExpr_QUOTE_OPEN: QUOTE_OPEN -> pushMode(LineString), type(QUOTE_OPEN) ;
StrExpr_TRIPLE_QUOTE_OPEN: TRIPLE_QUOTE_OPEN -> pushMode(MultiLineString), type(TRIPLE_QUOTE_OPEN) ;
StrExpr_BooleanLiteral: BooleanLiteral -> type(BooleanLiteral) ;
StrExpr_IntegerLiteral: IntegerLiteral -> type(IntegerLiteral) ;
StrExpr_HexLiteral: HexLiteral -> type(HexLiteral) ;
StrExpr_BinLiteral: BinLiteral -> type(BinLiteral) ;
StrExpr_CharacterLiteral: CharacterLiteral -> type(CharacterLiteral) ;
StrExpr_RealLiteral: RealLiteral -> type(RealLiteral) ;
StrExpr_NullLiteral: NullLiteral -> type(NullLiteral) ;
StrExpr_LongLiteral: LongLiteral -> type(LongLiteral) ;
StrExpr_Identifier: Identifier -> type(Identifier) ;
StrExpr_LabelReference: LabelReference -> type(LabelReference) ;
StrExpr_LabelDefinition: LabelDefinition -> type(LabelDefinition) ;
StrExpr_Comment: (LineComment | DelimitedComment) -> channel(HIDDEN) ;
StrExpr_WS: WS -> skip ;
StrExpr_NL: NL -> skip ;
| 15,355 | ANTLR | .g4 | 515 | 27.712621 | 103 | 0.659196 | cjsoftware-plugin/Antlr4SyntaxRailroadDiagram | 0 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 224786c70142d4075c0321f9ad1239ccf4fa7d82ab8e40b15803f4175da78f39 | true | true | false | false |
142 | KotlinParser.g4 | cjsoftware-plugin_Antlr4SyntaxRailroadDiagram/src/test/resources/antlr_kotlin/KotlinParser.g4 | /**
* Kotlin Grammar for ANTLR v4
*
* Based on:
* http://jetbrains.github.io/kotlin-spec/#_grammars_and_parsing
* and
* http://kotlinlang.org/docs/reference/grammar.html
*
* Tested on
* https://github.com/JetBrains/kotlin/tree/master/compiler/testData/psi
*/
parser grammar KotlinParser;
options { tokenVocab = KotlinLexer; }
kotlinFile
: NL* preamble anysemi* (topLevelObject (anysemi+ topLevelObject?)*)? EOF
;
script
: NL* preamble anysemi* (expression (anysemi+ expression?)*)? EOF
;
preamble
: fileAnnotations? packageHeader importList
;
fileAnnotations
: fileAnnotation+
;
fileAnnotation
: (FILE COLON (LSQUARE unescapedAnnotation+ RSQUARE | unescapedAnnotation) semi?)+
;
packageHeader
: (modifierList? PACKAGE identifier semi?)?
;
importList
: importHeader*
;
importHeader
: IMPORT identifier (DOT MULT | importAlias)? semi?
;
importAlias
: AS simpleIdentifier
;
topLevelObject
: classDeclaration
| objectDeclaration
| functionDeclaration
| propertyDeclaration
| typeAlias
;
classDeclaration
: modifierList? (CLASS | INTERFACE) NL* simpleIdentifier
(NL* typeParameters)? (NL* primaryConstructor)?
(NL* COLON NL* delegationSpecifiers)?
(NL* typeConstraints)?
(NL* classBody | NL* enumClassBody)?
;
primaryConstructor
: modifierList? (CONSTRUCTOR NL*)? classParameters
;
classParameters
: LPAREN (classParameter (COMMA classParameter)*)? RPAREN
;
classParameter
: modifierList? (VAL | VAR)? simpleIdentifier COLON type (ASSIGNMENT expression)?
;
delegationSpecifiers
: annotations* delegationSpecifier (NL* COMMA NL* delegationSpecifier)*
;
delegationSpecifier
: constructorInvocation
| userType
| explicitDelegation
;
constructorInvocation
: userType callSuffix
;
explicitDelegation
: userType NL* BY NL* expression
;
classBody
: LCURL NL* classMemberDeclaration* NL* RCURL
;
classMemberDeclaration
: (classDeclaration
| functionDeclaration
| objectDeclaration
| companionObject
| propertyDeclaration
| anonymousInitializer
| secondaryConstructor
| typeAlias) anysemi+
;
anonymousInitializer
: INIT NL* block
;
secondaryConstructor
: modifierList? CONSTRUCTOR NL* functionValueParameters (NL* COLON NL* constructorDelegationCall)? NL* block?
;
constructorDelegationCall
: THIS NL* valueArguments
| SUPER NL* valueArguments
;
enumClassBody
: LCURL NL* enumEntries? (NL* SEMICOLON NL* classMemberDeclaration*)? NL* RCURL
;
enumEntries
: (enumEntry NL*)+ SEMICOLON?
;
enumEntry
: simpleIdentifier (NL* valueArguments)? (NL* classBody)? (NL* COMMA)?
;
functionDeclaration
: modifierList? FUN
(NL* type NL* DOT)?
(NL* typeParameters)?
(NL* identifier)?
NL* functionValueParameters
(NL* COLON NL* type)?
(NL* typeConstraints)?
(NL* functionBody)?
;
functionValueParameters
: LPAREN (functionValueParameter (COMMA functionValueParameter)*)? RPAREN
;
functionValueParameter
: modifierList? parameter (ASSIGNMENT expression)?
;
parameter
: simpleIdentifier COLON type
;
functionBody
: block
| ASSIGNMENT NL* expression
;
objectDeclaration
: modifierList? OBJECT
NL* simpleIdentifier
(NL* primaryConstructor)?
(NL* COLON NL* delegationSpecifiers)?
(NL* classBody)?
;
companionObject
: modifierList? COMPANION NL* modifierList? OBJECT
(NL* simpleIdentifier)?
(NL* COLON NL* delegationSpecifiers)?
(NL* classBody)?
;
propertyDeclaration
: modifierList? (VAL | VAR)
(NL* typeParameters)?
(NL* type NL* DOT)?
(NL* (multiVariableDeclaration | variableDeclaration))
(NL* typeConstraints)?
(NL* (BY | ASSIGNMENT) NL* expression)?
(getter (semi setter)? | setter (semi getter)?)?
;
multiVariableDeclaration
: LPAREN variableDeclaration (COMMA variableDeclaration)* RPAREN
;
variableDeclaration
: simpleIdentifier (COLON type)?
;
getter
: modifierList? GETTER
| modifierList? GETTER NL* LPAREN RPAREN (NL* COLON NL* type)? NL* (block | ASSIGNMENT NL* expression)
;
setter
: modifierList? SETTER
| modifierList? SETTER NL* LPAREN (annotations | parameterModifier)* (simpleIdentifier | parameter) RPAREN NL* functionBody
;
typeAlias
: modifierList? TYPE_ALIAS NL* simpleIdentifier (NL* typeParameters)? NL* ASSIGNMENT NL* type
;
typeParameters
: LANGLE NL* typeParameter (NL* COMMA NL* typeParameter)* NL* RANGLE
;
typeParameter
: modifierList? NL* simpleIdentifier (NL* COLON NL* type)?
;
type
: typeModifierList?
( functionType
| parenthesizedType
| nullableType
| typeReference)
;
typeModifierList
: (annotations | SUSPEND NL*)+
;
parenthesizedType
: LPAREN type RPAREN
;
nullableType
: (typeReference | parenthesizedType) NL* QUEST+
;
typeReference
: LPAREN typeReference RPAREN
| userType
| DYNAMIC
;
functionType
: (functionTypeReceiver NL* DOT NL*)? functionTypeParameters NL* ARROW (NL* type)
;
functionTypeReceiver
: parenthesizedType
| nullableType
| typeReference
;
userType
: simpleUserType (NL* DOT NL* simpleUserType)*
;
simpleUserType
: simpleIdentifier (NL* typeArguments)?
;
//parameters for functionType
functionTypeParameters
: LPAREN (parameter | type)? (COMMA (parameter | type))* RPAREN
;
typeConstraints
: WHERE NL* typeConstraint (NL* COMMA NL* typeConstraint)*
;
typeConstraint
: annotations* simpleIdentifier NL* COLON NL* type
;
block
: LCURL statements RCURL
;
statements
: anysemi* (statement (anysemi+ statement?)*)?
;
statement
: declaration
| blockLevelExpression
;
blockLevelExpression
: annotations* NL* expression
;
declaration
: labelDefinition*
( classDeclaration
| functionDeclaration
| propertyDeclaration
| typeAlias)
;
expression
: disjunction (assignmentOperator disjunction)*
;
disjunction
: conjunction (NL* DISJ NL* conjunction)*
;
conjunction
: equalityComparison (NL* CONJ NL* equalityComparison)*
;
equalityComparison
: comparison (equalityOperation NL* comparison)*
;
comparison
: namedInfix (comparisonOperator NL* namedInfix)?
;
namedInfix
: elvisExpression ((inOperator NL* elvisExpression)+ | (isOperator NL* type))?
;
elvisExpression
: infixFunctionCall (NL* ELVIS NL* infixFunctionCall)*
;
infixFunctionCall
: rangeExpression (simpleIdentifier NL* rangeExpression)*
;
rangeExpression
: additiveExpression (RANGE NL* additiveExpression)*
;
additiveExpression
: multiplicativeExpression (additiveOperator NL* multiplicativeExpression)*
;
multiplicativeExpression
: typeRHS (multiplicativeOperation NL* typeRHS)*
;
typeRHS
: prefixUnaryExpression (NL* typeOperation prefixUnaryExpression)*
;
prefixUnaryExpression
: prefixUnaryOperation* postfixUnaryExpression
;
postfixUnaryExpression
: (atomicExpression | callableReference) postfixUnaryOperation*
;
atomicExpression
: parenthesizedExpression
| literalConstant
| functionLiteral
| thisExpression // THIS labelReference?
| superExpression // SUPER (LANGLE type RANGLE)? labelReference?
| conditionalExpression // ifExpression, whenExpression
| tryExpression
| objectLiteral
| jumpExpression
| loopExpression
| collectionLiteral
| simpleIdentifier
;
parenthesizedExpression
: LPAREN expression RPAREN
;
callSuffix
: typeArguments valueArguments? annotatedLambda*
| valueArguments annotatedLambda*
| annotatedLambda+
;
annotatedLambda
: unescapedAnnotation* LabelDefinition? NL* functionLiteral
;
arrayAccess
: LSQUARE (expression (COMMA expression)*)? RSQUARE
;
valueArguments
: LPAREN (valueArgument (COMMA valueArgument)*)? RPAREN
;
typeArguments
: LANGLE NL* typeProjection (NL* COMMA typeProjection)* NL* RANGLE
;
typeProjection
: typeProjectionModifierList? type | MULT
;
typeProjectionModifierList
: varianceAnnotation+
;
valueArgument
: (simpleIdentifier NL* ASSIGNMENT NL*)? MULT? NL* expression
;
literalConstant
: BooleanLiteral
| IntegerLiteral
| stringLiteral
| HexLiteral
| BinLiteral
| CharacterLiteral
| RealLiteral
| NullLiteral
| LongLiteral
;
stringLiteral
: lineStringLiteral
| multiLineStringLiteral
;
lineStringLiteral
: QUOTE_OPEN (lineStringContent | lineStringExpression)* QUOTE_CLOSE
;
multiLineStringLiteral
: TRIPLE_QUOTE_OPEN (multiLineStringContent | multiLineStringExpression | lineStringLiteral | MultiLineStringQuote)* TRIPLE_QUOTE_CLOSE
;
lineStringContent
: LineStrText
| LineStrEscapedChar
| LineStrRef
;
lineStringExpression
: LineStrExprStart expression RCURL
;
multiLineStringContent
: MultiLineStrText
| MultiLineStrEscapedChar
| MultiLineStrRef
;
multiLineStringExpression
: MultiLineStrExprStart expression RCURL
;
functionLiteral
: annotations*
( LCURL NL* statements NL* RCURL
| LCURL NL* lambdaParameters NL* ARROW NL* statements NL* RCURL )
;
lambdaParameters
: lambdaParameter? (NL* COMMA NL* lambdaParameter)*
;
lambdaParameter
: variableDeclaration
| multiVariableDeclaration (NL* COLON NL* type)?
;
objectLiteral
: OBJECT (NL* COLON NL* delegationSpecifiers)? NL* classBody
;
collectionLiteral
: LSQUARE expression? (COMMA expression)* RSQUARE
;
thisExpression
: THIS LabelReference?
;
superExpression
: SUPER (LANGLE NL* type NL* RANGLE)? LabelReference?
;
conditionalExpression
: ifExpression
| whenExpression
;
ifExpression
: IF NL* LPAREN expression RPAREN NL* controlStructureBody? SEMICOLON?
(NL* ELSE NL* controlStructureBody?)?
;
controlStructureBody
: block
| expression
;
whenExpression
: WHEN NL* (LPAREN expression RPAREN)? NL* LCURL NL* (whenEntry NL*)* NL* RCURL
;
whenEntry
: whenCondition (NL* COMMA NL* whenCondition)* NL* ARROW NL* controlStructureBody semi?
| ELSE NL* ARROW NL* controlStructureBody
;
whenCondition
: expression
| rangeTest
| typeTest
;
rangeTest
: inOperator NL* expression
;
typeTest
: isOperator NL* type
;
tryExpression
: TRY NL* block (NL* catchBlock)* (NL* finallyBlock)?
;
catchBlock
: CATCH NL* LPAREN annotations* simpleIdentifier COLON userType RPAREN NL* block
;
finallyBlock
: FINALLY NL* block
;
loopExpression
: forExpression
| whileExpression
| doWhileExpression
;
forExpression
: FOR NL* LPAREN annotations* (variableDeclaration | multiVariableDeclaration) IN expression RPAREN NL* controlStructureBody?
;
whileExpression
: WHILE NL* LPAREN expression RPAREN NL* controlStructureBody?
;
doWhileExpression
: DO NL* controlStructureBody? NL* WHILE NL* LPAREN expression RPAREN
;
jumpExpression
: THROW NL* expression
| (RETURN | RETURN_AT) expression?
| CONTINUE | CONTINUE_AT
| BREAK | BREAK_AT
;
callableReference
: (userType (QUEST NL*)*)? NL* (COLONCOLON | Q_COLONCOLON) NL* (identifier | CLASS)
;
assignmentOperator
: ASSIGNMENT
| ADD_ASSIGNMENT
| SUB_ASSIGNMENT
| MULT_ASSIGNMENT
| DIV_ASSIGNMENT
| MOD_ASSIGNMENT
;
equalityOperation
: EXCL_EQ
| EXCL_EQEQ
| EQEQ
| EQEQEQ
;
comparisonOperator
: LANGLE
| RANGLE
| LE
| GE
;
inOperator
: IN | NOT_IN
;
isOperator
: IS | NOT_IS
;
additiveOperator
: ADD | SUB
;
multiplicativeOperation
: MULT
| DIV
| MOD
;
typeOperation
: AS
| AS_SAFE
| COLON
;
prefixUnaryOperation
: INCR
| DECR
| ADD
| SUB
| EXCL
| annotations
| labelDefinition
;
postfixUnaryOperation
: INCR | DECR | EXCL EXCL
| callSuffix
| arrayAccess
| NL* memberAccessOperator postfixUnaryExpression
;
memberAccessOperator
: DOT | QUEST DOT
;
modifierList
: (annotations | modifier)+
;
modifier
: (classModifier
| memberModifier
| visibilityModifier
| varianceAnnotation
| functionModifier
| propertyModifier
| inheritanceModifier
| parameterModifier
| typeParameterModifier) NL*
;
classModifier
: ENUM
| SEALED
| ANNOTATION
| DATA
| INNER
;
memberModifier
: OVERRIDE
| LATEINIT
;
visibilityModifier
: PUBLIC
| PRIVATE
| INTERNAL
| PROTECTED
;
varianceAnnotation
: IN | OUT
;
functionModifier
: TAILREC
| OPERATOR
| INFIX
| INLINE
| EXTERNAL
| SUSPEND
;
propertyModifier
: CONST
;
inheritanceModifier
: ABSTRACT
| FINAL
| OPEN
;
parameterModifier
: VARARG
| NOINLINE
| CROSSINLINE
;
typeParameterModifier
: REIFIED
;
labelDefinition
: LabelDefinition NL*
;
annotations
: (annotation | annotationList) NL*
;
annotation
: annotationUseSiteTarget NL* COLON NL* unescapedAnnotation
| LabelReference (NL* typeArguments)? (NL* valueArguments)?
;
annotationList
: annotationUseSiteTarget COLON LSQUARE unescapedAnnotation+ RSQUARE
| AT LSQUARE unescapedAnnotation+ RSQUARE
;
annotationUseSiteTarget
: FIELD
| FILE
| PROPERTY
| GET
| SET
| RECEIVER
| PARAM
| SETPARAM
| DELEGATE
;
unescapedAnnotation
: identifier typeArguments? valueArguments?
;
identifier
: simpleIdentifier (NL* DOT simpleIdentifier)*
;
simpleIdentifier
: Identifier
//soft keywords:
| ABSTRACT
| ANNOTATION
| BY
| CATCH
| COMPANION
| CONSTRUCTOR
| CROSSINLINE
| DATA
| DYNAMIC
| ENUM
| EXTERNAL
| FINAL
| FINALLY
| GETTER
| IMPORT
| INFIX
| INIT
| INLINE
| INNER
| INTERNAL
| LATEINIT
| NOINLINE
| OPEN
| OPERATOR
| OUT
| OVERRIDE
| PRIVATE
| PROTECTED
| PUBLIC
| REIFIED
| SEALED
| TAILREC
| SETTER
| VARARG
| WHERE
//strong keywords
| CONST
| SUSPEND
;
semi: NL+ | NL* SEMICOLON NL*;
anysemi: NL | SEMICOLON;
| 14,551 | ANTLR | .g4 | 640 | 18.489063 | 139 | 0.708058 | cjsoftware-plugin/Antlr4SyntaxRailroadDiagram | 0 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 5426f006926179e297675ce799c4e3b30221489d56b7dd3c13161331762b3510 | true | true | false | false |
143 | Swift5Lexer.g4 | cjsoftware-plugin_Antlr4SyntaxRailroadDiagram/src/test/resources/antlr_swift5/Swift5Lexer.g4 | lexer grammar Swift5Lexer;
@lexer::header {
import java.util.Stack;
}
@lexer::members {
Stack<Integer> parenthesis = new Stack<Integer>();
@Override
public void reset(){
super.reset();
parenthesis.clear();
}
}
AS: 'as';
ALPHA: 'alpha';
BREAK: 'break';
CASE: 'case';
CATCH: 'catch';
CLASS: 'class';
CONTINUE: 'continue';
DEFAULT: 'default';
DEFER: 'defer';
DO: 'do';
GUARD: 'guard';
ELSE: 'else';
ENUM: 'enum';
FOR: 'for';
FALLTHROUGH: 'fallthrough';
FUNC: 'func';
IN: 'in';
IF: 'if';
IMPORT: 'import';
INTERNAL: 'internal';
FINAL: 'final';
OPEN: 'open';
PRIVATE: 'private';
PUBLIC: 'public';
WHERE: 'where';
WHILE: 'while';
LET: 'let';
VAR: 'var';
PROTOCOL: 'protocol';
GET: 'get';
SET: 'set';
WILL_SET: 'willSet';
DID_SET: 'didSet';
REPEAT: 'repeat';
SWITCH: 'switch';
STRUCT: 'struct';
RETURN: 'return';
THROW: 'throw';
THROWS: 'throws';
RETHROWS: 'rethrows';
INDIRECT: 'indirect';
INIT: 'init';
DEINIT: 'deinit';
ASSOCIATED_TYPE: 'associatedtype';
EXTENSION: 'extension';
SUBSCRIPT: 'subscript';
PREFIX: 'prefix';
INFIX: 'infix';
LEFT: 'left';
RIGHT: 'right';
NONE: 'none';
PRECEDENCE_GROUP: 'precedencegroup';
HIGHER_THAN: 'higherThan';
LOWER_THAN: 'lowerThan';
ASSIGNMENT: 'assignment';
ASSOCIATIVITY: 'associativity';
POSTFIX: 'postfix';
OPERATOR: 'operator';
TYPEALIAS: 'typealias';
OS: 'os';
ARCH: 'arch';
SWIFT: 'swift';
COMPILER: 'compiler';
CAN_IMPORT: 'canImport';
TARGET_ENVIRONMENT: 'targetEnvironment';
CONVENIENCE: 'convenience';
DYNAMIC: 'dynamic';
LAZY: 'lazy';
OPTIONAL: 'optional';
OVERRIDE: 'override';
REQUIRED: 'required';
STATIC: 'static';
WEAK: 'weak';
UNOWNED: 'unowned';
SAFE: 'safe';
UNSAFE: 'unsafe';
MUTATING: 'mutating';
NONMUTATING: 'nonmutating';
FILE_PRIVATE: 'fileprivate';
IS: 'is';
TRY: 'try';
SUPER: 'super';
ANY: 'Any';
FALSE: 'false';
RED: 'red';
BLUE: 'blue';
GREEN: 'green';
RESOURCE_NAME: 'resourceName';
TRUE: 'true';
NIL: 'nil';
INOUT: 'inout';
SOME: 'some';
TYPE: 'Type';
PRECEDENCE: 'precedence';
SELF: 'self';
SELF_BIG: 'Self';
MAC_OS: 'macOS';
I_OS: 'iOS';
OSX: 'OSX';
WATCH_OS: 'watchOS';
TV_OS: 'tvOS';
LINUX: 'Linux';
WINDOWS: 'Windows';
I386: 'i386';
X86_64: 'x86_64';
ARM: 'arm';
ARM64: 'arm64';
SIMULATOR: 'simulator';
MAC_CATALYST: 'macCatalyst';
I_OS_APPLICATION_EXTENSION: 'iOSApplicationExtension';
MAC_CATALYST_APPLICATION_EXTENSION:
'macCatalystApplicationExtension';
MAC_OS_APPLICATION_EXTENSION: 'macOSApplicationExtension';
SOURCE_LOCATION: '#sourceLocation';
FILE: 'file';
LINE: 'line';
ERROR: '#error';
WARNING: '#warning';
AVAILABLE: '#available';
HASH_IF: '#if';
HASH_ELSEIF: '#elseif';
HASH_ELSE: '#else';
HASH_ENDIF: '#endif';
HASH_FILE: '#file';
HASH_FILE_ID: '#fileID';
HASH_FILE_PATH: '#filePath';
HASH_LINE: '#line';
HASH_COLUMN: '#column';
HASH_FUNCTION: '#function';
HASH_DSO_HANDLE: '#dsohandle';
HASH_SELECTOR: '#selector';
HASH_KEYPATH: '#keyPath';
HASH_COLOR_LITERAL: '#colorLiteral';
HASH_FILE_LITERAL: '#fileLiteral';
HASH_IMAGE_LITERAL: '#imageLiteral';
GETTER: 'getter';
SETTER: 'setter';
Identifier:
Identifier_head Identifier_characters?
| Implicit_parameter_name
| Property_wrapper_projection;
fragment Identifier_head:
[a-zA-Z]
| '_'
| '\u00A8'
| '\u00AA'
| '\u00AD'
| '\u00AF'
| [\u00B2-\u00B5]
| [\u00B7-\u00BA]
| [\u00BC-\u00BE]
| [\u00C0-\u00D6]
| [\u00D8-\u00F6]
| [\u00F8-\u00FF]
| [\u0100-\u02FF]
| [\u0370-\u167F]
| [\u1681-\u180D]
| [\u180F-\u1DBF]
| [\u1E00-\u1FFF]
| [\u200B-\u200D]
| [\u202A-\u202E]
| [\u203F-\u2040]
| '\u2054'
| [\u2060-\u206F]
| [\u2070-\u20CF]
| [\u2100-\u218F]
| [\u2460-\u24FF]
| [\u2776-\u2793]
| [\u2C00-\u2DFF]
| [\u2E80-\u2FFF]
| [\u3004-\u3007]
| [\u3021-\u302F]
| [\u3031-\u303F]
| [\u3040-\uD7FF]
| [\uF900-\uFD3D]
| [\uFD40-\uFDCF]
| [\uFDF0-\uFE1F]
| [\uFE30-\uFE44]
| [\uFE47-\uFFFD]
| [\u{10000}-\u{1FFFD}]
| [\u{20000}-\u{2FFFD}]
| [\u{30000}-\u{3FFFD}]
| [\u{40000}-\u{4FFFD}]
| [\u{50000}-\u{5FFFD}]
| [\u{60000}-\u{6FFFD}]
| [\u{70000}-\u{7FFFD}]
| [\u{80000}-\u{8FFFD}]
| [\u{90000}-\u{9FFFD}]
| [\u{A0000}-\u{AFFFD}]
| [\u{B0000}-\u{BFFFD}]
| [\u{C0000}-\u{CFFFD}]
| [\u{D0000}-\u{DFFFD}]
| [\u{E0000}-\u{EFFFD}];
fragment Identifier_character:
[0-9]
| [\u0300-\u036F]
| [\u1DC0-\u1DFF]
| [\u20D0-\u20FF]
| [\uFE20-\uFE2F]
| Identifier_head;
fragment Identifier_characters: Identifier_character+;
fragment Implicit_parameter_name: '$' Decimal_digits;
fragment Property_wrapper_projection: '$' Identifier_characters;
DOT: '.';
LCURLY: '{';
LPAREN:
'(' { if(!parenthesis.isEmpty()) parenthesis.push(parenthesis.pop()+1);};
LBRACK: '[';
RCURLY: '}';
RPAREN:
')' { if(!parenthesis.isEmpty())
{
parenthesis.push(parenthesis.pop()-1);
if(parenthesis.peek() == 0)
{
parenthesis.pop();
popMode();
}
}
};
RBRACK: ']';
COMMA: ',';
COLON: ':';
SEMI: ';';
LT: '<';
GT: '>';
UNDERSCORE: '_';
BANG: '!';
QUESTION: '?';
AT: '@';
AND: '&';
SUB: '-';
EQUAL: '=';
OR: '|';
DIV: '/';
ADD: '+';
MUL: '*';
MOD: '%';
CARET: '^';
TILDE: '~';
HASH: '#';
BACKTICK: '`';
DOLLAR: '$';
BACKSLASH: '\\';
Operator_head_other: // valid operator chars not used by Swift itself
[\u00A1-\u00A7]
| [\u00A9\u00AB]
| [\u00AC\u00AE]
| [\u00B0-\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7]
| [\u2016-\u2017\u2020-\u2027]
| [\u2030-\u203E]
| [\u2041-\u2053]
| [\u2055-\u205E]
| [\u2190-\u23FF]
| [\u2500-\u2775]
| [\u2794-\u2BFF]
| [\u2E00-\u2E7F]
| [\u3001-\u3003]
| [\u3008-\u3020\u3030];
Operator_following_character:
[\u0300-\u036F]
| [\u1DC0-\u1DFF]
| [\u20D0-\u20FF]
| [\uFE00-\uFE0F]
| [\uFE20-\uFE2F]
| [\u{E0100}-\u{E01EF}];
Binary_literal: '0b' Binary_digit Binary_literal_characters?;
fragment Binary_digit: [01];
fragment Binary_literal_character: Binary_digit | '_';
fragment Binary_literal_characters: Binary_literal_character+;
Octal_literal: '0o' Octal_digit Octal_literal_characters?;
fragment Octal_digit: [0-7];
fragment Octal_literal_character: Octal_digit | '_';
fragment Octal_literal_characters: Octal_literal_character+;
Decimal_digits: Decimal_digit+;
Decimal_literal: Decimal_digit Decimal_literal_characters?;
fragment Decimal_digit: [0-9];
fragment Decimal_literal_character: Decimal_digit | '_';
fragment Decimal_literal_characters: Decimal_literal_character+;
Hexadecimal_literal:
'0x' Hexadecimal_digit Hexadecimal_literal_characters?;
fragment Hexadecimal_digit: [0-9a-fA-F];
fragment Hexadecimal_literal_character: Hexadecimal_digit | '_';
fragment Hexadecimal_literal_characters:
Hexadecimal_literal_character+;
// Floating-Point Literals
Floating_point_literal:
Decimal_literal Decimal_fraction? Decimal_exponent?
| Hexadecimal_literal Hexadecimal_fraction? Hexadecimal_exponent;
fragment Decimal_fraction: '.' Decimal_literal;
fragment Decimal_exponent:
Floating_point_e Sign? Decimal_literal;
fragment Hexadecimal_fraction:
'.' Hexadecimal_digit Hexadecimal_literal_characters?;
fragment Hexadecimal_exponent:
Floating_point_p Sign? Decimal_literal;
fragment Floating_point_e: [eE];
fragment Floating_point_p: [pP];
fragment Sign: [+-];
WS: [ \n\r\t\u000B\u000C\u0000]+ -> channel(HIDDEN);
HASHBANG: '#!' .*? [\r\n]+ -> channel(HIDDEN);
Block_comment:
'/*' (Block_comment | .)*? '*/' -> channel(HIDDEN);
Line_comment: '//' .*? ('\n' | EOF) -> channel(HIDDEN);
Multi_line_extended_string_open:
'#'+ '"""' -> pushMode(MultiLineExtended);
Single_line_extended_string_open:
'#'+ '"' -> pushMode(SingleLineExtended);
Multi_line_string_open: '"""' -> pushMode(MultiLine);
Single_line_string_open: '"' -> pushMode(SingleLine);
mode SingleLine;
Interpolataion_single_line:
'\\(' { parenthesis.push(1);} -> pushMode(DEFAULT_MODE);
Single_line_string_close: '"' -> popMode;
Quoted_single_line_text: Quoted_text;
mode MultiLine;
Interpolataion_multi_line:
'\\(' {parenthesis.push(1); } -> pushMode(DEFAULT_MODE);
Multi_line_string_close: '"""' -> popMode;
Quoted_multi_line_text: Multiline_quoted_text;
mode SingleLineExtended;
Single_line_extended_string_close: '"' '#'+ -> popMode;
Quoted_single_line_extended_text: ~[\r\n"]+;
mode MultiLineExtended;
Multi_line_extended_string_close: '"""' '#'+ -> popMode;
Quoted_multi_line_extended_text: ~["]+ | '"' '"'?;
fragment Quoted_text: Quoted_text_item+;
fragment Quoted_text_item: Escaped_character | ~["\n\r\\];
fragment Multiline_quoted_text:
Escaped_character
| ~[\\"]+
| '"' '"'?
| Escaped_newline;
fragment Escape_sequence: '\\' '#'*;
fragment Escaped_character:
Escape_sequence (
[0\\tnr"'\u201c]
| 'u' '{' Unicode_scalar_digits '}'
);
//Between one and eight hexadecimal digits
fragment Unicode_scalar_digits:
Hexadecimal_digit Hexadecimal_digit? Hexadecimal_digit? Hexadecimal_digit? Hexadecimal_digit?
Hexadecimal_digit? Hexadecimal_digit? Hexadecimal_digit?;
fragment Escaped_newline:
Escape_sequence Inline_spaces? Line_break;
fragment Inline_spaces: [\u0009\u0020];
fragment Line_break: [\u000A\u000D]| '\u000D' '\u000A';
| 8,901 | ANTLR | .g4 | 359 | 23.233983 | 94 | 0.69325 | cjsoftware-plugin/Antlr4SyntaxRailroadDiagram | 0 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 74df841302f7ed7f380568dc01dfed2f02d3522a4792ccbec59752f33f4826f3 | true | false | false | false |
144 | Swift5Parser.g4 | cjsoftware-plugin_Antlr4SyntaxRailroadDiagram/src/test/resources/antlr_swift5/Swift5Parser.g4 | parser grammar Swift5Parser;
options {
tokenVocab = Swift5Lexer;
}
top_level: statements? EOF;
// Statements
statement:
(
loop_statement
| declaration
| branch_statement
| labeled_statement
| control_transfer_statement
| defer_statement
| do_statement
| expression
) SEMI?
| compiler_control_statement;
statements
locals[int indexBefore = -1]: (
{SwiftSupport.isSeparatedStatement(_input, $indexBefore)}? statement {$indexBefore = _input.index();
}
)+;
// Loop Statements
loop_statement:
for_in_statement
| while_statement
| repeat_while_statement;
// For-In Statement
for_in_statement:
FOR CASE? pattern IN expression where_clause? code_block;
// While Statement
while_statement: WHILE condition_list code_block;
condition_list: condition (COMMA condition)*;
condition:
availability_condition
| expression
| case_condition
| optional_binding_condition;
case_condition: CASE pattern initializer;
optional_binding_condition: (LET | VAR) pattern initializer;
// Repeat-While Statement
repeat_while_statement: REPEAT code_block WHILE expression;
// Branch Statements
branch_statement:
if_statement
| guard_statement
| switch_statement;
// If Statement
if_statement: IF condition_list code_block else_clause?;
else_clause: ELSE code_block | ELSE if_statement;
// Guard Statement
guard_statement: GUARD condition_list ELSE code_block;
// Switch Statement
switch_statement: SWITCH expression LCURLY switch_cases? RCURLY;
switch_cases: switch_case switch_cases?;
switch_case: (case_label | default_label) statements
| conditional_switch_case;
case_label: attributes? CASE case_item_list COLON;
case_item_list:
pattern where_clause? (COMMA pattern where_clause?)*;
default_label: attributes? DEFAULT COLON;
where_clause: WHERE where_expression;
where_expression: expression;
conditional_switch_case:
switch_if_directive_clause switch_elseif_directive_clauses? switch_else_directive_clause?
HASH_ENDIF;
switch_if_directive_clause:
HASH_IF compilation_condition switch_cases?;
switch_elseif_directive_clauses:
elseif_directive_clause switch_elseif_directive_clauses?;
switch_elseif_directive_clause:
HASH_ELSEIF compilation_condition switch_cases?;
switch_else_directive_clause: HASH_ELSE switch_cases?;
// Labeled Statement
labeled_statement:
statement_label (
loop_statement
| if_statement
| switch_statement
| do_statement
);
statement_label: label_name COLON;
label_name: identifier;
// Control Transfer Statements
control_transfer_statement:
break_statement
| continue_statement
| fallthrough_statement
| return_statement
| throw_statement;
// Break Statement
break_statement: BREAK label_name?;
// Continue Statement
continue_statement: CONTINUE label_name?;
// Fallthrough Statement
fallthrough_statement: FALLTHROUGH;
// Return Statement
return_statement: RETURN expression?;
// Throw Statement
throw_statement: THROW expression;
// Defer Statement
defer_statement: DEFER code_block;
// Do Statement
do_statement: DO code_block catch_clauses?;
catch_clauses: catch_clause+;
catch_clause: CATCH catch_pattern_list? code_block;
catch_pattern_list:
catch_pattern (catch_pattern COMMA catch_pattern)*;
catch_pattern: pattern where_clause?;
// Compiler Control Statements
compiler_control_statement:
conditional_compilation_block
| line_control_statement
| diagnostic_statement;
// Conditional Compilation Block
conditional_compilation_block:
if_directive_clause elseif_directive_clauses? else_directive_clause? HASH_ENDIF;
if_directive_clause: HASH_IF compilation_condition statements?;
elseif_directive_clauses: elseif_directive_clause+;
elseif_directive_clause:
HASH_ELSEIF compilation_condition statements?;
else_directive_clause: HASH_ELSE statements?;
compilation_condition:
platform_condition
| identifier
| boolean_literal
| LPAREN compilation_condition RPAREN
| BANG compilation_condition
| compilation_condition (
compilation_condition_AND
| compilation_condition_OR
) compilation_condition;
platform_condition:
OS LPAREN operating_system RPAREN
| ARCH LPAREN architecture RPAREN
| (SWIFT | COMPILER) LPAREN (
compilation_condition_GE
| compilation_condition_L
) swift_version RPAREN
| CAN_IMPORT LPAREN module_name RPAREN
| TARGET_ENVIRONMENT LPAREN environment RPAREN;
swift_version: Decimal_digits swift_version_continuation?;
swift_version_continuation:
DOT Decimal_digits swift_version_continuation?;
operating_system:
MAC_OS
| I_OS
| OSX
| WATCH_OS
| TV_OS
| LINUX
| WINDOWS;
architecture: I386 | X86_64 | ARM | ARM64;
module_name: identifier (DOT identifier)*;
environment: SIMULATOR | MAC_CATALYST;
// Line Control Statement
line_control_statement:
SOURCE_LOCATION LPAREN (
FILE COLON file_name COMMA LINE COLON line_number
)? RPAREN;
line_number:
Decimal_literal; // TODO: A decimal integer greater than zero
file_name: static_string_literal;
// Compile-Time Diagnostic Statement
diagnostic_statement: (ERROR | WARNING) LPAREN diagnostic_message RPAREN;
diagnostic_message: static_string_literal;
// Availability Condition
availability_condition:
AVAILABLE LPAREN availability_arguments RPAREN;
availability_arguments:
availability_argument (COMMA availability_argument)*;
availability_argument: platform_name platform_version | MUL;
platform_name:
I_OS
| OSX
| I_OS_APPLICATION_EXTENSION
| MAC_OS
| MAC_OS_APPLICATION_EXTENSION
| MAC_CATALYST
| MAC_CATALYST_APPLICATION_EXTENSION
| WATCH_OS
| TV_OS;
platform_version:
Decimal_literal
| Decimal_digits
| Floating_point_literal (DOT Decimal_digits)?;
// Generic Parameter Clause
generic_parameter_clause: LT generic_parameter_list GT;
generic_parameter_list:
generic_parameter (COMMA generic_parameter)*;
generic_parameter:
type_name (
COLON (type_identifier | protocol_composition_type)
)?;
generic_where_clause: WHERE requirement_list;
requirement_list: requirement (COMMA requirement)*;
requirement: conformance_requirement | same_type_requirement;
conformance_requirement:
type_identifier COLON (
type_identifier
| protocol_composition_type
);
same_type_requirement:
type_identifier same_type_equals (type_identifier | type);
// Generic Argument Clause
generic_argument_clause: LT generic_argument_list GT;
generic_argument_list:
generic_argument (COMMA generic_argument)*;
generic_argument: type;
// Declarations
declaration:
(
import_declaration
| constant_declaration
| variable_declaration
| typealias_declaration
| function_declaration
| enum_declaration
| struct_declaration
| class_declaration
| protocol_declaration
| initializer_declaration
| deinitializer_declaration
| extension_declaration
| subscript_declaration
| operator_declaration
| precedence_group_declaration
) SEMI?;
declarations: declaration+;
// Top-Level Code
top_level_declaration: statements?;
// Code Blocks
code_block: LCURLY statements? RCURLY;
// Import Declaration
import_declaration: attributes? IMPORT import_kind? import_path;
import_kind:
TYPEALIAS
| STRUCT
| CLASS
| ENUM
| PROTOCOL
| LET
| VAR
| FUNC;
import_path:
import_path_identifier (DOT import_path_identifier)*;
import_path_identifier: identifier | operator;
// Constant Declaration
constant_declaration:
attributes? declaration_modifiers? LET pattern_initializer_list;
pattern_initializer_list:
pattern_initializer (COMMA pattern_initializer)*;
pattern_initializer: pattern initializer?;
initializer: EQUAL expression;
// Variable Declaration
variable_declaration:
variable_declaration_head (
variable_name (
initializer willSet_didSet_block
| type_annotation (
getter_setter_block // contains code_block
| getter_setter_keyword_block
| initializer? willSet_didSet_block
)
)
| pattern_initializer_list
);
variable_declaration_head:
attributes? declaration_modifiers? VAR;
variable_name: identifier;
getter_setter_block:
LCURLY (
getter_clause setter_clause?
| setter_clause getter_clause
) RCURLY
| code_block;
getter_clause: attributes? mutation_modifier? GET code_block?;
setter_clause:
attributes? mutation_modifier? SET setter_name? code_block?;
setter_name: LPAREN identifier RPAREN;
getter_setter_keyword_block:
LCURLY (
getter_keyword_clause setter_keyword_clause?
| setter_keyword_clause getter_keyword_clause
) RCURLY;
getter_keyword_clause: attributes? mutation_modifier? GET;
setter_keyword_clause: attributes? mutation_modifier? SET;
willSet_didSet_block:
LCURLY (
willSet_clause didSet_clause?
| didSet_clause willSet_clause?
) RCURLY;
willSet_clause: attributes? WILL_SET setter_name? code_block;
didSet_clause: attributes? DID_SET setter_name? code_block;
// Type Alias Declaration
typealias_declaration:
attributes? access_level_modifier? TYPEALIAS typealias_name generic_parameter_clause?
typealias_assignment;
typealias_name: identifier;
typealias_assignment: EQUAL type;
// Function Declaration
function_declaration:
function_head function_name generic_parameter_clause? function_signature generic_where_clause?
function_body?;
function_head: attributes? declaration_modifiers? FUNC;
function_name: identifier | operator;
function_signature:
parameter_clause (THROWS? | RETHROWS) function_result?;
function_result: arrow_operator attributes? type;
function_body: code_block;
parameter_clause: LPAREN parameter_list? RPAREN;
parameter_list: parameter (COMMA parameter)*;
parameter:
attributes? external_parameter_name? local_parameter_name type_annotation (
default_argument_clause?
| range_operator
);
external_parameter_name: identifier;
local_parameter_name: identifier;
default_argument_clause: EQUAL expression;
// Enumeration Declaration
enum_declaration:
attributes? access_level_modifier? (
union_style_enum
| raw_value_style_enum
);
union_style_enum:
INDIRECT? ENUM enum_name generic_parameter_clause? type_inheritance_clause? generic_where_clause
? LCURLY union_style_enum_members? RCURLY;
union_style_enum_members: union_style_enum_member+;
union_style_enum_member:
declaration
| union_style_enum_case_clause
| compiler_control_statement;
union_style_enum_case_clause:
attributes? INDIRECT? CASE union_style_enum_case_list;
union_style_enum_case_list:
union_style_enum_case (COMMA union_style_enum_case)*;
union_style_enum_case:
opaque_type
| enum_case_name (tuple_type | LPAREN type RPAREN)?;
enum_name: identifier;
enum_case_name: identifier;
raw_value_style_enum:
ENUM enum_name generic_parameter_clause? type_inheritance_clause generic_where_clause? LCURLY
raw_value_style_enum_members RCURLY;
raw_value_style_enum_members: raw_value_style_enum_member+;
raw_value_style_enum_member:
declaration
| raw_value_style_enum_case_clause
| compiler_control_statement;
raw_value_style_enum_case_clause:
attributes? CASE raw_value_style_enum_case_list;
raw_value_style_enum_case_list:
raw_value_style_enum_case (COMMA raw_value_style_enum_case)*;
raw_value_style_enum_case: enum_case_name raw_value_assignment?;
raw_value_assignment: EQUAL raw_value_literal;
raw_value_literal:
numeric_literal
| static_string_literal
| boolean_literal;
// Structure Declaration
struct_declaration:
attributes? access_level_modifier? STRUCT struct_name generic_parameter_clause?
type_inheritance_clause? generic_where_clause? struct_body;
struct_name: identifier;
struct_body: LCURLY struct_members RCURLY;
struct_members: struct_member*;
struct_member: declaration | compiler_control_statement;
// Class Declaration
class_declaration:
attributes? (
access_level_modifier? FINAL?
| FINAL access_level_modifier?
) CLASS class_name generic_parameter_clause? type_inheritance_clause? generic_where_clause?
class_body;
class_name: identifier;
class_body: LCURLY class_members RCURLY;
class_members: class_member*;
class_member: declaration | compiler_control_statement;
// Protocol Declaration
protocol_declaration:
attributes? access_level_modifier? PROTOCOL protocol_name (
COLON CLASS
| type_inheritance_clause
)? generic_where_clause? protocol_body;
protocol_name: identifier;
protocol_body: LCURLY protocol_members RCURLY;
protocol_members: protocol_member*;
protocol_member:
protocol_member_declaration
| compiler_control_statement;
protocol_member_declaration:
protocol_property_declaration
| protocol_method_declaration
| protocol_initializer_declaration
| protocol_subscript_declaration
| protocol_associated_type_declaration
| typealias_declaration;
// Protocol Property Declaration
protocol_property_declaration:
variable_declaration_head variable_name type_annotation getter_setter_keyword_block;
// Protocol Method Declaration
protocol_method_declaration:
function_head function_name generic_parameter_clause? function_signature generic_where_clause?;
// Protocol Initializer Declaration
protocol_initializer_declaration:
initializer_head generic_parameter_clause? parameter_clause (
THROWS?
| RETHROWS
) generic_where_clause?;
// Protocol Subscript Declaration
protocol_subscript_declaration:
subscript_head subscript_result generic_where_clause? getter_setter_keyword_block;
// Protocol Associated Type Declaration
protocol_associated_type_declaration:
attributes? access_level_modifier? ASSOCIATED_TYPE typealias_name type_inheritance_clause?
typealias_assignment? generic_where_clause?;
// Initializer Declaration
initializer_declaration:
initializer_head generic_parameter_clause? parameter_clause (
THROWS
| RETHROWS
)? generic_where_clause? initializer_body;
initializer_head:
attributes? declaration_modifiers? INIT (QUESTION | BANG)?;
initializer_body: code_block;
// Deinitializer Declaration
deinitializer_declaration: attributes? DEINIT code_block;
// Extension Declaration
extension_declaration:
attributes? access_level_modifier? EXTENSION type_identifier type_inheritance_clause?
generic_where_clause? extension_body;
extension_body: LCURLY extension_members RCURLY;
extension_members: extension_member*;
extension_member: declaration | compiler_control_statement;
// Subscript Declaration
subscript_declaration:
subscript_head subscript_result generic_where_clause? (
code_block
| getter_setter_block
| getter_setter_keyword_block
);
subscript_head:
attributes? declaration_modifiers? SUBSCRIPT generic_parameter_clause? parameter_clause;
subscript_result: arrow_operator attributes? type;
// Operator Declaration
operator_declaration:
prefix_operator_declaration
| postfix_operator_declaration
| infix_operator_declaration;
prefix_operator_declaration: PREFIX OPERATOR operator;
postfix_operator_declaration: POSTFIX OPERATOR operator;
infix_operator_declaration:
INFIX OPERATOR operator infix_operator_group?;
infix_operator_group: COLON precedence_group_name;
// Precedence Group Declaration
precedence_group_declaration:
PRECEDENCE_GROUP precedence_group_name LCURLY precedence_group_attributes? RCURLY;
precedence_group_attributes: precedence_group_attribute+;
precedence_group_attribute:
precedence_group_relation
| precedence_group_assignment
| precedence_group_associativity;
precedence_group_relation:
(HIGHER_THAN | LOWER_THAN) COLON precedence_group_names;
precedence_group_assignment: ASSIGNMENT COLON boolean_literal;
precedence_group_associativity:
ASSOCIATIVITY COLON (LEFT | RIGHT | NONE);
precedence_group_names:
precedence_group_name (COMMA precedence_group_name)*;
precedence_group_name: identifier (DOT identifier)*;
// Declaration Modifiers
declaration_modifier:
CLASS
| CONVENIENCE
| DYNAMIC
| FINAL
| INFIX
| LAZY
| OPTIONAL
| OVERRIDE
| POSTFIX
| PREFIX
| REQUIRED
| STATIC
| UNOWNED (LPAREN (SAFE | UNSAFE) RPAREN)?
| WEAK
| access_level_modifier
| mutation_modifier;
declaration_modifiers: declaration_modifier+;
access_level_modifier:
(PRIVATE | FILE_PRIVATE | INTERNAL | PUBLIC | OPEN) (
LPAREN SET RPAREN
)?;
mutation_modifier: MUTATING | NONMUTATING;
// Patterns
//The following sets of rules are mutually left-recursive [pattern, Type-Casting], to avoid this they were integrated into the same rule.
pattern:
(wildcard_pattern | identifier_pattern | tuple_pattern) type_annotation?
| value_binding_pattern
| enum_case_pattern
| optional_pattern
| IS type
| pattern AS type
| expression_pattern;
// Wildcard Pattern
wildcard_pattern: UNDERSCORE;
// identifier Pattern
identifier_pattern: identifier;
// Value-Binding Pattern
value_binding_pattern: VAR pattern | LET pattern;
// Tuple Pattern
tuple_pattern: LPAREN tuple_pattern_element_list? RPAREN;
tuple_pattern_element_list:
tuple_pattern_element (COMMA tuple_pattern_element)*;
tuple_pattern_element: (identifier COLON)? pattern;
// Enumeration Case Pattern
enum_case_pattern:
type_identifier? DOT enum_case_name tuple_pattern?;
// Optional Pattern
optional_pattern: identifier_pattern QUESTION;
// Expression Pattern
expression_pattern: expression;
// Attributes
attribute: AT attribute_name attribute_argument_clause?;
attribute_name: identifier (DOT identifier)*;
attribute_argument_clause: LPAREN balanced_tokens? RPAREN;
attributes: attribute+;
balanced_tokens: balanced_token+;
balanced_token:
LPAREN balanced_tokens? RPAREN
| LBRACK balanced_tokens? RBRACK
| LCURLY balanced_tokens? RCURLY
//Any identifier, keyword, literal, or operator Any punctuation except (, ), [, ], {, or }
| identifier
| keyword
| literal
| operator
| balanced_token_punctuation;
balanced_token_punctuation:
(
DOT
| COMMA
| COLON
| SEMI
| EQUAL
| AT
| HASH
| BACKTICK
| QUESTION
)
| arrow_operator
| {SwiftSupport.isPrefixOp(_input)}? AND
| {SwiftSupport.isPostfixOp(_input)}? BANG;
// Expressions
expression: try_operator? prefix_expression binary_expressions?;
expression_list: expression (COMMA expression)*;
// Prefix Expressions
prefix_expression:
prefix_operator? postfix_expression
| in_out_expression;
in_out_expression: AND identifier;
// Try Operator
try_operator: TRY (QUESTION | BANG)?;
// Binary Expressions
binary_expression:
binary_operator prefix_expression
| (assignment_operator | conditional_operator) try_operator? prefix_expression
| type_casting_operator;
binary_expressions: binary_expression+;
// Conditional Operator
conditional_operator: QUESTION expression COLON;
// Ternary Conditional Operator
type_casting_operator: (IS | AS ( QUESTION | BANG)?) type;
// Primary Expressions
primary_expression:
unqualified_name generic_argument_clause?
| array_type
| dictionary_type
| literal_expression
| self_expression
| superclass_expression
| closure_expression
| parenthesized_operator
| parenthesized_expression
| tuple_expression
| implicit_member_expression
| wildcard_expression
| key_path_expression
| selector_expression
| key_path_string_expression;
unqualified_name: identifier (LPAREN argument_names RPAREN)?;
// Literal Expression
literal_expression:
literal
| array_literal
| dictionary_literal
| playground_literal
| HASH_FILE
| HASH_FILE_ID
| HASH_FILE_PATH
| HASH_LINE
| HASH_COLUMN
| HASH_FUNCTION
| HASH_DSO_HANDLE;
array_literal: LBRACK array_literal_items? RBRACK;
array_literal_items:
array_literal_item (COMMA array_literal_item)* COMMA?;
array_literal_item: expression;
dictionary_literal:
LBRACK (dictionary_literal_items | COLON) RBRACK;
dictionary_literal_items:
dictionary_literal_item (COMMA dictionary_literal_item)* COMMA?;
dictionary_literal_item: expression COLON expression;
playground_literal:
HASH_COLOR_LITERAL LPAREN RED COLON expression COMMA GREEN COLON expression COMMA BLUE COLON
expression COMMA ALPHA COLON expression RPAREN
| HASH_FILE_LITERAL LPAREN RESOURCE_NAME COLON expression RPAREN
| HASH_IMAGE_LITERAL LPAREN RESOURCE_NAME COLON expression RPAREN;
// Self Expression
self_expression:
SELF # self_pure_expression
| SELF DOT identifier # self_method_expression
| SELF LBRACK function_call_argument_list RBRACK # self_subscript_expression
| SELF DOT INIT # self_initializer_expression;
// Superclass Expression
superclass_expression:
SUPER DOT identifier # superclass_method_expression
| SUPER LBRACK function_call_argument_list RBRACK # superclass_subscript_expression
| SUPER DOT INIT # superclass_initializer_expression;
// Capture Lists
closure_expression:
LCURLY closure_signature? statements? RCURLY;
closure_signature:
capture_list? closure_parameter_clause THROWS? function_result? IN
| capture_list IN;
closure_parameter_clause:
LPAREN closure_parameter_list? RPAREN
| identifier_list;
closure_parameter_list:
closure_parameter (COMMA closure_parameter)*;
closure_parameter:
closure_parameter_name = identifier (
type_annotation range_operator?
)?;
capture_list: LBRACK capture_list_items RBRACK;
capture_list_items:
capture_list_item (COMMA capture_list_item)*;
capture_list_item:
capture_specifier? (
identifier EQUAL? expression
| self_expression
);
capture_specifier:
WEAK
| UNOWNED (LPAREN (SAFE | UNSAFE) RPAREN)?;
// Implicit Member Expression
implicit_member_expression:
DOT (identifier | keyword) (DOT postfix_expression)?;
// let a: MyType = .default; static let `default` = MyType()
// Parenthesized Expression
parenthesized_operator: LPAREN operator RPAREN;
// Parenthesized Expression
parenthesized_expression: LPAREN expression RPAREN;
// Tuple Expression
tuple_expression:
LPAREN RPAREN
| LPAREN tuple_element COMMA tuple_element_list RPAREN;
tuple_element_list: tuple_element (COMMA tuple_element)*;
tuple_element: (identifier COLON)? expression;
// Wildcard Expression
wildcard_expression: UNDERSCORE;
// Key-Path Expression
key_path_expression: BACKSLASH type? DOT key_path_components;
key_path_components:
key_path_component (DOT key_path_component)*;
key_path_component:
identifier key_path_postfixes?
| key_path_postfixes;
key_path_postfixes: key_path_postfix+;
key_path_postfix:
QUESTION
| BANG
| SELF
| LBRACK function_call_argument_list RBRACK;
// Selector Expression
selector_expression:
HASH_SELECTOR LPAREN ((GETTER | SETTER) COLON)? expression RPAREN;
// Key-Path String Expression
key_path_string_expression:
HASH_KEYPATH LPAREN expression RPAREN;
// Postfix Expressions
//The following sets of rules are mutually left-recursive [postfix_expression,
// function_call_expression, initializer_expression, explicit_member_expression,
// postfix_self_expression, subscript_expression, forced_value_expression,
// optional_chaining_expression], to avoid this the rule inner_postfix_expression was implemented.
/*postfix_expression:
postfix_expression postfix_operator | function_call_expression | initializer_expression |
explicit_member_expression | postfix_self_expression | subscript_expression |
forced_value_expression | optional_chaining_expression | primary_expression ;
*/
postfix_expression:
primary_expression (
function_call_suffix
| initializer_suffix
| explicit_member_suffix
| postfix_self_suffix
| subscript_suffix
| forced_value_suffix
| optional_chaining_suffix
)* postfix_operator*?;
function_call_suffix:
function_call_argument_clause? trailing_closures
| function_call_argument_clause;
initializer_suffix: DOT INIT (LPAREN argument_names RPAREN)?;
explicit_member_suffix:
DOT (
Decimal_digits
| identifier (
generic_argument_clause
| LPAREN argument_names RPAREN
)?
);
postfix_self_suffix: DOT SELF;
subscript_suffix: LBRACK function_call_argument_list RBRACK;
forced_value_suffix: {!SwiftSupport.isBinaryOp(_input)}? BANG;
optional_chaining_suffix:
{!SwiftSupport.isBinaryOp(_input)}? QUESTION;
// Function Call Expression
function_call_argument_clause:
LPAREN function_call_argument_list? RPAREN;
function_call_argument_list:
function_call_argument (COMMA function_call_argument)*;
function_call_argument:
argument_name? (
identifier /*optimization */
| expression
| operator
);
trailing_closures:
closure_expression labeled_trailing_closures?;
labeled_trailing_closures: labeled_trailing_closure+;
labeled_trailing_closure: identifier COLON closure_expression;
argument_names: argument_name+;
argument_name: identifier COLON;
// Types
// The following sets of rules are mutually left-recursive [type, optional_type, implicitly_unwrapped_optional_type, metatype_type], to avoid this they were integrated into the same rule.
type:
function_type
| array_type
| dictionary_type
| protocol_composition_type
| type_identifier
| tuple_type
| opaque_type
| type (
{!SwiftSupport.isBinaryOp(_input)}? QUESTION //optional_type
| {!SwiftSupport.isBinaryOp(_input)}? BANG //implicitly_unwrapped_optional_type
| DOT TYPE
| DOT PROTOCOL
) //metatype_type
| any_type
| self_type
| LPAREN type RPAREN;
// Type Annotation
type_annotation: COLON attributes? INOUT? type;
// Type identifier
type_identifier:
type_name generic_argument_clause? (DOT type_identifier)?;
type_name: identifier;
// Tuple Type
tuple_type: LPAREN tuple_type_element_list? RPAREN;
tuple_type_element_list:
tuple_type_element (COMMA tuple_type_element)*;
tuple_type_element:
(element_name type_annotation | type) (EQUAL expression)? /* assigning value */;
element_name:
identifier+; // TODO understand a specific thing - _
// Function Type
function_type:
attributes? function_type_argument_clause THROWS? arrow_operator type;
function_type_argument_clause:
LPAREN (function_type_argument_list range_operator?)? RPAREN;
function_type_argument_list:
function_type_argument (COMMA function_type_argument)*;
function_type_argument:
attributes? INOUT? type
| argument_label type_annotation;
argument_label:
identifier+; // TODO Understand a specific thing - _
// Array Type
array_type: LBRACK type RBRACK;
// Dictionary Type
dictionary_type: LBRACK type COLON type RBRACK;
// Protocol Composition Type
protocol_composition_type:
type_identifier (AND type_identifier)* trailing_composition_and?;
trailing_composition_and:
{!SwiftSupport.isBinaryOp(_input)}? AND;
// Opaque Type
opaque_type: SOME type;
// Any Type
any_type: ANY;
// Self Type
self_type: SELF_BIG;
// Type Inheritance Clause
type_inheritance_clause: COLON type_inheritance_list;
type_inheritance_list: type_identifier (COMMA type_identifier)*;
// Identifiers
identifier:
(
LINUX
| WINDOWS
| ALPHA
| ARCH
| ARM
| ARM64
| ASSIGNMENT
| BLUE
| CAN_IMPORT
| COMPILER
| FILE
| GREEN
| HIGHER_THAN
| I386
| I_OS
| OSX
| I_OS_APPLICATION_EXTENSION
| LINE
| LOWER_THAN
| MAC_CATALYST
| MAC_CATALYST_APPLICATION_EXTENSION
| MAC_OS
| MAC_OS_APPLICATION_EXTENSION
| OS
| PRECEDENCE_GROUP
| RED
| RESOURCE_NAME
| SAFE
| SIMULATOR
| SOME
| SWIFT
| TARGET_ENVIRONMENT
| TV_OS
| UNSAFE
| WATCH_OS
| X86_64
// Keywords reserved in particular contexts
| ASSOCIATIVITY
| CONVENIENCE
| DYNAMIC
| DID_SET
| FINAL
| GET
| INFIX
| INDIRECT
| LAZY
| LEFT
| MUTATING
| NONE
| NONMUTATING
| OPTIONAL
| OVERRIDE
| POSTFIX
| PRECEDENCE
| PREFIX
| PROTOCOL
| REQUIRED
| RIGHT
| SET
| TYPE
| UNOWNED
| WEAK
| WILL_SET
| IN
| FOR
| GUARD
| WHERE
| DEFAULT
| INTERNAL
| PRIVATE
| PUBLIC
| OPEN
| AS
| PREFIX
| POSTFIX
| WHILE
| SELF
| SELF_BIG
| SET
| CLASS
| GETTER
| SETTER
| OPERATOR
| DO
| CATCH
)
| Identifier
| BACKTICK (keyword | Identifier | DOLLAR) BACKTICK;
identifier_list: identifier (COMMA identifier)*;
// Keywords and Punctuation
keyword:
// Keywords used in declarations
ASSOCIATED_TYPE
| CLASS
| DEINIT
| ENUM
| EXTENSION
| FILE_PRIVATE
| FUNC
| IMPORT
| INIT
| INOUT
| INTERNAL
| LET
| OPEN
| OPERATOR
| PRIVATE
| PROTOCOL
| PUBLIC
| RETHROWS
| STATIC
| STRUCT
| SUBSCRIPT
| TYPEALIAS
| VAR
// Keywords used in statements
| BREAK
| CASE
| CONTINUE
| DEFAULT
| DEFER
| DO
| ELSE
| FALLTHROUGH
| FOR
| GUARD
| IF
| IN
| REPEAT
| RETURN
| SWITCH
| WHERE
| WHILE
// Keywords used in expressions and types
| AS
| ANY
| CATCH
| FALSE
| IS
| NIL
| SUPER
| SELF
| SELF_BIG
| THROW
| THROWS
| TRUE
| TRY
// Keywords used in patterns
| UNDERSCORE
// Keywords that begin with a number sign (#)
| AVAILABLE
| HASH_COLOR_LITERAL
| HASH_COLUMN
| HASH_ELSE
| HASH_ELSEIF
| HASH_ENDIF
| ERROR
| HASH_FILE
| HASH_FILE_ID
| HASH_FILE_LITERAL
| HASH_FILE_PATH
| HASH_FUNCTION
| HASH_IF
| HASH_IMAGE_LITERAL
| HASH_LINE
| HASH_SELECTOR
| SOURCE_LOCATION
| WARNING;
// Operators
// Assignment Operator
assignment_operator: {SwiftSupport.isBinaryOp(_input)}? EQUAL;
negate_prefix_operator: {SwiftSupport.isPrefixOp(_input)}? SUB;
compilation_condition_AND:
{SwiftSupport.isOperator(_input,"&&")}? AND AND;
compilation_condition_OR:
{SwiftSupport.isOperator(_input,"||")}? OR OR;
compilation_condition_GE:
{SwiftSupport.isOperator(_input,">=")}? GT EQUAL;
compilation_condition_L: {SwiftSupport.isOperator(_input,"<")}? LT;
arrow_operator: {SwiftSupport.isOperator(_input,"->")}? SUB GT;
range_operator: {SwiftSupport.isOperator(_input,"...")}? DOT DOT DOT;
same_type_equals:
{SwiftSupport.isOperator(_input,"==")}? EQUAL EQUAL;
binary_operator: {SwiftSupport.isBinaryOp(_input)}? operator;
prefix_operator: {SwiftSupport.isPrefixOp(_input)}? operator;
postfix_operator: {SwiftSupport.isPostfixOp(_input)}? operator;
operator:
operator_head operator_characters?
| dot_operator_head dot_operator_characters;
operator_head: (
DIV
| EQUAL
| SUB
| ADD
| BANG
| MUL
| MOD
| AND
| OR
| LT
| GT
| CARET
| TILDE
| QUESTION
) // wrapping in (..) makes it a fast set comparison
| Operator_head_other;
operator_character:
operator_head
| Operator_following_character;
operator_characters: (
{_input.get(_input.index()-1).getType()!=WS}? operator_character
)+;
dot_operator_head: DOT;
dot_operator_character: DOT | operator_character;
dot_operator_characters: (
{_input.get(_input.index()-1).getType()!=WS}? dot_operator_character
)+;
// Literals
literal:
numeric_literal
| string_literal
| boolean_literal
| nil_literal;
numeric_literal:
negate_prefix_operator? integer_literal
| negate_prefix_operator? Floating_point_literal;
boolean_literal: TRUE | FALSE;
nil_literal: NIL;
// Integer Literals
integer_literal:
Decimal_digits
| Decimal_literal
| Binary_literal
| Octal_literal
| Hexadecimal_literal;
// String Literals
string_literal:
extended_string_literal
| interpolated_string_literal
| static_string_literal;
extended_string_literal:
Multi_line_extended_string_open Quoted_multi_line_extended_text+
Multi_line_extended_string_close
| Single_line_extended_string_open Quoted_single_line_extended_text+
Single_line_extended_string_close;
static_string_literal:
Single_line_string_open Quoted_single_line_text* Single_line_string_close
| Multi_line_string_open Quoted_multi_line_text* Multi_line_string_close;
interpolated_string_literal:
Single_line_string_open (
Quoted_single_line_text
| Interpolataion_single_line (
expression
| tuple_element COMMA tuple_element_list
) RPAREN
)* Single_line_string_close
| Multi_line_string_open (
Quoted_multi_line_text
| Interpolataion_multi_line (
expression
| tuple_element COMMA tuple_element_list
) RPAREN
)* Multi_line_string_close; | 31,241 | ANTLR | .g4 | 1,076 | 26.995353 | 187 | 0.792371 | cjsoftware-plugin/Antlr4SyntaxRailroadDiagram | 0 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | e7f106938c449efc75a965efeca7eb3f73419d204e87b78987b50b948c84634e | false | false | false | false |
145 | TypeScriptParser.g4 | cjsoftware-plugin_Antlr4SyntaxRailroadDiagram/src/test/resources/antlr_typescript/TypeScriptParser.g4 | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 by Bart Kiers (original author) and Alexandre Vitorelli (contributor -> ported to CSharp)
* Copyright (c) 2017 by Ivan Kochurkin (Positive Technologies):
added ECMAScript 6 support, cleared and transformed to the universal grammar.
* Copyright (c) 2018 by Juan Alvarez (contributor -> ported to Go)
* Copyright (c) 2019 by Andrii Artiushok (contributor -> added TypeScript support)
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
parser grammar TypeScriptParser;
options {
tokenVocab=TypeScriptLexer;
superClass=TypeScriptParserBase;
}
// SupportSyntax
initializer
: '=' singleExpression
;
bindingPattern
: (arrayLiteral | objectLiteral)
;
// TypeScript SPart
// A.1 Types
typeParameters
: '<' typeParameterList? '>'
;
typeParameterList
: typeParameter (',' typeParameter)*
;
typeParameter
: Identifier constraint?
| typeParameters
;
constraint
: 'extends' type_
;
typeArguments
: '<' typeArgumentList? '>'
;
typeArgumentList
: typeArgument (',' typeArgument)*
;
typeArgument
: type_
;
type_
: unionOrIntersectionOrPrimaryType
| functionType
| constructorType
| typeGeneric
| StringLiteral
;
unionOrIntersectionOrPrimaryType
: unionOrIntersectionOrPrimaryType '|' unionOrIntersectionOrPrimaryType #Union
| unionOrIntersectionOrPrimaryType '&' unionOrIntersectionOrPrimaryType #Intersection
| primaryType #Primary
;
primaryType
: '(' type_ ')' #ParenthesizedPrimType
| predefinedType #PredefinedPrimType
| typeReference #ReferencePrimType
| objectType #ObjectPrimType
| primaryType {notLineTerminator()}? '[' ']' #ArrayPrimType
| '[' tupleElementTypes ']' #TuplePrimType
| typeQuery #QueryPrimType
| This #ThisPrimType
| typeReference Is primaryType #RedefinitionOfType
;
predefinedType
: Any
| Number
| Boolean
| String
| Symbol
| Void
;
typeReference
: typeName nestedTypeGeneric?
;
nestedTypeGeneric
: typeIncludeGeneric
| typeGeneric
;
// I tried recursive include, but it's not working.
// typeGeneric
// : '<' typeArgumentList typeGeneric?'>'
// ;
//
// TODO: Fix recursive
//
typeGeneric
: '<' typeArgumentList '>'
;
typeIncludeGeneric
:'<' typeArgumentList '<' typeArgumentList ('>' bindingPattern '>' | '>>')
;
typeName
: Identifier
| namespaceName
;
objectType
: '{' typeBody? '}'
;
typeBody
: typeMemberList (SemiColon | ',')?
;
typeMemberList
: typeMember ((SemiColon | ',') typeMember)*
;
typeMember
: propertySignatur
| callSignature
| constructSignature
| indexSignature
| methodSignature ('=>' type_)?
;
arrayType
: primaryType {notLineTerminator()}? '[' ']'
;
tupleType
: '[' tupleElementTypes ']'
;
tupleElementTypes
: type_ (',' type_)*
;
functionType
: typeParameters? '(' parameterList? ')' '=>' type_
;
constructorType
: 'new' typeParameters? '(' parameterList? ')' '=>' type_
;
typeQuery
: 'typeof' typeQueryExpression
;
typeQueryExpression
: Identifier
| (identifierName '.')+ identifierName
;
propertySignatur
: ReadOnly? propertyName '?'? typeAnnotation? ('=>' type_)?
;
typeAnnotation
: ':' type_
;
callSignature
: typeParameters? '(' parameterList? ')' typeAnnotation?
;
parameterList
: restParameter
| parameter (',' parameter)* (',' restParameter)?
;
requiredParameterList
: requiredParameter (',' requiredParameter)*
;
parameter
: requiredParameter
| optionalParameter
;
optionalParameter
: decoratorList? ( accessibilityModifier? identifierOrPattern ('?' typeAnnotation? | typeAnnotation? initializer))
;
restParameter
: '...' singleExpression typeAnnotation?
;
requiredParameter
: decoratorList? accessibilityModifier? identifierOrPattern typeAnnotation?
;
accessibilityModifier
: Public
| Private
| Protected
;
identifierOrPattern
: identifierName
| bindingPattern
;
constructSignature
: 'new' typeParameters? '(' parameterList? ')' typeAnnotation?
;
indexSignature
: '[' Identifier ':' (Number|String) ']' typeAnnotation
;
methodSignature
: propertyName '?'? callSignature
;
typeAliasDeclaration
: 'type' Identifier typeParameters? '=' type_ SemiColon
;
constructorDeclaration
: accessibilityModifier? Constructor '(' formalParameterList? ')' ( ('{' functionBody '}') | SemiColon)?
;
// A.5 Interface
interfaceDeclaration
: Export? Declare? Interface Identifier typeParameters? interfaceExtendsClause? objectType SemiColon?
;
interfaceExtendsClause
: Extends classOrInterfaceTypeList
;
classOrInterfaceTypeList
: typeReference (',' typeReference)*
;
// A.7 Interface
enumDeclaration
: Const? Enum Identifier '{' enumBody? '}'
;
enumBody
: enumMemberList ','?
;
enumMemberList
: enumMember (',' enumMember)*
;
enumMember
: propertyName ('=' singleExpression)?
;
// A.8 Namespaces
namespaceDeclaration
: Namespace namespaceName '{' statementList? '}'
;
namespaceName
: Identifier ('.'+ Identifier)*
;
importAliasDeclaration
: Identifier '=' namespaceName SemiColon
;
// Ext.2 Additions to 1.8: Decorators
decoratorList
: decorator+ ;
decorator
: '@' (decoratorMemberExpression | decoratorCallExpression)
;
decoratorMemberExpression
: Identifier
| decoratorMemberExpression '.' identifierName
| '(' singleExpression ')'
;
decoratorCallExpression
: decoratorMemberExpression arguments;
// ECMAPart
program
: sourceElements? EOF
;
sourceElement
: Export? statement
;
statement
: block
| importStatement
| exportStatement
| emptyStatement_
| abstractDeclaration //ADDED
| decoratorList
| classDeclaration
| interfaceDeclaration //ADDED
| namespaceDeclaration //ADDED
| ifStatement
| iterationStatement
| continueStatement
| breakStatement
| returnStatement
| yieldStatement
| withStatement
| labelledStatement
| switchStatement
| throwStatement
| tryStatement
| debuggerStatement
| functionDeclaration
| arrowFunctionDeclaration
| generatorFunctionDeclaration
| variableStatement
| typeAliasDeclaration //ADDED
| enumDeclaration //ADDED
| expressionStatement
| Export statement
;
block
: '{' statementList? '}'
;
statementList
: statement+
;
abstractDeclaration
: Abstract (Identifier callSignature | variableStatement) eos
;
importStatement
: Import (fromBlock | importAliasDeclaration)
;
fromBlock
: (Multiply | multipleImportStatement) (As identifierName)? From StringLiteral eos
;
multipleImportStatement
: (identifierName ',')? '{' identifierName (',' identifierName)* '}'
;
exportStatement
: Export Default? (fromBlock | statement)
;
variableStatement
: bindingPattern typeAnnotation? initializer SemiColon?
| accessibilityModifier? varModifier? ReadOnly? variableDeclarationList SemiColon?
| Declare varModifier? variableDeclarationList SemiColon?
;
variableDeclarationList
: variableDeclaration (',' variableDeclaration)*
;
variableDeclaration
: ( identifierOrKeyWord | arrayLiteral | objectLiteral) typeAnnotation? singleExpression? ('=' typeParameters? singleExpression)? // ECMAScript 6: Array & Object Matching
;
emptyStatement_
: SemiColon
;
expressionStatement
: {this.notOpenBraceAndNotFunction()}? expressionSequence SemiColon?
;
ifStatement
: If '(' expressionSequence ')' statement (Else statement)?
;
iterationStatement
: Do statement While '(' expressionSequence ')' eos # DoStatement
| While '(' expressionSequence ')' statement # WhileStatement
| For '(' expressionSequence? SemiColon expressionSequence? SemiColon expressionSequence? ')' statement # ForStatement
| For '(' varModifier variableDeclarationList SemiColon expressionSequence? SemiColon expressionSequence? ')'
statement # ForVarStatement
| For '(' singleExpression (In | Identifier{this.p("of")}?) expressionSequence ')' statement # ForInStatement
| For '(' varModifier variableDeclaration (In | Identifier{this.p("of")}?) expressionSequence ')' statement # ForVarInStatement
;
varModifier
: Var
| Let
| Const
;
continueStatement
: Continue ({this.notLineTerminator()}? Identifier)? eos
;
breakStatement
: Break ({this.notLineTerminator()}? Identifier)? eos
;
returnStatement
: Return ({this.notLineTerminator()}? expressionSequence)? eos
;
yieldStatement
: Yield ({this.notLineTerminator()}? expressionSequence)? eos
;
withStatement
: With '(' expressionSequence ')' statement
;
switchStatement
: Switch '(' expressionSequence ')' caseBlock
;
caseBlock
: '{' caseClauses? (defaultClause caseClauses?)? '}'
;
caseClauses
: caseClause+
;
caseClause
: Case expressionSequence ':' statementList?
;
defaultClause
: Default ':' statementList?
;
labelledStatement
: Identifier ':' statement
;
throwStatement
: Throw {this.notLineTerminator()}? expressionSequence eos
;
tryStatement
: Try block (catchProduction finallyProduction? | finallyProduction)
;
catchProduction
: Catch '(' Identifier ')' block
;
finallyProduction
: Finally block
;
debuggerStatement
: Debugger eos
;
functionDeclaration
: Function_ Identifier callSignature ( ('{' functionBody '}') | SemiColon)
;
//Ovveride ECMA
classDeclaration
: Abstract? Class Identifier typeParameters? classHeritage classTail
;
classHeritage
: classExtendsClause? implementsClause?
;
classTail
: '{' classElement* '}'
;
classExtendsClause
: Extends typeReference
;
implementsClause
: Implements classOrInterfaceTypeList
;
// Classes modified
classElement
: constructorDeclaration
| decoratorList? propertyMemberDeclaration
| indexMemberDeclaration
| statement
;
propertyMemberDeclaration
: propertyMemberBase propertyName '?'? typeAnnotation? initializer? SemiColon # PropertyDeclarationExpression
| propertyMemberBase propertyName callSignature ( ('{' functionBody '}') | SemiColon) # MethodDeclarationExpression
| propertyMemberBase (getAccessor | setAccessor) # GetterSetterDeclarationExpression
| abstractDeclaration # AbstractMemberDeclaration
;
propertyMemberBase
: Async? accessibilityModifier? Static? ReadOnly?
;
indexMemberDeclaration
: indexSignature SemiColon
;
generatorMethod
: '*'? Identifier '(' formalParameterList? ')' '{' functionBody '}'
;
generatorFunctionDeclaration
: Function_ '*' Identifier? '(' formalParameterList? ')' '{' functionBody '}'
;
generatorBlock
: '{' generatorDefinition (',' generatorDefinition)* ','? '}'
;
generatorDefinition
: '*' iteratorDefinition
;
iteratorBlock
: '{' iteratorDefinition (',' iteratorDefinition)* ','? '}'
;
iteratorDefinition
: '[' singleExpression ']' '(' formalParameterList? ')' '{' functionBody '}'
;
formalParameterList
: formalParameterArg (',' formalParameterArg)* (',' lastFormalParameterArg)?
| lastFormalParameterArg
| arrayLiteral // ECMAScript 6: Parameter Context Matching
| objectLiteral (':' formalParameterList)? // ECMAScript 6: Parameter Context Matching
;
formalParameterArg
: decorator? accessibilityModifier? identifierOrKeyWord '?'? typeAnnotation? ('=' singleExpression)? // ECMAScript 6: Initialization
;
lastFormalParameterArg // ECMAScript 6: Rest Parameter
: Ellipsis Identifier
;
functionBody
: sourceElements?
;
sourceElements
: sourceElement+
;
arrayLiteral
: ('[' elementList? ']')
;
elementList
: arrayElement (','+ arrayElement)*
;
arrayElement // ECMAScript 6: Spread Operator
: Ellipsis? (singleExpression | Identifier) ','?
;
objectLiteral
: '{' (propertyAssignment (',' propertyAssignment)* ','?)? '}'
;
// MODIFIED
propertyAssignment
: propertyName (':' |'=') singleExpression # PropertyExpressionAssignment
| '[' singleExpression ']' ':' singleExpression # ComputedPropertyExpressionAssignment
| getAccessor # PropertyGetter
| setAccessor # PropertySetter
| generatorMethod # MethodProperty
| identifierOrKeyWord # PropertyShorthand
| restParameter # RestParameterInObject
;
getAccessor
: getter '(' ')' typeAnnotation? '{' functionBody '}'
;
setAccessor
: setter '(' ( Identifier | bindingPattern) typeAnnotation? ')' '{' functionBody '}'
;
propertyName
: identifierName
| StringLiteral
| numericLiteral
;
arguments
: '(' (argumentList ','?)? ')'
;
argumentList
: argument (',' argument)*
;
argument // ECMAScript 6: Spread Operator
: Ellipsis? (singleExpression | Identifier)
;
expressionSequence
: singleExpression (',' singleExpression)*
;
functionExpressionDeclaration
: Function_ Identifier? '(' formalParameterList? ')' typeAnnotation? '{' functionBody '}'
;
singleExpression
: functionExpressionDeclaration # FunctionExpression
| arrowFunctionDeclaration # ArrowFunctionExpression // ECMAScript 6
| Class Identifier? classTail # ClassExpression
| singleExpression '[' expressionSequence ']' # MemberIndexExpression
| singleExpression '.' identifierName nestedTypeGeneric? # MemberDotExpression
// Split to try `new Date()` first, then `new Date`.
| New singleExpression typeArguments? arguments # NewExpression
| New singleExpression typeArguments? # NewExpression
| singleExpression arguments # ArgumentsExpression
| singleExpression {this.notLineTerminator()}? '++' # PostIncrementExpression
| singleExpression {this.notLineTerminator()}? '--' # PostDecreaseExpression
| Delete singleExpression # DeleteExpression
| Void singleExpression # VoidExpression
| Typeof singleExpression # TypeofExpression
| '++' singleExpression # PreIncrementExpression
| '--' singleExpression # PreDecreaseExpression
| '+' singleExpression # UnaryPlusExpression
| '-' singleExpression # UnaryMinusExpression
| '~' singleExpression # BitNotExpression
| '!' singleExpression # NotExpression
| singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression
| singleExpression ('+' | '-') singleExpression # AdditiveExpression
| singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression
| singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression
| singleExpression Instanceof singleExpression # InstanceofExpression
| singleExpression In singleExpression # InExpression
| singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression
| singleExpression '&' singleExpression # BitAndExpression
| singleExpression '^' singleExpression # BitXOrExpression
| singleExpression '|' singleExpression # BitOrExpression
| singleExpression '&&' singleExpression # LogicalAndExpression
| singleExpression '||' singleExpression # LogicalOrExpression
| singleExpression '?' singleExpression ':' singleExpression # TernaryExpression
| singleExpression '=' singleExpression # AssignmentExpression
| singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression
| singleExpression templateStringLiteral # TemplateStringExpression // ECMAScript 6
| iteratorBlock # IteratorsExpression // ECMAScript 6
| generatorBlock # GeneratorsExpression // ECMAScript 6
| generatorFunctionDeclaration # GeneratorsFunctionExpression // ECMAScript 6
| yieldStatement # YieldExpression // ECMAScript 6
| This # ThisExpression
| identifierName singleExpression? # IdentifierExpression
| Super # SuperExpression
| literal # LiteralExpression
| arrayLiteral # ArrayLiteralExpression
| objectLiteral # ObjectLiteralExpression
| '(' expressionSequence ')' # ParenthesizedExpression
| typeArguments expressionSequence? # GenericTypes
| singleExpression As asExpression # CastAsExpression
;
asExpression
: predefinedType ('[' ']')?
| singleExpression
;
arrowFunctionDeclaration
: Async? arrowFunctionParameters typeAnnotation? '=>' arrowFunctionBody
;
arrowFunctionParameters
: Identifier
| '(' formalParameterList? ')'
;
arrowFunctionBody
: singleExpression
| '{' functionBody '}'
;
assignmentOperator
: '*='
| '/='
| '%='
| '+='
| '-='
| '<<='
| '>>='
| '>>>='
| '&='
| '^='
| '|='
;
literal
: NullLiteral
| BooleanLiteral
| StringLiteral
| templateStringLiteral
| RegularExpressionLiteral
| numericLiteral
;
templateStringLiteral
: BackTick templateStringAtom* BackTick
;
templateStringAtom
: TemplateStringAtom
| TemplateStringStartExpression singleExpression TemplateCloseBrace
;
numericLiteral
: DecimalLiteral
| HexIntegerLiteral
| OctalIntegerLiteral
| OctalIntegerLiteral2
| BinaryIntegerLiteral
;
identifierName
: Identifier
| reservedWord
;
identifierOrKeyWord
: Identifier
| TypeAlias
| Require
;
reservedWord
: keyword
| NullLiteral
| BooleanLiteral
;
keyword
: Break
| Do
| Instanceof
| Typeof
| Case
| Else
| New
| Var
| Catch
| Finally
| Return
| Void
| Continue
| For
| Switch
| While
| Debugger
| Function_
| This
| With
| Default
| If
| Throw
| Delete
| In
| Try
| ReadOnly
| Async
| From
| Class
| Enum
| Extends
| Super
| Const
| Export
| Import
| Implements
| Let
| Private
| Public
| Interface
| Package
| Protected
| Static
| Yield
| Get
| Set
| Require
| TypeAlias
| String
;
getter
: Get propertyName
;
setter
: Set propertyName
;
eos
: SemiColon
| EOF
| {this.lineTerminatorAhead()}?
| {this.closeBrace()}?
; | 22,328 | ANTLR | .g4 | 700 | 27.741429 | 174 | 0.617405 | cjsoftware-plugin/Antlr4SyntaxRailroadDiagram | 0 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 53e8d64ec5a7d181463ad08e266e08c7494923744841631146a385884eb0a6d4 | true | false | false | false |
146 | TypeScriptLexer.g4 | cjsoftware-plugin_Antlr4SyntaxRailroadDiagram/src/test/resources/antlr_typescript/TypeScriptLexer.g4 | lexer grammar TypeScriptLexer;
channels { ERROR }
options {
superClass=TypeScriptLexerBase;
}
MultiLineComment: '/*' .*? '*/' -> channel(HIDDEN);
SingleLineComment: '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN);
RegularExpressionLiteral: '/' RegularExpressionFirstChar RegularExpressionChar* {this.IsRegexPossible()}? '/' IdentifierPart*;
OpenBracket: '[';
CloseBracket: ']';
OpenParen: '(';
CloseParen: ')';
OpenBrace: '{' {this.ProcessOpenBrace();};
TemplateCloseBrace: {this.IsInTemplateString()}? '}' -> popMode;
CloseBrace: '}' {this.ProcessCloseBrace();};
SemiColon: ';';
Comma: ',';
Assign: '=';
QuestionMark: '?';
Colon: ':';
Ellipsis: '...';
Dot: '.';
PlusPlus: '++';
MinusMinus: '--';
Plus: '+';
Minus: '-';
BitNot: '~';
Not: '!';
Multiply: '*';
Divide: '/';
Modulus: '%';
RightShiftArithmetic: '>>';
LeftShiftArithmetic: '<<';
RightShiftLogical: '>>>';
LessThan: '<';
MoreThan: '>';
LessThanEquals: '<=';
GreaterThanEquals: '>=';
Equals_: '==';
NotEquals: '!=';
IdentityEquals: '===';
IdentityNotEquals: '!==';
BitAnd: '&';
BitXOr: '^';
BitOr: '|';
And: '&&';
Or: '||';
MultiplyAssign: '*=';
DivideAssign: '/=';
ModulusAssign: '%=';
PlusAssign: '+=';
MinusAssign: '-=';
LeftShiftArithmeticAssign: '<<=';
RightShiftArithmeticAssign: '>>=';
RightShiftLogicalAssign: '>>>=';
BitAndAssign: '&=';
BitXorAssign: '^=';
BitOrAssign: '|=';
ARROW: '=>';
/// Null Literals
NullLiteral: 'null';
/// Boolean Literals
BooleanLiteral: 'true'
| 'false';
/// Numeric Literals
DecimalLiteral: DecimalIntegerLiteral '.' [0-9]* ExponentPart?
| '.' [0-9]+ ExponentPart?
| DecimalIntegerLiteral ExponentPart?
;
/// Numeric Literals
HexIntegerLiteral: '0' [xX] HexDigit+;
OctalIntegerLiteral: '0' [0-7]+ {!this.IsStrictMode()}?;
OctalIntegerLiteral2: '0' [oO] [0-7]+;
BinaryIntegerLiteral: '0' [bB] [01]+;
/// Keywords
Break: 'break';
Do: 'do';
Instanceof: 'instanceof';
Typeof: 'typeof';
Case: 'case';
Else: 'else';
New: 'new';
Var: 'var';
Catch: 'catch';
Finally: 'finally';
Return: 'return';
Void: 'void';
Continue: 'continue';
For: 'for';
Switch: 'switch';
While: 'while';
Debugger: 'debugger';
Function_: 'function';
This: 'this';
With: 'with';
Default: 'default';
If: 'if';
Throw: 'throw';
Delete: 'delete';
In: 'in';
Try: 'try';
As: 'as';
From: 'from';
ReadOnly: 'readonly';
Async: 'async';
/// Future Reserved Words
Class: 'class';
Enum: 'enum';
Extends: 'extends';
Super: 'super';
Const: 'const';
Export: 'export';
Import: 'import';
/// The following tokens are also considered to be FutureReservedWords
/// when parsing strict mode
Implements: 'implements' ;
Let: 'let' ;
Private: 'private' ;
Public: 'public' ;
Interface: 'interface' ;
Package: 'package' ;
Protected: 'protected' ;
Static: 'static' ;
Yield: 'yield' ;
//keywords:
Any : 'any';
Number: 'number';
Boolean: 'boolean';
String: 'string';
Symbol: 'symbol';
TypeAlias : 'type';
Get: 'get';
Set: 'set';
Constructor: 'constructor';
Namespace: 'namespace';
Require: 'require';
Module: 'module';
Declare: 'declare';
Abstract: 'abstract';
Is: 'is';
//
// Ext.2 Additions to 1.8: Decorators
//
At: '@';
/// Identifier Names and Identifiers
Identifier: IdentifierStart IdentifierPart*;
/// String Literals
StringLiteral: ('"' DoubleStringCharacter* '"'
| '\'' SingleStringCharacter* '\'') {this.ProcessStringLiteral();}
;
BackTick: '`' {this.IncreaseTemplateDepth();} -> pushMode(TEMPLATE);
WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN);
LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN);
/// Comments
HtmlComment: '<!--' .*? '-->' -> channel(HIDDEN);
CDataComment: '<![CDATA[' .*? ']]>' -> channel(HIDDEN);
UnexpectedCharacter: . -> channel(ERROR);
mode TEMPLATE;
BackTickInside: '`' {this.DecreaseTemplateDepth();} -> type(BackTick), popMode;
TemplateStringStartExpression: '${' -> pushMode(DEFAULT_MODE);
TemplateStringAtom: ~[`];
// Fragment rules
fragment DoubleStringCharacter
: ~["\\\r\n]
| '\\' EscapeSequence
| LineContinuation
;
fragment SingleStringCharacter
: ~['\\\r\n]
| '\\' EscapeSequence
| LineContinuation
;
fragment EscapeSequence
: CharacterEscapeSequence
| '0' // no digit ahead! TODO
| HexEscapeSequence
| UnicodeEscapeSequence
| ExtendedUnicodeEscapeSequence
;
fragment CharacterEscapeSequence
: SingleEscapeCharacter
| NonEscapeCharacter
;
fragment HexEscapeSequence
: 'x' HexDigit HexDigit
;
fragment UnicodeEscapeSequence
: 'u' HexDigit HexDigit HexDigit HexDigit
;
fragment ExtendedUnicodeEscapeSequence
: 'u' '{' HexDigit+ '}'
;
fragment SingleEscapeCharacter
: ['"\\bfnrtv]
;
fragment NonEscapeCharacter
: ~['"\\bfnrtv0-9xu\r\n]
;
fragment EscapeCharacter
: SingleEscapeCharacter
| [0-9]
| [xu]
;
fragment LineContinuation
: '\\' [\r\n\u2028\u2029]
;
fragment HexDigit
: [0-9a-fA-F]
;
fragment DecimalIntegerLiteral
: '0'
| [1-9] [0-9]*
;
fragment ExponentPart
: [eE] [+-]? [0-9]+
;
fragment IdentifierPart
: IdentifierStart
| [\p{Mn}]
| [\p{Nd}]
| [\p{Pc}]
| '\u200C'
| '\u200D'
;
fragment IdentifierStart
: [\p{L}]
| [$_]
| '\\' UnicodeEscapeSequence
;
fragment RegularExpressionFirstChar
: ~[*\r\n\u2028\u2029\\/[]
| RegularExpressionBackslashSequence
| '[' RegularExpressionClassChar* ']'
;
fragment RegularExpressionChar
: ~[\r\n\u2028\u2029\\/[]
| RegularExpressionBackslashSequence
| '[' RegularExpressionClassChar* ']'
;
fragment RegularExpressionClassChar
: ~[\r\n\u2028\u2029\]\\]
| RegularExpressionBackslashSequence
;
fragment RegularExpressionBackslashSequence
: '\\' ~[\r\n\u2028\u2029]
;
| 8,311 | ANTLR | .g4 | 246 | 31.146341 | 132 | 0.458021 | cjsoftware-plugin/Antlr4SyntaxRailroadDiagram | 0 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 9fc7f71d4228c828a9f4135b834a6c6511aa6f86a86968c6964235a6680272b2 | true | true | false | false |
147 | ANTLRv4Lexer.g4 | cjsoftware-plugin_Antlr4SyntaxRailroadDiagram/src/main/antlr/com/cjsoftware/antlr4docgen/parser/ANTLRv4Lexer.g4 | /*
* [The "BSD license"]
* Copyright (c) 2012-2015 Terence Parr
* Copyright (c) 2012-2015 Sam Harwell
* Copyright (c) 2015 Gerald Rosenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* A grammar for ANTLR v4 implemented using v4 syntax
*
* Modified 2015.06.16 gbr
* -- update for compatibility with Antlr v4.5
*/
// ======================================================
// Lexer specification
// ======================================================
lexer grammar ANTLRv4Lexer;
options { superClass = LexerAdaptor; }
import LexBasic;
// Standard set of fragments
tokens { TOKEN_REF , RULE_REF , LEXER_CHAR_SET }
channels { OFF_CHANNEL , COMMENT }
// -------------------------
// Comments
DOC_COMMENT
: DocComment -> channel (COMMENT)
;
BLOCK_COMMENT
: BlockComment -> channel (COMMENT)
;
LINE_COMMENT
: LineComment -> channel (COMMENT)
;
// -------------------------
// Integer
INT
: DecimalNumeral
;
// -------------------------
// Literal string
//
// ANTLR makes no distinction between a single character literal and a
// multi-character string. All literals are single quote delimited and
// may contain unicode escape sequences of the form \uxxxx, where x
// is a valid hexadecimal number (per Unicode standard).
STRING_LITERAL
: SQuoteLiteral
;
UNTERMINATED_STRING_LITERAL
: USQuoteLiteral
;
// -------------------------
// Arguments
//
// Certain argument lists, such as those specifying call parameters
// to a rule invocation, or input parameters to a rule specification
// are contained within square brackets.
BEGIN_ARGUMENT
: LBrack
{ this.handleBeginArgument(); }
;
// -------------------------
// Target Language Actions
BEGIN_ACTION
: LBrace -> pushMode (TargetLanguageAction)
;
// -------------------------
// Keywords
//
// 'options', 'tokens', and 'channels' are considered keywords
// but only when followed by '{', and considered as a single token.
// Otherwise, the symbols are tokenized as RULE_REF and allowed as
// an identifier in a labeledElement.
OPTIONS : 'options' WSNLCHARS* '{' ;
TOKENS : 'tokens' WSNLCHARS* '{' ;
CHANNELS : 'channels' WSNLCHARS* '{' ;
fragment WSNLCHARS : ' ' | '\t' | '\f' | '\n' | '\r' ;
IMPORT
: 'import'
;
FRAGMENT
: 'fragment'
;
LEXER
: 'lexer'
;
PARSER
: 'parser'
;
GRAMMAR
: 'grammar'
;
PROTECTED
: 'protected'
;
PUBLIC
: 'public'
;
PRIVATE
: 'private'
;
RETURNS
: 'returns'
;
LOCALS
: 'locals'
;
THROWS
: 'throws'
;
CATCH
: 'catch'
;
FINALLY
: 'finally'
;
MODE
: 'mode'
;
// -------------------------
// Punctuation
COLON
: Colon
;
COLONCOLON
: DColon
;
COMMA
: Comma
;
SEMI
: Semi
;
LPAREN
: LParen
;
RPAREN
: RParen
;
LBRACE
: LBrace
;
RBRACE
: RBrace
;
RARROW
: RArrow
;
LT
: Lt
;
GT
: Gt
;
ASSIGN
: Equal
;
QUESTION
: Question
;
STAR
: Star
;
PLUS_ASSIGN
: PlusAssign
;
PLUS
: Plus
;
OR
: Pipe
;
DOLLAR
: Dollar
;
RANGE
: Range
;
DOT
: Dot
;
AT
: At
;
POUND
: Pound
;
NOT
: Tilde
;
// -------------------------
// Identifiers - allows unicode rule/token names
ID
: Id
;
// -------------------------
// Whitespace
WS
: Ws+ -> channel (OFF_CHANNEL)
;
// -------------------------
// Illegal Characters
//
// This is an illegal character trap which is always the last rule in the
// lexer specification. It matches a single character of any value and being
// the last rule in the file will match when no other rule knows what to do
// about the character. It is reported as an error but is not passed on to the
// parser. This means that the parser to deal with the gramamr file anyway
// but we will not try to analyse or code generate from a file with lexical
// errors.
// Comment this rule out to allow the error to be propagated to the parser
ERRCHAR
: . -> channel (HIDDEN)
;
// ======================================================
// Lexer modes
// -------------------------
// Arguments
mode Argument;
// E.g., [int x, List<String> a[]]
NESTED_ARGUMENT
: LBrack -> type (ARGUMENT_CONTENT) , pushMode (Argument)
;
ARGUMENT_ESCAPE
: EscAny -> type (ARGUMENT_CONTENT)
;
ARGUMENT_STRING_LITERAL
: DQuoteLiteral -> type (ARGUMENT_CONTENT)
;
ARGUMENT_CHAR_LITERAL
: SQuoteLiteral -> type (ARGUMENT_CONTENT)
;
END_ARGUMENT
: RBrack
{ this.handleEndArgument(); }
;
// added this to return non-EOF token type here. EOF does something weird
UNTERMINATED_ARGUMENT
: EOF -> popMode
;
ARGUMENT_CONTENT
: .
;
// TODO: This grammar and the one used in the Intellij Antlr4 plugin differ
// for "actions". This needs to be resolved at some point.
// The Intellij Antlr4 grammar is here:
// https://github.com/antlr/intellij-plugin-v4/blob/1f36fde17f7fa63cb18d7eeb9cb213815ac658fb/src/main/antlr/org/antlr/intellij/plugin/parser/ANTLRv4Lexer.g4#L587
// -------------------------
// Target Language Actions
//
// Many language targets use {} as block delimiters and so we
// must recursively match {} delimited blocks to balance the
// braces. Additionally, we must make some assumptions about
// literal string representation in the target language. We assume
// that they are delimited by ' or " and so consume these
// in their own alts so as not to inadvertantly match {}.
mode TargetLanguageAction;
NESTED_ACTION
: LBrace -> type (ACTION_CONTENT) , pushMode (TargetLanguageAction)
;
ACTION_ESCAPE
: EscAny -> type (ACTION_CONTENT)
;
ACTION_STRING_LITERAL
: DQuoteLiteral -> type (ACTION_CONTENT)
;
ACTION_CHAR_LITERAL
: SQuoteLiteral -> type (ACTION_CONTENT)
;
ACTION_DOC_COMMENT
: DocComment -> type (ACTION_CONTENT)
;
ACTION_BLOCK_COMMENT
: BlockComment -> type (ACTION_CONTENT)
;
ACTION_LINE_COMMENT
: LineComment -> type (ACTION_CONTENT)
;
END_ACTION
: RBrace
{ this.handleEndAction(); }
;
UNTERMINATED_ACTION
: EOF -> popMode
;
ACTION_CONTENT
: .
;
// -------------------------
mode LexerCharSet;
LEXER_CHAR_SET_BODY
: (~ [\]\\] | EscAny)+ -> more
;
LEXER_CHAR_SET
: RBrack -> popMode
;
UNTERMINATED_CHAR_SET
: EOF -> popMode
;
// ------------------------------------------------------------------------------
// Grammar specific Keywords, Punctuation, etc.
fragment Id
: NameStartChar NameChar*
;
| 7,932 | ANTLR | .g4 | 327 | 21.553517 | 161 | 0.651602 | cjsoftware-plugin/Antlr4SyntaxRailroadDiagram | 0 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 6d291ccd3d5bc9f640bb5e18b821b92b95b361713c600b3032dead782e7387b4 | true | false | false | false |
148 | ANTLRv4Parser.g4 | cjsoftware-plugin_Antlr4SyntaxRailroadDiagram/src/main/antlr/com/cjsoftware/antlr4docgen/parser/ANTLRv4Parser.g4 | /*
* [The "BSD license"]
* Copyright (c) 2012-2014 Terence Parr
* Copyright (c) 2012-2014 Sam Harwell
* Copyright (c) 2015 Gerald Rosenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* A grammar for ANTLR v4 written in ANTLR v4.
*
* Modified 2015.06.16 gbr
* -- update for compatibility with Antlr v4.5
* -- add mode for channels
* -- moved members to LexerAdaptor
* -- move fragments to imports
*/
parser grammar ANTLRv4Parser;
options { tokenVocab = 'com/cjsoftware/antlr4docgen/parser/ANTLRv4Lexer'; }
// The main entry point for parsing a v4 grammar.
grammarSpec
: grammarDecl prequelConstruct* rules modeSpec* EOF
;
grammarDecl
: grammarType identifier SEMI
;
grammarType
: (LEXER GRAMMAR | PARSER GRAMMAR | GRAMMAR)
;
// This is the list of all constructs that can be declared before
// the set of rules that compose the grammar, and is invoked 0..n
// times by the grammarPrequel rule.
prequelConstruct
: optionsSpec
| delegateGrammars
| tokensSpec
| channelsSpec
| action_
;
// ------------
// Options - things that affect analysis and/or code generation
optionsSpec
: OPTIONS (option SEMI)* RBRACE
;
option
: identifier ASSIGN optionValue
;
optionValue
: identifier (DOT identifier)*
| STRING_LITERAL
| actionBlock
| INT
;
// ------------
// Delegates
delegateGrammars
: IMPORT delegateGrammar (COMMA delegateGrammar)* SEMI
;
delegateGrammar
: identifier ASSIGN identifier
| identifier
;
// ------------
// Tokens & Channels
tokensSpec
: TOKENS idList? RBRACE
;
channelsSpec
: CHANNELS idList? RBRACE
;
idList
: identifier (COMMA identifier)* COMMA?
;
// Match stuff like @parser::members {int i;}
action_
: AT (actionScopeName COLONCOLON)? identifier actionBlock
;
// Scope names could collide with keywords; allow them as ids for action scopes
actionScopeName
: identifier
| LEXER
| PARSER
;
actionBlock
: BEGIN_ACTION ACTION_CONTENT* END_ACTION
;
argActionBlock
: BEGIN_ARGUMENT ARGUMENT_CONTENT* END_ARGUMENT
;
modeSpec
: MODE identifier SEMI lexerRuleSpec*
;
rules
: ruleSpec*
;
ruleSpec
: parserRuleSpec
| lexerRuleSpec
;
parserRuleSpec
: ruleModifiers? RULE_REF argActionBlock? ruleReturns? throwsSpec? localsSpec? rulePrequel* COLON ruleBlock SEMI exceptionGroup
;
exceptionGroup
: exceptionHandler* finallyClause?
;
exceptionHandler
: CATCH argActionBlock actionBlock
;
finallyClause
: FINALLY actionBlock
;
rulePrequel
: optionsSpec
| ruleAction
;
ruleReturns
: RETURNS argActionBlock
;
// --------------
// Exception spec
throwsSpec
: THROWS identifier (COMMA identifier)*
;
localsSpec
: LOCALS argActionBlock
;
/** Match stuff like @init {int i;} */
ruleAction
: AT identifier actionBlock
;
ruleModifiers
: ruleModifier+
;
// An individual access modifier for a rule. The 'fragment' modifier
// is an internal indication for lexer rules that they do not match
// from the input but are like subroutines for other lexer rules to
// reuse for certain lexical patterns. The other modifiers are passed
// to the code generation templates and may be ignored by the template
// if they are of no use in that language.
ruleModifier
: PUBLIC
| PRIVATE
| PROTECTED
| FRAGMENT
;
ruleBlock
: ruleAltList
;
ruleAltList
: labeledAlt (OR labeledAlt)*
;
labeledAlt
: alternative (POUND identifier)?
;
// --------------------
// Lexer rules
lexerRuleSpec
: FRAGMENT? TOKEN_REF optionsSpec? COLON lexerRuleBlock SEMI
;
lexerRuleBlock
: lexerAltList
;
lexerAltList
: lexerAlt (OR lexerAlt)*
;
lexerAlt
: lexerElements lexerCommands?
|
// explicitly allow empty alts
;
lexerElements
: lexerElement+
|
;
lexerElement
: labeledLexerElement ebnfSuffix?
| lexerAtom ebnfSuffix?
| lexerBlock ebnfSuffix?
| actionBlock QUESTION?
;
// but preds can be anywhere
labeledLexerElement
: identifier (ASSIGN | PLUS_ASSIGN) (lexerAtom | lexerBlock)
;
lexerBlock
: LPAREN lexerAltList RPAREN
;
// E.g., channel(HIDDEN), skip, more, mode(INSIDE), push(INSIDE), pop
lexerCommands
: RARROW lexerCommand (COMMA lexerCommand)*
;
lexerCommand
: lexerCommandName LPAREN lexerCommandExpr RPAREN
| lexerCommandName
;
lexerCommandName
: identifier
| MODE
;
lexerCommandExpr
: identifier
| INT
;
// --------------------
// Rule Alts
altList
: alternative (OR alternative)*
;
alternative
: elementOptions? element+
|
// explicitly allow empty alts
;
element
: labeledElement (ebnfSuffix |)
| atom (ebnfSuffix |)
| ebnf
| actionBlock QUESTION?
;
labeledElement
: identifier (ASSIGN | PLUS_ASSIGN) (atom | block)
;
// --------------------
// EBNF and blocks
ebnf
: block blockSuffix?
;
blockSuffix
: ebnfSuffix
;
ebnfSuffix
: QUESTION QUESTION?
| STAR QUESTION?
| PLUS QUESTION?
;
lexerAtom
: characterRange
| terminal
| notSet
| LEXER_CHAR_SET
| DOT elementOptions?
;
atom
: terminal
| ruleref
| notSet
| DOT elementOptions?
;
// --------------------
// Inverted element set
notSet
: NOT setElement
| NOT blockSet
;
blockSet
: LPAREN setElement (OR setElement)* RPAREN
;
setElement
: TOKEN_REF elementOptions?
| STRING_LITERAL elementOptions?
| characterRange
| LEXER_CHAR_SET
;
// -------------
// Grammar Block
block
: LPAREN (optionsSpec? ruleAction* COLON)? altList RPAREN
;
// ----------------
// Parser rule ref
ruleref
: RULE_REF argActionBlock? elementOptions?
;
// ---------------
// Character Range
characterRange
: STRING_LITERAL RANGE STRING_LITERAL
;
terminal
: TOKEN_REF elementOptions?
| STRING_LITERAL elementOptions?
;
// Terminals may be adorned with certain options when
// reference in the grammar: TOK<,,,>
elementOptions
: LT elementOption (COMMA elementOption)* GT
;
elementOption
: identifier
| identifier ASSIGN (identifier | STRING_LITERAL)
;
identifier
: RULE_REF
| TOKEN_REF
;
| 7,670 | ANTLR | .g4 | 316 | 21.056962 | 130 | 0.710187 | cjsoftware-plugin/Antlr4SyntaxRailroadDiagram | 0 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 6c3f7e926fddf3efd357a17bcdf0fa288242a2057907b7704ad5c539694b5d5e | false | false | false | false |
149 | Common.g4 | baekhyunwook_test_fuzzyc/Common.g4 | grammar Common;
import ModuleLex, Action;
unary_operator : '&' | '*' | '+'| '-' | '~' | '!';
relational_operator: ('<'|'>'|'<='|'>=');
constant
: HEX_LITERAL
| OCTAL_LITERAL
| DECIMAL_LITERAL
| BINARY_LITERAL
| STRING
| MULTILINE_STRING
| CHAR
| FLOATING_POINT_LITERAL
;
// keywords & operators
function_decl_specifiers: ('inline' | 'virtual' | 'explicit' | 'friend' | 'static');
ptr_operator: ('*' | '&');
access_specifier: ('public' | 'private' | 'protected');
operator: (('new' | 'delete' ) ('[' ']')?)
| '+' | '-' | '*' | '/' | '%' |'^' | '&' | '|' | '~'
| '!' | '=' | '<' | '>' | '+=' | '-=' | '*='
| '/=' | '%=' | '^=' | '&=' | '|=' | '>>'
|'<<'| '>>=' | '<<=' | '==' | '!='
| '<=' | '>=' | '&&' | '||' | '++' | '--'
| ',' | '->*' | '->' | '(' ')' | '[' ']'
;
assignment_operator: '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|=';
equality_operator: ('=='| '!=');
// TODO: Does not support default types (e.g. template<typename N = int>). To achieve extend template_decl_param.
template_decl: TEMPLATE '<' template_decl_param_list? '>';
template_decl_param_list: template_template template_decl_keyword template_name |
template_decl_param |
template_decl_param_list ',' template_decl_param;
template_template: TEMPLATE '<' (template_decl_keyword ','?)+ '>';
template_decl_param: (template_decl_keyword | CV_QUALIFIER? identifier) template_name? ptr_operator?;
template_decl_keyword: 'typename' | 'class';
template_name: ALPHA_NUMERIC+ ELLIPSIS? ;
template_args: '<' template_args_param_list? '>';
template_args_param_list: template_args_param |
template_args_param_list ',' template_args_param;
template_args_param: CV_QUALIFIER? base_type ptr_operator?;
// water
no_brackets: ~('(' | ')');
no_brackets_curlies_or_squares: ~('(' | ')' | '{' | '}' | '[' | ']');
no_brackets_or_semicolon: ~('(' | ')' | ';');
no_angle_brackets_or_brackets : ~('<' | '>' | '(' | ')');
no_curlies: ~('{' | '}');
no_squares: ~('[' | ']');
no_squares_or_semicolon: ~('[' | ']' | ';');
no_comma_or_semicolon: ~(',' | ';');
assign_water: ~('(' | ')' | '{' | '}' | '[' | ']' | ';' | ',');
assign_water_l2: ~('(' | ')' | '{' | '}' | '[' | ']');
water: .;
// operator-identifiers not implemented
identifier : (ALPHA_NUMERIC ('::' ALPHA_NUMERIC)*) | access_specifier;
number: HEX_LITERAL | DECIMAL_LITERAL | OCTAL_LITERAL;
ptrs: (CV_QUALIFIER? ptr_operator 'restrict'?)+;
func_ptrs: ptrs;
rvalue_ref: '&&';
class_key: 'struct' | 'class' | 'union' | 'enum';
class_def: template_decl* class_key gcc_attribute? class_name? template_args? base_classes? OPENING_CURLY skip_to_end_of_object;
class_name: identifier;
base_classes: ':' base_class (',' base_class)*;
base_class: VIRTUAL? access_specifier? identifier template_args?;
type_name : (CV_QUALIFIER* (class_key | UNSIGNED | SIGNED)?
base_type template_args? ('::' base_type template_args? )*) CV_QUALIFIER?
| UNSIGNED
| SIGNED
;
base_type: ((ALPHA_NUMERIC | AUTO | VOID | LONG | LONG) ELLIPSIS?)+;
gcc_attribute: GCC_ATTRIBUTE '(' '(' identifier ')' ')';
expr: assign_expr (',' expr)?;
assign_expr: conditional_expression (assignment_operator assign_expr)?;
conditional_expression: or_expression #normOr
| or_expression ('?' expr ':' conditional_expression) #cndExpr;
or_expression : and_expression ('||' or_expression)?;
and_expression : inclusive_or_expression ('&&' and_expression)?;
inclusive_or_expression: exclusive_or_expression ('|' inclusive_or_expression)?;
exclusive_or_expression: bit_and_expression ('^' exclusive_or_expression)?;
bit_and_expression: equality_expression ('&' bit_and_expression)?;
equality_expression: relational_expression (equality_operator equality_expression)?;
relational_expression: shift_expression (relational_operator relational_expression)?;
shift_expression: additive_expression ( ('<<'|'>>') shift_expression)?;
additive_expression: multiplicative_expression (('+'| '-') additive_expression)?;
multiplicative_expression: cast_expression ( ('*'| '/'| '%') multiplicative_expression)?;
cpp_cast_identifier: 'const_cast' | 'static_cast' | 'dynamic_cast' | 'reinterpret_cast';
cast_expression: ('(' cast_target ')' cast_expression)
| cpp_cast_identifier '<' cast_target '>' '(' cast_expression ')'
| unary_expression
;
cast_target: type_name ptr_operator*;
unary_expression: inc_dec cast_expression
| unary_op_and_cast_expr
| sizeof_expression
| new_expression
| delete_expression
| postfix_expression
;
new_expression: '::'? NEW type_name '[' conditional_expression? ']'
| '::'? NEW type_name '(' expr? ')'
;
delete_expression: DELETE identifier |
DELETE '[' ']' identifier;
unary_op_and_cast_expr: unary_operator cast_expression;
sizeof_expression: sizeof sizeof_operand2
| sizeof '(' sizeof_operand2 ')'
| sizeof '(' sizeof_operand ')';
sizeof: 'sizeof';
sizeof_operand: type_name ptr_operator *;
sizeof_operand2: unary_expression;
inc_dec: ('--' | '++');
// this is a bit misleading. We're just allowing access_specifiers
// here because C programs can use 'public', 'protected' or 'private'
// as variable names.
postfix_expression: postfix_expression '[' expr ']' #arrayIndexing
| postfix_expression '(' function_argument_list ')' #funcCall
| postfix_expression '.' TEMPLATE? (identifier) #memberAccess
| postfix_expression '->' TEMPLATE? (identifier) #ptrMemberAccess
| postfix_expression inc_dec #incDecOp
| primary_expression # primaryOnly
;
function_argument_list: ( function_argument (',' function_argument)* )?;
function_argument: assign_expr;
primary_expression: identifier | constant | '(' expr ')';
| 6,052 | ANTLR | .g4 | 124 | 43.524194 | 128 | 0.597723 | baekhyunwook/test_fuzzyc | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 025be7b6ac133db2342c14bf463395f33b22ef4103fcadd9be23334d0a3aea40 | false | false | false | false |
150 | Action.g4 | baekhyunwook_test_fuzzyc/Action.g4 | // Grammar for C++ runtime actions
grammar Action;
import ModuleLex;
@header {
#include <stack>
}
@parser::members {
void skipToEndOfObject() {
std::stack<char> curly_stack;
int t = _input->LA(1);
while (t != antlr4::Token::EOF &&
!(curly_stack.empty() && t == CLOSING_CURLY)) {
if (t == PRE_ELSE) {
std::stack<char> if_def_stack;
consume();
t = _input->LA(1);
while (t != antlr4::Token::EOF &&
!(if_def_stack.empty() && (t == PRE_ENDIF))) {
if (t == PRE_IF) if_def_stack.push(0);
else if (t == PRE_ENDIF) if_def_stack.pop();
consume();
t = _input->LA(1);
}
}
if (t == OPENING_CURLY) curly_stack.push(0);
else if (t == CLOSING_CURLY) curly_stack.pop();
consume();
t = _input->LA(1);
}
if (t != antlr4::Token::EOF) consume();
}
void preProcSkipToEnd() {
std::stack<char> curly_stack;
int t = _input->LA(1);
while(t != antlr4::Token::EOF &&
!(curly_stack.empty() && t == PRE_ENDIF)){
if(t == PRE_IF) curly_stack.push(0);
else if(t == PRE_ENDIF) curly_stack.pop();
consume();
t = _input->LA(1);
}
if(t != antlr4::Token::EOF) consume();
}
}
skip_to_end_of_object: {skipToEndOfObject();};
pre_proc_skip_to_end: {preProcSkipToEnd();};
| 1,374 | ANTLR | .g4 | 46 | 23.543478 | 60 | 0.533384 | baekhyunwook/test_fuzzyc | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | fa5defe0144c2d08a3ba41a75fcd57eda713da131e4f0b808235b4973b86f78b | false | false | false | false |
151 | ModuleLex.g4 | baekhyunwook_test_fuzzyc/ModuleLex.g4 | lexer grammar ModuleLex;
// Keywords shared among C/C++/Java
IF: 'if'; ELSE: 'else'; FOR: 'for'; WHILE: 'while';
BREAK: 'break'; CASE: 'case'; CONTINUE: 'continue';
SWITCH: 'switch'; DO: 'do';
GOTO: 'goto'; RETURN: 'return';
TYPEDEF: 'typedef';
EXTERN: 'extern';
VOID: 'void'; UNSIGNED: 'unsigned'; SIGNED: 'signed';
LONG: 'long'; CV_QUALIFIER : 'const' | 'constexpr' | 'volatile';
// Keywords shared among C++/Java
VIRTUAL: 'virtual';
TRY: 'try'; CATCH: 'catch'; THROW: 'throw';
USING: 'using'; NAMESPACE: 'namespace';
// Keywords shared among C/C++
AUTO: 'auto'; REGISTER: 'register';
// C++ keywords
OPERATOR: 'operator';
TEMPLATE: 'template';
NEW: 'new';
DELETE: 'delete';
GCC_ATTRIBUTE : '__attribute__';
ALPHA_NUMERIC: [a-zA-Z_~][a-zA-Z0-9_]*;
OPENING_CURLY: '{';
CLOSING_CURLY: '}';
// pre-processor directives: C/C++
PRE_IF: ('#if' | '#ifdef' | '#ifndef') ~[\r\n]* '\r'? '\n';
PRE_ELSE: ('#else' | '#elif') ~[\r\n]* '\r'? '\n';
PRE_ENDIF: '#endif' ~[\r\n]* '\r'? '\n';
// PREPROC : '#' ~[\r\n]* '\r'? '\n' -> skip;
PRE_DEFINE: '#define' ~[\r\n]* '\r'? '\n' -> skip;
HEX_LITERAL : '0' ('x'|'X') HexDigit+ IntegerTypeSuffix? ;
DECIMAL_LITERAL : ('0' | '1'..'9' '0'..'9'*) IntegerTypeSuffix? ;
OCTAL_LITERAL : '0' ('0'..'7')+ IntegerTypeSuffix? ;
BINARY_LITERAL : '0b' ( '0' | '1')+ IntegerTypeSuffix? ;
FLOATING_POINT_LITERAL
: ('0'..'9')+ '.' ('0'..'9')* Exponent? FloatTypeSuffix?
| '.' ('0'..'9')+ Exponent? FloatTypeSuffix?
| ('0'..'9')+ Exponent FloatTypeSuffix?
| ('0'..'9')+ Exponent? FloatTypeSuffix
;
CHAR
: '\'' ( EscapeSequence | ~('\''|'\\') ) '\''
;
STRING
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
;
MULTILINE_STRING: STRING ((WHITESPACE | ALPHA_NUMERIC)* MULTILINE_STRING)?;
fragment
IntegerTypeSuffix
: ('u'|'U')? ('l'|'L')
| ('u'|'U') ('l'|'L')?
;
fragment
Exponent : ('e'|'E') ('+'|'-')? ('0'..'9')+;
fragment
FloatTypeSuffix : ('f'|'F'|'d'|'D');
fragment
EscapeSequence
: '\\' .
| UnicodeEscape
| OctalEscape
;
fragment
OctalEscape
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
| '\\' ('0'..'7') ('0'..'7')
| '\\' ('0'..'7')
;
fragment
UnicodeEscape
: '\\' 'u' HexDigit HexDigit HexDigit HexDigit
;
fragment
HexDigit : ('0'..'9'|'a'..'f'|'A'..'F') ;
COMMENT : '/*' (COMMENT|.)*? '*/' -> channel(HIDDEN) ;
LINE_COMMENT : '//' .*? ('\n'|EOF) -> channel(HIDDEN) ;
WHITESPACE : [ \r\t\u000C\n]+ -> skip
;
ELLIPSIS : '...';
OTHER : . -> skip ;
| 2,508 | ANTLR | .g4 | 81 | 28.506173 | 75 | 0.549979 | baekhyunwook/test_fuzzyc | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 1ce8c516ef9429ded2fc115542b92942bea271db06ad7678d180a4c75c6d2850 | true | true | false | false |
152 | Module.g4 | baekhyunwook_test_fuzzyc/Module.g4 | grammar Module;
import ModuleLex, Common;
/*
Copyright (C) 2013 Fabian 'fabs' Yamaguchi <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
code : (function_decl | function_def | simple_decl | using_directive | water)*;
using_directive: USING NAMESPACE identifier ';';
function_decl: ('extern'? | template_decl*) return_type? function_name function_param_list ctor_list? ';';
function_def: template_decl* return_type? function_name function_param_list ctor_list? compound_statement;
return_type : (function_decl_specifiers* type_name) ptr_operator*;
function_param_list : '(' parameter_decl_clause? ')' CV_QUALIFIER* exception_specification?;
parameter_decl_clause: (parameter_decl (',' parameter_decl)*) (',' '...')?
| VOID;
parameter_ptrs: ptrs | rvalue_ref;
parameter_decl: param_decl_specifiers parameter_id |
param_decl_specifiers parameter_ptrs?;
parameter_id: parameter_ptrs? ('(' parameter_id ')' | parameter_name) type_suffix? default_parameter_value?;
default_parameter_value: '=' expr;
compound_statement: OPENING_CURLY skip_to_end_of_object;
ctor_list: ':' ctor_initializer (',' ctor_initializer)*;
ctor_initializer: initializer_id ctor_expr;
initializer_id : '::'? identifier;
ctor_expr: '(' expr? ')';
function_name: '(' function_name ')' | identifier | OPERATOR operator;
exception_specification : THROW '(' type_id_list ')';
type_id_list: no_brackets* ('(' type_id_list ')' no_brackets*)*;
// The following two contain 'water'-rules for expressions
init_declarator : declarator (('(' expr? ')') | ('=' assign_expr_w_))?;
declarator: ptrs? identifier template_args? type_suffix? |
ptrs? '(' func_ptrs identifier ')' type_suffix;
type_suffix : ('[' constant_expr_w_ ']') | param_type_list;
// water rules for expressions
assign_expr_w_: assign_water*
(('{' assign_expr_w__l2 '}' | '(' assign_expr_w__l2 ')' | '[' assign_expr_w__l2 ']')
assign_water*)*;
assign_expr_w__l2: assign_water_l2* (('{' assign_expr_w__l2 '}' | '(' assign_expr_w__l2 ')' | '[' assign_expr_w__l2 ']')
assign_water_l2*)*;
constant_expr_w_: no_squares* ('[' constant_expr_w_ ']' no_squares*)*;
simple_decl : storage_class_specifier* var_decl;
storage_class_specifier: (EXTERN | TYPEDEF);
var_decl : class_def init_declarator_list? #declByClass
| template_decl* type_name init_declarator_list #declByType
;
init_declarator_list: init_declarator (',' init_declarator)* ';';
initializer: assign_expr
|'{' initializer_list '}'
;
initializer_list: initializer (',' initializer)*;
// Parameters
param_decl_specifiers : (AUTO | REGISTER)? type_name;
// this is a bit misleading. We're just allowing access_specifiers
// here because C programs can use 'public', 'protected' or 'private'
// as variable names.
parameter_name: identifier;
param_type_list: '(' VOID ')'
| '(' (param_type (',' param_type)*)? ')';
param_type: param_decl_specifiers param_type_id;
param_type_id: ptrs? ('(' param_type_id ')' | parameter_name?) type_suffix?;
| 3,705 | ANTLR | .g4 | 68 | 50.441176 | 120 | 0.692585 | baekhyunwook/test_fuzzyc | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | dfd9becc804302d753cb9e25d866891409436d580d25388981c1cb16899d7ab2 | false | false | false | false |
153 | Function.g4 | baekhyunwook_test_fuzzyc/Function.g4 | grammar Function;
import ModuleLex, Common;
statements: (pre_opener
| pre_closer
| pre_else pre_proc_skip_to_end
| statement)*;
statement: opening_curly
| closing_curly
| block_starter
| jump_statement
| label
| simple_decl
| expr_statement
| water
;
pre_opener: PRE_IF;
pre_else: PRE_ELSE;
pre_closer: PRE_ENDIF;
opening_curly: '{';
closing_curly: '}';
block_starter: selection_or_iteration;
selection_or_iteration: TRY #Try_statement
| CATCH '(' (param_type | ELLIPSIS) ')' #Catch_statement
| IF '(' condition ')' #If_statement
| ELSE #Else_statement
| SWITCH '(' condition ')' #Switch_statement
| FOR '(' (for_init_statement | ';') condition? ';' expr? ')' #For_statement
| DO #Do_statement
| WHILE '(' condition ')' #While_statement
;
// Don't know why, but: introducing this unused rule results
// in a performance boost.
do_statement1: DO statement WHILE '(' expr ')';
for_init_statement : simple_decl
| expr ';'
;
jump_statement: BREAK ';' #breakStatement
| CONTINUE ';' #continueStatement
| GOTO identifier ';' #gotoStatement
| RETURN expr? ';' #returnStatement
| THROW expr? ';' #throwStatement
;
label: CASE? (identifier | number | CHAR ) ':' ;
expr_statement: expr? ';';
condition: expr
| type_name declarator '=' assign_expr;
// Copied from FineSimpleDecl.g4
init_declarator: declarator '(' expr? ')' #initDeclWithCall
| declarator '=' initializer #initDeclWithAssign
| declarator #initDeclSimple
;
declarator: ptrs? identifier template_args? type_suffix? |
ptrs? '(' func_ptrs identifier ')' type_suffix;
type_suffix : ('[' conditional_expression? ']') | param_type_list;
// Copied from SimpleDecl.g4
simple_decl : (TYPEDEF?) var_decl;
var_decl : class_def init_declarator_list? #declByClass
| template_decl* type_name init_declarator_list #declByType
;
init_declarator_list: init_declarator (',' init_declarator)* ';';
initializer: assign_expr
|'{' initializer_list '}'
;
initializer_list: initializer (',' initializer)* ','?
| '.' initializer (',' '.' initializer)* ','?
| conditional_expression (',' conditional_expression)* ','
| identifier ':' conditional_expression (',' identifier ':' conditional_expression)* ','?
;
// Parameters
param_decl_specifiers : (AUTO | REGISTER)? type_name;
// this is a bit misleading. We're just allowing access_specifiers
// here because C programs can use 'public', 'protected' or 'private'
// as variable names.
parameter_name: identifier;
param_type_list: '(' VOID ')'
| '(' (param_type (',' param_type)*)? ')';
param_type: param_decl_specifiers param_type_id;
param_type_id: (ptrs | rvalue_ref)? ('(' param_type_id ')' | parameter_name?) type_suffix?;
| 3,250 | ANTLR | .g4 | 78 | 33.423077 | 105 | 0.578428 | baekhyunwook/test_fuzzyc | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | afc2df95bb968f69c47b6577c75227e0c820fe1d1733cebc24ed023aa95ca674 | false | false | false | false |
154 | SCLang.g4 | shervinemp_VA-Project/SCLang.g4 | // Filename: SCLang.g4
grammar SCLang;
script : definition* ;
definition : conditionBlock? visibility actionBlock effectBlock? metaData?;
conditionBlock : '@' logicExpr ;
visibility : 'pub' | 'priv' ;
actionBlock : entityGroup '.' method argsWrapper ;
effectBlock : '->' logicExpr ;
metaData : '{' metaBlock? '}' ;
logicExpr : modifier? logicTerm ;
logicTerm : attrib comparison? | '!' liveTerm '!' | '[' logicGroup? ']' ;
logicGroup : logicOr ;
logicOr : logicAnd ('|' logicAnd)* ;
logicAnd : logicExpr ('&' logicExpr)* ;
liveTerm : attrib comparison? | '[' logicGroup ']' ;
modifier : '~' | '$' ;
comparison : compareOp attrib (compareOp attrib)? ;
compareOp : '!=' | '<' | '<=' | '>' | '>=' | '==' ;
entityRef : entity | entityGroup ;
entityGroup : '{' entityDef ('|' logicExpr)? '}' ;
entityDef : entityType ':' entity ;
entityType : entityClass | entityVariable | entityConstant ;
entityClass : 'ent' '(' IDENTIFIER ')' ;
entityVariable : 'var' '(' dataType ')' ;
entityConstant : 'const' '(' dataType ')' ;
dataType : 'Bool' | 'Float' | 'Int' | 'String' ;
attrib : entityRef methodCall? ;
methodCall : '.' method argsWrapper? ;
argsWrapper : '(' argsList ')' ;
argsList : argument (',' argument)* ;
argument : logicExpr ;
metaBlock : metaEntry (',' metaEntry)* ','? ;
metaEntry : STRING ':' value ;
value : NUMBER | STRING | 'True' | 'False' ;
entity : IDENTIFIER ;
method : IDENTIFIER ;
// Lexer rules
IDENTIFIER : [a-zA-Z_][a-zA-Z_0-9]* ;
NUMBER : [0-9]+ ('.' [0-9]+)? ;
STRING : '"' ( ~["\\] | '\\' . )* '"';
WS : [ \t\r\n]+ -> skip ; // Skip whitespace
COMMENT : '//' (~[ \r\n])* -> skip ; // Single-line comments
| 1,692 | ANTLR | .g4 | 42 | 39.047619 | 79 | 0.609146 | shervinemp/VA-Project | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 08da2bd93496b2e8f5a8224a509498ac7a5f78dbbe5bd2d63886ebec59249a62 | false | false | false | false |
155 | CoolLexer.g4 | sowgali_COOL-Compiler/Lexer/CoolLexer.g4 | lexer grammar CoolLexer;
tokens{
ERROR,
TYPEID,
OBJECTID,
BOOL_CONST,
INT_CONST,
STR_CONST,
LPAREN,
RPAREN,
COLON,
ATSYM,
SEMICOLON,
COMMA,
PLUS,
MINUS,
STAR,
SLASH,
TILDE,
LT,
EQUALS,
LBRACE,
RBRACE,
DOT,
DARROW,
LE,
ASSIGN,
CLASS,
ELSE,
FI,
IF,
IN,
INHERITS,
LET,
LOOP,
POOL,
THEN,
WHILE,
CASE,
ESAC,
OF,
NEW,
ISVOID,
NOT
}
/*
DO NOT EDIT CODE ABOVE THIS LINE
*/
@members{
/*
YOU CAN ADD YOUR MEMBER VARIABLES AND METHODS HERE
*/
/**
* Function to report errors.
* Use this function whenever your lexer encounters any erroneous input
* DO NOT EDIT THIS FUNCTION
*/
public void reportError(String errorString){
setText(errorString);
setType(ERROR);
}
/** Routine that processes any other token than
* those specified by COOL */
public void processOthers(){
Token t = _factory.create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex, getCharIndex()-1, _tokenStartLine, _tokenStartCharPositionInLine);
String text = t.getText();
setText(text);
setType(ERROR);
}
/** Routine to process strings*/
public void processString() {
Token t = _factory.create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex, getCharIndex()-1, _tokenStartLine, _tokenStartCharPositionInLine);
String text = t.getText();
//write your code to test strings here
StringBuilder myBuff = new StringBuilder(0);
String ouText;
if(text.indexOf('\0') != -1)
{
reportError("String contains null character");
return;
}
for(int j = 0; j < text.length()-1; j++)
{
if(text.charAt(j) == '\\')
{
switch(text.charAt(j+1))
{
case 'b' : myBuff.append('\b');
break;
case 't' : myBuff.append('\t');
break;
case 'n' : myBuff.append('\n');
break;
case 'f' : myBuff.append('\f');
break;
case '\\' : myBuff.append('\\');
break;
case '\"' : myBuff.append('\"');
break;
case '\'' : myBuff.append('\'');
break;
default : myBuff.append(text.charAt(j+1));
break;
}
j++;
}
else
myBuff.append(text.charAt(j));
}
ouText = myBuff.toString();
if(ouText.length() > 1024)
reportError("String constant too long");
else
{
setText(ouText);
setType(STR_CONST);
}
return;
}
}
/*
WRITE ALL LEXER RULES BELOW
*/
/** Keywords of cool language
* They are case-insensitive*/
CLASS : [cC][lL][aA][sS][sS];
ELSE : [eE][lL][sS][eE];
FI : [fF][iI];
IF : [iI][fF];
IN : [iI][nN];
INHERITS : [iI][nN][hH][eE][rR][iI][tT][sS];
LET : [lL][eE][tT];
LOOP : [lL][oO][oO][pP];
POOL : [pP][oO][oO][lL];
THEN : [tT][hH][eE][nN];
WHILE : [wW][hH][iI][lL][eE];
CASE : [cC][aA][sS][eE];
ESAC : [eE][sS][aA][cC];
OF : [oO][fF];
NEW : [nN][eE][wW];
ISVOID : [iI][sS][vV][oO][iI][dD];
NOT : [nN][oO][tT];
/** Basic constants and some special names*/
SELF : 'self';
SELF_TYPE : 'SELF_TYPE';
BOOL_CONST : [t][rR][uU][eE] | [f][aA][lL][sS][eE];
TYPEID : [A-Z]+[a-zA-Z0-9_]*;
OBJECTID : [a-z][a-zA-Z0-9_]+;
INT_CONST : [0-9]+;
STR_CONST : '"' -> skip,pushMode(STR_MODE);/
/**All valid lexical symbols of COOL*/
LPAREN : '{';
RPAREN : '}';
COLON : ':';
ATSYM : '@';
COMMA : ',';
PLUS : '+';
MINUS : '-';
STAR : '*';
SLASH : '/';
TILDE : '~';
LT : '<';
EQUALS : '=';
LBRACE : '(';
RBRACE : ')';
DOT : '.';
SEMICOLON : ';';
DARROW : '=>';
LE : '<=';
ASSIGN : '<-';
// Takes care of whitespaces
WHITESPACE : [ \n\f\r\t\v]+ -> skip;
// For inline comments
INLINE_COMMENT : '--' .*? '\n' -> skip;
// Goes to cooment mode to check for nesting and errors
COMMENT : '(*' -> pushMode(NEST_COMMENT), skip;
FILEND_COMMENT : '*)' EOF {reportError("Unmatched *)");};
END_COMMENT : '*)' {reportError("Unmatched *)");};
// Reports any other tokens that breaks the lexical rules of COOL
EVERYOTHERTHING : . {processOthers();};
// Checks for errors and initializes recursion, in case of nesting
mode NEST_COMMENT;
END_ERROR : .(EOF) {reportError("EOF in comment");}; // Reports of any EOF in comments
NESTING : '(*' -> pushMode(RECURSE) , skip; // Initiates Recursive NESTING
BYE_V1 : '*)' -> popMode , skip; // Terminates comment mode
JUST_GO_V1 : . -> skip; // Ignores content of comments
// The recursive routine and sanity checks
mode RECURSE;
END_ERROR_1 : .(EOF) {reportError("EOF in comment");}; // Reports of any EOF in comments
NEW_ERROR : '*)' EOF {reportError("EOF in comment");}; // Reports of any EOF in comments
R_NESTING : '(*' -> pushMode(RECURSE) , skip; // Maintains recursion
BYE_V2 : '*)' -> popMode , skip; // Terminate from recursion
JUST_GO_V2 : . -> skip; // Ignores content of comments
// Processes string constants
mode STR_MODE;
STR_END : '"' {processString();} -> popMode; // Detects end of string
NL_IN_STR : '\n' {reportError("Unescaped newline");} -> pushMode(DEFAULT_MODE); // Reports any unescaped newline
EOF_IN_STR : .(EOF) {reportError("EOF in string constant");} -> pushMode(DEFAULT_MODE); // Reports any EOF in string
BODY : ((~('\n'|[EOF]|'\u0000'|'"'))('\\''\n')?('\\''\"')?)+ -> more//{processString();}
; // Continues fetching tokens if terminating characters are present in strings as members
| 5,576 | ANTLR | .g4 | 200 | 25.305 | 165 | 0.587565 | sowgali/COOL-Compiler | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 15db9b540520e334e45782590729aa73784e937f124f2403b2b74104cb9eb962 | false | false | false | false |
156 | CoolLexer.g4 | sowgali_COOL-Compiler/Lexer/src/CoolLexer.g4 | lexer grammar CoolLexer;
tokens{
ERROR,
TYPEID,
OBJECTID,
BOOL_CONST,
INT_CONST,
STR_CONST,
LPAREN,
RPAREN,
COLON,
ATSYM,
SEMICOLON,
COMMA,
PLUS,
MINUS,
STAR,
SLASH,
TILDE,
LT,
EQUALS,
LBRACE,
RBRACE,
DOT,
DARROW,
LE,
ASSIGN,
CLASS,
ELSE,
FI,
IF,
IN,
INHERITS,
LET,
LOOP,
POOL,
THEN,
WHILE,
CASE,
ESAC,
OF,
NEW,
ISVOID,
NOT
}
/*
DO NOT EDIT CODE ABOVE THIS LINE
*/
/* Author : Sowrya Gali - CS18BTECH11012*/
@members{
/*
YOU CAN ADD YOUR MEMBER VARIABLES AND METHODS HERE
*/
/**
* Function to report errors.
* Use this function whenever your lexer encounters any erroneous input
* DO NOT EDIT THIS FUNCTION
*/
public void reportError(String errorString){
setText(errorString);
setType(ERROR);
}
/** Routine that processes any other token than
* those specified by COOL */
public void processOthers(){
Token t = _factory.create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex, getCharIndex()-1, _tokenStartLine, _tokenStartCharPositionInLine);
String text = t.getText();
setText(text);
setType(ERROR);
}
/** Routine to process strings*/
public void processString() {
Token t = _factory.create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex, getCharIndex()-1, _tokenStartLine, _tokenStartCharPositionInLine);
String text = t.getText();
//write your code to test strings here
StringBuilder myBuff = new StringBuilder(0);
String ouText;
int i = 0;
// Flags to keep track of errors
boolean unesc_nl = false;
boolean null_str = false;
boolean esc_null = false;
boolean eof = false;
boolean backslash = false;
boolean flag = true;
boolean max_len = false;
// Checking string end to set flags
if(text.charAt(text.length()-1) != '\"')
{
switch(text.charAt(text.length()-1))
{
case '\n' : unesc_nl = true;
break;
case '\\' : backslash = true;
break;
default : eof = true;
break;
}
}
// Loop to process string contents
for(int j = 0; flag&&(i<=1025)&&(j < text.length()-1); j++)
{
if(text.charAt(j)=='\\')
{
switch(text.charAt(j+1))
{
case 'b' : myBuff.append('\b');
break;
case 't' : myBuff.append('\t');
break;
case 'n' : myBuff.append('\n');
if(j+2 == text.length())
eof = true;
break;
case '\n' : myBuff.append('\n');
if(j+2 == text.length())
{
eof = true;
// If newline is found at it is actually escaped
if(unesc_nl)
unesc_nl = false;
}
break;
case 'f' : myBuff.append('\f');
break;
case '\\' : myBuff.append('\\');
if(j+2 == text.length())
{
eof = true;
// If backslash is found it is actually escaped
if(backslash)
backslash = false;
}
break;
case '\"' : myBuff.append('\"');
if(j+2 == text.length())
eof = true;
break;
case '\'' : myBuff.append('\'');
break;
case '\u0000' : esc_null = true; // Escaped null character is found in string
flag = false;
break;
default : myBuff.append(text.charAt(j+1));
break;
}
j++;
}
else
{
switch(text.charAt(j))
{
case '\u0000' : null_str = true; // Null charactr is found in the string
flag = false;
break;
default : myBuff.append(text.charAt(j));
break;
}
}
i++;
if(i>1024)
max_len = true; // If string exceeds maximum length
}
// The final string is copied to ouText
ouText = myBuff.toString();
//Reporting errors as per coolc precedence
if(null_str)
reportError("String contains null character");
else if(esc_null)
reportError("String contains escaped null character");
else if(i<1026 && backslash)
reportError("backslash at the end of file");
else if(i<1026 && unesc_nl)
reportError("Unterminated string constant");
else if(max_len)
reportError("String constant too long");
else if(eof)
reportError("EOF in string constant");
// If error is encountered
else
{
setText(ouText);
setType(STR_CONST);
}
return;
}
}
/*
WRITE ALL LEXER RULES BELOW
*/
/** Keywords of cool language
* They are case-insensitive*/
SEMICOLON : ';';
DARROW : '=>';
CLASS : [cC][lL][aA][sS][sS];
ELSE : [eE][lL][sS][eE];
FI : [fF][iI];
IF : [iI][fF];
IN : [iI][nN];
INHERITS : [iI][nN][hH][eE][rR][iI][tT][sS];
LET : [lL][eE][tT];
LOOP : [lL][oO][oO][pP];
POOL : [pP][oO][oO][lL];
THEN : [tT][hH][eE][nN];
WHILE : [wW][hH][iI][lL][eE];
CASE : [cC][aA][sS][eE];
ESAC : [eE][sS][aA][cC];
OF : [oO][fF];
NEW : [nN][eE][wW];
ISVOID : [iI][sS][vV][oO][iI][dD];
NOT : [nN][oO][tT];
/** Basic constants and some special names*/
//fragment SELF : [s][e][l][f];
//fragment SELF_TYPE : [S][E][L][F][_][T][Y][P][E];
BOOL_CONST : [t][rR][uU][eE] | [f][aA][lL][sS][eE];
TYPEID : [A-Z][a-zA-Z0-9_]*;
OBJECTID : [a-z][a-zA-Z0-9_]*;
INT_CONST : [0-9]+;
STR_CONST : '"' -> skip,pushMode(STR_MODE);
/**All valid lexical symbols of COOL*/
LPAREN : '(';
RPAREN : ')';
COLON : ':';
ATSYM : '@';
COMMA : ',';
PLUS : '+';
MINUS : '-';
STAR : '*';
SLASH : '/';
TILDE : '~';
LT : '<';
EQUALS : '=';
LBRACE : '{';
RBRACE : '}';
DOT : '.';
LE : '<=';
ASSIGN : '<-';
// Takes care of whitespaces
WHITESPACE : [ \n\f\r\t\v]+ -> skip;
// For inline comments
INLINE_COMMENT : '--' (~('\n'))*? ('\n' | EOF) -> skip;
// Goes to comment mode to check for nesting and errors
COMMENT : '(*' -> pushMode(NEST_COMMENT), skip;
FILEND_COMMENT : '*)' EOF {reportError("Unmatched *)");};
END_COMMENT : '*)' {reportError("Unmatched *)");};
// Reports any other tokens that breaks the lexical rules of COOL
EVERYOTHERTHING : . {processOthers();};
// Checks for errors and initializes recursion, in case of nesting
mode NEST_COMMENT;
END_ERROR : .(EOF) {reportError("EOF in comment");}; // Reports of any EOF in comments
NESTING : '(*' -> pushMode(RECURSE) , skip; // Initiates Recursive NESTING
BYE_V1 : '*)' -> popMode , skip; // Terminates comment mode
JUST_GO_V1 : . -> skip; // Ignores content of comments
// The recursive routine and sanity checks
mode RECURSE;
END_ERROR_1 : .(EOF) {reportError("EOF in comment");}; // Reports of any EOF in comments
NEW_ERROR : '*)' EOF {reportError("EOF in comment");}; // Reports of any EOF in comments
R_NESTING : '(*' -> pushMode(RECURSE) , skip; // Maintains recursion
BYE_V2 : '*)' -> popMode , skip; // Terminate from recursion
JUST_GO_V2 : . -> skip; // Ignores content of comments
// Processes string constants
mode STR_MODE;
BODY : (((~('\n'|'"'|'\\'))|'\\'(.)) ('\\''\n')?('\\''\"')?)* ('\n'|'"'|('\\'? EOF)) {processString();} -> popMode;
| 7,166 | ANTLR | .g4 | 263 | 23.410646 | 165 | 0.574938 | sowgali/COOL-Compiler | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 2851a4c16c8487fda4ed3416e7986ee642cddf51993a020552cc1050226529e6 | false | false | false | false |
157 | CoolLexersuk.g4 | sowgali_COOL-Compiler/Lexer/src/grammar/CoolLexersuk.g4 | lexer grammar CoolLexer;
tokens{
ERROR,
TYPEID,
OBJECTID,
BOOL_CONST,
INT_CONST,
STR_CONST,
LPAREN,
RPAREN,
COLON,
ATSYM,
SEMICOLON,
COMMA,
PLUS,
MINUS,
STAR,
SLASH,
TILDE,
LT,
EQUALS,
LBRACE,
RBRACE,
DOT,
DARROW,
LE,
ASSIGN,
CLASS,
ELSE,
FI,
IF,
IN,
INHERITS,
LET,
LOOP,
POOL,
THEN,
WHILE,
CASE,
ESAC,
OF,
NEW,
ISVOID,
NOT
}
/*
DO NOT EDIT CODE ABOVE THIS LINE
*/
@members{
/*
YOU CAN ADD YOUR MEMBER VARIABLES AND METHODS HERE
*/
/**
* Function to report errors.
* Use this function whenever your lexer encounters any erroneous input
* DO NOT EDIT THIS FUNCTION
*/
public void reportError(String errorString){
setText(errorString);
setType(ERROR);
}
public void processString() {
Token t = _factory.create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex, getCharIndex()-1, _tokenStartLine, _tokenStartCharPositionInLine);
String text = t.getText();
text = text.substring(0,text.length()-1);
if(text.length() > 1024)
{
reportError("String constant too long");
return;
}
if(text.indexOf('\0') != -1)
{
reportError("String contains null character");
return;
}
String escape_chars = "btnf";
String escape_chars_results = "\b\t\n\f";
int index = text.indexOf('\\');
while(index != -1) {
int escape_index = escape_chars.indexOf(text.charAt(index+1));
if(escape_index != -1) {
text = text.substring(0,index) + escape_chars_results.charAt(escape_index) + text.substring(index+2);
}
else
{
text = text.substring(0,index) + text.substring(index+1);
}
index = text.indexOf('\\');
}
setText(text);
setType(STR_CONST);
//write your code to test strings here
}
public void processCharacter() {
Token t = _factory.create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex, getCharIndex()-1, _tokenStartLine, _tokenStartCharPositionInLine);
String text = t.getText();
reportError(text);
}
public void parseComment() {
Token t = _factory.create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex, getCharIndex()-1, _tokenStartLine, _tokenStartCharPositionInLine);
String text = t.getText();
skip();
}
}
/*
WRITE ALL LEXER RULES BELOW
*/
SEMICOLON : ';';
DARROW : '=>';
CLASS : [Cc][Ll][Aa][Ss][Ss] ;
ELSE : [Ee][Ll][Ss][Ee] ;
FI : [Ff][Ii];
IF : [Ii][Ff] ;
IN : [Ii][Nn] ;
INHERITS : [Ii][Nn][Hh][Ee][Rr][Ii][Tt][Ss] ;
LET : [Ll][Ee][Tt] ;
LOOP : [Ll][Oo][Oo][Pp] ;
POOL : [Pp][Oo][Oo][Ll] ;
THEN : [Tt][Hh][Ee][Nn] ;
WHILE : [Ww][Hh][Ii][Ll][Ee] ;
CASE : [Cc][Aa][Ss][Ee] ;
ESAC : [Ee][Ss][Aa][Cc] ;
OF : [Oo][Ff] ;
NEW : [Nn][Ee][Ww] ;
ISVOID : [Ii][Ss][Vv][Oo][Ii][Dd] ;
NOT : [Nn][Oo][Tt] ;
BOOL_CONST : 't'[Rr][Uu][Ee] | 'f'[Aa][Ll][Ss][Ee] ;
TYPEID : [A-Z][a-z|A-Z|0-9|_]* ;
OBJECTID : [a-z][a-z|A-Z|0-9|_]* ;
INT_CONST : [0-9]+ ;
/*OPEN_COMMENT : '(*'(BLOCK_COMMENT | ~('*' | '(') | '*'~(')') | '('~('*') )*EOF {reportError("EOF in comment");} -> more;
BLOCK_COMMENT : '(*'(BLOCK_COMMENT | ~('*' | '(') | '*'~(')') | '('~('*') )*'*)' -> skip;*/
STRAY_COMMENT : '*)' {reportError("Unmatched *)");};
LPAREN : '(' ;
RPAREN : ')' ;
COLON : ':' ;
ATSYM : '@' ;
COMMA : ',' ;
PLUS : '+' ;
MINUS : '-' ;
STAR : '*' ;
SLASH : '/' ;
TILDE : '~' ;
LT : '<' ;
EQUALS : '=' ;
LBRACE : '{' ;
RBRACE : '}' ;
DOT : '.' ;
LE : '<=' ;
ASSIGN : '<-' ;
//BLCOMMENT : '(*'.*?BLCOMMENT?'*)' -> skip;
WHITESPACE : [\n\f\r\v\b\t ]+ -> skip ;
/*STR_CONST : '"'~('\u0000' | [EOF] | '"' | '\u000d' )* '"' {processString();};*/
/*STR_CONST : '"'~('\u0000' | [EOF] | '"' | '\n')*'"' {processString();}
| '"'~('\u0000' | '"' | '\n')*[EOF] {reportError("String contains EOF");}
| '"'~([EOF] | '"' | '\u0000')*'\n' {reportError("Unterminated string");}
;*/
STR_START : '"' -> skip, pushMode(STRING_MODE);
COMMENT_START : '(*' -> skip, pushMode(COMMENT_MODE);
SINGLE_LINE_COMMENT : ('--'~('\n' | [EOF])*'\n'
| '--'~('\n' | [EOF])*(EOF)) -> skip
;
INCORRECT_CHARACTERS : . {processCharacter();};
mode STRING_MODE;
//STRING : (STRING_BODY_PLAIN | E_NEWLINE)*;
STRING_END : '"' {processString();} -> popMode;
NEWLINE : '\n' {reportError("Unterminated string constant");} -> mode(DEFAULT_MODE) ;
//NULL_CHAR : '\u0000' {reportError("String contains null character");} -> mode(DEFAULT_MODE) ;
F_EOF_STR : .(EOF) {reportError("EOF in string constant");}-> mode(DEFAULT_MODE) ;
STRING_BODY_PLAIN : (~('\u0000' | [EOF] | '"' | '\n')('\\''\n')?('\\''\"')?)+ -> more//{processString();}
; //TODO unescaped newline - maybe done
//fragment END_QUOTE : ~('\\')'"';
/*BACKSLASH : '\\' -> skip, pushMode(ESCAPE_MODE);
mode ESCAPE_MODE;
NEWLINE : '\n' -> popMode;*/
mode COMMENT_MODE;
COMMENT_START_CM : '(*' -> skip, pushMode(COMMENT_MODE);
COMMENT_END : '*)' -> skip, popMode;
EOF_F : .(EOF) {reportError("EOF in comment");} -> mode(DEFAULT_MODE);
ANYTHING : . -> skip;
/*NOT_EOF_STAR : ~([EOF] | '*' | '(') ;
STAR_WITHOUT_PARENTHESES : '*'~(')') ;
PARENTHESES_WITHOUT_STAR : '('~('*');
THINGS_TO_SKIP : (NOT_EOF_STAR | STAR_WITHOUT_PARENTHESES | PARENTHESES_WITHOUT_STAR)* -> skip;*/
/*NO_STAR : (~([EOF])~('*')?)+ -> skip;
EOF_F : EOF {reportError("EOF in comment");} -> mode(DEFAULT_MODE);
STAR_WITHOUT_PARENTHESIS : (~([EOF])('*'~(')'))?)+ -> skip;*/
| 5,322 | ANTLR | .g4 | 187 | 26.395722 | 165 | 0.593671 | sowgali/COOL-Compiler | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 14d40f8b005a513514e54be3fb51ff7b20b4e5b14729f70d2f48e45df20403b7 | true | false | false | false |
160 | log4j2.xml | jsanzmex_java-nr-extensions-extractor/src/main/resources/log4j2.xml | <?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<File name="RollingFileAppender" fileName="extensions.log" immediateFlush="false" append="true">
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</File>
<Console name="ConsoleAppender">
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="ALL">
<AppenderRef ref="RollingFileAppender"/>
<AppenderRef ref="ConsoleAppender"/>
</Root>
</Loggers>
</Configuration> | 675 | ANTLR | .g4 | 17 | 32.176471 | 104 | 0.60091 | jsanzmex/java-nr-extensions-extractor | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 4655cf160fdfe9b3a6065a5c0ccc90e74551d5f833e31677a2c6e83d13ad32c9 | false | false | false | false |
161 | Java8Parser.g4 | jsanzmex_java-nr-extensions-extractor/src/main/antlr4/com/sopristec/extractor/Java8Parser.g4 | /*
* [The "BSD license"]
* Copyright (c) 2014 Terence Parr
* Copyright (c) 2014 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* A Java 8 grammar for ANTLR 4 derived from the Java Language Specification
* chapter 19.
*
* NOTE: This grammar results in a generated parser that is much slower
* than the Java 7 grammar in the grammars-v4/java directory. This
* one is, however, extremely close to the spec.
*
* You can test with
*
* $ antlr4 Java8.g4
* $ javac *.java
* $ grun Java8 compilationUnit *.java
*
* Or,
~/antlr/code/grammars-v4/java8 $ java Test .
/Users/parrt/antlr/code/grammars-v4/java8/./Java8BaseListener.java
/Users/parrt/antlr/code/grammars-v4/java8/./Java8Lexer.java
/Users/parrt/antlr/code/grammars-v4/java8/./Java8Listener.java
/Users/parrt/antlr/code/grammars-v4/java8/./Java8Parser.java
/Users/parrt/antlr/code/grammars-v4/java8/./Test.java
Total lexer+parser time 30844ms.
*/
parser grammar Java8Parser;
options {
tokenVocab=Java8Lexer;
}
/*
* Productions from §3 (Lexical Structure)
*/
literal
: IntegerLiteral
| FloatingPointLiteral
| BooleanLiteral
| CharacterLiteral
| StringLiteral
| NullLiteral
;
/*
* Productions from §4 (Types, Values, and Variables)
*/
primitiveType
: annotation* numericType
| annotation* 'boolean'
;
numericType
: integralType
| floatingPointType
;
integralType
: 'byte'
| 'short'
| 'int'
| 'long'
| 'char'
;
floatingPointType
: 'float'
| 'double'
;
referenceType
: classOrInterfaceType
| typeVariable
| arrayType
;
classOrInterfaceType
: ( classType_lfno_classOrInterfaceType
| interfaceType_lfno_classOrInterfaceType
)
( classType_lf_classOrInterfaceType
| interfaceType_lf_classOrInterfaceType
)*
;
classType
: annotation* Identifier typeArguments?
| classOrInterfaceType '.' annotation* Identifier typeArguments?
;
classType_lf_classOrInterfaceType
: '.' annotation* Identifier typeArguments?
;
classType_lfno_classOrInterfaceType
: annotation* Identifier typeArguments?
;
interfaceType
: classType
;
interfaceType_lf_classOrInterfaceType
: classType_lf_classOrInterfaceType
;
interfaceType_lfno_classOrInterfaceType
: classType_lfno_classOrInterfaceType
;
typeVariable
: annotation* Identifier
;
arrayType
: primitiveType dims
| classOrInterfaceType dims
| typeVariable dims
;
dims
: annotation* '[' ']' (annotation* '[' ']')*
;
typeParameter
: typeParameterModifier* Identifier typeBound?
;
typeParameterModifier
: annotation
;
typeBound
: 'extends' typeVariable
| 'extends' classOrInterfaceType additionalBound*
;
additionalBound
: '&' interfaceType
;
typeArguments
: '<' typeArgumentList '>'
;
typeArgumentList
: typeArgument (',' typeArgument)*
;
typeArgument
: referenceType
| wildcard
;
wildcard
: annotation* '?' wildcardBounds?
;
wildcardBounds
: 'extends' referenceType
| 'super' referenceType
;
/*
* Productions from §6 (Names)
*/
packageName
: Identifier
| packageName '.' Identifier
;
typeName
: Identifier
| packageOrTypeName '.' Identifier
;
packageOrTypeName
: Identifier
| packageOrTypeName '.' Identifier
;
expressionName
: Identifier
| ambiguousName '.' Identifier
;
methodName
: Identifier
;
ambiguousName
: Identifier
| ambiguousName '.' Identifier
;
/*
* Productions from §7 (Packages)
*/
compilationUnit
: packageDeclaration? importDeclaration* typeDeclaration* EOF
;
packageDeclaration
: packageModifier* 'package' packageName ';'
;
packageModifier
: annotation
;
importDeclaration
: singleTypeImportDeclaration
| typeImportOnDemandDeclaration
| singleStaticImportDeclaration
| staticImportOnDemandDeclaration
;
singleTypeImportDeclaration
: 'import' typeName ';'
;
typeImportOnDemandDeclaration
: 'import' packageOrTypeName '.' '*' ';'
;
singleStaticImportDeclaration
: 'import' 'static' typeName '.' Identifier ';'
;
staticImportOnDemandDeclaration
: 'import' 'static' typeName '.' '*' ';'
;
typeDeclaration
: classDeclaration
| interfaceDeclaration
| ';'
;
/*
* Productions from §8 (Classes)
*/
classDeclaration
: normalClassDeclaration
| enumDeclaration
;
normalClassDeclaration
: classModifier* 'class' Identifier typeParameters? superclass? superinterfaces? classBody
;
classModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'abstract'
| 'static'
| 'final'
| 'strictfp'
;
typeParameters
: '<' typeParameterList '>'
;
typeParameterList
: typeParameter (',' typeParameter)*
;
superclass
: 'extends' classType
;
superinterfaces
: 'implements' interfaceTypeList
;
interfaceTypeList
: interfaceType (',' interfaceType)*
;
classBody
: '{' classBodyDeclaration* '}'
;
classBodyDeclaration
: classMemberDeclaration
| instanceInitializer
| staticInitializer
| constructorDeclaration
;
classMemberDeclaration
: fieldDeclaration
| methodDeclaration
| classDeclaration
| interfaceDeclaration
| ';'
;
fieldDeclaration
: fieldModifier* unannType variableDeclaratorList ';'
;
fieldModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'static'
| 'final'
| 'transient'
| 'volatile'
;
variableDeclaratorList
: variableDeclarator (',' variableDeclarator)*
;
variableDeclarator
: variableDeclaratorId ('=' variableInitializer)?
;
variableDeclaratorId
: Identifier dims?
;
variableInitializer
: expression
| arrayInitializer
;
unannType
: unannPrimitiveType
| unannReferenceType
;
unannPrimitiveType
: numericType
| 'boolean'
;
unannReferenceType
: unannClassOrInterfaceType
| unannTypeVariable
| unannArrayType
;
unannClassOrInterfaceType
: ( unannClassType_lfno_unannClassOrInterfaceType
| unannInterfaceType_lfno_unannClassOrInterfaceType
)
( unannClassType_lf_unannClassOrInterfaceType
| unannInterfaceType_lf_unannClassOrInterfaceType
)*
;
unannClassType
: Identifier typeArguments?
| unannClassOrInterfaceType '.' annotation* Identifier typeArguments?
;
unannClassType_lf_unannClassOrInterfaceType
: '.' annotation* Identifier typeArguments?
;
unannClassType_lfno_unannClassOrInterfaceType
: Identifier typeArguments?
;
unannInterfaceType
: unannClassType
;
unannInterfaceType_lf_unannClassOrInterfaceType
: unannClassType_lf_unannClassOrInterfaceType
;
unannInterfaceType_lfno_unannClassOrInterfaceType
: unannClassType_lfno_unannClassOrInterfaceType
;
unannTypeVariable
: Identifier
;
unannArrayType
: unannPrimitiveType dims
| unannClassOrInterfaceType dims
| unannTypeVariable dims
;
methodDeclaration
: methodModifier* methodHeader methodBody
;
methodModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'abstract'
| 'static'
| 'final'
| 'synchronized'
| 'native'
| 'strictfp'
;
methodHeader
: result methodDeclarator throws_?
| typeParameters annotation* result methodDeclarator throws_?
;
result
: unannType
| 'void'
;
methodDeclarator
: Identifier '(' formalParameterList? ')' dims?
;
formalParameterList
: receiverParameter
| formalParameters ',' lastFormalParameter
| lastFormalParameter
;
formalParameters
: formalParameter (',' formalParameter)*
| receiverParameter (',' formalParameter)*
;
formalParameter
: variableModifier* unannType variableDeclaratorId?
;
variableModifier
: annotation
| 'final'
;
lastFormalParameter
: variableModifier* unannType annotation* '...' variableDeclaratorId?
| formalParameter
;
receiverParameter
: annotation* unannType (Identifier '.')? 'this'
;
throws_
: 'throws' exceptionTypeList
;
exceptionTypeList
: exceptionType (',' exceptionType)*
;
exceptionType
: classType
| typeVariable
;
methodBody
: block
| ';'
;
instanceInitializer
: block
;
staticInitializer
: 'static' block
;
/** MODIFIED BY JULIO
* original 'constructorDeclaration' looks for 'constructorBody', but in our case
* constructor and methods are more like signature declarations. Hence, we replaced
* it by ';'*
*
* constructorDeclaration
* : constructorModifier* constructorDeclarator throws_? constructorBody
* ;
*/
constructorDeclaration
: constructorModifier* constructorDeclarator throws_? ';'*
;
constructorModifier
: annotation
| 'public'
| 'protected'
| 'private'
;
constructorDeclarator
: typeParameters? simpleTypeName '(' formalParameterList? ')'
;
simpleTypeName
: Identifier
;
constructorBody
: '{' explicitConstructorInvocation? blockStatements? '}'
;
explicitConstructorInvocation
: typeArguments? 'this' '(' argumentList? ')' ';'
| typeArguments? 'super' '(' argumentList? ')' ';'
| expressionName '.' typeArguments? 'super' '(' argumentList? ')' ';'
| primary '.' typeArguments? 'super' '(' argumentList? ')' ';'
;
enumDeclaration
: classModifier* 'enum' Identifier superinterfaces? enumBody
;
enumBody
: '{' enumConstantList? ','? enumBodyDeclarations? '}'
;
enumConstantList
: enumConstant (',' enumConstant)*
;
enumConstant
: enumConstantModifier* Identifier ('(' argumentList? ')')? classBody?
;
enumConstantModifier
: annotation
;
enumBodyDeclarations
: ';' classBodyDeclaration*
;
/*
* Productions from §9 (Interfaces)
*/
interfaceDeclaration
: normalInterfaceDeclaration
| annotationTypeDeclaration
;
normalInterfaceDeclaration
: interfaceModifier* 'interface' Identifier typeParameters? extendsInterfaces? interfaceBody
;
interfaceModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'abstract'
| 'static'
| 'strictfp'
;
extendsInterfaces
: 'extends' interfaceTypeList
;
interfaceBody
: '{' interfaceMemberDeclaration* '}'
;
interfaceMemberDeclaration
: constantDeclaration
| interfaceMethodDeclaration
| classDeclaration
| interfaceDeclaration
| ';'
;
constantDeclaration
: constantModifier* unannType variableDeclaratorList ';'
;
constantModifier
: annotation
| 'public'
| 'static'
| 'final'
;
interfaceMethodDeclaration
: interfaceMethodModifier* methodHeader methodBody
;
interfaceMethodModifier
: annotation
| 'public'
| 'abstract'
| 'default'
| 'static'
| 'strictfp'
;
annotationTypeDeclaration
: interfaceModifier* '@' 'interface' Identifier annotationTypeBody
;
annotationTypeBody
: '{' annotationTypeMemberDeclaration* '}'
;
annotationTypeMemberDeclaration
: annotationTypeElementDeclaration
| constantDeclaration
| classDeclaration
| interfaceDeclaration
| ';'
;
annotationTypeElementDeclaration
: annotationTypeElementModifier* unannType Identifier '(' ')' dims? defaultValue? ';'
;
annotationTypeElementModifier
: annotation
| 'public'
| 'abstract'
;
defaultValue
: 'default' elementValue
;
annotation
: normalAnnotation
| markerAnnotation
| singleElementAnnotation
;
normalAnnotation
: '@' typeName '(' elementValuePairList? ')'
;
elementValuePairList
: elementValuePair (',' elementValuePair)*
;
elementValuePair
: Identifier '=' elementValue
;
elementValue
: conditionalExpression
| elementValueArrayInitializer
| annotation
;
elementValueArrayInitializer
: '{' elementValueList? ','? '}'
;
elementValueList
: elementValue (',' elementValue)*
;
markerAnnotation
: '@' typeName
;
singleElementAnnotation
: '@' typeName '(' elementValue ')'
;
/*
* Productions from §10 (Arrays)
*/
arrayInitializer
: '{' variableInitializerList? ','? '}'
;
variableInitializerList
: variableInitializer (',' variableInitializer)*
;
/*
* Productions from §14 (Blocks and Statements)
*/
block
: '{' blockStatements? '}'
;
blockStatements
: blockStatement+
;
blockStatement
: localVariableDeclarationStatement
| classDeclaration
| statement
;
localVariableDeclarationStatement
: localVariableDeclaration ';'
;
localVariableDeclaration
: variableModifier* unannType variableDeclaratorList
;
statement
: statementWithoutTrailingSubstatement
| labeledStatement
| ifThenStatement
| ifThenElseStatement
| whileStatement
| forStatement
;
statementNoShortIf
: statementWithoutTrailingSubstatement
| labeledStatementNoShortIf
| ifThenElseStatementNoShortIf
| whileStatementNoShortIf
| forStatementNoShortIf
;
statementWithoutTrailingSubstatement
: block
| emptyStatement
| expressionStatement
| assertStatement
| switchStatement
| doStatement
| breakStatement
| continueStatement
| returnStatement
| synchronizedStatement
| throwStatement
| tryStatement
;
emptyStatement
: ';'
;
labeledStatement
: Identifier ':' statement
;
labeledStatementNoShortIf
: Identifier ':' statementNoShortIf
;
expressionStatement
: statementExpression ';'
;
statementExpression
: assignment
| preIncrementExpression
| preDecrementExpression
| postIncrementExpression
| postDecrementExpression
| methodInvocation
| classInstanceCreationExpression
;
ifThenStatement
: 'if' '(' expression ')' statement
;
ifThenElseStatement
: 'if' '(' expression ')' statementNoShortIf 'else' statement
;
ifThenElseStatementNoShortIf
: 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf
;
assertStatement
: 'assert' expression ';'
| 'assert' expression ':' expression ';'
;
switchStatement
: 'switch' '(' expression ')' switchBlock
;
switchBlock
: '{' switchBlockStatementGroup* switchLabel* '}'
;
switchBlockStatementGroup
: switchLabels blockStatements
;
switchLabels
: switchLabel switchLabel*
;
switchLabel
: 'case' constantExpression ':'
| 'case' enumConstantName ':'
| 'default' ':'
;
enumConstantName
: Identifier
;
whileStatement
: 'while' '(' expression ')' statement
;
whileStatementNoShortIf
: 'while' '(' expression ')' statementNoShortIf
;
doStatement
: 'do' statement 'while' '(' expression ')' ';'
;
forStatement
: basicForStatement
| enhancedForStatement
;
forStatementNoShortIf
: basicForStatementNoShortIf
| enhancedForStatementNoShortIf
;
basicForStatement
: 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement
;
basicForStatementNoShortIf
: 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf
;
forInit
: statementExpressionList
| localVariableDeclaration
;
forUpdate
: statementExpressionList
;
statementExpressionList
: statementExpression (',' statementExpression)*
;
enhancedForStatement
: 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statement
;
enhancedForStatementNoShortIf
: 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statementNoShortIf
;
breakStatement
: 'break' Identifier? ';'
;
continueStatement
: 'continue' Identifier? ';'
;
returnStatement
: 'return' expression? ';'
;
throwStatement
: 'throw' expression ';'
;
synchronizedStatement
: 'synchronized' '(' expression ')' block
;
tryStatement
: 'try' block catches
| 'try' block catches? finally_
| tryWithResourcesStatement
;
catches
: catchClause catchClause*
;
catchClause
: 'catch' '(' catchFormalParameter ')' block
;
catchFormalParameter
: variableModifier* catchType variableDeclaratorId
;
catchType
: unannClassType ('|' classType)*
;
finally_
: 'finally' block
;
tryWithResourcesStatement
: 'try' resourceSpecification block catches? finally_?
;
resourceSpecification
: '(' resourceList ';'? ')'
;
resourceList
: resource (';' resource)*
;
resource
: variableModifier* unannType variableDeclaratorId '=' expression
;
/*
* Productions from §15 (Expressions)
*/
primary
: ( primaryNoNewArray_lfno_primary
| arrayCreationExpression
)
( primaryNoNewArray_lf_primary
)*
;
primaryNoNewArray
: literal
| typeName ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression
| fieldAccess
| arrayAccess
| methodInvocation
| methodReference
;
primaryNoNewArray_lf_arrayAccess
:
;
primaryNoNewArray_lfno_arrayAccess
: literal
| typeName ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression
| fieldAccess
| methodInvocation
| methodReference
;
primaryNoNewArray_lf_primary
: classInstanceCreationExpression_lf_primary
| fieldAccess_lf_primary
| arrayAccess_lf_primary
| methodInvocation_lf_primary
| methodReference_lf_primary
;
primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary
:
;
primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary
: classInstanceCreationExpression_lf_primary
| fieldAccess_lf_primary
| methodInvocation_lf_primary
| methodReference_lf_primary
;
primaryNoNewArray_lfno_primary
: literal
| typeName ('[' ']')* '.' 'class'
| unannPrimitiveType ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression_lfno_primary
| fieldAccess_lfno_primary
| arrayAccess_lfno_primary
| methodInvocation_lfno_primary
| methodReference_lfno_primary
;
primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary
:
;
primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary
: literal
| typeName ('[' ']')* '.' 'class'
| unannPrimitiveType ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression_lfno_primary
| fieldAccess_lfno_primary
| methodInvocation_lfno_primary
| methodReference_lfno_primary
;
classInstanceCreationExpression
: 'new' typeArguments? annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
| expressionName '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
| primary '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
;
classInstanceCreationExpression_lf_primary
: '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
;
classInstanceCreationExpression_lfno_primary
: 'new' typeArguments? annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
| expressionName '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
;
typeArgumentsOrDiamond
: typeArguments
| '<' '>'
;
fieldAccess
: primary '.' Identifier
| 'super' '.' Identifier
| typeName '.' 'super' '.' Identifier
;
fieldAccess_lf_primary
: '.' Identifier
;
fieldAccess_lfno_primary
: 'super' '.' Identifier
| typeName '.' 'super' '.' Identifier
;
arrayAccess
: ( expressionName '[' expression ']'
| primaryNoNewArray_lfno_arrayAccess '[' expression ']'
)
( primaryNoNewArray_lf_arrayAccess '[' expression ']'
)*
;
arrayAccess_lf_primary
: ( primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary '[' expression ']'
)
( primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary '[' expression ']'
)*
;
arrayAccess_lfno_primary
: ( expressionName '[' expression ']'
| primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary '[' expression ']'
)
( primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary '[' expression ']'
)*
;
methodInvocation
: methodName '(' argumentList? ')'
| typeName '.' typeArguments? Identifier '(' argumentList? ')'
| expressionName '.' typeArguments? Identifier '(' argumentList? ')'
| primary '.' typeArguments? Identifier '(' argumentList? ')'
| 'super' '.' typeArguments? Identifier '(' argumentList? ')'
| typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')'
;
methodInvocation_lf_primary
: '.' typeArguments? Identifier '(' argumentList? ')'
;
methodInvocation_lfno_primary
: methodName '(' argumentList? ')'
| typeName '.' typeArguments? Identifier '(' argumentList? ')'
| expressionName '.' typeArguments? Identifier '(' argumentList? ')'
| 'super' '.' typeArguments? Identifier '(' argumentList? ')'
| typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')'
;
argumentList
: expression (',' expression)*
;
methodReference
: expressionName '::' typeArguments? Identifier
| referenceType '::' typeArguments? Identifier
| primary '::' typeArguments? Identifier
| 'super' '::' typeArguments? Identifier
| typeName '.' 'super' '::' typeArguments? Identifier
| classType '::' typeArguments? 'new'
| arrayType '::' 'new'
;
methodReference_lf_primary
: '::' typeArguments? Identifier
;
methodReference_lfno_primary
: expressionName '::' typeArguments? Identifier
| referenceType '::' typeArguments? Identifier
| 'super' '::' typeArguments? Identifier
| typeName '.' 'super' '::' typeArguments? Identifier
| classType '::' typeArguments? 'new'
| arrayType '::' 'new'
;
arrayCreationExpression
: 'new' primitiveType dimExprs dims?
| 'new' classOrInterfaceType dimExprs dims?
| 'new' primitiveType dims arrayInitializer
| 'new' classOrInterfaceType dims arrayInitializer
;
dimExprs
: dimExpr dimExpr*
;
dimExpr
: annotation* '[' expression ']'
;
constantExpression
: expression
;
expression
: lambdaExpression
| assignmentExpression
;
lambdaExpression
: lambdaParameters '->' lambdaBody
;
lambdaParameters
: Identifier
| '(' formalParameterList? ')'
| '(' inferredFormalParameterList ')'
;
inferredFormalParameterList
: Identifier (',' Identifier)*
;
lambdaBody
: expression
| block
;
assignmentExpression
: conditionalExpression
| assignment
;
assignment
: leftHandSide assignmentOperator expression
;
leftHandSide
: expressionName
| fieldAccess
| arrayAccess
;
assignmentOperator
: '='
| '*='
| '/='
| '%='
| '+='
| '-='
| '<<='
| '>>='
| '>>>='
| '&='
| '^='
| '|='
;
conditionalExpression
: conditionalOrExpression
| conditionalOrExpression '?' expression ':' conditionalExpression
;
conditionalOrExpression
: conditionalAndExpression
| conditionalOrExpression '||' conditionalAndExpression
;
conditionalAndExpression
: inclusiveOrExpression
| conditionalAndExpression '&&' inclusiveOrExpression
;
inclusiveOrExpression
: exclusiveOrExpression
| inclusiveOrExpression '|' exclusiveOrExpression
;
exclusiveOrExpression
: andExpression
| exclusiveOrExpression '^' andExpression
;
andExpression
: equalityExpression
| andExpression '&' equalityExpression
;
equalityExpression
: relationalExpression
| equalityExpression '==' relationalExpression
| equalityExpression '!=' relationalExpression
;
relationalExpression
: shiftExpression
| relationalExpression '<' shiftExpression
| relationalExpression '>' shiftExpression
| relationalExpression '<=' shiftExpression
| relationalExpression '>=' shiftExpression
| relationalExpression 'instanceof' referenceType
;
shiftExpression
: additiveExpression
| shiftExpression '<' '<' additiveExpression
| shiftExpression '>' '>' additiveExpression
| shiftExpression '>' '>' '>' additiveExpression
;
additiveExpression
: multiplicativeExpression
| additiveExpression '+' multiplicativeExpression
| additiveExpression '-' multiplicativeExpression
;
multiplicativeExpression
: unaryExpression
| multiplicativeExpression '*' unaryExpression
| multiplicativeExpression '/' unaryExpression
| multiplicativeExpression '%' unaryExpression
;
unaryExpression
: preIncrementExpression
| preDecrementExpression
| '+' unaryExpression
| '-' unaryExpression
| unaryExpressionNotPlusMinus
;
preIncrementExpression
: '++' unaryExpression
;
preDecrementExpression
: '--' unaryExpression
;
unaryExpressionNotPlusMinus
: postfixExpression
| '~' unaryExpression
| '!' unaryExpression
| castExpression
;
postfixExpression
: ( primary
| expressionName
)
( postIncrementExpression_lf_postfixExpression
| postDecrementExpression_lf_postfixExpression
)*
;
postIncrementExpression
: postfixExpression '++'
;
postIncrementExpression_lf_postfixExpression
: '++'
;
postDecrementExpression
: postfixExpression '--'
;
postDecrementExpression_lf_postfixExpression
: '--'
;
castExpression
: '(' primitiveType ')' unaryExpression
| '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus
| '(' referenceType additionalBound* ')' lambdaExpression
; | 25,474 | ANTLR | .g4 | 1,104 | 21.047101 | 133 | 0.772051 | jsanzmex/java-nr-extensions-extractor | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 9dadeea7a09925ba4ba596889c3fec8ae1ac7cc3bc6d7958457e6dee2201ccd6 | false | false | false | false |
162 | Java8Lexer.g4 | jsanzmex_java-nr-extensions-extractor/src/main/antlr4/com/sopristec/extractor/Java8Lexer.g4 | /*
* [The "BSD license"]
* Copyright (c) 2014 Terence Parr
* Copyright (c) 2014 Sam Harwell
* Copyright (c) 2019 Student Main (Make it universal)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* A Java 8 grammar for ANTLR 4 derived from the Java Language Specification
* chapter 19.
*
* NOTE: This grammar results in a generated parser that is much slower
* than the Java 7 grammar in the grammars-v4/java directory. This
* one is, however, extremely close to the spec.
*
* You can test with
*
* $ antlr4 Java8.g4
* $ javac *.java
* $ grun Java8 compilationUnit *.java
*
* Or,
~/antlr/code/grammars-v4/java8 $ java Test .
/Users/parrt/antlr/code/grammars-v4/java8/./Java8BaseListener.java
/Users/parrt/antlr/code/grammars-v4/java8/./Java8Lexer.java
/Users/parrt/antlr/code/grammars-v4/java8/./Java8Listener.java
/Users/parrt/antlr/code/grammars-v4/java8/./Java8Parser.java
/Users/parrt/antlr/code/grammars-v4/java8/./Test.java
Total lexer+parser time 30844ms.
*/
lexer grammar Java8Lexer;
// LEXER
// §3.9 Keywords
ABSTRACT : 'abstract';
ASSERT : 'assert';
BOOLEAN : 'boolean';
BREAK : 'break';
BYTE : 'byte';
CASE : 'case';
CATCH : 'catch';
CHAR : 'char';
CLASS : 'class';
CONST : 'const';
CONTINUE : 'continue';
DEFAULT : 'default';
DO : 'do';
DOUBLE : 'double';
ELSE : 'else';
ENUM : 'enum';
EXTENDS : 'extends';
FINAL : 'final';
FINALLY : 'finally';
FLOAT : 'float';
FOR : 'for';
IF : 'if';
GOTO : 'goto';
IMPLEMENTS : 'implements';
IMPORT : 'import';
INSTANCEOF : 'instanceof';
INT : 'int';
INTERFACE : 'interface';
LONG : 'long';
NATIVE : 'native';
NEW : 'new';
PACKAGE : 'package';
PRIVATE : 'private';
PROTECTED : 'protected';
PUBLIC : 'public';
RETURN : 'return';
SHORT : 'short';
STATIC : 'static';
STRICTFP : 'strictfp';
SUPER : 'super';
SWITCH : 'switch';
SYNCHRONIZED : 'synchronized';
THIS : 'this';
THROW : 'throw';
THROWS : 'throws';
TRANSIENT : 'transient';
TRY : 'try';
VOID : 'void';
VOLATILE : 'volatile';
WHILE : 'while';
// §3.10.1 Integer Literals
IntegerLiteral
: DecimalIntegerLiteral
| HexIntegerLiteral
| OctalIntegerLiteral
| BinaryIntegerLiteral
;
fragment
DecimalIntegerLiteral
: DecimalNumeral IntegerTypeSuffix?
;
fragment
HexIntegerLiteral
: HexNumeral IntegerTypeSuffix?
;
fragment
OctalIntegerLiteral
: OctalNumeral IntegerTypeSuffix?
;
fragment
BinaryIntegerLiteral
: BinaryNumeral IntegerTypeSuffix?
;
fragment
IntegerTypeSuffix
: [lL]
;
fragment
DecimalNumeral
: '0'
| NonZeroDigit (Digits? | Underscores Digits)
;
fragment
Digits
: Digit (DigitsAndUnderscores? Digit)?
;
fragment
Digit
: '0'
| NonZeroDigit
;
fragment
NonZeroDigit
: [1-9]
;
fragment
DigitsAndUnderscores
: DigitOrUnderscore+
;
fragment
DigitOrUnderscore
: Digit
| '_'
;
fragment
Underscores
: '_'+
;
fragment
HexNumeral
: '0' [xX] HexDigits
;
fragment
HexDigits
: HexDigit (HexDigitsAndUnderscores? HexDigit)?
;
fragment
HexDigit
: [0-9a-fA-F]
;
fragment
HexDigitsAndUnderscores
: HexDigitOrUnderscore+
;
fragment
HexDigitOrUnderscore
: HexDigit
| '_'
;
fragment
OctalNumeral
: '0' Underscores? OctalDigits
;
fragment
OctalDigits
: OctalDigit (OctalDigitsAndUnderscores? OctalDigit)?
;
fragment
OctalDigit
: [0-7]
;
fragment
OctalDigitsAndUnderscores
: OctalDigitOrUnderscore+
;
fragment
OctalDigitOrUnderscore
: OctalDigit
| '_'
;
fragment
BinaryNumeral
: '0' [bB] BinaryDigits
;
fragment
BinaryDigits
: BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)?
;
fragment
BinaryDigit
: [01]
;
fragment
BinaryDigitsAndUnderscores
: BinaryDigitOrUnderscore+
;
fragment
BinaryDigitOrUnderscore
: BinaryDigit
| '_'
;
// §3.10.2 Floating-Point Literals
FloatingPointLiteral
: DecimalFloatingPointLiteral
| HexadecimalFloatingPointLiteral
;
fragment
DecimalFloatingPointLiteral
: Digits '.' Digits? ExponentPart? FloatTypeSuffix?
| '.' Digits ExponentPart? FloatTypeSuffix?
| Digits ExponentPart FloatTypeSuffix?
| Digits FloatTypeSuffix
;
fragment
ExponentPart
: ExponentIndicator SignedInteger
;
fragment
ExponentIndicator
: [eE]
;
fragment
SignedInteger
: Sign? Digits
;
fragment
Sign
: [+-]
;
fragment
FloatTypeSuffix
: [fFdD]
;
fragment
HexadecimalFloatingPointLiteral
: HexSignificand BinaryExponent FloatTypeSuffix?
;
fragment
HexSignificand
: HexNumeral '.'?
| '0' [xX] HexDigits? '.' HexDigits
;
fragment
BinaryExponent
: BinaryExponentIndicator SignedInteger
;
fragment
BinaryExponentIndicator
: [pP]
;
// §3.10.3 Boolean Literals
BooleanLiteral
: 'true'
| 'false'
;
// §3.10.4 Character Literals
CharacterLiteral
: '\'' SingleCharacter '\''
| '\'' EscapeSequence '\''
;
fragment
SingleCharacter
: ~['\\\r\n]
;
// §3.10.5 String Literals
StringLiteral
: '"' StringCharacters? '"'
;
fragment
StringCharacters
: StringCharacter+
;
fragment
StringCharacter
: ~["\\\r\n]
| EscapeSequence
;
// §3.10.6 Escape Sequences for Character and String Literals
fragment
EscapeSequence
: '\\' [btnfr"'\\]
| OctalEscape
| UnicodeEscape // This is not in the spec but prevents having to preprocess the input
;
fragment
OctalEscape
: '\\' OctalDigit
| '\\' OctalDigit OctalDigit
| '\\' ZeroToThree OctalDigit OctalDigit
;
fragment
ZeroToThree
: [0-3]
;
// This is not in the spec but prevents having to preprocess the input
fragment
UnicodeEscape
: '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit
;
// §3.10.7 The Null Literal
NullLiteral
: 'null'
;
// §3.11 Separators
LPAREN : '(';
RPAREN : ')';
LBRACE : '{';
RBRACE : '}';
LBRACK : '[';
RBRACK : ']';
SEMI : ';';
COMMA : ',';
DOT : '.';
// §3.12 Operators
ASSIGN : '=';
GT : '>';
LT : '<';
BANG : '!';
TILDE : '~';
QUESTION : '?';
COLON : ':';
EQUAL : '==';
LE : '<=';
GE : '>=';
NOTEQUAL : '!=';
AND : '&&';
OR : '||';
INC : '++';
DEC : '--';
ADD : '+';
SUB : '-';
MUL : '*';
DIV : '/';
BITAND : '&';
BITOR : '|';
CARET : '^';
MOD : '%';
ARROW : '->';
COLONCOLON : '::';
ADD_ASSIGN : '+=';
SUB_ASSIGN : '-=';
MUL_ASSIGN : '*=';
DIV_ASSIGN : '/=';
AND_ASSIGN : '&=';
OR_ASSIGN : '|=';
XOR_ASSIGN : '^=';
MOD_ASSIGN : '%=';
LSHIFT_ASSIGN : '<<=';
RSHIFT_ASSIGN : '>>=';
URSHIFT_ASSIGN : '>>>=';
// §3.8 Identifiers (must appear after all keywords in the grammar)
Identifier
: IdentifierStart IdentifierPart*
;
/*
fragment
JavaLetter
: [a-zA-Z$_] // these are the "java letters" below 0x7F
| // covers all characters above 0x7F which are not a surrogate
~[\u0000-\u007F\uD800-\uDBFF] {this.wasJavaIdentiferStart()}?
| // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
[\uD800-\uDBFF] [\uDC00-\uDFFF] {this.wasJavaIdentiferStartUTF16()}?
;
fragment
JavaLetterOrDigit
: [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F
| // covers all characters above 0x7F which are not a surrogate
~[\u0000-\u007F\uD800-\uDBFF] {this.wasJavaIdentiferPart()}?
| // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
[\uD800-\uDBFF] [\uDC00-\uDFFF] {this.wasJavaIdentiferPartUTF16()}?
;*/
// Dropped SMP support as ANTLR has no native support for it
fragment IdentifierStart
: [\u0024]
| [\u0041-\u005A]
| [\u005F]
| [\u0061-\u007A]
| [\u00A2-\u00A5]
| [\u00AA]
| [\u00B5]
| [\u00BA]
| [\u00C0-\u00D6]
| [\u00D8-\u00F6]
| [\u00F8-\u02C1]
| [\u02C6-\u02D1]
| [\u02E0-\u02E4]
| [\u02EC]
| [\u02EE]
| [\u0370-\u0374]
| [\u0376-\u0377]
| [\u037A-\u037D]
| [\u037F]
| [\u0386]
| [\u0388-\u038A]
| [\u038C]
| [\u038E-\u03A1]
| [\u03A3-\u03F5]
| [\u03F7-\u0481]
| [\u048A-\u052F]
| [\u0531-\u0556]
| [\u0559]
| [\u0561-\u0587]
| [\u058F]
| [\u05D0-\u05EA]
| [\u05F0-\u05F2]
| [\u060B]
| [\u0620-\u064A]
| [\u066E-\u066F]
| [\u0671-\u06D3]
| [\u06D5]
| [\u06E5-\u06E6]
| [\u06EE-\u06EF]
| [\u06FA-\u06FC]
| [\u06FF]
| [\u0710]
| [\u0712-\u072F]
| [\u074D-\u07A5]
| [\u07B1]
| [\u07CA-\u07EA]
| [\u07F4-\u07F5]
| [\u07FA]
| [\u0800-\u0815]
| [\u081A]
| [\u0824]
| [\u0828]
| [\u0840-\u0858]
| [\u0860-\u086A]
| [\u08A0-\u08B4]
| [\u08B6-\u08BD]
| [\u0904-\u0939]
| [\u093D]
| [\u0950]
| [\u0958-\u0961]
| [\u0971-\u0980]
| [\u0985-\u098C]
| [\u098F-\u0990]
| [\u0993-\u09A8]
| [\u09AA-\u09B0]
| [\u09B2]
| [\u09B6-\u09B9]
| [\u09BD]
| [\u09CE]
| [\u09DC-\u09DD]
| [\u09DF-\u09E1]
| [\u09F0-\u09F3]
| [\u09FB-\u09FC]
| [\u0A05-\u0A0A]
| [\u0A0F-\u0A10]
| [\u0A13-\u0A28]
| [\u0A2A-\u0A30]
| [\u0A32-\u0A33]
| [\u0A35-\u0A36]
| [\u0A38-\u0A39]
| [\u0A59-\u0A5C]
| [\u0A5E]
| [\u0A72-\u0A74]
| [\u0A85-\u0A8D]
| [\u0A8F-\u0A91]
| [\u0A93-\u0AA8]
| [\u0AAA-\u0AB0]
| [\u0AB2-\u0AB3]
| [\u0AB5-\u0AB9]
| [\u0ABD]
| [\u0AD0]
| [\u0AE0-\u0AE1]
| [\u0AF1]
| [\u0AF9]
| [\u0B05-\u0B0C]
| [\u0B0F-\u0B10]
| [\u0B13-\u0B28]
| [\u0B2A-\u0B30]
| [\u0B32-\u0B33]
| [\u0B35-\u0B39]
| [\u0B3D]
| [\u0B5C-\u0B5D]
| [\u0B5F-\u0B61]
| [\u0B71]
| [\u0B83]
| [\u0B85-\u0B8A]
| [\u0B8E-\u0B90]
| [\u0B92-\u0B95]
| [\u0B99-\u0B9A]
| [\u0B9C]
| [\u0B9E-\u0B9F]
| [\u0BA3-\u0BA4]
| [\u0BA8-\u0BAA]
| [\u0BAE-\u0BB9]
| [\u0BD0]
| [\u0BF9]
| [\u0C05-\u0C0C]
| [\u0C0E-\u0C10]
| [\u0C12-\u0C28]
| [\u0C2A-\u0C39]
| [\u0C3D]
| [\u0C58-\u0C5A]
| [\u0C60-\u0C61]
| [\u0C80]
| [\u0C85-\u0C8C]
| [\u0C8E-\u0C90]
| [\u0C92-\u0CA8]
| [\u0CAA-\u0CB3]
| [\u0CB5-\u0CB9]
| [\u0CBD]
| [\u0CDE]
| [\u0CE0-\u0CE1]
| [\u0CF1-\u0CF2]
| [\u0D05-\u0D0C]
| [\u0D0E-\u0D10]
| [\u0D12-\u0D3A]
| [\u0D3D]
| [\u0D4E]
| [\u0D54-\u0D56]
| [\u0D5F-\u0D61]
| [\u0D7A-\u0D7F]
| [\u0D85-\u0D96]
| [\u0D9A-\u0DB1]
| [\u0DB3-\u0DBB]
| [\u0DBD]
| [\u0DC0-\u0DC6]
| [\u0E01-\u0E30]
| [\u0E32-\u0E33]
| [\u0E3F-\u0E46]
| [\u0E81-\u0E82]
| [\u0E84]
| [\u0E87-\u0E88]
| [\u0E8A]
| [\u0E8D]
| [\u0E94-\u0E97]
| [\u0E99-\u0E9F]
| [\u0EA1-\u0EA3]
| [\u0EA5]
| [\u0EA7]
| [\u0EAA-\u0EAB]
| [\u0EAD-\u0EB0]
| [\u0EB2-\u0EB3]
| [\u0EBD]
| [\u0EC0-\u0EC4]
| [\u0EC6]
| [\u0EDC-\u0EDF]
| [\u0F00]
| [\u0F40-\u0F47]
| [\u0F49-\u0F6C]
| [\u0F88-\u0F8C]
| [\u1000-\u102A]
| [\u103F]
| [\u1050-\u1055]
| [\u105A-\u105D]
| [\u1061]
| [\u1065-\u1066]
| [\u106E-\u1070]
| [\u1075-\u1081]
| [\u108E]
| [\u10A0-\u10C5]
| [\u10C7]
| [\u10CD]
| [\u10D0-\u10FA]
| [\u10FC-\u1248]
| [\u124A-\u124D]
| [\u1250-\u1256]
| [\u1258]
| [\u125A-\u125D]
| [\u1260-\u1288]
| [\u128A-\u128D]
| [\u1290-\u12B0]
| [\u12B2-\u12B5]
| [\u12B8-\u12BE]
| [\u12C0]
| [\u12C2-\u12C5]
| [\u12C8-\u12D6]
| [\u12D8-\u1310]
| [\u1312-\u1315]
| [\u1318-\u135A]
| [\u1380-\u138F]
| [\u13A0-\u13F5]
| [\u13F8-\u13FD]
| [\u1401-\u166C]
| [\u166F-\u167F]
| [\u1681-\u169A]
| [\u16A0-\u16EA]
| [\u16EE-\u16F8]
| [\u1700-\u170C]
| [\u170E-\u1711]
| [\u1720-\u1731]
| [\u1740-\u1751]
| [\u1760-\u176C]
| [\u176E-\u1770]
| [\u1780-\u17B3]
| [\u17D7]
| [\u17DB-\u17DC]
| [\u1820-\u1877]
| [\u1880-\u1884]
| [\u1887-\u18A8]
| [\u18AA]
| [\u18B0-\u18F5]
| [\u1900-\u191E]
| [\u1950-\u196D]
| [\u1970-\u1974]
| [\u1980-\u19AB]
| [\u19B0-\u19C9]
| [\u1A00-\u1A16]
| [\u1A20-\u1A54]
| [\u1AA7]
| [\u1B05-\u1B33]
| [\u1B45-\u1B4B]
| [\u1B83-\u1BA0]
| [\u1BAE-\u1BAF]
| [\u1BBA-\u1BE5]
| [\u1C00-\u1C23]
| [\u1C4D-\u1C4F]
| [\u1C5A-\u1C7D]
| [\u1C80-\u1C88]
| [\u1CE9-\u1CEC]
| [\u1CEE-\u1CF1]
| [\u1CF5-\u1CF6]
| [\u1D00-\u1DBF]
| [\u1E00-\u1F15]
| [\u1F18-\u1F1D]
| [\u1F20-\u1F45]
| [\u1F48-\u1F4D]
| [\u1F50-\u1F57]
| [\u1F59]
| [\u1F5B]
| [\u1F5D]
| [\u1F5F-\u1F7D]
| [\u1F80-\u1FB4]
| [\u1FB6-\u1FBC]
| [\u1FBE]
| [\u1FC2-\u1FC4]
| [\u1FC6-\u1FCC]
| [\u1FD0-\u1FD3]
| [\u1FD6-\u1FDB]
| [\u1FE0-\u1FEC]
| [\u1FF2-\u1FF4]
| [\u1FF6-\u1FFC]
| [\u203F-\u2040]
| [\u2054]
| [\u2071]
| [\u207F]
| [\u2090-\u209C]
| [\u20A0-\u20BF]
| [\u2102]
| [\u2107]
| [\u210A-\u2113]
| [\u2115]
| [\u2119-\u211D]
| [\u2124]
| [\u2126]
| [\u2128]
| [\u212A-\u212D]
| [\u212F-\u2139]
| [\u213C-\u213F]
| [\u2145-\u2149]
| [\u214E]
| [\u2160-\u2188]
| [\u2C00-\u2C2E]
| [\u2C30-\u2C5E]
| [\u2C60-\u2CE4]
| [\u2CEB-\u2CEE]
| [\u2CF2-\u2CF3]
| [\u2D00-\u2D25]
| [\u2D27]
| [\u2D2D]
| [\u2D30-\u2D67]
| [\u2D6F]
| [\u2D80-\u2D96]
| [\u2DA0-\u2DA6]
| [\u2DA8-\u2DAE]
| [\u2DB0-\u2DB6]
| [\u2DB8-\u2DBE]
| [\u2DC0-\u2DC6]
| [\u2DC8-\u2DCE]
| [\u2DD0-\u2DD6]
| [\u2DD8-\u2DDE]
| [\u2E2F]
| [\u3005-\u3007]
| [\u3021-\u3029]
| [\u3031-\u3035]
| [\u3038-\u303C]
| [\u3041-\u3096]
| [\u309D-\u309F]
| [\u30A1-\u30FA]
| [\u30FC-\u30FF]
| [\u3105-\u312E]
| [\u3131-\u318E]
| [\u31A0-\u31BA]
| [\u31F0-\u31FF]
| [\u3400-\u4DB5]
| [\u4E00-\u9FEA]
| [\uA000-\uA48C]
| [\uA4D0-\uA4FD]
| [\uA500-\uA60C]
| [\uA610-\uA61F]
| [\uA62A-\uA62B]
| [\uA640-\uA66E]
| [\uA67F-\uA69D]
| [\uA6A0-\uA6EF]
| [\uA717-\uA71F]
| [\uA722-\uA788]
| [\uA78B-\uA7AE]
| [\uA7B0-\uA7B7]
| [\uA7F7-\uA801]
| [\uA803-\uA805]
| [\uA807-\uA80A]
| [\uA80C-\uA822]
| [\uA838]
| [\uA840-\uA873]
| [\uA882-\uA8B3]
| [\uA8F2-\uA8F7]
| [\uA8FB]
| [\uA8FD]
| [\uA90A-\uA925]
| [\uA930-\uA946]
| [\uA960-\uA97C]
| [\uA984-\uA9B2]
| [\uA9CF]
| [\uA9E0-\uA9E4]
| [\uA9E6-\uA9EF]
| [\uA9FA-\uA9FE]
| [\uAA00-\uAA28]
| [\uAA40-\uAA42]
| [\uAA44-\uAA4B]
| [\uAA60-\uAA76]
| [\uAA7A]
| [\uAA7E-\uAAAF]
| [\uAAB1]
| [\uAAB5-\uAAB6]
| [\uAAB9-\uAABD]
| [\uAAC0]
| [\uAAC2]
| [\uAADB-\uAADD]
| [\uAAE0-\uAAEA]
| [\uAAF2-\uAAF4]
| [\uAB01-\uAB06]
| [\uAB09-\uAB0E]
| [\uAB11-\uAB16]
| [\uAB20-\uAB26]
| [\uAB28-\uAB2E]
| [\uAB30-\uAB5A]
| [\uAB5C-\uAB65]
| [\uAB70-\uABE2]
| [\uAC00-\uD7A3]
| [\uD7B0-\uD7C6]
| [\uD7CB-\uD7FB]
| [\uF900-\uFA6D]
| [\uFA70-\uFAD9]
| [\uFB00-\uFB06]
| [\uFB13-\uFB17]
| [\uFB1D]
| [\uFB1F-\uFB28]
| [\uFB2A-\uFB36]
| [\uFB38-\uFB3C]
| [\uFB3E]
| [\uFB40-\uFB41]
| [\uFB43-\uFB44]
| [\uFB46-\uFBB1]
| [\uFBD3-\uFD3D]
| [\uFD50-\uFD8F]
| [\uFD92-\uFDC7]
| [\uFDF0-\uFDFC]
| [\uFE33-\uFE34]
| [\uFE4D-\uFE4F]
| [\uFE69]
| [\uFE70-\uFE74]
| [\uFE76-\uFEFC]
| [\uFF04]
| [\uFF21-\uFF3A]
| [\uFF3F]
| [\uFF41-\uFF5A]
| [\uFF66-\uFFBE]
| [\uFFC2-\uFFC7]
| [\uFFCA-\uFFCF]
| [\uFFD2-\uFFD7]
| [\uFFDA-\uFFDC]
| [\uFFE0-\uFFE1]
| [\uFFE5-\uFFE6]
;
fragment IdentifierPart
: IdentifierStart
| [\u0030-\u0039]
| [\u007F-\u009F]
| [\u00AD]
| [\u0300-\u036F]
| [\u0483-\u0487]
| [\u0591-\u05BD]
| [\u05BF]
| [\u05C1-\u05C2]
| [\u05C4-\u05C5]
| [\u05C7]
| [\u0600-\u0605]
| [\u0610-\u061A]
| [\u061C]
| [\u064B-\u0669]
| [\u0670]
| [\u06D6-\u06DD]
| [\u06DF-\u06E4]
| [\u06E7-\u06E8]
| [\u06EA-\u06ED]
| [\u06F0-\u06F9]
| [\u070F]
| [\u0711]
| [\u0730-\u074A]
| [\u07A6-\u07B0]
| [\u07C0-\u07C9]
| [\u07EB-\u07F3]
| [\u0816-\u0819]
| [\u081B-\u0823]
| [\u0825-\u0827]
| [\u0829-\u082D]
| [\u0859-\u085B]
| [\u08D4-\u0903]
| [\u093A-\u093C]
| [\u093E-\u094F]
| [\u0951-\u0957]
| [\u0962-\u0963]
| [\u0966-\u096F]
| [\u0981-\u0983]
| [\u09BC]
| [\u09BE-\u09C4]
| [\u09C7-\u09C8]
| [\u09CB-\u09CD]
| [\u09D7]
| [\u09E2-\u09E3]
| [\u09E6-\u09EF]
| [\u0A01-\u0A03]
| [\u0A3C]
| [\u0A3E-\u0A42]
| [\u0A47-\u0A48]
| [\u0A4B-\u0A4D]
| [\u0A51]
| [\u0A66-\u0A71]
| [\u0A75]
| [\u0A81-\u0A83]
| [\u0ABC]
| [\u0ABE-\u0AC5]
| [\u0AC7-\u0AC9]
| [\u0ACB-\u0ACD]
| [\u0AE2-\u0AE3]
| [\u0AE6-\u0AEF]
| [\u0AFA-\u0AFF]
| [\u0B01-\u0B03]
| [\u0B3C]
| [\u0B3E-\u0B44]
| [\u0B47-\u0B48]
| [\u0B4B-\u0B4D]
| [\u0B56-\u0B57]
| [\u0B62-\u0B63]
| [\u0B66-\u0B6F]
| [\u0B82]
| [\u0BBE-\u0BC2]
| [\u0BC6-\u0BC8]
| [\u0BCA-\u0BCD]
| [\u0BD7]
| [\u0BE6-\u0BEF]
| [\u0C00-\u0C03]
| [\u0C3E-\u0C44]
| [\u0C46-\u0C48]
| [\u0C4A-\u0C4D]
| [\u0C55-\u0C56]
| [\u0C62-\u0C63]
| [\u0C66-\u0C6F]
| [\u0C81-\u0C83]
| [\u0CBC]
| [\u0CBE-\u0CC4]
| [\u0CC6-\u0CC8]
| [\u0CCA-\u0CCD]
| [\u0CD5-\u0CD6]
| [\u0CE2-\u0CE3]
| [\u0CE6-\u0CEF]
| [\u0D00-\u0D03]
| [\u0D3B-\u0D3C]
| [\u0D3E-\u0D44]
| [\u0D46-\u0D48]
| [\u0D4A-\u0D4D]
| [\u0D57]
| [\u0D62-\u0D63]
| [\u0D66-\u0D6F]
| [\u0D82-\u0D83]
| [\u0DCA]
| [\u0DCF-\u0DD4]
| [\u0DD6]
| [\u0DD8-\u0DDF]
| [\u0DE6-\u0DEF]
| [\u0DF2-\u0DF3]
| [\u0E31]
| [\u0E34-\u0E3A]
| [\u0E47-\u0E4E]
| [\u0E50-\u0E59]
| [\u0EB1]
| [\u0EB4-\u0EB9]
| [\u0EBB-\u0EBC]
| [\u0EC8-\u0ECD]
| [\u0ED0-\u0ED9]
| [\u0F18-\u0F19]
| [\u0F20-\u0F29]
| [\u0F35]
| [\u0F37]
| [\u0F39]
| [\u0F3E-\u0F3F]
| [\u0F71-\u0F84]
| [\u0F86-\u0F87]
| [\u0F8D-\u0F97]
| [\u0F99-\u0FBC]
| [\u0FC6]
| [\u102B-\u103E]
| [\u1040-\u1049]
| [\u1056-\u1059]
| [\u105E-\u1060]
| [\u1062-\u1064]
| [\u1067-\u106D]
| [\u1071-\u1074]
| [\u1082-\u108D]
| [\u108F-\u109D]
| [\u135D-\u135F]
| [\u1712-\u1714]
| [\u1732-\u1734]
| [\u1752-\u1753]
| [\u1772-\u1773]
| [\u17B4-\u17D3]
| [\u17DD]
| [\u17E0-\u17E9]
| [\u180B-\u180E]
| [\u1810-\u1819]
| [\u1885-\u1886]
| [\u18A9]
| [\u1920-\u192B]
| [\u1930-\u193B]
| [\u1946-\u194F]
| [\u19D0-\u19D9]
| [\u1A17-\u1A1B]
| [\u1A55-\u1A5E]
| [\u1A60-\u1A7C]
| [\u1A7F-\u1A89]
| [\u1A90-\u1A99]
| [\u1AB0-\u1ABD]
| [\u1B00-\u1B04]
| [\u1B34-\u1B44]
| [\u1B50-\u1B59]
| [\u1B6B-\u1B73]
| [\u1B80-\u1B82]
| [\u1BA1-\u1BAD]
| [\u1BB0-\u1BB9]
| [\u1BE6-\u1BF3]
| [\u1C24-\u1C37]
| [\u1C40-\u1C49]
| [\u1C50-\u1C59]
| [\u1CD0-\u1CD2]
| [\u1CD4-\u1CE8]
| [\u1CED]
| [\u1CF2-\u1CF4]
| [\u1CF7-\u1CF9]
| [\u1DC0-\u1DF9]
| [\u1DFB-\u1DFF]
| [\u200B-\u200F]
| [\u202A-\u202E]
| [\u2060-\u2064]
| [\u2066-\u206F]
| [\u20D0-\u20DC]
| [\u20E1]
| [\u20E5-\u20F0]
| [\u2CEF-\u2CF1]
| [\u2D7F]
| [\u2DE0-\u2DFF]
| [\u302A-\u302F]
| [\u3099-\u309A]
| [\uA620-\uA629]
| [\uA66F]
| [\uA674-\uA67D]
| [\uA69E-\uA69F]
| [\uA6F0-\uA6F1]
| [\uA802]
| [\uA806]
| [\uA80B]
| [\uA823-\uA827]
| [\uA880-\uA881]
| [\uA8B4-\uA8C5]
| [\uA8D0-\uA8D9]
| [\uA8E0-\uA8F1]
| [\uA900-\uA909]
| [\uA926-\uA92D]
| [\uA947-\uA953]
| [\uA980-\uA983]
| [\uA9B3-\uA9C0]
| [\uA9D0-\uA9D9]
| [\uA9E5]
| [\uA9F0-\uA9F9]
| [\uAA29-\uAA36]
| [\uAA43]
| [\uAA4C-\uAA4D]
| [\uAA50-\uAA59]
| [\uAA7B-\uAA7D]
| [\uAAB0]
| [\uAAB2-\uAAB4]
| [\uAAB7-\uAAB8]
| [\uAABE-\uAABF]
| [\uAAC1]
| [\uAAEB-\uAAEF]
| [\uAAF5-\uAAF6]
| [\uABE3-\uABEA]
| [\uABEC-\uABED]
| [\uABF0-\uABF9]
| [\uFB1E]
| [\uFE00-\uFE0F]
| [\uFE20-\uFE2F]
| [\uFEFF]
| [\uFF10-\uFF19]
| [\uFFF9-\uFFFB]
;
//
// Additional symbols not defined in the lexical specification
//
AT : '@';
ELLIPSIS : '...';
//
// Whitespace and comments
//
WS : [ \t\r\n\u000C]+ -> skip
;
COMMENT
: '/*' .*? '*/' -> skip
;
LINE_COMMENT
: '//' ~[\r\n]* -> skip
;
// ADDED BY JULIO SANCHEZ: Skips expressions created by 'javap' while decompiling a class: 'Compiled from "SomeFile.java"'
COMPILED_FROM
: 'Compiled from' .*? [\n]+ -> skip
;
| 20,061 | ANTLR | .g4 | 1,053 | 17.153846 | 122 | 0.624399 | jsanzmex/java-nr-extensions-extractor | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 7ab97587c1f689c81f84e677b1b385ec75d75976ac5a79cbf4655db733345fcf | false | false | false | false |
163 | JavaScriptLexer.g4 | luwrain_grammar/src/main/antlr4/org/luwrain/antlr/js/JavaScriptLexer.g4 | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 by Bart Kiers (original author) and Alexandre Vitorelli (contributor -> ported to CSharp)
* Copyright (c) 2017-2020 by Ivan Kochurkin (Positive Technologies):
added ECMAScript 6 support, cleared and transformed to the universal grammar.
* Copyright (c) 2018 by Juan Alvarez (contributor -> ported to Go)
* Copyright (c) 2019 by Student Main (contributor -> ES2020)
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false
// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine
// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true
lexer grammar JavaScriptLexer;
channels {
ERROR
}
options {
superClass = JavaScriptLexerBase;
}
// Insert here @header for C++ lexer.
HashBangLine : { this.IsStartOfFile()}? '#!' ~[\r\n\u2028\u2029]*; // only allowed at start
MultiLineComment : '/*' .*? '*/' -> channel(HIDDEN);
SingleLineComment : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN);
RegularExpressionLiteral:
'/' RegularExpressionFirstChar RegularExpressionChar* {this.IsRegexPossible()}? '/' IdentifierPart*
;
OpenBracket : '[';
CloseBracket : ']';
OpenParen : '(';
CloseParen : ')';
OpenBrace : '{' {this.ProcessOpenBrace();};
TemplateCloseBrace : {this.IsInTemplateString()}? '}' -> popMode;
CloseBrace : '}' {this.ProcessCloseBrace();};
SemiColon : ';';
Comma : ',';
Assign : '=';
QuestionMark : '?';
QuestionMarkDot : '?.';
Colon : ':';
Ellipsis : '...';
Dot : '.';
PlusPlus : '++';
MinusMinus : '--';
Plus : '+';
Minus : '-';
BitNot : '~';
Not : '!';
Multiply : '*';
Divide : '/';
Modulus : '%';
Power : '**';
NullCoalesce : '??';
Hashtag : '#';
RightShiftArithmetic : '>>';
LeftShiftArithmetic : '<<';
RightShiftLogical : '>>>';
LessThan : '<';
MoreThan : '>';
LessThanEquals : '<=';
GreaterThanEquals : '>=';
Equals_ : '==';
NotEquals : '!=';
IdentityEquals : '===';
IdentityNotEquals : '!==';
BitAnd : '&';
BitXOr : '^';
BitOr : '|';
And : '&&';
Or : '||';
MultiplyAssign : '*=';
DivideAssign : '/=';
ModulusAssign : '%=';
PlusAssign : '+=';
MinusAssign : '-=';
LeftShiftArithmeticAssign : '<<=';
RightShiftArithmeticAssign : '>>=';
RightShiftLogicalAssign : '>>>=';
BitAndAssign : '&=';
BitXorAssign : '^=';
BitOrAssign : '|=';
PowerAssign : '**=';
NullishCoalescingAssign : '??=';
ARROW : '=>';
/// Null Literals
NullLiteral: 'null';
/// Boolean Literals
BooleanLiteral: 'true' | 'false';
/// Numeric Literals
DecimalLiteral:
DecimalIntegerLiteral '.' [0-9] [0-9_]* ExponentPart?
| '.' [0-9] [0-9_]* ExponentPart?
| DecimalIntegerLiteral ExponentPart?
;
/// Numeric Literals
HexIntegerLiteral : '0' [xX] [0-9a-fA-F] HexDigit*;
OctalIntegerLiteral : '0' [0-7]+ {!this.IsStrictMode()}?;
OctalIntegerLiteral2 : '0' [oO] [0-7] [_0-7]*;
BinaryIntegerLiteral : '0' [bB] [01] [_01]*;
BigHexIntegerLiteral : '0' [xX] [0-9a-fA-F] HexDigit* 'n';
BigOctalIntegerLiteral : '0' [oO] [0-7] [_0-7]* 'n';
BigBinaryIntegerLiteral : '0' [bB] [01] [_01]* 'n';
BigDecimalIntegerLiteral : DecimalIntegerLiteral 'n';
/// Keywords
Break : 'break';
Do : 'do';
Instanceof : 'instanceof';
Typeof : 'typeof';
Case : 'case';
Else : 'else';
New : 'new';
Var : 'var';
Catch : 'catch';
Finally : 'finally';
Return : 'return';
Void : 'void';
Continue : 'continue';
For : 'for';
Switch : 'switch';
While : 'while';
Debugger : 'debugger';
Function_ : 'function';
This : 'this';
With : 'with';
Default : 'default';
If : 'if';
Throw : 'throw';
Delete : 'delete';
In : 'in';
Try : 'try';
As : 'as';
From : 'from';
Of : 'of';
Yield : 'yield';
YieldStar : 'yield*';
/// Future Reserved Words
Class : 'class';
Enum : 'enum';
Extends : 'extends';
Super : 'super';
Const : 'const';
Export : 'export';
Import : 'import';
Async : 'async';
Await : 'await';
/// The following tokens are also considered to be FutureReservedWords
/// when parsing strict mode
Implements : 'implements' {this.IsStrictMode()}?;
StrictLet : 'let' {this.IsStrictMode()}?;
NonStrictLet : 'let' {!this.IsStrictMode()}?;
Private : 'private' {this.IsStrictMode()}?;
Public : 'public' {this.IsStrictMode()}?;
Interface : 'interface' {this.IsStrictMode()}?;
Package : 'package' {this.IsStrictMode()}?;
Protected : 'protected' {this.IsStrictMode()}?;
Static : 'static' {this.IsStrictMode()}?;
/// Identifier Names and Identifiers
Identifier: IdentifierStart IdentifierPart*;
/// String Literals
StringLiteral:
('"' DoubleStringCharacter* '"' | '\'' SingleStringCharacter* '\'') {this.ProcessStringLiteral();}
;
BackTick: '`' {this.IncreaseTemplateDepth();} -> pushMode(TEMPLATE);
WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN);
LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN);
/// Comments
HtmlComment : '<!--' .*? '-->' -> channel(HIDDEN);
CDataComment : '<![CDATA[' .*? ']]>' -> channel(HIDDEN);
UnexpectedCharacter : . -> channel(ERROR);
mode TEMPLATE;
BackTickInside : '`' {this.DecreaseTemplateDepth();} -> type(BackTick), popMode;
TemplateStringStartExpression : '${' -> pushMode(DEFAULT_MODE);
TemplateStringAtom : ~[`];
// Fragment rules
fragment DoubleStringCharacter: ~["\\\r\n] | '\\' EscapeSequence | LineContinuation;
fragment SingleStringCharacter: ~['\\\r\n] | '\\' EscapeSequence | LineContinuation;
fragment EscapeSequence:
CharacterEscapeSequence
| '0' // no digit ahead! TODO
| HexEscapeSequence
| UnicodeEscapeSequence
| ExtendedUnicodeEscapeSequence
;
fragment CharacterEscapeSequence: SingleEscapeCharacter | NonEscapeCharacter;
fragment HexEscapeSequence: 'x' HexDigit HexDigit;
fragment UnicodeEscapeSequence:
'u' HexDigit HexDigit HexDigit HexDigit
| 'u' '{' HexDigit HexDigit+ '}'
;
fragment ExtendedUnicodeEscapeSequence: 'u' '{' HexDigit+ '}';
fragment SingleEscapeCharacter: ['"\\bfnrtv];
fragment NonEscapeCharacter: ~['"\\bfnrtv0-9xu\r\n];
fragment EscapeCharacter: SingleEscapeCharacter | [0-9] | [xu];
fragment LineContinuation: '\\' [\r\n\u2028\u2029]+;
fragment HexDigit: [_0-9a-fA-F];
fragment DecimalIntegerLiteral: '0' | [1-9] [0-9_]*;
fragment ExponentPart: [eE] [+-]? [0-9_]+;
fragment IdentifierPart: IdentifierStart | [\p{Mn}] | [\p{Nd}] | [\p{Pc}] | '\u200C' | '\u200D';
fragment IdentifierStart: [\p{L}] | [$_] | '\\' UnicodeEscapeSequence;
fragment RegularExpressionFirstChar:
~[*\r\n\u2028\u2029\\/[]
| RegularExpressionBackslashSequence
| '[' RegularExpressionClassChar* ']'
;
fragment RegularExpressionChar:
~[\r\n\u2028\u2029\\/[]
| RegularExpressionBackslashSequence
| '[' RegularExpressionClassChar* ']'
;
fragment RegularExpressionClassChar: ~[\r\n\u2028\u2029\]\\] | RegularExpressionBackslashSequence;
fragment RegularExpressionBackslashSequence: '\\' ~[\r\n\u2028\u2029]; | 9,215 | ANTLR | .g4 | 231 | 38.181818 | 138 | 0.607479 | luwrain/grammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | ee63a4b879d278ab6d7e9c72eb84dcc8401e97f0add457cacf19a01c2a317a56 | false | false | false | false |
164 | JavaScriptParser.g4 | luwrain_grammar/src/main/antlr4/org/luwrain/antlr/js/JavaScriptParser.g4 | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 by Bart Kiers (original author) and Alexandre Vitorelli (contributor -> ported to CSharp)
* Copyright (c) 2017-2020 by Ivan Kochurkin (Positive Technologies):
added ECMAScript 6 support, cleared and transformed to the universal grammar.
* Copyright (c) 2018 by Juan Alvarez (contributor -> ported to Go)
* Copyright (c) 2019 by Student Main (contributor -> ES2020)
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false
// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging
parser grammar JavaScriptParser;
// Insert here @header for C++ parser.
options {
tokenVocab = JavaScriptLexer;
superClass = JavaScriptParserBase;
}
program
: HashBangLine? sourceElements? EOF
;
sourceElement
: statement
;
statement
: block
| variableStatement
| importStatement
| exportStatement
| emptyStatement_
| classDeclaration
| functionDeclaration
| expressionStatement
| ifStatement
| iterationStatement
| continueStatement
| breakStatement
| returnStatement
| yieldStatement
| withStatement
| labelledStatement
| switchStatement
| throwStatement
| tryStatement
| debuggerStatement
;
block
: '{' statementList? '}'
;
statementList
: statement+
;
importStatement
: Import importFromBlock
;
importFromBlock
: importDefault? (importNamespace | importModuleItems) importFrom eos
| StringLiteral eos
;
importModuleItems
: '{' (importAliasName ',')* (importAliasName ','?)? '}'
;
importAliasName
: moduleExportName (As importedBinding)?
;
moduleExportName
: identifierName
| StringLiteral
;
// yield and await are permitted as BindingIdentifier in the grammar
importedBinding
: Identifier
| Yield
| Await
;
importDefault
: aliasName ','
;
importNamespace
: ('*' | identifierName) (As identifierName)?
;
importFrom
: From StringLiteral
;
aliasName
: identifierName (As identifierName)?
;
exportStatement
: Export Default? (exportFromBlock | declaration) eos # ExportDeclaration
| Export Default singleExpression eos # ExportDefaultDeclaration
;
exportFromBlock
: importNamespace importFrom eos
| exportModuleItems importFrom? eos
;
exportModuleItems
: '{' (exportAliasName ',')* (exportAliasName ','?)? '}'
;
exportAliasName
: moduleExportName (As moduleExportName)?
;
declaration
: variableStatement
| classDeclaration
| functionDeclaration
;
variableStatement
: variableDeclarationList eos
;
variableDeclarationList
: varModifier variableDeclaration (',' variableDeclaration)*
;
variableDeclaration
: assignable ('=' singleExpression)? // ECMAScript 6: Array & Object Matching
;
emptyStatement_
: SemiColon
;
expressionStatement
: {this.notOpenBraceAndNotFunction()}? expressionSequence eos
;
ifStatement
: If '(' expressionSequence ')' statement (Else statement)?
;
iterationStatement
: Do statement While '(' expressionSequence ')' eos # DoStatement
| While '(' expressionSequence ')' statement # WhileStatement
| For '(' (expressionSequence | variableDeclarationList)? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement
| For '(' (singleExpression | variableDeclarationList) In expressionSequence ')' statement # ForInStatement
| For Await? '(' (singleExpression | variableDeclarationList) Of expressionSequence ')' statement # ForOfStatement
;
varModifier // let, const - ECMAScript 6
: Var
| let_
| Const
;
continueStatement
: Continue ({this.notLineTerminator()}? identifier)? eos
;
breakStatement
: Break ({this.notLineTerminator()}? identifier)? eos
;
returnStatement
: Return ({this.notLineTerminator()}? expressionSequence)? eos
;
yieldStatement
: (Yield | YieldStar) ({this.notLineTerminator()}? expressionSequence)? eos
;
withStatement
: With '(' expressionSequence ')' statement
;
switchStatement
: Switch '(' expressionSequence ')' caseBlock
;
caseBlock
: '{' caseClauses? (defaultClause caseClauses?)? '}'
;
caseClauses
: caseClause+
;
caseClause
: Case expressionSequence ':' statementList?
;
defaultClause
: Default ':' statementList?
;
labelledStatement
: identifier ':' statement
;
throwStatement
: Throw {this.notLineTerminator()}? expressionSequence eos
;
tryStatement
: Try block (catchProduction finallyProduction? | finallyProduction)
;
catchProduction
: Catch ('(' assignable? ')')? block
;
finallyProduction
: Finally block
;
debuggerStatement
: Debugger eos
;
functionDeclaration
: Async? Function_ '*'? identifier '(' formalParameterList? ')' functionBody
;
classDeclaration
: Class identifier classTail
;
classTail
: (Extends singleExpression)? '{' classElement* '}'
;
classElement
: (Static | {this.n("static")}? identifier)? methodDefinition
| (Static | {this.n("static")}? identifier)? fieldDefinition
| (Static | {this.n("static")}? identifier) block
| emptyStatement_
;
methodDefinition
: (Async {this.notLineTerminator()}?)? '*'? classElementName '(' formalParameterList? ')' functionBody
| '*'? getter '(' ')' functionBody
| '*'? setter '(' formalParameterList? ')' functionBody
;
fieldDefinition
: classElementName initializer?
;
classElementName
: propertyName
| privateIdentifier
;
privateIdentifier
: '#' identifierName
;
formalParameterList
: formalParameterArg (',' formalParameterArg)* (',' lastFormalParameterArg)?
| lastFormalParameterArg
;
formalParameterArg
: assignable ('=' singleExpression)? // ECMAScript 6: Initialization
;
lastFormalParameterArg // ECMAScript 6: Rest Parameter
: Ellipsis singleExpression
;
functionBody
: '{' sourceElements? '}'
;
sourceElements
: sourceElement+
;
arrayLiteral
: ('[' elementList ']')
;
// JavaScript supports arrasys like [,,1,2,,].
elementList
: ','* arrayElement? (','+ arrayElement) * ','* // Yes, everything is optional
;
arrayElement
: Ellipsis? singleExpression
;
propertyAssignment
: propertyName ':' singleExpression # PropertyExpressionAssignment
| '[' singleExpression ']' ':' singleExpression # ComputedPropertyExpressionAssignment
| Async? '*'? propertyName '(' formalParameterList? ')' functionBody # FunctionProperty
| getter '(' ')' functionBody # PropertyGetter
| setter '(' formalParameterArg ')' functionBody # PropertySetter
| Ellipsis? singleExpression # PropertyShorthand
;
propertyName
: identifierName
| StringLiteral
| numericLiteral
| '[' singleExpression ']'
;
arguments
: '(' (argument (',' argument)* ','?)? ')'
;
argument
: Ellipsis? (singleExpression | identifier)
;
expressionSequence
: singleExpression (',' singleExpression)*
;
singleExpression
: anonymousFunction # FunctionExpression
| Class identifier? classTail # ClassExpression
| singleExpression '?.' singleExpression # OptionalChainExpression
| singleExpression '?.'? '[' expressionSequence ']' # MemberIndexExpression
| singleExpression '?'? '.' '#'? identifierName # MemberDotExpression
// Split to try `new Date()` first, then `new Date`.
| New identifier arguments # NewExpression
| New singleExpression arguments # NewExpression
| New singleExpression # NewExpression
| singleExpression arguments # ArgumentsExpression
| New '.' identifier # MetaExpression // new.target
| singleExpression {this.notLineTerminator()}? '++' # PostIncrementExpression
| singleExpression {this.notLineTerminator()}? '--' # PostDecreaseExpression
| Delete singleExpression # DeleteExpression
| Void singleExpression # VoidExpression
| Typeof singleExpression # TypeofExpression
| '++' singleExpression # PreIncrementExpression
| '--' singleExpression # PreDecreaseExpression
| '+' singleExpression # UnaryPlusExpression
| '-' singleExpression # UnaryMinusExpression
| '~' singleExpression # BitNotExpression
| '!' singleExpression # NotExpression
| Await singleExpression # AwaitExpression
| <assoc = right> singleExpression '**' singleExpression # PowerExpression
| singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression
| singleExpression ('+' | '-') singleExpression # AdditiveExpression
| singleExpression '??' singleExpression # CoalesceExpression
| singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression
| singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression
| singleExpression Instanceof singleExpression # InstanceofExpression
| singleExpression In singleExpression # InExpression
| singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression
| singleExpression '&' singleExpression # BitAndExpression
| singleExpression '^' singleExpression # BitXOrExpression
| singleExpression '|' singleExpression # BitOrExpression
| singleExpression '&&' singleExpression # LogicalAndExpression
| singleExpression '||' singleExpression # LogicalOrExpression
| singleExpression '?' singleExpression ':' singleExpression # TernaryExpression
| <assoc = right> singleExpression '=' singleExpression # AssignmentExpression
| <assoc = right> singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression
| Import '(' singleExpression ')' # ImportExpression
| singleExpression templateStringLiteral # TemplateStringExpression // ECMAScript 6
| yieldStatement # YieldExpression // ECMAScript 6
| This # ThisExpression
| identifier # IdentifierExpression
| Super # SuperExpression
| literal # LiteralExpression
| arrayLiteral # ArrayLiteralExpression
| objectLiteral # ObjectLiteralExpression
| '(' expressionSequence ')' # ParenthesizedExpression
;
initializer
// TODO: must be `= AssignmentExpression` and we have such label alredy but it doesn't respect the specification.
// See https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#prod-Initializer
: '=' singleExpression
;
assignable
: identifier
| arrayLiteral
| objectLiteral
;
objectLiteral
: '{' (propertyAssignment (',' propertyAssignment)* ','?)? '}'
;
anonymousFunction
: functionDeclaration # NamedFunction
| Async? Function_ '*'? '(' formalParameterList? ')' functionBody # AnonymousFunctionDecl
| Async? arrowFunctionParameters '=>' arrowFunctionBody # ArrowFunction
;
arrowFunctionParameters
: identifier
| '(' formalParameterList? ')'
;
arrowFunctionBody
: singleExpression
| functionBody
;
assignmentOperator
: '*='
| '/='
| '%='
| '+='
| '-='
| '<<='
| '>>='
| '>>>='
| '&='
| '^='
| '|='
| '**='
| '??='
;
literal
: NullLiteral
| BooleanLiteral
| StringLiteral
| templateStringLiteral
| RegularExpressionLiteral
| numericLiteral
| bigintLiteral
;
templateStringLiteral
: BackTick templateStringAtom* BackTick
;
templateStringAtom
: TemplateStringAtom
| TemplateStringStartExpression singleExpression TemplateCloseBrace
;
numericLiteral
: DecimalLiteral
| HexIntegerLiteral
| OctalIntegerLiteral
| OctalIntegerLiteral2
| BinaryIntegerLiteral
;
bigintLiteral
: BigDecimalIntegerLiteral
| BigHexIntegerLiteral
| BigOctalIntegerLiteral
| BigBinaryIntegerLiteral
;
getter
: {this.n("get")}? identifier classElementName
;
setter
: {this.n("set")}? identifier classElementName
;
identifierName
: identifier
| reservedWord
;
identifier
: Identifier
| NonStrictLet
| Async
| As
| From
| Yield
| Of
;
reservedWord
: keyword
| NullLiteral
| BooleanLiteral
;
keyword
: Break
| Do
| Instanceof
| Typeof
| Case
| Else
| New
| Var
| Catch
| Finally
| Return
| Void
| Continue
| For
| Switch
| While
| Debugger
| Function_
| This
| With
| Default
| If
| Throw
| Delete
| In
| Try
| Class
| Enum
| Extends
| Super
| Const
| Export
| Import
| Implements
| let_
| Private
| Public
| Interface
| Package
| Protected
| Static
| Yield
| YieldStar
| Async
| Await
| From
| As
| Of
;
let_
: NonStrictLet
| StrictLet
;
eos
: SemiColon
| EOF
| {this.lineTerminatorAhead()}?
| {this.closeBrace()}?
; | 16,292 | ANTLR | .g4 | 489 | 29.075665 | 140 | 0.610093 | luwrain/grammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 4ca79e5bf5c1ed0ca76dbbe44486b265356da52c87c9f5f0bf84e53768752765 | false | false | false | false |
165 | LaTeX.g4 | luwrain_grammar/src/main/antlr4/org/luwrain/antlr/latex/LaTeX.g4 | /*
ANTLR4 LaTeX Math Grammar
Ported from latex2sympy by @augustt198 https://github.com/augustt198/latex2sympy See license in
LICENSE.txt
*/
grammar LaTeX;
WS: [ \t\r\n]+ -> skip;
THINSPACE: ('\\,' | '\\thinspace') -> skip;
MEDSPACE: ('\\:' | '\\medspace') -> skip;
THICKSPACE: ('\\;' | '\\thickspace') -> skip;
QUAD: '\\quad' -> skip;
QQUAD: '\\qquad' -> skip;
NEGTHINSPACE: ('\\!' | '\\negthinspace') -> skip;
NEGMEDSPACE: '\\negmedspace' -> skip;
NEGTHICKSPACE: '\\negthickspace' -> skip;
CMD_LEFT: '\\left' -> skip;
CMD_RIGHT: '\\right' -> skip;
IGNORE:
(
'\\vrule'
| '\\vcenter'
| '\\vbox'
| '\\vskip'
| '\\vspace'
| '\\hfil'
| '\\*'
| '\\-'
| '\\.'
| '\\/'
| '\\"'
| '\\('
| '\\='
) -> skip;
ADD: '+';
SUB: '-';
MUL: '*';
DIV: '/';
L_PAREN: '(';
R_PAREN: ')';
L_BRACE: '{';
R_BRACE: '}';
L_BRACE_LITERAL: '\\{';
R_BRACE_LITERAL: '\\}';
L_BRACKET: '[';
R_BRACKET: ']';
BAR: '|';
R_BAR: '\\right|';
L_BAR: '\\left|';
L_ANGLE: '\\langle';
R_ANGLE: '\\rangle';
FUNC_LIM: '\\lim';
LIM_APPROACH_SYM:
'\\to'
| '\\rightarrow'
| '\\Rightarrow'
| '\\longrightarrow'
| '\\Longrightarrow';
FUNC_INT: '\\int';
FUNC_SUM: '\\sum';
FUNC_PROD: '\\prod';
FUNC_EXP: '\\exp';
FUNC_LOG: '\\log';
FUNC_LN: '\\ln';
FUNC_SIN: '\\sin';
FUNC_COS: '\\cos';
FUNC_TAN: '\\tan';
FUNC_CSC: '\\csc';
FUNC_SEC: '\\sec';
FUNC_COT: '\\cot';
FUNC_ARCSIN: '\\arcsin';
FUNC_ARCCOS: '\\arccos';
FUNC_ARCTAN: '\\arctan';
FUNC_ARCCSC: '\\arccsc';
FUNC_ARCSEC: '\\arcsec';
FUNC_ARCCOT: '\\arccot';
FUNC_SINH: '\\sinh';
FUNC_COSH: '\\cosh';
FUNC_TANH: '\\tanh';
FUNC_ARSINH: '\\arsinh';
FUNC_ARCOSH: '\\arcosh';
FUNC_ARTANH: '\\artanh';
L_FLOOR: '\\lfloor';
R_FLOOR: '\\rfloor';
L_CEIL: '\\lceil';
R_CEIL: '\\rceil';
FUNC_SQRT: '\\sqrt';
FUNC_OVERLINE: '\\overline';
CMD_TIMES: '\\times';
CMD_CDOT: '\\cdot';
CMD_DIV: '\\div';
CMD_FRAC: '\\frac';
CMD_BINOM: '\\binom';
CMD_DBINOM: '\\dbinom';
CMD_TBINOM: '\\tbinom';
CMD_MATHIT: '\\mathit';
UNDERSCORE: '_';
CARET: '^';
COLON: ':';
fragment WS_CHAR: [ \t\r\n];
DIFFERENTIAL: 'd' WS_CHAR*? ([a-zA-Z] | '\\' [a-zA-Z]+);
LETTER: [a-zA-Z];
fragment DIGIT: [0-9];
NUMBER:
DIGIT+ (',' DIGIT DIGIT DIGIT)*
| DIGIT* (',' DIGIT DIGIT DIGIT)* '.' DIGIT+;
EQUAL: (('&' WS_CHAR*?)? '=') | ('=' (WS_CHAR*? '&')?);
NEQ: '\\neq';
LT: '<';
LTE: ('\\leq' | '\\le' | LTE_Q | LTE_S);
LTE_Q: '\\leqq';
LTE_S: '\\leqslant';
GT: '>';
GTE: ('\\geq' | '\\ge' | GTE_Q | GTE_S);
GTE_Q: '\\geqq';
GTE_S: '\\geqslant';
BANG: '!';
SYMBOL: '\\' [a-zA-Z]+;
math: relation;
relation:
relation (EQUAL | LT | LTE | GT | GTE | NEQ) relation
| expr;
equality: expr EQUAL expr;
expr: additive;
additive: additive (ADD | SUB) additive | mp;
// mult part
mp:
mp (MUL | CMD_TIMES | CMD_CDOT | DIV | CMD_DIV | COLON) mp
| unary;
mp_nofunc:
mp_nofunc (
MUL
| CMD_TIMES
| CMD_CDOT
| DIV
| CMD_DIV
| COLON
) mp_nofunc
| unary_nofunc;
unary: (ADD | SUB) unary | postfix+;
unary_nofunc:
(ADD | SUB) unary_nofunc
| postfix postfix_nofunc*;
postfix: exp postfix_op*;
postfix_nofunc: exp_nofunc postfix_op*;
postfix_op: BANG | eval_at;
eval_at:
BAR (eval_at_sup | eval_at_sub | eval_at_sup eval_at_sub);
eval_at_sub: UNDERSCORE L_BRACE (expr | equality) R_BRACE;
eval_at_sup: CARET L_BRACE (expr | equality) R_BRACE;
exp: exp CARET (atom | L_BRACE expr R_BRACE) subexpr? | comp;
exp_nofunc:
exp_nofunc CARET (atom | L_BRACE expr R_BRACE) subexpr?
| comp_nofunc;
comp:
group
| abs_group
| func
| atom
| frac
| binom
| floor
| ceil;
comp_nofunc:
group
| abs_group
| atom
| frac
| binom
| floor
| ceil;
group:
L_PAREN expr R_PAREN
| L_BRACKET expr R_BRACKET
| L_BRACE expr R_BRACE
| L_BRACE_LITERAL expr R_BRACE_LITERAL;
abs_group: BAR expr BAR;
atom: (LETTER | SYMBOL) subexpr?
| NUMBER
| DIFFERENTIAL
| mathit
| bra
| ket;
bra: L_ANGLE expr (R_BAR | BAR);
ket: (L_BAR | BAR) expr R_ANGLE;
mathit: CMD_MATHIT L_BRACE mathit_text R_BRACE;
mathit_text: LETTER*;
frac:
CMD_FRAC L_BRACE upper = expr R_BRACE L_BRACE lower = expr R_BRACE;
binom:
(CMD_BINOM | CMD_DBINOM | CMD_TBINOM) L_BRACE n = expr R_BRACE L_BRACE k = expr R_BRACE;
floor: L_FLOOR val = expr R_FLOOR;
ceil: L_CEIL val = expr R_CEIL;
func_normal:
FUNC_EXP
| FUNC_LOG
| FUNC_LN
| FUNC_SIN
| FUNC_COS
| FUNC_TAN
| FUNC_CSC
| FUNC_SEC
| FUNC_COT
| FUNC_ARCSIN
| FUNC_ARCCOS
| FUNC_ARCTAN
| FUNC_ARCCSC
| FUNC_ARCSEC
| FUNC_ARCCOT
| FUNC_SINH
| FUNC_COSH
| FUNC_TANH
| FUNC_ARSINH
| FUNC_ARCOSH
| FUNC_ARTANH;
func:
func_normal (subexpr? supexpr? | supexpr? subexpr?) (
L_PAREN func_arg R_PAREN
| func_arg_noparens
)
| (LETTER | SYMBOL) subexpr? // e.g. f(x)
L_PAREN args R_PAREN
| FUNC_INT (subexpr supexpr | supexpr subexpr)? (
additive? DIFFERENTIAL
| frac
| additive
)
| FUNC_SQRT (L_BRACKET root = expr R_BRACKET)? L_BRACE base = expr R_BRACE
| FUNC_OVERLINE L_BRACE base = expr R_BRACE
| (FUNC_SUM | FUNC_PROD) (subeq supexpr | supexpr subeq) mp
| FUNC_LIM limit_sub mp;
args: (expr ',' args) | expr;
limit_sub:
UNDERSCORE L_BRACE (LETTER | SYMBOL) LIM_APPROACH_SYM expr (
CARET L_BRACE (ADD | SUB) R_BRACE
)? R_BRACE;
func_arg: expr | (expr ',' func_arg);
func_arg_noparens: mp_nofunc;
subexpr: UNDERSCORE (atom | L_BRACE expr R_BRACE);
supexpr: CARET (atom | L_BRACE expr R_BRACE);
subeq: UNDERSCORE L_BRACE equality R_BRACE;
supeq: UNDERSCORE L_BRACE equality R_BRACE;
| 5,388 | ANTLR | .g4 | 241 | 20.568465 | 96 | 0.631114 | luwrain/grammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 6b805ae0c245ad6a68efb7898e2f85c3d7990e56b2039c777839732f7686c999 | false | false | false | false |
166 | Lilypond.g4 | luwrain_grammar/src/main/antlr4/org/luwrain/antlr/ly/Lilypond.g4 |
grammar Lilypond;
/*
@header{
package org.luwrain.antlr.ly;
}
*/
music
: musicUnit* EOF
;
musicUnit
: command | note | String
;
command
: '\\' Ident
;
seq
: '{' IDENT '}'
;
note
: NoteName Oct? Duration?
;
NoteName
: ('a' | 'b')
;
Oct
: (',' | ',,')
;
Duration
: ('1' | '2' | '4' | '8' | '16' | '32' | '64')
;
Ident
: [A-Za-z]+
;
String
: '"' [ a-zA-Z0-9.]* '"'
;
WS
: [ \t\r\n]+ -> skip
;
| 445 | ANTLR | .g4 | 39 | 9.102564 | 46 | 0.489796 | luwrain/grammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | a5fbb38814464a5289bc68bf2eec45548e2a33528ed2abfbb27aafa9426f00fc | false | false | false | false |
167 | Java.g4 | luwrain_grammar/src/main/antlr4/org/luwrain/antlr/java/Java.g4 | /*
* [The "BSD license"]
* Copyright (c) 2014 Terence Parr
* Copyright (c) 2014 Sam Harwell
* Copyright (c) 2017 Chan Chung Kwong
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* A Java 9 grammar for ANTLR 4 derived from the Java Language Specification
* chapter 19.
*
* NOTE: This grammar results in a generated parser that is much slower
* than the Java 7 grammar in the grammars-v4/java directory. This
* one is, however, extremely close to the spec.
*
* You can test with
*
* $ antlr4 Java9.g4
* $ javac *.java
* $ grun Java9 compilationUnit *.java
*
* Or,
~/antlr/code/grammars-v4/java9 $ java Test .
/Users/parrt/antlr/code/grammars-v4/java9/./Java9BaseListener.java
/Users/parrt/antlr/code/grammars-v4/java9/./Java9Lexer.java
/Users/parrt/antlr/code/grammars-v4/java9/./Java9Listener.java
/Users/parrt/antlr/code/grammars-v4/java9/./Java9Parser.java
/Users/parrt/antlr/code/grammars-v4/java9/./Test.java
Total lexer+parser time 30844ms.
~/antlr/code/grammars-v4/java9 $ java Test examples/module-info.java
/home/kwong/projects/grammars-v4/java9/examples/module-info.java
Total lexer+parser time 914ms.
~/antlr/code/grammars-v4/java9 $ java Test examples/TryWithResourceDemo.java
/home/kwong/projects/grammars-v4/java9/examples/TryWithResourceDemo.java
Total lexer+parser time 3634ms.
~/antlr/code/grammars-v4/java9 $ java Test examples/helloworld.java
/home/kwong/projects/grammars-v4/java9/examples/helloworld.java
Total lexer+parser time 2497ms.
*/
grammar Java;
/*
* Productions from §3 (Lexical Structure)
*/
literal
: IntegerLiteral
| FloatingPointLiteral
| BooleanLiteral
| CharacterLiteral
| StringLiteral
| NullLiteral
;
/*
* Productions from §4 (Types, Values, and Variables)
*/
primitiveType
: annotation* numericType
| annotation* 'boolean'
;
numericType
: integralType
| floatingPointType
;
integralType
: 'byte'
| 'short'
| 'int'
| 'long'
| 'char'
;
floatingPointType
: 'float'
| 'double'
;
referenceType
: classOrInterfaceType
| typeVariable
| arrayType
;
/*classOrInterfaceType
: classType
| interfaceType
;
*/
classOrInterfaceType
: ( classType_lfno_classOrInterfaceType
| interfaceType_lfno_classOrInterfaceType
)
( classType_lf_classOrInterfaceType
| interfaceType_lf_classOrInterfaceType
)*
;
classType
: annotation* identifier typeArguments?
| classOrInterfaceType '.' annotation* identifier typeArguments?
;
classType_lf_classOrInterfaceType
: '.' annotation* identifier typeArguments?
;
classType_lfno_classOrInterfaceType
: annotation* identifier typeArguments?
;
interfaceType
: classType
;
interfaceType_lf_classOrInterfaceType
: classType_lf_classOrInterfaceType
;
interfaceType_lfno_classOrInterfaceType
: classType_lfno_classOrInterfaceType
;
typeVariable
: annotation* identifier
;
arrayType
: primitiveType dims
| classOrInterfaceType dims
| typeVariable dims
;
dims
: annotation* '[' ']' (annotation* '[' ']')*
;
typeParameter
: typeParameterModifier* identifier typeBound?
;
typeParameterModifier
: annotation
;
typeBound
: 'extends' typeVariable
| 'extends' classOrInterfaceType additionalBound*
;
additionalBound
: '&' interfaceType
;
typeArguments
: '<' typeArgumentList '>'
;
typeArgumentList
: typeArgument (',' typeArgument)*
;
typeArgument
: referenceType
| wildcard
;
wildcard
: annotation* '?' wildcardBounds?
;
wildcardBounds
: 'extends' referenceType
| 'super' referenceType
;
/*
* Productions from §6 (Names)
*/
moduleName
: identifier
| moduleName '.' identifier
;
packageName
: identifier
| packageName '.' identifier
;
typeName
: identifier
| packageOrTypeName '.' identifier
;
packageOrTypeName
: identifier
| packageOrTypeName '.' identifier
;
expressionName
: identifier
| ambiguousName '.' identifier
;
methodName
: identifier
;
ambiguousName
: identifier
| ambiguousName '.' identifier
;
/*
* Productions from §7 (Packages)
*/
compilationUnit
: ordinaryCompilation
| modularCompilation
;
ordinaryCompilation
: packageDeclaration? importDeclaration* typeDeclaration* EOF
;
modularCompilation
: importDeclaration* moduleDeclaration
;
packageDeclaration
: packageModifier* 'package' packageName ';'
;
packageModifier
: annotation
;
importDeclaration
: singleTypeImportDeclaration
| typeImportOnDemandDeclaration
| singleStaticImportDeclaration
| staticImportOnDemandDeclaration
;
singleTypeImportDeclaration
: 'import' typeName ';'
;
typeImportOnDemandDeclaration
: 'import' packageOrTypeName '.' '*' ';'
;
singleStaticImportDeclaration
: 'import' 'static' typeName '.' identifier ';'
;
staticImportOnDemandDeclaration
: 'import' 'static' typeName '.' '*' ';'
;
typeDeclaration
: classDeclaration
| interfaceDeclaration
| ';'
;
moduleDeclaration
: annotation* 'open'? 'module' moduleName '{' moduleDirective* '}'
;
moduleDirective
: 'requires' requiresModifier* moduleName ';'
| 'exports' packageName ('to' moduleName (',' moduleName)*)? ';'
| 'opens' packageName ('to' moduleName (',' moduleName)*)? ';'
| 'uses' typeName ';'
| 'provides' typeName 'with' typeName (',' typeName)* ';'
;
requiresModifier
: 'transitive'
| 'static'
;
/*
* Productions from §8 (Classes)
*/
classDeclaration
: normalClassDeclaration
| enumDeclaration
;
normalClassDeclaration
: classModifier* 'class' identifier typeParameters? superclass? superinterfaces? classBody
;
classModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'abstract'
| 'static'
| 'final'
| 'strictfp'
;
typeParameters
: '<' typeParameterList '>'
;
typeParameterList
: typeParameter (',' typeParameter)*
;
superclass
: 'extends' classType
;
superinterfaces
: 'implements' interfaceTypeList
;
interfaceTypeList
: interfaceType (',' interfaceType)*
;
classBody
: '{' classBodyDeclaration* '}'
;
classBodyDeclaration
: classMemberDeclaration
| instanceInitializer
| staticInitializer
| constructorDeclaration
;
classMemberDeclaration
: fieldDeclaration
| methodDeclaration
| classDeclaration
| interfaceDeclaration
| ';'
;
fieldDeclaration
: fieldModifier* unannType variableDeclaratorList ';'
;
fieldModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'static'
| 'final'
| 'transient'
| 'volatile'
;
variableDeclaratorList
: variableDeclarator (',' variableDeclarator)*
;
variableDeclarator
: variableDeclaratorId ('=' variableInitializer)?
;
variableDeclaratorId
: identifier dims?
;
variableInitializer
: expression
| arrayInitializer
;
unannType
: unannPrimitiveType
| unannReferenceType
;
unannPrimitiveType
: numericType
| 'boolean'
;
unannReferenceType
: unannClassOrInterfaceType
| unannTypeVariable
| unannArrayType
;
/*unannClassOrInterfaceType
: unannClassType
| unannInterfaceType
;
*/
unannClassOrInterfaceType
: ( unannClassType_lfno_unannClassOrInterfaceType
| unannInterfaceType_lfno_unannClassOrInterfaceType
)
( unannClassType_lf_unannClassOrInterfaceType
| unannInterfaceType_lf_unannClassOrInterfaceType
)*
;
unannClassType
: identifier typeArguments?
| unannClassOrInterfaceType '.' annotation* identifier typeArguments?
;
unannClassType_lf_unannClassOrInterfaceType
: '.' annotation* identifier typeArguments?
;
unannClassType_lfno_unannClassOrInterfaceType
: identifier typeArguments?
;
unannInterfaceType
: unannClassType
;
unannInterfaceType_lf_unannClassOrInterfaceType
: unannClassType_lf_unannClassOrInterfaceType
;
unannInterfaceType_lfno_unannClassOrInterfaceType
: unannClassType_lfno_unannClassOrInterfaceType
;
unannTypeVariable
: identifier
;
unannArrayType
: unannPrimitiveType dims
| unannClassOrInterfaceType dims
| unannTypeVariable dims
;
methodDeclaration
: methodModifier* methodHeader methodBody
;
methodModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'abstract'
| 'static'
| 'final'
| 'synchronized'
| 'native'
| 'strictfp'
;
methodHeader
: result methodDeclarator throws_?
| typeParameters annotation* result methodDeclarator throws_?
;
result
: unannType
| 'void'
;
methodDeclarator
: identifier '(' formalParameterList? ')' dims?
;
formalParameterList
: formalParameters ',' lastFormalParameter
| lastFormalParameter
| receiverParameter
;
formalParameters
: formalParameter (',' formalParameter)*
| receiverParameter (',' formalParameter)*
;
formalParameter
: variableModifier* unannType variableDeclaratorId
;
variableModifier
: annotation
| 'final'
;
lastFormalParameter
: variableModifier* unannType annotation* '...' variableDeclaratorId
| formalParameter
;
receiverParameter
: annotation* unannType (identifier '.')? 'this'
;
throws_
: 'throws' exceptionTypeList
;
exceptionTypeList
: exceptionType (',' exceptionType)*
;
exceptionType
: classType
| typeVariable
;
methodBody
: block
| ';'
;
instanceInitializer
: block
;
staticInitializer
: 'static' block
;
constructorDeclaration
: constructorModifier* constructorDeclarator throws_? constructorBody
;
constructorModifier
: annotation
| 'public'
| 'protected'
| 'private'
;
constructorDeclarator
: typeParameters? simpleTypeName '(' formalParameterList? ')'
;
simpleTypeName
: identifier
;
constructorBody
: '{' explicitConstructorInvocation? blockStatements? '}'
;
explicitConstructorInvocation
: typeArguments? 'this' '(' argumentList? ')' ';'
| typeArguments? 'super' '(' argumentList? ')' ';'
| expressionName '.' typeArguments? 'super' '(' argumentList? ')' ';'
| primary '.' typeArguments? 'super' '(' argumentList? ')' ';'
;
enumDeclaration
: classModifier* 'enum' identifier superinterfaces? enumBody
;
enumBody
: '{' enumConstantList? ','? enumBodyDeclarations? '}'
;
enumConstantList
: enumConstant (',' enumConstant)*
;
enumConstant
: enumConstantModifier* identifier ('(' argumentList? ')')? classBody?
;
enumConstantModifier
: annotation
;
enumBodyDeclarations
: ';' classBodyDeclaration*
;
/*
* Productions from §9 (Interfaces)
*/
interfaceDeclaration
: normalInterfaceDeclaration
| annotationTypeDeclaration
;
normalInterfaceDeclaration
: interfaceModifier* 'interface' identifier typeParameters? extendsInterfaces? interfaceBody
;
interfaceModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'abstract'
| 'static'
| 'strictfp'
;
extendsInterfaces
: 'extends' interfaceTypeList
;
interfaceBody
: '{' interfaceMemberDeclaration* '}'
;
interfaceMemberDeclaration
: constantDeclaration
| interfaceMethodDeclaration
| classDeclaration
| interfaceDeclaration
| ';'
;
constantDeclaration
: constantModifier* unannType variableDeclaratorList ';'
;
constantModifier
: annotation
| 'public'
| 'static'
| 'final'
;
interfaceMethodDeclaration
: interfaceMethodModifier* methodHeader methodBody
;
interfaceMethodModifier
: annotation
| 'public'
| 'private'//Introduced in Java 9
| 'abstract'
| 'default'
| 'static'
| 'strictfp'
;
annotationTypeDeclaration
: interfaceModifier* '@' 'interface' identifier annotationTypeBody
;
annotationTypeBody
: '{' annotationTypeMemberDeclaration* '}'
;
annotationTypeMemberDeclaration
: annotationTypeElementDeclaration
| constantDeclaration
| classDeclaration
| interfaceDeclaration
| ';'
;
annotationTypeElementDeclaration
: annotationTypeElementModifier* unannType identifier '(' ')' dims? defaultValue? ';'
;
annotationTypeElementModifier
: annotation
| 'public'
| 'abstract'
;
defaultValue
: 'default' elementValue
;
annotation
: normalAnnotation
| markerAnnotation
| singleElementAnnotation
;
normalAnnotation
: '@' typeName '(' elementValuePairList? ')'
;
elementValuePairList
: elementValuePair (',' elementValuePair)*
;
elementValuePair
: identifier '=' elementValue
;
elementValue
: conditionalExpression
| elementValueArrayInitializer
| annotation
;
elementValueArrayInitializer
: '{' elementValueList? ','? '}'
;
elementValueList
: elementValue (',' elementValue)*
;
markerAnnotation
: '@' typeName
;
singleElementAnnotation
: '@' typeName '(' elementValue ')'
;
/*
* Productions from §10 (Arrays)
*/
arrayInitializer
: '{' variableInitializerList? ','? '}'
;
variableInitializerList
: variableInitializer (',' variableInitializer)*
;
/*
* Productions from §14 (Blocks and Statements)
*/
block
: '{' blockStatements? '}'
;
blockStatements
: blockStatement+
;
blockStatement
: localVariableDeclarationStatement
| classDeclaration
| statement
;
localVariableDeclarationStatement
: localVariableDeclaration ';'
;
localVariableDeclaration
: variableModifier* unannType variableDeclaratorList
;
statement
: statementWithoutTrailingSubstatement
| labeledStatement
| ifThenStatement
| ifThenElseStatement
| whileStatement
| forStatement
;
statementNoShortIf
: statementWithoutTrailingSubstatement
| labeledStatementNoShortIf
| ifThenElseStatementNoShortIf
| whileStatementNoShortIf
| forStatementNoShortIf
;
statementWithoutTrailingSubstatement
: block
| emptyStatement
| expressionStatement
| assertStatement
| switchStatement
| doStatement
| breakStatement
| continueStatement
| returnStatement
| synchronizedStatement
| throwStatement
| tryStatement
;
emptyStatement
: ';'
;
labeledStatement
: identifier ':' statement
;
labeledStatementNoShortIf
: identifier ':' statementNoShortIf
;
expressionStatement
: statementExpression ';'
;
statementExpression
: assignment
| preIncrementExpression
| preDecrementExpression
| postIncrementExpression
| postDecrementExpression
| methodInvocation
| classInstanceCreationExpression
;
ifThenStatement
: 'if' '(' expression ')' statement
;
ifThenElseStatement
: 'if' '(' expression ')' statementNoShortIf 'else' statement
;
ifThenElseStatementNoShortIf
: 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf
;
assertStatement
: 'assert' expression ';'
| 'assert' expression ':' expression ';'
;
switchStatement
: 'switch' '(' expression ')' switchBlock
;
switchBlock
: '{' switchBlockStatementGroup* switchLabel* '}'
;
switchBlockStatementGroup
: switchLabels blockStatements
;
switchLabels
: switchLabel+
;
switchLabel
: 'case' constantExpression ':'
| 'case' enumConstantName ':'
| 'default' ':'
;
enumConstantName
: identifier
;
whileStatement
: 'while' '(' expression ')' statement
;
whileStatementNoShortIf
: 'while' '(' expression ')' statementNoShortIf
;
doStatement
: 'do' statement 'while' '(' expression ')' ';'
;
forStatement
: basicForStatement
| enhancedForStatement
;
forStatementNoShortIf
: basicForStatementNoShortIf
| enhancedForStatementNoShortIf
;
basicForStatement
: 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement
;
basicForStatementNoShortIf
: 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf
;
forInit
: statementExpressionList
| localVariableDeclaration
;
forUpdate
: statementExpressionList
;
statementExpressionList
: statementExpression (',' statementExpression)*
;
enhancedForStatement
: 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statement
;
enhancedForStatementNoShortIf
: 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statementNoShortIf
;
breakStatement
: 'break' identifier? ';'
;
continueStatement
: 'continue' identifier? ';'
;
returnStatement
: 'return' expression? ';'
;
throwStatement
: 'throw' expression ';'
;
synchronizedStatement
: 'synchronized' '(' expression ')' block
;
tryStatement
: 'try' block catches
| 'try' block catches? finally_
| tryWithResourcesStatement
;
catches
: catchClause+
;
catchClause
: 'catch' '(' catchFormalParameter ')' block
;
catchFormalParameter
: variableModifier* catchType variableDeclaratorId
;
catchType
: unannClassType ('|' classType)*
;
finally_
: 'finally' block
;
tryWithResourcesStatement
: 'try' resourceSpecification block catches? finally_?
;
resourceSpecification
: '(' resourceList ';'? ')'
;
resourceList
: resource (';' resource)*
;
resource
: variableModifier* unannType variableDeclaratorId '=' expression
| variableAccess//Introduced in Java 9
;
variableAccess
: expressionName
| fieldAccess
;
/*
* Productions from §15 (Expressions)
*/
/*primary
: primaryNoNewArray
| arrayCreationExpression
;
*/
primary
: ( primaryNoNewArray_lfno_primary
| arrayCreationExpression
)
( primaryNoNewArray_lf_primary
)*
;
primaryNoNewArray
: literal
| classLiteral
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression
| fieldAccess
| arrayAccess
| methodInvocation
| methodReference
;
primaryNoNewArray_lf_arrayAccess
:
;
primaryNoNewArray_lfno_arrayAccess
: literal
| typeName ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression
| fieldAccess
| methodInvocation
| methodReference
;
primaryNoNewArray_lf_primary
: classInstanceCreationExpression_lf_primary
| fieldAccess_lf_primary
| arrayAccess_lf_primary
| methodInvocation_lf_primary
| methodReference_lf_primary
;
primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary
:
;
primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary
: classInstanceCreationExpression_lf_primary
| fieldAccess_lf_primary
| methodInvocation_lf_primary
| methodReference_lf_primary
;
primaryNoNewArray_lfno_primary
: literal
| typeName ('[' ']')* '.' 'class'
| unannPrimitiveType ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression_lfno_primary
| fieldAccess_lfno_primary
| arrayAccess_lfno_primary
| methodInvocation_lfno_primary
| methodReference_lfno_primary
;
primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary
:
;
primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary
: literal
| typeName ('[' ']')* '.' 'class'
| unannPrimitiveType ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression_lfno_primary
| fieldAccess_lfno_primary
| methodInvocation_lfno_primary
| methodReference_lfno_primary
;
classLiteral
: (typeName|numericType|'boolean') ('[' ']')* '.' 'class'
| 'void' '.' 'class'
;
classInstanceCreationExpression
: 'new' typeArguments? annotation* identifier ('.' annotation* identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
| expressionName '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
| primary '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
;
classInstanceCreationExpression_lf_primary
: '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
;
classInstanceCreationExpression_lfno_primary
: 'new' typeArguments? annotation* identifier ('.' annotation* identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
| expressionName '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
;
typeArgumentsOrDiamond
: typeArguments
| '<' '>'
;
fieldAccess
: primary '.' identifier
| 'super' '.' identifier
| typeName '.' 'super' '.' identifier
;
fieldAccess_lf_primary
: '.' identifier
;
fieldAccess_lfno_primary
: 'super' '.' identifier
| typeName '.' 'super' '.' identifier
;
/*arrayAccess
: expressionName '[' expression ']'
| primaryNoNewArray '[' expression ']'
;
*/
arrayAccess
: ( expressionName '[' expression ']'
| primaryNoNewArray_lfno_arrayAccess '[' expression ']'
)
( primaryNoNewArray_lf_arrayAccess '[' expression ']'
)*
;
arrayAccess_lf_primary
: ( primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary '[' expression ']'
)
( primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary '[' expression ']'
)*
;
arrayAccess_lfno_primary
: ( expressionName '[' expression ']'
| primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary '[' expression ']'
)
( primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary '[' expression ']'
)*
;
methodInvocation
: methodName '(' argumentList? ')'
| typeName '.' typeArguments? identifier '(' argumentList? ')'
| expressionName '.' typeArguments? identifier '(' argumentList? ')'
| primary '.' typeArguments? identifier '(' argumentList? ')'
| 'super' '.' typeArguments? identifier '(' argumentList? ')'
| typeName '.' 'super' '.' typeArguments? identifier '(' argumentList? ')'
;
methodInvocation_lf_primary
: '.' typeArguments? identifier '(' argumentList? ')'
;
methodInvocation_lfno_primary
: methodName '(' argumentList? ')'
| typeName '.' typeArguments? identifier '(' argumentList? ')'
| expressionName '.' typeArguments? identifier '(' argumentList? ')'
| 'super' '.' typeArguments? identifier '(' argumentList? ')'
| typeName '.' 'super' '.' typeArguments? identifier '(' argumentList? ')'
;
argumentList
: expression (',' expression)*
;
methodReference
: expressionName '::' typeArguments? identifier
| referenceType '::' typeArguments? identifier
| primary '::' typeArguments? identifier
| 'super' '::' typeArguments? identifier
| typeName '.' 'super' '::' typeArguments? identifier
| classType '::' typeArguments? 'new'
| arrayType '::' 'new'
;
methodReference_lf_primary
: '::' typeArguments? identifier
;
methodReference_lfno_primary
: expressionName '::' typeArguments? identifier
| referenceType '::' typeArguments? identifier
| 'super' '::' typeArguments? identifier
| typeName '.' 'super' '::' typeArguments? identifier
| classType '::' typeArguments? 'new'
| arrayType '::' 'new'
;
arrayCreationExpression
: 'new' primitiveType dimExprs dims?
| 'new' classOrInterfaceType dimExprs dims?
| 'new' primitiveType dims arrayInitializer
| 'new' classOrInterfaceType dims arrayInitializer
;
dimExprs
: dimExpr+
;
dimExpr
: annotation* '[' expression ']'
;
constantExpression
: expression
;
expression
: lambdaExpression
| assignmentExpression
;
lambdaExpression
: lambdaParameters '->' lambdaBody
;
lambdaParameters
: identifier
| '(' formalParameterList? ')'
| '(' inferredFormalParameterList ')'
;
inferredFormalParameterList
: identifier (',' identifier)*
;
lambdaBody
: expression
| block
;
assignmentExpression
: conditionalExpression
| assignment
;
assignment
: leftHandSide assignmentOperator expression
;
leftHandSide
: expressionName
| fieldAccess
| arrayAccess
;
assignmentOperator
: '='
| '*='
| '/='
| '%='
| '+='
| '-='
| '<<='
| '>>='
| '>>>='
| '&='
| '^='
| '|='
;
conditionalExpression
: conditionalOrExpression
| conditionalOrExpression '?' expression ':' (conditionalExpression|lambdaExpression)
;
conditionalOrExpression
: conditionalAndExpression
| conditionalOrExpression '||' conditionalAndExpression
;
conditionalAndExpression
: inclusiveOrExpression
| conditionalAndExpression '&&' inclusiveOrExpression
;
inclusiveOrExpression
: exclusiveOrExpression
| inclusiveOrExpression '|' exclusiveOrExpression
;
exclusiveOrExpression
: andExpression
| exclusiveOrExpression '^' andExpression
;
andExpression
: equalityExpression
| andExpression '&' equalityExpression
;
equalityExpression
: relationalExpression
| equalityExpression '==' relationalExpression
| equalityExpression '!=' relationalExpression
;
relationalExpression
: shiftExpression
| relationalExpression '<' shiftExpression
| relationalExpression '>' shiftExpression
| relationalExpression '<=' shiftExpression
| relationalExpression '>=' shiftExpression
| relationalExpression 'instanceof' referenceType
;
shiftExpression
: additiveExpression
| shiftExpression '<' '<' additiveExpression
| shiftExpression '>' '>' additiveExpression
| shiftExpression '>' '>' '>' additiveExpression
;
additiveExpression
: multiplicativeExpression
| additiveExpression '+' multiplicativeExpression
| additiveExpression '-' multiplicativeExpression
;
multiplicativeExpression
: unaryExpression
| multiplicativeExpression '*' unaryExpression
| multiplicativeExpression '/' unaryExpression
| multiplicativeExpression '%' unaryExpression
;
unaryExpression
: preIncrementExpression
| preDecrementExpression
| '+' unaryExpression
| '-' unaryExpression
| unaryExpressionNotPlusMinus
;
preIncrementExpression
: '++' unaryExpression
;
preDecrementExpression
: '--' unaryExpression
;
unaryExpressionNotPlusMinus
: postfixExpression
| '~' unaryExpression
| '!' unaryExpression
| castExpression
;
/*postfixExpression
: primary
| expressionName
| postIncrementExpression
| postDecrementExpression
;
*/
postfixExpression
: ( primary
| expressionName
)
( postIncrementExpression_lf_postfixExpression
| postDecrementExpression_lf_postfixExpression
)*
;
postIncrementExpression
: postfixExpression '++'
;
postIncrementExpression_lf_postfixExpression
: '++'
;
postDecrementExpression
: postfixExpression '--'
;
postDecrementExpression_lf_postfixExpression
: '--'
;
castExpression
: '(' primitiveType ')' unaryExpression
| '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus
| '(' referenceType additionalBound* ')' lambdaExpression
;
// LEXER
identifier : Identifier | 'to' | 'module' | 'open' | 'with' | 'provides' | 'uses' | 'opens' | 'requires' | 'exports';
// §3.9 Keywords
ABSTRACT : 'abstract';
ASSERT : 'assert';
BOOLEAN : 'boolean';
BREAK : 'break';
BYTE : 'byte';
CASE : 'case';
CATCH : 'catch';
CHAR : 'char';
CLASS : 'class';
CONST : 'const';
CONTINUE : 'continue';
DEFAULT : 'default';
DO : 'do';
DOUBLE : 'double';
ELSE : 'else';
ENUM : 'enum';
EXTENDS : 'extends';
FINAL : 'final';
FINALLY : 'finally';
FLOAT : 'float';
FOR : 'for';
IF : 'if';
GOTO : 'goto';
IMPLEMENTS : 'implements';
IMPORT : 'import';
INSTANCEOF : 'instanceof';
INT : 'int';
INTERFACE : 'interface';
LONG : 'long';
NATIVE : 'native';
NEW : 'new';
PACKAGE : 'package';
PRIVATE : 'private';
PROTECTED : 'protected';
PUBLIC : 'public';
RETURN : 'return';
SHORT : 'short';
STATIC : 'static';
STRICTFP : 'strictfp';
SUPER : 'super';
SWITCH : 'switch';
SYNCHRONIZED : 'synchronized';
THIS : 'this';
THROW : 'throw';
THROWS : 'throws';
TRANSIENT : 'transient';
TRY : 'try';
VOID : 'void';
VOLATILE : 'volatile';
WHILE : 'while';
UNDER_SCORE : '_';//Introduced in Java 9
// §3.10.1 Integer Literals
IntegerLiteral
: DecimalIntegerLiteral
| HexIntegerLiteral
| OctalIntegerLiteral
| BinaryIntegerLiteral
;
fragment
DecimalIntegerLiteral
: DecimalNumeral IntegerTypeSuffix?
;
fragment
HexIntegerLiteral
: HexNumeral IntegerTypeSuffix?
;
fragment
OctalIntegerLiteral
: OctalNumeral IntegerTypeSuffix?
;
fragment
BinaryIntegerLiteral
: BinaryNumeral IntegerTypeSuffix?
;
fragment
IntegerTypeSuffix
: [lL]
;
fragment
DecimalNumeral
: '0'
| NonZeroDigit (Digits? | Underscores Digits)
;
fragment
Digits
: Digit (DigitsAndUnderscores? Digit)?
;
fragment
Digit
: '0'
| NonZeroDigit
;
fragment
NonZeroDigit
: [1-9]
;
fragment
DigitsAndUnderscores
: DigitOrUnderscore+
;
fragment
DigitOrUnderscore
: Digit
| '_'
;
fragment
Underscores
: '_'+
;
fragment
HexNumeral
: '0' [xX] HexDigits
;
fragment
HexDigits
: HexDigit (HexDigitsAndUnderscores? HexDigit)?
;
fragment
HexDigit
: [0-9a-fA-F]
;
fragment
HexDigitsAndUnderscores
: HexDigitOrUnderscore+
;
fragment
HexDigitOrUnderscore
: HexDigit
| '_'
;
fragment
OctalNumeral
: '0' Underscores? OctalDigits
;
fragment
OctalDigits
: OctalDigit (OctalDigitsAndUnderscores? OctalDigit)?
;
fragment
OctalDigit
: [0-7]
;
fragment
OctalDigitsAndUnderscores
: OctalDigitOrUnderscore+
;
fragment
OctalDigitOrUnderscore
: OctalDigit
| '_'
;
fragment
BinaryNumeral
: '0' [bB] BinaryDigits
;
fragment
BinaryDigits
: BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)?
;
fragment
BinaryDigit
: [01]
;
fragment
BinaryDigitsAndUnderscores
: BinaryDigitOrUnderscore+
;
fragment
BinaryDigitOrUnderscore
: BinaryDigit
| '_'
;
// §3.10.2 Floating-Point Literals
FloatingPointLiteral
: DecimalFloatingPointLiteral
| HexadecimalFloatingPointLiteral
;
fragment
DecimalFloatingPointLiteral
: Digits '.' Digits? ExponentPart? FloatTypeSuffix?
| '.' Digits ExponentPart? FloatTypeSuffix?
| Digits ExponentPart FloatTypeSuffix?
| Digits FloatTypeSuffix
;
fragment
ExponentPart
: ExponentIndicator SignedInteger
;
fragment
ExponentIndicator
: [eE]
;
fragment
SignedInteger
: Sign? Digits
;
fragment
Sign
: [+-]
;
fragment
FloatTypeSuffix
: [fFdD]
;
fragment
HexadecimalFloatingPointLiteral
: HexSignificand BinaryExponent FloatTypeSuffix?
;
fragment
HexSignificand
: HexNumeral '.'?
| '0' [xX] HexDigits? '.' HexDigits
;
fragment
BinaryExponent
: BinaryExponentIndicator SignedInteger
;
fragment
BinaryExponentIndicator
: [pP]
;
// §3.10.3 Boolean Literals
BooleanLiteral
: 'true'
| 'false'
;
// §3.10.4 Character Literals
CharacterLiteral
: '\'' SingleCharacter '\''
| '\'' EscapeSequence '\''
;
fragment
SingleCharacter
: ~['\\\r\n]
;
// §3.10.5 String Literals
StringLiteral
: '"' StringCharacters? '"'
;
fragment
StringCharacters
: StringCharacter+
;
fragment
StringCharacter
: ~["\\\r\n]
| EscapeSequence
;
// §3.10.6 Escape Sequences for Character and String Literals
fragment
EscapeSequence
: '\\' [btnfr"'\\]
| OctalEscape
| UnicodeEscape // This is not in the spec but prevents having to preprocess the input
;
fragment
OctalEscape
: '\\' OctalDigit
| '\\' OctalDigit OctalDigit
| '\\' ZeroToThree OctalDigit OctalDigit
;
fragment
ZeroToThree
: [0-3]
;
// This is not in the spec but prevents having to preprocess the input
fragment
UnicodeEscape
: '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit
;
// §3.10.7 The Null Literal
NullLiteral
: 'null'
;
// §3.11 Separators
LPAREN : '(';
RPAREN : ')';
LBRACE : '{';
RBRACE : '}';
LBRACK : '[';
RBRACK : ']';
SEMI : ';';
COMMA : ',';
DOT : '.';
ELLIPSIS : '...';
AT : '@';
COLONCOLON : '::';
// §3.12 Operators
ASSIGN : '=';
GT : '>';
LT : '<';
BANG : '!';
TILDE : '~';
QUESTION : '?';
COLON : ':';
ARROW : '->';
EQUAL : '==';
LE : '<=';
GE : '>=';
NOTEQUAL : '!=';
AND : '&&';
OR : '||';
INC : '++';
DEC : '--';
ADD : '+';
SUB : '-';
MUL : '*';
DIV : '/';
BITAND : '&';
BITOR : '|';
CARET : '^';
MOD : '%';
//LSHIFT : '<<';
//RSHIFT : '>>';
//URSHIFT : '>>>';
ADD_ASSIGN : '+=';
SUB_ASSIGN : '-=';
MUL_ASSIGN : '*=';
DIV_ASSIGN : '/=';
AND_ASSIGN : '&=';
OR_ASSIGN : '|=';
XOR_ASSIGN : '^=';
MOD_ASSIGN : '%=';
LSHIFT_ASSIGN : '<<=';
RSHIFT_ASSIGN : '>>=';
URSHIFT_ASSIGN : '>>>=';
// §3.8 Identifiers (must appear after all keywords in the grammar)
Identifier
: JavaLetter JavaLetterOrDigit*
;
fragment
JavaLetter
: [a-zA-Z$_] // these are the "java letters" below 0x7F
| // covers all characters above 0x7F which are not a surrogate
~[\u0000-\u007F\uD800-\uDBFF]
{Character.isJavaIdentifierStart(_input.LA(-1))}?
| // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
[\uD800-\uDBFF] [\uDC00-\uDFFF]
{Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}?
;
fragment
JavaLetterOrDigit
: [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F
| // covers all characters above 0x7F which are not a surrogate
~[\u0000-\u007F\uD800-\uDBFF]
{Character.isJavaIdentifierPart(_input.LA(-1))}?
| // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
[\uD800-\uDBFF] [\uDC00-\uDFFF]
{Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}?
;
//
// Whitespace and comments
//
WS : [ \t\r\n\u000C]+ -> skip
;
COMMENT
: '/*' .*? '*/' -> channel(HIDDEN)
;
LINE_COMMENT
: '//' ~[\r\n]* -> channel(HIDDEN)
;
| 33,444 | ANTLR | .g4 | 1,527 | 19.956123 | 133 | 0.759728 | luwrain/grammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | b3fe1bfbef9b90dc2d63d0d69aa090e45df2ee428c45f626c028727ab5b05728 | true | false | false | false |
168 | ANTLRv4Lexer.g4 | rbarzic_antlr2insta/grammars/ANTLRv4Lexer.g4 | /*
* [The "BSD license"]
* Copyright (c) 2014 Terence Parr
* Copyright (c) 2014 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** A grammar for ANTLR v4 tokens */
lexer grammar ANTLRv4Lexer;
tokens {
TOKEN_REF,
RULE_REF,
LEXER_CHAR_SET
}
@members {
/** Track whether we are inside of a rule and whether it is lexical parser.
* _currentRuleType==Token.INVALID_TYPE means that we are outside of a rule.
* At the first sign of a rule name reference and _currentRuleType==invalid,
* we can assume that we are starting a parser rule. Similarly, seeing
* a token reference when not already in rule means starting a token
* rule. The terminating ';' of a rule, flips this back to invalid type.
*
* This is not perfect logic but works. For example, "grammar T;" means
* that we start and stop a lexical rule for the "T;". Dangerous but works.
*
* The whole point of this state information is to distinguish
* between [..arg actions..] and [charsets]. Char sets can only occur in
* lexical rules and arg actions cannot occur.
*/
private int _currentRuleType = Token.INVALID_TYPE;
public int getCurrentRuleType() {
return _currentRuleType;
}
public void setCurrentRuleType(int ruleType) {
this._currentRuleType = ruleType;
}
protected void handleBeginArgAction() {
if (inLexerRule()) {
pushMode(LexerCharSet);
more();
}
else {
pushMode(ArgAction);
more();
}
}
@Override
public Token emit() {
if (_type == ID) {
String firstChar = _input.getText(Interval.of(_tokenStartCharIndex, _tokenStartCharIndex));
if (Character.isUpperCase(firstChar.charAt(0))) {
_type = TOKEN_REF;
} else {
_type = RULE_REF;
}
if (_currentRuleType == Token.INVALID_TYPE) { // if outside of rule def
_currentRuleType = _type; // set to inside lexer or parser rule
}
}
else if (_type == SEMI) { // exit rule def
_currentRuleType = Token.INVALID_TYPE;
}
return super.emit();
}
private boolean inLexerRule() {
return _currentRuleType == TOKEN_REF;
}
private boolean inParserRule() { // not used, but added for clarity
return _currentRuleType == RULE_REF;
}
}
DOC_COMMENT
: '/**' .*? ('*/' | EOF)
;
BLOCK_COMMENT
: '/*' .*? ('*/' | EOF) -> channel(HIDDEN)
;
LINE_COMMENT
: '//' ~[\r\n]* -> channel(HIDDEN)
;
BEGIN_ARG_ACTION
: '[' {handleBeginArgAction();}
;
// OPTIONS and TOKENS must also consume the opening brace that captures
// their option block, as this is teh easiest way to parse it separate
// to an ACTION block, despite it usingthe same {} delimiters.
//
OPTIONS : 'options' [ \t\f\n\r]* '{' ;
TOKENS : 'tokens' [ \t\f\n\r]* '{' ;
IMPORT : 'import' ;
FRAGMENT : 'fragment' ;
LEXER : 'lexer' ;
PARSER : 'parser' ;
GRAMMAR : 'grammar' ;
PROTECTED : 'protected' ;
PUBLIC : 'public' ;
PRIVATE : 'private' ;
RETURNS : 'returns' ;
LOCALS : 'locals' ;
THROWS : 'throws' ;
CATCH : 'catch' ;
FINALLY : 'finally' ;
MODE : 'mode' ;
COLON : ':' ;
COLONCOLON : '::' ;
COMMA : ',' ;
SEMI : ';' ;
LPAREN : '(' ;
RPAREN : ')' ;
RARROW : '->' ;
LT : '<' ;
GT : '>' ;
ASSIGN : '=' ;
QUESTION : '?' ;
STAR : '*' ;
PLUS : '+' ;
PLUS_ASSIGN : '+=' ;
OR : '|' ;
DOLLAR : '$' ;
DOT : '.' ;
RANGE : '..' ;
AT : '@' ;
POUND : '#' ;
NOT : '~' ;
RBRACE : '}' ;
/** Allow unicode rule/token names */
ID : NameStartChar NameChar*;
fragment
NameChar
: NameStartChar
| '0'..'9'
| '_'
| '\u00B7'
| '\u0300'..'\u036F'
| '\u203F'..'\u2040'
;
fragment
NameStartChar
: 'A'..'Z'
| 'a'..'z'
| '\u00C0'..'\u00D6'
| '\u00D8'..'\u00F6'
| '\u00F8'..'\u02FF'
| '\u0370'..'\u037D'
| '\u037F'..'\u1FFF'
| '\u200C'..'\u200D'
| '\u2070'..'\u218F'
| '\u2C00'..'\u2FEF'
| '\u3001'..'\uD7FF'
| '\uF900'..'\uFDCF'
| '\uFDF0'..'\uFFFD'
; // ignores | ['\u10000-'\uEFFFF] ;
INT : [0-9]+
;
// ANTLR makes no distinction between a single character literal and a
// multi-character string. All literals are single quote delimited and
// may contain unicode escape sequences of the form \uxxxx, where x
// is a valid hexadecimal number (as per Java basically).
STRING_LITERAL
: '\'' (ESC_SEQ | ~['\r\n\\])* '\''
;
UNTERMINATED_STRING_LITERAL
: '\'' (ESC_SEQ | ~['\r\n\\])*
;
// Any kind of escaped character that we can embed within ANTLR
// literal strings.
fragment
ESC_SEQ
: '\\'
( // The standard escaped character set such as tab, newline, etc.
[btnfr"'\\]
| // A Java style Unicode escape sequence
UNICODE_ESC
| // Invalid escape
.
| // Invalid escape at end of file
EOF
)
;
fragment
UNICODE_ESC
: 'u' (HEX_DIGIT (HEX_DIGIT (HEX_DIGIT HEX_DIGIT?)?)?)?
;
fragment
HEX_DIGIT : [0-9a-fA-F] ;
WS : [ \t\r\n\f]+ -> channel(HIDDEN) ;
// Many language targets use {} as block delimiters and so we
// must recursively match {} delimited blocks to balance the
// braces. Additionally, we must make some assumptions about
// literal string representation in the target language. We assume
// that they are delimited by ' or " and so consume these
// in their own alts so as not to inadvertantly match {}.
ACTION
: '{'
( ACTION
| ACTION_ESCAPE
| ACTION_STRING_LITERAL
| ACTION_CHAR_LITERAL
| '/*' .*? '*/' // ('*/' | EOF)
| '//' ~[\r\n]*
| .
)*?
('}'|EOF)
;
fragment
ACTION_ESCAPE
: '\\' .
;
fragment
ACTION_STRING_LITERAL
: '"' (ACTION_ESCAPE | ~["\\])* '"'
;
fragment
ACTION_CHAR_LITERAL
: '\'' (ACTION_ESCAPE | ~['\\])* '\''
;
// -----------------
// Illegal Character
//
// This is an illegal character trap which is always the last rule in the
// lexer specification. It matches a single character of any value and being
// the last rule in the file will match when no other rule knows what to do
// about the character. It is reported as an error but is not passed on to the
// parser. This means that the parser to deal with the gramamr file anyway
// but we will not try to analyse or code generate from a file with lexical
// errors.
//
ERRCHAR
: . -> channel(HIDDEN)
;
mode ArgAction; // E.g., [int x, List<String> a[]]
NESTED_ARG_ACTION
: '[' -> more, pushMode(ArgAction)
;
ARG_ACTION_ESCAPE
: '\\' . -> more
;
ARG_ACTION_STRING_LITERAL
: ('"' ('\\' . | ~["\\])* '"')-> more
;
ARG_ACTION_CHAR_LITERAL
: ('"' '\\' . | ~["\\] '"') -> more
;
ARG_ACTION
: ']' -> popMode
;
UNTERMINATED_ARG_ACTION // added this to return non-EOF token type here. EOF did something weird
: EOF -> popMode
;
ARG_ACTION_CHAR // must be last
: . -> more
;
mode LexerCharSet;
LEXER_CHAR_SET_BODY
: ( ~[\]\\]
| '\\' .
)+
-> more
;
LEXER_CHAR_SET
: ']' -> popMode
;
UNTERMINATED_CHAR_SET
: EOF -> popMode
;
| 9,260 | ANTLR | .g4 | 287 | 29.56446 | 97 | 0.57607 | rbarzic/antlr2insta | 0 | 1 | 0 | EPL-1.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 00d36f20fded9d5ee3b359e9ce1539a869065d69e956f0560285387b8321de06 | true | true | false | false |
169 | ANTLRv4Parser.g4 | rbarzic_antlr2insta/grammars/ANTLRv4Parser.g4 | /*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** A grammar for ANTLR v4 written in ANTLR v4.
*/
parser grammar ANTLRv4Parser;
options {
tokenVocab=ANTLRv4Lexer;
}
// The main entry point for parsing a v4 grammar.
grammarSpec
: DOC_COMMENT?
grammarType id SEMI
prequelConstruct*
rules
modeSpec*
EOF
;
grammarType
: ( LEXER GRAMMAR
| PARSER GRAMMAR
| GRAMMAR
)
;
// This is the list of all constructs that can be declared before
// the set of rules that compose the grammar, and is invoked 0..n
// times by the grammarPrequel rule.
prequelConstruct
: optionsSpec
| delegateGrammars
| tokensSpec
| action
;
// A list of options that affect analysis and/or code generation
optionsSpec
: OPTIONS (option SEMI)* RBRACE
;
option
: id ASSIGN optionValue
;
optionValue
: id (DOT id)*
| STRING_LITERAL
| ACTION
| INT
;
delegateGrammars
: IMPORT delegateGrammar (COMMA delegateGrammar)* SEMI
;
delegateGrammar
: id ASSIGN id
| id
;
tokensSpec
: TOKENS id (COMMA id)* COMMA? RBRACE
;
/** Match stuff like @parser::members {int i;} */
action
: AT (actionScopeName COLONCOLON)? id ACTION
;
/** Sometimes the scope names will collide with keywords; allow them as
* ids for action scopes.
*/
actionScopeName
: id
| LEXER
| PARSER
;
modeSpec
: MODE id SEMI lexerRule*
;
rules
: ruleSpec*
;
ruleSpec
: parserRuleSpec
| lexerRule
;
parserRuleSpec
: DOC_COMMENT?
ruleModifiers? RULE_REF ARG_ACTION?
ruleReturns? throwsSpec? localsSpec?
rulePrequel*
COLON
ruleBlock
SEMI
exceptionGroup
;
exceptionGroup
: exceptionHandler* finallyClause?
;
exceptionHandler
: CATCH ARG_ACTION ACTION
;
finallyClause
: FINALLY ACTION
;
rulePrequel
: optionsSpec
| ruleAction
;
ruleReturns
: RETURNS ARG_ACTION
;
throwsSpec
: THROWS id (COMMA id)*
;
localsSpec
: LOCALS ARG_ACTION
;
/** Match stuff like @init {int i;} */
ruleAction
: AT id ACTION
;
ruleModifiers
: ruleModifier+
;
// An individual access modifier for a rule. The 'fragment' modifier
// is an internal indication for lexer rules that they do not match
// from the input but are like subroutines for other lexer rules to
// reuse for certain lexical patterns. The other modifiers are passed
// to the code generation templates and may be ignored by the template
// if they are of no use in that language.
ruleModifier
: PUBLIC
| PRIVATE
| PROTECTED
| FRAGMENT
;
ruleBlock
: ruleAltList
;
ruleAltList
: labeledAlt (OR labeledAlt)*
;
labeledAlt
: alternative (POUND id)?
;
lexerRule
: DOC_COMMENT? FRAGMENT?
TOKEN_REF COLON lexerRuleBlock SEMI
;
lexerRuleBlock
: lexerAltList
;
lexerAltList
: lexerAlt (OR lexerAlt)*
;
lexerAlt
: lexerElements lexerCommands?
|
;
lexerElements
: lexerElement+
;
lexerElement
: labeledLexerElement ebnfSuffix?
| lexerAtom ebnfSuffix?
| lexerBlock ebnfSuffix?
| ACTION QUESTION? // actions only allowed at end of outer alt actually,
// but preds can be anywhere
;
labeledLexerElement
: id (ASSIGN|PLUS_ASSIGN)
( lexerAtom
| block
)
;
lexerBlock
: LPAREN lexerAltList RPAREN
;
// E.g., channel(HIDDEN), skip, more, mode(INSIDE), push(INSIDE), pop
lexerCommands
: RARROW lexerCommand (COMMA lexerCommand)*
;
lexerCommand
: lexerCommandName LPAREN lexerCommandExpr RPAREN
| lexerCommandName
;
lexerCommandName
: id
| MODE
;
lexerCommandExpr
: id
| INT
;
altList
: alternative (OR alternative)*
;
alternative
: elementOptions? element*
;
element
: labeledElement
( ebnfSuffix
|
)
| atom
( ebnfSuffix
|
)
| ebnf
| ACTION QUESTION? // SEMPRED is ACTION followed by QUESTION
;
labeledElement
: id (ASSIGN|PLUS_ASSIGN)
( atom
| block
)
;
ebnf: block blockSuffix?
;
blockSuffix
: ebnfSuffix // Standard EBNF
;
ebnfSuffix
: QUESTION QUESTION?
| STAR QUESTION?
| PLUS QUESTION?
;
lexerAtom
: range
| terminal
| RULE_REF
| notSet
| LEXER_CHAR_SET
| DOT elementOptions?
;
atom
: range // Range x..y - only valid in lexers
| terminal
| ruleref
| notSet
| DOT elementOptions?
;
notSet
: NOT setElement
| NOT blockSet
;
blockSet
: LPAREN setElement (OR setElement)* RPAREN
;
setElement
: TOKEN_REF elementOptions?
| STRING_LITERAL elementOptions?
| range
| LEXER_CHAR_SET
;
block
: LPAREN
( optionsSpec? ruleAction* COLON )?
altList
RPAREN
;
ruleref
: RULE_REF ARG_ACTION? elementOptions?
;
range
: STRING_LITERAL RANGE STRING_LITERAL
;
terminal
: TOKEN_REF elementOptions?
| STRING_LITERAL elementOptions?
;
// Terminals may be adorned with certain options when
// reference in the grammar: TOK<,,,>
elementOptions
: LT elementOption (COMMA elementOption)* GT
;
elementOption
: // This format indicates the default node option
id
| // This format indicates option assignment
id ASSIGN (id | STRING_LITERAL)
;
id : RULE_REF
| TOKEN_REF
;
| 6,428 | ANTLR | .g4 | 305 | 18.868852 | 77 | 0.753877 | rbarzic/antlr2insta | 0 | 1 | 0 | EPL-1.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 9cdd889c2046dc13f6a3faf8e3cfb9cb81adf955c921267e40a8513649314310 | true | true | false | false |
170 | Python3.g4 | bartfrenk_entish/src/antlr/Python3.g4 | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 by Bart Kiers
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Project : python3-parser; an ANTLR4 grammar for Python 3
* https://github.com/bkiers/python3-parser
* Developed by : Bart Kiers, [email protected]
*/
grammar Python3;
// All comments that start with "///" are copy-pasted from
// The Python Language Reference
tokens { INDENT, DEDENT }
@lexer::members {
// A queue where extra tokens are pushed on (see the NEWLINE lexer rule).
private java.util.LinkedList<Token> tokens = new java.util.LinkedList<>();
// The stack that keeps track of the indentation level.
private java.util.Stack<Integer> indents = new java.util.Stack<>();
// The amount of opened braces, brackets and parenthesis.
private int opened = 0;
// The most recently produced token.
private Token lastToken = null;
@Override
public void emit(Token t) {
super.setToken(t);
tokens.offer(t);
}
@Override
public Token nextToken() {
// Check if the end-of-file is ahead and there are still some DEDENTS expected.
if (_input.LA(1) == EOF && !this.indents.isEmpty()) {
// Remove any trailing EOF tokens from our buffer.
for (int i = tokens.size() - 1; i >= 0; i--) {
if (tokens.get(i).getType() == EOF) {
tokens.remove(i);
}
}
// First emit an extra line break that serves as the end of the statement.
this.emit(commonToken(Python3Parser.NEWLINE, "\n"));
// Now emit as much DEDENT tokens as needed.
while (!indents.isEmpty()) {
this.emit(createDedent());
indents.pop();
}
// Put the EOF back on the token stream.
this.emit(commonToken(Python3Parser.EOF, "<EOF>"));
}
Token next = super.nextToken();
if (next.getChannel() == Token.DEFAULT_CHANNEL) {
// Keep track of the last token on the default channel.
this.lastToken = next;
}
return tokens.isEmpty() ? next : tokens.poll();
}
private Token createDedent() {
CommonToken dedent = commonToken(Python3Parser.DEDENT, "");
dedent.setLine(this.lastToken.getLine());
return dedent;
}
private CommonToken commonToken(int type, String text) {
int stop = this.getCharIndex() - 1;
int start = text.isEmpty() ? stop : stop - text.length() + 1;
return new CommonToken(this._tokenFactorySourcePair, type, DEFAULT_TOKEN_CHANNEL, start, stop);
}
// Calculates the indentation of the provided spaces, taking the
// following rules into account:
//
// "Tabs are replaced (from left to right) by one to eight spaces
// such that the total number of characters up to and including
// the replacement is a multiple of eight [...]"
//
// -- https://docs.python.org/3.1/reference/lexical_analysis.html#indentation
static int getIndentationCount(String spaces) {
int count = 0;
for (char ch : spaces.toCharArray()) {
switch (ch) {
case '\t':
count += 8 - (count % 8);
break;
default:
// A normal space char.
count++;
}
}
return count;
}
boolean atStartOfInput() {
return super.getCharPositionInLine() == 0 && super.getLine() == 1;
}
}
/*
* parser rules
*/
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE;
file_input: (NEWLINE | stmt)* EOF;
eval_input: testlist NEWLINE* EOF;
decorator: '@' dotted_name ( '(' (arglist)? ')' )? NEWLINE;
decorators: decorator+;
decorated: decorators (classdef | funcdef | async_funcdef);
async_funcdef: ASYNC funcdef;
funcdef: 'def' NAME parameters ('->' test)? ':' suite;
parameters: '(' (typedargslist)? ')';
typedargslist: (tfpdef ('=' test)? (',' tfpdef ('=' test)?)* (',' (
'*' (tfpdef)? (',' tfpdef ('=' test)?)* (',' ('**' tfpdef (',')?)?)?
| '**' tfpdef (',')?)?)?
| '*' (tfpdef)? (',' tfpdef ('=' test)?)* (',' ('**' tfpdef (',')?)?)?
| '**' tfpdef (',')?);
tfpdef: NAME (':' test)?;
varargslist: (vfpdef ('=' test)? (',' vfpdef ('=' test)?)* (',' (
'*' (vfpdef)? (',' vfpdef ('=' test)?)* (',' ('**' vfpdef (',')?)?)?
| '**' vfpdef (',')?)?)?
| '*' (vfpdef)? (',' vfpdef ('=' test)?)* (',' ('**' vfpdef (',')?)?)?
| '**' vfpdef (',')?
);
vfpdef: NAME;
stmt: simple_stmt | compound_stmt;
simple_stmt: small_stmt (';' small_stmt)* (';')? NEWLINE;
small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt |
import_stmt | global_stmt | nonlocal_stmt | assert_stmt);
expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) |
('=' (yield_expr|testlist_star_expr))*);
annassign: ':' test ('=' test)?;
testlist_star_expr: (test|star_expr) (',' (test|star_expr))* (',')?;
augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
'<<=' | '>>=' | '**=' | '//=');
// For normal and annotated assignments, additional restrictions enforced by the interpreter
del_stmt: 'del' exprlist;
pass_stmt: 'pass';
flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt;
break_stmt: 'break';
continue_stmt: 'continue';
return_stmt: 'return' (testlist)?;
yield_stmt: yield_expr;
raise_stmt: 'raise' (test ('from' test)?)?;
import_stmt: import_name | import_from;
import_name: 'import' dotted_as_names;
// note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+)
'import' ('*' | '(' import_as_names ')' | import_as_names));
import_as_name: NAME ('as' NAME)?;
dotted_as_name: dotted_name ('as' NAME)?;
import_as_names: import_as_name (',' import_as_name)* (',')?;
dotted_as_names: dotted_as_name (',' dotted_as_name)*;
dotted_name: NAME ('.' NAME)*;
global_stmt: 'global' NAME (',' NAME)*;
nonlocal_stmt: 'nonlocal' NAME (',' NAME)*;
assert_stmt: 'assert' test (',' test)?;
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt;
async_stmt: ASYNC (funcdef | with_stmt | for_stmt);
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ('else' ':' suite)?;
while_stmt: 'while' test ':' suite ('else' ':' suite)?;
for_stmt: 'for' exprlist 'in' testlist ':' suite ('else' ':' suite)?;
try_stmt: ('try' ':' suite
((except_clause ':' suite)+
('else' ':' suite)?
('finally' ':' suite)? |
'finally' ':' suite));
with_stmt: 'with' with_item (',' with_item)* ':' suite;
with_item: test ('as' expr)?;
// NB compile.c makes sure that the default except clause is last
except_clause: 'except' (test ('as' NAME)?)?;
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT;
test: or_test ('if' or_test 'else' test)? | lambdef;
test_nocond: or_test | lambdef_nocond;
lambdef: 'lambda' (varargslist)? ':' test;
lambdef_nocond: 'lambda' (varargslist)? ':' test_nocond;
or_test: and_test ('or' and_test)*;
and_test: not_test ('and' not_test)*;
not_test: 'not' not_test | comparison;
comparison: expr (comp_op expr)*;
// <> isn't actually a valid comparison operator in Python. It's here for the
// sake of a __future__ import described in PEP 401 (which really works :-)
comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not';
star_expr: '*' expr;
expr: xor_expr ('|' xor_expr)*;
xor_expr: and_expr ('^' and_expr)*;
and_expr: shift_expr ('&' shift_expr)*;
shift_expr: arith_expr (('<<'|'>>') arith_expr)*;
arith_expr: term (('+'|'-') term)*;
term: factor (('*'|'@'|'/'|'%'|'//') factor)*;
factor: ('+'|'-'|'~') factor | power;
power: atom_expr ('**' factor)?;
atom_expr: (AWAIT)? atom trailer*;
atom: ('(' (yield_expr|testlist_comp)? ')' |
'[' (testlist_comp)? ']' |
'{' (dictorsetmaker)? '}' |
NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False');
testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* (',')? );
trailer: '(' (arglist)? ')' | '[' subscriptlist ']' | '.' NAME;
subscriptlist: subscript (',' subscript)* (',')?;
subscript: test | (test)? ':' (test)? (sliceop)?;
sliceop: ':' (test)?;
exprlist: (expr|star_expr) (',' (expr|star_expr))* (',')?;
testlist: test (',' test)* (',')?;
dictorsetmaker: ( ((test ':' test | '**' expr)
(comp_for | (',' (test ':' test | '**' expr))* (',')?)) |
((test | star_expr)
(comp_for | (',' (test | star_expr))* (',')?)) );
classdef: 'class' NAME ('(' (arglist)? ')')? ':' suite;
arglist: argument (',' argument)* (',')?;
// The reason that keywords are test nodes instead of NAME is that using NAME
// results in an ambiguity. ast.c makes sure it's a NAME.
// "test '=' test" is really "keyword '=' test", but we have no such token.
// These need to be in a single rule to avoid grammar that is ambiguous
// to our LL(1) parser. Even though 'test' includes '*expr' in star_expr,
// we explicitly match '*' here, too, to give it proper precedence.
// Illegal combinations and orderings are blocked in ast.c:
// multiple (test comp_for) arguments are blocked; keyword unpackings
// that precede iterable unpackings are blocked; etc.
argument: ( test (comp_for)? |
test '=' test |
'**' test |
'*' test );
comp_iter: comp_for | comp_if;
comp_for: (ASYNC)? 'for' exprlist 'in' or_test (comp_iter)?;
comp_if: 'if' test_nocond (comp_iter)?;
// not used in grammar, but may appear in "node" passed from Parser to Compiler
encoding_decl: NAME;
yield_expr: 'yield' (yield_arg)?;
yield_arg: 'from' test | testlist;
/*
* lexer rules
*/
STRING
: STRING_LITERAL
| BYTES_LITERAL
;
NUMBER
: INTEGER
| FLOAT_NUMBER
| IMAG_NUMBER
;
INTEGER
: DECIMAL_INTEGER
| OCT_INTEGER
| HEX_INTEGER
| BIN_INTEGER
;
DEF : 'def';
RETURN : 'return';
RAISE : 'raise';
FROM : 'from';
IMPORT : 'import';
AS : 'as';
GLOBAL : 'global';
NONLOCAL : 'nonlocal';
ASSERT : 'assert';
IF : 'if';
ELIF : 'elif';
ELSE : 'else';
WHILE : 'while';
FOR : 'for';
IN : 'in';
TRY : 'try';
FINALLY : 'finally';
WITH : 'with';
EXCEPT : 'except';
LAMBDA : 'lambda';
OR : 'or';
AND : 'and';
NOT : 'not';
IS : 'is';
NONE : 'None';
TRUE : 'True';
FALSE : 'False';
CLASS : 'class';
YIELD : 'yield';
DEL : 'del';
PASS : 'pass';
CONTINUE : 'continue';
BREAK : 'break';
ASYNC : 'async';
AWAIT : 'await';
NEWLINE
: ( {atStartOfInput()}? SPACES
| ( '\r'? '\n' | '\r' | '\f' ) SPACES?
)
{
String newLine = getText().replaceAll("[^\r\n\f]+", "");
String spaces = getText().replaceAll("[\r\n\f]+", "");
int next = _input.LA(1);
if (opened > 0 || next == '\r' || next == '\n' || next == '\f' || next == '#') {
// If we're inside a list or on a blank line, ignore all indents,
// dedents and line breaks.
skip();
}
else {
emit(commonToken(NEWLINE, newLine));
int indent = getIndentationCount(spaces);
int previous = indents.isEmpty() ? 0 : indents.peek();
if (indent == previous) {
// skip indents of the same size as the present indent-size
skip();
}
else if (indent > previous) {
indents.push(indent);
emit(commonToken(Python3Parser.INDENT, spaces));
}
else {
// Possibly emit more than 1 DEDENT token.
while(!indents.isEmpty() && indents.peek() > indent) {
this.emit(createDedent());
indents.pop();
}
}
}
}
;
/// identifier ::= id_start id_continue*
NAME
: ID_START ID_CONTINUE*
;
/// stringliteral ::= [stringprefix](shortstring | longstring)
/// stringprefix ::= "r" | "u" | "R" | "U" | "f" | "F"
/// | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF"
STRING_LITERAL
: ( [rR] | [uU] | [fF] | ( [fF] [rR] ) | ( [rR] [fF] ) )? ( SHORT_STRING | LONG_STRING )
;
/// bytesliteral ::= bytesprefix(shortbytes | longbytes)
/// bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB"
BYTES_LITERAL
: ( [bB] | ( [bB] [rR] ) | ( [rR] [bB] ) ) ( SHORT_BYTES | LONG_BYTES )
;
/// decimalinteger ::= nonzerodigit digit* | "0"+
DECIMAL_INTEGER
: NON_ZERO_DIGIT DIGIT*
| '0'+
;
/// octinteger ::= "0" ("o" | "O") octdigit+
OCT_INTEGER
: '0' [oO] OCT_DIGIT+
;
/// hexinteger ::= "0" ("x" | "X") hexdigit+
HEX_INTEGER
: '0' [xX] HEX_DIGIT+
;
/// bininteger ::= "0" ("b" | "B") bindigit+
BIN_INTEGER
: '0' [bB] BIN_DIGIT+
;
/// floatnumber ::= pointfloat | exponentfloat
FLOAT_NUMBER
: POINT_FLOAT
| EXPONENT_FLOAT
;
/// imagnumber ::= (floatnumber | intpart) ("j" | "J")
IMAG_NUMBER
: ( FLOAT_NUMBER | INT_PART ) [jJ]
;
DOT : '.';
ELLIPSIS : '...';
STAR : '*';
OPEN_PAREN : '(' {opened++;};
CLOSE_PAREN : ')' {opened--;};
COMMA : ',';
COLON : ':';
SEMI_COLON : ';';
POWER : '**';
ASSIGN : '=';
OPEN_BRACK : '[' {opened++;};
CLOSE_BRACK : ']' {opened--;};
OR_OP : '|';
XOR : '^';
AND_OP : '&';
LEFT_SHIFT : '<<';
RIGHT_SHIFT : '>>';
ADD : '+';
MINUS : '-';
DIV : '/';
MOD : '%';
IDIV : '//';
NOT_OP : '~';
OPEN_BRACE : '{' {opened++;};
CLOSE_BRACE : '}' {opened--;};
LESS_THAN : '<';
GREATER_THAN : '>';
EQUALS : '==';
GT_EQ : '>=';
LT_EQ : '<=';
NOT_EQ_1 : '<>';
NOT_EQ_2 : '!=';
AT : '@';
ARROW : '->';
ADD_ASSIGN : '+=';
SUB_ASSIGN : '-=';
MULT_ASSIGN : '*=';
AT_ASSIGN : '@=';
DIV_ASSIGN : '/=';
MOD_ASSIGN : '%=';
AND_ASSIGN : '&=';
OR_ASSIGN : '|=';
XOR_ASSIGN : '^=';
LEFT_SHIFT_ASSIGN : '<<=';
RIGHT_SHIFT_ASSIGN : '>>=';
POWER_ASSIGN : '**=';
IDIV_ASSIGN : '//=';
SKIP_
: ( SPACES | COMMENT | LINE_JOINING ) -> skip
;
UNKNOWN_CHAR
: .
;
/*
* fragments
*/
/// shortstring ::= "'" shortstringitem* "'" | '"' shortstringitem* '"'
/// shortstringitem ::= shortstringchar | stringescapeseq
/// shortstringchar ::= <any source character except "\" or newline or the quote>
fragment SHORT_STRING
: '\'' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f'] )* '\''
| '"' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f"] )* '"'
;
/// longstring ::= "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
fragment LONG_STRING
: '\'\'\'' LONG_STRING_ITEM*? '\'\'\''
| '"""' LONG_STRING_ITEM*? '"""'
;
/// longstringitem ::= longstringchar | stringescapeseq
fragment LONG_STRING_ITEM
: LONG_STRING_CHAR
| STRING_ESCAPE_SEQ
;
/// longstringchar ::= <any source character except "\">
fragment LONG_STRING_CHAR
: ~'\\'
;
/// stringescapeseq ::= "\" <any source character>
fragment STRING_ESCAPE_SEQ
: '\\' .
| '\\' NEWLINE
;
/// nonzerodigit ::= "1"..."9"
fragment NON_ZERO_DIGIT
: [1-9]
;
/// digit ::= "0"..."9"
fragment DIGIT
: [0-9]
;
/// octdigit ::= "0"..."7"
fragment OCT_DIGIT
: [0-7]
;
/// hexdigit ::= digit | "a"..."f" | "A"..."F"
fragment HEX_DIGIT
: [0-9a-fA-F]
;
/// bindigit ::= "0" | "1"
fragment BIN_DIGIT
: [01]
;
/// pointfloat ::= [intpart] fraction | intpart "."
fragment POINT_FLOAT
: INT_PART? FRACTION
| INT_PART '.'
;
/// exponentfloat ::= (intpart | pointfloat) exponent
fragment EXPONENT_FLOAT
: ( INT_PART | POINT_FLOAT ) EXPONENT
;
/// intpart ::= digit+
fragment INT_PART
: DIGIT+
;
/// fraction ::= "." digit+
fragment FRACTION
: '.' DIGIT+
;
/// exponent ::= ("e" | "E") ["+" | "-"] digit+
fragment EXPONENT
: [eE] [+-]? DIGIT+
;
/// shortbytes ::= "'" shortbytesitem* "'" | '"' shortbytesitem* '"'
/// shortbytesitem ::= shortbyteschar | bytesescapeseq
fragment SHORT_BYTES
: '\'' ( SHORT_BYTES_CHAR_NO_SINGLE_QUOTE | BYTES_ESCAPE_SEQ )* '\''
| '"' ( SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE | BYTES_ESCAPE_SEQ )* '"'
;
/// longbytes ::= "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""'
fragment LONG_BYTES
: '\'\'\'' LONG_BYTES_ITEM*? '\'\'\''
| '"""' LONG_BYTES_ITEM*? '"""'
;
/// longbytesitem ::= longbyteschar | bytesescapeseq
fragment LONG_BYTES_ITEM
: LONG_BYTES_CHAR
| BYTES_ESCAPE_SEQ
;
/// shortbyteschar ::= <any ASCII character except "\" or newline or the quote>
fragment SHORT_BYTES_CHAR_NO_SINGLE_QUOTE
: [\u0000-\u0009]
| [\u000B-\u000C]
| [\u000E-\u0026]
| [\u0028-\u005B]
| [\u005D-\u007F]
;
fragment SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE
: [\u0000-\u0009]
| [\u000B-\u000C]
| [\u000E-\u0021]
| [\u0023-\u005B]
| [\u005D-\u007F]
;
/// longbyteschar ::= <any ASCII character except "\">
fragment LONG_BYTES_CHAR
: [\u0000-\u005B]
| [\u005D-\u007F]
;
/// bytesescapeseq ::= "\" <any ASCII character>
fragment BYTES_ESCAPE_SEQ
: '\\' [\u0000-\u007F]
;
fragment SPACES
: [ \t]+
;
fragment COMMENT
: '#' ~[\r\n\f]*
;
fragment LINE_JOINING
: '\\' SPACES? ( '\r'? '\n' | '\r' | '\f')
;
/// id_start ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>
fragment ID_START
: '_'
| [A-Z]
| [a-z]
| '\u00AA'
| '\u00B5'
| '\u00BA'
| [\u00C0-\u00D6]
| [\u00D8-\u00F6]
| [\u00F8-\u01BA]
| '\u01BB'
| [\u01BC-\u01BF]
| [\u01C0-\u01C3]
| [\u01C4-\u0241]
| [\u0250-\u02AF]
| [\u02B0-\u02C1]
| [\u02C6-\u02D1]
| [\u02E0-\u02E4]
| '\u02EE'
| '\u037A'
| '\u0386'
| [\u0388-\u038A]
| '\u038C'
| [\u038E-\u03A1]
| [\u03A3-\u03CE]
| [\u03D0-\u03F5]
| [\u03F7-\u0481]
| [\u048A-\u04CE]
| [\u04D0-\u04F9]
| [\u0500-\u050F]
| [\u0531-\u0556]
| '\u0559'
| [\u0561-\u0587]
| [\u05D0-\u05EA]
| [\u05F0-\u05F2]
| [\u0621-\u063A]
| '\u0640'
| [\u0641-\u064A]
| [\u066E-\u066F]
| [\u0671-\u06D3]
| '\u06D5'
| [\u06E5-\u06E6]
| [\u06EE-\u06EF]
| [\u06FA-\u06FC]
| '\u06FF'
| '\u0710'
| [\u0712-\u072F]
| [\u074D-\u076D]
| [\u0780-\u07A5]
| '\u07B1'
| [\u0904-\u0939]
| '\u093D'
| '\u0950'
| [\u0958-\u0961]
| '\u097D'
| [\u0985-\u098C]
| [\u098F-\u0990]
| [\u0993-\u09A8]
| [\u09AA-\u09B0]
| '\u09B2'
| [\u09B6-\u09B9]
| '\u09BD'
| '\u09CE'
| [\u09DC-\u09DD]
| [\u09DF-\u09E1]
| [\u09F0-\u09F1]
| [\u0A05-\u0A0A]
| [\u0A0F-\u0A10]
| [\u0A13-\u0A28]
| [\u0A2A-\u0A30]
| [\u0A32-\u0A33]
| [\u0A35-\u0A36]
| [\u0A38-\u0A39]
| [\u0A59-\u0A5C]
| '\u0A5E'
| [\u0A72-\u0A74]
| [\u0A85-\u0A8D]
| [\u0A8F-\u0A91]
| [\u0A93-\u0AA8]
| [\u0AAA-\u0AB0]
| [\u0AB2-\u0AB3]
| [\u0AB5-\u0AB9]
| '\u0ABD'
| '\u0AD0'
| [\u0AE0-\u0AE1]
| [\u0B05-\u0B0C]
| [\u0B0F-\u0B10]
| [\u0B13-\u0B28]
| [\u0B2A-\u0B30]
| [\u0B32-\u0B33]
| [\u0B35-\u0B39]
| '\u0B3D'
| [\u0B5C-\u0B5D]
| [\u0B5F-\u0B61]
| '\u0B71'
| '\u0B83'
| [\u0B85-\u0B8A]
| [\u0B8E-\u0B90]
| [\u0B92-\u0B95]
| [\u0B99-\u0B9A]
| '\u0B9C'
| [\u0B9E-\u0B9F]
| [\u0BA3-\u0BA4]
| [\u0BA8-\u0BAA]
| [\u0BAE-\u0BB9]
| [\u0C05-\u0C0C]
| [\u0C0E-\u0C10]
| [\u0C12-\u0C28]
| [\u0C2A-\u0C33]
| [\u0C35-\u0C39]
| [\u0C60-\u0C61]
| [\u0C85-\u0C8C]
| [\u0C8E-\u0C90]
| [\u0C92-\u0CA8]
| [\u0CAA-\u0CB3]
| [\u0CB5-\u0CB9]
| '\u0CBD'
| '\u0CDE'
| [\u0CE0-\u0CE1]
| [\u0D05-\u0D0C]
| [\u0D0E-\u0D10]
| [\u0D12-\u0D28]
| [\u0D2A-\u0D39]
| [\u0D60-\u0D61]
| [\u0D85-\u0D96]
| [\u0D9A-\u0DB1]
| [\u0DB3-\u0DBB]
| '\u0DBD'
| [\u0DC0-\u0DC6]
| [\u0E01-\u0E30]
| [\u0E32-\u0E33]
| [\u0E40-\u0E45]
| '\u0E46'
| [\u0E81-\u0E82]
| '\u0E84'
| [\u0E87-\u0E88]
| '\u0E8A'
| '\u0E8D'
| [\u0E94-\u0E97]
| [\u0E99-\u0E9F]
| [\u0EA1-\u0EA3]
| '\u0EA5'
| '\u0EA7'
| [\u0EAA-\u0EAB]
| [\u0EAD-\u0EB0]
| [\u0EB2-\u0EB3]
| '\u0EBD'
| [\u0EC0-\u0EC4]
| '\u0EC6'
| [\u0EDC-\u0EDD]
| '\u0F00'
| [\u0F40-\u0F47]
| [\u0F49-\u0F6A]
| [\u0F88-\u0F8B]
| [\u1000-\u1021]
| [\u1023-\u1027]
| [\u1029-\u102A]
| [\u1050-\u1055]
| [\u10A0-\u10C5]
| [\u10D0-\u10FA]
| '\u10FC'
| [\u1100-\u1159]
| [\u115F-\u11A2]
| [\u11A8-\u11F9]
| [\u1200-\u1248]
| [\u124A-\u124D]
| [\u1250-\u1256]
| '\u1258'
| [\u125A-\u125D]
| [\u1260-\u1288]
| [\u128A-\u128D]
| [\u1290-\u12B0]
| [\u12B2-\u12B5]
| [\u12B8-\u12BE]
| '\u12C0'
| [\u12C2-\u12C5]
| [\u12C8-\u12D6]
| [\u12D8-\u1310]
| [\u1312-\u1315]
| [\u1318-\u135A]
| [\u1380-\u138F]
| [\u13A0-\u13F4]
| [\u1401-\u166C]
| [\u166F-\u1676]
| [\u1681-\u169A]
| [\u16A0-\u16EA]
| [\u16EE-\u16F0]
| [\u1700-\u170C]
| [\u170E-\u1711]
| [\u1720-\u1731]
| [\u1740-\u1751]
| [\u1760-\u176C]
| [\u176E-\u1770]
| [\u1780-\u17B3]
| '\u17D7'
| '\u17DC'
| [\u1820-\u1842]
| '\u1843'
| [\u1844-\u1877]
| [\u1880-\u18A8]
| [\u1900-\u191C]
| [\u1950-\u196D]
| [\u1970-\u1974]
| [\u1980-\u19A9]
| [\u19C1-\u19C7]
| [\u1A00-\u1A16]
| [\u1D00-\u1D2B]
| [\u1D2C-\u1D61]
| [\u1D62-\u1D77]
| '\u1D78'
| [\u1D79-\u1D9A]
| [\u1D9B-\u1DBF]
| [\u1E00-\u1E9B]
| [\u1EA0-\u1EF9]
| [\u1F00-\u1F15]
| [\u1F18-\u1F1D]
| [\u1F20-\u1F45]
| [\u1F48-\u1F4D]
| [\u1F50-\u1F57]
| '\u1F59'
| '\u1F5B'
| '\u1F5D'
| [\u1F5F-\u1F7D]
| [\u1F80-\u1FB4]
| [\u1FB6-\u1FBC]
| '\u1FBE'
| [\u1FC2-\u1FC4]
| [\u1FC6-\u1FCC]
| [\u1FD0-\u1FD3]
| [\u1FD6-\u1FDB]
| [\u1FE0-\u1FEC]
| [\u1FF2-\u1FF4]
| [\u1FF6-\u1FFC]
| '\u2071'
| '\u207F'
| [\u2090-\u2094]
| '\u2102'
| '\u2107'
| [\u210A-\u2113]
| '\u2115'
| '\u2118'
| [\u2119-\u211D]
| '\u2124'
| '\u2126'
| '\u2128'
| [\u212A-\u212D]
| '\u212E'
| [\u212F-\u2131]
| [\u2133-\u2134]
| [\u2135-\u2138]
| '\u2139'
| [\u213C-\u213F]
| [\u2145-\u2149]
| [\u2160-\u2183]
| [\u2C00-\u2C2E]
| [\u2C30-\u2C5E]
| [\u2C80-\u2CE4]
| [\u2D00-\u2D25]
| [\u2D30-\u2D65]
| '\u2D6F'
| [\u2D80-\u2D96]
| [\u2DA0-\u2DA6]
| [\u2DA8-\u2DAE]
| [\u2DB0-\u2DB6]
| [\u2DB8-\u2DBE]
| [\u2DC0-\u2DC6]
| [\u2DC8-\u2DCE]
| [\u2DD0-\u2DD6]
| [\u2DD8-\u2DDE]
| '\u3005'
| '\u3006'
| '\u3007'
| [\u3021-\u3029]
| [\u3031-\u3035]
| [\u3038-\u303A]
| '\u303B'
| '\u303C'
| [\u3041-\u3096]
| [\u309B-\u309C]
| [\u309D-\u309E]
| '\u309F'
| [\u30A1-\u30FA]
| [\u30FC-\u30FE]
| '\u30FF'
| [\u3105-\u312C]
| [\u3131-\u318E]
| [\u31A0-\u31B7]
| [\u31F0-\u31FF]
| [\u3400-\u4DB5]
| [\u4E00-\u9FBB]
| [\uA000-\uA014]
| '\uA015'
| [\uA016-\uA48C]
| [\uA800-\uA801]
| [\uA803-\uA805]
| [\uA807-\uA80A]
| [\uA80C-\uA822]
| [\uAC00-\uD7A3]
| [\uF900-\uFA2D]
| [\uFA30-\uFA6A]
| [\uFA70-\uFAD9]
| [\uFB00-\uFB06]
| [\uFB13-\uFB17]
| '\uFB1D'
| [\uFB1F-\uFB28]
| [\uFB2A-\uFB36]
| [\uFB38-\uFB3C]
| '\uFB3E'
| [\uFB40-\uFB41]
| [\uFB43-\uFB44]
| [\uFB46-\uFBB1]
| [\uFBD3-\uFD3D]
| [\uFD50-\uFD8F]
| [\uFD92-\uFDC7]
| [\uFDF0-\uFDFB]
| [\uFE70-\uFE74]
| [\uFE76-\uFEFC]
| [\uFF21-\uFF3A]
| [\uFF41-\uFF5A]
| [\uFF66-\uFF6F]
| '\uFF70'
| [\uFF71-\uFF9D]
| [\uFF9E-\uFF9F]
| [\uFFA0-\uFFBE]
| [\uFFC2-\uFFC7]
| [\uFFCA-\uFFCF]
| [\uFFD2-\uFFD7]
| [\uFFDA-\uFFDC]
;
/// id_continue ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
fragment ID_CONTINUE
: ID_START
| [0-9]
| [\u0300-\u036F]
| [\u0483-\u0486]
| [\u0591-\u05B9]
| [\u05BB-\u05BD]
| '\u05BF'
| [\u05C1-\u05C2]
| [\u05C4-\u05C5]
| '\u05C7'
| [\u0610-\u0615]
| [\u064B-\u065E]
| [\u0660-\u0669]
| '\u0670'
| [\u06D6-\u06DC]
| [\u06DF-\u06E4]
| [\u06E7-\u06E8]
| [\u06EA-\u06ED]
| [\u06F0-\u06F9]
| '\u0711'
| [\u0730-\u074A]
| [\u07A6-\u07B0]
| [\u0901-\u0902]
| '\u0903'
| '\u093C'
| [\u093E-\u0940]
| [\u0941-\u0948]
| [\u0949-\u094C]
| '\u094D'
| [\u0951-\u0954]
| [\u0962-\u0963]
| [\u0966-\u096F]
| '\u0981'
| [\u0982-\u0983]
| '\u09BC'
| [\u09BE-\u09C0]
| [\u09C1-\u09C4]
| [\u09C7-\u09C8]
| [\u09CB-\u09CC]
| '\u09CD'
| '\u09D7'
| [\u09E2-\u09E3]
| [\u09E6-\u09EF]
| [\u0A01-\u0A02]
| '\u0A03'
| '\u0A3C'
| [\u0A3E-\u0A40]
| [\u0A41-\u0A42]
| [\u0A47-\u0A48]
| [\u0A4B-\u0A4D]
| [\u0A66-\u0A6F]
| [\u0A70-\u0A71]
| [\u0A81-\u0A82]
| '\u0A83'
| '\u0ABC'
| [\u0ABE-\u0AC0]
| [\u0AC1-\u0AC5]
| [\u0AC7-\u0AC8]
| '\u0AC9'
| [\u0ACB-\u0ACC]
| '\u0ACD'
| [\u0AE2-\u0AE3]
| [\u0AE6-\u0AEF]
| '\u0B01'
| [\u0B02-\u0B03]
| '\u0B3C'
| '\u0B3E'
| '\u0B3F'
| '\u0B40'
| [\u0B41-\u0B43]
| [\u0B47-\u0B48]
| [\u0B4B-\u0B4C]
| '\u0B4D'
| '\u0B56'
| '\u0B57'
| [\u0B66-\u0B6F]
| '\u0B82'
| [\u0BBE-\u0BBF]
| '\u0BC0'
| [\u0BC1-\u0BC2]
| [\u0BC6-\u0BC8]
| [\u0BCA-\u0BCC]
| '\u0BCD'
| '\u0BD7'
| [\u0BE6-\u0BEF]
| [\u0C01-\u0C03]
| [\u0C3E-\u0C40]
| [\u0C41-\u0C44]
| [\u0C46-\u0C48]
| [\u0C4A-\u0C4D]
| [\u0C55-\u0C56]
| [\u0C66-\u0C6F]
| [\u0C82-\u0C83]
| '\u0CBC'
| '\u0CBE'
| '\u0CBF'
| [\u0CC0-\u0CC4]
| '\u0CC6'
| [\u0CC7-\u0CC8]
| [\u0CCA-\u0CCB]
| [\u0CCC-\u0CCD]
| [\u0CD5-\u0CD6]
| [\u0CE6-\u0CEF]
| [\u0D02-\u0D03]
| [\u0D3E-\u0D40]
| [\u0D41-\u0D43]
| [\u0D46-\u0D48]
| [\u0D4A-\u0D4C]
| '\u0D4D'
| '\u0D57'
| [\u0D66-\u0D6F]
| [\u0D82-\u0D83]
| '\u0DCA'
| [\u0DCF-\u0DD1]
| [\u0DD2-\u0DD4]
| '\u0DD6'
| [\u0DD8-\u0DDF]
| [\u0DF2-\u0DF3]
| '\u0E31'
| [\u0E34-\u0E3A]
| [\u0E47-\u0E4E]
| [\u0E50-\u0E59]
| '\u0EB1'
| [\u0EB4-\u0EB9]
| [\u0EBB-\u0EBC]
| [\u0EC8-\u0ECD]
| [\u0ED0-\u0ED9]
| [\u0F18-\u0F19]
| [\u0F20-\u0F29]
| '\u0F35'
| '\u0F37'
| '\u0F39'
| [\u0F3E-\u0F3F]
| [\u0F71-\u0F7E]
| '\u0F7F'
| [\u0F80-\u0F84]
| [\u0F86-\u0F87]
| [\u0F90-\u0F97]
| [\u0F99-\u0FBC]
| '\u0FC6'
| '\u102C'
| [\u102D-\u1030]
| '\u1031'
| '\u1032'
| [\u1036-\u1037]
| '\u1038'
| '\u1039'
| [\u1040-\u1049]
| [\u1056-\u1057]
| [\u1058-\u1059]
| '\u135F'
| [\u1369-\u1371]
| [\u1712-\u1714]
| [\u1732-\u1734]
| [\u1752-\u1753]
| [\u1772-\u1773]
| '\u17B6'
| [\u17B7-\u17BD]
| [\u17BE-\u17C5]
| '\u17C6'
| [\u17C7-\u17C8]
| [\u17C9-\u17D3]
| '\u17DD'
| [\u17E0-\u17E9]
| [\u180B-\u180D]
| [\u1810-\u1819]
| '\u18A9'
| [\u1920-\u1922]
| [\u1923-\u1926]
| [\u1927-\u1928]
| [\u1929-\u192B]
| [\u1930-\u1931]
| '\u1932'
| [\u1933-\u1938]
| [\u1939-\u193B]
| [\u1946-\u194F]
| [\u19B0-\u19C0]
| [\u19C8-\u19C9]
| [\u19D0-\u19D9]
| [\u1A17-\u1A18]
| [\u1A19-\u1A1B]
| [\u1DC0-\u1DC3]
| [\u203F-\u2040]
| '\u2054'
| [\u20D0-\u20DC]
| '\u20E1'
| [\u20E5-\u20EB]
| [\u302A-\u302F]
| [\u3099-\u309A]
| '\uA802'
| '\uA806'
| '\uA80B'
| [\uA823-\uA824]
| [\uA825-\uA826]
| '\uA827'
| '\uFB1E'
| [\uFE00-\uFE0F]
| [\uFE20-\uFE23]
| [\uFE33-\uFE34]
| [\uFE4D-\uFE4F]
| [\uFF10-\uFF19]
| '\uFF3F'
; | 26,984 | ANTLR | .g4 | 1,077 | 22.619313 | 148 | 0.577816 | bartfrenk/entish | 0 | 0 | 0 | EPL-1.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 382e9519e425f2b8983e3701e16f3eea7b5543a89ac20f578b51aacbb76364b9 | true | true | false | false |
171 | Entish.g4 | bartfrenk_entish/src/antlr/Entish.g4 | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 by Bart Kiers
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Project : python3-parser; an ANTLR4 grammar for Python 3
* https://github.com/bkiers/python3-parser
* Developed by : Bart Kiers, [email protected]
* Adapter by : Bart Frenk, [email protected]
*/
grammar Entish;
// All comments that start with "///" are copy-pasted from
// The Python Language Reference
tokens { INDENT, DEDENT }
@lexer::members {
// A queue where extra tokens are pushed on (see the NEWLINE lexer rule).
private java.util.LinkedList<Token> tokens = new java.util.LinkedList<>();
// The stack that keeps track of the indentation level.
private java.util.Stack<Integer> indents = new java.util.Stack<>();
// The amount of opened braces, brackets and parenthesis.
private int opened = 0;
// The most recently produced token.
private Token lastToken = null;
@Override
public void emit(Token t) {
super.setToken(t);
tokens.offer(t);
}
@Override
public Token nextToken() {
// Check if the end-of-file is ahead and there are still some DEDENTS expected.
if (_input.LA(1) == EOF && !this.indents.isEmpty()) {
// Remove any trailing EOF tokens from our buffer.
for (int i = tokens.size() - 1; i >= 0; i--) {
if (tokens.get(i).getType() == EOF) {
tokens.remove(i);
}
}
// First emit an extra line break that serves as the end of the statement.
this.emit(commonToken(Python3Parser.NEWLINE, "\n"));
// Now emit as much DEDENT tokens as needed.
while (!indents.isEmpty()) {
this.emit(createDedent());
indents.pop();
}
// Put the EOF back on the token stream.
this.emit(commonToken(Python3Parser.EOF, "<EOF>"));
}
Token next = super.nextToken();
if (next.getChannel() == Token.DEFAULT_CHANNEL) {
// Keep track of the last token on the default channel.
this.lastToken = next;
}
return tokens.isEmpty() ? next : tokens.poll();
}
private Token createDedent() {
CommonToken dedent = commonToken(Python3Parser.DEDENT, "");
dedent.setLine(this.lastToken.getLine());
return dedent;
}
private CommonToken commonToken(int type, String text) {
int stop = this.getCharIndex() - 1;
int start = text.isEmpty() ? stop : stop - text.length() + 1;
return new CommonToken(this._tokenFactorySourcePair, type, DEFAULT_TOKEN_CHANNEL, start, stop);
}
// Calculates the indentation of the provided spaces, taking the
// following rules into account:
//
// "Tabs are replaced (from left to right) by one to eight spaces
// such that the total number of characters up to and including
// the replacement is a multiple of eight [...]"
//
// -- https://docs.python.org/3.1/reference/lexical_analysis.html#indentation
static int getIndentationCount(String spaces) {
int count = 0;
for (char ch : spaces.toCharArray()) {
switch (ch) {
case '\t':
count += 8 - (count % 8);
break;
default:
// A normal space char.
count++;
}
}
return count;
}
boolean atStartOfInput() {
return super.getCharPositionInLine() == 0 && super.getLine() == 1;
}
}
/*
* parser rules
*/
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE;
file_input: (NEWLINE | stmt)* EOF;
eval_input: testlist NEWLINE* EOF;
decorator: '@' dotted_name ( '(' (arglist)? ')' )? NEWLINE;
decorators: decorator+;
decorated: decorators (classdef | funcdef | async_funcdef);
async_funcdef: ASYNC funcdef;
funcdef: 'def' NAME parameters ('->' test)? ':' suite;
parameters: '(' (typedargslist)? ')';
typedargslist: (tfpdef ('=' test)? (',' tfpdef ('=' test)?)* (',' (
'*' (tfpdef)? (',' tfpdef ('=' test)?)* (',' ('**' tfpdef (',')?)?)?
| '**' tfpdef (',')?)?)?
| '*' (tfpdef)? (',' tfpdef ('=' test)?)* (',' ('**' tfpdef (',')?)?)?
| '**' tfpdef (',')?);
tfpdef: NAME (':' test)?;
varargslist: (vfpdef ('=' test)? (',' vfpdef ('=' test)?)* (',' (
'*' (vfpdef)? (',' vfpdef ('=' test)?)* (',' ('**' vfpdef (',')?)?)?
| '**' vfpdef (',')?)?)?
| '*' (vfpdef)? (',' vfpdef ('=' test)?)* (',' ('**' vfpdef (',')?)?)?
| '**' vfpdef (',')?
);
vfpdef: NAME;
stmt: simple_stmt | compound_stmt;
simple_stmt: small_stmt (';' small_stmt)* (';')? NEWLINE;
small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt |
import_stmt | global_stmt | nonlocal_stmt | assert_stmt);
expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) |
('=' (yield_expr|testlist_star_expr))*);
annassign: ':' test ('=' test)?;
testlist_star_expr: (test|star_expr) (',' (test|star_expr))* (',')?;
augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
'<<=' | '>>=' | '**=' | '//=');
// For normal and annotated assignments, additional restrictions enforced by the interpreter
del_stmt: 'del' exprlist;
pass_stmt: 'pass';
flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt;
break_stmt: 'break';
continue_stmt: 'continue';
return_stmt: 'return' (testlist)?;
yield_stmt: yield_expr;
raise_stmt: 'raise' (test ('from' test)?)?;
import_stmt: import_name | import_from;
import_name: 'import' dotted_as_names;
// note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+)
'import' ('*' | '(' import_as_names ')' | import_as_names));
import_as_name: NAME ('as' NAME)?;
dotted_as_name: dotted_name ('as' NAME)?;
import_as_names: import_as_name (',' import_as_name)* (',')?;
dotted_as_names: dotted_as_name (',' dotted_as_name)*;
dotted_name: NAME ('.' NAME)*;
global_stmt: 'global' NAME (',' NAME)*;
nonlocal_stmt: 'nonlocal' NAME (',' NAME)*;
assert_stmt: 'assert' test (',' test)?;
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt;
async_stmt: ASYNC (funcdef | with_stmt | for_stmt);
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ('else' ':' suite)?;
while_stmt: 'while' test ':' suite ('else' ':' suite)?;
for_stmt: 'for' exprlist 'in' testlist ':' suite ('else' ':' suite)?;
try_stmt: ('try' ':' suite
((except_clause ':' suite)+
('else' ':' suite)?
('finally' ':' suite)? |
'finally' ':' suite));
with_stmt: 'with' with_item (',' with_item)* ':' suite;
with_item: test ('as' expr)?;
// NB compile.c makes sure that the default except clause is last
except_clause: 'except' (test ('as' NAME)?)?;
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT;
test: or_test ('if' or_test 'else' test)? | lambdef;
test_nocond: or_test | lambdef_nocond;
lambdef: 'lambda' (varargslist)? ':' test;
lambdef_nocond: 'lambda' (varargslist)? ':' test_nocond;
or_test: and_test ('or' and_test)*;
and_test: not_test ('and' not_test)*;
not_test: 'not' not_test | comparison;
comparison: expr (comp_op expr)*;
// <> isn't actually a valid comparison operator in Python. It's here for the
// sake of a __future__ import described in PEP 401 (which really works :-)
comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not';
star_expr: '*' expr;
expr: xor_expr ('|' xor_expr)*;
xor_expr: and_expr ('^' and_expr)*;
and_expr: shift_expr ('&' shift_expr)*;
shift_expr: arith_expr (('<<'|'>>') arith_expr)*;
arith_expr: term (('+'|'-') term)*;
term: factor (('*'|'@'|'/'|'%'|'//') factor)*;
factor: ('+'|'-'|'~') factor | power;
power: atom_expr ('**' factor)?;
atom_expr: (AWAIT)? atom trailer*;
atom: ('(' (yield_expr|testlist_comp)? ')' |
'[' (testlist_comp)? ']' |
'{' (dictorsetmaker)? '}' |
NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False');
testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* (',')? );
trailer: '(' (arglist)? ')' | '[' subscriptlist ']' | '.' NAME;
subscriptlist: subscript (',' subscript)* (',')?;
subscript: test | (test)? ':' (test)? (sliceop)?;
sliceop: ':' (test)?;
exprlist: (expr|star_expr) (',' (expr|star_expr))* (',')?;
testlist: test (',' test)* (',')?;
dictorsetmaker: ( ((test ':' test | '**' expr)
(comp_for | (',' (test ':' test | '**' expr))* (',')?)) |
((test | star_expr)
(comp_for | (',' (test | star_expr))* (',')?)) );
classdef: 'class' NAME ('(' (arglist)? ')')? ':' suite;
arglist: argument (',' argument)* (',')?;
// The reason that keywords are test nodes instead of NAME is that using NAME
// results in an ambiguity. ast.c makes sure it's a NAME.
// "test '=' test" is really "keyword '=' test", but we have no such token.
// These need to be in a single rule to avoid grammar that is ambiguous
// to our LL(1) parser. Even though 'test' includes '*expr' in star_expr,
// we explicitly match '*' here, too, to give it proper precedence.
// Illegal combinations and orderings are blocked in ast.c:
// multiple (test comp_for) arguments are blocked; keyword unpackings
// that precede iterable unpackings are blocked; etc.
argument: ( test (comp_for)? |
test '=' test |
'**' test |
'*' test );
comp_iter: comp_for | comp_if;
comp_for: (ASYNC)? 'for' exprlist 'in' or_test (comp_iter)?;
comp_if: 'if' test_nocond (comp_iter)?;
// not used in grammar, but may appear in "node" passed from Parser to Compiler
encoding_decl: NAME;
yield_expr: 'yield' (yield_arg)?;
yield_arg: 'from' test | testlist;
/*
* lexer rules
*/
STRING
: STRING_LITERAL
| BYTES_LITERAL
;
NUMBER
: INTEGER
| FLOAT_NUMBER
| IMAG_NUMBER
;
INTEGER
: DECIMAL_INTEGER
| OCT_INTEGER
| HEX_INTEGER
| BIN_INTEGER
;
DEF : 'def';
RETURN : 'return';
RAISE : 'raise';
FROM : 'from';
IMPORT : 'import';
AS : 'as';
GLOBAL : 'global';
NONLOCAL : 'nonlocal';
ASSERT : 'assert';
IF : 'if';
ELIF : 'elif';
ELSE : 'else';
WHILE : 'while';
FOR : 'for';
IN : 'in';
TRY : 'try';
FINALLY : 'finally';
WITH : 'with';
EXCEPT : 'except';
LAMBDA : 'lambda';
OR : 'or';
AND : 'and';
NOT : 'not';
IS : 'is';
NONE : 'None';
TRUE : 'True';
FALSE : 'False';
CLASS : 'class';
YIELD : 'yield';
DEL : 'del';
PASS : 'pass';
CONTINUE : 'continue';
BREAK : 'break';
ASYNC : 'async';
AWAIT : 'await';
NEWLINE
: ( {atStartOfInput()}? SPACES
| ( '\r'? '\n' | '\r' | '\f' ) SPACES?
)
{
String newLine = getText().replaceAll("[^\r\n\f]+", "");
String spaces = getText().replaceAll("[\r\n\f]+", "");
int next = _input.LA(1);
if (opened > 0 || next == '\r' || next == '\n' || next == '\f' || next == '#') {
// If we're inside a list or on a blank line, ignore all indents,
// dedents and line breaks.
skip();
}
else {
emit(commonToken(NEWLINE, newLine));
int indent = getIndentationCount(spaces);
int previous = indents.isEmpty() ? 0 : indents.peek();
if (indent == previous) {
// skip indents of the same size as the present indent-size
skip();
}
else if (indent > previous) {
indents.push(indent);
emit(commonToken(Python3Parser.INDENT, spaces));
}
else {
// Possibly emit more than 1 DEDENT token.
while(!indents.isEmpty() && indents.peek() > indent) {
this.emit(createDedent());
indents.pop();
}
}
}
}
;
/// identifier ::= id_start id_continue*
NAME
: ID_START ID_CONTINUE*
;
/// stringliteral ::= [stringprefix](shortstring | longstring)
/// stringprefix ::= "r" | "u" | "R" | "U" | "f" | "F"
/// | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF"
STRING_LITERAL
: ( [rR] | [uU] | [fF] | ( [fF] [rR] ) | ( [rR] [fF] ) )? ( SHORT_STRING | LONG_STRING )
;
/// bytesliteral ::= bytesprefix(shortbytes | longbytes)
/// bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB"
BYTES_LITERAL
: ( [bB] | ( [bB] [rR] ) | ( [rR] [bB] ) ) ( SHORT_BYTES | LONG_BYTES )
;
/// decimalinteger ::= nonzerodigit digit* | "0"+
DECIMAL_INTEGER
: NON_ZERO_DIGIT DIGIT*
| '0'+
;
/// octinteger ::= "0" ("o" | "O") octdigit+
OCT_INTEGER
: '0' [oO] OCT_DIGIT+
;
/// hexinteger ::= "0" ("x" | "X") hexdigit+
HEX_INTEGER
: '0' [xX] HEX_DIGIT+
;
/// bininteger ::= "0" ("b" | "B") bindigit+
BIN_INTEGER
: '0' [bB] BIN_DIGIT+
;
/// floatnumber ::= pointfloat | exponentfloat
FLOAT_NUMBER
: POINT_FLOAT
| EXPONENT_FLOAT
;
/// imagnumber ::= (floatnumber | intpart) ("j" | "J")
IMAG_NUMBER
: ( FLOAT_NUMBER | INT_PART ) [jJ]
;
DOT : '.';
ELLIPSIS : '...';
STAR : '*';
OPEN_PAREN : '(' {opened++;};
CLOSE_PAREN : ')' {opened--;};
COMMA : ',';
COLON : ':';
SEMI_COLON : ';';
POWER : '**';
ASSIGN : '=';
OPEN_BRACK : '[' {opened++;};
CLOSE_BRACK : ']' {opened--;};
OR_OP : '|';
XOR : '^';
AND_OP : '&';
LEFT_SHIFT : '<<';
RIGHT_SHIFT : '>>';
ADD : '+';
MINUS : '-';
DIV : '/';
MOD : '%';
IDIV : '//';
NOT_OP : '~';
OPEN_BRACE : '{' {opened++;};
CLOSE_BRACE : '}' {opened--;};
LESS_THAN : '<';
GREATER_THAN : '>';
EQUALS : '==';
GT_EQ : '>=';
LT_EQ : '<=';
NOT_EQ_1 : '<>';
NOT_EQ_2 : '!=';
AT : '@';
ARROW : '->';
ADD_ASSIGN : '+=';
SUB_ASSIGN : '-=';
MULT_ASSIGN : '*=';
AT_ASSIGN : '@=';
DIV_ASSIGN : '/=';
MOD_ASSIGN : '%=';
AND_ASSIGN : '&=';
OR_ASSIGN : '|=';
XOR_ASSIGN : '^=';
LEFT_SHIFT_ASSIGN : '<<=';
RIGHT_SHIFT_ASSIGN : '>>=';
POWER_ASSIGN : '**=';
IDIV_ASSIGN : '//=';
SKIP_
: ( SPACES | COMMENT | LINE_JOINING ) -> skip
;
UNKNOWN_CHAR
: .
;
/*
* fragments
*/
/// shortstring ::= "'" shortstringitem* "'" | '"' shortstringitem* '"'
/// shortstringitem ::= shortstringchar | stringescapeseq
/// shortstringchar ::= <any source character except "\" or newline or the quote>
fragment SHORT_STRING
: '\'' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f'] )* '\''
| '"' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f"] )* '"'
;
/// longstring ::= "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
fragment LONG_STRING
: '\'\'\'' LONG_STRING_ITEM*? '\'\'\''
| '"""' LONG_STRING_ITEM*? '"""'
;
/// longstringitem ::= longstringchar | stringescapeseq
fragment LONG_STRING_ITEM
: LONG_STRING_CHAR
| STRING_ESCAPE_SEQ
;
/// longstringchar ::= <any source character except "\">
fragment LONG_STRING_CHAR
: ~'\\'
;
/// stringescapeseq ::= "\" <any source character>
fragment STRING_ESCAPE_SEQ
: '\\' .
| '\\' NEWLINE
;
/// nonzerodigit ::= "1"..."9"
fragment NON_ZERO_DIGIT
: [1-9]
;
/// digit ::= "0"..."9"
fragment DIGIT
: [0-9]
;
/// octdigit ::= "0"..."7"
fragment OCT_DIGIT
: [0-7]
;
/// hexdigit ::= digit | "a"..."f" | "A"..."F"
fragment HEX_DIGIT
: [0-9a-fA-F]
;
/// bindigit ::= "0" | "1"
fragment BIN_DIGIT
: [01]
;
/// pointfloat ::= [intpart] fraction | intpart "."
fragment POINT_FLOAT
: INT_PART? FRACTION
| INT_PART '.'
;
/// exponentfloat ::= (intpart | pointfloat) exponent
fragment EXPONENT_FLOAT
: ( INT_PART | POINT_FLOAT ) EXPONENT
;
/// intpart ::= digit+
fragment INT_PART
: DIGIT+
;
/// fraction ::= "." digit+
fragment FRACTION
: '.' DIGIT+
;
/// exponent ::= ("e" | "E") ["+" | "-"] digit+
fragment EXPONENT
: [eE] [+-]? DIGIT+
;
/// shortbytes ::= "'" shortbytesitem* "'" | '"' shortbytesitem* '"'
/// shortbytesitem ::= shortbyteschar | bytesescapeseq
fragment SHORT_BYTES
: '\'' ( SHORT_BYTES_CHAR_NO_SINGLE_QUOTE | BYTES_ESCAPE_SEQ )* '\''
| '"' ( SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE | BYTES_ESCAPE_SEQ )* '"'
;
/// longbytes ::= "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""'
fragment LONG_BYTES
: '\'\'\'' LONG_BYTES_ITEM*? '\'\'\''
| '"""' LONG_BYTES_ITEM*? '"""'
;
/// longbytesitem ::= longbyteschar | bytesescapeseq
fragment LONG_BYTES_ITEM
: LONG_BYTES_CHAR
| BYTES_ESCAPE_SEQ
;
/// shortbyteschar ::= <any ASCII character except "\" or newline or the quote>
fragment SHORT_BYTES_CHAR_NO_SINGLE_QUOTE
: [\u0000-\u0009]
| [\u000B-\u000C]
| [\u000E-\u0026]
| [\u0028-\u005B]
| [\u005D-\u007F]
;
fragment SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE
: [\u0000-\u0009]
| [\u000B-\u000C]
| [\u000E-\u0021]
| [\u0023-\u005B]
| [\u005D-\u007F]
;
/// longbyteschar ::= <any ASCII character except "\">
fragment LONG_BYTES_CHAR
: [\u0000-\u005B]
| [\u005D-\u007F]
;
/// bytesescapeseq ::= "\" <any ASCII character>
fragment BYTES_ESCAPE_SEQ
: '\\' [\u0000-\u007F]
;
fragment SPACES
: [ \t]+
;
fragment COMMENT
: '#' ~[\r\n\f]*
;
fragment LINE_JOINING
: '\\' SPACES? ( '\r'? '\n' | '\r' | '\f')
;
/// id_start ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>
fragment ID_START
: '_'
| [A-Z]
| [a-z]
| '\u00AA'
| '\u00B5'
| '\u00BA'
| [\u00C0-\u00D6]
| [\u00D8-\u00F6]
| [\u00F8-\u01BA]
| '\u01BB'
| [\u01BC-\u01BF]
| [\u01C0-\u01C3]
| [\u01C4-\u0241]
| [\u0250-\u02AF]
| [\u02B0-\u02C1]
| [\u02C6-\u02D1]
| [\u02E0-\u02E4]
| '\u02EE'
| '\u037A'
| '\u0386'
| [\u0388-\u038A]
| '\u038C'
| [\u038E-\u03A1]
| [\u03A3-\u03CE]
| [\u03D0-\u03F5]
| [\u03F7-\u0481]
| [\u048A-\u04CE]
| [\u04D0-\u04F9]
| [\u0500-\u050F]
| [\u0531-\u0556]
| '\u0559'
| [\u0561-\u0587]
| [\u05D0-\u05EA]
| [\u05F0-\u05F2]
| [\u0621-\u063A]
| '\u0640'
| [\u0641-\u064A]
| [\u066E-\u066F]
| [\u0671-\u06D3]
| '\u06D5'
| [\u06E5-\u06E6]
| [\u06EE-\u06EF]
| [\u06FA-\u06FC]
| '\u06FF'
| '\u0710'
| [\u0712-\u072F]
| [\u074D-\u076D]
| [\u0780-\u07A5]
| '\u07B1'
| [\u0904-\u0939]
| '\u093D'
| '\u0950'
| [\u0958-\u0961]
| '\u097D'
| [\u0985-\u098C]
| [\u098F-\u0990]
| [\u0993-\u09A8]
| [\u09AA-\u09B0]
| '\u09B2'
| [\u09B6-\u09B9]
| '\u09BD'
| '\u09CE'
| [\u09DC-\u09DD]
| [\u09DF-\u09E1]
| [\u09F0-\u09F1]
| [\u0A05-\u0A0A]
| [\u0A0F-\u0A10]
| [\u0A13-\u0A28]
| [\u0A2A-\u0A30]
| [\u0A32-\u0A33]
| [\u0A35-\u0A36]
| [\u0A38-\u0A39]
| [\u0A59-\u0A5C]
| '\u0A5E'
| [\u0A72-\u0A74]
| [\u0A85-\u0A8D]
| [\u0A8F-\u0A91]
| [\u0A93-\u0AA8]
| [\u0AAA-\u0AB0]
| [\u0AB2-\u0AB3]
| [\u0AB5-\u0AB9]
| '\u0ABD'
| '\u0AD0'
| [\u0AE0-\u0AE1]
| [\u0B05-\u0B0C]
| [\u0B0F-\u0B10]
| [\u0B13-\u0B28]
| [\u0B2A-\u0B30]
| [\u0B32-\u0B33]
| [\u0B35-\u0B39]
| '\u0B3D'
| [\u0B5C-\u0B5D]
| [\u0B5F-\u0B61]
| '\u0B71'
| '\u0B83'
| [\u0B85-\u0B8A]
| [\u0B8E-\u0B90]
| [\u0B92-\u0B95]
| [\u0B99-\u0B9A]
| '\u0B9C'
| [\u0B9E-\u0B9F]
| [\u0BA3-\u0BA4]
| [\u0BA8-\u0BAA]
| [\u0BAE-\u0BB9]
| [\u0C05-\u0C0C]
| [\u0C0E-\u0C10]
| [\u0C12-\u0C28]
| [\u0C2A-\u0C33]
| [\u0C35-\u0C39]
| [\u0C60-\u0C61]
| [\u0C85-\u0C8C]
| [\u0C8E-\u0C90]
| [\u0C92-\u0CA8]
| [\u0CAA-\u0CB3]
| [\u0CB5-\u0CB9]
| '\u0CBD'
| '\u0CDE'
| [\u0CE0-\u0CE1]
| [\u0D05-\u0D0C]
| [\u0D0E-\u0D10]
| [\u0D12-\u0D28]
| [\u0D2A-\u0D39]
| [\u0D60-\u0D61]
| [\u0D85-\u0D96]
| [\u0D9A-\u0DB1]
| [\u0DB3-\u0DBB]
| '\u0DBD'
| [\u0DC0-\u0DC6]
| [\u0E01-\u0E30]
| [\u0E32-\u0E33]
| [\u0E40-\u0E45]
| '\u0E46'
| [\u0E81-\u0E82]
| '\u0E84'
| [\u0E87-\u0E88]
| '\u0E8A'
| '\u0E8D'
| [\u0E94-\u0E97]
| [\u0E99-\u0E9F]
| [\u0EA1-\u0EA3]
| '\u0EA5'
| '\u0EA7'
| [\u0EAA-\u0EAB]
| [\u0EAD-\u0EB0]
| [\u0EB2-\u0EB3]
| '\u0EBD'
| [\u0EC0-\u0EC4]
| '\u0EC6'
| [\u0EDC-\u0EDD]
| '\u0F00'
| [\u0F40-\u0F47]
| [\u0F49-\u0F6A]
| [\u0F88-\u0F8B]
| [\u1000-\u1021]
| [\u1023-\u1027]
| [\u1029-\u102A]
| [\u1050-\u1055]
| [\u10A0-\u10C5]
| [\u10D0-\u10FA]
| '\u10FC'
| [\u1100-\u1159]
| [\u115F-\u11A2]
| [\u11A8-\u11F9]
| [\u1200-\u1248]
| [\u124A-\u124D]
| [\u1250-\u1256]
| '\u1258'
| [\u125A-\u125D]
| [\u1260-\u1288]
| [\u128A-\u128D]
| [\u1290-\u12B0]
| [\u12B2-\u12B5]
| [\u12B8-\u12BE]
| '\u12C0'
| [\u12C2-\u12C5]
| [\u12C8-\u12D6]
| [\u12D8-\u1310]
| [\u1312-\u1315]
| [\u1318-\u135A]
| [\u1380-\u138F]
| [\u13A0-\u13F4]
| [\u1401-\u166C]
| [\u166F-\u1676]
| [\u1681-\u169A]
| [\u16A0-\u16EA]
| [\u16EE-\u16F0]
| [\u1700-\u170C]
| [\u170E-\u1711]
| [\u1720-\u1731]
| [\u1740-\u1751]
| [\u1760-\u176C]
| [\u176E-\u1770]
| [\u1780-\u17B3]
| '\u17D7'
| '\u17DC'
| [\u1820-\u1842]
| '\u1843'
| [\u1844-\u1877]
| [\u1880-\u18A8]
| [\u1900-\u191C]
| [\u1950-\u196D]
| [\u1970-\u1974]
| [\u1980-\u19A9]
| [\u19C1-\u19C7]
| [\u1A00-\u1A16]
| [\u1D00-\u1D2B]
| [\u1D2C-\u1D61]
| [\u1D62-\u1D77]
| '\u1D78'
| [\u1D79-\u1D9A]
| [\u1D9B-\u1DBF]
| [\u1E00-\u1E9B]
| [\u1EA0-\u1EF9]
| [\u1F00-\u1F15]
| [\u1F18-\u1F1D]
| [\u1F20-\u1F45]
| [\u1F48-\u1F4D]
| [\u1F50-\u1F57]
| '\u1F59'
| '\u1F5B'
| '\u1F5D'
| [\u1F5F-\u1F7D]
| [\u1F80-\u1FB4]
| [\u1FB6-\u1FBC]
| '\u1FBE'
| [\u1FC2-\u1FC4]
| [\u1FC6-\u1FCC]
| [\u1FD0-\u1FD3]
| [\u1FD6-\u1FDB]
| [\u1FE0-\u1FEC]
| [\u1FF2-\u1FF4]
| [\u1FF6-\u1FFC]
| '\u2071'
| '\u207F'
| [\u2090-\u2094]
| '\u2102'
| '\u2107'
| [\u210A-\u2113]
| '\u2115'
| '\u2118'
| [\u2119-\u211D]
| '\u2124'
| '\u2126'
| '\u2128'
| [\u212A-\u212D]
| '\u212E'
| [\u212F-\u2131]
| [\u2133-\u2134]
| [\u2135-\u2138]
| '\u2139'
| [\u213C-\u213F]
| [\u2145-\u2149]
| [\u2160-\u2183]
| [\u2C00-\u2C2E]
| [\u2C30-\u2C5E]
| [\u2C80-\u2CE4]
| [\u2D00-\u2D25]
| [\u2D30-\u2D65]
| '\u2D6F'
| [\u2D80-\u2D96]
| [\u2DA0-\u2DA6]
| [\u2DA8-\u2DAE]
| [\u2DB0-\u2DB6]
| [\u2DB8-\u2DBE]
| [\u2DC0-\u2DC6]
| [\u2DC8-\u2DCE]
| [\u2DD0-\u2DD6]
| [\u2DD8-\u2DDE]
| '\u3005'
| '\u3006'
| '\u3007'
| [\u3021-\u3029]
| [\u3031-\u3035]
| [\u3038-\u303A]
| '\u303B'
| '\u303C'
| [\u3041-\u3096]
| [\u309B-\u309C]
| [\u309D-\u309E]
| '\u309F'
| [\u30A1-\u30FA]
| [\u30FC-\u30FE]
| '\u30FF'
| [\u3105-\u312C]
| [\u3131-\u318E]
| [\u31A0-\u31B7]
| [\u31F0-\u31FF]
| [\u3400-\u4DB5]
| [\u4E00-\u9FBB]
| [\uA000-\uA014]
| '\uA015'
| [\uA016-\uA48C]
| [\uA800-\uA801]
| [\uA803-\uA805]
| [\uA807-\uA80A]
| [\uA80C-\uA822]
| [\uAC00-\uD7A3]
| [\uF900-\uFA2D]
| [\uFA30-\uFA6A]
| [\uFA70-\uFAD9]
| [\uFB00-\uFB06]
| [\uFB13-\uFB17]
| '\uFB1D'
| [\uFB1F-\uFB28]
| [\uFB2A-\uFB36]
| [\uFB38-\uFB3C]
| '\uFB3E'
| [\uFB40-\uFB41]
| [\uFB43-\uFB44]
| [\uFB46-\uFBB1]
| [\uFBD3-\uFD3D]
| [\uFD50-\uFD8F]
| [\uFD92-\uFDC7]
| [\uFDF0-\uFDFB]
| [\uFE70-\uFE74]
| [\uFE76-\uFEFC]
| [\uFF21-\uFF3A]
| [\uFF41-\uFF5A]
| [\uFF66-\uFF6F]
| '\uFF70'
| [\uFF71-\uFF9D]
| [\uFF9E-\uFF9F]
| [\uFFA0-\uFFBE]
| [\uFFC2-\uFFC7]
| [\uFFCA-\uFFCF]
| [\uFFD2-\uFFD7]
| [\uFFDA-\uFFDC]
;
/// id_continue ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
fragment ID_CONTINUE
: ID_START
| [0-9]
| [\u0300-\u036F]
| [\u0483-\u0486]
| [\u0591-\u05B9]
| [\u05BB-\u05BD]
| '\u05BF'
| [\u05C1-\u05C2]
| [\u05C4-\u05C5]
| '\u05C7'
| [\u0610-\u0615]
| [\u064B-\u065E]
| [\u0660-\u0669]
| '\u0670'
| [\u06D6-\u06DC]
| [\u06DF-\u06E4]
| [\u06E7-\u06E8]
| [\u06EA-\u06ED]
| [\u06F0-\u06F9]
| '\u0711'
| [\u0730-\u074A]
| [\u07A6-\u07B0]
| [\u0901-\u0902]
| '\u0903'
| '\u093C'
| [\u093E-\u0940]
| [\u0941-\u0948]
| [\u0949-\u094C]
| '\u094D'
| [\u0951-\u0954]
| [\u0962-\u0963]
| [\u0966-\u096F]
| '\u0981'
| [\u0982-\u0983]
| '\u09BC'
| [\u09BE-\u09C0]
| [\u09C1-\u09C4]
| [\u09C7-\u09C8]
| [\u09CB-\u09CC]
| '\u09CD'
| '\u09D7'
| [\u09E2-\u09E3]
| [\u09E6-\u09EF]
| [\u0A01-\u0A02]
| '\u0A03'
| '\u0A3C'
| [\u0A3E-\u0A40]
| [\u0A41-\u0A42]
| [\u0A47-\u0A48]
| [\u0A4B-\u0A4D]
| [\u0A66-\u0A6F]
| [\u0A70-\u0A71]
| [\u0A81-\u0A82]
| '\u0A83'
| '\u0ABC'
| [\u0ABE-\u0AC0]
| [\u0AC1-\u0AC5]
| [\u0AC7-\u0AC8]
| '\u0AC9'
| [\u0ACB-\u0ACC]
| '\u0ACD'
| [\u0AE2-\u0AE3]
| [\u0AE6-\u0AEF]
| '\u0B01'
| [\u0B02-\u0B03]
| '\u0B3C'
| '\u0B3E'
| '\u0B3F'
| '\u0B40'
| [\u0B41-\u0B43]
| [\u0B47-\u0B48]
| [\u0B4B-\u0B4C]
| '\u0B4D'
| '\u0B56'
| '\u0B57'
| [\u0B66-\u0B6F]
| '\u0B82'
| [\u0BBE-\u0BBF]
| '\u0BC0'
| [\u0BC1-\u0BC2]
| [\u0BC6-\u0BC8]
| [\u0BCA-\u0BCC]
| '\u0BCD'
| '\u0BD7'
| [\u0BE6-\u0BEF]
| [\u0C01-\u0C03]
| [\u0C3E-\u0C40]
| [\u0C41-\u0C44]
| [\u0C46-\u0C48]
| [\u0C4A-\u0C4D]
| [\u0C55-\u0C56]
| [\u0C66-\u0C6F]
| [\u0C82-\u0C83]
| '\u0CBC'
| '\u0CBE'
| '\u0CBF'
| [\u0CC0-\u0CC4]
| '\u0CC6'
| [\u0CC7-\u0CC8]
| [\u0CCA-\u0CCB]
| [\u0CCC-\u0CCD]
| [\u0CD5-\u0CD6]
| [\u0CE6-\u0CEF]
| [\u0D02-\u0D03]
| [\u0D3E-\u0D40]
| [\u0D41-\u0D43]
| [\u0D46-\u0D48]
| [\u0D4A-\u0D4C]
| '\u0D4D'
| '\u0D57'
| [\u0D66-\u0D6F]
| [\u0D82-\u0D83]
| '\u0DCA'
| [\u0DCF-\u0DD1]
| [\u0DD2-\u0DD4]
| '\u0DD6'
| [\u0DD8-\u0DDF]
| [\u0DF2-\u0DF3]
| '\u0E31'
| [\u0E34-\u0E3A]
| [\u0E47-\u0E4E]
| [\u0E50-\u0E59]
| '\u0EB1'
| [\u0EB4-\u0EB9]
| [\u0EBB-\u0EBC]
| [\u0EC8-\u0ECD]
| [\u0ED0-\u0ED9]
| [\u0F18-\u0F19]
| [\u0F20-\u0F29]
| '\u0F35'
| '\u0F37'
| '\u0F39'
| [\u0F3E-\u0F3F]
| [\u0F71-\u0F7E]
| '\u0F7F'
| [\u0F80-\u0F84]
| [\u0F86-\u0F87]
| [\u0F90-\u0F97]
| [\u0F99-\u0FBC]
| '\u0FC6'
| '\u102C'
| [\u102D-\u1030]
| '\u1031'
| '\u1032'
| [\u1036-\u1037]
| '\u1038'
| '\u1039'
| [\u1040-\u1049]
| [\u1056-\u1057]
| [\u1058-\u1059]
| '\u135F'
| [\u1369-\u1371]
| [\u1712-\u1714]
| [\u1732-\u1734]
| [\u1752-\u1753]
| [\u1772-\u1773]
| '\u17B6'
| [\u17B7-\u17BD]
| [\u17BE-\u17C5]
| '\u17C6'
| [\u17C7-\u17C8]
| [\u17C9-\u17D3]
| '\u17DD'
| [\u17E0-\u17E9]
| [\u180B-\u180D]
| [\u1810-\u1819]
| '\u18A9'
| [\u1920-\u1922]
| [\u1923-\u1926]
| [\u1927-\u1928]
| [\u1929-\u192B]
| [\u1930-\u1931]
| '\u1932'
| [\u1933-\u1938]
| [\u1939-\u193B]
| [\u1946-\u194F]
| [\u19B0-\u19C0]
| [\u19C8-\u19C9]
| [\u19D0-\u19D9]
| [\u1A17-\u1A18]
| [\u1A19-\u1A1B]
| [\u1DC0-\u1DC3]
| [\u203F-\u2040]
| '\u2054'
| [\u20D0-\u20DC]
| '\u20E1'
| [\u20E5-\u20EB]
| [\u302A-\u302F]
| [\u3099-\u309A]
| '\uA802'
| '\uA806'
| '\uA80B'
| [\uA823-\uA824]
| [\uA825-\uA826]
| '\uA827'
| '\uFB1E'
| [\uFE00-\uFE0F]
| [\uFE20-\uFE23]
| [\uFE33-\uFE34]
| [\uFE4D-\uFE4F]
| [\uFF10-\uFF19]
| '\uFF3F'
;
| 27,035 | ANTLR | .g4 | 1,078 | 22.642857 | 148 | 0.578036 | bartfrenk/entish | 0 | 0 | 0 | EPL-1.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | b7cf3e7305a67591bdd3d448320d57dbd8f901dcdd211242ada6767192dc17cd | false | false | false | false |
172 | TerraformLexer.g4 | tycarac_antlr-grammar/terraform/TerraformLexer.g4 | // $antlr-format on
lexer grammar TerraformLexer;
tokens{STRING, BOOL}
/* Syntax HCL - https://github.com/hashicorp/hcl/blob/hcl2/hclsyntax/spec.md
*/
// Other
WS : [ \t\r\n]+ -> skip;
COMMENT : (INLINE_COMMENT | LINE_COMMENT) -> skip;
// Fragments
fragment SYMBOL : [a-zA-Z][a-zA-Z0-9_-]*;
fragment EXPONENT_MARKER : ('e' | 'E') ('+' | '-')?;
fragment INLINE_COMMENT : '/*' .*? '*/';
fragment LINE_COMMENT : ('//' | '#') ~ [\r\n]*;
// Operators
BRACKET_LROUND : '(';
BRACKET_RROUND : ')';
BRACKET_LSQUARE : '[';
BRACKET_RSQUARE : ']';
BRACKET_LCURLY : '{';
BRACKET_RCURLY : '}';
OP_ASSIGN : '=';
OP_DOT : '.';
OP_ELIPSE : '...';
OP_COMMA : ',';
OP_COLON : ':';
OP_QUESTION : '?';
OP_BAR : '|';
OP_MULTILINE : '<<';
UNARY_OP : '-' | '!';
COMPARE_OP : '==' | '!=' | '<' | '>' | '<=' | '>=';
ARITHMETIC_OP : '+' | '-' | '*' | '/' | '%';
LOGIC_OP : '&&' | '||';
// Base prefix
HEX : '0x' ([0-9] | [A-F])+;
OCTAL : '0' [0-7]+;
// Literals
STRING_DQUOTED : '"' ('\\' . | '\\"' | ~('"' | '\\'))* '"' -> type(STRING);
NUMBER : [0-9]+ ('.' [0-9]+)? (EXPONENT_MARKER [0-9]+)?;
TRUE : 'true';
FALSE : 'false';
NULL : 'null';
// Variable
IDENTIFIER : SYMBOL;
| 1,687 | ANTLR | .g4 | 43 | 37.953488 | 88 | 0.355392 | tycarac/antlr-grammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 797f269204255adf25f1f7618a9657387d052640029d504595e42ac893148214 | false | false | false | false |
173 | TerraformParser.g4 | tycarac_antlr-grammar/terraform/TerraformParser.g4 | // $antlr-format on
parser grammar TerraformParser;
options { tokenVocab=TerraformLexer; }
root
: (attribute | block)* EOF
;
block
: IDENTIFIER STRING* BRACKET_LCURLY (attribute | block)* BRACKET_RCURLY
;
attribute
: IDENTIFIER OP_ASSIGN (literal | expression | array | dictionary)
;
// Expressions
expression
: expression_term | operation | conditional
;
expression_term
: literal
| IDENTIFIER (OP_DOT IDENTIFIER)*
| function
;
operation
: UNARY_OP expression_term
| expression_term (COMPARE_OP | ARITHMETIC_OP | LOGIC_OP) expression_term
;
function
: IDENTIFIER (OP_DOT IDENTIFIER)* BRACKET_LROUND arguments BRACKET_RROUND
;
arguments
: ()
| expression (OP_COMMA expression)* (OP_COMMA | OP_ELIPSE)?
;
array
: BRACKET_LSQUARE BRACKET_RSQUARE
| BRACKET_LSQUARE expression (OP_COMMA expression)* OP_COMMA? BRACKET_RSQUARE
;
dictionary
: BRACKET_LCURLY attribute* BRACKET_RCURLY
;
//
conditional
: expression_term OP_QUESTION expression OP_COLON expression
;
// Primitives
literal
: STRING | NUMBER | 'true' | 'false' | 'null'
;
/*
heredocTemplate
: (('<<' | '<<-') IDENTIFIER)
;
*/ | 1,226 | ANTLR | .g4 | 52 | 19.807692 | 81 | 0.685616 | tycarac/antlr-grammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 22a5fc60e5fa1615197a389813118c91105b5e2bf2a7b78738e5f40a0126feb1 | false | false | false | false |
174 | FreemarkerParser.g4 | tycarac_antlr-grammar/freemarker/FreemarkerParser.g4 | // $antlr-format on
parser grammar FreemarkerParser;
options { tokenVocab=FreemarkerLexer; }
/*
https://freemarker.apache.org/docs/dgui_template_exp.html#exp_cheatsheet
https://freemarker.apache.org/docs/ref_directive_alphaidx.html
*/
root
: (tag | interpolation | content)* EOF
;
// Tags
tag
: TAG_START_BEGIN_1 directive_start TAG_END_1
| TAG_START_BEGIN_2 directive_start TAG_END_2
| TAG_CLOSE_BEGIN_1 directive_end TAG_END_1
| TAG_CLOSE_BEGIN_2 directive_end TAG_END_2
;
directive_start
: (DIRECT_IF | DIRECT_ELSEIF) condition
| DIRECT_ELSE
| (DIRECT_ASSIGN | DIRECT_SETTING) (assignment)+
| DIRECT_LIST expression (AS variable (OPER_COMMA variable)*)?
| DIRECT_INCLUDE expression
| DIRECT_ESCAPE IDENTIFIER AS expression
| DIRECT_NOESCAPE
| DIRECT_MACRO variable+
// | DIRECT_ITEMS (AS variable)?
// | DIRECT_SEP
| DIRECT_FTL
;
directive_end
: DIRECT_IF
| DIRECT_ASSIGN
| DIRECT_LIST
| DIRECT_ESCAPE
| DIRECT_NOESCAPE
| DIRECT_MACRO
// | DIRECT_ITEMS
// | DIRECT_SEP
;
assignment
: IDENTIFIER OPER_ASSIGN expression
;
condition // excludes OPER_GT
: OPER_L_PAREN condition OPER_R_PAREN
| OPER_BANG condition
| expression OPER_TWO_QUESTION?
| expression (OPER_QUESTION builtin)+
| expression (OPER_CMP_EQ | OPER_CMP_NEQ | OPER_CMP_LT | OPER_CMP_LTE | OPER_CMP_GT | OPER_CMP_GTE) expression
| condition ((OPER_LOGICAL_AND | OPER_LOGICAL_OR) condition)+
;
interpolation
: INTPOL_ENTER expression INTPOL_EXIT
;
expression
// Operator Precedence https://freemarker.apache.org/docs/dgui_template_exp.html#dgui_template_exp_precedence
: variable | literal
| variable (OPER_DOT (variable| builtin))+
| expression (OPER_QUESTION builtin)+
| expression OPER_BANG (value)?
| expression (OPER_PLUS | OPER_MODULUS) expression
;
sequence
: (IDENTIFIER)? SEQ_L_SQ_PAREN SEQ_CONTENT SEQ_R_SQ_PAREN
;
builtin
: IDENTIFIER (OPER_L_PAREN parameterList? OPER_R_PAREN)?
;
methodCall
: IDENTIFIER OPER_L_PAREN parameterList? OPER_R_PAREN
;
parameterList
: expression (OPER_COMMA expression)*
;
variable
: OPER_DOT? IDENTIFIER
| (IDENTIFIER)? SEQ_L_SQ_PAREN SEQ_CONTENT SEQ_R_SQ_PAREN // sequence
;
literal
: STRING | NUMBER | TRUE | FALSE
;
value
: STRING | NUMBER | IDENTIFIER | STRING | NUMBER | TRUE | FALSE
;
content
: CONTENT+
;
| 2,500 | ANTLR | .g4 | 87 | 24.62069 | 114 | 0.688545 | tycarac/antlr-grammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | b3b28f2c9513a754505744e41f275887ac223f69f0499b3291a58cec0c15dcb4 | false | false | false | false |
175 | FreemarkerLexer.g4 | tycarac_antlr-grammar/freemarker/FreemarkerLexer.g4 | // $antlr-format on
lexer grammar FreemarkerLexer;
tokens{STRING}
/*
Alternative syntax: https://freemarker.apache.org/docs/dgui_misc_alternativesyntax.html
Expressions: https://freemarker.apache.org/docs/dgui_template_exp.html
Notes:
1. #{ and }, but that shouldn't be used anymore; https://freemarker.apache.org/docs/ref_depr_numerical_interpolation.html)
*/
// Tags and Interpolations
TAG_START_BEGIN_1 : '<#' -> pushMode(EXPR_MODE);
TAG_START_BEGIN_2 : '[#' -> pushMode(EXPR_MODE);
TAG_CLOSE_BEGIN_1 : '</#' -> pushMode(EXPR_MODE);
TAG_CLOSE_BEGIN_2 : '[/#' -> pushMode(EXPR_MODE);
INTPOL_ENTER : '${' -> pushMode(EXPR_MODE);
// Content
CONTENT : ('[' | '<' | '$' | ~[[<$]+)+?;
// Other
WS : WHIESPACE -> skip;
COMMENT : (FRAG_COMMENT_1 | FRAG_COMMENT_2) -> skip;
// Fragments
fragment WHIESPACE : [ \t\r\n]+;
fragment SYMBOL : [a-zA-Z][a-zA-Z0-9_]*;
fragment INTEGER : [0-9]+;
fragment REAL : [0-9]+ '.' [0-9]*;
fragment FRAG_COMMENT_1 : '<#--' .*? '-->';
fragment FRAG_COMMENT_2 : '[#--' .*? '--]';
/*
//Experiment
//_____________________________________________________________________________
//CONTENT : ('[' | '<' | '$' | ~[[<$]+) -> more;
//CONTENT : ('[' | '<' | '$' | ~[[<$]+) -> skip;
//CONTENT : ('[' | '<' | '$' | ~[[<$]+)+;
//CONTENT : (~[[<$] | (('[' | '<') ~('/' | '#')) | ('$' ~'{'))+;
//CC_CONTENT : ~[[<$]+ -> skip;
//_____________________________________________________________________________
mode CONTENT_MODE;
CONTENT_WS : WS -> skip;
*/
//_____________________________________________________________________________
mode EXPR_MODE;
TAG_END_1 : '>' -> popMode;
TAG_END_2 : ']' -> popMode;
INTPOL_EXIT : '}' -> popMode;
// Directives
DIRECT_IF : 'if';
DIRECT_ELSE : 'else';
DIRECT_ELSEIF : 'elseif';
DIRECT_ASSIGN : 'assign';
DIRECT_BREAK : 'break';
DIRECT_CONTINUE : 'continue';
DIRECT_FTL : 'ftl';
DIRECT_INCLUDE : 'include';
DIRECT_ESCAPE : 'escape';
DIRECT_ITEMS : 'items';
DIRECT_LIST : 'list';
DIRECT_MACRO : 'macro';
DIRECT_NOESCAPE : 'noescape';
DIRECT_SETTING : 'setting';
DIRECT_SEP : 'sep';
// Keywords
AS : 'as';
TRUE : 'true';
FALSE : 'false';
IN : 'in';
USING : 'using';
SEQ_L_SQ_PAREN : '[' -> pushMode(SEQ_MODE);
// Operators
OPER_L_PAREN : '(';
OPER_R_PAREN : ')';
OPER_CMP_EQ : '==';
OPER_CMP_NEQ : '!=';
OPER_LOGICAL_AND : '&&' | '&&';
OPER_LOGICAL_OR : '||';
OPER_ASSIGN : '=';
OPER_AT : '@';
OPER_TWO_QUESTION : '??';
OPER_QUESTION : '?';
OPER_BANG : '!';
OPER_DOT : '.';
OPER_COMMA : ',';
OPER_COLON : ':';
OPER_SEMICOLON : ';';
OPER_CMP_LT : '<' | 'lt';
OPER_CMP_LTE : '<=' | 'lte';
OPER_CMP_GT : 'gt';
OPER_CMP_GTE : '>=' | 'gte';
OPER_PLUS : '+';
OPER_MINUS : '-';
OPER_MULTIPY : '*';
OPER_DIVIDE : '/';
OPER_MODULUS : '%';
OPER_LAMBDA : '->';
// Literals
SQUOTED_STRING : '\'' ('\\' . | '\\\'' | ~('\'' | '\\'))* '\'' -> type(STRING);
DQUOTED_STRING : '"' ('\\' . | '\\"' | ~('"' | '\\'))* '"' -> type(STRING);
NUMBER : INTEGER | REAL;
// Variable
IDENTIFIER : SYMBOL;
// Skip
EXPR_WS : WS -> skip;
EXPR_COMMENT : (FRAG_COMMENT_1 | FRAG_COMMENT_2) -> skip;
//_____________________________________________________________________________
mode SEQ_MODE;
SEQ_R_SQ_PAREN : ']' -> popMode;
//SEQ_CONTENT : (~[\]])+;
SEQ_CONTENT : ('\'' | '"' | ',' | [0-9a-zA-Z])+;
SEQ_WS : WS -> skip; | 4,523 | ANTLR | .g4 | 108 | 40.564815 | 122 | 0.367366 | tycarac/antlr-grammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 6de026f832c4691d2f284cfb5cbb83bc795132499dfd8d64a3763624b53c354f | false | false | false | false |
176 | mdql.g4 | MDQL_dsl/mdql.g4 | grammar MDQL;
query: view fields FROM table (WHERE filters)? EOF;
view: TASKLIST | LIST | TABLE;
fields: FIELD (',' FIELD)*;
filters: attr_filter (AND attr_filter)*;
attr_filter: FIELD COMPARE_OPERATOR STRING_LITERAL;
table: TASKS | DOCUMENTS;
COMPARE_OPERATOR: (OP_EQUALS | OP_NOTEQUALS | OP_CONTAINS);
OP_EQUALS: '=';
OP_NOTEQUALS: '!=';
OP_CONTAINS: '=~';
NEWLINE: [\r\n]+ -> skip;
TASKS: 'tasks';
DOCUMENTS: 'documents';
TASKLIST: ('tasklist' | 'TASKLIST');
LIST: ('list' | 'LIST');
TABLE: ('table' | 'TABLE');
FROM: ('from' | 'FROM');
WHERE: ('where' | 'WHERE');
AND: ('and' | 'AND');
FIELD: [a-zA-Z0-9.]+;
STRING_LITERAL: '\'' ( ~'\'' | '\'\'')* '\'';
| 660 | ANTLR | .g4 | 22 | 28.909091 | 59 | 0.63522 | MDQL/dsl | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | ca76faf4545227ec2a9889471140aa8c267f4ea0aaca7eb32fb4dcf97186dc80 | false | false | false | false |
177 | Json.g4 | ThinhPTran_learnANTLR/grammars/Json.g4 | /*
BSD License
Copyright (c) 2013, Rainer Schuster
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of Rainer Schuster nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
JSON grammar derived from:
http://tools.ietf.org/html/rfc4627
The application/json Media Type for JavaScript Object Notation (JSON)
July 2006
Terminal rules mainly created by ANTLRWorks 1.5 sample code.
*/
grammar Json;
jsonText
: jsonObject
| jsonArray
;
jsonValue
: 'false'
| 'null'
| 'true'
| jsonObject
| jsonArray
| jsonNumber
| jsonString
;
jsonNumber
: NUMBER
;
jsonString
: STRING
;
jsonObject
: '{' (member (',' member)*)? '}'
;
member
: STRING ':' jsonValue
;
jsonArray
: '[' (jsonValue (',' jsonValue)*)? ']'
;
fragment
INT
: '0'..'9'+
;
NUMBER
: '-'? ('0' | ( '1'..'9' INT* )) ('.' INT+)? EXPONENT?
;
WS
: ( ' '
| '\t'
| '\n'
| '\r'
) -> channel(HIDDEN)
;
STRING
: '"' ( ESC_SEQ | ~('\\'|'"') )* '"'
;
fragment
EXPONENT
: ('e'|'E') ('+'|'-')? ('0'..'9')+
;
fragment
HEX_DIGIT
: ('0'..'9'|'a'..'f'|'A'..'F')
;
fragment
ESC_SEQ
: '\\' ('\"'|'\\'|'/'|'b'|'f'|'n'|'r'|'t')
| UNICODE_ESC
;
fragment
UNICODE_ESC
: '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
;
| 2,569 | ANTLR | .g4 | 95 | 24.915789 | 73 | 0.724786 | ThinhPTran/learnANTLR | 0 | 0 | 0 | EPL-1.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 9129d36ba1546572d5f2ae898a872813c633dbf0b02feef047a950612b9a4b12 | true | true | false | false |
178 | contract.g4 | CanChenExeter_Solidity-ANTLR-File/contract.g4 |
// Based on solidity version 0.8.15
grammar contract;
sourceUnit
: '// SPDX-License-Identifier: GPL-3.0' '\n' pragmaDirective (contractDefinition | libraryDefinition | interfaceDefinition )* EOF;
pragmaDirective
: 'pragma solidity ^0.8.15' ';' ;
versionConstraint
: versionOperator | VersionLiteral ;
versionOperator
: '^' ;
VersionLiteral
: [0-9]+ '.' [0-9]+ '.' [0-9]+ ;
contractDefinition
: ('\n' 'abstract' 'contract' identifier '{' '\n' (contractPart1'\n')* ('\n' fallbackDefinition)? ('\n' receiveDefinition)? ('\n' constructorDefinition1)? '}')
| ('\n' 'contract' identifier '{' '\n' (contractPart2'\n')* ('\n' fallbackDefinition2)? ('\n' receiveDefinition2)? ('\n' constructorDefinition2)? '}') ;
interfaceDefinition
: '\n' 'interface' identifier '{' '\n' (interfacePart'\n')* ('\n' interfacefallbackDefinition)? ('\n' interfacereceiveDefinition)? '\n' '}' ;
interfacePart
: interfacefunctionDefinition
| structDefinition
| enumDefinition
| usertypeDefinition
| eventDefinition
| errorDefinition ;
interfacestateVariableDeclaration
: typeName (ConstantKeyword | PublicKeyword | InternalKeyword | PrivateKeyword | ImmutableKeyword) identifier ('=' expression)? ';' ;
interfacereceiveDefinition
: ReceiveKeyword '(' ')' ExternalKeyword PayableKeyword VirtualKeyword? ';' ;
interfacefallbackDefinition
: FallbackKeyword '(' parameterList? ')' ExternalKeyword PayableKeyword? VirtualKeyword? returnParameters? ';' ;
interfacefunctionDefinition
: 'function' ( identifier | ReceiveKeyword | FallbackKeyword ) '(' parameterList? ')' 'external' stateMutability? VirtualKeyword? returnParameters? ';' ;
libraryDefinition
: '\n' 'library' identifier '{' '\n' (libraryPart'\n')* '}' ;
libraryfunctionDefinition
: 'function' ( identifier | ReceiveKeyword | FallbackKeyword ) '(' parameterList? ')' visibility stateMutability1? modifierInvocation? ( returnParameters | block ) ;
librarymodifierDefinition
: 'modifier' identifier ( '(' parameterList? ')' )? modifierblock ;
libraryPart
| libraryfunctionDefinition
| librarymodifierDefinition
| structDefinition
| enumDefinition
| usertypeDefinition
| librarystateVariableDeclaration
| eventDefinition
| errorDefinition ;
librarystateVariableDeclaration
: typeName ConstantKeyword (PublicKeyword | InternalKeyword | PrivateKeyword) identifier '=' expression ';' ;
contractPart1
: functionDefinition1
| modifierDefinition1
| structDefinition
| enumDefinition
| usertypeDefinition
| stateVariableDeclaration
| eventDefinition
| errorDefinition ;
contractPart2
: functionDefinition2
| modifierDefinition2
| structDefinition
| enumDefinition
| usertypeDefinition
| stateVariableDeclaration
| eventDefinition
| errorDefinition ;
usingDefinition
: 'using' (identifierPath | ('{' identifierPath (',' identifierPath)* '}') ) 'for' ('*' | typeName) 'global'? ';' ;
errorDefinition
: 'error' identifier '(' errorParameterList? ')' ';' ;
errorParameterList
: errorParameter (',' errorParameter)* ;
errorParameter
: typeName identifier? ;
eventDefinition
: 'event' identifier '(' eventParameterList? ')' AnonymousKeyword? ';' ;
eventParameterList
: eventParameter (',' eventParameter)* ;
eventParameter
: typeName IndexedKeyword? identifier? ;
enumDefinition
: 'enum' identifier '{' enumValue (',' enumValue)* '}' ;
enumValue
: identifier ;
receiveDefinition
: receiveDefinition1 | receiveDefinition2 ;
receiveDefinition1
: ReceiveKeyword '(' ')' ExternalKeyword PayableKeyword VirtualKeyword ';' ;
receiveDefinition2
: ReceiveKeyword '(' ')' ExternalKeyword PayableKeyword VirtualKeyword? modifierInvocation? block ;
fallbackDefinition
: fallbackDefinition1 | fallbackDefinition2 ;
fallbackDefinition1
: FallbackKeyword '(' parameterList? ')' ExternalKeyword PayableKeyword? returnParameters? VirtualKeyword ';' ;
fallbackDefinition2
: FallbackKeyword '(' parameterList? ')' ExternalKeyword PayableKeyword? returnParameters? VirtualKeyword? modifierInvocation? block ;
functionDefinition
: functionDefinition1|functionDefinition2 ;
functionDefinitionOrigin
: 'function' ( identifier | ReceiveKeyword | FallbackKeyword ) '(' parameterList? ')' ( (visibilityN VirtualKeyword?)|'private' ) stateMutability? returnParameters? ( ';' | modifierInvocation? block ) ;
functionDefinition1
: 'function' ( identifier | ReceiveKeyword | FallbackKeyword ) '(' parameterList? ')' ((visibilityN VirtualKeyword stateMutability1?) | (visibilityM VirtualKeyword stateMutability?))
returnParameters? ';' ;
functionDefinition2
: 'function' ( identifier | ReceiveKeyword | FallbackKeyword ) '(' parameterList? ')' (( visibilityN VirtualKeyword? stateMutability1? ) | ('private' stateMutability1? ) | (visibilityM VirtualKeyword? stateMutability?))
returnParameters? modifierInvocation? block ;
visibilityM
: 'external' |'public' ;
stateMutability1
: 'pure' | 'view' ;
constructorDefinition
: 'constructor' '(' parameterList? ')' modifierInvocation? PayableKeyword? (InternalKeyword | PublicKeyword)? block ;
constructorDefinition1
: 'constructor' '(' parameterList? ')' modifierInvocation? PayableKeyword? InternalKeyword? block ;
constructorDefinition2
: 'constructor' '(' parameterList? ')' modifierInvocation? PayableKeyword? PublicKeyword? block ;
usertypeDefinitionOrigin
: 'type' identifier 'is' elementaryTypeName ';' ;
usertypeDefinition
: 'type' identifier 'is' elementaryTypeNameN ';' ;
elementaryTypeNameN
: 'address' PayableKeyword? | 'bool' | Int | Uint | Byte | 'fixed' | 'ufixed' ;
block
: '{' (statement uncheckedblock?)? '}' ;
modifierblock
: '{' (statement uncheckedblock?)? '_;' '}' ;
block725
: '{' ( statement | uncheckedblock )? '}' ;
uncheckedblock
: 'unchecked' block ;
structDefinition
: 'struct' identifier '{' structMember structMember* '}' ;
structMember
: typeName identifier ';' ;
statement
: block
| variableDeclarationStatement
| expressionStatement
| ifStatement
| forStatement
| whileStatement
| doWhileStatement
| continueStatement
| breakStatement
| tryStatement
| returnStatement
| emitStatement
| revertStatement ;
revertStatement
: 'revert' expression callArgumentList ';' ;
emitStatement
: 'emit' expression callArgumentList ';' ;
callArgumentList
: '(' ('{' nameValueList? '}' | expressionList? ) ')' ;
tryStatement : 'try' expression returnParameters? block catchClause+ ;
catchClause : 'catch' ( identifier? '(' parameterList ')' )? block ;
continueStatement
: 'continue' ';' ;
breakStatement
: 'break' ';' ;
doWhileStatement
: 'do' statement 'while' '(' expression ')' ';' ;
whileStatement
: 'while' '(' expression ')' statement ;
expressionStatement
: expression ';' ;
forStatement
: 'for' '(' ( simpleStatement | ';' ) ( expressionStatement | ';' ) expression? ')' statement ;
simpleStatement
: ( variableDeclarationStatement | expressionStatement ) ;
variableDeclarationStatement
: variableDeclaration ('=' expression)? ';' ;
variableDeclaration
: typeName dataLocation? identifier ;
ifStatement
: 'if' '(' expression ')' statement ( 'else' statement )? ;
returnStatement
: 'return' ';' ;
stateVariableDeclaration
: stateVariableDeclaration1 | stateVariableDeclaration2 ;
stateVariableDeclaration1
: typeName (ConstantKeyword | ImmutableKeyword) ( PublicKeyword | InternalKeyword | PrivateKeyword )
identifier ('=' expression) ';' ;
stateVariableDeclaration2
: typeName ( PublicKeyword | InternalKeyword | PrivateKeyword )
identifier ('=' expression)? ';' ;
typeName
: elementaryTypeName
| mapping
| functionTypeName
| typeName '[' expression? ']' ;
functionTypeName
: 'function' '(' parameterList? ')' (visibility | stateMutability) returnParameters? ;
visibility
: 'internal' | 'external' | 'private' | 'public' ;
visibilityN
: 'internal' | 'external' |'public' ;
stateMutability
: 'pure' | 'view' | 'payable' ;
returnParameters
: 'returns' '(' parameterList ')' ;
parameterList
: parameter (',' parameter)* ;
parameter
: typeName dataLocation? identifier? ;
parameterListc
: parameterc (',' parameterc)* ;
parameterc
: typeName dataLocation identifier ;
constructorLocation
: 'memory' | 'storage' ;
dataLocation
: 'memory' | 'storage' | 'calldata';
modifierDefinition1
: 'modifier' identifier ('(' parameterList? ')' )? VirtualKeyword ';' ;
modifierDefinition2
: 'modifier' identifier ('(' parameterList? ')' )? VirtualKeyword? modifierblock ;
modifierDefinitionOrigin
: 'modifier' identifier ('(' parameterList? ')' )? ( VirtualKeyword )? ( ';' | block ) ;
modifierListOrigin
: ( stateMutability | ExternalKeyword
| PublicKeyword | InternalKeyword | PrivateKeyword | VirtualKeyword | overrideSpecifier )* ;
modifierList
: ( stateMutability | ExternalKeyword
| PublicKeyword | InternalKeyword | PrivateKeyword | VirtualKeyword | overrideSpecifier )* ;
modifierInvocation
: ;
modifierInvocationOrigin
: identifier ;
overrideSpecifier : 'override' ( '(' identifierPath (','identifierPath)* ')' )? ;
inheritanceSpecifier
: identifierPath ( '(' expressionList? ')' )? ;
//identifier-path
identifierPath
: identifier('.'identifier )* ;
elementaryTypeName
: 'address' PayableKeyword? | 'bool' | 'string' | 'bytes' | Int | Uint | Byte | 'fixed' | 'ufixed' ;
mapping
: 'mapping' '(' (elementaryTypeName) '=>' typeName ')' ;
Int
: 'int' | 'int8' | 'int16' | 'int24' | 'int32' | 'int40' | 'int48' | 'int56' | 'int64' | 'int72' | 'int80' | 'int88' | 'int96' | 'int104' | 'int112' | 'int120' | 'int128' | 'int136' | 'int144' | 'int152' | 'int160' | 'int168' | 'int176' | 'int184' | 'int192' | 'int200' | 'int208' | 'int216' | 'int224' | 'int232' | 'int240' | 'int248' | 'int256' ;
Uint
: 'uint' | 'uint8' | 'uint16' | 'uint24' | 'uint32' | 'uint40' | 'uint48' | 'uint56' | 'uint64' | 'uint72' | 'uint80' | 'uint88' | 'uint96' | 'uint104' | 'uint112' | 'uint120' | 'uint128' | 'uint136' | 'uint144' | 'uint152' | 'uint160' | 'uint168' | 'uint176' | 'uint184' | 'uint192' | 'uint200' | 'uint208' | 'uint216' | 'uint224' | 'uint232' | 'uint240' | 'uint248' | 'uint256' ;
Byte
: 'bytes1' | 'bytes2' | 'bytes3' | 'bytes4' | 'bytes5' | 'bytes6' | 'bytes7' | 'bytes8' | 'bytes9' | 'bytes10' | 'bytes11' | 'bytes12' | 'bytes13' | 'bytes14' | 'bytes15' | 'bytes16' | 'bytes17' | 'bytes18' | 'bytes19' | 'bytes20' | 'bytes21' | 'bytes22' | 'bytes23' | 'bytes24' | 'bytes25' | 'bytes26' | 'bytes27' | 'bytes28' | 'bytes29' | 'bytes30' | 'bytes31' | 'bytes32' ;
expression
: expression '[' expression? ']'
| expression '[' expression? ':' expression? ']'
| expression '.' (identifier)|('address')
| expression '{' nameValueList '}'
| expression callArgumentList
| 'payable' callArgumentList
| 'type' '(' typeName ')'
| ('++' | '--' | '!' | '~' | 'delete' | '-' ) expression
| expression ('++' | '--')
| expression '**' expression
| expression ('*' | '/' | '%') expression
| expression ('+' | '-') expression
| expression ('<<' | '>>' | '>>>' ) expression
| expression '&' expression
| expression '^' expression
| expression '|' expression
| expression ('<' | '>' | '<=' | '>=') expression
| expression ('==' | '!=') expression
| expression '&&' expression
| expression '||' expression
| expression '?' expression ':' expression
| expression ('=' | '|=' | '^=' | '&=' | '<<=' | '>>=' | '>>>=' | '+=' | '-=' | '*=' | '/=' | '%=') expression
| 'new' typeName
| tupleExpression
| inlineArrayExpression
| identifier
| literal
| elementaryTypeName ;
literal
: numberLiteral
| hexLiteral
| BooleanLiteral
| stringLiteral
| hexLiteral ;
primaryExpression
: BooleanLiteral
| numberLiteral
| hexLiteral
| stringLiteral
| identifier ('[' ']')?
| TypeKeyword
| tupleExpression
| typeNameExpression ('[' ']')? ;
tupleExpression
: '(' expression? ( ',' expression? )* ')' ;
inlineArrayExpression
: '[' ( expression ( ',' expression )* )? ']' ;
typeNameExpression
: elementaryTypeName
| identifierPath ;
BooleanLiteral
: 'true' | 'false' ;
numberLiteral
: (DecimalNumber | HexNumber) NumberUnit? ;
DecimalNumber
: ( DecimalDigits | (DecimalDigits? '.' DecimalDigits) ) ( [eE] '-'? DecimalDigits )? ;
fragment
DecimalDigits
: [0-9] ( '_'? [0-9] )* ;
HexNumber
: '0' 'x' HexDigits ;
fragment
HexDigits
: HexCharacter ( '_'? HexCharacter )* ;
NumberUnit
: 'wei' | 'szabo' | 'finney' | 'ether'
| 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'years' ;
HexLiteralFragment
: 'hex' (('"' HexDigits? '"') | ('\'' HexDigits? '\'')) ;
hexLiteral : HexLiteralFragment+ ;
fragment
HexPair
: HexCharacter HexCharacter ;
fragment
HexCharacter
: [0-9A-Fa-f] ;
stringLiteral
: StringLiteralFragment+ ;
StringLiteralFragment
: '"' DoubleQuotedStringCharacter* '"'
| '\'' SingleQuotedStringCharacter* '\'' ;
fragment
DoubleQuotedStringCharacter
: ~["\r\n\\] | ('\\' .) ;
fragment
SingleQuotedStringCharacter
: ~['\r\n\\] | ('\\' .) ;
nameValueList
: nameValue (',' nameValue)* ','? ;
nameValue
: identifier ':' expression ;
expressionList
: expression (',' expression)* ;
functionCallArguments
: '{' nameValueList? '}'
| expressionList? ;
AnonymousKeyword : 'anonymous' ;
BreakKeyword : 'break' ;
ConstantKeyword : 'constant' ;
ImmutableKeyword : 'immutable' ;
ContinueKeyword : 'continue' ;
LeaveKeyword : 'leave' ;
ExternalKeyword : 'external' ;
IndexedKeyword : 'indexed' ;
InternalKeyword : 'internal' ;
PayableKeyword : 'payable' ;
PrivateKeyword : 'private' ;
PublicKeyword : 'public' ;
VirtualKeyword : 'virtual' ;
PureKeyword : 'pure' ;
TypeKeyword : 'type' ;
ViewKeyword : 'view' ;
ConstructorKeyword : 'constructor' ;
FallbackKeyword : 'fallback' ;
ReceiveKeyword : 'receive' ;
identifierOrigin
: Identifier ;
identifier
: ('from' | 'error' | 'revert' | 'global' | Identifier) ;
OneWordidentifier
: IdentifierStart ;
IdentifierString
: '"' IdentifierStart IdentifierPart* '"' ;
Identifier
: IdentifierStart IdentifierPart* ;
fragment
IdentifierStart
: [a-zA-Z$_] ;
fragment
IdentifierPart
: [a-zA-Z0-9$_] ;
| 14,943 | ANTLR | .g4 | 378 | 35.343915 | 383 | 0.697888 | CanChenExeter/Solidity-ANTLR-File | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | e915ca882467a1dd0008393d93599d4e441d63f0ccf59a4e1c8dac65f5d6118f | false | false | false | false |
179 | ParkingSignGrammar.g4 | steveobjectmethods_parking-signs/ParkingSignGrammar.g4 | /*
@licstart The following is the entire license notice for the
grammar in this file.
Copyright (C) 2020 Stephen V. Kowalski
[email protected]
The grammar in this page is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the grammar in this file.
*/
/*
This parking sign grammar is for Los Angeles City parking signs but probably will
work well with signs in other cities. A repository of parking sign images can be
found at https://github.com/steveobjectmethods/parking-signs
Here are some example text streams to test with (generated by text recognition):
streetSweepingSign:
NO PARKING 9AM TO 12 NOON MONDAY STREET CLEANING
NO PARKING 8AM - 10AM TUESDAY STREET CLEANING
8AM TO 10 AM TUESDAY STREET SWEEPING
9AM TO 12NOON MONDAY STREET SWEEPING
noParkingSign:
NO PARKING 6PM TO 8AM NIGHTLY
NO PARKING 6PM TO 8AM
NO PARKING ANY TIME
NO PARKING ANY TIME EXCEPT
noStoppingSign:
NO STOPPING 7AM TO 9AM 4PM TO 7PM EXCEPT SATURDAY & SUNDAY
TOW AWAY NO STOPPING 7 TO 9A.M. 4 TO 7P.M. EXCEPT SAT & SUN
TOW AWAY VALET PARKING ONLY 6PM TO 3AM NIGHTLY
passengerLoadingSign:
PASSENGER LOADING ONLY 6PM TO 1AM
singleTimeLimitSign:
4 HOUR PARKING 8AM TO 6PM EXCEPT SUNDAY
2 HOUR PARKING 8AM TO 6PM DAILY
1 HOUR PARKING 8AM TO 4PM EXCEPT SUNDAY
2 HOUR PARKING 8AM THRU 6PM MONDAY THRU FRIDAY
15 MIN PARKING 7AM TO 5PM SCHOOL DAYS
2 HOUR PARKING 8AM TO 6PM
doubleTimeLimitSign:
2 HOUR PARKING MON TO SAT SUN 8 AM 11 AM TO TO 11 AM 8 PM
2 HOUR PARKING MON TO SAT SUNDAY 8 AM 11 AM TO TO 6 PM 6 PM EXCEPT HOLIDAYS
temporaryNoParkingSign:
TOW-AWAY TEMPORARY NO PARKING 6:30AM TO 4PM EXCEPT SATURDAY & SUNDAY
TOW-AWAY TEMPORARY NO PARKING 5PM TO MIDNIGHT MONDAY THRU FRIDAY
TOW-AWAY TEMPORARY NO PARKING 11AM TO 11PM SATURDAY & SUNDAY
TOW-AWAY TEMPORARY NO PARKING ANYTIME THURSDAY ONLY
permitSign:
DISTRICT NO. 78 PERMITS EXEMPT
VEHICLES WITH DISTRICT NO. 78 PERMITS EXEMPTED
DISTRICT NO.34 PERMITS EXEMPT
*/
grammar ParkingSignGrammar;
/*
There can be multiple parking signs on the same pole that together determine
the parking rules for the location. Assume we have at least one sign in the image
we are analyzing.
*/
parkingSigns : parkingSign* ;
parkingSign
: streetSweepingSign
| noParkingSign
| noStoppingSign
| passengerLoadingSign
| singleTimeLimitSign
| doubleTimeLimitSign
| temporaryNoParkingSign
| permitSign
;
/*
Sometimes there are the words NO PARKING and sometimes there is a graphic P
with a circle and line through it. We don't include the graphic in the grammar
*/
streetSweepingSign
: noParking? timeRange day streetSweeping
;
// Sometimes the exception is on a different sign below the no parking sign
noParkingSign
: noParking? ( anyTime | timeRange ) EXCEPT? dayRange?
;
noStoppingSign
: towAway? ( noStopping | valetOnly ) timeRange+ EXCEPT? dayRange?
;
passengerLoadingSign
: towAway? loadingOnly timeRange+ EXCEPT? dayRange?
;
temporaryNoParkingSign
: towAway TEMPORARY noParking (anyTime | timeRange) EXCEPT? dayRange?
;
singleTimeLimitSign
: ((INT HOUR) | (INT minute)) PARKING timeRange EXCEPT? dayRange?
;
/*
The double time limit sign is a challenge in that the order of the tokens
is not ideal. If there is 2 hour parking Mon-Sat from 8am to 8pm and on
Sun from 11am to 8pm, the order of the tokens will be
2 HOUR PARKING MON TO SAT SUN 8 AM 11 AM TO TO 11 AM 8 PM
because of the vertical arrangement of the day/time ranges
*/
doubleTimeLimitSign
: INT HOUR PARKING dayRange dayRange time time TO TO time time (EXCEPT HOLIDAYS)?
;
permitSign
: (VEHICLES WITH)? DISTRICT NO INT PERMITS exempt
;
// Phrases
streetSweeping : STREET ( SWEEPING | CLEANING ) ;
noParking : NO PARKING ;
noStopping : NO STOPPING ;
valetOnly : VALET PARKING ONLY ;
loadingOnly : PASSENGER LOADING ONLY ;
schoolDays : SCHOOL DAYS ;
timeRange : (time to time) | (INT to time) ;
everyDay : DAILY | NIGHTLY ;
dayToDay : day to day ;
dayAndDay : day and day ;
dayRange
: everyDay
| schoolDays
| HOLIDAYS
| dayAndDay
| dayToDay
| day ONLY
| day
;
dayRangePlus
: dayRange
;
to : TO | DASH | THRU ;
and : AND | AMPERSAND ;
towAway : TOW DASH? AWAY ;
minute : MIN | MINUTE ;
exempt : EXEMPT | EXEMPTED ;
anyTime : ANYTIME | (ANY TIME) ;
NO : 'NO' ; // two meanings : negative (no) and abbreviation for number (No.)
PARKING : 'PARKING' ;
TO : 'TO' ;
THRU : 'THRU' ;
DASH : '-' ;
ANYTIME : 'ANYTIME' ;
ANY : 'ANY' ;
TIME : 'TIME' ;
EXCEPT : 'EXCEPT' ;
DAILY : 'DAILY' ;
NIGHTLY : 'NIGHTLY' ;
SCHOOL : 'SCHOOL' ;
DAYS : 'DAYS' ;
HOLIDAYS : 'HOLIDAYS' ;
AND : 'AND' ;
AMPERSAND : '&' ;
TOW : 'TOW' ;
AWAY : 'AWAY' ;
STOPPING : 'STOPPING' ;
VALET : 'VALET' ;
ONLY : 'ONLY' ;
VEHICLES : 'VEHICLES' ;
WITH : 'WITH' ;
DISTRICT : 'DISTRICT' ;
PERMITS : 'PERMITS' ;
EXEMPTED: 'EXEMPTED' ;
EXEMPT : 'EXEMPT' ;
HOUR : 'HOUR' ;
MINUTE : 'MINUTE' ;
MIN : 'MIN' ;
TEMPORARY : 'TEMPORARY' ;
PASSENGER : 'PASSENGER' ;
LOADING : 'LOADING' ;
day : MON | TUE | WED | THU | FRI | SAT | SUN ;
MON : 'MONDAY' | 'MON' ;
TUE : 'TUESDAY' | 'TUE' ;
WED : 'WEDNESDAY' | 'WED' ;
THU : 'THURSDAY' | 'THU' ;
FRI : 'FRIDAY' | 'FRI' ;
SAT : 'SATURDAY' | 'SAT' ;
SUN : 'SUNDAY' | 'SUN' ;
STREET : 'STREET' ;
SWEEPING : 'SWEEPING' ;
CLEANING : 'CLEANING' ;
time
: INT (':' INT )? (am | pm )?
| twelveNoon
| twelveMidnight
;
twelveNoon : NOON | ('12' NOON) ;
twelveMidnight : MIDNIGHT | ('12' MIDNIGHT) ;
am : 'AM' | ('A.M.') ;
pm : 'PM' | ('P.M.') ;
NOON : 'NOON' ;
MIDNIGHT : 'MIDNIGHT' ;
INT : [0-9]+ ;
// skip whitespace and periods (e.g., 7a.m.)
WS : [ \t\r\n.]+ -> skip ;
| 6,293 | ANTLR | .g4 | 201 | 29.666667 | 82 | 0.746697 | steveobjectmethods/parking-signs | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 5c66c0262785525892c08d5347cf70df27576f1259f5790ff1230e46fe0d0700 | false | false | false | false |
180 | Java8.g4 | Java2NetProject_JavaConverter/Java8.g4 | /*
* [The "BSD license"]
* Copyright (c) 2014 Terence Parr
* Copyright (c) 2014 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* A Java 8 grammar for ANTLR 4 derived from the Java Language Specification
* chapter 19.
*
* NOTE: This grammar results in a generated parser that is much slower
* than the Java 7 grammar in the grammars-v4/java directory. This
* one is, however, extremely close to the spec.
*
* You can test with
*
* $ antlr4 Java8.g4
* $ javac *.java
* $ grun Java8 compilationUnit *.java
*
* Or,
~/antlr/code/grammars-v4/java8 $ java Test .
/Users/parrt/antlr/code/grammars-v4/java8/./Java8BaseListener.java
/Users/parrt/antlr/code/grammars-v4/java8/./Java8Lexer.java
/Users/parrt/antlr/code/grammars-v4/java8/./Java8Listener.java
/Users/parrt/antlr/code/grammars-v4/java8/./Java8Parser.java
/Users/parrt/antlr/code/grammars-v4/java8/./Test.java
Total lexer+parser time 30844ms.
*/
grammar Java8;
/*
* Productions from §3 (Lexical Structure)
*/
literal
: IntegerLiteral
| FloatingPointLiteral
| BooleanLiteral
| CharacterLiteral
| StringLiteral
| NullLiteral
;
/*
* Productions from §4 (Types, Values, and Variables)
*/
type
: primitiveType
| referenceType
;
primitiveType
: annotation* numericType
| annotation* 'boolean'
;
numericType
: integralType
| floatingPointType
;
integralType
: 'byte'
| 'short'
| 'int'
| 'long'
| 'char'
;
floatingPointType
: 'float'
| 'double'
;
referenceType
: classOrInterfaceType
| typeVariable
| arrayType
;
classOrInterfaceType
: ( classType_lfno_classOrInterfaceType
| interfaceType_lfno_classOrInterfaceType
)
( classType_lf_classOrInterfaceType
| interfaceType_lf_classOrInterfaceType
)*
;
classType
: annotation* Identifier typeArguments?
| classOrInterfaceType '.' annotation* Identifier typeArguments?
;
classType_lf_classOrInterfaceType
: '.' annotation* Identifier typeArguments?
;
classType_lfno_classOrInterfaceType
: annotation* Identifier typeArguments?
;
interfaceType
: classType
;
interfaceType_lf_classOrInterfaceType
: classType_lf_classOrInterfaceType
;
interfaceType_lfno_classOrInterfaceType
: classType_lfno_classOrInterfaceType
;
typeVariable
: annotation* Identifier
;
arrayType
: primitiveType dims
| classOrInterfaceType dims
| typeVariable dims
;
dims
: annotation* '[' ']' (annotation* '[' ']')*
;
typeParameter
: typeParameterModifier* Identifier typeBound?
;
typeParameterModifier
: annotation
;
typeBound
: 'extends' typeVariable
| 'extends' classOrInterfaceType additionalBound*
;
additionalBound
: '&' interfaceType
;
typeArguments
: '<' typeArgumentList '>'
;
typeArgumentList
: typeArgument (',' typeArgument)*
;
typeArgument
: referenceType
| wildcard
;
wildcard
: annotation* '?' wildcardBounds?
;
wildcardBounds
: 'extends' referenceType
| 'super' referenceType
;
/*
* Productions from §6 (Names)
*/
packageName
: Identifier
| packageName '.' Identifier
;
typeName
: Identifier
| packageOrTypeName '.' Identifier
;
packageOrTypeName
: Identifier
| packageOrTypeName '.' Identifier
;
expressionName
: Identifier
| ambiguousName '.' Identifier
;
methodName
: Identifier
;
ambiguousName
: Identifier
| ambiguousName '.' Identifier
;
/*
* Productions from §7 (Packages)
*/
compilationUnit
: packageDeclaration? importDeclaration* typeDeclaration* EOF
;
packageDeclaration
: packageModifier* 'package' Identifier ('.' Identifier)* ';'
;
packageModifier
: annotation
;
importDeclaration
: singleTypeImportDeclaration
| typeImportOnDemandDeclaration
| singleStaticImportDeclaration
| staticImportOnDemandDeclaration
;
singleTypeImportDeclaration
: 'import' typeName ';'
;
typeImportOnDemandDeclaration
: 'import' packageOrTypeName '.' '*' ';'
;
singleStaticImportDeclaration
: 'import' 'static' typeName '.' Identifier ';'
;
staticImportOnDemandDeclaration
: 'import' 'static' typeName '.' '*' ';'
;
typeDeclaration
: classDeclaration
| interfaceDeclaration
| ';'
;
/*
* Productions from §8 (Classes)
*/
classDeclaration
: normalClassDeclaration
| enumDeclaration
;
normalClassDeclaration
: classModifier* 'class' Identifier typeParameters? superclass? superinterfaces? classBody
;
classModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'abstract'
| 'static'
| 'final'
| 'strictfp'
;
typeParameters
: '<' typeParameterList '>'
;
typeParameterList
: typeParameter (',' typeParameter)*
;
superclass
: 'extends' classType
;
superinterfaces
: 'implements' interfaceTypeList
;
interfaceTypeList
: interfaceType (',' interfaceType)*
;
classBody
: '{' classBodyDeclaration* '}'
;
classBodyDeclaration
: classMemberDeclaration
| instanceInitializer
| staticInitializer
| constructorDeclaration
;
classMemberDeclaration
: fieldDeclaration
| methodDeclaration
| classDeclaration
| interfaceDeclaration
| ';'
;
fieldDeclaration
: fieldModifier* unannType variableDeclaratorList ';'
;
fieldModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'static'
| 'final'
| 'transient'
| 'volatile'
;
variableDeclaratorList
: variableDeclarator (',' variableDeclarator)*
;
variableDeclarator
: variableDeclaratorId ('=' variableInitializer)?
;
variableDeclaratorId
: Identifier dims?
;
variableInitializer
: expression
| arrayInitializer
;
unannType
: unannPrimitiveType
| unannReferenceType
;
unannPrimitiveType
: numericType
| 'boolean'
;
unannReferenceType
: unannClassOrInterfaceType
| unannTypeVariable
| unannArrayType
;
unannClassOrInterfaceType
: ( unannClassType_lfno_unannClassOrInterfaceType
| unannInterfaceType_lfno_unannClassOrInterfaceType
)
( unannClassType_lf_unannClassOrInterfaceType
| unannInterfaceType_lf_unannClassOrInterfaceType
)*
;
unannClassType
: Identifier typeArguments?
| unannClassOrInterfaceType '.' annotation* Identifier typeArguments?
;
unannClassType_lf_unannClassOrInterfaceType
: '.' annotation* Identifier typeArguments?
;
unannClassType_lfno_unannClassOrInterfaceType
: Identifier typeArguments?
;
unannInterfaceType
: unannClassType
;
unannInterfaceType_lf_unannClassOrInterfaceType
: unannClassType_lf_unannClassOrInterfaceType
;
unannInterfaceType_lfno_unannClassOrInterfaceType
: unannClassType_lfno_unannClassOrInterfaceType
;
unannTypeVariable
: Identifier
;
unannArrayType
: unannPrimitiveType dims
| unannClassOrInterfaceType dims
| unannTypeVariable dims
;
methodDeclaration
: methodModifier* methodHeader methodBody
;
methodModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'abstract'
| 'static'
| 'final'
| 'synchronized'
| 'native'
| 'strictfp'
;
methodHeader
: result methodDeclarator throws_?
| typeParameters annotation* result methodDeclarator throws_?
;
result
: unannType
| 'void'
;
methodDeclarator
: Identifier '(' formalParameterList? ')' dims?
;
formalParameterList
: formalParameters ',' lastFormalParameter
| lastFormalParameter
;
formalParameters
: formalParameter (',' formalParameter)*
| receiverParameter (',' formalParameter)*
;
formalParameter
: variableModifier* unannType variableDeclaratorId
;
variableModifier
: annotation
| 'final'
;
lastFormalParameter
: variableModifier* unannType annotation* '...' variableDeclaratorId
| formalParameter
;
receiverParameter
: annotation* unannType (Identifier '.')? 'this'
;
throws_
: 'throws' exceptionTypeList
;
exceptionTypeList
: exceptionType (',' exceptionType)*
;
exceptionType
: classType
| typeVariable
;
methodBody
: block
| ';'
;
instanceInitializer
: block
;
staticInitializer
: 'static' block
;
constructorDeclaration
: constructorModifier* constructorDeclarator throws_? constructorBody
;
constructorModifier
: annotation
| 'public'
| 'protected'
| 'private'
;
constructorDeclarator
: typeParameters? simpleTypeName '(' formalParameterList? ')'
;
simpleTypeName
: Identifier
;
constructorBody
: '{' explicitConstructorInvocation? blockStatements? '}'
;
explicitConstructorInvocation
: typeArguments? 'this' '(' argumentList? ')' ';'
| typeArguments? 'super' '(' argumentList? ')' ';'
| expressionName '.' typeArguments? 'super' '(' argumentList? ')' ';'
| primary '.' typeArguments? 'super' '(' argumentList? ')' ';'
;
enumDeclaration
: classModifier* 'enum' Identifier superinterfaces? enumBody
;
enumBody
: '{' enumConstantList? ','? enumBodyDeclarations? '}'
;
enumConstantList
: enumConstant (',' enumConstant)*
;
enumConstant
: enumConstantModifier* Identifier ('(' argumentList? ')')? classBody?
;
enumConstantModifier
: annotation
;
enumBodyDeclarations
: ';' classBodyDeclaration*
;
/*
* Productions from §9 (Interfaces)
*/
interfaceDeclaration
: normalInterfaceDeclaration
| annotationTypeDeclaration
;
normalInterfaceDeclaration
: interfaceModifier* 'interface' Identifier typeParameters? extendsInterfaces? interfaceBody
;
interfaceModifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'abstract'
| 'static'
| 'strictfp'
;
extendsInterfaces
: 'extends' interfaceTypeList
;
interfaceBody
: '{' interfaceMemberDeclaration* '}'
;
interfaceMemberDeclaration
: constantDeclaration
| interfaceMethodDeclaration
| classDeclaration
| interfaceDeclaration
| ';'
;
constantDeclaration
: constantModifier* unannType variableDeclaratorList ';'
;
constantModifier
: annotation
| 'public'
| 'static'
| 'final'
;
interfaceMethodDeclaration
: interfaceMethodModifier* methodHeader methodBody
;
interfaceMethodModifier
: annotation
| 'public'
| 'abstract'
| 'default'
| 'static'
| 'strictfp'
;
annotationTypeDeclaration
: interfaceModifier* '@' 'interface' Identifier annotationTypeBody
;
annotationTypeBody
: '{' annotationTypeMemberDeclaration* '}'
;
annotationTypeMemberDeclaration
: annotationTypeElementDeclaration
| constantDeclaration
| classDeclaration
| interfaceDeclaration
| ';'
;
annotationTypeElementDeclaration
: annotationTypeElementModifier* unannType Identifier '(' ')' dims? defaultValue? ';'
;
annotationTypeElementModifier
: annotation
| 'public'
| 'abstract'
;
defaultValue
: 'default' elementValue
;
annotation
: normalAnnotation
| markerAnnotation
| singleElementAnnotation
;
normalAnnotation
: '@' typeName '(' elementValuePairList? ')'
;
elementValuePairList
: elementValuePair (',' elementValuePair)*
;
elementValuePair
: Identifier '=' elementValue
;
elementValue
: conditionalExpression
| elementValueArrayInitializer
| annotation
;
elementValueArrayInitializer
: '{' elementValueList? ','? '}'
;
elementValueList
: elementValue (',' elementValue)*
;
markerAnnotation
: '@' typeName
;
singleElementAnnotation
: '@' typeName '(' elementValue ')'
;
/*
* Productions from §10 (Arrays)
*/
arrayInitializer
: '{' variableInitializerList? ','? '}'
;
variableInitializerList
: variableInitializer (',' variableInitializer)*
;
/*
* Productions from §14 (Blocks and Statements)
*/
block
: '{' blockStatements? '}'
;
blockStatements
: blockStatement blockStatement*
;
blockStatement
: localVariableDeclarationStatement
| classDeclaration
| statement
;
localVariableDeclarationStatement
: localVariableDeclaration ';'
;
localVariableDeclaration
: variableModifier* unannType variableDeclaratorList
;
statement
: statementWithoutTrailingSubstatement
| labeledStatement
| ifThenStatement
| ifThenElseStatement
| whileStatement
| forStatement
;
statementNoShortIf
: statementWithoutTrailingSubstatement
| labeledStatementNoShortIf
| ifThenElseStatementNoShortIf
| whileStatementNoShortIf
| forStatementNoShortIf
;
statementWithoutTrailingSubstatement
: block
| emptyStatement
| expressionStatement
| assertStatement
| switchStatement
| doStatement
| breakStatement
| continueStatement
| returnStatement
| synchronizedStatement
| throwStatement
| tryStatement
;
emptyStatement
: ';'
;
labeledStatement
: Identifier ':' statement
;
labeledStatementNoShortIf
: Identifier ':' statementNoShortIf
;
expressionStatement
: statementExpression ';'
;
statementExpression
: assignment
| preIncrementExpression
| preDecrementExpression
| postIncrementExpression
| postDecrementExpression
| methodInvocation
| classInstanceCreationExpression
;
ifThenStatement
: 'if' '(' expression ')' statement
;
ifThenElseStatement
: 'if' '(' expression ')' statementNoShortIf 'else' statement
;
ifThenElseStatementNoShortIf
: 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf
;
assertStatement
: 'assert' expression ';'
| 'assert' expression ':' expression ';'
;
switchStatement
: 'switch' '(' expression ')' switchBlock
;
switchBlock
: '{' switchBlockStatementGroup* switchLabel* '}'
;
switchBlockStatementGroup
: switchLabels blockStatements
;
switchLabels
: switchLabel switchLabel*
;
switchLabel
: 'case' constantExpression ':'
| 'case' enumConstantName ':'
| 'default' ':'
;
enumConstantName
: Identifier
;
whileStatement
: 'while' '(' expression ')' statement
;
whileStatementNoShortIf
: 'while' '(' expression ')' statementNoShortIf
;
doStatement
: 'do' statement 'while' '(' expression ')' ';'
;
forStatement
: basicForStatement
| enhancedForStatement
;
forStatementNoShortIf
: basicForStatementNoShortIf
| enhancedForStatementNoShortIf
;
basicForStatement
: 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement
;
basicForStatementNoShortIf
: 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf
;
forInit
: statementExpressionList
| localVariableDeclaration
;
forUpdate
: statementExpressionList
;
statementExpressionList
: statementExpression (',' statementExpression)*
;
enhancedForStatement
: 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statement
;
enhancedForStatementNoShortIf
: 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statementNoShortIf
;
breakStatement
: 'break' Identifier? ';'
;
continueStatement
: 'continue' Identifier? ';'
;
returnStatement
: 'return' expression? ';'
;
throwStatement
: 'throw' expression ';'
;
synchronizedStatement
: 'synchronized' '(' expression ')' block
;
tryStatement
: 'try' block catches
| 'try' block catches? finally_
| tryWithResourcesStatement
;
catches
: catchClause catchClause*
;
catchClause
: 'catch' '(' catchFormalParameter ')' block
;
catchFormalParameter
: variableModifier* catchType variableDeclaratorId
;
catchType
: unannClassType ('|' classType)*
;
finally_
: 'finally' block
;
tryWithResourcesStatement
: 'try' resourceSpecification block catches? finally_?
;
resourceSpecification
: '(' resourceList ';'? ')'
;
resourceList
: resource (';' resource)*
;
resource
: variableModifier* unannType variableDeclaratorId '=' expression
;
/*
* Productions from §15 (Expressions)
*/
primary
: ( primaryNoNewArray_lfno_primary
| arrayCreationExpression
)
( primaryNoNewArray_lf_primary
)*
;
primaryNoNewArray
: literal
| typeName ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression
| fieldAccess
| arrayAccess
| methodInvocation
| methodReference
;
primaryNoNewArray_lf_arrayAccess
:
;
primaryNoNewArray_lfno_arrayAccess
: literal
| typeName ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression
| fieldAccess
| methodInvocation
| methodReference
;
primaryNoNewArray_lf_primary
: classInstanceCreationExpression_lf_primary
| fieldAccess_lf_primary
| arrayAccess_lf_primary
| methodInvocation_lf_primary
| methodReference_lf_primary
;
primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary
:
;
primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary
: classInstanceCreationExpression_lf_primary
| fieldAccess_lf_primary
| methodInvocation_lf_primary
| methodReference_lf_primary
;
primaryNoNewArray_lfno_primary
: literal
| typeName ('[' ']')* '.' 'class'
| unannPrimitiveType ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression_lfno_primary
| fieldAccess_lfno_primary
| arrayAccess_lfno_primary
| methodInvocation_lfno_primary
| methodReference_lfno_primary
;
primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary
:
;
primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary
: literal
| typeName ('[' ']')* '.' 'class'
| unannPrimitiveType ('[' ']')* '.' 'class'
| 'void' '.' 'class'
| 'this'
| typeName '.' 'this'
| '(' expression ')'
| classInstanceCreationExpression_lfno_primary
| fieldAccess_lfno_primary
| methodInvocation_lfno_primary
| methodReference_lfno_primary
;
classInstanceCreationExpression
: 'new' typeArguments? annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
| expressionName '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
| primary '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
;
classInstanceCreationExpression_lf_primary
: '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
;
classInstanceCreationExpression_lfno_primary
: 'new' typeArguments? annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
| expressionName '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody?
;
typeArgumentsOrDiamond
: typeArguments
| '<' '>'
;
fieldAccess
: primary '.' Identifier
| 'super' '.' Identifier
| typeName '.' 'super' '.' Identifier
;
fieldAccess_lf_primary
: '.' Identifier
;
fieldAccess_lfno_primary
: 'super' '.' Identifier
| typeName '.' 'super' '.' Identifier
;
arrayAccess
: ( expressionName '[' expression ']'
| primaryNoNewArray_lfno_arrayAccess '[' expression ']'
)
( primaryNoNewArray_lf_arrayAccess '[' expression ']'
)*
;
arrayAccess_lf_primary
: ( primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary '[' expression ']'
)
( primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary '[' expression ']'
)*
;
arrayAccess_lfno_primary
: ( expressionName '[' expression ']'
| primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary '[' expression ']'
)
( primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary '[' expression ']'
)*
;
methodInvocation
: methodName '(' argumentList? ')'
| typeName '.' typeArguments? Identifier '(' argumentList? ')'
| expressionName '.' typeArguments? Identifier '(' argumentList? ')'
| primary '.' typeArguments? Identifier '(' argumentList? ')'
| 'super' '.' typeArguments? Identifier '(' argumentList? ')'
| typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')'
;
methodInvocation_lf_primary
: '.' typeArguments? Identifier '(' argumentList? ')'
;
methodInvocation_lfno_primary
: methodName '(' argumentList? ')'
| typeName '.' typeArguments? Identifier '(' argumentList? ')'
| expressionName '.' typeArguments? Identifier '(' argumentList? ')'
| 'super' '.' typeArguments? Identifier '(' argumentList? ')'
| typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')'
;
argumentList
: expression (',' expression)*
;
methodReference
: expressionName '::' typeArguments? Identifier
| referenceType '::' typeArguments? Identifier
| primary '::' typeArguments? Identifier
| 'super' '::' typeArguments? Identifier
| typeName '.' 'super' '::' typeArguments? Identifier
| classType '::' typeArguments? 'new'
| arrayType '::' 'new'
;
methodReference_lf_primary
: '::' typeArguments? Identifier
;
methodReference_lfno_primary
: expressionName '::' typeArguments? Identifier
| referenceType '::' typeArguments? Identifier
| 'super' '::' typeArguments? Identifier
| typeName '.' 'super' '::' typeArguments? Identifier
| classType '::' typeArguments? 'new'
| arrayType '::' 'new'
;
arrayCreationExpression
: 'new' primitiveType dimExprs dims?
| 'new' classOrInterfaceType dimExprs dims?
| 'new' primitiveType dims arrayInitializer
| 'new' classOrInterfaceType dims arrayInitializer
;
dimExprs
: dimExpr dimExpr*
;
dimExpr
: annotation* '[' expression ']'
;
constantExpression
: expression
;
expression
: lambdaExpression
| assignmentExpression
;
lambdaExpression
: lambdaParameters '->' lambdaBody
;
lambdaParameters
: Identifier
| '(' formalParameterList? ')'
| '(' inferredFormalParameterList ')'
;
inferredFormalParameterList
: Identifier (',' Identifier)*
;
lambdaBody
: expression
| block
;
assignmentExpression
: conditionalExpression
| assignment
;
assignment
: leftHandSide assignmentOperator expression
;
leftHandSide
: expressionName
| fieldAccess
| arrayAccess
;
assignmentOperator
: '='
| '*='
| '/='
| '%='
| '+='
| '-='
| '<<='
| '>>='
| '>>>='
| '&='
| '^='
| '|='
;
conditionalExpression
: conditionalOrExpression
| conditionalOrExpression '?' expression ':' conditionalExpression
;
conditionalOrExpression
: conditionalAndExpression
| conditionalOrExpression '||' conditionalAndExpression
;
conditionalAndExpression
: inclusiveOrExpression
| conditionalAndExpression '&&' inclusiveOrExpression
;
inclusiveOrExpression
: exclusiveOrExpression
| inclusiveOrExpression '|' exclusiveOrExpression
;
exclusiveOrExpression
: andExpression
| exclusiveOrExpression '^' andExpression
;
andExpression
: equalityExpression
| andExpression '&' equalityExpression
;
equalityExpression
: relationalExpression
| equalityExpression '==' relationalExpression
| equalityExpression '!=' relationalExpression
;
relationalExpression
: shiftExpression
| relationalExpression '<' shiftExpression
| relationalExpression '>' shiftExpression
| relationalExpression '<=' shiftExpression
| relationalExpression '>=' shiftExpression
| relationalExpression 'instanceof' referenceType
;
shiftExpression
: additiveExpression
| shiftExpression '<' '<' additiveExpression
| shiftExpression '>' '>' additiveExpression
| shiftExpression '>' '>' '>' additiveExpression
;
additiveExpression
: multiplicativeExpression
| additiveExpression '+' multiplicativeExpression
| additiveExpression '-' multiplicativeExpression
;
multiplicativeExpression
: unaryExpression
| multiplicativeExpression '*' unaryExpression
| multiplicativeExpression '/' unaryExpression
| multiplicativeExpression '%' unaryExpression
;
unaryExpression
: preIncrementExpression
| preDecrementExpression
| '+' unaryExpression
| '-' unaryExpression
| unaryExpressionNotPlusMinus
;
preIncrementExpression
: '++' unaryExpression
;
preDecrementExpression
: '--' unaryExpression
;
unaryExpressionNotPlusMinus
: postfixExpression
| '~' unaryExpression
| '!' unaryExpression
| castExpression
;
postfixExpression
: ( primary
| expressionName
)
( postIncrementExpression_lf_postfixExpression
| postDecrementExpression_lf_postfixExpression
)*
;
postIncrementExpression
: postfixExpression '++'
;
postIncrementExpression_lf_postfixExpression
: '++'
;
postDecrementExpression
: postfixExpression '--'
;
postDecrementExpression_lf_postfixExpression
: '--'
;
castExpression
: '(' primitiveType ')' unaryExpression
| '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus
| '(' referenceType additionalBound* ')' lambdaExpression
;
// LEXER
// §3.9 Keywords
ABSTRACT : 'abstract';
ASSERT : 'assert';
BOOLEAN : 'boolean';
BREAK : 'break';
BYTE : 'byte';
CASE : 'case';
CATCH : 'catch';
CHAR : 'char';
CLASS : 'class';
CONST : 'const';
CONTINUE : 'continue';
DEFAULT : 'default';
DO : 'do';
DOUBLE : 'double';
ELSE : 'else';
ENUM : 'enum';
EXTENDS : 'extends';
FINAL : 'final';
FINALLY : 'finally';
FLOAT : 'float';
FOR : 'for';
IF : 'if';
GOTO : 'goto';
IMPLEMENTS : 'implements';
IMPORT : 'import';
INSTANCEOF : 'instanceof';
INT : 'int';
INTERFACE : 'interface';
LONG : 'long';
NATIVE : 'native';
NEW : 'new';
PACKAGE : 'package';
PRIVATE : 'private';
PROTECTED : 'protected';
PUBLIC : 'public';
RETURN : 'return';
SHORT : 'short';
STATIC : 'static';
STRICTFP : 'strictfp';
SUPER : 'super';
SWITCH : 'switch';
SYNCHRONIZED : 'synchronized';
THIS : 'this';
THROW : 'throw';
THROWS : 'throws';
TRANSIENT : 'transient';
TRY : 'try';
VOID : 'void';
VOLATILE : 'volatile';
WHILE : 'while';
// §3.10.1 Integer Literals
IntegerLiteral
: DecimalIntegerLiteral
| HexIntegerLiteral
| OctalIntegerLiteral
| BinaryIntegerLiteral
;
fragment
DecimalIntegerLiteral
: DecimalNumeral IntegerTypeSuffix?
;
fragment
HexIntegerLiteral
: HexNumeral IntegerTypeSuffix?
;
fragment
OctalIntegerLiteral
: OctalNumeral IntegerTypeSuffix?
;
fragment
BinaryIntegerLiteral
: BinaryNumeral IntegerTypeSuffix?
;
fragment
IntegerTypeSuffix
: [lL]
;
fragment
DecimalNumeral
: '0'
| NonZeroDigit (Digits? | Underscores Digits)
;
fragment
Digits
: Digit (DigitsAndUnderscores? Digit)?
;
fragment
Digit
: '0'
| NonZeroDigit
;
fragment
NonZeroDigit
: [1-9]
;
fragment
DigitsAndUnderscores
: DigitOrUnderscore+
;
fragment
DigitOrUnderscore
: Digit
| '_'
;
fragment
Underscores
: '_'+
;
fragment
HexNumeral
: '0' [xX] HexDigits
;
fragment
HexDigits
: HexDigit (HexDigitsAndUnderscores? HexDigit)?
;
fragment
HexDigit
: [0-9a-fA-F]
;
fragment
HexDigitsAndUnderscores
: HexDigitOrUnderscore+
;
fragment
HexDigitOrUnderscore
: HexDigit
| '_'
;
fragment
OctalNumeral
: '0' Underscores? OctalDigits
;
fragment
OctalDigits
: OctalDigit (OctalDigitsAndUnderscores? OctalDigit)?
;
fragment
OctalDigit
: [0-7]
;
fragment
OctalDigitsAndUnderscores
: OctalDigitOrUnderscore+
;
fragment
OctalDigitOrUnderscore
: OctalDigit
| '_'
;
fragment
BinaryNumeral
: '0' [bB] BinaryDigits
;
fragment
BinaryDigits
: BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)?
;
fragment
BinaryDigit
: [01]
;
fragment
BinaryDigitsAndUnderscores
: BinaryDigitOrUnderscore+
;
fragment
BinaryDigitOrUnderscore
: BinaryDigit
| '_'
;
// §3.10.2 Floating-Point Literals
FloatingPointLiteral
: DecimalFloatingPointLiteral
| HexadecimalFloatingPointLiteral
;
fragment
DecimalFloatingPointLiteral
: Digits '.' Digits? ExponentPart? FloatTypeSuffix?
| '.' Digits ExponentPart? FloatTypeSuffix?
| Digits ExponentPart FloatTypeSuffix?
| Digits FloatTypeSuffix
;
fragment
ExponentPart
: ExponentIndicator SignedInteger
;
fragment
ExponentIndicator
: [eE]
;
fragment
SignedInteger
: Sign? Digits
;
fragment
Sign
: [+-]
;
fragment
FloatTypeSuffix
: [fFdD]
;
fragment
HexadecimalFloatingPointLiteral
: HexSignificand BinaryExponent FloatTypeSuffix?
;
fragment
HexSignificand
: HexNumeral '.'?
| '0' [xX] HexDigits? '.' HexDigits
;
fragment
BinaryExponent
: BinaryExponentIndicator SignedInteger
;
fragment
BinaryExponentIndicator
: [pP]
;
// §3.10.3 Boolean Literals
BooleanLiteral
: 'true'
| 'false'
;
// §3.10.4 Character Literals
CharacterLiteral
: '\'' SingleCharacter '\''
| '\'' EscapeSequence '\''
;
fragment
SingleCharacter
: ~['\\]
;
// §3.10.5 String Literals
StringLiteral
: '"' StringCharacters? '"'
;
fragment
StringCharacters
: StringCharacter+
;
fragment
StringCharacter
: ~["\\]
| EscapeSequence
;
// §3.10.6 Escape Sequences for Character and String Literals
fragment
EscapeSequence
: '\\' [btnfr"'\\]
| OctalEscape
| UnicodeEscape // This is not in the spec but prevents having to preprocess the input
;
fragment
OctalEscape
: '\\' OctalDigit
| '\\' OctalDigit OctalDigit
| '\\' ZeroToThree OctalDigit OctalDigit
;
fragment
ZeroToThree
: [0-3]
;
// This is not in the spec but prevents having to preprocess the input
fragment
UnicodeEscape
: '\\' 'u' HexDigit HexDigit HexDigit HexDigit
;
// §3.10.7 The Null Literal
NullLiteral
: 'null'
;
// §3.11 Separators
LPAREN : '(';
RPAREN : ')';
LBRACE : '{';
RBRACE : '}';
LBRACK : '[';
RBRACK : ']';
SEMI : ';';
COMMA : ',';
DOT : '.';
// §3.12 Operators
ASSIGN : '=';
GT : '>';
LT : '<';
BANG : '!';
TILDE : '~';
QUESTION : '?';
COLON : ':';
EQUAL : '==';
LE : '<=';
GE : '>=';
NOTEQUAL : '!=';
AND : '&&';
OR : '||';
INC : '++';
DEC : '--';
ADD : '+';
SUB : '-';
MUL : '*';
DIV : '/';
BITAND : '&';
BITOR : '|';
CARET : '^';
MOD : '%';
ARROW : '->';
COLONCOLON : '::';
ADD_ASSIGN : '+=';
SUB_ASSIGN : '-=';
MUL_ASSIGN : '*=';
DIV_ASSIGN : '/=';
AND_ASSIGN : '&=';
OR_ASSIGN : '|=';
XOR_ASSIGN : '^=';
MOD_ASSIGN : '%=';
LSHIFT_ASSIGN : '<<=';
RSHIFT_ASSIGN : '>>=';
URSHIFT_ASSIGN : '>>>=';
// §3.8 Identifiers (must appear after all keywords in the grammar)
Identifier
: JavaLetter JavaLetterOrDigit*
;
fragment
JavaLetter
: [a-zA-Z$_] // these are the "java letters" below 0x7F
| // covers all characters above 0x7F which are not a surrogate
~[\u0000-\u007F\uD800-\uDBFF]
{Character.isJavaIdentifierStart(_input.LA(-1))}?
| // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
[\uD800-\uDBFF] [\uDC00-\uDFFF]
{Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}?
;
fragment
JavaLetterOrDigit
: [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F
| // covers all characters above 0x7F which are not a surrogate
~[\u0000-\u007F\uD800-\uDBFF]
{Character.isJavaIdentifierPart(_input.LA(-1))}?
| // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
[\uD800-\uDBFF] [\uDC00-\uDFFF]
{Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}?
;
//
// Additional symbols not defined in the lexical specification
//
AT : '@';
ELLIPSIS : '...';
//
// Whitespace and comments
//
WS : [ \t\r\n\u000C]+ -> skip
;
COMMENT
: '/*' .*? '*/' -> skip
;
LINE_COMMENT
: '//' ~[\r\n]* -> skip
;
| 31,587 | ANTLR | .g4 | 1,457 | 19.72615 | 133 | 0.760458 | Java2NetProject/JavaConverter | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | b96f3803c86d00b1a2ea61ae59830430a39d478483983c09401f50b2ab56921a | false | false | false | false |
182 | Scritty1.g4 | peteranton1_parsepy1/src/main/antlr4/scritty/Scritty1.g4 | /*
* Copyright (c) 2019 by Peter Anton
*
*/
grammar Scritty1;
// All comments that start with "///" are copy-pasted from
// The Python Language Reference
tokens { INDENT, DEDENT }
@lexer::members {
// A queue where extra tokens are pushed on (see the NEWLINE lexer rule).
private java.util.LinkedList<Token> tokens = new java.util.LinkedList<>();
// The stack that keeps track of the indentation level.
private java.util.Stack<Integer> indents = new java.util.Stack<>();
// The amount of opened braces, brackets and parenthesis.
private int opened = 0;
// The most recently produced token.
private Token lastToken = null;
@Override
public void emit(Token t) {
super.setToken(t);
tokens.offer(t);
}
@Override
public Token nextToken() {
// Check if the end-of-file is ahead and there are still some DEDENTS expected.
if (_input.LA(1) == EOF && !this.indents.isEmpty()) {
// Remove any trailing EOF tokens from our buffer.
for (int i = tokens.size() - 1; i >= 0; i--) {
if (tokens.get(i).getType() == EOF) {
tokens.remove(i);
}
}
// First emit an extra line break that serves as the end of the statement.
this.emit(commonToken(Scritty1Parser.NEWLINE, "\n"));
// Now emit as much DEDENT tokens as needed.
while (!indents.isEmpty()) {
this.emit(createDedent());
indents.pop();
}
// Put the EOF back on the token stream.
this.emit(commonToken(Scritty1Parser.EOF, "<EOF>"));
}
Token next = super.nextToken();
if (next.getChannel() == Token.DEFAULT_CHANNEL) {
// Keep track of the last token on the default channel.
this.lastToken = next;
}
return tokens.isEmpty() ? next : tokens.poll();
}
private Token createDedent() {
CommonToken dedent = commonToken(Scritty1Parser.DEDENT, "");
dedent.setLine(this.lastToken.getLine());
return dedent;
}
private CommonToken commonToken(int type, String text) {
int stop = this.getCharIndex() - 1;
int start = text.isEmpty() ? stop : stop - text.length() + 1;
return new CommonToken(this._tokenFactorySourcePair, type, DEFAULT_TOKEN_CHANNEL, start, stop);
}
// Calculates the indentation of the provided spaces, taking the
// following rules into account:
//
// "Tabs are replaced (from left to right) by one to eight spaces
// such that the total number of characters up to and including
// the replacement is a multiple of eight [...]"
//
// -- https://docs.python.org/3.1/reference/lexical_analysis.html#indentation
static int getIndentationCount(String spaces) {
int count = 0;
for (char ch : spaces.toCharArray()) {
switch (ch) {
case '\t':
count += 8 - (count % 8);
break;
default:
// A normal space char.
count++;
}
}
return count;
}
boolean atStartOfInput() {
return super.getCharPositionInLine() == 0 && super.getLine() == 1;
}
}
/*
* parser rules
*/
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE;
file_input: (NEWLINE | stmt)* EOF;
eval_input: testlist NEWLINE* EOF;
decorator: '@' dotted_name ( '(' (arglist)? ')' )? NEWLINE;
decorators: decorator+;
decorated: decorators (classdef | funcdef | async_funcdef);
async_funcdef: ASYNC funcdef;
funcdef: 'def' NAME parameters ('->' test)? ':' suite;
parameters: '(' (typedargslist)? ')';
typedargslist: (tfpdef ('=' test)? (',' tfpdef ('=' test)?)* (',' (
'*' (tfpdef)? (',' tfpdef ('=' test)?)* (',' ('**' tfpdef (',')?)?)?
| '**' tfpdef (',')?)?)?
| '*' (tfpdef)? (',' tfpdef ('=' test)?)* (',' ('**' tfpdef (',')?)?)?
| '**' tfpdef (',')?);
tfpdef: NAME (':' test)?;
varargslist: (vfpdef ('=' test)? (',' vfpdef ('=' test)?)* (',' (
'*' (vfpdef)? (',' vfpdef ('=' test)?)* (',' ('**' vfpdef (',')?)?)?
| '**' vfpdef (',')?)?)?
| '*' (vfpdef)? (',' vfpdef ('=' test)?)* (',' ('**' vfpdef (',')?)?)?
| '**' vfpdef (',')?
);
vfpdef: NAME;
stmt: simple_stmt | compound_stmt;
simple_stmt: small_stmt (';' small_stmt)* (';')? NEWLINE;
small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt |
import_stmt | global_stmt | nonlocal_stmt | assert_stmt);
expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) |
('=' (yield_expr|testlist_star_expr))*);
annassign: ':' test ('=' test)?;
testlist_star_expr: (test|star_expr) (',' (test|star_expr))* (',')?;
augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
'<<=' | '>>=' | '**=' | '//=');
// For normal and annotated assignments, additional restrictions enforced by the interpreter
del_stmt: 'del' exprlist;
pass_stmt: 'pass';
flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt;
break_stmt: 'break';
continue_stmt: 'continue';
return_stmt: 'return' (testlist)?;
yield_stmt: yield_expr;
raise_stmt: 'raise' (test ('from' test)?)?;
import_stmt: import_name | import_from;
import_name: 'import' dotted_as_names;
// note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+)
'import' ('*' | '(' import_as_names ')' | import_as_names));
import_as_name: NAME ('as' NAME)?;
dotted_as_name: dotted_name ('as' NAME)?;
import_as_names: import_as_name (',' import_as_name)* (',')?;
dotted_as_names: dotted_as_name (',' dotted_as_name)*;
dotted_name: NAME ('.' NAME)*;
global_stmt: 'global' NAME (',' NAME)*;
nonlocal_stmt: 'nonlocal' NAME (',' NAME)*;
assert_stmt: 'assert' test (',' test)?;
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt;
async_stmt: ASYNC (funcdef | with_stmt | for_stmt);
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ('else' ':' suite)?;
while_stmt: 'while' test ':' suite ('else' ':' suite)?;
for_stmt: 'for' exprlist 'in' testlist ':' suite ('else' ':' suite)?;
try_stmt: ('try' ':' suite
((except_clause ':' suite)+
('else' ':' suite)?
('finally' ':' suite)? |
'finally' ':' suite));
with_stmt: 'with' with_item (',' with_item)* ':' suite;
with_item: test ('as' expr)?;
// NB compile.c makes sure that the default except clause is last
except_clause: 'except' (test ('as' NAME)?)?;
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT;
test: or_test ('if' or_test 'else' test)? | lambdef;
test_nocond: or_test | lambdef_nocond;
lambdef: 'lambda' (varargslist)? ':' test;
lambdef_nocond: 'lambda' (varargslist)? ':' test_nocond;
or_test: and_test ('or' and_test)*;
and_test: not_test ('and' not_test)*;
not_test: 'not' not_test | comparison;
comparison: expr (comp_op expr)*;
// <> isn't actually a valid comparison operator in Python. It's here for the
// sake of a __future__ import described in PEP 401 (which really works :-)
comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not';
star_expr: '*' expr;
expr: xor_expr ('|' xor_expr)*;
xor_expr: and_expr ('^' and_expr)*;
and_expr: shift_expr ('&' shift_expr)*;
shift_expr: arith_expr (('<<'|'>>') arith_expr)*;
arith_expr: term (('+'|'-') term)*;
term: factor (('*'|'@'|'/'|'%'|'//') factor)*;
factor: ('+'|'-'|'~') factor | power;
power: atom_expr ('**' factor)?;
atom_expr: (AWAIT)? atom trailer*;
atom: ('(' (yield_expr|testlist_comp)? ')' |
'[' (testlist_comp)? ']' |
'{' (dictorsetmaker)? '}' |
NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False');
testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* (',')? );
trailer: '(' (arglist)? ')' | '[' subscriptlist ']' | '.' NAME;
subscriptlist: subscript (',' subscript)* (',')?;
subscript: test | (test)? ':' (test)? (sliceop)?;
sliceop: ':' (test)?;
exprlist: (expr|star_expr) (',' (expr|star_expr))* (',')?;
testlist: test (',' test)* (',')?;
dictorsetmaker: ( ((test ':' test | '**' expr)
(comp_for | (',' (test ':' test | '**' expr))* (',')?)) |
((test | star_expr)
(comp_for | (',' (test | star_expr))* (',')?)) );
classdef: 'class' NAME ('(' (arglist)? ')')? ':' suite;
arglist: argument (',' argument)* (',')?;
// The reason that keywords are test nodes instead of NAME is that using NAME
// results in an ambiguity. ast.c makes sure it's a NAME.
// "test '=' test" is really "keyword '=' test", but we have no such token.
// These need to be in a single rule to avoid grammar that is ambiguous
// to our LL(1) parser. Even though 'test' includes '*expr' in star_expr,
// we explicitly match '*' here, too, to give it proper precedence.
// Illegal combinations and orderings are blocked in ast.c:
// multiple (test comp_for) arguments are blocked; keyword unpackings
// that precede iterable unpackings are blocked; etc.
argument: ( test (comp_for)? |
test '=' test |
'**' test |
'*' test );
comp_iter: comp_for | comp_if;
comp_for: (ASYNC)? 'for' exprlist 'in' or_test (comp_iter)?;
comp_if: 'if' test_nocond (comp_iter)?;
// not used in grammar, but may appear in "node" passed from Parser to Compiler
encoding_decl: NAME;
yield_expr: 'yield' (yield_arg)?;
yield_arg: 'from' test | testlist;
/*
* lexer rules
*/
STRING
: STRING_LITERAL
| BYTES_LITERAL
;
NUMBER
: INTEGER
| FLOAT_NUMBER
| IMAG_NUMBER
;
INTEGER
: DECIMAL_INTEGER
| OCT_INTEGER
| HEX_INTEGER
| BIN_INTEGER
;
// scritty tokens
VAR : 'var';
COL : 'col';
ROW : 'row';
BLOCK : 'block';
CODE : 'code';
SINGLE : 'single';
MULTIPLE : 'multiple';
// python tokens
DEF : 'def';
RETURN : 'return';
RAISE : 'raise';
FROM : 'from';
IMPORT : 'import';
AS : 'as';
GLOBAL : 'global';
NONLOCAL : 'nonlocal';
ASSERT : 'assert';
IF : 'if';
ELIF : 'elif';
ELSE : 'else';
WHILE : 'while';
FOR : 'for';
IN : 'in';
TRY : 'try';
FINALLY : 'finally';
WITH : 'with';
EXCEPT : 'except';
LAMBDA : 'lambda';
OR : 'or';
AND : 'and';
NOT : 'not';
IS : 'is';
NONE : 'None';
TRUE : 'True';
FALSE : 'False';
CLASS : 'class';
YIELD : 'yield';
DEL : 'del';
PASS : 'pass';
CONTINUE : 'continue';
BREAK : 'break';
ASYNC : 'async';
AWAIT : 'await';
NEWLINE
: ( {atStartOfInput()}? SPACES
| ( '\r'? '\n' | '\r' | '\f' ) SPACES?
)
{
String newLine = getText().replaceAll("[^\r\n\f]+", "");
String spaces = getText().replaceAll("[\r\n\f]+", "");
int next = _input.LA(1);
if (opened > 0 || next == '\r' || next == '\n' || next == '\f' || next == '#') {
// If we're inside a list or on a blank line, ignore all indents,
// dedents and line breaks.
skip();
}
else {
emit(commonToken(NEWLINE, newLine));
int indent = getIndentationCount(spaces);
int previous = indents.isEmpty() ? 0 : indents.peek();
if (indent == previous) {
// skip indents of the same size as the present indent-size
skip();
}
else if (indent > previous) {
indents.push(indent);
emit(commonToken(Scritty1Parser.INDENT, spaces));
}
else {
// Possibly emit more than 1 DEDENT token.
while(!indents.isEmpty() && indents.peek() > indent) {
this.emit(createDedent());
indents.pop();
}
}
}
}
;
/// identifier ::= id_start id_continue*
NAME
: ID_START ID_CONTINUE*
;
/// stringliteral ::= [stringprefix](shortstring | longstring)
/// stringprefix ::= "r" | "u" | "R" | "U" | "f" | "F"
/// | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF"
STRING_LITERAL
: ( [rR] | [uU] | [fF] | ( [fF] [rR] ) | ( [rR] [fF] ) )? ( SHORT_STRING | LONG_STRING )
;
/// bytesliteral ::= bytesprefix(shortbytes | longbytes)
/// bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB"
BYTES_LITERAL
: ( [bB] | ( [bB] [rR] ) | ( [rR] [bB] ) ) ( SHORT_BYTES | LONG_BYTES )
;
/// decimalinteger ::= nonzerodigit digit* | "0"+
DECIMAL_INTEGER
: NON_ZERO_DIGIT DIGIT*
| '0'+
;
/// octinteger ::= "0" ("o" | "O") octdigit+
OCT_INTEGER
: '0' [oO] OCT_DIGIT+
;
/// hexinteger ::= "0" ("x" | "X") hexdigit+
HEX_INTEGER
: '0' [xX] HEX_DIGIT+
;
/// bininteger ::= "0" ("b" | "B") bindigit+
BIN_INTEGER
: '0' [bB] BIN_DIGIT+
;
/// floatnumber ::= pointfloat | exponentfloat
FLOAT_NUMBER
: POINT_FLOAT
| EXPONENT_FLOAT
;
/// imagnumber ::= (floatnumber | intpart) ("j" | "J")
IMAG_NUMBER
: ( FLOAT_NUMBER | INT_PART ) [jJ]
;
DOT : '.';
ELLIPSIS : '...';
STAR : '*';
OPEN_PAREN : '(' {opened++;};
CLOSE_PAREN : ')' {opened--;};
COMMA : ',';
COLON : ':';
SEMI_COLON : ';';
POWER : '**';
ASSIGN : '=';
OPEN_BRACK : '[' {opened++;};
CLOSE_BRACK : ']' {opened--;};
OR_OP : '|';
XOR : '^';
AND_OP : '&';
LEFT_SHIFT : '<<';
RIGHT_SHIFT : '>>';
ADD : '+';
MINUS : '-';
DIV : '/';
MOD : '%';
IDIV : '//';
NOT_OP : '~';
OPEN_BRACE : '{' {opened++;};
CLOSE_BRACE : '}' {opened--;};
LESS_THAN : '<';
GREATER_THAN : '>';
EQUALS : '==';
GT_EQ : '>=';
LT_EQ : '<=';
NOT_EQ_1 : '<>';
NOT_EQ_2 : '!=';
AT : '@';
ARROW : '->';
ADD_ASSIGN : '+=';
SUB_ASSIGN : '-=';
MULT_ASSIGN : '*=';
AT_ASSIGN : '@=';
DIV_ASSIGN : '/=';
MOD_ASSIGN : '%=';
AND_ASSIGN : '&=';
OR_ASSIGN : '|=';
XOR_ASSIGN : '^=';
LEFT_SHIFT_ASSIGN : '<<=';
RIGHT_SHIFT_ASSIGN : '>>=';
POWER_ASSIGN : '**=';
IDIV_ASSIGN : '//=';
SKIP_
: ( SPACES | COMMENT | LINE_JOINING ) -> skip
;
UNKNOWN_CHAR
: .
;
/*
* fragments
*/
/// shortstring ::= "'" shortstringitem* "'" | '"' shortstringitem* '"'
/// shortstringitem ::= shortstringchar | stringescapeseq
/// shortstringchar ::= <any source character except "\" or newline or the quote>
fragment SHORT_STRING
: '\'' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f'] )* '\''
| '"' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f"] )* '"'
;
/// longstring ::= "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
fragment LONG_STRING
: '\'\'\'' LONG_STRING_ITEM*? '\'\'\''
| '"""' LONG_STRING_ITEM*? '"""'
;
/// longstringitem ::= longstringchar | stringescapeseq
fragment LONG_STRING_ITEM
: LONG_STRING_CHAR
| STRING_ESCAPE_SEQ
;
/// longstringchar ::= <any source character except "\">
fragment LONG_STRING_CHAR
: ~'\\'
;
/// stringescapeseq ::= "\" <any source character>
fragment STRING_ESCAPE_SEQ
: '\\' .
| '\\' NEWLINE
;
/// nonzerodigit ::= "1"..."9"
fragment NON_ZERO_DIGIT
: [1-9]
;
/// digit ::= "0"..."9"
fragment DIGIT
: [0-9]
;
/// octdigit ::= "0"..."7"
fragment OCT_DIGIT
: [0-7]
;
/// hexdigit ::= digit | "a"..."f" | "A"..."F"
fragment HEX_DIGIT
: [0-9a-fA-F]
;
/// bindigit ::= "0" | "1"
fragment BIN_DIGIT
: [01]
;
/// pointfloat ::= [intpart] fraction | intpart "."
fragment POINT_FLOAT
: INT_PART? FRACTION
| INT_PART '.'
;
/// exponentfloat ::= (intpart | pointfloat) exponent
fragment EXPONENT_FLOAT
: ( INT_PART | POINT_FLOAT ) EXPONENT
;
/// intpart ::= digit+
fragment INT_PART
: DIGIT+
;
/// fraction ::= "." digit+
fragment FRACTION
: '.' DIGIT+
;
/// exponent ::= ("e" | "E") ["+" | "-"] digit+
fragment EXPONENT
: [eE] [+-]? DIGIT+
;
/// shortbytes ::= "'" shortbytesitem* "'" | '"' shortbytesitem* '"'
/// shortbytesitem ::= shortbyteschar | bytesescapeseq
fragment SHORT_BYTES
: '\'' ( SHORT_BYTES_CHAR_NO_SINGLE_QUOTE | BYTES_ESCAPE_SEQ )* '\''
| '"' ( SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE | BYTES_ESCAPE_SEQ )* '"'
;
/// longbytes ::= "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""'
fragment LONG_BYTES
: '\'\'\'' LONG_BYTES_ITEM*? '\'\'\''
| '"""' LONG_BYTES_ITEM*? '"""'
;
/// longbytesitem ::= longbyteschar | bytesescapeseq
fragment LONG_BYTES_ITEM
: LONG_BYTES_CHAR
| BYTES_ESCAPE_SEQ
;
/// shortbyteschar ::= <any ASCII character except "\" or newline or the quote>
fragment SHORT_BYTES_CHAR_NO_SINGLE_QUOTE
: [\u0000-\u0009]
| [\u000B-\u000C]
| [\u000E-\u0026]
| [\u0028-\u005B]
| [\u005D-\u007F]
;
fragment SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE
: [\u0000-\u0009]
| [\u000B-\u000C]
| [\u000E-\u0021]
| [\u0023-\u005B]
| [\u005D-\u007F]
;
/// longbyteschar ::= <any ASCII character except "\">
fragment LONG_BYTES_CHAR
: [\u0000-\u005B]
| [\u005D-\u007F]
;
/// bytesescapeseq ::= "\" <any ASCII character>
fragment BYTES_ESCAPE_SEQ
: '\\' [\u0000-\u007F]
;
fragment SPACES
: [ \t]+
;
fragment COMMENT
: '#' ~[\r\n\f]*
;
fragment LINE_JOINING
: '\\' SPACES? ( '\r'? '\n' | '\r' | '\f')
;
/// id_start ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>
fragment ID_START
: '_'
| [A-Z]
| [a-z]
| '\u00AA'
| '\u00B5'
| '\u00BA'
| [\u00C0-\u00D6]
| [\u00D8-\u00F6]
| [\u00F8-\u01BA]
| '\u01BB'
| [\u01BC-\u01BF]
| [\u01C0-\u01C3]
| [\u01C4-\u0241]
| [\u0250-\u02AF]
| [\u02B0-\u02C1]
| [\u02C6-\u02D1]
| [\u02E0-\u02E4]
| '\u02EE'
| '\u037A'
| '\u0386'
| [\u0388-\u038A]
| '\u038C'
| [\u038E-\u03A1]
| [\u03A3-\u03CE]
| [\u03D0-\u03F5]
| [\u03F7-\u0481]
| [\u048A-\u04CE]
| [\u04D0-\u04F9]
| [\u0500-\u050F]
| [\u0531-\u0556]
| '\u0559'
| [\u0561-\u0587]
| [\u05D0-\u05EA]
| [\u05F0-\u05F2]
| [\u0621-\u063A]
| '\u0640'
| [\u0641-\u064A]
| [\u066E-\u066F]
| [\u0671-\u06D3]
| '\u06D5'
| [\u06E5-\u06E6]
| [\u06EE-\u06EF]
| [\u06FA-\u06FC]
| '\u06FF'
| '\u0710'
| [\u0712-\u072F]
| [\u074D-\u076D]
| [\u0780-\u07A5]
| '\u07B1'
| [\u0904-\u0939]
| '\u093D'
| '\u0950'
| [\u0958-\u0961]
| '\u097D'
| [\u0985-\u098C]
| [\u098F-\u0990]
| [\u0993-\u09A8]
| [\u09AA-\u09B0]
| '\u09B2'
| [\u09B6-\u09B9]
| '\u09BD'
| '\u09CE'
| [\u09DC-\u09DD]
| [\u09DF-\u09E1]
| [\u09F0-\u09F1]
| [\u0A05-\u0A0A]
| [\u0A0F-\u0A10]
| [\u0A13-\u0A28]
| [\u0A2A-\u0A30]
| [\u0A32-\u0A33]
| [\u0A35-\u0A36]
| [\u0A38-\u0A39]
| [\u0A59-\u0A5C]
| '\u0A5E'
| [\u0A72-\u0A74]
| [\u0A85-\u0A8D]
| [\u0A8F-\u0A91]
| [\u0A93-\u0AA8]
| [\u0AAA-\u0AB0]
| [\u0AB2-\u0AB3]
| [\u0AB5-\u0AB9]
| '\u0ABD'
| '\u0AD0'
| [\u0AE0-\u0AE1]
| [\u0B05-\u0B0C]
| [\u0B0F-\u0B10]
| [\u0B13-\u0B28]
| [\u0B2A-\u0B30]
| [\u0B32-\u0B33]
| [\u0B35-\u0B39]
| '\u0B3D'
| [\u0B5C-\u0B5D]
| [\u0B5F-\u0B61]
| '\u0B71'
| '\u0B83'
| [\u0B85-\u0B8A]
| [\u0B8E-\u0B90]
| [\u0B92-\u0B95]
| [\u0B99-\u0B9A]
| '\u0B9C'
| [\u0B9E-\u0B9F]
| [\u0BA3-\u0BA4]
| [\u0BA8-\u0BAA]
| [\u0BAE-\u0BB9]
| [\u0C05-\u0C0C]
| [\u0C0E-\u0C10]
| [\u0C12-\u0C28]
| [\u0C2A-\u0C33]
| [\u0C35-\u0C39]
| [\u0C60-\u0C61]
| [\u0C85-\u0C8C]
| [\u0C8E-\u0C90]
| [\u0C92-\u0CA8]
| [\u0CAA-\u0CB3]
| [\u0CB5-\u0CB9]
| '\u0CBD'
| '\u0CDE'
| [\u0CE0-\u0CE1]
| [\u0D05-\u0D0C]
| [\u0D0E-\u0D10]
| [\u0D12-\u0D28]
| [\u0D2A-\u0D39]
| [\u0D60-\u0D61]
| [\u0D85-\u0D96]
| [\u0D9A-\u0DB1]
| [\u0DB3-\u0DBB]
| '\u0DBD'
| [\u0DC0-\u0DC6]
| [\u0E01-\u0E30]
| [\u0E32-\u0E33]
| [\u0E40-\u0E45]
| '\u0E46'
| [\u0E81-\u0E82]
| '\u0E84'
| [\u0E87-\u0E88]
| '\u0E8A'
| '\u0E8D'
| [\u0E94-\u0E97]
| [\u0E99-\u0E9F]
| [\u0EA1-\u0EA3]
| '\u0EA5'
| '\u0EA7'
| [\u0EAA-\u0EAB]
| [\u0EAD-\u0EB0]
| [\u0EB2-\u0EB3]
| '\u0EBD'
| [\u0EC0-\u0EC4]
| '\u0EC6'
| [\u0EDC-\u0EDD]
| '\u0F00'
| [\u0F40-\u0F47]
| [\u0F49-\u0F6A]
| [\u0F88-\u0F8B]
| [\u1000-\u1021]
| [\u1023-\u1027]
| [\u1029-\u102A]
| [\u1050-\u1055]
| [\u10A0-\u10C5]
| [\u10D0-\u10FA]
| '\u10FC'
| [\u1100-\u1159]
| [\u115F-\u11A2]
| [\u11A8-\u11F9]
| [\u1200-\u1248]
| [\u124A-\u124D]
| [\u1250-\u1256]
| '\u1258'
| [\u125A-\u125D]
| [\u1260-\u1288]
| [\u128A-\u128D]
| [\u1290-\u12B0]
| [\u12B2-\u12B5]
| [\u12B8-\u12BE]
| '\u12C0'
| [\u12C2-\u12C5]
| [\u12C8-\u12D6]
| [\u12D8-\u1310]
| [\u1312-\u1315]
| [\u1318-\u135A]
| [\u1380-\u138F]
| [\u13A0-\u13F4]
| [\u1401-\u166C]
| [\u166F-\u1676]
| [\u1681-\u169A]
| [\u16A0-\u16EA]
| [\u16EE-\u16F0]
| [\u1700-\u170C]
| [\u170E-\u1711]
| [\u1720-\u1731]
| [\u1740-\u1751]
| [\u1760-\u176C]
| [\u176E-\u1770]
| [\u1780-\u17B3]
| '\u17D7'
| '\u17DC'
| [\u1820-\u1842]
| '\u1843'
| [\u1844-\u1877]
| [\u1880-\u18A8]
| [\u1900-\u191C]
| [\u1950-\u196D]
| [\u1970-\u1974]
| [\u1980-\u19A9]
| [\u19C1-\u19C7]
| [\u1A00-\u1A16]
| [\u1D00-\u1D2B]
| [\u1D2C-\u1D61]
| [\u1D62-\u1D77]
| '\u1D78'
| [\u1D79-\u1D9A]
| [\u1D9B-\u1DBF]
| [\u1E00-\u1E9B]
| [\u1EA0-\u1EF9]
| [\u1F00-\u1F15]
| [\u1F18-\u1F1D]
| [\u1F20-\u1F45]
| [\u1F48-\u1F4D]
| [\u1F50-\u1F57]
| '\u1F59'
| '\u1F5B'
| '\u1F5D'
| [\u1F5F-\u1F7D]
| [\u1F80-\u1FB4]
| [\u1FB6-\u1FBC]
| '\u1FBE'
| [\u1FC2-\u1FC4]
| [\u1FC6-\u1FCC]
| [\u1FD0-\u1FD3]
| [\u1FD6-\u1FDB]
| [\u1FE0-\u1FEC]
| [\u1FF2-\u1FF4]
| [\u1FF6-\u1FFC]
| '\u2071'
| '\u207F'
| [\u2090-\u2094]
| '\u2102'
| '\u2107'
| [\u210A-\u2113]
| '\u2115'
| '\u2118'
| [\u2119-\u211D]
| '\u2124'
| '\u2126'
| '\u2128'
| [\u212A-\u212D]
| '\u212E'
| [\u212F-\u2131]
| [\u2133-\u2134]
| [\u2135-\u2138]
| '\u2139'
| [\u213C-\u213F]
| [\u2145-\u2149]
| [\u2160-\u2183]
| [\u2C00-\u2C2E]
| [\u2C30-\u2C5E]
| [\u2C80-\u2CE4]
| [\u2D00-\u2D25]
| [\u2D30-\u2D65]
| '\u2D6F'
| [\u2D80-\u2D96]
| [\u2DA0-\u2DA6]
| [\u2DA8-\u2DAE]
| [\u2DB0-\u2DB6]
| [\u2DB8-\u2DBE]
| [\u2DC0-\u2DC6]
| [\u2DC8-\u2DCE]
| [\u2DD0-\u2DD6]
| [\u2DD8-\u2DDE]
| '\u3005'
| '\u3006'
| '\u3007'
| [\u3021-\u3029]
| [\u3031-\u3035]
| [\u3038-\u303A]
| '\u303B'
| '\u303C'
| [\u3041-\u3096]
| [\u309B-\u309C]
| [\u309D-\u309E]
| '\u309F'
| [\u30A1-\u30FA]
| [\u30FC-\u30FE]
| '\u30FF'
| [\u3105-\u312C]
| [\u3131-\u318E]
| [\u31A0-\u31B7]
| [\u31F0-\u31FF]
| [\u3400-\u4DB5]
| [\u4E00-\u9FBB]
| [\uA000-\uA014]
| '\uA015'
| [\uA016-\uA48C]
| [\uA800-\uA801]
| [\uA803-\uA805]
| [\uA807-\uA80A]
| [\uA80C-\uA822]
| [\uAC00-\uD7A3]
| [\uF900-\uFA2D]
| [\uFA30-\uFA6A]
| [\uFA70-\uFAD9]
| [\uFB00-\uFB06]
| [\uFB13-\uFB17]
| '\uFB1D'
| [\uFB1F-\uFB28]
| [\uFB2A-\uFB36]
| [\uFB38-\uFB3C]
| '\uFB3E'
| [\uFB40-\uFB41]
| [\uFB43-\uFB44]
| [\uFB46-\uFBB1]
| [\uFBD3-\uFD3D]
| [\uFD50-\uFD8F]
| [\uFD92-\uFDC7]
| [\uFDF0-\uFDFB]
| [\uFE70-\uFE74]
| [\uFE76-\uFEFC]
| [\uFF21-\uFF3A]
| [\uFF41-\uFF5A]
| [\uFF66-\uFF6F]
| '\uFF70'
| [\uFF71-\uFF9D]
| [\uFF9E-\uFF9F]
| [\uFFA0-\uFFBE]
| [\uFFC2-\uFFC7]
| [\uFFCA-\uFFCF]
| [\uFFD2-\uFFD7]
| [\uFFDA-\uFFDC]
;
/// id_continue ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
fragment ID_CONTINUE
: ID_START
| [0-9]
| [\u0300-\u036F]
| [\u0483-\u0486]
| [\u0591-\u05B9]
| [\u05BB-\u05BD]
| '\u05BF'
| [\u05C1-\u05C2]
| [\u05C4-\u05C5]
| '\u05C7'
| [\u0610-\u0615]
| [\u064B-\u065E]
| [\u0660-\u0669]
| '\u0670'
| [\u06D6-\u06DC]
| [\u06DF-\u06E4]
| [\u06E7-\u06E8]
| [\u06EA-\u06ED]
| [\u06F0-\u06F9]
| '\u0711'
| [\u0730-\u074A]
| [\u07A6-\u07B0]
| [\u0901-\u0902]
| '\u0903'
| '\u093C'
| [\u093E-\u0940]
| [\u0941-\u0948]
| [\u0949-\u094C]
| '\u094D'
| [\u0951-\u0954]
| [\u0962-\u0963]
| [\u0966-\u096F]
| '\u0981'
| [\u0982-\u0983]
| '\u09BC'
| [\u09BE-\u09C0]
| [\u09C1-\u09C4]
| [\u09C7-\u09C8]
| [\u09CB-\u09CC]
| '\u09CD'
| '\u09D7'
| [\u09E2-\u09E3]
| [\u09E6-\u09EF]
| [\u0A01-\u0A02]
| '\u0A03'
| '\u0A3C'
| [\u0A3E-\u0A40]
| [\u0A41-\u0A42]
| [\u0A47-\u0A48]
| [\u0A4B-\u0A4D]
| [\u0A66-\u0A6F]
| [\u0A70-\u0A71]
| [\u0A81-\u0A82]
| '\u0A83'
| '\u0ABC'
| [\u0ABE-\u0AC0]
| [\u0AC1-\u0AC5]
| [\u0AC7-\u0AC8]
| '\u0AC9'
| [\u0ACB-\u0ACC]
| '\u0ACD'
| [\u0AE2-\u0AE3]
| [\u0AE6-\u0AEF]
| '\u0B01'
| [\u0B02-\u0B03]
| '\u0B3C'
| '\u0B3E'
| '\u0B3F'
| '\u0B40'
| [\u0B41-\u0B43]
| [\u0B47-\u0B48]
| [\u0B4B-\u0B4C]
| '\u0B4D'
| '\u0B56'
| '\u0B57'
| [\u0B66-\u0B6F]
| '\u0B82'
| [\u0BBE-\u0BBF]
| '\u0BC0'
| [\u0BC1-\u0BC2]
| [\u0BC6-\u0BC8]
| [\u0BCA-\u0BCC]
| '\u0BCD'
| '\u0BD7'
| [\u0BE6-\u0BEF]
| [\u0C01-\u0C03]
| [\u0C3E-\u0C40]
| [\u0C41-\u0C44]
| [\u0C46-\u0C48]
| [\u0C4A-\u0C4D]
| [\u0C55-\u0C56]
| [\u0C66-\u0C6F]
| [\u0C82-\u0C83]
| '\u0CBC'
| '\u0CBE'
| '\u0CBF'
| [\u0CC0-\u0CC4]
| '\u0CC6'
| [\u0CC7-\u0CC8]
| [\u0CCA-\u0CCB]
| [\u0CCC-\u0CCD]
| [\u0CD5-\u0CD6]
| [\u0CE6-\u0CEF]
| [\u0D02-\u0D03]
| [\u0D3E-\u0D40]
| [\u0D41-\u0D43]
| [\u0D46-\u0D48]
| [\u0D4A-\u0D4C]
| '\u0D4D'
| '\u0D57'
| [\u0D66-\u0D6F]
| [\u0D82-\u0D83]
| '\u0DCA'
| [\u0DCF-\u0DD1]
| [\u0DD2-\u0DD4]
| '\u0DD6'
| [\u0DD8-\u0DDF]
| [\u0DF2-\u0DF3]
| '\u0E31'
| [\u0E34-\u0E3A]
| [\u0E47-\u0E4E]
| [\u0E50-\u0E59]
| '\u0EB1'
| [\u0EB4-\u0EB9]
| [\u0EBB-\u0EBC]
| [\u0EC8-\u0ECD]
| [\u0ED0-\u0ED9]
| [\u0F18-\u0F19]
| [\u0F20-\u0F29]
| '\u0F35'
| '\u0F37'
| '\u0F39'
| [\u0F3E-\u0F3F]
| [\u0F71-\u0F7E]
| '\u0F7F'
| [\u0F80-\u0F84]
| [\u0F86-\u0F87]
| [\u0F90-\u0F97]
| [\u0F99-\u0FBC]
| '\u0FC6'
| '\u102C'
| [\u102D-\u1030]
| '\u1031'
| '\u1032'
| [\u1036-\u1037]
| '\u1038'
| '\u1039'
| [\u1040-\u1049]
| [\u1056-\u1057]
| [\u1058-\u1059]
| '\u135F'
| [\u1369-\u1371]
| [\u1712-\u1714]
| [\u1732-\u1734]
| [\u1752-\u1753]
| [\u1772-\u1773]
| '\u17B6'
| [\u17B7-\u17BD]
| [\u17BE-\u17C5]
| '\u17C6'
| [\u17C7-\u17C8]
| [\u17C9-\u17D3]
| '\u17DD'
| [\u17E0-\u17E9]
| [\u180B-\u180D]
| [\u1810-\u1819]
| '\u18A9'
| [\u1920-\u1922]
| [\u1923-\u1926]
| [\u1927-\u1928]
| [\u1929-\u192B]
| [\u1930-\u1931]
| '\u1932'
| [\u1933-\u1938]
| [\u1939-\u193B]
| [\u1946-\u194F]
| [\u19B0-\u19C0]
| [\u19C8-\u19C9]
| [\u19D0-\u19D9]
| [\u1A17-\u1A18]
| [\u1A19-\u1A1B]
| [\u1DC0-\u1DC3]
| [\u203F-\u2040]
| '\u2054'
| [\u20D0-\u20DC]
| '\u20E1'
| [\u20E5-\u20EB]
| [\u302A-\u302F]
| [\u3099-\u309A]
| '\uA802'
| '\uA806'
| '\uA80B'
| [\uA823-\uA824]
| [\uA825-\uA826]
| '\uA827'
| '\uFB1E'
| [\uFE00-\uFE0F]
| [\uFE20-\uFE23]
| [\uFE33-\uFE34]
| [\uFE4D-\uFE4F]
| [\uFF10-\uFF19]
| '\uFF3F'
;
| 25,852 | ANTLR | .g4 | 1,060 | 21.960377 | 148 | 0.569267 | peteranton1/parsepy1 | 0 | 0 | 1 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | a44a16c85195c6868c2812a894902f09afa525d2b1f3ace421ad552cbae63c00 | false | false | false | false |
183 | AFM.g4 | flamapy_afmparser/afmparser/AFM.g4 | grammar AFM;
//parser rules
//model
feature_model:
relationships_block attributes_block? constraints_block?;
//relationships block
relationships_block: '%Relationships' relationship_spec*;
relationship_spec:
init_spec (non_cardinal_spec | cardinal_spec)+ ';';
init_spec: SPACE? WORD SPACE? ':' SPACE?;
obligatory_spec: SPACE? WORD SPACE?;
optional_spec: SPACE? '[' WORD ']' SPACE?;
non_cardinal_spec: (obligatory_spec | optional_spec);
cardinality: '[' INT ',' INT ']';
cardinal_spec:
SPACE? cardinality SPACE? '{' obligatory_spec+ '}';
//attributes block
attributes_block: '%Attributes' attribute_spec*;
attribute_spec:
attribute_name SPACE? ':' SPACE? attribute_domain SPACE? ',' SPACE? attribute_default_value
SPACE? ',' SPACE? attribute_null_value ';';
attribute_name: WORD '.' LOWERCASE;
attribute_domain: (discrete_domain_spec | range_domain_spec);
discrete_domain_spec: '[' value_spec (',' value_spec)* ']';
range_domain_spec: SPACE? INTEGER SPACE? domain_range*;
domain_range: '[' INT SPACE? 'to' SPACE? INT ']';
attribute_default_value: value_spec;
attribute_null_value: value_spec;
value_spec: (WORD | LOWERCASE | INT | DOUBLE | STRING);
//constraints block
constraints_block: '%Constraints' constraint_spec*;
constraint_spec: brackets_spec | simple_spec;
brackets_spec:
SPACE? WORD SPACE? '{' SPACE? simple_spec* SPACE? '}' SPACE?;
simple_spec: SPACE? expression SPACE? ';' SPACE?;
expression:
SPACE? '(' expression ')' SPACE? # parenthesisExp
| expression arithmetic_operator expression # arithmeticExp
| expression relational_operator expression # relationalExp
| NOT expression # notExp
| expression AND expression # andExp
| expression OR expression # orExp
| expression logical_operator expression # logicalExp
| SPACE? (variable | number) SPACE? # atom;
logical_operator: IFF | IMPLIES | REQUIRES | EXCLUDES;
arithmetic_operator: ADD | SUB | MULT | DIV | MOD | POW | ASIG;
relational_operator:
HIGHER_THAN
| LOWER_THAN
| HIGHER_EQUAL_THAN
| LOWER_EQUAL_THAN
| EQUAL
| DISTINCT;
number: INT | DOUBLE;
variable: WORD ('.' LOWERCASE)? | LOWERCASE;
//lexer rules
//arithmetic operators
ADD: '+';
SUB: '-';
MULT: '*';
DIV: '/';
MOD: '%';
POW: '^';
ASIG: '=';
//prefix operators
ABS: 'abs';
MAX: 'max';
MIN: 'min';
COS: 'cos';
SIN: 'sin';
SUM: 'sum';
//logical operators
AND: 'AND';
OR: 'OR';
NOT: 'NOT';
IFF: 'IFF';
IMPLIES: 'IMPLIES';
REQUIRES: 'REQUIRES';
EXCLUDES: 'EXCLUDES';
//relational operators
HIGHER_THAN: '>';
LOWER_THAN: '<';
HIGHER_EQUAL_THAN: '>=';
LOWER_EQUAL_THAN: '<=';
EQUAL: '==';
DISTINCT: '!=';
INTEGER: 'Integer';
LOWERCASE: [a-z][a-z0-9]*;
WORD: [A-Z][a-zA-Z0-9]*;
INT: '0' | [1-9][0-9]*;
DOUBLE: [1-9][0-9]* '.' [0-9]+;
STRING: '"' (~'"')* '"';
SPACE: (' ' | '\t')+;
WS: [\n\r]+ -> skip; | 2,795 | ANTLR | .g4 | 94 | 28.170213 | 92 | 0.694496 | flamapy/afmparser | 0 | 0 | 1 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | f7181df101235bd5f03bb9043823da2ffd6660e35857337b301482e691e75b9a | false | false | false | false |
184 | CommandSkript.g4 | Zerthick_CommandSkript/src/main/antlr/io/github/zerthick/commandskript/CommandSkript.g4 | grammar CommandSkript;
@header {
package io.github.zerthick.commandskript;
}
script
: block EOF
;
block
: statement*
;
statement
: assignment ';'
| functionCall ';'
| ifStatement
| forStatement
| whileStatement
;
assignment
: Variable index? '=' expression #variableAssignment
| Constant '=' expression #constantAssignment
;
functionCall
: Print '(' expression ')' #printFunctionCall
| Check '(' expression ')' #checkFunctionCall
| Size '(' expression ')' #sizeFunctionCall
| ConsoleEx '(' exprList ')' #consoleExFuntionCall
| Execute '(' exprList ')' #executeFuntionCall
| Player '(' ')' #playerFunctionCall
| Rand '(' exprList ')' #randFunctionCall
| Round '(' expression ')' #roundFunctionCall
| Floor '(' expression ')' #floorFunctionCall
| Ceil '(' expression ')' #ceilFunctionCall
;
ifStatement
: ifStat elseIfStat* elseStat? End
;
ifStat
: If expression Do block
;
elseIfStat
: Else If expression Do block
;
elseStat
: Else Do block
;
forStatement
: For Variable '=' expression To expression Do block End
;
whileStatement
: While expression Do block End
;
exprList
: expression (',' expression)*
;
expression
: '-' expression #unaryMinusExpression
| '!' expression #notExpression
| expression '^' expression #powerExpression
| expression '*' expression #multiplyExpression
| expression '/' expression #divideExpression
| expression '%' expression #modulusExpression
| expression '+' expression #addExpression
| expression '-' expression #subtractExpression
| expression '>=' expression #gtEqExpression
| expression '<=' expression #ltEqExpression
| expression '>' expression #gtExpression
| expression '<' expression #ltExpression
| expression '==' expression #eqExpression
| expression '!=' expression #notEqExpression
| expression '&&' expression #andExpression
| expression '||' expression #orExpression
| expression '?' expression ':' expression #ternaryExpression
| expression In expression #inExpression
| Number #numberExpression
| Bool #boolExpression
| Null #nullExpression
| functionCall #functionCallExpression
| Variable index? #variableExpression
| Constant index? #constantExpression
| Special index? #specialExpression
| String #stringExpression
| list index? #listExpression
| '(' expression ')' #expressionExpression
;
list
: '[' exprList? ']'
;
index
: '[' expression ']'
;
Print : 'print';
Check : 'perm';
Size : 'size';
Player : 'player';
Rand : 'rand';
Round : 'round';
Floor : 'floor';
Ceil : 'ceil';
Execute : 'ex';
ConsoleEx : 'qx';
If : 'if';
Else : 'else';
For : 'for';
While : 'while';
To : 'to';
Do : 'do';
End : 'end';
In : 'in';
Null : 'null';
Or : '||';
And : '&&';
Equals : '==';
NEquals : '!=';
GTEquals : '>=';
LTEquals : '<=';
Pow : '^';
Excl : '!';
GT : '>';
LT : '<';
Add : '+';
Subtract : '-';
Multiply : '*';
Divide : '/';
Modulus : '%';
OBrace : '{';
CBrace : '}';
OBracket : '[';
CBracket : ']';
OParen : '(';
CParen : ')';
SColon : ';';
Assign : '=';
Comma : ',';
QMark : '?';
Colon : ':';
Bool
: 'true'
| 'false'
;
Number
: Int ('.' Digit*)?
;
String
: ['] (~['\r\n] | '\\\\' | '\\\'')* [']
;
Variable
: [a-z] [a-zA-Z_0-9]*
;
Constant
: [A-Z][a-zA-Z_0-9]*
;
Special
: '_'[a-zA-Z_0-9]+
;
Comment
: ('//' ~[\r\n]* | '/*' .*? '*/') -> skip
;
Space
: [ \t\r\n\u000C] -> skip
;
fragment Int
: [1-9] Digit*
| '0'
;
fragment Digit
: [0-9]
; | 4,596 | ANTLR | .g4 | 167 | 24.131737 | 70 | 0.488642 | Zerthick/CommandSkript | 0 | 0 | 0 | GPL-2.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | f04bd989c1fd89bfb81640ef0cb32207a3c829c16fafe47b6668b466e5416493 | false | false | false | false |
185 | pascal.g4 | matnut2_AutomataLab2/pascal.g4 | grammar pascal;
start : 'program' ID ';' 'var' decl_list main_code EOF ;
decl_list : decl | decl decl_list ;
decl : var_list ':' 'integer' ';' ;
var_list : ID | ID ',' var_list ;
main_code : code_block '.' ;
code_block: 'begin' st_list 'end' ;
st_list : statement | statement ';' st_list ;
statement : open_stat | close_stat ;
open_stat : o_branch;
close_stat: | assign | code_block | c_branch | in | out | repeat ;
assign : ID ':=' expr ;
o_branch : 'if' bool_expr 'then' open_stat | 'if' bool_expr 'then' close_stat 'else' open_stat ;
c_branch : 'if' bool_expr 'then' close_stat | 'if' bool_expr 'then' close_stat 'else' close_stat ;
in : 'readln' '(' ID ')' ;
out : 'writeln' '(' expr ')' ;
repeat : 'repeat' st_list 'until' bool_expr ;
expr : arith_expr | bool_expr | STRING ;
arith_expr: sum_expr ;
sum_expr : prod_expr | prod_expr ('+' | '-') sum_expr;
prod_expr : sign_val | sign_val ('*' | '/' | '%') prod_expr ;
sign_val : arith_val | ('+' | '-') sign_val;
arith_val : NUMBER | ID | '(' arith_expr ')';
bool_expr : or_expr ;
or_expr : and_expr | and_expr 'or' or_expr ;
and_expr : not_expr | not_expr 'and' and_expr ;
not_expr : bool_value | 'not' bool_value ;
bool_value: relation | '(' bool_expr ')' ;
relation : arith_expr LT arith_expr | arith_expr LEQ arith_expr | arith_expr EQ arith_expr
| arith_expr NEQ arith_expr | arith_expr GEQ arith_expr | arith_expr GT arith_expr ;
EQ : '=' ;
LT : '<' ;
LEQ : '<=' ;
GT : '>' ;
GEQ : '>=' ;
NEQ : '<>' ;
ID : [a-z]+ ;
NUMBER : [0-9]+ ;
R_COMMENT : '(*' .*? '*)' -> skip ; // .*? matches anything until the first */
C_COMMENT : '{' .*? '}' -> skip ; // .*? matches anything until the first }
LINE_COMMENT : '//' ~[\r\n]* -> skip ; // ~[\r\n]* matches anything but \r and \n
STRING : '\'' (~['])* '\'' ;
WS : [ \n\t\r]+ -> skip;
ErrorChar : . ; | 1,944 | ANTLR | .g4 | 44 | 42.522727 | 99 | 0.552072 | matnut2/AutomataLab2 | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 89e3f3da11606e4738fe63f7f0b25f537b796e4a3978a82868e475ab8c497378 | true | false | false | false |
186 | ElmerSolver.g4 | AltElmer_ElmerSolverParser/ElmerSolver.g4 | grammar ElmerSolver;
// options { language = Python3; }
// Parser Rules
statement: EndOfStatment;
statement_list: statement+;
// section: SectionName statement_list End;
section:
'Header' statement_list End
| 'Simulation' statement_list End
| 'Constants' statement_list End
| 'Body ' Integer statement_list End
| 'Material ' Integer statement_list End
| 'Body Force ' Integer statement_list End
| 'Equation ' Integer statement_list End
| 'Solver ' Integer statement_list End
| 'Boundary Condition ' Integer statement_list End
| 'Initial Condition ' Integer statement_list End
| 'Component' Integer statement_list End;
sections: section+ EOF;
// Lexer Rules
fragment DIGIT: [0-9];
Integer: DIGIT+;
Float:
[+-]? (DIGIT+ ([.]DIGIT*)? | [.]DIGIT+) ([Ee][+-]? DIGIT+)?;
End: 'End';
// statementEnd: ';' NewLine*;
NewLine: ('\r'? '\n' | '\n' | '\r') -> skip;
EndOfStatment: ';' | NewLine;
LineJoining:
'\\' WhiteSpace? ('\r'? '\n' | '\r' | '\f') -> skip;
WhiteSpace: [ \t\r\n]+ -> skip;
LineComment: '#' ~( '\r' | '\n')* -> skip;
| 1,055 | ANTLR | .g4 | 32 | 31 | 61 | 0.671642 | AltElmer/ElmerSolverParser | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 01e8de2c3ab4f761f01eb977337587e643191645b3ee3023a06c2a557c16eacf | false | false | false | false |
187 | qLua.g4 | DasDarki_qLua/assets/qLua.g4 | /*
qLua grammer based on Lua grammer by the following authors:
BSD License
Copyright (c) 2013, Kazunori Sakamoto
Copyright (c) 2016, Alexander Alexeev
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the NAME of Rainer Schuster nor the NAMEs of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This grammar file derived from:
Luau 0.537 Grammar Documentation
https://github.com/Roblox/luau/blob/0.537/docs/_pages/grammar.md
Lua 5.4 Reference Manual
http://www.lua.org/manual/5.4/manual.html
Lua 5.3 Reference Manual
http://www.lua.org/manual/5.3/manual.html
Lua 5.2 Reference Manual
http://www.lua.org/manual/5.2/manual.html
Lua 5.1 grammar written by Nicolai Mainiero
http://www.antlr3.org/grammar/1178608849736/Lua.g
Tested by Kazunori Sakamoto with Test suite for Lua 5.2 (http://www.lua.org/tests/5.2/)
Tested by Alexander Alexeev with Test suite for Lua 5.3 http://www.lua.org/tests/lua-5.3.2-tests.tar.gz
Tested by Matt Hargett with:
- Test suite for Lua 5.4.4: http://www.lua.org/tests/lua-5.4.4-tests.tar.gz
- Test suite for Selene Lua lint tool v0.20.0: https://github.com/Kampfkarren/selene/tree/0.20.0/selene-lib/tests
- Test suite for full-moon Lua parsing library v0.15.1: https://github.com/Kampfkarren/full-moon/tree/main/full-moon/tests
- Test suite for IntelliJ-Luanalysis IDE plug-in v1.3.0: https://github.com/Benjamin-Dobell/IntelliJ-Luanalysis/tree/v1.3.0/src/test
- Test suite for StyLua formatting tool v.14.1: https://github.com/JohnnyMorganz/StyLua/tree/v0.14.1/tests
- Entire codebase for luvit: https://github.com/luvit/luvit/
- Entire codebase for lit: https://github.com/luvit/lit/
- Entire codebase and test suite for neovim v0.7.2: https://github.com/neovim/neovim/tree/v0.7.2
- Entire codebase for World of Warcraft Interface: https://github.com/tomrus88/BlizzardInterfaceCode
- Benchmarks and conformance test suite for Luau 0.537: https://github.com/Roblox/luau/tree/0.537
*/
grammar qLua;
chunk
: block EOF
;
block
: stat* laststat?
;
stat
: ';'
| topLevelStat
| functioncall
| label
| 'break'
| 'goto' NAME
| 'do' block 'end'
| 'while' exp 'do' block 'end'
| 'repeat' block 'until' exp
| 'if' exp 'then' block ('elseif' exp 'then' block)* ('else' block)? 'end'
| 'for' NAME '=' exp ',' exp (',' exp)? 'do' block 'end'
| 'for' namelist 'in' explist 'do' block 'end'
;
topLevelStat
: annotationMark* varlist '=' explist
| enum
| annotationMark* class
| interface
| annotation
| annotationMark* 'function' funcname funcbody
| annotationMark* 'local' 'function' NAME funcbody
| annotationMark* 'local' attnamelist ('=' explist)?
;
attnamelist
: optTypedName attrib (',' optTypedName attrib)*
;
attrib
: ('<' NAME '>')?
;
laststat
: 'return' explist? | 'break' | 'continue' ';'?
;
label
: '::' NAME '::'
;
funcname
: NAME ('.' NAME)* (':' NAME)?
;
varlist
: var (',' var)*
;
namelist
: optTypedName (',' optTypedName)*
;
explist
: (exp ',')* exp
;
exp
: 'nil' | 'false' | 'true'
| number
| string
| '...'
| functiondef
| prefixexp
| tableconstructor
| <assoc=right> exp operatorPower exp
| operatorUnary exp
| exp operatorMulDivMod exp
| exp operatorAddSub exp
| <assoc=right> exp operatorStrcat exp
| exp operatorComparison exp
| exp operatorAnd exp
| exp operatorOr exp
| exp operatorBitwise exp
| exp 'as' NAME
| NAME
;
prefixexp
: varOrExp nameAndArgs*
;
functioncall
: varOrExp nameAndArgs+
;
varOrExp
: var | '(' exp ')'
;
var
: (NAME | '(' exp ')' varSuffix) varSuffix*
;
varSuffix
: nameAndArgs* ('[' exp ']' | '.' NAME)
;
nameAndArgs
: (':' NAME)? args
;
args
: '(' explist? ')' | tableconstructor | string
;
functiondef
: 'function' funcbody
;
funcbody
: genericDeclaration? '(' parlist? ')' typeDeclaration? block 'end'
;
funcbodyWithoutGeneric
: '(' parlist? ')' typeDeclaration? block 'end'
;
parlist
: namelist (',' '...')? | '...'
;
tableconstructor
: '{' fieldlist? '}'
;
fieldlist
: field (fieldsep field)* fieldsep?
;
field
: '[' exp ']' '=' exp | NAME '=' exp | exp
;
fieldsep
: ',' | ';'
;
operatorOr
: 'or' | '||';
operatorAnd
: 'and' | '&&';
operatorComparison
: '<' | '>' | '<=' | '>=' | '~=' | '==' | '!=' | '===' | '!==' | '~==' | 'is' | 'is not' | 'instanceof' | 'not instanceof';
operatorStrcat
: '..'
| '+';
operatorAddSub
: '+' | '-';
operatorMulDivMod
: '*' | '/' | '%' | '//';
operatorBitwise
: '&' | '|' | '~' | '<<' | '>>';
operatorUnary
: 'not' | '#' | '-' | '~' | '!';
operatorPower
: '^';
optTypedName
: NAME typeDeclaration?
;
// ----------------------- CUSTOM qLua additions -----------------------
const
: 'nil' | 'false' | 'true'
| number
| string
| tableconstructor
;
constlist
: const (',' const)*
;
// annotation definition
annotation
: 'annotation' NAME '(' namelist? ')' block 'end'
;
// annoatation marking
annotationMark
: '@' NAME ('(' constlist? ')')?
;
// override operators or even cast operators
validOperators
: operatorAddSub | operatorMulDivMod | operatorPower | operatorUnary | operatorStrcat
| '#' | 'len' | '==' | '<=' | '<' | 'newindex' | '[]=' | 'index' | '[]'
| 'as' NAME
;
operatorOverload
: 'operator' validOperators funcbodyWithoutGeneric
;
// class like class A extends B end or class A implements B, C end
class
: 'class' NAME genericDeclaration? ('extends' NAME)? ('implements' NAME (',' NAME)*)? classBlock 'end'
;
classMember
: topLevelStat
| operatorOverload
;
classBlock
: classMember*
;
// interface like interface A extends B, C end
interface
: 'interface' NAME genericDeclaration? ('extends' NAME (',' NAME)*)? interfaceBlock 'end'
;
interfaceBlock
: interfaceBlockStat*
;
interfaceBlockStat
: 'function' NAME genericDeclaration? '(' parlist? ')' typeDeclaration? ';'?
| NAME typeDeclaration? ';'?
;
// enum like enum A, B, C, D end or with value enum A = 1, B = 2, C = 3, D = 4 end or with complex value enum A = {a = 1, b = 2}, B = {a = 3, b = 4} end
enum
: 'enum' enumFields 'end'
;
enumFields
: enumField (',' enumField)*
;
enumField
: NAME ('=' exp)?
;
typeDeclaration
: ':' typeUnion
;
typeUnion
: type ('|' type)*
;
// type e.g. number, {number, string}, {number: string}, number[]
type
: typeBasic | typeTable | typeArray | typeFunction
;
// basic type e.g. number, string, boolean, nil
typeBasic
: 'number' | 'string' | 'boolean' | 'nil' | 'any' | 'void' | NAME
;
// table type e.g. {number, string}, {number: string}
typeTable
: '{' typeTableFields? '}'
;
// table fields e.g. number, string, number: string
typeTableFields
: typeTableField (',' typeTableField)*
;
// table field e.g. number, string, number: string
typeTableField
: typeTableFieldBasic | typeTableFieldKeyValue
;
// basic table field e.g. number, string
typeTableFieldBasic
: type
;
// key-value table field e.g. number: string
typeTableFieldKeyValue
: type ':' type
;
// array type e.g. number[]
typeArray
: typeBasic '[' ']'
;
// function type e.g. (number, string) -> number | (number) -> number | () -> number | (number) -> () | () -> ()
typeFunction
: '(' typeFunctionArgs? ')' '->' typeFunctionReturn
;
// function arguments e.g. number, string
typeFunctionArgs
: typeFunctionArg (',' typeFunctionArg)*
;
// function argument e.g. number, string
typeFunctionArg
: typeUnion
;
// function return type e.g. number | ()
typeFunctionReturn
: typeUnion | '()' | 'void'
;
genericDeclaration
: '<' genericDeclarationFields '>'
;
genericDeclarationFields
: genericDeclarationField (',' genericDeclarationField)*
;
genericDeclarationField
: NAME
| NAME '=' type
| NAME 'extends' type
| NAME 'extends' type '=' type
| NAME 'implements' type
| NAME 'implements' type '=' type
;
// ----------------------- END CUSTOM qLua additions -----------------------
number
: INT | HEX | FLOAT | HEX_FLOAT
;
string
: NORMALSTRING | CHARSTRING | LONGSTRING
;
// LEXER
NAME
: [a-zA-Z_][a-zA-Z_0-9]*
;
NORMALSTRING
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
;
CHARSTRING
: '\'' ( EscapeSequence | ~('\''|'\\') )* '\''
;
LONGSTRING
: '[' NESTED_STR ']'
;
fragment
NESTED_STR
: '=' NESTED_STR '='
| '[' .*? ']'
;
INT
: Digit+
;
HEX
: '0' [xX] HexDigit+
;
FLOAT
: Digit+ '.' Digit* ExponentPart?
| '.' Digit+ ExponentPart?
| Digit+ ExponentPart
;
HEX_FLOAT
: '0' [xX] HexDigit+ '.' HexDigit* HexExponentPart?
| '0' [xX] '.' HexDigit+ HexExponentPart?
| '0' [xX] HexDigit+ HexExponentPart
;
fragment
ExponentPart
: [eE] [+-]? Digit+
;
fragment
HexExponentPart
: [pP] [+-]? Digit+
;
fragment
EscapeSequence
: '\\' [abfnrtvz"'|$#\\] // World of Warcraft Lua additionally escapes |$#
| '\\' '\r'? '\n'
| DecimalEscape
| HexEscape
| UtfEscape
;
fragment
DecimalEscape
: '\\' Digit
| '\\' Digit Digit
| '\\' [0-2] Digit Digit
;
fragment
HexEscape
: '\\' 'x' HexDigit HexDigit
;
fragment
UtfEscape
: '\\' 'u{' HexDigit+ '}'
;
fragment
Digit
: [0-9]
;
fragment
HexDigit
: [0-9a-fA-F]
;
fragment
SingleLineInputCharacter
: ~[\r\n\u0085\u2028\u2029]
;
COMMENT
: '--[' NESTED_STR ']' -> channel(HIDDEN)
;
LINE_COMMENT
: '--' SingleLineInputCharacter* -> channel(HIDDEN)
;
WS
: [ \t\u000C\r\n]+ -> skip
;
SHEBANG
: '#' '!' SingleLineInputCharacter* -> channel(HIDDEN)
; | 11,867 | ANTLR | .g4 | 417 | 23.501199 | 152 | 0.641042 | DasDarki/qLua | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | a0d12552bb8a903701cac7b85cabc9eeab583305235606efd6d6301382badce0 | false | false | false | false |
188 | ANTLRv4Lexer.g4 | babeloff_boot-antlr4-parser/src_antlr4/ANTLRv4Lexer.g4 | /*
* [The "BSD license"]
* Copyright (c) 2012-2015 Terence Parr
* Copyright (c) 2012-2015 Sam Harwell
* Copyright (c) 2015 Gerald Rosenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* A grammar for ANTLR v4 implemented using v4 syntax
*
* Modified 2015.06.16 gbr
* -- update for compatibility with Antlr v4.5
*/
lexer grammar ANTLRv4Lexer;
options
{ superClass = 'LexerAdaptor'; }
import LexBasic;
// Standard set of fragments
tokens
{ TOKEN_REF , RULE_REF , LEXER_CHAR_SET }
channels
{ OFF_CHANNEL }
// ======================================================
// Lexer specification
//
// -------------------------
// Comments
DOC_COMMENT
: DocComment
;
BLOCK_COMMENT
: BlockComment -> channel (OFF_CHANNEL)
;
LINE_COMMENT
: LineComment -> channel (OFF_CHANNEL)
;
// -------------------------
// Integer
//
INT
: DecimalNumeral
;
// -------------------------
// Literal string
//
// ANTLR makes no distinction between a single character literal and a
// multi-character string. All literals are single quote delimited and
// may contain unicode escape sequences of the form \uxxxx, where x
// is a valid hexadecimal number (per Unicode standard).
STRING_LITERAL
: SQuoteLiteral
;
UNTERMINATED_STRING_LITERAL
: USQuoteLiteral
;
// -------------------------
// Arguments
//
// Certain argument lists, such as those specifying call parameters
// to a rule invocation, or input parameters to a rule specification
// are contained within square brackets.
BEGIN_ARGUMENT
: LBrack{ handleBeginArgument(); };
// -------------------------
// Actions
BEGIN_ACTION
: LBrace -> pushMode (Action)
;
// -------------------------
// Keywords
//
// Keywords may not be used as labels for rules or in any other context where
// they would be ambiguous with the keyword vs some other identifier. OPTIONS,
// TOKENS, & CHANNELS blocks are handled idiomatically in dedicated lexical modes.
OPTIONS
: 'options' -> pushMode (Options)
;
TOKENS
: 'tokens' -> pushMode (Tokens)
;
CHANNELS
: 'channels' -> pushMode (Channels)
;
IMPORT
: 'import'
;
FRAGMENT
: 'fragment'
;
LEXER
: 'lexer'
;
PARSER
: 'parser'
;
GRAMMAR
: 'grammar'
;
PROTECTED
: 'protected'
;
PUBLIC
: 'public'
;
PRIVATE
: 'private'
;
RETURNS
: 'returns'
;
LOCALS
: 'locals'
;
THROWS
: 'throws'
;
CATCH
: 'catch'
;
FINALLY
: 'finally'
;
MODE
: 'mode'
;
// -------------------------
// Punctuation
COLON
: Colon
;
COLONCOLON
: DColon
;
COMMA
: Comma
;
SEMI
: Semi
;
LPAREN
: LParen
;
RPAREN
: RParen
;
LBRACE
: LBrace
;
RBRACE
: RBrace
;
RARROW
: RArrow
;
LT
: Lt
;
GT
: Gt
;
ASSIGN
: Equal
;
QUESTION
: Question
;
STAR
: Star
;
PLUS_ASSIGN
: PlusAssign
;
PLUS
: Plus
;
OR
: Pipe
;
DOLLAR
: Dollar
;
RANGE
: Range
;
DOT
: Dot
;
AT
: At
;
POUND
: Pound
;
NOT
: Tilde
;
// -------------------------
// Identifiers - allows unicode rule/token names
ID
: Id
;
// -------------------------
// Whitespace
WS
: Ws + -> channel (OFF_CHANNEL)
;
// -------------------------
// Illegal Characters
//
// This is an illegal character trap which is always the last rule in the
// lexer specification. It matches a single character of any value and being
// the last rule in the file will match when no other rule knows what to do
// about the character. It is reported as an error but is not passed on to the
// parser. This means that the parser to deal with the gramamr file anyway
// but we will not try to analyse or code generate from a file with lexical
// errors.
//
// Comment this rule out to allow the error to be propagated to the parser
ERRCHAR
: . -> channel (HIDDEN)
;
// ======================================================
// Lexer modes
// -------------------------
// Arguments
mode Argument;
// E.g., [int x, List<String> a[]]
NESTED_ARGUMENT
: LBrack -> type (ARGUMENT_CONTENT) , pushMode (Argument)
;
ARGUMENT_ESCAPE
: EscAny -> type (ARGUMENT_CONTENT)
;
ARGUMENT_STRING_LITERAL
: DQuoteLiteral -> type (ARGUMENT_CONTENT)
;
ARGUMENT_CHAR_LITERAL
: SQuoteLiteral -> type (ARGUMENT_CONTENT)
;
END_ARGUMENT
: RBrack{ handleEndArgument(); };
// added this to return non-EOF token type here. EOF does something weird
UNTERMINATED_ARGUMENT
: EOF -> popMode
;
ARGUMENT_CONTENT
: .
;
// -------------------------
// Actions
//
// Many language targets use {} as block delimiters and so we
// must recursively match {} delimited blocks to balance the
// braces. Additionally, we must make some assumptions about
// literal string representation in the target language. We assume
// that they are delimited by ' or " and so consume these
// in their own alts so as not to inadvertantly match {}.
mode Action;
NESTED_ACTION
: LBrace -> type (ACTION_CONTENT) , pushMode (Action)
;
ACTION_ESCAPE
: EscAny -> type (ACTION_CONTENT)
;
ACTION_STRING_LITERAL
: DQuoteLiteral -> type (ACTION_CONTENT)
;
ACTION_CHAR_LITERAL
: SQuoteLiteral -> type (ACTION_CONTENT)
;
ACTION_DOC_COMMENT
: DocComment -> type (ACTION_CONTENT)
;
ACTION_BLOCK_COMMENT
: BlockComment -> type (ACTION_CONTENT)
;
ACTION_LINE_COMMENT
: LineComment -> type (ACTION_CONTENT)
;
END_ACTION
: RBrace{ handleEndAction(); };
UNTERMINATED_ACTION
: EOF -> popMode
;
ACTION_CONTENT
: .
;
// -------------------------
mode Options;
OPT_DOC_COMMENT
: DocComment -> type (DOC_COMMENT) , channel (OFF_CHANNEL)
;
OPT_BLOCK_COMMENT
: BlockComment -> type (BLOCK_COMMENT) , channel (OFF_CHANNEL)
;
OPT_LINE_COMMENT
: LineComment -> type (LINE_COMMENT) , channel (OFF_CHANNEL)
;
OPT_LBRACE
: LBrace -> type (LBRACE)
;
OPT_RBRACE
: RBrace -> type (RBRACE) , popMode
;
OPT_ID
: Id -> type (ID)
;
OPT_DOT
: Dot -> type (DOT)
;
OPT_ASSIGN
: Equal -> type (ASSIGN)
;
OPT_STRING_LITERAL
: SQuoteLiteral -> type (STRING_LITERAL)
;
OPT_INT
: Int -> type (INT)
;
OPT_STAR
: Star -> type (STAR)
;
OPT_SEMI
: Semi -> type (SEMI)
;
OPT_WS
: Ws + -> type (WS) , channel (OFF_CHANNEL)
;
// -------------------------
mode Tokens;
TOK_DOC_COMMENT
: DocComment -> type (DOC_COMMENT) , channel (OFF_CHANNEL)
;
TOK_BLOCK_COMMENT
: BlockComment -> type (BLOCK_COMMENT) , channel (OFF_CHANNEL)
;
TOK_LINE_COMMENT
: LineComment -> type (LINE_COMMENT) , channel (OFF_CHANNEL)
;
TOK_LBRACE
: LBrace -> type (LBRACE)
;
TOK_RBRACE
: RBrace -> type (RBRACE) , popMode
;
TOK_ID
: Id -> type (ID)
;
TOK_DOT
: Dot -> type (DOT)
;
TOK_COMMA
: Comma -> type (COMMA)
;
TOK_WS
: Ws + -> type (WS) , channel (OFF_CHANNEL)
;
// -------------------------
mode Channels;
// currently same as Tokens mode; distinguished by keyword
CHN_DOC_COMMENT
: DocComment -> type (DOC_COMMENT) , channel (OFF_CHANNEL)
;
CHN_BLOCK_COMMENT
: BlockComment -> type (BLOCK_COMMENT) , channel (OFF_CHANNEL)
;
CHN_LINE_COMMENT
: LineComment -> type (LINE_COMMENT) , channel (OFF_CHANNEL)
;
CHN_LBRACE
: LBrace -> type (LBRACE)
;
CHN_RBRACE
: RBrace -> type (RBRACE) , popMode
;
CHN_ID
: Id -> type (ID)
;
CHN_DOT
: Dot -> type (DOT)
;
CHN_COMMA
: Comma -> type (COMMA)
;
CHN_WS
: Ws + -> type (WS) , channel (OFF_CHANNEL)
;
// -------------------------
mode LexerCharSet;
LEXER_CHAR_SET_BODY
: (~ [\]\\] | EscAny) + -> more
;
LEXER_CHAR_SET
: RBrack -> popMode
;
UNTERMINATED_CHAR_SET
: EOF -> popMode
;
// ------------------------------------------------------------------------------
// Grammar specific Keywords, Punctuation, etc.
fragment Id
: NameStartChar NameChar*
;
| 9,404 | ANTLR | .g4 | 426 | 19.176056 | 82 | 0.641311 | babeloff/boot-antlr4-parser | 0 | 0 | 1 | EPL-1.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 72940d6fa7d6303160e22dc9d803cb629598d5e209849a21e94cfd8299922b6f | false | false | false | false |
190 | ANTLRv4LiterateParser.g4 | babeloff_boot-antlr4-parser/src_antlr4/ANTLRv4LiterateParser.g4 | parser grammar ANTLRv4LiterateParser;
options
{ tokenVocab = ANTLRv4Lexer; }
import ANTLRv4Parser;
literaryGrammarSpec : (literarySpec | grammarSpec) ;
literarySpec : DOC_COMMENT ; | 187 | ANTLR | .g4 | 6 | 29.166667 | 52 | 0.820225 | babeloff/boot-antlr4-parser | 0 | 0 | 1 | EPL-1.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 537edc4c67149b8a9b3f3296ac9aefb7141c2e7796f82e76e592dd3917aca90f | false | false | false | false |
191 | ANTLRv4Parser.g4 | babeloff_boot-antlr4-parser/src_antlr4/ANTLRv4Parser.g4 | /*
* [The "BSD license"]
* Copyright (c) 2012-2014 Terence Parr
* Copyright (c) 2012-2014 Sam Harwell
* Copyright (c) 2015 Gerald Rosenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* A grammar for ANTLR v4 written in ANTLR v4.
*
* Modified 2015.06.16 gbr
* -- update for compatibility with Antlr v4.5
* -- add mode for channels
* -- moved members to LexerAdaptor
* -- move fragments to imports
*/
parser grammar ANTLRv4Parser;
options
{ tokenVocab = ANTLRv4Lexer; }
// The main entry point for parsing a v4 grammar.
grammarSpec
: DOC_COMMENT* grammarType identifier SEMI prequelConstruct* rules modeSpec* EOF
;
grammarType
: (LEXER GRAMMAR | PARSER GRAMMAR | GRAMMAR)
;
// This is the list of all constructs that can be declared before
// the set of rules that compose the grammar, and is invoked 0..n
// times by the grammarPrequel rule.
prequelConstruct
: optionsSpec
| delegateGrammars
| tokensSpec
| channelsSpec
| action
;
// ------------
// Options - things that affect analysis and/or code generation
optionsSpec
: OPTIONS LBRACE (option SEMI)* RBRACE
;
option
: identifier ASSIGN optionValue
;
optionValue
: identifier (DOT identifier)*
| STRING_LITERAL
| actionBlock
| INT
;
// ------------
// Delegates
delegateGrammars
: IMPORT delegateGrammar (COMMA delegateGrammar)* SEMI
;
delegateGrammar
: identifier ASSIGN identifier
| identifier
;
// ------------
// Tokens & Channels
tokensSpec
: TOKENS LBRACE idList? RBRACE
;
channelsSpec
: CHANNELS LBRACE idList? RBRACE
;
idList
: identifier (COMMA identifier)* COMMA?
;
// Match stuff like @parser::members {int i;}
action
: AT (actionScopeName COLONCOLON)? identifier actionBlock
;
// Scope names could collide with keywords; allow them as ids for action scopes
actionScopeName
: identifier
| LEXER
| PARSER
;
actionBlock
: BEGIN_ACTION ACTION_CONTENT* END_ACTION
;
argActionBlock
: BEGIN_ARGUMENT ARGUMENT_CONTENT* END_ARGUMENT
;
modeSpec
: MODE identifier SEMI lexerRuleSpec*
;
rules
: ruleSpec*
;
ruleSpec
: parserRuleSpec
| lexerRuleSpec
;
parserRuleSpec
: DOC_COMMENT* ruleModifiers? RULE_REF argActionBlock? ruleReturns? throwsSpec? localsSpec? rulePrequel* COLON ruleBlock SEMI exceptionGroup
;
exceptionGroup
: exceptionHandler* finallyClause?
;
exceptionHandler
: CATCH argActionBlock actionBlock
;
finallyClause
: FINALLY actionBlock
;
rulePrequel
: optionsSpec
| ruleAction
;
ruleReturns
: RETURNS argActionBlock
;
// --------------
// Exception spec
throwsSpec
: THROWS identifier (COMMA identifier)*
;
localsSpec
: LOCALS argActionBlock
;
/** Match stuff like @init {int i;} */
ruleAction
: AT identifier actionBlock
;
ruleModifiers
: ruleModifier +
;
// An individual access modifier for a rule. The 'fragment' modifier
// is an internal indication for lexer rules that they do not match
// from the input but are like subroutines for other lexer rules to
// reuse for certain lexical patterns. The other modifiers are passed
// to the code generation templates and may be ignored by the template
// if they are of no use in that language.
ruleModifier
: PUBLIC
| PRIVATE
| PROTECTED
| FRAGMENT
;
ruleBlock
: ruleAltList
;
ruleAltList
: labeledAlt (OR labeledAlt)*
;
labeledAlt
: alternative (POUND identifier)?
;
// --------------------
// Lexer rules
lexerRuleSpec
: DOC_COMMENT* FRAGMENT? TOKEN_REF COLON lexerRuleBlock SEMI
;
lexerRuleBlock
: lexerAltList
;
lexerAltList
: lexerAlt (OR lexerAlt)*
;
lexerAlt
: lexerElements lexerCommands?
|
// explicitly allow empty alts
;
lexerElements
: lexerElement +
;
lexerElement
: labeledLexerElement ebnfSuffix?
| lexerAtom ebnfSuffix?
| lexerBlock ebnfSuffix?
| actionBlock QUESTION?
;
// but preds can be anywhere
labeledLexerElement
: identifier (ASSIGN | PLUS_ASSIGN) (lexerAtom | lexerBlock)
;
lexerBlock
: LPAREN lexerAltList RPAREN
;
// E.g., channel(HIDDEN), skip, more, mode(INSIDE), push(INSIDE), pop
lexerCommands
: RARROW lexerCommand (COMMA lexerCommand)*
;
lexerCommand
: lexerCommandName LPAREN lexerCommandExpr RPAREN
| lexerCommandName
;
lexerCommandName
: identifier
| MODE
;
lexerCommandExpr
: identifier
| INT
;
// --------------------
// Rule Alts
altList
: alternative (OR alternative)*
;
alternative
: elementOptions? element +
|
// explicitly allow empty alts
;
element
: labeledElement (ebnfSuffix |)
| atom (ebnfSuffix |)
| ebnf
| actionBlock QUESTION?
;
labeledElement
: identifier (ASSIGN | PLUS_ASSIGN) (atom | block)
;
// --------------------
// EBNF and blocks
ebnf
: block blockSuffix?
;
blockSuffix
: ebnfSuffix
;
ebnfSuffix
: QUESTION QUESTION?
| STAR QUESTION?
| PLUS QUESTION?
;
lexerAtom
: characterRange
| terminal
| notSet
| LEXER_CHAR_SET
| DOT elementOptions?
;
atom
: terminal
| ruleref
| notSet
| DOT elementOptions?
;
// --------------------
// Inverted element set
notSet
: NOT setElement
| NOT blockSet
;
blockSet
: LPAREN setElement (OR setElement)* RPAREN
;
setElement
: TOKEN_REF elementOptions?
| STRING_LITERAL elementOptions?
| characterRange
| LEXER_CHAR_SET
;
// -------------
// Grammar Block
block
: LPAREN (optionsSpec? ruleAction* COLON)? altList RPAREN
;
// ----------------
// Parser rule ref
ruleref
: RULE_REF argActionBlock? elementOptions?
;
// ---------------
// Character Range
characterRange
: STRING_LITERAL RANGE STRING_LITERAL
;
terminal
: TOKEN_REF elementOptions?
| STRING_LITERAL elementOptions?
;
// Terminals may be adorned with certain options when
// reference in the grammar: TOK<,,,>
elementOptions
: LT elementOption (COMMA elementOption)* GT
;
elementOption
: identifier
| identifier ASSIGN (identifier | STRING_LITERAL)
;
identifier
: RULE_REF
| TOKEN_REF
;
| 7,565 | ANTLR | .g4 | 313 | 21.207668 | 143 | 0.717546 | babeloff/boot-antlr4-parser | 0 | 0 | 1 | EPL-1.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | e98e3c0f7d4de265ad82b8254aa1fd33ed74cab0080105c72c5a448c928eeb86 | true | true | false | false |
192 | BatteryManagementBoard-In3_Cu(GND).g4 | Eldalote_Divelamp/KiCadProject/BatteryManagementBoard/Fab/BatteryManagementBoard-In3_Cu(GND).g4 | %TF.GenerationSoftware,KiCad,Pcbnew,(6.0.9)*%
%TF.CreationDate,2023-02-03T11:40:43+01:00*%
%TF.ProjectId,BatteryManagementBoard,42617474-6572-4794-9d61-6e6167656d65,rev?*%
%TF.SameCoordinates,Original*%
%TF.FileFunction,Copper,L4,Inr*%
%TF.FilePolarity,Positive*%
%FSLAX46Y46*%
G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)*
G04 Created by KiCad (PCBNEW (6.0.9)) date 2023-02-03 11:40:43*
%MOMM*%
%LPD*%
G01*
G04 APERTURE LIST*
G04 Aperture macros list*
%AMRoundRect*
0 Rectangle with rounded corners*
0 $1 Rounding radius*
0 $2 $3 $4 $5 $6 $7 $8 $9 X,Y pos of 4 corners*
0 Add a 4 corners polygon primitive as box body*
4,1,4,$2,$3,$4,$5,$6,$7,$8,$9,$2,$3,0*
0 Add four circle primitives for the rounded corners*
1,1,$1+$1,$2,$3*
1,1,$1+$1,$4,$5*
1,1,$1+$1,$6,$7*
1,1,$1+$1,$8,$9*
0 Add four rect primitives between the rounded corners*
20,1,$1+$1,$2,$3,$4,$5,0*
20,1,$1+$1,$4,$5,$6,$7,0*
20,1,$1+$1,$6,$7,$8,$9,0*
20,1,$1+$1,$8,$9,$2,$3,0*%
G04 Aperture macros list end*
%TA.AperFunction,ComponentPad*%
%ADD10O,1.100000X2.200000*%
%TD*%
%TA.AperFunction,ComponentPad*%
%ADD11R,0.850000X0.850000*%
%TD*%
%TA.AperFunction,ComponentPad*%
%ADD12O,0.850000X0.850000*%
%TD*%
%TA.AperFunction,ComponentPad*%
%ADD13R,1.350000X1.350000*%
%TD*%
%TA.AperFunction,ComponentPad*%
%ADD14O,1.350000X1.350000*%
%TD*%
%TA.AperFunction,ComponentPad*%
%ADD15RoundRect,0.250000X-0.600000X-0.725000X0.600000X-0.725000X0.600000X0.725000X-0.600000X0.725000X0*%
%TD*%
%TA.AperFunction,ComponentPad*%
%ADD16O,1.700000X1.950000*%
%TD*%
%TA.AperFunction,ComponentPad*%
%ADD17C,6.500000*%
%TD*%
%TA.AperFunction,ComponentPad*%
%ADD18R,6.300000X6.000000*%
%TD*%
%TA.AperFunction,ComponentPad*%
%ADD19C,4.000000*%
%TD*%
%TA.AperFunction,ViaPad*%
%ADD20C,0.450000*%
%TD*%
%TA.AperFunction,ViaPad*%
%ADD21C,0.800000*%
%TD*%
%TA.AperFunction,ViaPad*%
%ADD22C,0.500000*%
%TD*%
%TA.AperFunction,ViaPad*%
%ADD23C,0.700000*%
%TD*%
G04 APERTURE END LIST*
D10*
X165150000Y-107600000D03*
X160850000Y-107600000D03*
X165150000Y-112400000D03*
X160850000Y-112400000D03*
D11*
X164850000Y-86550000D03*
D12*
X165850000Y-86550000D03*
D13*
X161700000Y-115600000D03*
D14*
X159700000Y-115600000D03*
D15*
X145000000Y-82525000D03*
D16*
X147500000Y-82525000D03*
X150000000Y-82525000D03*
X152500000Y-82525000D03*
X155000000Y-82525000D03*
D17*
X150600000Y-115500000D03*
D18*
X143400000Y-115500000D03*
D19*
X137817767Y-85732233D03*
X134282233Y-89267767D03*
D20*
X166700000Y-91340000D03*
X155000000Y-86000000D03*
X164700000Y-101600000D03*
X163800000Y-113200000D03*
X162100000Y-112300000D03*
X131000000Y-93000000D03*
X145300000Y-104600000D03*
X165690000Y-95200000D03*
X156998944Y-80997933D03*
X152600000Y-92000000D03*
X163300000Y-93200000D03*
X137100000Y-107300000D03*
X149000000Y-94000000D03*
X132000000Y-94100000D03*
X144860000Y-101500000D03*
X150996922Y-79994855D03*
X147890000Y-100230000D03*
X158991799Y-82990766D03*
X137993844Y-89992789D03*
X143400000Y-105700000D03*
X130700000Y-97400000D03*
X142500000Y-100000000D03*
X166800000Y-105200000D03*
X168460000Y-94160000D03*
X161250000Y-96500000D03*
X137000000Y-83000000D03*
X130500000Y-103600000D03*
X145000000Y-121000000D03*
X144300000Y-109500000D03*
X148995192Y-91994518D03*
X160998966Y-84987667D03*
X162100000Y-106800000D03*
X167700000Y-111800000D03*
X170000000Y-108250000D03*
X145000000Y-96750000D03*
X139600000Y-111500000D03*
X157000000Y-118000000D03*
X164250000Y-116250000D03*
X149000000Y-97700000D03*
X163000000Y-86000000D03*
X156400000Y-95600000D03*
X160998966Y-82989733D03*
X161710000Y-89960000D03*
X135100000Y-101500000D03*
X138400000Y-93300000D03*
X134750000Y-94250000D03*
X147000000Y-96000000D03*
X143000000Y-86000000D03*
X146992833Y-79994855D03*
X169200000Y-105300000D03*
X155800000Y-108200000D03*
X134500000Y-100000000D03*
D21*
X149200000Y-103700000D03*
D20*
X131000000Y-95000000D03*
X143400000Y-103300000D03*
X130500000Y-100100000D03*
X155000000Y-117000000D03*
X157000000Y-117000000D03*
X159000000Y-117000000D03*
X162996900Y-86997933D03*
X138400000Y-92000000D03*
X164410000Y-91980000D03*
X155300000Y-101200000D03*
X164700000Y-98100000D03*
X162999999Y-90998966D03*
X151800000Y-108500000D03*
X164000000Y-99000000D03*
X164700000Y-98900000D03*
X147994855Y-120991778D03*
X161600000Y-87300000D03*
X152440000Y-100200000D03*
X169200000Y-104400000D03*
X154992789Y-79994855D03*
X147330000Y-98410000D03*
X157000000Y-115000000D03*
X133879122Y-109920878D03*
X163800000Y-112300000D03*
X138400000Y-92700000D03*
X129200000Y-106000000D03*
X152994855Y-79994855D03*
X156000000Y-103500000D03*
X145000000Y-86000000D03*
X147700000Y-107400000D03*
X152994855Y-93994855D03*
X143400000Y-99700000D03*
X148998988Y-79994855D03*
X149600000Y-97200000D03*
X129000000Y-95000000D03*
X155300000Y-102000000D03*
X135800000Y-100000000D03*
X141000000Y-80000000D03*
X152000000Y-98040000D03*
X133000000Y-93000000D03*
X151000000Y-94000000D03*
X155300000Y-104600000D03*
X164700000Y-100700000D03*
X135100000Y-98700000D03*
X142994855Y-81994855D03*
X155300000Y-102800000D03*
X152750000Y-109000000D03*
X143400000Y-98800000D03*
X135100000Y-103100000D03*
X155001033Y-110940401D03*
X164700000Y-102500000D03*
X162800000Y-92500000D03*
X131624500Y-100100000D03*
D21*
X150900000Y-103700000D03*
D20*
X159500000Y-96500000D03*
X148400000Y-108500000D03*
X163300000Y-94200000D03*
X154000000Y-121000000D03*
X150200000Y-97700000D03*
X156650878Y-97209122D03*
X143000000Y-84000000D03*
X143400000Y-104900000D03*
X130200000Y-106800000D03*
X155300000Y-103700000D03*
X144994899Y-79994855D03*
X135400000Y-104300000D03*
X162100000Y-113200000D03*
X154988700Y-112999999D03*
X131000000Y-91000000D03*
X135500000Y-106900000D03*
X142500000Y-102000000D03*
X168891670Y-99091392D03*
X161000000Y-81000000D03*
X142500000Y-104000000D03*
X156996900Y-85987667D03*
X135800000Y-98000000D03*
X168700000Y-100000000D03*
X138400000Y-91300000D03*
X162999999Y-88996900D03*
X155300000Y-100300000D03*
X164700000Y-103300000D03*
X133130026Y-110948504D03*
X141000000Y-88000000D03*
X162100000Y-107700000D03*
X146800000Y-107400000D03*
X167370000Y-88560000D03*
X157750000Y-111750000D03*
X151250000Y-110250000D03*
X152000000Y-121000000D03*
X155700000Y-99000000D03*
X166800000Y-104400000D03*
X149000000Y-96000000D03*
X135100000Y-100600000D03*
X156000000Y-101500000D03*
X163850000Y-107650000D03*
X162800000Y-94800000D03*
X143400000Y-101500000D03*
X155000000Y-115000000D03*
X163000000Y-96500000D03*
X147000000Y-94000000D03*
X135100000Y-96700000D03*
X169400000Y-100000000D03*
X164000000Y-101000000D03*
X153000000Y-86000000D03*
X167000000Y-96800000D03*
X149991778Y-120991778D03*
X162996900Y-84987667D03*
X138996922Y-87994855D03*
X161600000Y-88500000D03*
X135000000Y-85000000D03*
X168420000Y-91790000D03*
X150800000Y-108534500D03*
X164700000Y-104100000D03*
X151000000Y-92000000D03*
X143000000Y-88000000D03*
X133900000Y-110800000D03*
X152750000Y-110250000D03*
X158991799Y-80992833D03*
X155000000Y-84000000D03*
X147000000Y-92000000D03*
X147900000Y-111700000D03*
X141000000Y-84000000D03*
X142996965Y-79994855D03*
X143400000Y-100600000D03*
X139110000Y-90010000D03*
X151000000Y-96000000D03*
X152540000Y-88040000D03*
D21*
X149200000Y-101900000D03*
D20*
X134000000Y-86000000D03*
X152900000Y-99500000D03*
X160200000Y-110000000D03*
X153999999Y-87997933D03*
X164700000Y-99800000D03*
X143400000Y-102400000D03*
X139100000Y-93800000D03*
X171500000Y-95500000D03*
X159500000Y-113500000D03*
X162999999Y-82990766D03*
X161600000Y-87900000D03*
X143400000Y-104100000D03*
X141000000Y-86000000D03*
X150124500Y-108500000D03*
X135800000Y-102000000D03*
X135100000Y-99700000D03*
X158988700Y-84987667D03*
X164960000Y-88510000D03*
X159500000Y-112000000D03*
X141000000Y-82000000D03*
X149500000Y-110250000D03*
X165750000Y-96210000D03*
X154250000Y-96000000D03*
X138989733Y-81999999D03*
X156996900Y-83989733D03*
D21*
X150900000Y-101900000D03*
D20*
X146250000Y-98000000D03*
X164000000Y-103000000D03*
X163865000Y-106865000D03*
X144750000Y-100000000D03*
X134600000Y-97300000D03*
X170000000Y-91750000D03*
X147100000Y-109000000D03*
X135100000Y-102300000D03*
X145000000Y-88000000D03*
X135100000Y-97700000D03*
X154000000Y-101800000D03*
X156700000Y-98000000D03*
X156400000Y-96500000D03*
X153191973Y-101429983D03*
X138300000Y-104600000D03*
X139200000Y-104600000D03*
X152825000Y-100775000D03*
X152600000Y-106000000D03*
X153206233Y-104193767D03*
X152700000Y-107200000D03*
X148500000Y-106200000D03*
X147000000Y-105300000D03*
X149600000Y-99900000D03*
X147100000Y-108300000D03*
X141514502Y-107700000D03*
X131600000Y-98700000D03*
X131700000Y-101300000D03*
X151300000Y-105600000D03*
X132760000Y-102540000D03*
X133600000Y-102500000D03*
D22*
X168700000Y-102600000D03*
D20*
X129050000Y-102540000D03*
X169180000Y-94410000D03*
D23*
X165715688Y-106107186D03*
X165850000Y-105250000D03*
D20*
X168160000Y-93490000D03*
X162994502Y-109275500D03*
X161399832Y-110299832D03*
X164540210Y-109750000D03*
X168220000Y-92550000D03*
X162950000Y-110750000D03*
X154200000Y-107700000D03*
X154044500Y-103800000D03*
X169600000Y-101300000D03*
X164800000Y-92520000D03*
X150500000Y-105800000D03*
X149703061Y-105798166D03*
X168570000Y-100775500D03*
X156500000Y-108200000D03*
X164780000Y-93450000D03*
X169410000Y-98700000D03*
X165120878Y-91864500D03*
X154600000Y-102200000D03*
X165475500Y-98600000D03*
X154600000Y-103000000D03*
X155200000Y-106874500D03*
X130500000Y-101300000D03*
X147900000Y-110900000D03*
X149145936Y-106132031D03*
X130400000Y-98700000D03*
X146800000Y-104000000D03*
X140900000Y-106500000D03*
X145543767Y-101856233D03*
X147400000Y-100800000D03*
X142600000Y-97000000D03*
X148200000Y-98400000D03*
X139100000Y-90700000D03*
X151200000Y-98000000D03*
X161000000Y-89900000D03*
X161600000Y-90700000D03*
X151174500Y-99950000D03*
X166700000Y-94840000D03*
X169530000Y-97500000D03*
X165110000Y-94420000D03*
X130100000Y-107900000D03*
X130100000Y-108800000D03*
%TA.AperFunction,Conductor*%
G36*
X150468558Y-77755489D02*
G01*
X151394462Y-77794295D01*
X151399640Y-77794621D01*
X151861382Y-77833394D01*
X152323121Y-77872168D01*
X152328286Y-77872711D01*
X152502320Y-77894697D01*
X153247694Y-77988859D01*
X153252818Y-77989616D01*
X154166597Y-78144171D01*
X154171699Y-78145144D01*
X154511259Y-78217319D01*
X155078171Y-78337820D01*
X155083185Y-78338996D01*
X155613307Y-78475108D01*
X155980803Y-78569465D01*
X155985805Y-78570861D01*
X156872992Y-78838719D01*
X156877931Y-78840324D01*
X157753105Y-79145091D01*
X157757974Y-79146902D01*
X158619608Y-79488048D01*
X158624395Y-79490060D01*
X159471033Y-79867007D01*
X159475686Y-79869197D01*
X160305786Y-80281262D01*
X160310359Y-80283652D01*
X161122499Y-80730130D01*
X161126970Y-80732713D01*
X161441723Y-80923333D01*
X161919648Y-81212776D01*
X161924034Y-81215559D01*
X162695936Y-81728409D01*
X162700200Y-81731373D01*
X163449924Y-82276080D01*
X163454061Y-82279220D01*
X163884412Y-82620311D01*
X164180346Y-82854866D01*
X164184322Y-82858155D01*
X164700646Y-83303834D01*
X164885847Y-83463695D01*
X164889707Y-83467170D01*
X165565264Y-84101561D01*
X165568975Y-84105195D01*
X166217373Y-84767317D01*
X166220928Y-84771103D01*
X166841027Y-85459792D01*
X166844394Y-85463692D01*
X167266972Y-85974500D01*
X167435140Y-86177780D01*
X167438366Y-86181851D01*
X167942999Y-86846680D01*
X167998653Y-86920002D01*
X168001706Y-86924204D01*
X168530593Y-87685175D01*
X168533467Y-87689500D01*
X168683119Y-87925313D01*
X168997199Y-88420222D01*
X169030044Y-88471978D01*
X169032724Y-88476405D01*
X169496098Y-89278993D01*
X169498576Y-89283500D01*
X169693040Y-89655475D01*
X169927928Y-90104774D01*
X169930238Y-90109426D01*
X170047384Y-90358374D01*
X170323207Y-90944525D01*
X170324830Y-90947975D01*
X170326939Y-90952712D01*
X170670832Y-91770804D01*
X170686055Y-91807017D01*
X170687967Y-91811846D01*
X171010997Y-92680450D01*
X171012705Y-92685355D01*
X171299078Y-93566720D01*
X171300579Y-93571692D01*
X171392652Y-93901459D01*
X171537432Y-94420000D01*
X171549791Y-94464266D01*
X171551078Y-94469275D01*
X171762707Y-95371560D01*
X171763781Y-95376615D01*
X171937433Y-96286931D01*
X171938299Y-96292050D01*
X171967582Y-96490359D01*
X172073676Y-97208825D01*
X172074327Y-97213977D01*
X172171198Y-98135642D01*
X172171632Y-98140818D01*
X172229819Y-99065683D01*
X172230037Y-99070872D01*
X172234744Y-99295565D01*
X172247608Y-99909641D01*
X172249446Y-99997403D01*
X172249446Y-100002578D01*
X172238191Y-100539878D01*
X172230037Y-100929128D01*
X172229819Y-100934317D01*
X172171632Y-101859182D01*
X172171198Y-101864358D01*
X172074327Y-102786023D01*
X172073676Y-102791175D01*
X172053283Y-102929277D01*
X171955675Y-103590281D01*
X171938299Y-103707948D01*
X171937433Y-103713066D01*
X171766403Y-104609641D01*
X171763781Y-104623385D01*
X171762707Y-104628440D01*
X171551805Y-105527625D01*
X171551083Y-105530704D01*
X171549794Y-105535723D01*
X171462872Y-105847042D01*
X171300579Y-106428308D01*
X171299078Y-106433280D01*
X171012705Y-107314645D01*
X171010997Y-107319550D01*
X170775988Y-107951472D01*
X170718785Y-108105288D01*
X170687967Y-108188154D01*
X170686058Y-108192975D01*
X170417877Y-108830955D01*
X170326942Y-109047280D01*
X170324833Y-109052018D01*
X170224207Y-109265859D01*
X169930238Y-109890574D01*
X169927928Y-109895226D01*
X169498576Y-110716500D01*
X169496098Y-110721007D01*
X169034830Y-111519948D01*
X169032734Y-111523579D01*
X169030054Y-111528006D01*
X168856726Y-111801126D01*
X168533467Y-112310500D01*
X168530593Y-112314825D01*
X168001706Y-113075796D01*
X167998658Y-113079991D01*
X167670066Y-113512896D01*
X167438366Y-113818149D01*
X167435140Y-113822220D01*
X167393781Y-113872214D01*
X166844394Y-114536308D01*
X166841027Y-114540208D01*
X166675090Y-114724500D01*
X166220928Y-115228897D01*
X166217373Y-115232683D01*
X165568975Y-115894805D01*
X165565264Y-115898439D01*
X164889707Y-116532830D01*
X164885849Y-116536303D01*
X164184322Y-117141845D01*
X164180346Y-117145134D01*
X163884412Y-117379689D01*
X163454061Y-117720780D01*
X163449924Y-117723920D01*
X162700200Y-118268627D01*
X162695936Y-118271591D01*
X161924034Y-118784441D01*
X161919648Y-118787224D01*
X161441723Y-119076667D01*
X161126970Y-119267287D01*
X161122499Y-119269870D01*
X160310359Y-119716348D01*
X160305786Y-119718738D01*
X159475686Y-120130803D01*
X159471033Y-120132993D01*
X158791525Y-120435529D01*
X158624395Y-120509940D01*
X158619608Y-120511952D01*
X157757974Y-120853098D01*
X157753105Y-120854909D01*
X156877931Y-121159676D01*
X156872992Y-121161281D01*
X155985805Y-121429139D01*
X155980803Y-121430535D01*
X155613307Y-121524892D01*
X155083185Y-121661004D01*
X155078171Y-121662180D01*
X154511259Y-121782681D01*
X154171699Y-121854856D01*
X154166597Y-121855829D01*
X153252818Y-122010384D01*
X153247694Y-122011141D01*
X152502320Y-122105303D01*
X152328286Y-122127289D01*
X152323121Y-122127832D01*
X151861382Y-122166605D01*
X151399640Y-122205379D01*
X151394462Y-122205705D01*
X150468559Y-122244511D01*
X150463367Y-122244620D01*
X149536633Y-122244620D01*
X149531441Y-122244511D01*
X148605538Y-122205705D01*
X148600360Y-122205379D01*
X148138618Y-122166605D01*
X147676879Y-122127832D01*
X147671714Y-122127289D01*
X147497680Y-122105303D01*
X146752306Y-122011141D01*
X146747182Y-122010384D01*
X145833403Y-121855829D01*
X145828301Y-121854856D01*
X145488741Y-121782681D01*
X144921829Y-121662180D01*
X144916815Y-121661004D01*
X144386693Y-121524892D01*
X144019197Y-121430535D01*
X144014195Y-121429139D01*
X143127008Y-121161281D01*
X143122069Y-121159676D01*
X142246895Y-120854909D01*
X142242026Y-120853098D01*
X141380392Y-120511952D01*
X141375605Y-120509940D01*
X141208475Y-120435529D01*
X140528967Y-120132993D01*
X140524314Y-120130803D01*
X139694214Y-119718738D01*
X139689641Y-119716348D01*
X138877501Y-119269870D01*
X138873030Y-119267287D01*
X138558277Y-119076667D01*
X138080352Y-118787224D01*
X138075966Y-118784441D01*
X137677571Y-118519748D01*
X140049500Y-118519748D01*
X140061133Y-118578231D01*
X140105448Y-118644552D01*
X140171769Y-118688867D01*
X140183745Y-118691249D01*
X140183747Y-118691250D01*
X140202326Y-118694945D01*
X140230252Y-118700500D01*
X146569748Y-118700500D01*
X146597674Y-118694945D01*
X146616253Y-118691250D01*
X146616255Y-118691249D01*
X146628231Y-118688867D01*
X146694552Y-118644552D01*
X146738867Y-118578231D01*
X146750500Y-118519748D01*
X146750500Y-116294748D01*
X160824500Y-116294748D01*
X160836133Y-116353231D01*
X160880448Y-116419552D01*
X160946769Y-116463867D01*
X160958745Y-116466249D01*
X160958747Y-116466250D01*
X160977326Y-116469945D01*
X161005252Y-116475500D01*
X162394748Y-116475500D01*
X162422674Y-116469945D01*
X162441253Y-116466250D01*
X162441255Y-116466249D01*
X162453231Y-116463867D01*
X162519552Y-116419552D01*
X162563867Y-116353231D01*
X162575500Y-116294748D01*
X162575500Y-114905252D01*
X162563867Y-114846769D01*
X162519552Y-114780448D01*
X162453231Y-114736133D01*
X162441255Y-114733751D01*
X162441253Y-114733750D01*
X162422674Y-114730055D01*
X162394748Y-114724500D01*
X161005252Y-114724500D01*
X160977326Y-114730055D01*
X160958747Y-114733750D01*
X160958745Y-114733751D01*
X160946769Y-114736133D01*
X160880448Y-114780448D01*
X160836133Y-114846769D01*
X160824500Y-114905252D01*
X160824500Y-116294748D01*
X146750500Y-116294748D01*
X146750500Y-113782990D01*
X162475643Y-113782990D01*
X162477313Y-113791271D01*
X162484529Y-113827059D01*
X162486075Y-113842547D01*
X162484592Y-113850000D01*
X162486975Y-113861980D01*
X162486975Y-113861983D01*
X162487444Y-113864341D01*
X162489046Y-113874643D01*
X162499150Y-113964316D01*
X162537145Y-114072899D01*
X162598350Y-114170305D01*
X162679695Y-114251650D01*
X162777101Y-114312855D01*
X162783670Y-114315154D01*
X162783673Y-114315155D01*
X162879107Y-114348549D01*
X162879110Y-114348550D01*
X162885684Y-114350850D01*
X162892607Y-114351630D01*
X162975357Y-114360954D01*
X162985659Y-114362556D01*
X162988017Y-114363025D01*
X162988020Y-114363025D01*
X163000000Y-114365408D01*
X163011980Y-114363025D01*
X163011983Y-114363025D01*
X163014341Y-114362556D01*
X163024643Y-114360954D01*
X163107393Y-114351630D01*
X163114316Y-114350850D01*
X163120890Y-114348550D01*
X163120893Y-114348549D01*
X163216327Y-114315155D01*
X163216330Y-114315154D01*
X163222899Y-114312855D01*
X163320305Y-114251650D01*
X163401650Y-114170305D01*
X163462855Y-114072899D01*
X163500850Y-113964316D01*
X163510954Y-113874643D01*
X163511332Y-113872214D01*
X163511295Y-113871611D01*
X163511538Y-113869456D01*
X163511539Y-113869451D01*
X163511757Y-113869476D01*
X163512553Y-113864356D01*
X163513024Y-113861989D01*
X163513024Y-113861983D01*
X163513148Y-113861360D01*
X163513913Y-113859236D01*
X163514113Y-113856509D01*
X163515408Y-113850000D01*
X163515154Y-113848726D01*
X163515470Y-113847651D01*
X163515533Y-113847054D01*
X163514811Y-113847001D01*
X163519512Y-113782990D01*
X163524357Y-113717010D01*
X163515471Y-113672940D01*
X163513925Y-113657453D01*
X163515408Y-113650000D01*
X163513025Y-113638020D01*
X163513025Y-113638017D01*
X163512556Y-113635659D01*
X163510954Y-113625357D01*
X163501630Y-113542607D01*
X163500850Y-113535684D01*
X163462855Y-113427101D01*
X163401650Y-113329695D01*
X163320305Y-113248350D01*
X163222899Y-113187145D01*
X163216330Y-113184846D01*
X163216327Y-113184845D01*
X163120893Y-113151451D01*
X163120890Y-113151450D01*
X163114316Y-113149150D01*
X163103077Y-113147884D01*
X163024643Y-113139046D01*
X163014341Y-113137444D01*
X163011983Y-113136975D01*
X163011980Y-113136975D01*
X163000000Y-113134592D01*
X162988020Y-113136975D01*
X162988017Y-113136975D01*
X162985659Y-113137444D01*
X162975357Y-113139046D01*
X162896923Y-113147884D01*
X162885684Y-113149150D01*
X162879110Y-113151450D01*
X162879107Y-113151451D01*
X162783673Y-113184845D01*
X162783670Y-113184846D01*
X162777101Y-113187145D01*
X162679695Y-113248350D01*
X162598350Y-113329695D01*
X162537145Y-113427101D01*
X162499150Y-113535684D01*
X162498370Y-113542607D01*
X162489047Y-113625351D01*
X162488668Y-113627786D01*
X162488705Y-113628389D01*
X162488462Y-113630544D01*
X162488461Y-113630549D01*
X162488243Y-113630524D01*
X162487447Y-113635644D01*
X162486976Y-113638011D01*
X162486976Y-113638016D01*
X162486852Y-113638640D01*
X162486087Y-113640764D01*
X162485887Y-113643491D01*
X162484592Y-113650000D01*
X162484846Y-113651274D01*
X162484530Y-113652349D01*
X162484467Y-113652946D01*
X162485189Y-113652999D01*
X162475643Y-113782990D01*
X146750500Y-113782990D01*
X146750500Y-112991302D01*
X160169500Y-112991302D01*
X160169948Y-112995003D01*
X160179983Y-113077928D01*
X160184289Y-113113514D01*
X160242509Y-113267589D01*
X160335800Y-113403328D01*
X160458777Y-113512896D01*
X160604339Y-113589968D01*
X160764084Y-113630093D01*
X160849672Y-113630541D01*
X160921315Y-113630916D01*
X160921316Y-113630916D01*
X160928789Y-113630955D01*
X160936052Y-113629211D01*
X160936055Y-113629211D01*
X161012570Y-113610841D01*
X161088945Y-113592505D01*
X161235307Y-113516962D01*
X161359424Y-113408688D01*
X161454132Y-113273933D01*
X161513962Y-113120476D01*
X161530500Y-112994854D01*
X161530500Y-112991302D01*
X164469500Y-112991302D01*
X164469948Y-112995003D01*
X164479983Y-113077928D01*
X164484289Y-113113514D01*
X164542509Y-113267589D01*
X164635800Y-113403328D01*
X164758777Y-113512896D01*
X164904339Y-113589968D01*
X165064084Y-113630093D01*
X165149672Y-113630541D01*
X165221315Y-113630916D01*
X165221316Y-113630916D01*
X165228789Y-113630955D01*
X165236052Y-113629211D01*
X165236055Y-113629211D01*
X165312570Y-113610841D01*
X165388945Y-113592505D01*
X165535307Y-113516962D01*
X165659424Y-113408688D01*
X165754132Y-113273933D01*
X165813962Y-113120476D01*
X165830500Y-112994854D01*
X165830500Y-111808698D01*
X165815711Y-111686486D01*
X165757491Y-111532411D01*
X165664200Y-111396672D01*
X165566606Y-111309719D01*
X165546806Y-111292078D01*
X165546805Y-111292077D01*
X165541223Y-111287104D01*
X165395661Y-111210032D01*
X165235916Y-111169907D01*
X165150328Y-111169459D01*
X165078685Y-111169084D01*
X165078684Y-111169084D01*
X165071211Y-111169045D01*
X165063948Y-111170789D01*
X165063945Y-111170789D01*
X164987430Y-111189159D01*
X164911055Y-111207495D01*
X164764693Y-111283038D01*
X164759062Y-111287951D01*
X164759061Y-111287951D01*
X164722308Y-111320013D01*
X164640576Y-111391312D01*
X164545868Y-111526067D01*
X164486038Y-111679524D01*
X164485062Y-111686939D01*
X164471763Y-111787959D01*
X164469500Y-111805146D01*
X164469500Y-112991302D01*
X161530500Y-112991302D01*
X161530500Y-111808698D01*
X161515711Y-111686486D01*
X161457491Y-111532411D01*
X161364200Y-111396672D01*
X161266606Y-111309719D01*
X161246806Y-111292078D01*
X161246805Y-111292077D01*
X161241223Y-111287104D01*
X161095661Y-111210032D01*
X160935916Y-111169907D01*
X160850328Y-111169459D01*
X160778685Y-111169084D01*
X160778684Y-111169084D01*
X160771211Y-111169045D01*
X160763948Y-111170789D01*
X160763945Y-111170789D01*
X160687430Y-111189159D01*
X160611055Y-111207495D01*
X160464693Y-111283038D01*
X160459062Y-111287951D01*
X160459061Y-111287951D01*
X160422308Y-111320013D01*
X160340576Y-111391312D01*
X160245868Y-111526067D01*
X160186038Y-111679524D01*
X160185062Y-111686939D01*
X160171763Y-111787959D01*
X160169500Y-111805146D01*
X160169500Y-112991302D01*
X146750500Y-112991302D01*
X146750500Y-112480252D01*
X146738867Y-112421769D01*
X146694552Y-112355448D01*
X146628231Y-112311133D01*
X146616255Y-112308751D01*
X146616253Y-112308750D01*
X146597674Y-112305055D01*
X146569748Y-112299500D01*
X140230252Y-112299500D01*
X140202326Y-112305055D01*
X140183747Y-112308750D01*
X140183745Y-112308751D01*
X140171769Y-112311133D01*
X140105448Y-112355448D01*
X140061133Y-112421769D01*
X140049500Y-112480252D01*
X140049500Y-118519748D01*
X137677571Y-118519748D01*
X137304064Y-118271591D01*
X137299800Y-118268627D01*
X136550076Y-117723920D01*
X136545939Y-117720780D01*
X136115588Y-117379689D01*
X135819654Y-117145134D01*
X135815678Y-117141845D01*
X135114151Y-116536303D01*
X135110293Y-116532830D01*
X134434736Y-115898439D01*
X134431025Y-115894805D01*
X133782627Y-115232683D01*
X133779072Y-115228897D01*
X133324910Y-114724500D01*
X133158973Y-114540208D01*
X133155606Y-114536308D01*
X132606219Y-113872214D01*
X132564860Y-113822220D01*
X132561634Y-113818149D01*
X132329934Y-113512896D01*
X132001342Y-113079991D01*
X131998294Y-113075796D01*
X131469407Y-112314825D01*
X131466533Y-112310500D01*
X131143274Y-111801126D01*
X130969946Y-111528006D01*
X130967266Y-111523579D01*
X130965170Y-111519948D01*
X130607243Y-110900000D01*
X147469196Y-110900000D01*
X147490281Y-111033126D01*
X147551472Y-111153220D01*
X147646780Y-111248528D01*
X147766874Y-111309719D01*
X147900000Y-111330804D01*
X148033126Y-111309719D01*
X148153220Y-111248528D01*
X148248528Y-111153220D01*
X148309719Y-111033126D01*
X148330804Y-110900000D01*
X148309719Y-110766874D01*
X148301121Y-110750000D01*
X162519196Y-110750000D01*
X162540281Y-110883126D01*
X162601472Y-111003220D01*
X162696780Y-111098528D01*
X162816874Y-111159719D01*
X162950000Y-111180804D01*
X163083126Y-111159719D01*
X163203220Y-111098528D01*
X163298528Y-111003220D01*
X163359719Y-110883126D01*
X163380804Y-110750000D01*
X163359719Y-110616874D01*
X163298528Y-110496780D01*
X163203220Y-110401472D01*
X163083126Y-110340281D01*
X162950000Y-110319196D01*
X162816874Y-110340281D01*
X162696780Y-110401472D01*
X162601472Y-110496780D01*
X162540281Y-110616874D01*
X162519196Y-110750000D01*
X148301121Y-110750000D01*
X148248528Y-110646780D01*
X148153220Y-110551472D01*
X148033126Y-110490281D01*
X147900000Y-110469196D01*
X147766874Y-110490281D01*
X147646780Y-110551472D01*
X147551472Y-110646780D01*
X147490281Y-110766874D01*
X147469196Y-110900000D01*
X130607243Y-110900000D01*
X130503902Y-110721007D01*
X130501424Y-110716500D01*
X130283595Y-110299832D01*
X160969028Y-110299832D01*
X160990113Y-110432958D01*
X161051304Y-110553052D01*
X161146612Y-110648360D01*
X161266706Y-110709551D01*
X161399832Y-110730636D01*
X161532958Y-110709551D01*
X161653052Y-110648360D01*
X161748360Y-110553052D01*
X161809551Y-110432958D01*
X161830636Y-110299832D01*
X161809551Y-110166706D01*
X161748360Y-110046612D01*
X161653052Y-109951304D01*
X161532958Y-109890113D01*
X161399832Y-109869028D01*
X161266706Y-109890113D01*
X161146612Y-109951304D01*
X161051304Y-110046612D01*
X160990113Y-110166706D01*
X160969028Y-110299832D01*
X130283595Y-110299832D01*
X130072072Y-109895226D01*
X130069762Y-109890574D01*
X130003613Y-109750000D01*
X164109406Y-109750000D01*
X164130491Y-109883126D01*
X164191682Y-110003220D01*
X164286990Y-110098528D01*
X164407084Y-110159719D01*
X164540210Y-110180804D01*
X164673336Y-110159719D01*
X164793430Y-110098528D01*
X164888738Y-110003220D01*
X164949929Y-109883126D01*
X164971014Y-109750000D01*
X164949929Y-109616874D01*
X164888738Y-109496780D01*
X164793430Y-109401472D01*
X164673336Y-109340281D01*
X164540210Y-109319196D01*
X164407084Y-109340281D01*
X164286990Y-109401472D01*
X164191682Y-109496780D01*
X164130491Y-109616874D01*
X164109406Y-109750000D01*
X130003613Y-109750000D01*
X129831233Y-109383675D01*
X129820501Y-109314634D01*
X129837835Y-109275500D01*
X162563698Y-109275500D01*
X162584783Y-109408626D01*
X162645974Y-109528720D01*
X162741282Y-109624028D01*
X162861376Y-109685219D01*
X162994502Y-109706304D01*
X163127628Y-109685219D01*
X163247722Y-109624028D01*
X163343030Y-109528720D01*
X163404221Y-109408626D01*
X163425306Y-109275500D01*
X163404221Y-109142374D01*
X163343030Y-109022280D01*
X163247722Y-108926972D01*
X163127628Y-108865781D01*
X162994502Y-108844696D01*
X162861376Y-108865781D01*
X162741282Y-108926972D01*
X162645974Y-109022280D01*
X162584783Y-109142374D01*
X162563698Y-109275500D01*
X129837835Y-109275500D01*
X129848797Y-109250751D01*
X129907140Y-109212308D01*
X129966384Y-109212815D01*
X129966874Y-109209719D01*
X130100000Y-109230804D01*
X130233126Y-109209719D01*
X130353220Y-109148528D01*
X130448528Y-109053220D01*
X130509719Y-108933126D01*
X130530804Y-108800000D01*
X130509719Y-108666874D01*
X130448528Y-108546780D01*
X130353220Y-108451472D01*
X130347790Y-108448705D01*
X130306368Y-108394986D01*
X130300390Y-108325373D01*
X130313778Y-108300000D01*
X146669196Y-108300000D01*
X146690281Y-108433126D01*
X146751472Y-108553220D01*
X146846780Y-108648528D01*
X146966874Y-108709719D01*
X147100000Y-108730804D01*
X147233126Y-108709719D01*
X147353220Y-108648528D01*
X147448528Y-108553220D01*
X147509719Y-108433126D01*
X147530804Y-108300000D01*
X147514966Y-108200000D01*
X156069196Y-108200000D01*
X156090281Y-108333126D01*
X156151472Y-108453220D01*
X156246780Y-108548528D01*
X156366874Y-108609719D01*
X156500000Y-108630804D01*
X156633126Y-108609719D01*
X156753220Y-108548528D01*
X156848528Y-108453220D01*
X156909719Y-108333126D01*
X156930804Y-108200000D01*
X156929426Y-108191302D01*
X160169500Y-108191302D01*
X160169948Y-108195003D01*
X160182654Y-108300000D01*
X160184289Y-108313514D01*
X160242509Y-108467589D01*
X160335800Y-108603328D01*
X160347337Y-108613607D01*
X160429636Y-108686932D01*
X160458777Y-108712896D01*
X160604339Y-108789968D01*
X160764084Y-108830093D01*
X160849672Y-108830541D01*
X160921315Y-108830916D01*
X160921316Y-108830916D01*
X160928789Y-108830955D01*
X160936052Y-108829211D01*
X160936055Y-108829211D01*
X161017568Y-108809641D01*
X161088945Y-108792505D01*
X161235307Y-108716962D01*
X161359424Y-108608688D01*
X161454132Y-108473933D01*
X161463340Y-108450317D01*
X161511246Y-108327442D01*
X161513962Y-108320476D01*
X161530500Y-108194854D01*
X161530500Y-108191302D01*
X164469500Y-108191302D01*
X164469948Y-108195003D01*
X164482654Y-108300000D01*
X164484289Y-108313514D01*
X164542509Y-108467589D01*
X164635800Y-108603328D01*
X164647337Y-108613607D01*
X164729636Y-108686932D01*
X164758777Y-108712896D01*
X164904339Y-108789968D01*
X165064084Y-108830093D01*
X165149672Y-108830541D01*
X165221315Y-108830916D01*
X165221316Y-108830916D01*
X165228789Y-108830955D01*
X165236052Y-108829211D01*
X165236055Y-108829211D01*
X165317568Y-108809641D01*
X165388945Y-108792505D01*
X165535307Y-108716962D01*
X165659424Y-108608688D01*
X165754132Y-108473933D01*
X165763340Y-108450317D01*
X165811246Y-108327442D01*
X165813962Y-108320476D01*
X165830500Y-108194854D01*
X165830500Y-107008698D01*
X165827110Y-106980682D01*
X165816610Y-106893911D01*
X165816609Y-106893907D01*
X165815711Y-106886486D01*
X165807539Y-106864859D01*
X165784405Y-106803635D01*
X165779122Y-106733966D01*
X165812344Y-106672500D01*
X165859959Y-106644873D01*
X165859397Y-106643516D01*
X165972490Y-106596672D01*
X165993313Y-106588047D01*
X166059423Y-106537319D01*
X166101866Y-106504751D01*
X166108309Y-106499807D01*
X166117407Y-106487951D01*
X166191602Y-106391258D01*
X166196549Y-106384811D01*
X166252018Y-106250895D01*
X166270938Y-106107186D01*
X166252018Y-105963477D01*
X166248704Y-105955475D01*
X166199661Y-105837073D01*
X166199659Y-105837070D01*
X166196549Y-105829561D01*
X166191600Y-105823112D01*
X166189422Y-105819339D01*
X166172951Y-105751438D01*
X166195803Y-105685412D01*
X166221322Y-105658965D01*
X166236177Y-105647566D01*
X166236178Y-105647565D01*
X166242621Y-105642621D01*
X166255126Y-105626325D01*
X166325914Y-105534072D01*
X166330861Y-105527625D01*
X166352031Y-105476516D01*
X166383218Y-105401223D01*
X166383219Y-105401221D01*
X166386330Y-105393709D01*
X166405250Y-105250000D01*
X166386330Y-105106291D01*
X166330861Y-104972375D01*
X166242621Y-104857379D01*
X166225870Y-104844525D01*
X166134072Y-104774086D01*
X166127625Y-104769139D01*
X166040681Y-104733126D01*
X166001223Y-104716782D01*
X166001221Y-104716781D01*
X165993709Y-104713670D01*
X165850000Y-104694750D01*
X165706291Y-104713670D01*
X165698779Y-104716781D01*
X165698777Y-104716782D01*
X165659319Y-104733126D01*
X165572375Y-104769139D01*
X165565928Y-104774086D01*
X165474131Y-104844525D01*
X165457379Y-104857379D01*
X165369139Y-104972375D01*
X165313670Y-105106291D01*
X165294750Y-105250000D01*
X165313670Y-105393709D01*
X165316781Y-105401221D01*
X165316782Y-105401223D01*
X165361062Y-105508124D01*
X165369139Y-105527625D01*
X165374086Y-105534072D01*
X165376266Y-105537847D01*
X165392737Y-105605748D01*
X165369885Y-105671774D01*
X165344366Y-105698221D01*
X165334183Y-105706035D01*
X165323067Y-105714565D01*
X165318123Y-105721008D01*
X165302152Y-105741822D01*
X165234827Y-105829561D01*
X165225751Y-105851472D01*
X165183165Y-105954287D01*
X165179358Y-105963477D01*
X165160438Y-106107186D01*
X165161499Y-106115245D01*
X165161499Y-106115246D01*
X165176732Y-106230952D01*
X165165966Y-106299987D01*
X165119586Y-106352243D01*
X165071661Y-106369047D01*
X165071211Y-106369045D01*
X164911055Y-106407495D01*
X164904414Y-106410923D01*
X164904413Y-106410923D01*
X164899362Y-106413530D01*
X164764693Y-106483038D01*
X164640576Y-106591312D01*
X164545868Y-106726067D01*
X164543152Y-106733032D01*
X164543152Y-106733033D01*
X164520832Y-106790281D01*
X164486038Y-106879524D01*
X164469500Y-107005146D01*
X164469500Y-108191302D01*
X161530500Y-108191302D01*
X161530500Y-107008698D01*
X161527110Y-106980682D01*
X161516610Y-106893911D01*
X161516609Y-106893907D01*
X161515711Y-106886486D01*
X161457491Y-106732411D01*
X161364200Y-106596672D01*
X161241223Y-106487104D01*
X161095661Y-106410032D01*
X160935916Y-106369907D01*
X160850328Y-106369459D01*
X160778685Y-106369084D01*
X160778684Y-106369084D01*
X160771211Y-106369045D01*
X160763948Y-106370789D01*
X160763945Y-106370789D01*
X160703708Y-106385251D01*
X160611055Y-106407495D01*
X160604414Y-106410923D01*
X160604413Y-106410923D01*
X160599362Y-106413530D01*
X160464693Y-106483038D01*
X160340576Y-106591312D01*
X160245868Y-106726067D01*
X160243152Y-106733032D01*
X160243152Y-106733033D01*
X160220832Y-106790281D01*
X160186038Y-106879524D01*
X160169500Y-107005146D01*
X160169500Y-108191302D01*
X156929426Y-108191302D01*
X156909719Y-108066874D01*
X156848528Y-107946780D01*
X156753220Y-107851472D01*
X156633126Y-107790281D01*
X156500000Y-107769196D01*
X156366874Y-107790281D01*
X156246780Y-107851472D01*
X156151472Y-107946780D01*
X156090281Y-108066874D01*
X156069196Y-108200000D01*
X147514966Y-108200000D01*
X147509719Y-108166874D01*
X147448528Y-108046780D01*
X147353220Y-107951472D01*
X147233126Y-107890281D01*
X147100000Y-107869196D01*
X146966874Y-107890281D01*
X146846780Y-107951472D01*
X146751472Y-108046780D01*
X146690281Y-108166874D01*
X146669196Y-108300000D01*
X130313778Y-108300000D01*
X130332997Y-108263578D01*
X130346292Y-108252058D01*
X130353220Y-108248528D01*
X130448528Y-108153220D01*
X130509719Y-108033126D01*
X130530804Y-107900000D01*
X130509719Y-107766874D01*
X130475645Y-107700000D01*
X141083698Y-107700000D01*
X141104783Y-107833126D01*
X141165974Y-107953220D01*
X141261282Y-108048528D01*
X141381376Y-108109719D01*
X141514502Y-108130804D01*
X141647628Y-108109719D01*
X141767722Y-108048528D01*
X141863030Y-107953220D01*
X141924221Y-107833126D01*
X141945306Y-107700000D01*
X153769196Y-107700000D01*
X153790281Y-107833126D01*
X153851472Y-107953220D01*
X153946780Y-108048528D01*
X154066874Y-108109719D01*
X154200000Y-108130804D01*
X154333126Y-108109719D01*
X154453220Y-108048528D01*
X154548528Y-107953220D01*
X154609719Y-107833126D01*
X154630804Y-107700000D01*
X154609719Y-107566874D01*
X154548528Y-107446780D01*
X154453220Y-107351472D01*
X154333126Y-107290281D01*
X154200000Y-107269196D01*
X154066874Y-107290281D01*
X153946780Y-107351472D01*
X153851472Y-107446780D01*
X153790281Y-107566874D01*
X153769196Y-107700000D01*
X141945306Y-107700000D01*
X141924221Y-107566874D01*
X141863030Y-107446780D01*
X141767722Y-107351472D01*
X141647628Y-107290281D01*
X141514502Y-107269196D01*
X141381376Y-107290281D01*
X141261282Y-107351472D01*
X141165974Y-107446780D01*
X141104783Y-107566874D01*
X141083698Y-107700000D01*
X130475645Y-107700000D01*
X130448528Y-107646780D01*
X130353220Y-107551472D01*
X130233126Y-107490281D01*
X130100000Y-107469196D01*
X129966874Y-107490281D01*
X129846780Y-107551472D01*
X129751472Y-107646780D01*
X129690281Y-107766874D01*
X129669196Y-107900000D01*
X129690281Y-108033126D01*
X129751472Y-108153220D01*
X129846780Y-108248528D01*
X129852210Y-108251295D01*
X129893632Y-108305014D01*
X129899610Y-108374627D01*
X129867003Y-108436422D01*
X129853708Y-108447942D01*
X129846780Y-108451472D01*
X129751472Y-108546780D01*
X129747042Y-108555475D01*
X129714500Y-108619341D01*
X129666525Y-108670137D01*
X129598704Y-108686932D01*
X129532569Y-108664394D01*
X129489704Y-108611098D01*
X129489125Y-108609719D01*
X129313942Y-108192975D01*
X129312033Y-108188154D01*
X129281216Y-108105288D01*
X129224012Y-107951472D01*
X128989003Y-107319550D01*
X128987295Y-107314645D01*
X128950045Y-107200000D01*
X152269196Y-107200000D01*
X152290281Y-107333126D01*
X152351472Y-107453220D01*
X152446780Y-107548528D01*
X152566874Y-107609719D01*
X152700000Y-107630804D01*
X152833126Y-107609719D01*
X152953220Y-107548528D01*
X153048528Y-107453220D01*
X153109719Y-107333126D01*
X153130804Y-107200000D01*
X153109719Y-107066874D01*
X153048528Y-106946780D01*
X152976248Y-106874500D01*
X154769196Y-106874500D01*
X154790281Y-107007626D01*
X154851472Y-107127720D01*
X154946780Y-107223028D01*
X155066874Y-107284219D01*
X155200000Y-107305304D01*
X155333126Y-107284219D01*
X155453220Y-107223028D01*
X155548528Y-107127720D01*
X155609719Y-107007626D01*
X155630804Y-106874500D01*
X155609719Y-106741374D01*
X155548528Y-106621280D01*
X155453220Y-106525972D01*
X155333126Y-106464781D01*
X155200000Y-106443696D01*
X155066874Y-106464781D01*
X154946780Y-106525972D01*
X154851472Y-106621280D01*
X154790281Y-106741374D01*
X154769196Y-106874500D01*
X152976248Y-106874500D01*
X152953220Y-106851472D01*
X152833126Y-106790281D01*
X152700000Y-106769196D01*
X152566874Y-106790281D01*
X152446780Y-106851472D01*
X152351472Y-106946780D01*
X152290281Y-107066874D01*
X152269196Y-107200000D01*
X128950045Y-107200000D01*
X128722601Y-106500000D01*
X140469196Y-106500000D01*
X140490281Y-106633126D01*
X140551472Y-106753220D01*
X140646780Y-106848528D01*
X140766874Y-106909719D01*
X140900000Y-106930804D01*
X141033126Y-106909719D01*
X141153220Y-106848528D01*
X141248528Y-106753220D01*
X141309719Y-106633126D01*
X141330804Y-106500000D01*
X141309719Y-106366874D01*
X141248528Y-106246780D01*
X141201748Y-106200000D01*
X148069196Y-106200000D01*
X148090281Y-106333126D01*
X148151472Y-106453220D01*
X148246780Y-106548528D01*
X148366874Y-106609719D01*
X148500000Y-106630804D01*
X148633126Y-106609719D01*
X148753220Y-106548528D01*
X148781628Y-106520120D01*
X148842951Y-106486635D01*
X148912643Y-106491619D01*
X148925600Y-106497314D01*
X149012810Y-106541750D01*
X149145936Y-106562835D01*
X149279062Y-106541750D01*
X149399156Y-106480559D01*
X149494464Y-106385251D01*
X149498894Y-106376557D01*
X149498896Y-106376554D01*
X149542823Y-106290341D01*
X149590797Y-106239544D01*
X149658618Y-106222749D01*
X149672700Y-106224161D01*
X149703061Y-106228970D01*
X149836187Y-106207885D01*
X149956281Y-106146694D01*
X149987730Y-106115245D01*
X150012934Y-106090042D01*
X150074257Y-106056558D01*
X150143949Y-106061543D01*
X150188295Y-106090043D01*
X150246780Y-106148528D01*
X150366874Y-106209719D01*
X150500000Y-106230804D01*
X150633126Y-106209719D01*
X150753220Y-106148528D01*
X150848528Y-106053220D01*
X150875811Y-105999674D01*
X150923785Y-105948878D01*
X150991606Y-105932083D01*
X151045568Y-105950906D01*
X151046780Y-105948528D01*
X151166874Y-106009719D01*
X151300000Y-106030804D01*
X151433126Y-106009719D01*
X151452201Y-106000000D01*
X152169196Y-106000000D01*
X152190281Y-106133126D01*
X152251472Y-106253220D01*
X152346780Y-106348528D01*
X152466874Y-106409719D01*
X152600000Y-106430804D01*
X152733126Y-106409719D01*
X152853220Y-106348528D01*
X152918758Y-106282990D01*
X162475643Y-106282990D01*
X162477313Y-106291272D01*
X162501259Y-106410032D01*
X162503830Y-106422785D01*
X162507666Y-106430314D01*
X162507667Y-106430316D01*
X162537034Y-106487951D01*
X162568573Y-106549849D01*
X162574293Y-106556069D01*
X162574294Y-106556071D01*
X162645150Y-106633126D01*
X162665101Y-106654823D01*
X162672288Y-106659279D01*
X162672289Y-106659280D01*
X162742419Y-106702762D01*
X162786303Y-106729971D01*
X162794418Y-106732329D01*
X162794421Y-106732330D01*
X162876032Y-106756040D01*
X162923249Y-106769758D01*
X162929731Y-106770234D01*
X162931079Y-106770333D01*
X162931080Y-106770333D01*
X162933354Y-106770500D01*
X163035727Y-106770500D01*
X163103465Y-106761221D01*
X163132917Y-106757187D01*
X163132918Y-106757187D01*
X163141289Y-106756040D01*
X163184260Y-106737445D01*
X163264407Y-106702762D01*
X163264410Y-106702760D01*
X163272168Y-106699403D01*
X163382996Y-106609657D01*
X163387891Y-106602769D01*
X163387893Y-106602767D01*
X163454073Y-106509641D01*
X163465606Y-106493413D01*
X163513913Y-106359236D01*
X163524357Y-106217010D01*
X163509157Y-106141626D01*
X163497841Y-106085501D01*
X163497840Y-106085499D01*
X163496170Y-106077215D01*
X163483010Y-106051386D01*
X163435263Y-105957680D01*
X163431427Y-105950151D01*
X163334899Y-105845177D01*
X163318026Y-105834715D01*
X163220881Y-105774483D01*
X163220880Y-105774482D01*
X163213697Y-105770029D01*
X163205582Y-105767671D01*
X163205579Y-105767670D01*
X163109918Y-105739878D01*
X163076751Y-105730242D01*
X163070269Y-105729766D01*
X163068921Y-105729667D01*
X163068920Y-105729667D01*
X163066646Y-105729500D01*
X162964273Y-105729500D01*
X162896535Y-105738779D01*
X162867083Y-105742813D01*
X162867082Y-105742813D01*
X162858711Y-105743960D01*
X162850953Y-105747317D01*
X162850954Y-105747317D01*
X162735593Y-105797238D01*
X162735590Y-105797240D01*
X162727832Y-105800597D01*
X162617004Y-105890343D01*
X162612109Y-105897231D01*
X162612107Y-105897233D01*
X162553117Y-105980241D01*
X162534394Y-106006587D01*
X162486087Y-106140764D01*
X162475643Y-106282990D01*
X152918758Y-106282990D01*
X152948528Y-106253220D01*
X153009719Y-106133126D01*
X153030804Y-106000000D01*
X153009719Y-105866874D01*
X152948528Y-105746780D01*
X152853220Y-105651472D01*
X152733126Y-105590281D01*
X152600000Y-105569196D01*
X152466874Y-105590281D01*
X152346780Y-105651472D01*
X152251472Y-105746780D01*
X152190281Y-105866874D01*
X152169196Y-106000000D01*
X151452201Y-106000000D01*
X151553220Y-105948528D01*
X151648528Y-105853220D01*
X151709719Y-105733126D01*
X151730804Y-105600000D01*
X151709719Y-105466874D01*
X151648528Y-105346780D01*
X151553220Y-105251472D01*
X151433126Y-105190281D01*
X151300000Y-105169196D01*
X151166874Y-105190281D01*
X151046780Y-105251472D01*
X150951472Y-105346780D01*
X150924189Y-105400326D01*
X150876215Y-105451122D01*
X150808394Y-105467917D01*
X150754432Y-105449094D01*
X150753220Y-105451472D01*
X150717214Y-105433126D01*
X150633126Y-105390281D01*
X150500000Y-105369196D01*
X150366874Y-105390281D01*
X150246780Y-105451472D01*
X150190128Y-105508124D01*
X150128807Y-105541609D01*
X150059115Y-105536625D01*
X150014767Y-105508124D01*
X149956281Y-105449638D01*
X149836187Y-105388447D01*
X149703061Y-105367362D01*
X149569935Y-105388447D01*
X149449841Y-105449638D01*
X149354533Y-105544946D01*
X149350103Y-105553640D01*
X149350101Y-105553643D01*
X149306174Y-105639856D01*
X149258200Y-105690653D01*
X149190379Y-105707448D01*
X149176297Y-105706036D01*
X149145936Y-105701227D01*
X149012810Y-105722312D01*
X148892716Y-105783503D01*
X148864308Y-105811911D01*
X148802985Y-105845396D01*
X148733293Y-105840412D01*
X148720336Y-105834717D01*
X148633126Y-105790281D01*
X148500000Y-105769196D01*
X148366874Y-105790281D01*
X148246780Y-105851472D01*
X148151472Y-105946780D01*
X148090281Y-106066874D01*
X148069196Y-106200000D01*
X141201748Y-106200000D01*
X141153220Y-106151472D01*
X141033126Y-106090281D01*
X140900000Y-106069196D01*
X140766874Y-106090281D01*
X140646780Y-106151472D01*
X140551472Y-106246780D01*
X140490281Y-106366874D01*
X140469196Y-106500000D01*
X128722601Y-106500000D01*
X128700922Y-106433280D01*
X128699421Y-106428308D01*
X128537128Y-105847042D01*
X128450206Y-105535723D01*
X128448917Y-105530704D01*
X128448195Y-105527625D01*
X128394806Y-105300000D01*
X146569196Y-105300000D01*
X146590281Y-105433126D01*
X146651472Y-105553220D01*
X146746780Y-105648528D01*
X146866874Y-105709719D01*
X147000000Y-105730804D01*
X147133126Y-105709719D01*
X147253220Y-105648528D01*
X147348528Y-105553220D01*
X147409719Y-105433126D01*
X147430804Y-105300000D01*
X147409719Y-105166874D01*
X147348528Y-105046780D01*
X147253220Y-104951472D01*
X147133126Y-104890281D01*
X147000000Y-104869196D01*
X146866874Y-104890281D01*
X146746780Y-104951472D01*
X146651472Y-105046780D01*
X146590281Y-105166874D01*
X146569196Y-105300000D01*
X128394806Y-105300000D01*
X128237293Y-104628440D01*
X128236219Y-104623385D01*
X128233598Y-104609641D01*
X128231759Y-104600000D01*
X137869196Y-104600000D01*
X137890281Y-104733126D01*
X137951472Y-104853220D01*
X138046780Y-104948528D01*
X138166874Y-105009719D01*
X138300000Y-105030804D01*
X138433126Y-105009719D01*
X138553220Y-104948528D01*
X138648528Y-104853220D01*
X138651295Y-104847790D01*
X138705014Y-104806368D01*
X138774627Y-104800390D01*
X138836422Y-104832997D01*
X138847942Y-104846292D01*
X138851472Y-104853220D01*
X138946780Y-104948528D01*
X139066874Y-105009719D01*
X139200000Y-105030804D01*
X139333126Y-105009719D01*
X139453220Y-104948528D01*
X139548528Y-104853220D01*
X139609719Y-104733126D01*
X139630804Y-104600000D01*
X139609719Y-104466874D01*
X139548528Y-104346780D01*
X139453220Y-104251472D01*
X139333126Y-104190281D01*
X139200000Y-104169196D01*
X139066874Y-104190281D01*
X138946780Y-104251472D01*
X138851472Y-104346780D01*
X138848705Y-104352210D01*
X138794986Y-104393632D01*
X138725373Y-104399610D01*
X138663578Y-104367003D01*
X138652058Y-104353708D01*
X138648528Y-104346780D01*
X138553220Y-104251472D01*
X138433126Y-104190281D01*
X138300000Y-104169196D01*
X138166874Y-104190281D01*
X138046780Y-104251472D01*
X137951472Y-104346780D01*
X137890281Y-104466874D01*
X137869196Y-104600000D01*
X128231759Y-104600000D01*
X128117303Y-104000000D01*
X146369196Y-104000000D01*
X146390281Y-104133126D01*
X146451472Y-104253220D01*
X146546780Y-104348528D01*
X146666874Y-104409719D01*
X146800000Y-104430804D01*
X146933126Y-104409719D01*
X147053220Y-104348528D01*
X147148528Y-104253220D01*
X147209719Y-104133126D01*
X147230804Y-104000000D01*
X147209719Y-103866874D01*
X147148528Y-103746780D01*
X147053220Y-103651472D01*
X146933126Y-103590281D01*
X146800000Y-103569196D01*
X146666874Y-103590281D01*
X146546780Y-103651472D01*
X146451472Y-103746780D01*
X146390281Y-103866874D01*
X146369196Y-104000000D01*
X128117303Y-104000000D01*
X128062567Y-103713066D01*
X128061701Y-103707948D01*
X128044326Y-103590281D01*
X127946717Y-102929277D01*
X127926324Y-102791175D01*
X127925673Y-102786023D01*
X127899815Y-102540000D01*
X128619196Y-102540000D01*
X128640281Y-102673126D01*
X128701472Y-102793220D01*
X128796780Y-102888528D01*
X128916874Y-102949719D01*
X129050000Y-102970804D01*
X129183126Y-102949719D01*
X129303220Y-102888528D01*
X129398528Y-102793220D01*
X129459719Y-102673126D01*
X129480804Y-102540000D01*
X132329196Y-102540000D01*
X132350281Y-102673126D01*
X132411472Y-102793220D01*
X132506780Y-102888528D01*
X132626874Y-102949719D01*
X132760000Y-102970804D01*
X132893126Y-102949719D01*
X133013220Y-102888528D01*
X133108528Y-102793220D01*
X133110288Y-102794980D01*
X133154425Y-102760954D01*
X133224039Y-102754983D01*
X133287081Y-102788829D01*
X133346780Y-102848528D01*
X133466874Y-102909719D01*
X133600000Y-102930804D01*
X133733126Y-102909719D01*
X133853220Y-102848528D01*
X133948528Y-102753220D01*
X134009719Y-102633126D01*
X134030804Y-102500000D01*
X134009719Y-102366874D01*
X133948528Y-102246780D01*
X133853220Y-102151472D01*
X133733126Y-102090281D01*
X133600000Y-102069196D01*
X133466874Y-102090281D01*
X133346780Y-102151472D01*
X133251472Y-102246780D01*
X133249712Y-102245020D01*
X133205575Y-102279046D01*
X133135961Y-102285017D01*
X133072919Y-102251171D01*
X133013220Y-102191472D01*
X132893126Y-102130281D01*
X132760000Y-102109196D01*
X132626874Y-102130281D01*
X132506780Y-102191472D01*
X132411472Y-102286780D01*
X132350281Y-102406874D01*
X132329196Y-102540000D01*
X129480804Y-102540000D01*
X129459719Y-102406874D01*
X129398528Y-102286780D01*
X129303220Y-102191472D01*
X129183126Y-102130281D01*
X129050000Y-102109196D01*
X128916874Y-102130281D01*
X128796780Y-102191472D01*
X128701472Y-102286780D01*
X128640281Y-102406874D01*
X128619196Y-102540000D01*
X127899815Y-102540000D01*
X127828802Y-101864358D01*
X127828368Y-101859182D01*
X127828182Y-101856233D01*
X145112963Y-101856233D01*
X145134048Y-101989359D01*
X145195239Y-102109453D01*
X145290547Y-102204761D01*
X145410641Y-102265952D01*
X145543767Y-102287037D01*
X145676893Y-102265952D01*
X145796987Y-102204761D01*
X145892295Y-102109453D01*
X145953486Y-101989359D01*
X145974571Y-101856233D01*
X145953486Y-101723107D01*
X145892295Y-101603013D01*
X145796987Y-101507705D01*
X145676893Y-101446514D01*
X145543767Y-101425429D01*
X145410641Y-101446514D01*
X145290547Y-101507705D01*
X145195239Y-101603013D01*
X145134048Y-101723107D01*
X145112963Y-101856233D01*
X127828182Y-101856233D01*
X127793188Y-101300000D01*
X130069196Y-101300000D01*
X130090281Y-101433126D01*
X130151472Y-101553220D01*
X130246780Y-101648528D01*
X130366874Y-101709719D01*
X130500000Y-101730804D01*
X130633126Y-101709719D01*
X130753220Y-101648528D01*
X130848528Y-101553220D01*
X130909719Y-101433126D01*
X130930804Y-101300000D01*
X131269196Y-101300000D01*
X131290281Y-101433126D01*
X131351472Y-101553220D01*
X131446780Y-101648528D01*
X131566874Y-101709719D01*
X131700000Y-101730804D01*
X131833126Y-101709719D01*
X131953220Y-101648528D01*
X132048528Y-101553220D01*
X132109719Y-101433126D01*
X132130804Y-101300000D01*
X132109719Y-101166874D01*
X132048528Y-101046780D01*
X131953220Y-100951472D01*
X131833126Y-100890281D01*
X131700000Y-100869196D01*
X131566874Y-100890281D01*
X131446780Y-100951472D01*
X131351472Y-101046780D01*
X131290281Y-101166874D01*
X131269196Y-101300000D01*
X130930804Y-101300000D01*
X130909719Y-101166874D01*
X130848528Y-101046780D01*
X130753220Y-100951472D01*
X130633126Y-100890281D01*
X130500000Y-100869196D01*
X130366874Y-100890281D01*
X130246780Y-100951472D01*
X130151472Y-101046780D01*
X130090281Y-101166874D01*
X130069196Y-101300000D01*
X127793188Y-101300000D01*
X127770181Y-100934317D01*
X127769963Y-100929128D01*
X127767258Y-100800000D01*
X146969196Y-100800000D01*
X146990281Y-100933126D01*
X147051472Y-101053220D01*
X147146780Y-101148528D01*
X147266874Y-101209719D01*
X147400000Y-101230804D01*
X147533126Y-101209719D01*
X147653220Y-101148528D01*
X147748528Y-101053220D01*
X147809719Y-100933126D01*
X147830804Y-100800000D01*
X147826844Y-100775000D01*
X152394196Y-100775000D01*
X152415281Y-100908126D01*
X152476472Y-101028220D01*
X152571780Y-101123528D01*
X152620845Y-101148528D01*
X152683177Y-101180288D01*
X152683179Y-101180289D01*
X152691874Y-101184719D01*
X152696546Y-101185459D01*
X152751916Y-101223318D01*
X152779115Y-101287676D01*
X152778397Y-101321209D01*
X152761169Y-101429983D01*
X152782254Y-101563109D01*
X152843445Y-101683203D01*
X152938753Y-101778511D01*
X153058847Y-101839702D01*
X153191973Y-101860787D01*
X153325099Y-101839702D01*
X153404718Y-101799134D01*
X153473387Y-101786238D01*
X153538128Y-101812514D01*
X153578385Y-101869621D01*
X153583483Y-101890207D01*
X153590281Y-101933126D01*
X153651472Y-102053220D01*
X153746780Y-102148528D01*
X153866874Y-102209719D01*
X154000000Y-102230804D01*
X154009641Y-102229277D01*
X154009642Y-102229277D01*
X154047343Y-102223306D01*
X154116636Y-102232261D01*
X154170088Y-102277257D01*
X154184615Y-102314573D01*
X154185740Y-102314208D01*
X154188754Y-102323484D01*
X154190281Y-102333126D01*
X154251472Y-102453220D01*
X154310571Y-102512319D01*
X154344056Y-102573642D01*
X154339072Y-102643334D01*
X154310571Y-102687681D01*
X154251472Y-102746780D01*
X154190281Y-102866874D01*
X154169196Y-103000000D01*
X154190281Y-103133126D01*
X154194712Y-103141822D01*
X154194713Y-103141825D01*
X154223436Y-103198196D01*
X154236333Y-103266865D01*
X154210057Y-103331606D01*
X154152951Y-103371863D01*
X154093557Y-103376966D01*
X154044500Y-103369196D01*
X153911374Y-103390281D01*
X153791280Y-103451472D01*
X153695972Y-103546780D01*
X153634781Y-103666874D01*
X153623219Y-103739878D01*
X153622247Y-103746012D01*
X153592318Y-103809147D01*
X153533007Y-103846079D01*
X153463144Y-103845081D01*
X153443479Y-103837100D01*
X153388619Y-103809147D01*
X153339359Y-103784048D01*
X153206233Y-103762963D01*
X153073107Y-103784048D01*
X152953013Y-103845239D01*
X152857705Y-103940547D01*
X152796514Y-104060641D01*
X152775429Y-104193767D01*
X152796514Y-104326893D01*
X152857705Y-104446987D01*
X152953013Y-104542295D01*
X153073107Y-104603486D01*
X153206233Y-104624571D01*
X153339359Y-104603486D01*
X153459453Y-104542295D01*
X153554761Y-104446987D01*
X153615952Y-104326893D01*
X153628486Y-104247754D01*
X153658415Y-104184620D01*
X153717726Y-104147688D01*
X153787589Y-104148686D01*
X153807252Y-104156666D01*
X153911374Y-104209719D01*
X154044500Y-104230804D01*
X154177626Y-104209719D01*
X154297720Y-104148528D01*
X154393028Y-104053220D01*
X154454219Y-103933126D01*
X154475304Y-103800000D01*
X154454219Y-103666874D01*
X154446372Y-103651472D01*
X154421064Y-103601804D01*
X154408167Y-103533135D01*
X154434443Y-103468394D01*
X154491549Y-103428137D01*
X154550943Y-103423034D01*
X154600000Y-103430804D01*
X154733126Y-103409719D01*
X154853220Y-103348528D01*
X154948528Y-103253220D01*
X155009719Y-103133126D01*
X155030804Y-103000000D01*
X155009719Y-102866874D01*
X154948528Y-102746780D01*
X154889429Y-102687681D01*
X154855944Y-102626358D01*
X154858227Y-102594440D01*
X168244901Y-102594440D01*
X168261633Y-102722394D01*
X168265192Y-102730482D01*
X168265192Y-102730483D01*
X168278600Y-102760954D01*
X168313605Y-102840510D01*
X168330876Y-102861056D01*
X168368057Y-102905288D01*
X168396639Y-102939291D01*
X168403990Y-102944184D01*
X168403992Y-102944186D01*
X168487841Y-103000000D01*
X168504060Y-103010796D01*
X168512488Y-103013429D01*
X168512490Y-103013430D01*
X168560281Y-103028361D01*
X168627233Y-103049278D01*
X168636067Y-103049440D01*
X168672777Y-103050113D01*
X168756255Y-103051643D01*
X168764771Y-103049321D01*
X168764773Y-103049321D01*
X168872236Y-103020023D01*
X168872239Y-103020022D01*
X168880755Y-103017700D01*
X168990724Y-102950179D01*
X169077322Y-102854507D01*
X169081171Y-102846562D01*
X169081174Y-102846558D01*
X169129737Y-102746324D01*
X169129738Y-102746322D01*
X169133588Y-102738375D01*
X169144565Y-102673126D01*
X169154204Y-102615835D01*
X169154204Y-102615832D01*
X169154997Y-102611120D01*
X169155133Y-102600000D01*
X169154337Y-102594440D01*
X169138092Y-102481005D01*
X169138091Y-102481002D01*
X169136839Y-102472259D01*
X169130783Y-102458939D01*
X169087084Y-102362828D01*
X169087083Y-102362826D01*
X169083428Y-102354788D01*
X169048777Y-102314573D01*
X169004958Y-102263718D01*
X169004956Y-102263716D01*
X168999193Y-102257028D01*
X168956378Y-102229277D01*
X168898317Y-102191644D01*
X168898314Y-102191643D01*
X168890906Y-102186841D01*
X168882446Y-102184311D01*
X168882444Y-102184310D01*
X168775736Y-102152397D01*
X168767273Y-102149866D01*
X168758440Y-102149812D01*
X168710027Y-102149516D01*
X168638231Y-102149078D01*
X168514155Y-102184539D01*
X168405019Y-102253399D01*
X168319596Y-102350122D01*
X168264754Y-102466932D01*
X168263396Y-102475656D01*
X168263395Y-102475658D01*
X168261106Y-102490359D01*
X168244901Y-102594440D01*
X154858227Y-102594440D01*
X154860928Y-102556666D01*
X154889429Y-102512319D01*
X154948528Y-102453220D01*
X155009719Y-102333126D01*
X155030804Y-102200000D01*
X155009719Y-102066874D01*
X154948528Y-101946780D01*
X154853220Y-101851472D01*
X154733126Y-101790281D01*
X154600000Y-101769196D01*
X154590359Y-101770723D01*
X154590358Y-101770723D01*
X154552657Y-101776694D01*
X154483364Y-101767739D01*
X154429912Y-101722743D01*
X154415385Y-101685427D01*
X154414260Y-101685792D01*
X154411246Y-101676516D01*
X154409719Y-101666874D01*
X154348528Y-101546780D01*
X154253220Y-101451472D01*
X154133126Y-101390281D01*
X154000000Y-101369196D01*
X153866874Y-101390281D01*
X153797892Y-101425429D01*
X153787255Y-101430849D01*
X153718586Y-101443745D01*
X153653845Y-101417469D01*
X153613588Y-101360362D01*
X153608490Y-101339776D01*
X153602190Y-101300000D01*
X169169196Y-101300000D01*
X169190281Y-101433126D01*
X169251472Y-101553220D01*
X169346780Y-101648528D01*
X169466874Y-101709719D01*
X169600000Y-101730804D01*
X169733126Y-101709719D01*
X169853220Y-101648528D01*
X169948528Y-101553220D01*
X170009719Y-101433126D01*
X170030804Y-101300000D01*
X170009719Y-101166874D01*
X169948528Y-101046780D01*
X169853220Y-100951472D01*
X169733126Y-100890281D01*
X169600000Y-100869196D01*
X169466874Y-100890281D01*
X169346780Y-100951472D01*
X169251472Y-101046780D01*
X169190281Y-101166874D01*
X169169196Y-101300000D01*
X153602190Y-101300000D01*
X153601692Y-101296857D01*
X153540501Y-101176763D01*
X153445193Y-101081455D01*
X153355241Y-101035622D01*
X153333796Y-101024695D01*
X153333794Y-101024694D01*
X153325099Y-101020264D01*
X153320427Y-101019524D01*
X153265057Y-100981665D01*
X153237858Y-100917307D01*
X153238576Y-100883771D01*
X153254277Y-100784641D01*
X153255725Y-100775500D01*
X168139196Y-100775500D01*
X168160281Y-100908626D01*
X168221472Y-101028720D01*
X168316780Y-101124028D01*
X168436874Y-101185219D01*
X168570000Y-101206304D01*
X168703126Y-101185219D01*
X168823220Y-101124028D01*
X168918528Y-101028720D01*
X168979719Y-100908626D01*
X169000804Y-100775500D01*
X168979719Y-100642374D01*
X168918528Y-100522280D01*
X168823220Y-100426972D01*
X168703126Y-100365781D01*
X168570000Y-100344696D01*
X168436874Y-100365781D01*
X168316780Y-100426972D01*
X168221472Y-100522280D01*
X168160281Y-100642374D01*
X168139196Y-100775500D01*
X153255725Y-100775500D01*
X153255804Y-100775000D01*
X153234719Y-100641874D01*
X153173528Y-100521780D01*
X153078220Y-100426472D01*
X152958126Y-100365281D01*
X152825000Y-100344196D01*
X152691874Y-100365281D01*
X152571780Y-100426472D01*
X152476472Y-100521780D01*
X152415281Y-100641874D01*
X152394196Y-100775000D01*
X147826844Y-100775000D01*
X147809719Y-100666874D01*
X147748528Y-100546780D01*
X147653220Y-100451472D01*
X147533126Y-100390281D01*
X147400000Y-100369196D01*
X147266874Y-100390281D01*
X147146780Y-100451472D01*
X147051472Y-100546780D01*
X146990281Y-100666874D01*
X146969196Y-100800000D01*
X127767258Y-100800000D01*
X127761809Y-100539878D01*
X127750554Y-100002578D01*
X127750554Y-99997403D01*
X127752393Y-99909641D01*
X127752595Y-99900000D01*
X149169196Y-99900000D01*
X149190281Y-100033126D01*
X149251472Y-100153220D01*
X149346780Y-100248528D01*
X149466874Y-100309719D01*
X149600000Y-100330804D01*
X149733126Y-100309719D01*
X149853220Y-100248528D01*
X149948528Y-100153220D01*
X150009719Y-100033126D01*
X150022885Y-99950000D01*
X150743696Y-99950000D01*
X150764781Y-100083126D01*
X150825972Y-100203220D01*
X150921280Y-100298528D01*
X151041374Y-100359719D01*
X151174500Y-100380804D01*
X151307626Y-100359719D01*
X151427720Y-100298528D01*
X151523028Y-100203220D01*
X151584219Y-100083126D01*
X151605304Y-99950000D01*
X151584219Y-99816874D01*
X151523028Y-99696780D01*
X151427720Y-99601472D01*
X151307626Y-99540281D01*
X151174500Y-99519196D01*
X151041374Y-99540281D01*
X150921280Y-99601472D01*
X150825972Y-99696780D01*
X150764781Y-99816874D01*
X150743696Y-99950000D01*
X150022885Y-99950000D01*
X150030804Y-99900000D01*
X150009719Y-99766874D01*
X149948528Y-99646780D01*
X149853220Y-99551472D01*
X149733126Y-99490281D01*
X149600000Y-99469196D01*
X149466874Y-99490281D01*
X149346780Y-99551472D01*
X149251472Y-99646780D01*
X149190281Y-99766874D01*
X149169196Y-99900000D01*
X127752595Y-99900000D01*
X127765256Y-99295565D01*
X127769963Y-99070872D01*
X127770181Y-99065683D01*
X127793188Y-98700000D01*
X129969196Y-98700000D01*
X129990281Y-98833126D01*
X130051472Y-98953220D01*
X130146780Y-99048528D01*
X130266874Y-99109719D01*
X130400000Y-99130804D01*
X130533126Y-99109719D01*
X130653220Y-99048528D01*
X130748528Y-98953220D01*
X130809719Y-98833126D01*
X130830804Y-98700000D01*
X131169196Y-98700000D01*
X131190281Y-98833126D01*
X131251472Y-98953220D01*
X131346780Y-99048528D01*
X131466874Y-99109719D01*
X131600000Y-99130804D01*
X131733126Y-99109719D01*
X131853220Y-99048528D01*
X131948528Y-98953220D01*
X132009719Y-98833126D01*
X132030804Y-98700000D01*
X132009719Y-98566874D01*
X131948528Y-98446780D01*
X131901748Y-98400000D01*
X147769196Y-98400000D01*
X147790281Y-98533126D01*
X147851472Y-98653220D01*
X147946780Y-98748528D01*
X148066874Y-98809719D01*
X148200000Y-98830804D01*
X148333126Y-98809719D01*
X148453220Y-98748528D01*
X148548528Y-98653220D01*
X148575645Y-98600000D01*
X165044696Y-98600000D01*
X165065781Y-98733126D01*
X165126972Y-98853220D01*
X165222280Y-98948528D01*
X165342374Y-99009719D01*
X165475500Y-99030804D01*
X165608626Y-99009719D01*
X165728720Y-98948528D01*
X165824028Y-98853220D01*
X165885219Y-98733126D01*
X165890466Y-98700000D01*
X168979196Y-98700000D01*
X169000281Y-98833126D01*
X169061472Y-98953220D01*
X169156780Y-99048528D01*
X169276874Y-99109719D01*
X169410000Y-99130804D01*
X169543126Y-99109719D01*
X169663220Y-99048528D01*
X169758528Y-98953220D01*
X169819719Y-98833126D01*
X169840804Y-98700000D01*
X169819719Y-98566874D01*
X169758528Y-98446780D01*
X169663220Y-98351472D01*
X169543126Y-98290281D01*
X169410000Y-98269196D01*
X169276874Y-98290281D01*
X169156780Y-98351472D01*
X169061472Y-98446780D01*
X169000281Y-98566874D01*
X168979196Y-98700000D01*
X165890466Y-98700000D01*
X165906304Y-98600000D01*
X165885219Y-98466874D01*
X165824028Y-98346780D01*
X165728720Y-98251472D01*
X165608626Y-98190281D01*
X165475500Y-98169196D01*
X165342374Y-98190281D01*
X165222280Y-98251472D01*
X165126972Y-98346780D01*
X165065781Y-98466874D01*
X165044696Y-98600000D01*
X148575645Y-98600000D01*
X148609719Y-98533126D01*
X148630804Y-98400000D01*
X148609719Y-98266874D01*
X148548528Y-98146780D01*
X148453220Y-98051472D01*
X148352201Y-98000000D01*
X150769196Y-98000000D01*
X150790281Y-98133126D01*
X150851472Y-98253220D01*
X150946780Y-98348528D01*
X151066874Y-98409719D01*
X151200000Y-98430804D01*
X151333126Y-98409719D01*
X151453220Y-98348528D01*
X151548528Y-98253220D01*
X151609719Y-98133126D01*
X151630804Y-98000000D01*
X156269196Y-98000000D01*
X156290281Y-98133126D01*
X156351472Y-98253220D01*
X156446780Y-98348528D01*
X156566874Y-98409719D01*
X156700000Y-98430804D01*
X156833126Y-98409719D01*
X156953220Y-98348528D01*
X157048528Y-98253220D01*
X157109719Y-98133126D01*
X157130804Y-98000000D01*
X157109719Y-97866874D01*
X157048528Y-97746780D01*
X156953220Y-97651472D01*
X156833126Y-97590281D01*
X156700000Y-97569196D01*
X156566874Y-97590281D01*
X156446780Y-97651472D01*
X156351472Y-97746780D01*
X156290281Y-97866874D01*
X156269196Y-98000000D01*
X151630804Y-98000000D01*
X151609719Y-97866874D01*
X151548528Y-97746780D01*
X151453220Y-97651472D01*
X151333126Y-97590281D01*
X151200000Y-97569196D01*
X151066874Y-97590281D01*
X150946780Y-97651472D01*
X150851472Y-97746780D01*
X150790281Y-97866874D01*
X150769196Y-98000000D01*
X148352201Y-98000000D01*
X148333126Y-97990281D01*
X148200000Y-97969196D01*
X148066874Y-97990281D01*
X147946780Y-98051472D01*
X147851472Y-98146780D01*
X147790281Y-98266874D01*
X147769196Y-98400000D01*
X131901748Y-98400000D01*
X131853220Y-98351472D01*
X131733126Y-98290281D01*
X131600000Y-98269196D01*
X131466874Y-98290281D01*
X131346780Y-98351472D01*
X131251472Y-98446780D01*
X131190281Y-98566874D01*
X131169196Y-98700000D01*
X130830804Y-98700000D01*
X130809719Y-98566874D01*
X130748528Y-98446780D01*
X130653220Y-98351472D01*
X130533126Y-98290281D01*
X130400000Y-98269196D01*
X130266874Y-98290281D01*
X130146780Y-98351472D01*
X130051472Y-98446780D01*
X129990281Y-98566874D01*
X129969196Y-98700000D01*
X127793188Y-98700000D01*
X127828368Y-98140818D01*
X127828802Y-98135642D01*
X127895611Y-97500000D01*
X169099196Y-97500000D01*
X169120281Y-97633126D01*
X169181472Y-97753220D01*
X169276780Y-97848528D01*
X169396874Y-97909719D01*
X169530000Y-97930804D01*
X169663126Y-97909719D01*
X169783220Y-97848528D01*
X169878528Y-97753220D01*
X169939719Y-97633126D01*
X169960804Y-97500000D01*
X169939719Y-97366874D01*
X169878528Y-97246780D01*
X169783220Y-97151472D01*
X169663126Y-97090281D01*
X169530000Y-97069196D01*
X169396874Y-97090281D01*
X169276780Y-97151472D01*
X169181472Y-97246780D01*
X169120281Y-97366874D01*
X169099196Y-97500000D01*
X127895611Y-97500000D01*
X127925673Y-97213977D01*
X127926324Y-97208825D01*
X127957161Y-97000000D01*
X142169196Y-97000000D01*
X142190281Y-97133126D01*
X142251472Y-97253220D01*
X142346780Y-97348528D01*
X142466874Y-97409719D01*
X142600000Y-97430804D01*
X142733126Y-97409719D01*
X142853220Y-97348528D01*
X142948528Y-97253220D01*
X143009719Y-97133126D01*
X143030804Y-97000000D01*
X143009719Y-96866874D01*
X142948528Y-96746780D01*
X142853220Y-96651472D01*
X142733126Y-96590281D01*
X142600000Y-96569196D01*
X142466874Y-96590281D01*
X142346780Y-96651472D01*
X142251472Y-96746780D01*
X142190281Y-96866874D01*
X142169196Y-97000000D01*
X127957161Y-97000000D01*
X128030994Y-96500000D01*
X155969196Y-96500000D01*
X155990281Y-96633126D01*
X156051472Y-96753220D01*
X156146780Y-96848528D01*
X156266874Y-96909719D01*
X156400000Y-96930804D01*
X156533126Y-96909719D01*
X156653220Y-96848528D01*
X156748528Y-96753220D01*
X156809719Y-96633126D01*
X156830804Y-96500000D01*
X156809719Y-96366874D01*
X156748528Y-96246780D01*
X156653220Y-96151472D01*
X156533126Y-96090281D01*
X156400000Y-96069196D01*
X156266874Y-96090281D01*
X156146780Y-96151472D01*
X156051472Y-96246780D01*
X155990281Y-96366874D01*
X155969196Y-96500000D01*
X128030994Y-96500000D01*
X128032418Y-96490359D01*
X128061701Y-96292050D01*
X128062567Y-96286931D01*
X128236219Y-95376615D01*
X128237293Y-95371560D01*
X128448922Y-94469275D01*
X128450209Y-94464266D01*
X128462569Y-94420000D01*
X128607348Y-93901459D01*
X128699421Y-93571692D01*
X128700922Y-93566720D01*
X128738847Y-93450000D01*
X164349196Y-93450000D01*
X164370281Y-93583126D01*
X164431472Y-93703220D01*
X164526780Y-93798528D01*
X164646874Y-93859719D01*
X164770514Y-93879302D01*
X164833648Y-93909230D01*
X164870580Y-93968541D01*
X164869582Y-94038404D01*
X164838797Y-94089455D01*
X164761472Y-94166780D01*
X164700281Y-94286874D01*
X164679196Y-94420000D01*
X164700281Y-94553126D01*
X164761472Y-94673220D01*
X164856780Y-94768528D01*
X164976874Y-94829719D01*
X165110000Y-94850804D01*
X165178214Y-94840000D01*
X166269196Y-94840000D01*
X166290281Y-94973126D01*
X166351472Y-95093220D01*
X166446780Y-95188528D01*
X166566874Y-95249719D01*
X166700000Y-95270804D01*
X166833126Y-95249719D01*
X166953220Y-95188528D01*
X167048528Y-95093220D01*
X167109719Y-94973126D01*
X167130804Y-94840000D01*
X167109719Y-94706874D01*
X167048528Y-94586780D01*
X166953220Y-94491472D01*
X166833126Y-94430281D01*
X166705076Y-94410000D01*
X168749196Y-94410000D01*
X168770281Y-94543126D01*
X168831472Y-94663220D01*
X168926780Y-94758528D01*
X169046874Y-94819719D01*
X169180000Y-94840804D01*
X169313126Y-94819719D01*
X169433220Y-94758528D01*
X169528528Y-94663220D01*
X169589719Y-94543126D01*
X169610804Y-94410000D01*
X169589719Y-94276874D01*
X169528528Y-94156780D01*
X169433220Y-94061472D01*
X169313126Y-94000281D01*
X169180000Y-93979196D01*
X169046874Y-94000281D01*
X168926780Y-94061472D01*
X168831472Y-94156780D01*
X168770281Y-94276874D01*
X168749196Y-94410000D01*
X166705076Y-94410000D01*
X166700000Y-94409196D01*
X166566874Y-94430281D01*
X166446780Y-94491472D01*
X166351472Y-94586780D01*
X166290281Y-94706874D01*
X166269196Y-94840000D01*
X165178214Y-94840000D01*
X165243126Y-94829719D01*
X165363220Y-94768528D01*
X165458528Y-94673220D01*
X165519719Y-94553126D01*
X165540804Y-94420000D01*
X165519719Y-94286874D01*
X165458528Y-94166780D01*
X165363220Y-94071472D01*
X165243126Y-94010281D01*
X165119486Y-93990698D01*
X165056352Y-93960770D01*
X165019420Y-93901459D01*
X165020418Y-93831596D01*
X165051203Y-93780545D01*
X165128528Y-93703220D01*
X165189719Y-93583126D01*
X165204469Y-93490000D01*
X167729196Y-93490000D01*
X167750281Y-93623126D01*
X167811472Y-93743220D01*
X167906780Y-93838528D01*
X168026874Y-93899719D01*
X168160000Y-93920804D01*
X168293126Y-93899719D01*
X168413220Y-93838528D01*
X168508528Y-93743220D01*
X168569719Y-93623126D01*
X168590804Y-93490000D01*
X168569719Y-93356874D01*
X168508528Y-93236780D01*
X168413220Y-93141472D01*
X168404524Y-93137041D01*
X168403585Y-93136359D01*
X168360919Y-93081030D01*
X168354940Y-93011416D01*
X168387545Y-92949621D01*
X168420175Y-92925556D01*
X168463185Y-92903641D01*
X168473220Y-92898528D01*
X168568528Y-92803220D01*
X168629719Y-92683126D01*
X168650804Y-92550000D01*
X168629719Y-92416874D01*
X168568528Y-92296780D01*
X168473220Y-92201472D01*
X168353126Y-92140281D01*
X168220000Y-92119196D01*
X168086874Y-92140281D01*
X167966780Y-92201472D01*
X167871472Y-92296780D01*
X167810281Y-92416874D01*
X167789196Y-92550000D01*
X167810281Y-92683126D01*
X167871472Y-92803220D01*
X167966780Y-92898528D01*
X167975476Y-92902959D01*
X167976415Y-92903641D01*
X168019081Y-92958970D01*
X168025060Y-93028584D01*
X167992455Y-93090379D01*
X167959825Y-93114444D01*
X167906780Y-93141472D01*
X167811472Y-93236780D01*
X167750281Y-93356874D01*
X167729196Y-93490000D01*
X165204469Y-93490000D01*
X165210804Y-93450000D01*
X165189719Y-93316874D01*
X165128528Y-93196780D01*
X165033220Y-93101472D01*
X165024525Y-93097042D01*
X165016628Y-93091304D01*
X165018670Y-93088494D01*
X164980665Y-93052589D01*
X164963880Y-92984766D01*
X164986427Y-92918634D01*
X165031471Y-92879610D01*
X165044523Y-92872960D01*
X165044526Y-92872958D01*
X165053220Y-92868528D01*
X165148528Y-92773220D01*
X165209719Y-92653126D01*
X165230804Y-92520000D01*
X165210609Y-92392493D01*
X165219564Y-92323199D01*
X165264560Y-92269747D01*
X165276788Y-92262610D01*
X165365401Y-92217460D01*
X165365404Y-92217458D01*
X165374098Y-92213028D01*
X165469406Y-92117720D01*
X165530597Y-91997626D01*
X165551682Y-91864500D01*
X165530597Y-91731374D01*
X165469406Y-91611280D01*
X165374098Y-91515972D01*
X165254004Y-91454781D01*
X165120878Y-91433696D01*
X164987752Y-91454781D01*
X164867658Y-91515972D01*
X164772350Y-91611280D01*
X164711159Y-91731374D01*
X164690074Y-91864500D01*
X164691601Y-91874141D01*
X164710269Y-91992007D01*
X164701314Y-92061301D01*
X164656318Y-92114753D01*
X164644090Y-92121890D01*
X164555477Y-92167040D01*
X164555474Y-92167042D01*
X164546780Y-92171472D01*
X164451472Y-92266780D01*
X164390281Y-92386874D01*
X164369196Y-92520000D01*
X164390281Y-92653126D01*
X164451472Y-92773220D01*
X164546780Y-92868528D01*
X164555475Y-92872958D01*
X164563372Y-92878696D01*
X164561330Y-92881506D01*
X164599335Y-92917411D01*
X164616120Y-92985234D01*
X164593573Y-93051366D01*
X164548529Y-93090390D01*
X164535477Y-93097040D01*
X164535474Y-93097042D01*
X164526780Y-93101472D01*
X164431472Y-93196780D01*
X164370281Y-93316874D01*
X164349196Y-93450000D01*
X128738847Y-93450000D01*
X128987295Y-92685355D01*
X128989003Y-92680450D01*
X129312033Y-91811846D01*
X129313945Y-91807017D01*
X129329168Y-91770804D01*
X129673061Y-90952712D01*
X129675170Y-90947975D01*
X129676794Y-90944525D01*
X129952616Y-90358374D01*
X130069762Y-90109426D01*
X130072072Y-90104774D01*
X130306960Y-89655475D01*
X130501424Y-89283500D01*
X130503902Y-89278993D01*
X130510383Y-89267767D01*
X132077011Y-89267767D01*
X132095877Y-89555606D01*
X132152152Y-89838520D01*
X132153457Y-89842364D01*
X132243320Y-90107090D01*
X132244874Y-90111669D01*
X132372455Y-90370378D01*
X132532713Y-90610221D01*
X132722906Y-90827094D01*
X132939779Y-91017287D01*
X133179622Y-91177545D01*
X133438331Y-91305126D01*
X133442171Y-91306429D01*
X133442177Y-91306432D01*
X133569467Y-91349641D01*
X133711480Y-91397848D01*
X133994394Y-91454123D01*
X133998435Y-91454388D01*
X133998436Y-91454388D01*
X134278190Y-91472724D01*
X134282233Y-91472989D01*
X134286276Y-91472724D01*
X134566030Y-91454388D01*
X134566031Y-91454388D01*
X134570072Y-91454123D01*
X134852986Y-91397848D01*
X134994999Y-91349641D01*
X135023401Y-91340000D01*
X166269196Y-91340000D01*
X166290281Y-91473126D01*
X166351472Y-91593220D01*
X166446780Y-91688528D01*
X166566874Y-91749719D01*
X166700000Y-91770804D01*
X166833126Y-91749719D01*
X166953220Y-91688528D01*
X167048528Y-91593220D01*
X167109719Y-91473126D01*
X167130804Y-91340000D01*
X167109719Y-91206874D01*
X167048528Y-91086780D01*
X166953220Y-90991472D01*
X166833126Y-90930281D01*
X166700000Y-90909196D01*
X166566874Y-90930281D01*
X166446780Y-90991472D01*
X166351472Y-91086780D01*
X166290281Y-91206874D01*
X166269196Y-91340000D01*
X135023401Y-91340000D01*
X135122289Y-91306432D01*
X135122295Y-91306429D01*
X135126135Y-91305126D01*
X135384844Y-91177545D01*
X135624687Y-91017287D01*
X135841560Y-90827094D01*
X135953019Y-90700000D01*
X138669196Y-90700000D01*
X138690281Y-90833126D01*
X138751472Y-90953220D01*
X138846780Y-91048528D01*
X138966874Y-91109719D01*
X139100000Y-91130804D01*
X139233126Y-91109719D01*
X139353220Y-91048528D01*
X139448528Y-90953220D01*
X139509719Y-90833126D01*
X139530804Y-90700000D01*
X139509719Y-90566874D01*
X139448528Y-90446780D01*
X139353220Y-90351472D01*
X139233126Y-90290281D01*
X139100000Y-90269196D01*
X138966874Y-90290281D01*
X138846780Y-90351472D01*
X138751472Y-90446780D01*
X138690281Y-90566874D01*
X138669196Y-90700000D01*
X135953019Y-90700000D01*
X136031753Y-90610221D01*
X136192011Y-90370378D01*
X136319592Y-90111669D01*
X136321147Y-90107090D01*
X136391444Y-89900000D01*
X160569196Y-89900000D01*
X160590281Y-90033126D01*
X160651472Y-90153220D01*
X160746780Y-90248528D01*
X160866874Y-90309719D01*
X161000000Y-90330804D01*
X161009641Y-90329277D01*
X161097460Y-90315368D01*
X161166754Y-90324323D01*
X161220206Y-90369319D01*
X161240845Y-90436071D01*
X161227343Y-90494136D01*
X161190281Y-90566874D01*
X161169196Y-90700000D01*
X161190281Y-90833126D01*
X161251472Y-90953220D01*
X161346780Y-91048528D01*
X161466874Y-91109719D01*
X161600000Y-91130804D01*
X161733126Y-91109719D01*
X161853220Y-91048528D01*
X161948528Y-90953220D01*
X162009719Y-90833126D01*
X162030804Y-90700000D01*
X162009719Y-90566874D01*
X161948528Y-90446780D01*
X161853220Y-90351472D01*
X161733126Y-90290281D01*
X161600000Y-90269196D01*
X161590359Y-90270723D01*
X161502540Y-90284632D01*
X161433246Y-90275677D01*
X161379794Y-90230681D01*
X161359155Y-90163929D01*
X161372657Y-90105864D01*
X161405288Y-90041822D01*
X161409719Y-90033126D01*
X161430804Y-89900000D01*
X161409719Y-89766874D01*
X161348528Y-89646780D01*
X161253220Y-89551472D01*
X161133126Y-89490281D01*
X161000000Y-89469196D01*
X160866874Y-89490281D01*
X160746780Y-89551472D01*
X160651472Y-89646780D01*
X160590281Y-89766874D01*
X160569196Y-89900000D01*
X136391444Y-89900000D01*
X136411009Y-89842364D01*
X136412314Y-89838520D01*
X136468589Y-89555606D01*
X136487455Y-89267767D01*
X136468589Y-88979928D01*
X136412314Y-88697014D01*
X136390673Y-88633261D01*
X136320898Y-88427711D01*
X136320895Y-88427705D01*
X136319592Y-88423865D01*
X136192011Y-88165156D01*
X136031753Y-87925313D01*
X135841560Y-87708440D01*
X135624687Y-87518247D01*
X135384844Y-87357989D01*
X135126135Y-87230408D01*
X135122295Y-87229105D01*
X135122289Y-87229102D01*
X134856830Y-87138991D01*
X134856832Y-87138991D01*
X134852986Y-87137686D01*
X134570072Y-87081411D01*
X134566031Y-87081146D01*
X134566030Y-87081146D01*
X134286276Y-87062810D01*
X134282233Y-87062545D01*
X134278190Y-87062810D01*
X133998436Y-87081146D01*
X133998435Y-87081146D01*
X133994394Y-87081411D01*
X133711480Y-87137686D01*
X133707634Y-87138991D01*
X133707636Y-87138991D01*
X133442177Y-87229102D01*
X133442171Y-87229105D01*
X133438331Y-87230408D01*
X133179622Y-87357989D01*
X132939779Y-87518247D01*
X132722906Y-87708440D01*
X132532713Y-87925313D01*
X132372455Y-88165156D01*
X132244874Y-88423865D01*
X132243571Y-88427705D01*
X132243568Y-88427711D01*
X132173793Y-88633261D01*
X132152152Y-88697014D01*
X132095877Y-88979928D01*
X132077011Y-89267767D01*
X130510383Y-89267767D01*
X130967276Y-88476405D01*
X130969956Y-88471978D01*
X131002802Y-88420222D01*
X131316881Y-87925313D01*
X131466533Y-87689500D01*
X131469407Y-87685175D01*
X131952690Y-86989820D01*
X164274500Y-86989820D01*
X164283233Y-87033722D01*
X164316496Y-87083504D01*
X164366278Y-87116767D01*
X164393136Y-87122110D01*
X164404201Y-87124311D01*
X164404204Y-87124311D01*
X164410180Y-87125500D01*
X165289820Y-87125500D01*
X165295796Y-87124311D01*
X165295799Y-87124311D01*
X165306864Y-87122110D01*
X165333722Y-87116767D01*
X165383504Y-87083504D01*
X165390290Y-87073348D01*
X165398910Y-87064728D01*
X165460233Y-87031243D01*
X165529925Y-87036227D01*
X165548587Y-87045020D01*
X165553327Y-87047756D01*
X165559767Y-87052698D01*
X165588810Y-87064728D01*
X165692255Y-87107577D01*
X165692257Y-87107578D01*
X165699764Y-87110687D01*
X165850000Y-87130466D01*
X165858059Y-87129405D01*
X165992177Y-87111748D01*
X166000236Y-87110687D01*
X166007743Y-87107578D01*
X166007745Y-87107577D01*
X166111190Y-87064728D01*
X166140233Y-87052698D01*
X166260451Y-86960451D01*
X166288265Y-86924204D01*
X166347751Y-86846680D01*
X166352698Y-86840233D01*
X166410687Y-86700236D01*
X166430466Y-86550000D01*
X166410687Y-86399764D01*
X166352698Y-86259767D01*
X166260451Y-86139549D01*
X166140233Y-86047302D01*
X166065861Y-86016496D01*
X166007745Y-85992423D01*
X166007743Y-85992422D01*
X166000236Y-85989313D01*
X165850000Y-85969534D01*
X165699764Y-85989313D01*
X165692257Y-85992422D01*
X165692255Y-85992423D01*
X165634139Y-86016496D01*
X165559767Y-86047302D01*
X165553327Y-86052244D01*
X165548587Y-86054980D01*
X165480687Y-86071450D01*
X165414660Y-86048596D01*
X165398910Y-86035272D01*
X165390290Y-86026652D01*
X165383504Y-86016496D01*
X165333722Y-85983233D01*
X165306864Y-85977890D01*
X165295799Y-85975689D01*
X165295796Y-85975689D01*
X165289820Y-85974500D01*
X164410180Y-85974500D01*
X164404204Y-85975689D01*
X164404201Y-85975689D01*
X164393136Y-85977890D01*
X164366278Y-85983233D01*
X164316496Y-86016496D01*
X164309710Y-86026652D01*
X164295048Y-86048596D01*
X164283233Y-86066278D01*
X164274500Y-86110180D01*
X164274500Y-86989820D01*
X131952690Y-86989820D01*
X131998294Y-86924204D01*
X132001347Y-86920002D01*
X132057002Y-86846680D01*
X132561634Y-86181851D01*
X132564860Y-86177780D01*
X132733028Y-85974500D01*
X133155606Y-85463692D01*
X133158973Y-85459792D01*
X133779072Y-84771103D01*
X133782627Y-84767317D01*
X134431025Y-84105195D01*
X134434736Y-84101561D01*
X135110293Y-83467170D01*
X135114153Y-83463695D01*
X135299354Y-83303834D01*
X143949500Y-83303834D01*
X143952481Y-83335369D01*
X143997366Y-83463184D01*
X144077850Y-83572150D01*
X144085306Y-83577657D01*
X144179361Y-83647128D01*
X144179363Y-83647129D01*
X144186816Y-83652634D01*
X144195555Y-83655703D01*
X144195557Y-83655704D01*
X144243242Y-83672449D01*
X144314631Y-83697519D01*
X144322150Y-83698230D01*
X144322151Y-83698230D01*
X144343252Y-83700225D01*
X144343262Y-83700225D01*
X144346166Y-83700500D01*
X145653834Y-83700500D01*
X145656738Y-83700225D01*
X145656748Y-83700225D01*
X145677849Y-83698230D01*
X145677850Y-83698230D01*
X145685369Y-83697519D01*
X145756758Y-83672449D01*
X145804443Y-83655704D01*
X145804445Y-83655703D01*
X145813184Y-83652634D01*
X145820637Y-83647129D01*
X145820639Y-83647128D01*
X145914694Y-83577657D01*
X145922150Y-83572150D01*
X146002634Y-83463184D01*
X146047519Y-83335369D01*
X146050500Y-83303834D01*
X146050500Y-82701841D01*
X146449500Y-82701841D01*
X146449796Y-82704856D01*
X146449796Y-82704864D01*
X146463928Y-82848994D01*
X146464520Y-82855030D01*
X146524065Y-83052251D01*
X146620782Y-83234151D01*
X146750989Y-83393800D01*
X146909725Y-83525118D01*
X147090945Y-83623103D01*
X147096736Y-83624896D01*
X147096737Y-83624896D01*
X147114624Y-83630433D01*
X147287746Y-83684023D01*
X147492631Y-83705557D01*
X147498664Y-83705008D01*
X147498668Y-83705008D01*
X147624279Y-83693576D01*
X147697797Y-83686886D01*
X147703610Y-83685175D01*
X147703611Y-83685175D01*
X147889608Y-83630433D01*
X147889609Y-83630433D01*
X147895428Y-83628720D01*
X148017898Y-83564694D01*
X148072626Y-83536083D01*
X148072630Y-83536080D01*
X148077998Y-83533274D01*
X148165173Y-83463184D01*
X148233827Y-83407985D01*
X148233828Y-83407984D01*
X148238553Y-83404185D01*
X148370976Y-83246370D01*
X148470224Y-83065838D01*
X148532516Y-82869468D01*
X148550500Y-82709136D01*
X148550500Y-82701841D01*
X148949500Y-82701841D01*
X148949796Y-82704856D01*
X148949796Y-82704864D01*
X148963928Y-82848994D01*
X148964520Y-82855030D01*
X149024065Y-83052251D01*
X149120782Y-83234151D01*
X149250989Y-83393800D01*
X149409725Y-83525118D01*
X149590945Y-83623103D01*
X149596736Y-83624896D01*
X149596737Y-83624896D01*
X149614624Y-83630433D01*
X149787746Y-83684023D01*
X149992631Y-83705557D01*
X149998664Y-83705008D01*
X149998668Y-83705008D01*
X150124279Y-83693576D01*
X150197797Y-83686886D01*
X150203610Y-83685175D01*
X150203611Y-83685175D01*
X150389608Y-83630433D01*
X150389609Y-83630433D01*
X150395428Y-83628720D01*
X150517898Y-83564694D01*
X150572626Y-83536083D01*
X150572630Y-83536080D01*
X150577998Y-83533274D01*
X150665173Y-83463184D01*
X150733827Y-83407985D01*
X150733828Y-83407984D01*
X150738553Y-83404185D01*
X150870976Y-83246370D01*
X150970224Y-83065838D01*
X151032516Y-82869468D01*
X151050500Y-82709136D01*
X151050500Y-82701841D01*
X151449500Y-82701841D01*
X151449796Y-82704856D01*
X151449796Y-82704864D01*
X151463928Y-82848994D01*
X151464520Y-82855030D01*
X151524065Y-83052251D01*
X151620782Y-83234151D01*
X151750989Y-83393800D01*
X151909725Y-83525118D01*
X152090945Y-83623103D01*
X152096736Y-83624896D01*
X152096737Y-83624896D01*
X152114624Y-83630433D01*
X152287746Y-83684023D01*
X152492631Y-83705557D01*
X152498664Y-83705008D01*
X152498668Y-83705008D01*
X152624279Y-83693576D01*
X152697797Y-83686886D01*
X152703610Y-83685175D01*
X152703611Y-83685175D01*
X152889608Y-83630433D01*
X152889609Y-83630433D01*
X152895428Y-83628720D01*
X153017898Y-83564694D01*
X153072626Y-83536083D01*
X153072630Y-83536080D01*
X153077998Y-83533274D01*
X153165173Y-83463184D01*
X153233827Y-83407985D01*
X153233828Y-83407984D01*
X153238553Y-83404185D01*
X153370976Y-83246370D01*
X153470224Y-83065838D01*
X153532516Y-82869468D01*
X153550500Y-82709136D01*
X153550500Y-82348159D01*
X153550126Y-82344337D01*
X153536072Y-82201006D01*
X153536072Y-82201004D01*
X153535480Y-82194970D01*
X153475935Y-81997749D01*
X153379218Y-81815849D01*
X153249011Y-81656200D01*
X153090275Y-81524882D01*
X152909055Y-81426897D01*
X152899991Y-81424091D01*
X152718046Y-81367770D01*
X152718047Y-81367770D01*
X152712254Y-81365977D01*
X152507369Y-81344443D01*
X152501336Y-81344992D01*
X152501332Y-81344992D01*
X152391539Y-81354984D01*
X152302203Y-81363114D01*
X152296390Y-81364825D01*
X152296389Y-81364825D01*
X152167117Y-81402872D01*
X152104572Y-81421280D01*
X152020819Y-81465065D01*
X151927374Y-81513917D01*
X151927370Y-81513920D01*
X151922002Y-81516726D01*
X151917279Y-81520523D01*
X151917278Y-81520524D01*
X151823956Y-81595557D01*
X151761447Y-81645815D01*
X151629024Y-81803630D01*
X151529776Y-81984162D01*
X151467484Y-82180532D01*
X151449500Y-82340864D01*
X151449500Y-82701841D01*
X151050500Y-82701841D01*
X151050500Y-82348159D01*
X151050126Y-82344337D01*
X151036072Y-82201006D01*
X151036072Y-82201004D01*
X151035480Y-82194970D01*
X150975935Y-81997749D01*
X150879218Y-81815849D01*
X150749011Y-81656200D01*
X150590275Y-81524882D01*
X150409055Y-81426897D01*
X150399991Y-81424091D01*
X150218046Y-81367770D01*
X150218047Y-81367770D01*
X150212254Y-81365977D01*
X150007369Y-81344443D01*
X150001336Y-81344992D01*
X150001332Y-81344992D01*
X149891539Y-81354984D01*
X149802203Y-81363114D01*
X149796390Y-81364825D01*
X149796389Y-81364825D01*
X149667117Y-81402872D01*
X149604572Y-81421280D01*
X149520819Y-81465065D01*
X149427374Y-81513917D01*
X149427370Y-81513920D01*
X149422002Y-81516726D01*
X149417279Y-81520523D01*
X149417278Y-81520524D01*
X149323956Y-81595557D01*
X149261447Y-81645815D01*
X149129024Y-81803630D01*
X149029776Y-81984162D01*
X148967484Y-82180532D01*
X148949500Y-82340864D01*
X148949500Y-82701841D01*
X148550500Y-82701841D01*
X148550500Y-82348159D01*
X148550126Y-82344337D01*
X148536072Y-82201006D01*
X148536072Y-82201004D01*
X148535480Y-82194970D01*
X148475935Y-81997749D01*
X148379218Y-81815849D01*
X148249011Y-81656200D01*
X148090275Y-81524882D01*
X147909055Y-81426897D01*
X147899991Y-81424091D01*
X147718046Y-81367770D01*
X147718047Y-81367770D01*
X147712254Y-81365977D01*
X147507369Y-81344443D01*
X147501336Y-81344992D01*
X147501332Y-81344992D01*
X147391539Y-81354984D01*
X147302203Y-81363114D01*
X147296390Y-81364825D01*
X147296389Y-81364825D01*
X147167117Y-81402872D01*
X147104572Y-81421280D01*
X147020819Y-81465065D01*
X146927374Y-81513917D01*
X146927370Y-81513920D01*
X146922002Y-81516726D01*
X146917279Y-81520523D01*
X146917278Y-81520524D01*
X146823956Y-81595557D01*
X146761447Y-81645815D01*
X146629024Y-81803630D01*
X146529776Y-81984162D01*
X146467484Y-82180532D01*
X146449500Y-82340864D01*
X146449500Y-82701841D01*
X146050500Y-82701841D01*
X146050500Y-81746166D01*
X146048822Y-81728409D01*
X146048230Y-81722151D01*
X146048230Y-81722150D01*
X146047519Y-81714631D01*
X146002634Y-81586816D01*
X145922150Y-81477850D01*
X145843242Y-81419567D01*
X145820639Y-81402872D01*
X145820637Y-81402871D01*
X145813184Y-81397366D01*
X145804445Y-81394297D01*
X145804443Y-81394296D01*
X145756758Y-81377551D01*
X145685369Y-81352481D01*
X145677850Y-81351770D01*
X145677849Y-81351770D01*
X145656748Y-81349775D01*
X145656738Y-81349775D01*
X145653834Y-81349500D01*
X144346166Y-81349500D01*
X144343262Y-81349775D01*
X144343252Y-81349775D01*
X144322151Y-81351770D01*
X144322150Y-81351770D01*
X144314631Y-81352481D01*
X144243242Y-81377551D01*
X144195557Y-81394296D01*
X144195555Y-81394297D01*
X144186816Y-81397366D01*
X144179363Y-81402871D01*
X144179361Y-81402872D01*
X144156758Y-81419567D01*
X144077850Y-81477850D01*
X143997366Y-81586816D01*
X143952481Y-81714631D01*
X143951770Y-81722150D01*
X143951770Y-81722151D01*
X143951179Y-81728409D01*
X143949500Y-81746166D01*
X143949500Y-83303834D01*
X135299354Y-83303834D01*
X135815678Y-82858155D01*
X135819654Y-82854866D01*
X136115588Y-82620311D01*
X136545939Y-82279220D01*
X136550076Y-82276080D01*
X137299800Y-81731373D01*
X137304064Y-81728409D01*
X138075966Y-81215559D01*
X138080352Y-81212776D01*
X138558277Y-80923333D01*
X138873030Y-80732713D01*
X138877501Y-80730130D01*
X139689641Y-80283652D01*
X139694214Y-80281262D01*
X140524314Y-79869197D01*
X140528967Y-79867007D01*
X141375605Y-79490060D01*
X141380392Y-79488048D01*
X142242026Y-79146902D01*
X142246895Y-79145091D01*
X143122069Y-78840324D01*
X143127008Y-78838719D01*
X144014195Y-78570861D01*
X144019197Y-78569465D01*
X144386693Y-78475108D01*
X144916815Y-78338996D01*
X144921829Y-78337820D01*
X145488741Y-78217319D01*
X145828301Y-78145144D01*
X145833403Y-78144171D01*
X146747182Y-77989616D01*
X146752306Y-77988859D01*
X147497680Y-77894697D01*
X147671714Y-77872711D01*
X147676879Y-77872168D01*
X148138618Y-77833394D01*
X148600360Y-77794621D01*
X148605538Y-77794295D01*
X149531442Y-77755489D01*
X149536633Y-77755380D01*
X150463367Y-77755380D01*
X150468558Y-77755489D01*
G37*
%TD.AperFunction*%
M02*
| 85,321 | ANTLR | .g4 | 3,355 | 24.430999 | 104 | 0.914099 | Eldalote/Divelamp | 0 | 0 | 0 | GPL-2.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | fa8d99f2528863d1eaf9ed068554276e46f468c38fdcb9971feef8fcf6447d85 | false | false | false | false |
193 | Pytanga.g4 | Diego6699_Pytanga/gramatica/Pytanga.g4 | grammar Pytanga;
INTEIRO: 'inteiro';
REAL: 'flutuante';
CADEIA_CARACTERE: 'cadeia';
LISTA_UNIFORME: 'lista';
LISTA_DIVERSA: 'matriz';
ABRE_CHAVE: '{';
FECHA_CHAVE: '}';
ABRE_COLCHETE: '[';
FECHA_COLCHETE: ']';
ABRE_PARENTESE: '(';
FECHA_PARENTESE: ')';
PONTE_E_VIRGULA: ';';
ASPAS_DUPLAS: '"';
DOIS_PONTOS: ':';
PONTO: '.';
VIRGULA: ',';
MENOR_QUE: '<';
MAIOR_QUE: '>';
MENOR_IGUAL: '<=';
MAIOR_IGUAL: '>=';
IGUAL_IGUAL: '==';
DIFERENTE: '!=';
E_LOGICO: 'and';
OU_LOGICO: 'or';
NAO_LOGICO: 'not';
SOMA: '+';
SUBTRACAO: '-';
MULTIPLICACAO: '*';
DIVISAO: '/';
MODULO: '%';
IGUAL: '=';
SOMA_IGUAL: '+=';
SUBTRACAO_IGUAL: '-=';
MULTIPLICACAO_IGUAL: '*=';
DIVISAO_IGUAL: '/=';
CARACTERE_MINUSCULO: [a-z]+;
CARACTERE_MAIUSCULO: [A-Z]+;
CARACTERE_LITERAL: [a-zA-Z]+;
NUMERO_INTEIRO: [0-9]+;
NUMERO_REAL: [0-9]+ PONTO [0-9]+;
WS: ('\n' | '\t' | '\r' | ' ')+ -> skip;
//definicao de variavel
identificador_variavel: CARACTERE_MINUSCULO CARACTERE_MAIUSCULO*;
variavel_inteiro: INTEIRO definicao_variavel IGUAL NUMERO_INTEIRO PONTE_E_VIRGULA;
variavel_real: REAL definicao_variavel IGUAL NUMERO_REAL PONTE_E_VIRGULA;
variavel_cadeia: CADEIA_CARACTERE definicao_variavel IGUAL ASPAS_DUPLAS cadeia_literal ASPAS_DUPLAS PONTE_E_VIRGULA;
//cadeia de caractere
cadeia_literal: (CARACTERE_MINUSCULO | CARACTERE_MAIUSCULO | NUMERO_INTEIRO | NUMERO_REAL);
comeco
: programa EOF
;
programa
: declaracao+
;
declaracao
: definicao_variavel
;
definicao_variavel
: variavel_inteiro
| variavel_real
| variavel_cadeia
;
| 1,551 | ANTLR | .g4 | 63 | 22.714286 | 116 | 0.691366 | Diego6699/Pytanga | 0 | 1 | 1 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 173749bf43b4f535c30a954e60f01eb1c8794baa08f4a4b5387ace55d108f78a | false | false | false | false |
194 | BPP.g4 | missimer_b-plus-plus/Compiler/grammar/BPP.g4 | /*
[The "BSD licence"]
Copyright (c) 2013 Sam Harwell
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** C 2011 grammar built from the C11 Spec */
grammar BPP;
@parser::header {#pragma warning disable 3021}
@lexer::header {#pragma warning disable 3021}
options
{
language=CSharp_v4_5;
}
primaryExpression
: Identifier
| Constant
| StringLiteral+
| '(' expression ')'
| genericSelection
| '__extension__'? '(' compoundStatement ')' // Blocks (GCC extension)
| '__builtin_va_arg' '(' unaryExpression ',' typeName ')'
| '__builtin_offsetof' '(' typeName ',' unaryExpression ')'
;
genericSelection
: '_Generic' '(' assignmentExpression ',' genericAssocList ')'
;
genericAssocList
: genericAssociation
| genericAssocList ',' genericAssociation
;
genericAssociation
: typeName ':' assignmentExpression
| 'default' ':' assignmentExpression
;
postfixExpression
: primaryExpression
| postfixExpression '[' expression ']'
| postfixExpression '(' argumentExpressionList? ')'
| postfixExpression '.' Identifier
| postfixExpression '->' Identifier
| postfixExpression '++'
| postfixExpression '--'
| '(' typeName ')' '{' initializerList '}'
| '(' typeName ')' '{' initializerList ',' '}'
| '__extension__' '(' typeName ')' '{' initializerList '}'
| '__extension__' '(' typeName ')' '{' initializerList ',' '}'
;
argumentExpressionList
: assignmentExpression
| argumentExpressionList ',' assignmentExpression
;
unaryExpression
: postfixExpression
| '++' unaryExpression
| '--' unaryExpression
| unaryOperator castExpression
| 'sizeof' unaryExpression
| 'sizeof' '(' typeName ')'
| '_Alignof' '(' typeName ')'
| '&&' Identifier // GCC extension address of label
;
unaryOperator
: '&' | '*' | '+' | '-' | '~' | '!'
;
castExpression
: unaryExpression
| '(' typeName ')' castExpression
| '__extension__' '(' typeName ')' castExpression
;
multiplicativeExpression
: castExpression
| multiplicativeExpression '*' castExpression
| multiplicativeExpression '/' castExpression
| multiplicativeExpression '%' castExpression
;
additiveExpression
: multiplicativeExpression
| additiveExpression '+' multiplicativeExpression
| additiveExpression '-' multiplicativeExpression
;
shiftExpression
: additiveExpression
| shiftExpression '<<' additiveExpression
| shiftExpression '>>' additiveExpression
;
relationalExpression
: shiftExpression
| relationalExpression '<' shiftExpression
| relationalExpression '>' shiftExpression
| relationalExpression '<=' shiftExpression
| relationalExpression '>=' shiftExpression
;
equalityExpression
: relationalExpression
| equalityExpression '==' relationalExpression
| equalityExpression '!=' relationalExpression
;
andExpression
: equalityExpression
| andExpression '&' equalityExpression
;
exclusiveOrExpression
: andExpression
| exclusiveOrExpression '^' andExpression
;
inclusiveOrExpression
: exclusiveOrExpression
| inclusiveOrExpression '|' exclusiveOrExpression
;
logicalAndExpression
: inclusiveOrExpression
| logicalAndExpression '&&' inclusiveOrExpression
;
logicalOrExpression
: logicalAndExpression
| logicalOrExpression '||' logicalAndExpression
;
conditionalExpression
: logicalOrExpression ('?' expression ':' conditionalExpression)?
;
assignmentExpression
: conditionalExpression
| unaryExpression assignmentOperator assignmentExpression
;
assignmentOperator
: '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|='
;
expression
: assignmentExpression
| expression ',' assignmentExpression
;
constantExpression
: conditionalExpression
;
declaration
: declarationSpecifiers initDeclaratorList? ';'
| staticAssertDeclaration
;
declarationSpecifiers
: declarationSpecifier+
;
declarationSpecifiers2
: declarationSpecifier+
;
declarationSpecifier
: storageClassSpecifier
| typeSpecifier
| typeQualifier
| functionSpecifier
| alignmentSpecifier
;
initDeclaratorList
: initDeclarator
| initDeclaratorList ',' initDeclarator
;
initDeclarator
: declarator
| declarator '=' initializer
;
storageClassSpecifier
: 'typedef'
| 'extern'
| 'static'
| '_Thread_local'
| 'auto'
| 'register'
;
typeSpecifier
: ('void'
| 'char'
| 'short'
| 'int'
| 'long'
| 'float'
| 'double'
| 'signed'
| 'unsigned'
| '_Bool'
| '_Complex'
| '__m128'
| '__m128d'
| '__m128i')
| '__extension__' '(' ('__m128' | '__m128d' | '__m128i') ')'
| atomicTypeSpecifier
| structOrUnionSpecifier
| enumSpecifier
| typedefName
| '__typeof__' '(' constantExpression ')' // GCC extension
;
structOrUnionSpecifier
: structOrUnion Identifier? '{' structDeclarationList '}'
| structOrUnion Identifier
;
structOrUnion
: 'struct'
| 'union'
;
structDeclarationList
: structDeclaration
| structDeclarationList structDeclaration
;
structDeclaration
: specifierQualifierList structDeclaratorList? ';'
| staticAssertDeclaration
;
specifierQualifierList
: typeSpecifier specifierQualifierList?
| typeQualifier specifierQualifierList?
;
structDeclaratorList
: structDeclarator
| structDeclaratorList ',' structDeclarator
;
structDeclarator
: declarator
| declarator? ':' constantExpression
;
enumSpecifier
: 'enum' Identifier? '{' enumeratorList '}'
| 'enum' Identifier? '{' enumeratorList ',' '}'
| 'enum' Identifier
;
enumeratorList
: enumerator
| enumeratorList ',' enumerator
;
enumerator
: enumerationConstant
| enumerationConstant '=' constantExpression
;
enumerationConstant
: Identifier
;
atomicTypeSpecifier
: '_Atomic' '(' typeName ')'
;
typeQualifier
: 'const'
| 'restrict'
| 'volatile'
| '_Atomic'
;
functionSpecifier
: ('inline'
| '_Noreturn'
| '__inline__' // GCC extension
| '__stdcall')
| gccAttributeSpecifier
| '__declspec' '(' Identifier ')'
;
alignmentSpecifier
: '_Alignas' '(' typeName ')'
| '_Alignas' '(' constantExpression ')'
;
declarator
: pointer? directDeclarator gccDeclaratorExtension*
;
directDeclarator
: Identifier
| '(' declarator ')'
| directDeclarator '[' typeQualifierList? assignmentExpression? ']'
| directDeclarator '[' 'static' typeQualifierList? assignmentExpression ']'
| directDeclarator '[' typeQualifierList 'static' assignmentExpression ']'
| directDeclarator '[' typeQualifierList? '*' ']'
| directDeclarator '(' parameterTypeList ')'
| directDeclarator '(' identifierList? ')'
;
gccDeclaratorExtension
: '__asm' '(' StringLiteral+ ')'
| gccAttributeSpecifier
;
gccAttributeSpecifier
: '__attribute__' '(' '(' gccAttributeList ')' ')'
;
gccAttributeList
: gccAttribute (',' gccAttribute)*
| // empty
;
gccAttribute
: ~(',' | '(' | ')') // relaxed def for "identifier or reserved word"
('(' argumentExpressionList? ')')?
| // empty
;
nestedParenthesesBlock
: ( ~('(' | ')')
| '(' nestedParenthesesBlock ')'
)*
;
pointer
: '*' typeQualifierList?
| '*' typeQualifierList? pointer
| '^' typeQualifierList? // Blocks language extension
| '^' typeQualifierList? pointer // Blocks language extension
;
typeQualifierList
: typeQualifier
| typeQualifierList typeQualifier
;
parameterTypeList
: parameterList
| parameterList ',' '...'
;
parameterList
: parameterDeclaration
| parameterList ',' parameterDeclaration
;
parameterDeclaration
: declarationSpecifiers declarator
| declarationSpecifiers2 abstractDeclarator?
;
identifierList
: Identifier
| identifierList ',' Identifier
;
typeName
: specifierQualifierList abstractDeclarator?
;
abstractDeclarator
: pointer
| pointer? directAbstractDeclarator gccDeclaratorExtension*
;
directAbstractDeclarator
: '(' abstractDeclarator ')' gccDeclaratorExtension*
| '[' typeQualifierList? assignmentExpression? ']'
| '[' 'static' typeQualifierList? assignmentExpression ']'
| '[' typeQualifierList 'static' assignmentExpression ']'
| '[' '*' ']'
| '(' parameterTypeList? ')' gccDeclaratorExtension*
| directAbstractDeclarator '[' typeQualifierList? assignmentExpression? ']'
| directAbstractDeclarator '[' 'static' typeQualifierList? assignmentExpression ']'
| directAbstractDeclarator '[' typeQualifierList 'static' assignmentExpression ']'
| directAbstractDeclarator '[' '*' ']'
| directAbstractDeclarator '(' parameterTypeList? ')' gccDeclaratorExtension*
;
typedefName
: Identifier
;
initializer
: assignmentExpression
| '{' initializerList '}'
| '{' initializerList ',' '}'
;
initializerList
: designation? initializer
| initializerList ',' designation? initializer
;
designation
: designatorList '='
;
designatorList
: designator
| designatorList designator
;
designator
: '[' constantExpression ']'
| '.' Identifier
;
staticAssertDeclaration
: '_Static_assert' '(' constantExpression ',' StringLiteral+ ')' ';'
;
statement
: labeledStatement
| compoundStatement
| expressionStatement
| selectionStatement
| iterationStatement
| jumpStatement
| ('__asm' | '__asm__') ('volatile' | '__volatile__') '(' (logicalOrExpression (',' logicalOrExpression)*)? (':' (logicalOrExpression (',' logicalOrExpression)*)?)* ')' ';'
;
labeledStatement
: Identifier ':' statement
| 'case' constantExpression ':' statement
| 'default' ':' statement
;
compoundStatement
: '{' blockItemList? '}'
;
blockItemList
: blockItem
| blockItemList blockItem
;
blockItem
: declaration
| statement
;
expressionStatement
: expression? ';'
;
selectionStatement
: 'if' '(' expression ')' statement ('else' statement)?
| 'switch' '(' expression ')' statement
;
iterationStatement
: 'while' '(' expression ')' statement
| 'do' statement 'while' '(' expression ')' ';'
| 'for' '(' expression? ';' expression? ';' expression? ')' statement
| 'for' '(' declaration expression? ';' expression? ')' statement
;
jumpStatement
: 'goto' Identifier ';'
| 'continue' ';'
| 'break' ';'
| 'return' expression? ';'
| 'goto' unaryExpression ';' // GCC extension
;
compilationUnit
: translationUnit? EOF
;
translationUnit
: externalDeclaration
| translationUnit externalDeclaration
;
externalDeclaration
: functionDefinition
| declaration
| ';' // stray ;
;
functionDefinition
: declarationSpecifiers? declarator declarationList? compoundStatement
;
declarationList
: declaration
| declarationList declaration
;
Auto : 'auto';
Break : 'break';
Case : 'case';
Char : 'char';
Const : 'const';
Continue : 'continue';
Default : 'default';
Do : 'do';
Double : 'double';
Else : 'else';
Enum : 'enum';
Extern : 'extern';
Float : 'float';
For : 'for';
Goto : 'goto';
If : 'if';
Inline : 'inline';
Int : 'int';
Long : 'long';
Register : 'register';
Restrict : 'restrict';
Return : 'return';
Short : 'short';
Signed : 'signed';
Sizeof : 'sizeof';
Static : 'static';
Struct : 'struct';
Switch : 'switch';
Typedef : 'typedef';
Union : 'union';
Unsigned : 'unsigned';
Void : 'void';
Volatile : 'volatile';
While : 'while';
Alignas : '_Alignas';
Alignof : '_Alignof';
Atomic : '_Atomic';
Bool : '_Bool';
Complex : '_Complex';
Generic : '_Generic';
Imaginary : '_Imaginary';
Noreturn : '_Noreturn';
StaticAssert : '_Static_assert';
ThreadLocal : '_Thread_local';
LeftParen : '(';
RightParen : ')';
LeftBracket : '[';
RightBracket : ']';
LeftBrace : '{';
RightBrace : '}';
Less : '<';
LessEqual : '<=';
Greater : '>';
GreaterEqual : '>=';
LeftShift : '<<';
RightShift : '>>';
Plus : '+';
PlusPlus : '++';
Minus : '-';
MinusMinus : '--';
Star : '*';
Div : '/';
Mod : '%';
And : '&';
Or : '|';
AndAnd : '&&';
OrOr : '||';
Caret : '^';
Not : '!';
Tilde : '~';
Question : '?';
Colon : ':';
Semi : ';';
Comma : ',';
Assign : '=';
// '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|='
StarAssign : '*=';
DivAssign : '/=';
ModAssign : '%=';
PlusAssign : '+=';
MinusAssign : '-=';
LeftShiftAssign : '<<=';
RightShiftAssign : '>>=';
AndAssign : '&=';
XorAssign : '^=';
OrAssign : '|=';
Equal : '==';
NotEqual : '!=';
Arrow : '->';
Dot : '.';
Ellipsis : '...';
Identifier
: IdentifierNondigit
( IdentifierNondigit
| Digit
)*
;
fragment
IdentifierNondigit
: Nondigit
| UniversalCharacterName
//| // other implementation-defined characters...
;
fragment
Nondigit
: [a-zA-Z_]
;
fragment
Digit
: [0-9]
;
fragment
UniversalCharacterName
: '\\u' HexQuad
| '\\U' HexQuad HexQuad
;
fragment
HexQuad
: HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit
;
Constant
: IntegerConstant
| FloatingConstant
//| EnumerationConstant
| CharacterConstant
;
fragment
IntegerConstant
: DecimalConstant IntegerSuffix?
| OctalConstant IntegerSuffix?
| HexadecimalConstant IntegerSuffix?
| BinaryConstant
;
fragment
BinaryConstant
: '0' [bB] [0-1]+
;
fragment
DecimalConstant
: NonzeroDigit Digit*
;
fragment
OctalConstant
: '0' OctalDigit*
;
fragment
HexadecimalConstant
: HexadecimalPrefix HexadecimalDigit+
;
fragment
HexadecimalPrefix
: '0' [xX]
;
fragment
NonzeroDigit
: [1-9]
;
fragment
OctalDigit
: [0-7]
;
fragment
HexadecimalDigit
: [0-9a-fA-F]
;
fragment
IntegerSuffix
: UnsignedSuffix LongSuffix?
| UnsignedSuffix LongLongSuffix
| LongSuffix UnsignedSuffix?
| LongLongSuffix UnsignedSuffix?
;
fragment
UnsignedSuffix
: [uU]
;
fragment
LongSuffix
: [lL]
;
fragment
LongLongSuffix
: 'll' | 'LL'
;
fragment
FloatingConstant
: DecimalFloatingConstant
| HexadecimalFloatingConstant
;
fragment
DecimalFloatingConstant
: FractionalConstant ExponentPart? FloatingSuffix?
| DigitSequence ExponentPart FloatingSuffix?
;
fragment
HexadecimalFloatingConstant
: HexadecimalPrefix HexadecimalFractionalConstant BinaryExponentPart FloatingSuffix?
| HexadecimalPrefix HexadecimalDigitSequence BinaryExponentPart FloatingSuffix?
;
fragment
FractionalConstant
: DigitSequence? '.' DigitSequence
| DigitSequence '.'
;
fragment
ExponentPart
: 'e' Sign? DigitSequence
| 'E' Sign? DigitSequence
;
fragment
Sign
: '+' | '-'
;
fragment
DigitSequence
: Digit+
;
fragment
HexadecimalFractionalConstant
: HexadecimalDigitSequence? '.' HexadecimalDigitSequence
| HexadecimalDigitSequence '.'
;
fragment
BinaryExponentPart
: 'p' Sign? DigitSequence
| 'P' Sign? DigitSequence
;
fragment
HexadecimalDigitSequence
: HexadecimalDigit+
;
fragment
FloatingSuffix
: 'f' | 'l' | 'F' | 'L'
;
fragment
CharacterConstant
: '\'' CCharSequence '\''
| 'L\'' CCharSequence '\''
| 'u\'' CCharSequence '\''
| 'U\'' CCharSequence '\''
;
fragment
CCharSequence
: CChar+
;
fragment
CChar
: ~['\\\r\n]
| EscapeSequence
;
fragment
EscapeSequence
: SimpleEscapeSequence
| OctalEscapeSequence
| HexadecimalEscapeSequence
| UniversalCharacterName
;
fragment
SimpleEscapeSequence
: '\\' ['"?abfnrtv\\]
;
fragment
OctalEscapeSequence
: '\\' OctalDigit
| '\\' OctalDigit OctalDigit
| '\\' OctalDigit OctalDigit OctalDigit
;
fragment
HexadecimalEscapeSequence
: '\\x' HexadecimalDigit+
;
StringLiteral
: EncodingPrefix? '"' SCharSequence? '"'
;
fragment
EncodingPrefix
: 'u8'
| 'u'
| 'U'
| 'L'
;
fragment
SCharSequence
: SChar+
;
fragment
SChar
: ~["\\\r\n]
| EscapeSequence
| '\\\n' // Added line
| '\\\r\n' // Added line
;
ComplexDefine
: '#' Whitespace? 'define' ~[#]*
-> skip
;
// ignore the following asm blocks:
/*
asm
{
mfspr x, 286;
}
*/
AsmBlock
: 'asm' ~['{']* '{' ~['}']* '}'
-> skip
;
// ignore the lines generated by c preprocessor
// sample line : '#line 1 "/home/dm/files/dk1.h" 1'
LineAfterPreprocessing
: '#line' Whitespace* ~[\r\n]*
-> skip
;
LineDirective
: '#' Whitespace? DecimalConstant Whitespace? StringLiteral ~[\r\n]*
-> skip
;
PragmaDirective
: '#' Whitespace? 'pragma' Whitespace ~[\r\n]*
-> skip
;
Whitespace
: [ \t]+
-> skip
;
Newline
: ( '\r' '\n'?
| '\n'
)
-> skip
;
BlockComment
: '/*' .*? '*/'
-> skip
;
LineComment
: '//' ~[\r\n]*
-> skip
;
| 19,348 | ANTLR | .g4 | 784 | 20.811224 | 178 | 0.641526 | missimer/b-plus-plus | 0 | 0 | 0 | GPL-2.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 1ea122e2891131bcb33fca505b13adfb754c5ee84edf6edf1d66da57f3d86ba9 | false | false | false | false |
195 | vb.g4 | steave6_vbtranslator/vbgrammer/src/main/vbgrammer/vb.g4 | grammar vb;
start: Start;
// 2. Lexical grammar
LogicalLineStart
: LogicalLine*
;
LogicalLine
: LogicalLineElement* Comment? LineTerminator
;
LogicalLineElement
: WhiteSpace
| LineContinuation
| Token
;
Token
: Identifier
| Keyword
| Literal
| Separator
| Operator
;
Character:
'<Any Unicode character except a LineTerminator>'
;
LineTerminator
: '<Unicode 0x00D>'
| '<Unicode 0x00A>'
| '<CR>'
| '<LF>'
| '<Unicode 0x2028>'
| '<Unicode 0x2029>'
;
LineContinuation
: WhiteSpace '_' WhiteSpace* LineTerminator
;
Comma
: ',' LineTerminator?
;
Period
: '.' LineTerminator?
;
OpenParenthesis
: '(' LineTerminator?
;
CloseParenthesis
: LineTerminator? ')'
;
OpenCurlyBrace
: '{' LineTerminator?
;
CloseCurlyBrace
: LineTerminator? '}'
;
Equals
: '=' LineTerminator?
;
ColonEquals
: ':' '=' LineTerminator?
;
WhiteSpace
: '<Unicode class Zs>'
| '<Unicode Tab 0x0009>'
;
Comment
: CommentMarker Character*
;
CommentMarker
: SingleQuoteCharacter
| 'REM'
;
SingleQuoteCharacter
: '\''
| '<Unicode 0x2018>'
| '<Unicode 0x2019>'
;
Identifier
: NonEscapedIdentifier TypeCharacter?
| Keyword TypeCharacter
| EscapedIdentifier
;
NonEscapedIdentifier
: '<Any IdentifierName but not Keyword>'
;
EscapedIdentifier
: '[' IdentifierName ']'
;
IdentifierName
: IdentifierStart IdentifierCharacter*
;
IdentifierStart
: AlphaCharacter
| UnderscoreCharacter IdentifierCharacter
;
IdentifierCharacter
: UnderscoreCharacter
| AlphaCharacter
| NumericCharacter
| CombiningCharacter
| FormattingCharacter
;
AlphaCharacter
: '<Unicode classes Lu,Ll,Lt,Lm,Lo,Nl>'
;
NumericCharacter
: '<Unicode decimal digit class Nd>'
;
CombiningCharacter
: '<Unicode combining character classes Mn, Mc>'
;
FormattingCharacter
: '<Unicode formatting character class Cf>'
;
UnderscoreCharacter
: '<Unicode connection character class Pc>'
;
IdentifierOrKeyword
: Identifier
| Keyword
;
TypeCharacter
: IntegerTypeCharacter
| LongTypeCharacter
| DecimalTypeCharacter
| SingleTypeCharacter
| DoubleTypeCharacter
| StringTypeCharacter
;
IntegerTypeCharacter
: '%'
;
LongTypeCharacter
: '&'
;
DecimalTypeCharacter
: '@'
;
SingleTypeCharacter
: '!'
;
DoubleTypeCharacter
: '#'
;
StringTypeCharacter
: '$'
;
Keyword
: 'AddHandler' | 'AddressOf' | 'Alias' | 'And'
| 'AndAlso' | 'As' | 'Boolean' | 'ByRef'
| 'Byte' | 'ByVal' | 'Call' | 'Case'
| 'Catch' | 'CBool' | 'CByte' | 'CChar'
| 'CDate' | 'CDbl' | 'CDec' | 'Char'
| 'CInt' | 'Class' | 'CLng' | 'CObj'
| 'Const' | 'Continue' | 'CSByte' | 'CShort'
| 'CSng' | 'CStr' | 'CType' | 'CUInt'
| 'CULng' | 'CUShort' | 'Date' | 'Decimal'
| 'Declare' | 'Default' | 'Delegate' | 'Dim'
| 'DirectCast' | 'Do' | 'Double' | 'Each'
| 'Else' | 'ElseIf' | 'End' | 'EndIf'
| 'Enum' | 'Erase' | 'Error' | 'Event'
| 'Exit' | 'False' | 'Finally' | 'For'
| 'Friend' | 'Function' | 'Get' | 'GetType'
| 'GetXmlNamespace' | 'Global' | 'GoSub' | 'GoTo'
| 'Handles' | 'If' | 'Implements' | 'Imports'
| 'In' | 'Inherits' | 'Integer' | 'Interface'
| 'Is' | 'IsNot' | 'Let' | 'Lib'
| 'Like' | 'Long' | 'Loop' | 'Me'
| 'Mod' | 'Module' | 'MustInherit' | 'MustOverride'
| 'MyBase' | 'MyClass' | 'Namespace' | 'Narrowing'
| 'New' | 'Next' | 'Not' | 'Nothing'
| 'NotInheritable' | 'NotOverridable' | 'Object' | 'Of'
| 'On' | 'Operator' | 'Option' | 'Optional'
| 'Or' | 'OrElse' | 'Overloads' | 'Overridable'
| 'Overrides' | 'ParamArray' | 'Partial' | 'Private'
| 'Property' | 'Protected' | 'Public' | 'RaiseEvent'
| 'ReadOnly' | 'ReDim' | 'REM' | 'RemoveHandler'
| 'Resume' | 'Return' | 'SByte' | 'Select'
| 'Set' | 'Shadows' | 'Shared' | 'Short'
| 'Single' | 'Static' | 'Step' | 'Stop'
| 'String' | 'Structure' | 'Sub' | 'SyncLock'
| 'Then' | 'Throw' | 'To' | 'True'
| 'Try' | 'TryCast' | 'TypeOf' | 'UInteger'
| 'ULong' | 'UShort' | 'Using' | 'Variant'
| 'Wend' | 'When' | 'While' | 'Widening'
| 'With' | 'WithEvents' | 'WriteOnly' | 'Xor'
;
Literal
: BooleanLiteral
| IntegerLiteral
| FloatingPointLiteral
| StringLiteral
| CharacterLiteral
| DateLiteral
| Nothing
;
BooleanLiteral
: 'True' | 'False'
;
IntegerLiteral
: IntegralLiteralValue IntegralTypeCharacter?
;
IntegralLiteralValue
: IntLiteral
| HexLiteral
| OctalLiteral
;
IntegralTypeCharacter
: ShortCharacter
| UnsignedShortCharacter
| IntegerCharacter
| UnsignedIntegerCharacter
| LongCharacter
| UnsignedLongCharacter
| IntegerTypeCharacter
| LongTypeCharacter
;
ShortCharacter
: 'S'
;
UnsignedShortCharacter
: 'US'
;
IntegerCharacter
: 'I'
;
UnsignedIntegerCharacter
: 'UI'
;
LongCharacter
: 'L'
;
UnsignedLongCharacter
: 'UL'
;
IntLiteral
: Digit+
;
HexLiteral
: '&' 'H' HexDigit+
;
OctalLiteral
: '&' 'O' OctalDigit+
;
Digit
: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
;
HexDigit
: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
;
OctalDigit
: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7'
;
FloatingPointLiteral
: FloatingPointLiteralValue FloatingPointTypeCharacter?
| IntLiteral FloatingPointTypeCharacter
;
FloatingPointTypeCharacter
: SingleCharacter
| DoubleCharacter
| DecimalCharacter
| SingleTypeCharacter
| DoubleTypeCharacter
| DecimalTypeCharacter
;
SingleCharacter
: 'F'
;
DoubleCharacter
: 'R'
;
DecimalCharacter
: 'D'
;
FloatingPointLiteralValue
: IntLiteral '.' IntLiteral Exponent?
| '.' IntLiteral Exponent?
| IntLiteral Exponent
;
Exponent
: 'E' Sign? IntLiteral
;
Sign
: '+'
| '-'
;
StringLiteral
: DoubleQuoteCharacter StringCharacter* DoubleQuoteCharacter
;
DoubleQuoteCharacter
: '"'
| '<unicode left double-quote 0x201c>'
| '<unicode right double-quote 0x201D>'
;
StringCharacter
: '<Any character except DoubleQuoteCharacter>'
| DoubleQuoteCharacter DoubleQuoteCharacter
;
CharacterLiteral
: DoubleQuoteCharacter StringCharacter DoubleQuoteCharacter 'C'
;
DateLiteral
: '#' WhiteSpace* DateOrTime WhiteSpace* '#'
;
DateOrTime
: DateValue WhiteSpace+ TimeValue
| DateValue
| TimeValue
;
DateValue
: MonthValue '/' DayValue '/' YearValue
| MonthValue '-' DayValue '-' YearValue
;
TimeValue
: HourValue ':' MinuteValue ( ':' SecondValue )? WhiteSpace* AMPM?
| HourValue WhiteSpace* AMPM
;
MonthValue
: IntLiteral
;
DayValue
: IntLiteral
;
YearValue
: IntLiteral
;
HourValue
: IntLiteral
;
MinuteValue
: IntLiteral
;
SecondValue
: IntLiteral
;
AMPM
: 'AM' | 'PM'
;
ElseIf
: 'ElseIf'
| 'Else' 'If'
;
Nothing
: 'Nothing'
;
Separator
: '(' | ')' | '{' | '}' | '!' | '#' | ',' | '.' | ':' | '?'
;
Operator
: '&' | '*' | '+' | '-' | '/' | '\\' | '^' | '<' | '=' | '>'
;
// 3. Preprocessing Directives
CCStart
: CCStatement*
;
CCStatement
: CCConstantDeclaration
| CCIfGroup
| LogicalLine
;
CCExpression
: LiteralExpression
| CCParenthesizedExpression
| CCSimpleNameExpression
| CCCastExpression
| CCOperatorExpression
| CCConditionalExpression
;
CCParenthesizedExpression
: '(' CCExpression ')'
;
CCSimpleNameExpression
: Identifier
;
CCCastExpression
: 'DirectCast' '(' CCExpression ',' TypeName ')'
| 'TryCast' '(' CCExpression ',' TypeName ')'
| 'CType' '(' CCExpression ',' TypeName ')'
| CastTarget '(' CCExpression ')'
;
CCOperatorExpression
: CCUnaryOperator CCExpression
| CCExpression CCBinaryOperator CCExpression
;
CCUnaryOperator
: '+' | '-' | 'Not'
;
CCBinaryOperator
: '+' | '-' | '*' | '/' | '\\' | 'Mod' | '^' | '='
| '<' '>' | '<' | '>' | '<' '=' | '>' '=' | '&'
| 'And' | 'Or' | 'Xor' | 'AndAlso' | 'OrElse'
| '<' '<' | '>' '>'
;
CCConditionalExpression
: 'If' '(' CCExpression ',' CCExpression ',' CCExpression ')'
| 'If' '(' CCExpression ',' CCExpression ')'
;
CCConstantDeclaration
: '#' 'Const' Identifier '=' CCExpression LineTerminator
;
CCIfGroup
: '#' 'If' CCExpression 'Then'? LineTerminator CCStatement*
CCElseIfGroup* CCElseGroup? '#' 'End' 'If' LineTerminator
;
CCElseIfGroup
: '#' ElseIf CCExpression 'Then'? LineTerminator CCStatement*
;
CCElseGroup
: '#' 'Else' LineTerminator CCStatement*
;
ESDStart
: ExternalSourceStatement*
;
ExternalSourceStatement
: ExternalSourceGroup
| LogicalLine
;
ExternalSourceGroup
: '#' 'ExternalSource' '(' StringLiteral ',' IntLiteral ')' LineTerminator
LogicalLine* '#' 'End' 'ExternalSource' LineTerminator
;
RegionStart
: RegionStatement*
;
RegionStatement
: RegionGroup
| LogicalLine
;
RegionGroup
: '#' 'Region' StringLiteral LineTerminator
RegionStatement*
'#' 'End' 'Region' LineTerminator
;
ExternalChecksumStart
: ExternalChecksumStatement*
;
ExternalChecksumStatement
: '#' 'ExternalChecksum' '('
StringLiteral ',' StringLiteral ',' StringLiteral
')' LineTerminator
;
// 4. General concepts
AccessModifier
: 'Public'
| 'Protected'
| 'Friend'
| 'Private'
| 'Protected' 'Friend'
;
TypeParameterList
: OpenParenthesis 'Of' TypeParameter ( Comma TypeParameter )* CloseParenthesis
;
TypeParameter
: VarianceModifier? Identifier TypeParameterConstraints?
;
VarianceModifier
: 'In' | 'Out'
;
TypeParameterConstraints
: 'As' Constraint
| 'As' OpenCurlyBrace ConstraintList CloseCurlyBrace
;
ConstraintList
: Constraint ( Comma Constraint )*
;
Constraint
: TypeName
| 'New'
| 'Structure'
| 'Class'
;
// 5. Attributes
Attributes
: AttributeBlock+
;
AttributeBlock
: LineTerminator? '<' AttributeList LineTerminator? '>' LineTerminator?
;
AttributeList
: Attribute ( Comma Attribute )*
;
Attribute
: ( AttributeModifier ':' )? SimpleTypeName
( OpenParenthesis AttributeArguments? CloseParenthesis )?
;
AttributeModifier
: 'Assembly' | 'Module'
;
AttributeArguments
: AttributePositionalArgumentList
| AttributePositionalArgumentList Comma VariablePropertyInitializerList
| VariablePropertyInitializerList
;
AttributePositionalArgumentList
: AttributeArgumentExpression? ( Comma AttributeArgumentExpression? )*
;
VariablePropertyInitializerList
: VariablePropertyInitializer ( Comma VariablePropertyInitializer )*
;
VariablePropertyInitializer
: IdentifierOrKeyword ColonEquals AttributeArgumentExpression
;
AttributeArgumentExpression
: ConstantExpression
| GetTypeExpression
| ArrayExpression
;
// 6. Source files and namespaces
Start
: OptionStatement* ImportsStatement* AttributesStatement* NamespaceMemberDeclaration*
;
StatementTerminator
: LineTerminator
| ':'
;
AttributesStatement
: Attributes StatementTerminator
;
OptionStatement
: OptionExplicitStatement
| OptionStrictStatement
| OptionCompareStatement
| OptionInferStatement
;
OptionExplicitStatement
: 'Option' 'Explicit' OnOff? StatementTerminator
;
OnOff
: 'On' | 'Off'
;
OptionStrictStatement
: 'Option' 'Strict' OnOff? StatementTerminator
;
OptionCompareStatement
: 'Option' 'Compare' CompareOption StatementTerminator
;
CompareOption
: 'Binary' | 'Text'
;
OptionInferStatement
: 'Option' 'Infer' OnOff? StatementTerminator
;
ImportsStatement
: 'Imports' ImportsClauses StatementTerminator
;
ImportsClauses
: ImportsClause ( Comma ImportsClause )*
;
ImportsClause
: AliasImportsClause
| MembersImportsClause
| XMLNamespaceImportsClause
;
AliasImportsClause
: Identifier Equals TypeName
;
MembersImportsClause
: TypeName
;
XMLNamespaceImportsClause
: '<' XMLNamespaceAttributeName XMLWhitespace? Equals XMLWhitespace?
XMLNamespaceValue '>'
;
XMLNamespaceValue
: DoubleQuoteCharacter XMLAttributeDoubleQuoteValueCharacter* DoubleQuoteCharacter
| SingleQuoteCharacter XMLAttributeSingleQuoteValueCharacter* SingleQuoteCharacter
;
NamespaceDeclaration
: 'Namespace' NamespaceName StatementTerminator
NamespaceMemberDeclaration*
'End' 'Namespace' StatementTerminator
;
NamespaceName
: RelativeNamespaceName
| 'Global'
| 'Global' '.' RelativeNamespaceName
;
RelativeNamespaceName
: Identifier ( Period IdentifierOrKeyword )*
;
NamespaceMemberDeclaration
: NamespaceDeclaration
| TypeDeclaration
;
TypeDeclaration
: ModuleDeclaration
| NonModuleDeclaration
;
NonModuleDeclaration
: EnumDeclaration
| StructureDeclaration
| InterfaceDeclaration
| ClassDeclaration
| DelegateDeclaration
;
// 7. Types
TypeName
: ArrayTypeName
| NonArrayTypeName
;
NonArrayTypeName
: SimpleTypeName
| NullableTypeName
;
SimpleTypeName
: QualifiedTypeName
| BuiltInTypeName
;
QualifiedTypeName
: Identifier TypeArguments? (Period IdentifierOrKeyword TypeArguments?)*
| 'Global' Period IdentifierOrKeyword TypeArguments?
(Period IdentifierOrKeyword TypeArguments?)*
;
TypeArguments
: OpenParenthesis 'Of' TypeArgumentList CloseParenthesis
;
TypeArgumentList
: TypeName ( Comma TypeName )*
;
BuiltInTypeName
: 'Object'
| PrimitiveTypeName
;
TypeModifier
: AccessModifier
| 'Shadows'
;
IdentifierModifiers
: NullableNameModifier? ArrayNameModifier?
;
NullableTypeName
: NonArrayTypeName '?'
;
NullableNameModifier
: '?'
;
TypeImplementsClause
: 'Implements' TypeImplements StatementTerminator
;
TypeImplements
: NonArrayTypeName ( Comma NonArrayTypeName )*
;
PrimitiveTypeName
: NumericTypeName
| 'Boolean'
| 'Date'
| 'Char'
| 'String'
;
NumericTypeName
: IntegralTypeName
| FloatingPointTypeName
| 'Decimal'
;
IntegralTypeName
: 'Byte' | 'SByte' | 'UShort' | 'Short' | 'UInteger'
| 'Integer' | 'ULong' | 'Long'
;
FloatingPointTypeName
: 'Single' | 'Double'
;
EnumDeclaration
: Attributes? TypeModifier* 'Enum' Identifier
( 'As' NonArrayTypeName )? StatementTerminator
EnumMemberDeclaration+
'End' 'Enum' StatementTerminator
;
EnumMemberDeclaration
: Attributes? Identifier ( Equals ConstantExpression )? StatementTerminator
;
ClassDeclaration
: Attributes? ClassModifier* 'Class' Identifier TypeParameterList? StatementTerminator
ClassBase?
TypeImplementsClause*
ClassMemberDeclaration*
'End' 'Class' StatementTerminator
;
ClassModifier
: TypeModifier
| 'MustInherit'
| 'NotInheritable'
| 'Partial'
;
ClassBase
: 'Inherits' NonArrayTypeName StatementTerminator
;
ClassMemberDeclaration
: NonModuleDeclaration
| EventMemberDeclaration
| VariableMemberDeclaration
| ConstantMemberDeclaration
| MethodMemberDeclaration
| PropertyMemberDeclaration
| ConstructorMemberDeclaration
| OperatorDeclaration
;
StructureDeclaration
: Attributes? StructureModifier* 'Structure' Identifier
TypeParameterList? StatementTerminator
TypeImplementsClause*
StructMemberDeclaration*
'End' 'Structure' StatementTerminator
;
StructureModifier
: TypeModifier
| 'Partial'
;
StructMemberDeclaration
: NonModuleDeclaration
| VariableMemberDeclaration
| ConstantMemberDeclaration
| EventMemberDeclaration
| MethodMemberDeclaration
| PropertyMemberDeclaration
| ConstructorMemberDeclaration
| OperatorDeclaration
;
ModuleDeclaration
: Attributes? TypeModifier* 'Module' Identifier StatementTerminator
ModuleMemberDeclaration*
'End' 'Module' StatementTerminator
;
ModuleMemberDeclaration
: NonModuleDeclaration
| VariableMemberDeclaration
| ConstantMemberDeclaration
| EventMemberDeclaration
| MethodMemberDeclaration
| PropertyMemberDeclaration
| ConstructorMemberDeclaration
;
InterfaceDeclaration
: Attributes? TypeModifier* 'Interface' Identifier
TypeParameterList? StatementTerminator
InterfaceBase*
InterfaceMemberDeclaration*
'End' 'Interface' StatementTerminator
;
InterfaceBase
: 'Inherits' InterfaceBases StatementTerminator
;
InterfaceBases
: NonArrayTypeName ( Comma NonArrayTypeName )*
;
InterfaceMemberDeclaration
: NonModuleDeclaration
| InterfaceEventMemberDeclaration
| InterfaceMethodMemberDeclaration
| InterfacePropertyMemberDeclaration
;
ArrayTypeName
: NonArrayTypeName ArrayTypeModifiers
;
ArrayTypeModifiers
: ArrayTypeModifier+
;
ArrayTypeModifier
: OpenParenthesis RankList? CloseParenthesis
;
RankList
: Comma*
;
ArrayNameModifier
: ArrayTypeModifiers
| ArraySizeInitializationModifier
;
DelegateDeclaration
: Attributes? TypeModifier* 'Delegate' MethodSignature StatementTerminator
;
MethodSignature
: SubSignature
| FunctionSignature
;
// 9. Type members
ImplementsClause
: ( 'Implements' ImplementsList )?
;
ImplementsList
: InterfaceMemberSpecifier ( Comma InterfaceMemberSpecifier )*
;
InterfaceMemberSpecifier
: NonArrayTypeName Period IdentifierOrKeyword
;
MethodMemberDeclaration
: MethodDeclaration
| ExternalMethodDeclaration
;
InterfaceMethodMemberDeclaration
: InterfaceMethodDeclaration
;
MethodDeclaration
: SubDeclaration
| MustOverrideSubDeclaration
| FunctionDeclaration
| MustOverrideFunctionDeclaration
;
InterfaceMethodDeclaration
: InterfaceSubDeclaration
| InterfaceFunctionDeclaration
;
SubSignature
: 'Sub' Identifier TypeParameterList?
( OpenParenthesis ParameterList? CloseParenthesis )?
;
FunctionSignature
: 'Function' Identifier TypeParameterList?
( OpenParenthesis ParameterList? CloseParenthesis )?
( 'As' Attributes? TypeName )?
;
SubDeclaration
: Attributes? ProcedureModifier* SubSignature
HandlesOrImplements? LineTerminator
Block
'End' 'Sub' StatementTerminator
;
MustOverrideSubDeclaration
: Attributes? MustOverrideProcedureModifier+ SubSignature
HandlesOrImplements? StatementTerminator
;
InterfaceSubDeclaration
: Attributes? InterfaceProcedureModifier* SubSignature StatementTerminator
;
FunctionDeclaration
: Attributes? ProcedureModifier* FunctionSignature
HandlesOrImplements? LineTerminator
Block
'End' 'Function' StatementTerminator
;
MustOverrideFunctionDeclaration
: Attributes? MustOverrideProcedureModifier+ FunctionSignature
HandlesOrImplements? StatementTerminator
;
InterfaceFunctionDeclaration
: Attributes? InterfaceProcedureModifier* FunctionSignature StatementTerminator
;
ProcedureModifier
: AccessModifier | 'Shadows' | 'Shared' | 'Overridable' | 'NotOverridable' | 'Overrides'
| 'Overloads' | 'Partial' | 'Iterator' | 'Async'
;
MustOverrideProcedureModifier
: ProcedureModifier
| 'MustOverride'
;
InterfaceProcedureModifier
: 'Shadows' | 'Overloads'
;
HandlesOrImplements
: HandlesClause
| ImplementsClause
;
ExternalMethodDeclaration
: ExternalSubDeclaration
| ExternalFunctionDeclaration
;
ExternalSubDeclaration
: Attributes? ExternalMethodModifier* 'Declare' CharsetModifier? 'Sub'
Identifier LibraryClause AliasClause?
( OpenParenthesis ParameterList? CloseParenthesis )? StatementTerminator
;
ExternalFunctionDeclaration
: Attributes? ExternalMethodModifier* 'Declare' CharsetModifier? 'Function'
Identifier LibraryClause AliasClause?
( OpenParenthesis ParameterList? CloseParenthesis )?
( 'As' Attributes? TypeName )?
StatementTerminator
;
ExternalMethodModifier
: AccessModifier
| 'Shadows'
| 'Overloads'
;
CharsetModifier
: 'Ansi' | 'Unicode' | 'Auto'
;
LibraryClause
: 'Lib' StringLiteral
;
AliasClause
: 'Alias' StringLiteral
;
ParameterList
: Parameter ( Comma Parameter )*
;
Parameter
: Attributes? ParameterModifier* ParameterIdentifier ( 'As' TypeName )?
( Equals ConstantExpression )?
;
ParameterModifier
: 'ByVal' | 'ByRef' | 'Optional' | 'ParamArray'
;
ParameterIdentifier
: Identifier IdentifierModifiers
;
HandlesClause
: ( 'Handles' EventHandlesList )?
;
EventHandlesList
: EventMemberSpecifier ( Comma EventMemberSpecifier )*
;
EventMemberSpecifier
: Identifier Period IdentifierOrKeyword
| 'MyBase' Period IdentifierOrKeyword
| 'MyClass' Period IdentifierOrKeyword
| 'Me' Period IdentifierOrKeyword
;
ConstructorMemberDeclaration
: Attributes? ConstructorModifier* 'Sub' 'New'
( OpenParenthesis ParameterList? CloseParenthesis )? LineTerminator
Block?
'End' 'Sub' StatementTerminator
;
ConstructorModifier
: AccessModifier
| 'Shared'
;
EventMemberDeclaration
: RegularEventMemberDeclaration
| CustomEventMemberDeclaration
;
RegularEventMemberDeclaration
: Attributes? EventModifiers* 'Event'
Identifier ParametersOrType ImplementsClause? StatementTerminator
;
InterfaceEventMemberDeclaration
: Attributes? InterfaceEventModifiers* 'Event'
Identifier ParametersOrType StatementTerminator
;
ParametersOrType
: ( OpenParenthesis ParameterList? CloseParenthesis )?
| 'As' NonArrayTypeName
;
EventModifiers
: AccessModifier
| 'Shadows'
| 'Shared'
;
InterfaceEventModifiers
: 'Shadows'
;
CustomEventMemberDeclaration
: Attributes? EventModifiers* 'Custom' 'Event'
Identifier 'As' TypeName ImplementsClause? StatementTerminator
EventAccessorDeclaration+
'End' 'Event' StatementTerminator
;
EventAccessorDeclaration
: AddHandlerDeclaration
| RemoveHandlerDeclaration
| RaiseEventDeclaration
;
AddHandlerDeclaration
: Attributes? 'AddHandler'
OpenParenthesis ParameterList CloseParenthesis LineTerminator
Block?
'End' 'AddHandler' StatementTerminator
;
RemoveHandlerDeclaration
: Attributes? 'RemoveHandler'
OpenParenthesis ParameterList CloseParenthesis LineTerminator
Block?
'End' 'RemoveHandler' StatementTerminator
;
RaiseEventDeclaration
: Attributes? 'RaiseEvent'
OpenParenthesis ParameterList CloseParenthesis LineTerminator
Block?
'End' 'RaiseEvent' StatementTerminator
;
ConstantMemberDeclaration
: Attributes? ConstantModifier* 'Const' ConstantDeclarators StatementTerminator
;
ConstantModifier
: AccessModifier
| 'Shadows'
;
ConstantDeclarators
: ConstantDeclarator ( Comma ConstantDeclarator )*
;
ConstantDeclarator
: Identifier ( 'As' TypeName )? Equals ConstantExpression StatementTerminator
;
VariableMemberDeclaration
: Attributes? VariableModifier+ VariableDeclarators StatementTerminator
;
VariableModifier
: AccessModifier
| 'Shadows'
| 'Shared'
| 'ReadOnly'
| 'WithEvents'
| 'Dim'
;
VariableDeclarators
: VariableDeclarator ( Comma VariableDeclarator )*
;
VariableDeclarator
: VariableIdentifiers 'As' ObjectCreationExpression
| VariableIdentifiers ( 'As' TypeName )? ( Equals Expression )?
;
VariableIdentifiers
: VariableIdentifier ( Comma VariableIdentifier )*
;
VariableIdentifier
: Identifier IdentifierModifiers
;
ArraySizeInitializationModifier
: OpenParenthesis BoundList CloseParenthesis ArrayTypeModifiers?
;
BoundList
: Bound ( Comma Bound )*
;
Bound
: Expression
| '0' 'To' Expression
;
PropertyMemberDeclaration
: RegularPropertyMemberDeclaration
| MustOverridePropertyMemberDeclaration
| AutoPropertyMemberDeclaration
;
PropertySignature
: 'Property'
Identifier ( OpenParenthesis ParameterList? CloseParenthesis )?
( 'As' Attributes? TypeName )?
;
RegularPropertyMemberDeclaration
: Attributes? PropertyModifier* PropertySignature
ImplementsClause? LineTerminator
PropertyAccessorDeclaration+
'End' 'Property' StatementTerminator
;
MustOverridePropertyMemberDeclaration
: Attributes? MustOverridePropertyModifier+ PropertySignature
ImplementsClause? StatementTerminator
;
AutoPropertyMemberDeclaration
: Attributes? AutoPropertyModifier* 'Property' Identifier
( OpenParenthesis ParameterList? CloseParenthesis )?
( 'As' Attributes? TypeName )? ( Equals Expression )?
ImplementsClause? LineTerminator
| Attributes? AutoPropertyModifier* 'Property' Identifier
( OpenParenthesis ParameterList? CloseParenthesis )?
'As' Attributes? 'New'
( NonArrayTypeName ( OpenParenthesis ArgumentList? CloseParenthesis )? )?
ObjectCreationExpressionInitializer?
ImplementsClause? LineTerminator
;
InterfacePropertyMemberDeclaration
: Attributes? InterfacePropertyModifier* PropertySignature StatementTerminator
;
AutoPropertyModifier
: AccessModifier
| 'Shadows'
| 'Shared'
| 'Overridable'
| 'NotOverridable'
| 'Overrides'
| 'Overloads'
;
PropertyModifier
: AutoPropertyModifier
| 'Default'
| 'ReadOnly'
| 'WriteOnly'
| 'Iterator'
;
MustOverridePropertyModifier
: PropertyModifier
| 'MustOverride'
;
InterfacePropertyModifier
: 'Shadows'
| 'Overloads'
| 'Default'
| 'ReadOnly'
| 'WriteOnly'
;
PropertyAccessorDeclaration
: PropertyGetDeclaration
| PropertySetDeclaration
;
PropertyGetDeclaration
: Attributes? AccessModifier? 'Get' LineTerminator
Block?
'End' 'Get' StatementTerminator
;
PropertySetDeclaration
: Attributes? AccessModifier? 'Set'
( OpenParenthesis ParameterList? CloseParenthesis )? LineTerminator
Block?
'End' 'Set' StatementTerminator
;
OperatorDeclaration
: Attributes? OperatorModifier* 'Operator' OverloadableOperator
OpenParenthesis ParameterList CloseParenthesis
( 'As' Attributes? TypeName )? LineTerminator
Block?
'End' 'Operator' StatementTerminator
;
OperatorModifier
: 'Public' | 'Shared' | 'Overloads' | 'Shadows' | 'Widening' | 'Narrowing'
;
OverloadableOperator
: '+' | '-' | '*' | '/' | '\\' | '&' | 'Like' | 'Mod' | 'And' | 'Or' | 'Xor'
| '^' | '<' '<' | '>' '>' | '=' | '<' '>' | '>' | '<' | '>' '=' | '<' '='
| 'Not' | 'IsTrue' | 'IsFalse' | 'CType'
;
// 10. Statements
Statement
: LabelDeclarationStatement
| LocalDeclarationStatement
| WithStatement
| SyncLockStatement
| EventStatement
| AssignmentStatement
| InvocationStatement
| ConditionalStatement
| LoopStatement
| ErrorHandlingStatement
| BranchStatement
| ArrayHandlingStatement
| UsingStatement
| AwaitStatement
| YieldStatement
;
Block
: Statements*
;
LabelDeclarationStatement
: LabelName ':'
;
LabelName
: Identifier
| IntLiteral
;
Statements
: Statement? ( ':' Statement? )*
;
LocalDeclarationStatement
: LocalModifier VariableDeclarators StatementTerminator
;
LocalModifier
: 'Static' | 'Dim' | 'Const'
;
WithStatement
: 'With' Expression StatementTerminator
Block?
'End' 'With' StatementTerminator
;
SyncLockStatement
: 'SyncLock' Expression StatementTerminator
Block?
'End' 'SyncLock' StatementTerminator
;
EventStatement
: RaiseEventStatement
| AddHandlerStatement
| RemoveHandlerStatement
;
RaiseEventStatement
: 'RaiseEvent' IdentifierOrKeyword
( OpenParenthesis ArgumentList? CloseParenthesis )? StatementTerminator
;
AddHandlerStatement
: 'AddHandler' Expression Comma Expression StatementTerminator
;
RemoveHandlerStatement
: 'RemoveHandler' Expression Comma Expression StatementTerminator
;
AssignmentStatement
: RegularAssignmentStatement
| CompoundAssignmentStatement
| MidAssignmentStatement
;
RegularAssignmentStatement
: Expression Equals Expression StatementTerminator
;
CompoundAssignmentStatement
: Expression CompoundBinaryOperator LineTerminator? Expression StatementTerminator
;
CompoundBinaryOperator
: '^' '=' | '*' '=' | '/' '=' | '\\' '=' | '+' '=' | '-' '='
| '&' '=' | '<' '<' '=' | '>' '>' '='
;
MidAssignmentStatement
: 'Mid' '$'? OpenParenthesis Expression Comma Expression
( Comma Expression )? CloseParenthesis Equals Expression StatementTerminator
;
InvocationStatement
: 'Call'? InvocationExpression StatementTerminator
;
ConditionalStatement
: IfStatement
| SelectStatement
;
IfStatement
: BlockIfStatement
| LineIfThenStatement
;
BlockIfStatement
: 'If' BooleanExpression 'Then'? StatementTerminator
Block?
ElseIfStatement*
ElseStatement?
'End' 'If' StatementTerminator
;
ElseIfStatement
: ElseIf BooleanExpression 'Then'? StatementTerminator
Block?
;
ElseStatement
: 'Else' StatementTerminator
Block?
;
LineIfThenStatement
: 'If' BooleanExpression 'Then' Statements ( 'Else' Statements )? StatementTerminator
;
SelectStatement
: 'Select' 'Case'? Expression StatementTerminator
CaseStatement*
CaseElseStatement?
'End' 'Select' StatementTerminator
;
CaseStatement
: 'Case' CaseClauses StatementTerminator
Block?
;
CaseClauses
: CaseClause ( Comma CaseClause )*
;
CaseClause
: ( 'Is' LineTerminator? )? ComparisonOperator LineTerminator? Expression
| Expression ( 'To' Expression )?
;
ComparisonOperator
: '=' | '<' '>' | '<' | '>' | '>' '=' | '<' '='
;
CaseElseStatement
: 'Case' 'Else' StatementTerminator
Block?
;
LoopStatement
: WhileStatement
| DoLoopStatement
| ForStatement
| ForEachStatement
;
WhileStatement
: 'While' BooleanExpression StatementTerminator
Block?
'End' 'While' StatementTerminator
;
DoLoopStatement
: DoTopLoopStatement
| DoBottomLoopStatement
;
DoTopLoopStatement
: 'Do' ( WhileOrUntil BooleanExpression )? StatementTerminator
Block?
'Loop' StatementTerminator
;
DoBottomLoopStatement
: 'Do' StatementTerminator
Block?
'Loop' WhileOrUntil BooleanExpression StatementTerminator
;
WhileOrUntil
: 'While' | 'Until'
;
ForStatement
: 'For' LoopControlVariable Equals Expression 'To' Expression
( 'Step' Expression )? StatementTerminator
Block?
( 'Next' NextExpressionList? StatementTerminator )?
;
LoopControlVariable
: Identifier ( IdentifierModifiers 'As' TypeName )?
| Expression
;
NextExpressionList
: Expression ( Comma Expression )*
;
ForEachStatement
: 'For' 'Each' LoopControlVariable 'In' LineTerminator? Expression StatementTerminator
Block?
( 'Next' NextExpressionList? StatementTerminator )?
;
ErrorHandlingStatement
: StructuredErrorStatement
| UnstructuredErrorStatement
;
StructuredErrorStatement
: ThrowStatement
| TryStatement
;
TryStatement
: 'Try' StatementTerminator
Block?
CatchStatement*
FinallyStatement?
'End' 'Try' StatementTerminator
;
FinallyStatement
: 'Finally' StatementTerminator
Block?
;
CatchStatement
: 'Catch' ( Identifier ( 'As' NonArrayTypeName )? )?
( 'When' BooleanExpression )? StatementTerminator
Block?
;
ThrowStatement
: 'Throw' Expression? StatementTerminator
;
UnstructuredErrorStatement
: ErrorStatement
| OnErrorStatement
| ResumeStatement
;
ErrorStatement
: 'Error' Expression StatementTerminator
;
OnErrorStatement
: 'On' 'Error' ErrorClause StatementTerminator
;
ErrorClause
: 'GoTo' '-' '1'
| 'GoTo' '0'
| GoToStatement
| 'Resume' 'Next'
;
ResumeStatement
: 'Resume' ResumeClause? StatementTerminator
;
ResumeClause
: 'Next'
| LabelName
;
BranchStatement
: GoToStatement
| ExitStatement
| ContinueStatement
| StopStatement
| EndStatement
| ReturnStatement
;
GoToStatement
: 'GoTo' LabelName StatementTerminator
;
ExitStatement
: 'Exit' ExitKind StatementTerminator
;
ExitKind
: 'Do' | 'For' | 'While' | 'Select' | 'Sub' | 'Function' | 'Property' | 'Try'
;
ContinueStatement
: 'Continue' ContinueKind StatementTerminator
;
ContinueKind
: 'Do' | 'For' | 'While'
;
StopStatement
: 'Stop' StatementTerminator
;
EndStatement
: 'End' StatementTerminator
;
ReturnStatement
: 'Return' Expression? StatementTerminator
;
ArrayHandlingStatement
: RedimStatement
| EraseStatement
;
RedimStatement
: 'ReDim' 'Preserve'? RedimClauses StatementTerminator
;
RedimClauses
: RedimClause ( Comma RedimClause )*
;
RedimClause
: Expression ArraySizeInitializationModifier
;
EraseStatement
: 'Erase' EraseExpressions StatementTerminator
;
EraseExpressions
: Expression ( Comma Expression )*
;
UsingStatement
: 'Using' UsingResources StatementTerminator
Block?
'End' 'Using' StatementTerminator
;
UsingResources
: VariableDeclarators
| Expression
;
AwaitStatement
: AwaitOperatorExpression StatementTerminator
;
YieldStatement
: 'Yield' Expression StatementTerminator
;
// 11. Expressions
Expression
: SimpleExpression
| TypeExpression
| MemberAccessExpression
| DictionaryAccessExpression
| InvocationExpression
| IndexExpression
| NewExpression
| CastExpression
| OperatorExpression
| ConditionalExpression
| LambdaExpression
| QueryExpression
| XMLLiteralExpression
| XMLMemberAccessExpression
;
ConstantExpression
: Expression
;
SimpleExpression
: LiteralExpression
| ParenthesizedExpression
| InstanceExpression
| SimpleNameExpression
| AddressOfExpression
;
LiteralExpression
: Literal
;
ParenthesizedExpression
: OpenParenthesis Expression CloseParenthesis
;
InstanceExpression
: 'Me'
;
SimpleNameExpression
: Identifier ( OpenParenthesis 'Of' TypeArgumentList CloseParenthesis )?
;
AddressOfExpression
: 'AddressOf' Expression
;
TypeExpression
: GetTypeExpression
| TypeOfIsExpression
| IsExpression
| GetXmlNamespaceExpression
;
GetTypeExpression
: 'GetType' OpenParenthesis GetTypeTypeName CloseParenthesis
;
GetTypeTypeName
: TypeName
| QualifiedOpenTypeName
;
QualifiedOpenTypeName
: Identifier TypeArityList? (Period IdentifierOrKeyword TypeArityList?)*
| 'Global' Period IdentifierOrKeyword TypeArityList?
(Period IdentifierOrKeyword TypeArityList?)*
;
TypeArityList
: OpenParenthesis 'Of' CommaList? CloseParenthesis
;
CommaList
: Comma Comma*
;
TypeOfIsExpression
: 'TypeOf' Expression 'Is' LineTerminator? TypeName
;
IsExpression
: Expression 'Is' LineTerminator? Expression
| Expression 'IsNot' LineTerminator? Expression
;
GetXmlNamespaceExpression
: 'GetXmlNamespace' OpenParenthesis XMLNamespaceName? CloseParenthesis
;
MemberAccessExpression
: MemberAccessBase? Period IdentifierOrKeyword
( OpenParenthesis 'Of' TypeArgumentList CloseParenthesis )?
;
MemberAccessBase
: Expression
| NonArrayTypeName
| 'Global'
| 'MyClass'
| 'MyBase'
;
DictionaryAccessExpression
: Expression? '!' IdentifierOrKeyword
;
InvocationExpression
: Expression ( OpenParenthesis ArgumentList? CloseParenthesis )?
;
ArgumentList
: PositionalArgumentList
| PositionalArgumentList Comma NamedArgumentList
| NamedArgumentList
;
PositionalArgumentList
: Expression? ( Comma Expression? )*
;
NamedArgumentList
: IdentifierOrKeyword ColonEquals Expression
( Comma IdentifierOrKeyword ColonEquals Expression )*
;
IndexExpression
: Expression OpenParenthesis ArgumentList? CloseParenthesis
;
NewExpression
: ObjectCreationExpression
| ArrayExpression
| AnonymousObjectCreationExpression
;
ObjectCreationExpression
: 'New' NonArrayTypeName ( OpenParenthesis ArgumentList? CloseParenthesis )?
ObjectCreationExpressionInitializer?
;
ObjectCreationExpressionInitializer
: ObjectMemberInitializer
| ObjectCollectionInitializer
;
ObjectMemberInitializer
: 'With' OpenCurlyBrace FieldInitializerList CloseCurlyBrace
;
FieldInitializerList
: FieldInitializer ( Comma FieldInitializer )*
;
FieldInitializer
: 'Key'? ('.' IdentifierOrKeyword Equals )? Expression
;
ObjectCollectionInitializer
: 'From' CollectionInitializer
;
CollectionInitializer
: OpenCurlyBrace CollectionElementList? CloseCurlyBrace
;
CollectionElementList
: CollectionElement ( Comma CollectionElement )*
;
CollectionElement
: Expression
| CollectionInitializer
;
ArrayExpression
: ArrayCreationExpression
| ArrayLiteralExpression
;
ArrayCreationExpression
: 'New' NonArrayTypeName ArrayNameModifier CollectionInitializer
;
ArrayLiteralExpression
: CollectionInitializer
;
AnonymousObjectCreationExpression
: 'New' ObjectMemberInitializer
;
CastExpression
: 'DirectCast' OpenParenthesis Expression Comma TypeName CloseParenthesis
| 'TryCast' OpenParenthesis Expression Comma TypeName CloseParenthesis
| 'CType' OpenParenthesis Expression Comma TypeName CloseParenthesis
| CastTarget OpenParenthesis Expression CloseParenthesis
;
CastTarget
: 'CBool' | 'CByte' | 'CChar' | 'CDate' | 'CDec' | 'CDbl' | 'CInt'
| 'CLng' | 'CObj' | 'CSByte' | 'CShort' | 'CSng' | 'CStr' | 'CUInt'
| 'CULng' | 'CUShort'
;
OperatorExpression
: ArithmeticOperatorExpression
| RelationalOperatorExpression
| LikeOperatorExpression
| ConcatenationOperatorExpression
| ShortCircuitLogicalOperatorExpression
| LogicalOperatorExpression
| ShiftOperatorExpression
| AwaitOperatorExpression
;
ArithmeticOperatorExpression
: UnaryPlusExpression
| UnaryMinusExpression
| AdditionOperatorExpression
| SubtractionOperatorExpression
| MultiplicationOperatorExpression
| DivisionOperatorExpression
| ModuloOperatorExpression
| ExponentOperatorExpression
;
UnaryPlusExpression
: '+' Expression
;
UnaryMinusExpression
: '-' Expression
;
AdditionOperatorExpression
: Expression '+' LineTerminator? Expression
;
SubtractionOperatorExpression
: Expression '-' LineTerminator? Expression
;
MultiplicationOperatorExpression
: Expression '*' LineTerminator? Expression
;
DivisionOperatorExpression
: FPDivisionOperatorExpression
| IntegerDivisionOperatorExpression
;
FPDivisionOperatorExpression
: Expression '/' LineTerminator? Expression
;
IntegerDivisionOperatorExpression
: Expression '\\' LineTerminator? Expression
;
ModuloOperatorExpression
: Expression 'Mod' LineTerminator? Expression
;
ExponentOperatorExpression
: Expression '^' LineTerminator? Expression
;
RelationalOperatorExpression
: Expression '=' LineTerminator? Expression
| Expression '<' '>' LineTerminator? Expression
| Expression '<' LineTerminator? Expression
| Expression '>' LineTerminator? Expression
| Expression '<' '=' LineTerminator? Expression
| Expression '>' '=' LineTerminator? Expression
;
LikeOperatorExpression
: Expression 'Like' LineTerminator? Expression
;
ConcatenationOperatorExpression
: Expression '&' LineTerminator? Expression
;
LogicalOperatorExpression
: 'Not' Expression
| Expression 'And' LineTerminator? Expression
| Expression 'Or' LineTerminator? Expression
| Expression 'Xor' LineTerminator? Expression
;
ShortCircuitLogicalOperatorExpression
: Expression 'AndAlso' LineTerminator? Expression
| Expression 'OrElse' LineTerminator? Expression
;
ShiftOperatorExpression
: Expression '<' '<' LineTerminator? Expression
| Expression '>' '>' LineTerminator? Expression
;
BooleanExpression
: Expression
;
LambdaExpression
: SingleLineLambda
| MultiLineLambda
;
SingleLineLambda
: LambdaModifier* 'Function' ( OpenParenthesis ParameterList? CloseParenthesis )? Expression
| 'Sub' ( OpenParenthesis ParameterList? CloseParenthesis )? Statement
;
MultiLineLambda
: MultiLineFunctionLambda
| MultiLineSubLambda
;
MultiLineFunctionLambda
: LambdaModifier* 'Function' ( OpenParenthesis ParameterList? CloseParenthesis )? ( 'As' TypeName )? LineTerminator
Block
'End' 'Function'
;
MultiLineSubLambda
: LambdaModifier* 'Sub' ( OpenParenthesis ParameterList? CloseParenthesis )? LineTerminator
Block
'End' 'Sub'
;
LambdaModifier
: 'Async' | 'Iterator'
;
QueryExpression
: FromOrAggregateQueryOperator QueryOperator*
;
FromOrAggregateQueryOperator
: FromQueryOperator
| AggregateQueryOperator
;
QueryOperator
: FromQueryOperator
| AggregateQueryOperator
| SelectQueryOperator
| DistinctQueryOperator
| WhereQueryOperator
| OrderByQueryOperator
| PartitionQueryOperator
| LetQueryOperator
| GroupByQueryOperator
| JoinOrGroupJoinQueryOperator
;
JoinOrGroupJoinQueryOperator
: JoinQueryOperator
| GroupJoinQueryOperator
;
CollectionRangeVariableDeclarationList
: CollectionRangeVariableDeclaration ( Comma CollectionRangeVariableDeclaration )*
;
CollectionRangeVariableDeclaration
: Identifier ( 'As' TypeName )? 'In' LineTerminator? Expression
;
ExpressionRangeVariableDeclarationList
: ExpressionRangeVariableDeclaration ( Comma ExpressionRangeVariableDeclaration )*
;
ExpressionRangeVariableDeclaration
: Identifier ( 'As' TypeName )? Equals Expression
;
FromQueryOperator
: LineTerminator? 'From' LineTerminator? CollectionRangeVariableDeclarationList
;
JoinQueryOperator
: LineTerminator? 'Join' LineTerminator? CollectionRangeVariableDeclaration
JoinOrGroupJoinQueryOperator? LineTerminator? 'On' LineTerminator? JoinConditionList
;
JoinConditionList
: JoinCondition ( 'And' LineTerminator? JoinCondition )*
;
JoinCondition
: Expression 'Equals' LineTerminator? Expression
;
LetQueryOperator
: LineTerminator? 'Let' LineTerminator? ExpressionRangeVariableDeclarationList
;
SelectQueryOperator
: LineTerminator? 'Select' LineTerminator? ExpressionRangeVariableDeclarationList
;
DistinctQueryOperator
: LineTerminator? 'Distinct' LineTerminator?
;
WhereQueryOperator
: LineTerminator? 'Where' LineTerminator? BooleanExpression
;
PartitionQueryOperator
: LineTerminator? 'Take' LineTerminator? Expression
| LineTerminator? 'Take' 'While' LineTerminator? BooleanExpression
| LineTerminator? 'Skip' LineTerminator? Expression
| LineTerminator? 'Skip' 'While' LineTerminator? BooleanExpression
;
OrderByQueryOperator
: LineTerminator? 'Order' 'By' LineTerminator? OrderExpressionList
;
OrderExpressionList
: OrderExpression ( Comma OrderExpression )*
;
OrderExpression
: Expression Ordering?
;
Ordering
: 'Ascending' | 'Descending'
;
GroupByQueryOperator
: LineTerminator? 'Group' ( LineTerminator? ExpressionRangeVariableDeclarationList )?
LineTerminator? 'By' LineTerminator? ExpressionRangeVariableDeclarationList
LineTerminator? 'Into' LineTerminator? ExpressionRangeVariableDeclarationList
;
AggregateQueryOperator
: LineTerminator? 'Aggregate' LineTerminator? CollectionRangeVariableDeclaration QueryOperator*
LineTerminator? 'Into' LineTerminator? ExpressionRangeVariableDeclarationList
;
GroupJoinQueryOperator
: LineTerminator? 'Group' 'Join' LineTerminator? CollectionRangeVariableDeclaration
JoinOrGroupJoinQueryOperator? LineTerminator? 'On' LineTerminator? JoinConditionList
LineTerminator? 'Into' LineTerminator? ExpressionRangeVariableDeclarationList
;
ConditionalExpression
: 'If' OpenParenthesis BooleanExpression Comma Expression Comma Expression CloseParenthesis
| 'If' OpenParenthesis Expression Comma Expression CloseParenthesis
;
XMLLiteralExpression
: XMLDocument
| XMLElement
| XMLProcessingInstruction
| XMLComment
| XMLCDATASection
;
XMLCharacter
: '<Unicode tab character (0x0009)>'
| '<Unicode linefeed character (0x000A)>'
| '<Unicode carriage return character (0x000D)>'
| '<Unicode characters 0x0020 - 0xD7FF>'
| '<Unicode characters 0xE000 - 0xFFFD>'
| '<Unicode characters 0x10000 - 0x10FFFF>'
;
XMLString
: XMLCharacter+
;
XMLWhitespace
: XMLWhitespaceCharacter+
;
XMLWhitespaceCharacter
: '<Unicode carriage return character (0x000D)>'
| '<Unicode linefeed character (0x000A)>'
| '<Unicode space character (0x0020)>'
| '<Unicode tab character (0x0009)>'
;
XMLNameCharacter
: XMLLetter
| XMLDigit
| '.'
| '-'
| '_'
| ':'
| XMLCombiningCharacter
| XMLExtender
;
XMLNameStartCharacter
: XMLLetter
| '_'
| ':'
;
XMLName
: XMLNameStartCharacter XMLNameCharacter*
;
XMLLetter
: '<Unicode character as defined in the Letter production of the XML 1.0 specification>'
;
XMLDigit
: '<Unicode character as defined in the Digit production of the XML 1.0 specification>'
;
XMLCombiningCharacter
: '<Unicode character as defined in the CombiningChar production of the XML 1.0 specification>'
;
XMLExtender
: '<Unicode character as defined in the Extender production of the XML 1.0 specification>'
;
XMLEmbeddedExpression
: '<' '%' '=' LineTerminator? Expression LineTerminator? '%' '>'
;
XMLDocument
: XMLDocumentPrologue XMLMisc* XMLDocumentBody XMLMisc*
;
XMLDocumentPrologue
: '<' '?' 'xml' XMLVersion XMLEncoding? XMLStandalone? XMLWhitespace? '?' '>'
;
XMLVersion
: XMLWhitespace 'version' XMLWhitespace? '=' XMLWhitespace? XMLVersionNumberValue
;
XMLVersionNumberValue
: SingleQuoteCharacter '1' '.' '0' SingleQuoteCharacter
| DoubleQuoteCharacter '1' '.' '0' DoubleQuoteCharacter
;
XMLEncoding
: XMLWhitespace 'encoding' XMLWhitespace? '=' XMLWhitespace? XMLEncodingNameValue
;
XMLEncodingNameValue
: SingleQuoteCharacter XMLEncodingName SingleQuoteCharacter
| DoubleQuoteCharacter XMLEncodingName DoubleQuoteCharacter
;
XMLEncodingName
: XMLLatinAlphaCharacter XMLEncodingNameCharacter*
;
XMLEncodingNameCharacter
: XMLUnderscoreCharacter
| XMLLatinAlphaCharacter
| XMLNumericCharacter
| XMLPeriodCharacter
| XMLDashCharacter
;
XMLLatinAlphaCharacter
: '<Unicode Latin alphabetic character (0x0041-0x005a, 0x0061-0x007a)>'
;
XMLNumericCharacter
: '<Unicode digit character (0x0030-0x0039)>'
;
XMLHexNumericCharacter
: XMLNumericCharacter
| '<Unicode Latin hex alphabetic character (0x0041-0x0046, 0x0061-0x0066)>'
;
XMLPeriodCharacter
: '<Unicode period character (0x002e)>'
;
XMLUnderscoreCharacter
: '<Unicode underscore character (0x005f)>'
;
XMLDashCharacter
: '<Unicode dash character (0x002d)>'
;
XMLStandalone
: XMLWhitespace 'standalone' XMLWhitespace? '=' XMLWhitespace? XMLYesNoValue
;
XMLYesNoValue
: SingleQuoteCharacter XMLYesNo SingleQuoteCharacter
| DoubleQuoteCharacter XMLYesNo DoubleQuoteCharacter
;
XMLYesNo
: 'yes'
| 'no'
;
XMLMisc
: XMLComment
| XMLProcessingInstruction
| XMLWhitespace
;
XMLDocumentBody
: XMLElement
| XMLEmbeddedExpression
;
XMLElement
: XMLEmptyElement
| XMLElementStart XMLContent XMLElementEnd
;
XMLEmptyElement
: '<' XMLQualifiedNameOrExpression XMLAttribute* XMLWhitespace? '/' '>'
;
XMLElementStart
: '<' XMLQualifiedNameOrExpression XMLAttribute* XMLWhitespace? '>'
;
XMLElementEnd
: '<' '/' '>'
| '<' '/' XMLQualifiedName XMLWhitespace? '>'
;
XMLContent
: XMLCharacterData? ( XMLNestedContent XMLCharacterData? )+
;
XMLCharacterData
: '<Any XMLCharacterDataString that does not contain the string "]]>">'
;
XMLCharacterDataString
: '<Any Unicode character except < or &>'+
;
XMLNestedContent
: XMLElement
| XMLReference
| XMLCDATASection
| XMLProcessingInstruction
| XMLComment
| XMLEmbeddedExpression
;
XMLAttribute
: XMLWhitespace XMLAttributeName XMLWhitespace? '=' XMLWhitespace? XMLAttributeValue
| XMLWhitespace XMLEmbeddedExpression
;
XMLAttributeName
: XMLQualifiedNameOrExpression
| XMLNamespaceAttributeName
;
XMLAttributeValue
: DoubleQuoteCharacter XMLAttributeDoubleQuoteValueCharacter* DoubleQuoteCharacter
| SingleQuoteCharacter XMLAttributeSingleQuoteValueCharacter* SingleQuoteCharacter
| XMLEmbeddedExpression
;
XMLAttributeDoubleQuoteValueCharacter
: '<Any XMLCharacter except <, &, or DoubleQuoteCharacter>'
| XMLReference
;
XMLAttributeSingleQuoteValueCharacter
: '<Any XMLCharacter except <, &, or SingleQuoteCharacter>'
| XMLReference
;
XMLReference
: XMLEntityReference
| XMLCharacterReference
;
XMLEntityReference
: '&' XMLEntityName ';'
;
XMLEntityName
: 'lt' | 'gt' | 'amp' | 'apos' | 'quot'
;
XMLCharacterReference
: '&' '#' XMLNumericCharacter+ ';'
| '&' '#' 'x' XMLHexNumericCharacter+ ';'
;
XMLNamespaceAttributeName
: XMLPrefixedNamespaceAttributeName
| XMLDefaultNamespaceAttributeName
;
XMLPrefixedNamespaceAttributeName
: 'xmlns' ':' XMLNamespaceName
;
XMLDefaultNamespaceAttributeName
: 'xmlns'
;
XMLNamespaceName
: XMLNamespaceNameStartCharacter XMLNamespaceNameCharacter*
;
XMLNamespaceNameStartCharacter
: '<Any XMLNameCharacter except :>'
;
XMLNamespaceNameCharacter
: XMLLetter
| '_'
;
XMLQualifiedNameOrExpression
: XMLQualifiedName
| XMLEmbeddedExpression
;
XMLQualifiedName
: XMLPrefixedName
| XMLUnprefixedName
;
XMLPrefixedName
: XMLNamespaceName ':' XMLNamespaceName
;
XMLUnprefixedName
: XMLNamespaceName
;
XMLProcessingInstruction
: '<' '?' XMLProcessingTarget ( XMLWhitespace XMLProcessingValue? )? '?' '>'
;
XMLProcessingTarget
: '<Any XMLName except a casing permutation of the string "xml">'
;
XMLProcessingValue
: '<Any XMLString that does not contain a question-mark followed by ">">'
;
XMLComment
: '<' '!' '-' '-' XMLCommentCharacter* '-' '-' '>'
;
XMLCommentCharacter
: '<Any XMLCharacter except dash (0x002D)>'
| '-' '<Any XMLCharacter except dash (0x002D)>'
;
XMLCDATASection
: '<' '!' ( 'CDATA' '[' XMLCDATASectionString? ']' )? '>'
;
XMLCDATASectionString
: '<Any XMLString that does not contain the string "]]>">'
;
XMLMemberAccessExpression
: Expression '.' LineTerminator? '<' XMLQualifiedName '>'
| Expression '.' LineTerminator? '@' LineTerminator? '<' XMLQualifiedName '>'
| Expression '.' LineTerminator? '@' LineTerminator? IdentifierOrKeyword
| Expression '.' '.' '.' LineTerminator? '<' XMLQualifiedName '>'
;
AwaitOperatorExpression
: 'Await' Expression
;
| 53,608 | ANTLR | .g4 | 2,033 | 21.915396 | 119 | 0.703363 | steave6/vbtranslator | 0 | 0 | 1 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | aa89cd6159c45fb27aff0ffe6dfd0898cb33cd458871445f4be958f7f50850cc | true | false | false | false |
196 | VBLexer.g4 | steave6_vbtranslator/vbgrammer/src/main/vbgrammer/VBLexer.g4 | lexer grammar VBLexer;
// 2. Lexical grammar
CHARACTER:
'<Any Unicode character except a LineTerminator>'
;
LINETERMINATOR
: '<Unicode 0x00D>'
| '<Unicode 0x00A>'
| '\r'
| '\n'
| '\u2028'
| '\u2029'
;
fragment NewLine
: '\u000D'
| '\u000A'
| '\r'
| '\n'
| '\u2028'
| '\u2029'
;
COMMA: ',';
PERIOD: '.';
OPENPARENTHESIS: '(';
CLOSEPARENTHESIS: ')';
OPENCURLYBRACE: '{';
CLOSECURLYBRACE: '}';
EQUALS: '=';
COLONEQUALS: ':=';
WHITESPACE: (UnicodeClassZs | '\u0009');
// '<Unicode class Zs>'
fragment UnicodeClassZs // TODO
:
;
COMMENTMAKE: (SingleQuoteCharacter | 'REM');
fragment SingleQuoteCharacter
: '\''
| '\u2018'
| '\u2019'
;
Identifier
: NonEscapedIdentifier TypeCharacter?
| Keyword TypeCharacter
| EscapedIdentifier
;
NonEscapedIdentifier
: '<Any IdentifierName but not Keyword>'
;
EscapedIdentifier
: '[' IdentifierName ']'
;
IdentifierName
: IdentifierStart IdentifierCharacter*
;
IdentifierStart
: AlphaCharacter
| UnderscoreCharacter IdentifierCharacter
;
IdentifierCharacter
: UnderscoreCharacter
| AlphaCharacter
| NumericCharacter
| CombiningCharacter
| FormattingCharacter
;
AlphaCharacter
: '<Unicode classes Lu,Ll,Lt,Lm,Lo,Nl>'
;
NumericCharacter
: '<Unicode decimal digit class Nd>'
;
CombiningCharacter
: '<Unicode combining character classes Mn, Mc>'
;
FormattingCharacter
: '<Unicode formatting character class Cf>'
;
UnderscoreCharacter
: '<Unicode connection character class Pc>'
;
IdentifierOrKeyword
: Identifier
| Keyword
;
TypeCharacter
: IntegerTypeCharacter
| LongTypeCharacter
| DecimalTypeCharacter
| SingleTypeCharacter
| DoubleTypeCharacter
| StringTypeCharacter
;
IntegerTypeCharacter
: '%'
;
LongTypeCharacter
: '&'
;
DecimalTypeCharacter
: '@'
;
SingleTypeCharacter
: '!'
;
DoubleTypeCharacter
: '#'
;
StringTypeCharacter
: '$'
;
Keyword
: 'AddHandler' | 'AddressOf' | 'Alias' | 'And'
| 'AndAlso' | 'As' | 'Boolean' | 'ByRef'
| 'Byte' | 'ByVal' | 'Call' | 'Case'
| 'Catch' | 'CBool' | 'CByte' | 'CChar'
| 'CDate' | 'CDbl' | 'CDec' | 'Char'
| 'CInt' | 'Class' | 'CLng' | 'CObj'
| 'Const' | 'Continue' | 'CSByte' | 'CShort'
| 'CSng' | 'CStr' | 'CType' | 'CUInt'
| 'CULng' | 'CUShort' | 'Date' | 'Decimal'
| 'Declare' | 'Default' | 'Delegate' | 'Dim'
| 'DirectCast' | 'Do' | 'Double' | 'Each'
| 'Else' | 'ElseIf' | 'End' | 'EndIf'
| 'Enum' | 'Erase' | 'Error' | 'Event'
| 'Exit' | 'False' | 'Finally' | 'For'
| 'Friend' | 'Function' | 'Get' | 'GetType'
| 'GetXmlNamespace' | 'Global' | 'GoSub' | 'GoTo'
| 'Handles' | 'If' | 'Implements' | 'Imports'
| 'In' | 'Inherits' | 'Integer' | 'Interface'
| 'Is' | 'IsNot' | 'Let' | 'Lib'
| 'Like' | 'Long' | 'Loop' | 'Me'
| 'Mod' | 'Module' | 'MustInherit' | 'MustOverride'
| 'MyBase' | 'MyClass' | 'Namespace' | 'Narrowing'
| 'New' | 'Next' | 'Not' | 'Nothing'
| 'NotInheritable' | 'NotOverridable' | 'Object' | 'Of'
| 'On' | 'Operator' | 'Option' | 'Optional'
| 'Or' | 'OrElse' | 'Overloads' | 'Overridable'
| 'Overrides' | 'ParamArray' | 'Partial' | 'Private'
| 'Property' | 'Protected' | 'Public' | 'RaiseEvent'
| 'ReadOnly' | 'ReDim' | 'REM' | 'RemoveHandler'
| 'Resume' | 'Return' | 'SByte' | 'Select'
| 'Set' | 'Shadows' | 'Shared' | 'Short'
| 'Single' | 'Static' | 'Step' | 'Stop'
| 'String' | 'Structure' | 'Sub' | 'SyncLock'
| 'Then' | 'Throw' | 'To' | 'True'
| 'Try' | 'TryCast' | 'TypeOf' | 'UInteger'
| 'ULong' | 'UShort' | 'Using' | 'Variant'
| 'Wend' | 'When' | 'While' | 'Widening'
| 'With' | 'WithEvents' | 'WriteOnly' | 'Xor'
;
Literal
: BooleanLiteral
| IntegerLiteral
| FloatingPointLiteral
| StringLiteral
| CharacterLiteral
| DateLiteral
| Nothing
;
BooleanLiteral
: 'True' | 'False'
;
IntegerLiteral
: IntegralLiteralValue IntegralTypeCharacter?
;
IntegralLiteralValue
: IntLiteral
| HexLiteral
| OctalLiteral
;
IntegralTypeCharacter
: ShortCharacter
| UnsignedShortCharacter
| IntegerCharacter
| UnsignedIntegerCharacter
| LongCharacter
| UnsignedLongCharacter
| IntegerTypeCharacter
| LongTypeCharacter
;
ShortCharacter
: 'S'
;
UnsignedShortCharacter
: 'US'
;
IntegerCharacter
: 'I'
;
UnsignedIntegerCharacter
: 'UI'
;
LongCharacter
: 'L'
;
UnsignedLongCharacter
: 'UL'
;
IntLiteral
: Digit+
;
HexLiteral
: '&' 'H' HexDigit+
;
OctalLiteral
: '&' 'O' OctalDigit+
;
Digit
: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
;
HexDigit
: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
;
OctalDigit
: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7'
;
FloatingPointLiteral
: FloatingPointLiteralValue FloatingPointTypeCharacter?
| IntLiteral FloatingPointTypeCharacter
;
FloatingPointTypeCharacter
: SingleCharacter
| DoubleCharacter
| DecimalCharacter
| SingleTypeCharacter
| DoubleTypeCharacter
| DecimalTypeCharacter
;
SingleCharacter
: 'F'
;
DoubleCharacter
: 'R'
;
DecimalCharacter
: 'D'
;
FloatingPointLiteralValue
: IntLiteral '.' IntLiteral Exponent?
| '.' IntLiteral Exponent?
| IntLiteral Exponent
;
Exponent
: 'E' Sign? IntLiteral
;
Sign
: '+'
| '-'
;
StringLiteral
: DoubleQuoteCharacter StringCharacter* DoubleQuoteCharacter
;
DoubleQuoteCharacter
: '"'
| '<unicode left double-quote 0x201c>'
| '<unicode right double-quote 0x201D>'
;
StringCharacter
: '<Any character except DoubleQuoteCharacter>'
| DoubleQuoteCharacter DoubleQuoteCharacter
;
CharacterLiteral
: DoubleQuoteCharacter StringCharacter DoubleQuoteCharacter 'C'
;
DateLiteral
: '#' WhiteSpace* DateOrTime WhiteSpace* '#'
;
DateOrTime
: DateValue WhiteSpace+ TimeValue
| DateValue
| TimeValue
;
DateValue
: MonthValue '/' DayValue '/' YearValue
| MonthValue '-' DayValue '-' YearValue
;
TimeValue
: HourValue ':' MinuteValue ( ':' SecondValue )? WhiteSpace* AMPM?
| HourValue WhiteSpace* AMPM
;
MonthValue
: IntLiteral
;
DayValue
: IntLiteral
;
YearValue
: IntLiteral
;
HourValue
: IntLiteral
;
MinuteValue
: IntLiteral
;
SecondValue
: IntLiteral
;
AMPM
: 'AM' | 'PM'
;
ElseIf
: 'ElseIf'
| 'Else' 'If'
;
Nothing
: 'Nothing'
;
Separator
: '(' | ')' | '{' | '}' | '!' | '#' | ',' | '.' | ':' | '?'
;
Operator
: '&' | '*' | '+' | '-' | '/' | '\\' | '^' | '<' | '=' | '>'
;
// 3. Preprocessing Directives
CCStart
: CCStatement*
;
CCStatement
: CCConstantDeclaration
| CCIfGroup
| LogicalLine
;
CCExpression
: LiteralExpression
| CCParenthesizedExpression
| CCSimpleNameExpression
| CCCastExpression
| CCOperatorExpression
| CCConditionalExpression
;
CCParenthesizedExpression
: '(' CCExpression ')'
;
CCSimpleNameExpression
: Identifier
;
CCCastExpression
: 'DirectCast' '(' CCExpression ',' TypeName ')'
| 'TryCast' '(' CCExpression ',' TypeName ')'
| 'CType' '(' CCExpression ',' TypeName ')'
| CastTarget '(' CCExpression ')'
;
CCOperatorExpression
: CCUnaryOperator CCExpression
| CCExpression CCBinaryOperator CCExpression
;
CCUnaryOperator
: '+' | '-' | 'Not'
;
CCBinaryOperator
: '+' | '-' | '*' | '/' | '\\' | 'Mod' | '^' | '='
| '<' '>' | '<' | '>' | '<' '=' | '>' '=' | '&'
| 'And' | 'Or' | 'Xor' | 'AndAlso' | 'OrElse'
| '<' '<' | '>' '>'
;
CCConditionalExpression
: 'If' '(' CCExpression ',' CCExpression ',' CCExpression ')'
| 'If' '(' CCExpression ',' CCExpression ')'
;
CCConstantDeclaration
: '#' 'Const' Identifier '=' CCExpression LineTerminator
;
CCIfGroup
: '#' 'If' CCExpression 'Then'? LineTerminator CCStatement*
CCElseIfGroup* CCElseGroup? '#' 'End' 'If' LineTerminator
;
CCElseIfGroup
: '#' ElseIf CCExpression 'Then'? LineTerminator CCStatement*
;
CCElseGroup
: '#' 'Else' LineTerminator CCStatement*
;
ESDStart
: ExternalSourceStatement*
;
ExternalSourceStatement
: ExternalSourceGroup
| LogicalLine
;
ExternalSourceGroup
: '#' 'ExternalSource' '(' StringLiteral ',' IntLiteral ')' LineTerminator
LogicalLine* '#' 'End' 'ExternalSource' LineTerminator
;
RegionStart
: RegionStatement*
;
RegionStatement
: RegionGroup
| LogicalLine
;
RegionGroup
: '#' 'Region' StringLiteral LineTerminator
RegionStatement*
'#' 'End' 'Region' LineTerminator
;
ExternalChecksumStart
: ExternalChecksumStatement*
;
ExternalChecksumStatement
: '#' 'ExternalChecksum' '('
StringLiteral ',' StringLiteral ',' StringLiteral
')' LineTerminator
;
// 4. General concepts
AccessModifier
: 'Public'
| 'Protected'
| 'Friend'
| 'Private'
| 'Protected' 'Friend'
;
TypeParameterList
: OpenParenthesis 'Of' TypeParameter ( Comma TypeParameter )* CloseParenthesis
;
TypeParameter
: VarianceModifier? Identifier TypeParameterConstraints?
;
VarianceModifier
: 'In' | 'Out'
;
TypeParameterConstraints
: 'As' Constraint
| 'As' OpenCurlyBrace ConstraintList CloseCurlyBrace
;
ConstraintList
: Constraint ( Comma Constraint )*
;
Constraint
: TypeName
| 'New'
| 'Structure'
| 'Class'
;
// 5. Attributes
Attributes
: AttributeBlock+
;
AttributeBlock
: LineTerminator? '<' AttributeList LineTerminator? '>' LineTerminator?
;
AttributeList
: Attribute ( Comma Attribute )*
;
Attribute
: ( AttributeModifier ':' )? SimpleTypeName
( OpenParenthesis AttributeArguments? CloseParenthesis )?
;
AttributeModifier
: 'Assembly' | 'Module'
;
AttributeArguments
: AttributePositionalArgumentList
| AttributePositionalArgumentList Comma VariablePropertyInitializerList
| VariablePropertyInitializerList
;
AttributePositionalArgumentList
: AttributeArgumentExpression? ( Comma AttributeArgumentExpression? )*
;
VariablePropertyInitializerList
: VariablePropertyInitializer ( Comma VariablePropertyInitializer )*
;
VariablePropertyInitializer
: IdentifierOrKeyword ColonEquals AttributeArgumentExpression
;
AttributeArgumentExpression
: ConstantExpression
| GetTypeExpression
| ArrayExpression
;
// 6. Source files and namespaces
Start
: OptionStatement* ImportsStatement* AttributesStatement* NamespaceMemberDeclaration*
;
StatementTerminator
: LineTerminator
| ':'
;
AttributesStatement
: Attributes StatementTerminator
;
OptionStatement
: OptionExplicitStatement
| OptionStrictStatement
| OptionCompareStatement
| OptionInferStatement
;
OptionExplicitStatement
: 'Option' 'Explicit' OnOff? StatementTerminator
;
OnOff
: 'On' | 'Off'
;
OptionStrictStatement
: 'Option' 'Strict' OnOff? StatementTerminator
;
OptionCompareStatement
: 'Option' 'Compare' CompareOption StatementTerminator
;
CompareOption
: 'Binary' | 'Text'
;
OptionInferStatement
: 'Option' 'Infer' OnOff? StatementTerminator
;
ImportsStatement
: 'Imports' ImportsClauses StatementTerminator
;
ImportsClauses
: ImportsClause ( Comma ImportsClause )*
;
ImportsClause
: AliasImportsClause
| MembersImportsClause
| XMLNamespaceImportsClause
;
AliasImportsClause
: Identifier Equals TypeName
;
MembersImportsClause
: TypeName
;
XMLNamespaceImportsClause
: '<' XMLNamespaceAttributeName XMLWhitespace? Equals XMLWhitespace?
XMLNamespaceValue '>'
;
XMLNamespaceValue
: DoubleQuoteCharacter XMLAttributeDoubleQuoteValueCharacter* DoubleQuoteCharacter
| SingleQuoteCharacter XMLAttributeSingleQuoteValueCharacter* SingleQuoteCharacter
;
NamespaceDeclaration
: 'Namespace' NamespaceName StatementTerminator
NamespaceMemberDeclaration*
'End' 'Namespace' StatementTerminator
;
NamespaceName
: RelativeNamespaceName
| 'Global'
| 'Global' '.' RelativeNamespaceName
;
RelativeNamespaceName
: Identifier ( Period IdentifierOrKeyword )*
;
NamespaceMemberDeclaration
: NamespaceDeclaration
| TypeDeclaration
;
TypeDeclaration
: ModuleDeclaration
| NonModuleDeclaration
;
NonModuleDeclaration
: EnumDeclaration
| StructureDeclaration
| InterfaceDeclaration
| ClassDeclaration
| DelegateDeclaration
;
// 7. Types
TypeName
: ArrayTypeName
| NonArrayTypeName
;
NonArrayTypeName
: SimpleTypeName
| NullableTypeName
;
SimpleTypeName
: QualifiedTypeName
| BuiltInTypeName
;
QualifiedTypeName
: Identifier TypeArguments? (Period IdentifierOrKeyword TypeArguments?)*
| 'Global' Period IdentifierOrKeyword TypeArguments?
(Period IdentifierOrKeyword TypeArguments?)*
;
TypeArguments
: OpenParenthesis 'Of' TypeArgumentList CloseParenthesis
;
TypeArgumentList
: TypeName ( Comma TypeName )*
;
BuiltInTypeName
: 'Object'
| PrimitiveTypeName
;
TypeModifier
: AccessModifier
| 'Shadows'
;
IdentifierModifiers
: NullableNameModifier? ArrayNameModifier?
;
NullableTypeName
: NonArrayTypeName '?'
;
NullableNameModifier
: '?'
;
TypeImplementsClause
: 'Implements' TypeImplements StatementTerminator
;
TypeImplements
: NonArrayTypeName ( Comma NonArrayTypeName )*
;
PrimitiveTypeName
: NumericTypeName
| 'Boolean'
| 'Date'
| 'Char'
| 'String'
;
NumericTypeName
: IntegralTypeName
| FloatingPointTypeName
| 'Decimal'
;
IntegralTypeName
: 'Byte' | 'SByte' | 'UShort' | 'Short' | 'UInteger'
| 'Integer' | 'ULong' | 'Long'
;
FloatingPointTypeName
: 'Single' | 'Double'
;
EnumDeclaration
: Attributes? TypeModifier* 'Enum' Identifier
( 'As' NonArrayTypeName )? StatementTerminator
EnumMemberDeclaration+
'End' 'Enum' StatementTerminator
;
EnumMemberDeclaration
: Attributes? Identifier ( Equals ConstantExpression )? StatementTerminator
;
ClassDeclaration
: Attributes? ClassModifier* 'Class' Identifier TypeParameterList? StatementTerminator
ClassBase?
TypeImplementsClause*
ClassMemberDeclaration*
'End' 'Class' StatementTerminator
;
ClassModifier
: TypeModifier
| 'MustInherit'
| 'NotInheritable'
| 'Partial'
;
ClassBase
: 'Inherits' NonArrayTypeName StatementTerminator
;
ClassMemberDeclaration
: NonModuleDeclaration
| EventMemberDeclaration
| VariableMemberDeclaration
| ConstantMemberDeclaration
| MethodMemberDeclaration
| PropertyMemberDeclaration
| ConstructorMemberDeclaration
| OperatorDeclaration
;
StructureDeclaration
: Attributes? StructureModifier* 'Structure' Identifier
TypeParameterList? StatementTerminator
TypeImplementsClause*
StructMemberDeclaration*
'End' 'Structure' StatementTerminator
;
StructureModifier
: TypeModifier
| 'Partial'
;
StructMemberDeclaration
: NonModuleDeclaration
| VariableMemberDeclaration
| ConstantMemberDeclaration
| EventMemberDeclaration
| MethodMemberDeclaration
| PropertyMemberDeclaration
| ConstructorMemberDeclaration
| OperatorDeclaration
;
ModuleDeclaration
: Attributes? TypeModifier* 'Module' Identifier StatementTerminator
ModuleMemberDeclaration*
'End' 'Module' StatementTerminator
;
ModuleMemberDeclaration
: NonModuleDeclaration
| VariableMemberDeclaration
| ConstantMemberDeclaration
| EventMemberDeclaration
| MethodMemberDeclaration
| PropertyMemberDeclaration
| ConstructorMemberDeclaration
;
InterfaceDeclaration
: Attributes? TypeModifier* 'Interface' Identifier
TypeParameterList? StatementTerminator
InterfaceBase*
InterfaceMemberDeclaration*
'End' 'Interface' StatementTerminator
;
InterfaceBase
: 'Inherits' InterfaceBases StatementTerminator
;
InterfaceBases
: NonArrayTypeName ( Comma NonArrayTypeName )*
;
InterfaceMemberDeclaration
: NonModuleDeclaration
| InterfaceEventMemberDeclaration
| InterfaceMethodMemberDeclaration
| InterfacePropertyMemberDeclaration
;
ArrayTypeName
: NonArrayTypeName ArrayTypeModifiers
;
ArrayTypeModifiers
: ArrayTypeModifier+
;
ArrayTypeModifier
: OpenParenthesis RankList? CloseParenthesis
;
RankList
: Comma*
;
ArrayNameModifier
: ArrayTypeModifiers
| ArraySizeInitializationModifier
;
DelegateDeclaration
: Attributes? TypeModifier* 'Delegate' MethodSignature StatementTerminator
;
MethodSignature
: SubSignature
| FunctionSignature
;
// 9. Type members
ImplementsClause
: ( 'Implements' ImplementsList )?
;
ImplementsList
: InterfaceMemberSpecifier ( Comma InterfaceMemberSpecifier )*
;
InterfaceMemberSpecifier
: NonArrayTypeName Period IdentifierOrKeyword
;
MethodMemberDeclaration
: MethodDeclaration
| ExternalMethodDeclaration
;
InterfaceMethodMemberDeclaration
: InterfaceMethodDeclaration
;
MethodDeclaration
: SubDeclaration
| MustOverrideSubDeclaration
| FunctionDeclaration
| MustOverrideFunctionDeclaration
;
InterfaceMethodDeclaration
: InterfaceSubDeclaration
| InterfaceFunctionDeclaration
;
SubSignature
: 'Sub' Identifier TypeParameterList?
( OpenParenthesis ParameterList? CloseParenthesis )?
;
FunctionSignature
: 'Function' Identifier TypeParameterList?
( OpenParenthesis ParameterList? CloseParenthesis )?
( 'As' Attributes? TypeName )?
;
SubDeclaration
: Attributes? ProcedureModifier* SubSignature
HandlesOrImplements? LineTerminator
Block
'End' 'Sub' StatementTerminator
;
MustOverrideSubDeclaration
: Attributes? MustOverrideProcedureModifier+ SubSignature
HandlesOrImplements? StatementTerminator
;
InterfaceSubDeclaration
: Attributes? InterfaceProcedureModifier* SubSignature StatementTerminator
;
FunctionDeclaration
: Attributes? ProcedureModifier* FunctionSignature
HandlesOrImplements? LineTerminator
Block
'End' 'Function' StatementTerminator
;
MustOverrideFunctionDeclaration
: Attributes? MustOverrideProcedureModifier+ FunctionSignature
HandlesOrImplements? StatementTerminator
;
InterfaceFunctionDeclaration
: Attributes? InterfaceProcedureModifier* FunctionSignature StatementTerminator
;
ProcedureModifier
: AccessModifier | 'Shadows' | 'Shared' | 'Overridable' | 'NotOverridable' | 'Overrides'
| 'Overloads' | 'Partial' | 'Iterator' | 'Async'
;
MustOverrideProcedureModifier
: ProcedureModifier
| 'MustOverride'
;
InterfaceProcedureModifier
: 'Shadows' | 'Overloads'
;
HandlesOrImplements
: HandlesClause
| ImplementsClause
;
ExternalMethodDeclaration
: ExternalSubDeclaration
| ExternalFunctionDeclaration
;
ExternalSubDeclaration
: Attributes? ExternalMethodModifier* 'Declare' CharsetModifier? 'Sub'
Identifier LibraryClause AliasClause?
( OpenParenthesis ParameterList? CloseParenthesis )? StatementTerminator
;
ExternalFunctionDeclaration
: Attributes? ExternalMethodModifier* 'Declare' CharsetModifier? 'Function'
Identifier LibraryClause AliasClause?
( OpenParenthesis ParameterList? CloseParenthesis )?
( 'As' Attributes? TypeName )?
StatementTerminator
;
ExternalMethodModifier
: AccessModifier
| 'Shadows'
| 'Overloads'
;
CharsetModifier
: 'Ansi' | 'Unicode' | 'Auto'
;
LibraryClause
: 'Lib' StringLiteral
;
AliasClause
: 'Alias' StringLiteral
;
ParameterList
: Parameter ( Comma Parameter )*
;
Parameter
: Attributes? ParameterModifier* ParameterIdentifier ( 'As' TypeName )?
( Equals ConstantExpression )?
;
ParameterModifier
: 'ByVal' | 'ByRef' | 'Optional' | 'ParamArray'
;
ParameterIdentifier
: Identifier IdentifierModifiers
;
HandlesClause
: ( 'Handles' EventHandlesList )?
;
EventHandlesList
: EventMemberSpecifier ( Comma EventMemberSpecifier )*
;
EventMemberSpecifier
: Identifier Period IdentifierOrKeyword
| 'MyBase' Period IdentifierOrKeyword
| 'MyClass' Period IdentifierOrKeyword
| 'Me' Period IdentifierOrKeyword
;
ConstructorMemberDeclaration
: Attributes? ConstructorModifier* 'Sub' 'New'
( OpenParenthesis ParameterList? CloseParenthesis )? LineTerminator
Block?
'End' 'Sub' StatementTerminator
;
ConstructorModifier
: AccessModifier
| 'Shared'
;
EventMemberDeclaration
: RegularEventMemberDeclaration
| CustomEventMemberDeclaration
;
RegularEventMemberDeclaration
: Attributes? EventModifiers* 'Event'
Identifier ParametersOrType ImplementsClause? StatementTerminator
;
InterfaceEventMemberDeclaration
: Attributes? InterfaceEventModifiers* 'Event'
Identifier ParametersOrType StatementTerminator
;
ParametersOrType
: ( OpenParenthesis ParameterList? CloseParenthesis )?
| 'As' NonArrayTypeName
;
EventModifiers
: AccessModifier
| 'Shadows'
| 'Shared'
;
InterfaceEventModifiers
: 'Shadows'
;
CustomEventMemberDeclaration
: Attributes? EventModifiers* 'Custom' 'Event'
Identifier 'As' TypeName ImplementsClause? StatementTerminator
EventAccessorDeclaration+
'End' 'Event' StatementTerminator
;
EventAccessorDeclaration
: AddHandlerDeclaration
| RemoveHandlerDeclaration
| RaiseEventDeclaration
;
AddHandlerDeclaration
: Attributes? 'AddHandler'
OpenParenthesis ParameterList CloseParenthesis LineTerminator
Block?
'End' 'AddHandler' StatementTerminator
;
RemoveHandlerDeclaration
: Attributes? 'RemoveHandler'
OpenParenthesis ParameterList CloseParenthesis LineTerminator
Block?
'End' 'RemoveHandler' StatementTerminator
;
RaiseEventDeclaration
: Attributes? 'RaiseEvent'
OpenParenthesis ParameterList CloseParenthesis LineTerminator
Block?
'End' 'RaiseEvent' StatementTerminator
;
ConstantMemberDeclaration
: Attributes? ConstantModifier* 'Const' ConstantDeclarators StatementTerminator
;
ConstantModifier
: AccessModifier
| 'Shadows'
;
ConstantDeclarators
: ConstantDeclarator ( Comma ConstantDeclarator )*
;
ConstantDeclarator
: Identifier ( 'As' TypeName )? Equals ConstantExpression StatementTerminator
;
VariableMemberDeclaration
: Attributes? VariableModifier+ VariableDeclarators StatementTerminator
;
VariableModifier
: AccessModifier
| 'Shadows'
| 'Shared'
| 'ReadOnly'
| 'WithEvents'
| 'Dim'
;
VariableDeclarators
: VariableDeclarator ( Comma VariableDeclarator )*
;
VariableDeclarator
: VariableIdentifiers 'As' ObjectCreationExpression
| VariableIdentifiers ( 'As' TypeName )? ( Equals Expression )?
;
VariableIdentifiers
: VariableIdentifier ( Comma VariableIdentifier )*
;
VariableIdentifier
: Identifier IdentifierModifiers
;
ArraySizeInitializationModifier
: OpenParenthesis BoundList CloseParenthesis ArrayTypeModifiers?
;
BoundList
: Bound ( Comma Bound )*
;
Bound
: Expression
| '0' 'To' Expression
;
PropertyMemberDeclaration
: RegularPropertyMemberDeclaration
| MustOverridePropertyMemberDeclaration
| AutoPropertyMemberDeclaration
;
PropertySignature
: 'Property'
Identifier ( OpenParenthesis ParameterList? CloseParenthesis )?
( 'As' Attributes? TypeName )?
;
RegularPropertyMemberDeclaration
: Attributes? PropertyModifier* PropertySignature
ImplementsClause? LineTerminator
PropertyAccessorDeclaration+
'End' 'Property' StatementTerminator
;
MustOverridePropertyMemberDeclaration
: Attributes? MustOverridePropertyModifier+ PropertySignature
ImplementsClause? StatementTerminator
;
AutoPropertyMemberDeclaration
: Attributes? AutoPropertyModifier* 'Property' Identifier
( OpenParenthesis ParameterList? CloseParenthesis )?
( 'As' Attributes? TypeName )? ( Equals Expression )?
ImplementsClause? LineTerminator
| Attributes? AutoPropertyModifier* 'Property' Identifier
( OpenParenthesis ParameterList? CloseParenthesis )?
'As' Attributes? 'New'
( NonArrayTypeName ( OpenParenthesis ArgumentList? CloseParenthesis )? )?
ObjectCreationExpressionInitializer?
ImplementsClause? LineTerminator
;
InterfacePropertyMemberDeclaration
: Attributes? InterfacePropertyModifier* PropertySignature StatementTerminator
;
AutoPropertyModifier
: AccessModifier
| 'Shadows'
| 'Shared'
| 'Overridable'
| 'NotOverridable'
| 'Overrides'
| 'Overloads'
;
PropertyModifier
: AutoPropertyModifier
| 'Default'
| 'ReadOnly'
| 'WriteOnly'
| 'Iterator'
;
MustOverridePropertyModifier
: PropertyModifier
| 'MustOverride'
;
InterfacePropertyModifier
: 'Shadows'
| 'Overloads'
| 'Default'
| 'ReadOnly'
| 'WriteOnly'
;
PropertyAccessorDeclaration
: PropertyGetDeclaration
| PropertySetDeclaration
;
PropertyGetDeclaration
: Attributes? AccessModifier? 'Get' LineTerminator
Block?
'End' 'Get' StatementTerminator
;
PropertySetDeclaration
: Attributes? AccessModifier? 'Set'
( OpenParenthesis ParameterList? CloseParenthesis )? LineTerminator
Block?
'End' 'Set' StatementTerminator
;
OperatorDeclaration
: Attributes? OperatorModifier* 'Operator' OverloadableOperator
OpenParenthesis ParameterList CloseParenthesis
( 'As' Attributes? TypeName )? LineTerminator
Block?
'End' 'Operator' StatementTerminator
;
OperatorModifier
: 'Public' | 'Shared' | 'Overloads' | 'Shadows' | 'Widening' | 'Narrowing'
;
OverloadableOperator
: '+' | '-' | '*' | '/' | '\\' | '&' | 'Like' | 'Mod' | 'And' | 'Or' | 'Xor'
| '^' | '<' '<' | '>' '>' | '=' | '<' '>' | '>' | '<' | '>' '=' | '<' '='
| 'Not' | 'IsTrue' | 'IsFalse' | 'CType'
;
// 10. Statements
Statement
: LabelDeclarationStatement
| LocalDeclarationStatement
| WithStatement
| SyncLockStatement
| EventStatement
| AssignmentStatement
| InvocationStatement
| ConditionalStatement
| LoopStatement
| ErrorHandlingStatement
| BranchStatement
| ArrayHandlingStatement
| UsingStatement
| AwaitStatement
| YieldStatement
;
Block
: Statements*
;
LabelDeclarationStatement
: LabelName ':'
;
LabelName
: Identifier
| IntLiteral
;
Statements
: Statement? ( ':' Statement? )*
;
LocalDeclarationStatement
: LocalModifier VariableDeclarators StatementTerminator
;
LocalModifier
: 'Static' | 'Dim' | 'Const'
;
WithStatement
: 'With' Expression StatementTerminator
Block?
'End' 'With' StatementTerminator
;
SyncLockStatement
: 'SyncLock' Expression StatementTerminator
Block?
'End' 'SyncLock' StatementTerminator
;
EventStatement
: RaiseEventStatement
| AddHandlerStatement
| RemoveHandlerStatement
;
RaiseEventStatement
: 'RaiseEvent' IdentifierOrKeyword
( OpenParenthesis ArgumentList? CloseParenthesis )? StatementTerminator
;
AddHandlerStatement
: 'AddHandler' Expression Comma Expression StatementTerminator
;
RemoveHandlerStatement
: 'RemoveHandler' Expression Comma Expression StatementTerminator
;
AssignmentStatement
: RegularAssignmentStatement
| CompoundAssignmentStatement
| MidAssignmentStatement
;
RegularAssignmentStatement
: Expression Equals Expression StatementTerminator
;
CompoundAssignmentStatement
: Expression CompoundBinaryOperator LineTerminator? Expression StatementTerminator
;
CompoundBinaryOperator
: '^' '=' | '*' '=' | '/' '=' | '\\' '=' | '+' '=' | '-' '='
| '&' '=' | '<' '<' '=' | '>' '>' '='
;
MidAssignmentStatement
: 'Mid' '$'? OpenParenthesis Expression Comma Expression
( Comma Expression )? CloseParenthesis Equals Expression StatementTerminator
;
InvocationStatement
: 'Call'? InvocationExpression StatementTerminator
;
ConditionalStatement
: IfStatement
| SelectStatement
;
IfStatement
: BlockIfStatement
| LineIfThenStatement
;
BlockIfStatement
: 'If' BooleanExpression 'Then'? StatementTerminator
Block?
ElseIfStatement*
ElseStatement?
'End' 'If' StatementTerminator
;
ElseIfStatement
: ElseIf BooleanExpression 'Then'? StatementTerminator
Block?
;
ElseStatement
: 'Else' StatementTerminator
Block?
;
LineIfThenStatement
: 'If' BooleanExpression 'Then' Statements ( 'Else' Statements )? StatementTerminator
;
SelectStatement
: 'Select' 'Case'? Expression StatementTerminator
CaseStatement*
CaseElseStatement?
'End' 'Select' StatementTerminator
;
CaseStatement
: 'Case' CaseClauses StatementTerminator
Block?
;
CaseClauses
: CaseClause ( Comma CaseClause )*
;
CaseClause
: ( 'Is' LineTerminator? )? ComparisonOperator LineTerminator? Expression
| Expression ( 'To' Expression )?
;
ComparisonOperator
: '=' | '<' '>' | '<' | '>' | '>' '=' | '<' '='
;
CaseElseStatement
: 'Case' 'Else' StatementTerminator
Block?
;
LoopStatement
: WhileStatement
| DoLoopStatement
| ForStatement
| ForEachStatement
;
WhileStatement
: 'While' BooleanExpression StatementTerminator
Block?
'End' 'While' StatementTerminator
;
DoLoopStatement
: DoTopLoopStatement
| DoBottomLoopStatement
;
DoTopLoopStatement
: 'Do' ( WhileOrUntil BooleanExpression )? StatementTerminator
Block?
'Loop' StatementTerminator
;
DoBottomLoopStatement
: 'Do' StatementTerminator
Block?
'Loop' WhileOrUntil BooleanExpression StatementTerminator
;
WhileOrUntil
: 'While' | 'Until'
;
ForStatement
: 'For' LoopControlVariable Equals Expression 'To' Expression
( 'Step' Expression )? StatementTerminator
Block?
( 'Next' NextExpressionList? StatementTerminator )?
;
LoopControlVariable
: Identifier ( IdentifierModifiers 'As' TypeName )?
| Expression
;
NextExpressionList
: Expression ( Comma Expression )*
;
ForEachStatement
: 'For' 'Each' LoopControlVariable 'In' LineTerminator? Expression StatementTerminator
Block?
( 'Next' NextExpressionList? StatementTerminator )?
;
ErrorHandlingStatement
: StructuredErrorStatement
| UnstructuredErrorStatement
;
StructuredErrorStatement
: ThrowStatement
| TryStatement
;
TryStatement
: 'Try' StatementTerminator
Block?
CatchStatement*
FinallyStatement?
'End' 'Try' StatementTerminator
;
FinallyStatement
: 'Finally' StatementTerminator
Block?
;
CatchStatement
: 'Catch' ( Identifier ( 'As' NonArrayTypeName )? )?
( 'When' BooleanExpression )? StatementTerminator
Block?
;
ThrowStatement
: 'Throw' Expression? StatementTerminator
;
UnstructuredErrorStatement
: ErrorStatement
| OnErrorStatement
| ResumeStatement
;
ErrorStatement
: 'Error' Expression StatementTerminator
;
OnErrorStatement
: 'On' 'Error' ErrorClause StatementTerminator
;
ErrorClause
: 'GoTo' '-' '1'
| 'GoTo' '0'
| GoToStatement
| 'Resume' 'Next'
;
ResumeStatement
: 'Resume' ResumeClause? StatementTerminator
;
ResumeClause
: 'Next'
| LabelName
;
BranchStatement
: GoToStatement
| ExitStatement
| ContinueStatement
| StopStatement
| EndStatement
| ReturnStatement
;
GoToStatement
: 'GoTo' LabelName StatementTerminator
;
ExitStatement
: 'Exit' ExitKind StatementTerminator
;
ExitKind
: 'Do' | 'For' | 'While' | 'Select' | 'Sub' | 'Function' | 'Property' | 'Try'
;
ContinueStatement
: 'Continue' ContinueKind StatementTerminator
;
ContinueKind
: 'Do' | 'For' | 'While'
;
StopStatement
: 'Stop' StatementTerminator
;
EndStatement
: 'End' StatementTerminator
;
ReturnStatement
: 'Return' Expression? StatementTerminator
;
ArrayHandlingStatement
: RedimStatement
| EraseStatement
;
RedimStatement
: 'ReDim' 'Preserve'? RedimClauses StatementTerminator
;
RedimClauses
: RedimClause ( Comma RedimClause )*
;
RedimClause
: Expression ArraySizeInitializationModifier
;
EraseStatement
: 'Erase' EraseExpressions StatementTerminator
;
EraseExpressions
: Expression ( Comma Expression )*
;
UsingStatement
: 'Using' UsingResources StatementTerminator
Block?
'End' 'Using' StatementTerminator
;
UsingResources
: VariableDeclarators
| Expression
;
AwaitStatement
: AwaitOperatorExpression StatementTerminator
;
YieldStatement
: 'Yield' Expression StatementTerminator
;
// 11. Expressions
Expression
: SimpleExpression
| TypeExpression
| MemberAccessExpression
| DictionaryAccessExpression
| InvocationExpression
| IndexExpression
| NewExpression
| CastExpression
| OperatorExpression
| ConditionalExpression
| LambdaExpression
| QueryExpression
| XMLLiteralExpression
| XMLMemberAccessExpression
;
ConstantExpression
: Expression
;
SimpleExpression
: LiteralExpression
| ParenthesizedExpression
| InstanceExpression
| SimpleNameExpression
| AddressOfExpression
;
LiteralExpression
: Literal
;
ParenthesizedExpression
: OpenParenthesis Expression CloseParenthesis
;
InstanceExpression
: 'Me'
;
SimpleNameExpression
: Identifier ( OpenParenthesis 'Of' TypeArgumentList CloseParenthesis )?
;
AddressOfExpression
: 'AddressOf' Expression
;
TypeExpression
: GetTypeExpression
| TypeOfIsExpression
| IsExpression
| GetXmlNamespaceExpression
;
GetTypeExpression
: 'GetType' OpenParenthesis GetTypeTypeName CloseParenthesis
;
GetTypeTypeName
: TypeName
| QualifiedOpenTypeName
;
QualifiedOpenTypeName
: Identifier TypeArityList? (Period IdentifierOrKeyword TypeArityList?)*
| 'Global' Period IdentifierOrKeyword TypeArityList?
(Period IdentifierOrKeyword TypeArityList?)*
;
TypeArityList
: OpenParenthesis 'Of' CommaList? CloseParenthesis
;
CommaList
: Comma Comma*
;
TypeOfIsExpression
: 'TypeOf' Expression 'Is' LineTerminator? TypeName
;
IsExpression
: Expression 'Is' LineTerminator? Expression
| Expression 'IsNot' LineTerminator? Expression
;
GetXmlNamespaceExpression
: 'GetXmlNamespace' OpenParenthesis XMLNamespaceName? CloseParenthesis
;
MemberAccessExpression
: MemberAccessBase? Period IdentifierOrKeyword
( OpenParenthesis 'Of' TypeArgumentList CloseParenthesis )?
;
MemberAccessBase
: Expression
| NonArrayTypeName
| 'Global'
| 'MyClass'
| 'MyBase'
;
DictionaryAccessExpression
: Expression? '!' IdentifierOrKeyword
;
InvocationExpression
: Expression ( OpenParenthesis ArgumentList? CloseParenthesis )?
;
ArgumentList
: PositionalArgumentList
| PositionalArgumentList Comma NamedArgumentList
| NamedArgumentList
;
PositionalArgumentList
: Expression? ( Comma Expression? )*
;
NamedArgumentList
: IdentifierOrKeyword ColonEquals Expression
( Comma IdentifierOrKeyword ColonEquals Expression )*
;
IndexExpression
: Expression OpenParenthesis ArgumentList? CloseParenthesis
;
NewExpression
: ObjectCreationExpression
| ArrayExpression
| AnonymousObjectCreationExpression
;
ObjectCreationExpression
: 'New' NonArrayTypeName ( OpenParenthesis ArgumentList? CloseParenthesis )?
ObjectCreationExpressionInitializer?
;
ObjectCreationExpressionInitializer
: ObjectMemberInitializer
| ObjectCollectionInitializer
;
ObjectMemberInitializer
: 'With' OpenCurlyBrace FieldInitializerList CloseCurlyBrace
;
FieldInitializerList
: FieldInitializer ( Comma FieldInitializer )*
;
FieldInitializer
: 'Key'? ('.' IdentifierOrKeyword Equals )? Expression
;
ObjectCollectionInitializer
: 'From' CollectionInitializer
;
CollectionInitializer
: OpenCurlyBrace CollectionElementList? CloseCurlyBrace
;
CollectionElementList
: CollectionElement ( Comma CollectionElement )*
;
CollectionElement
: Expression
| CollectionInitializer
;
ArrayExpression
: ArrayCreationExpression
| ArrayLiteralExpression
;
ArrayCreationExpression
: 'New' NonArrayTypeName ArrayNameModifier CollectionInitializer
;
ArrayLiteralExpression
: CollectionInitializer
;
AnonymousObjectCreationExpression
: 'New' ObjectMemberInitializer
;
CastExpression
: 'DirectCast' OpenParenthesis Expression Comma TypeName CloseParenthesis
| 'TryCast' OpenParenthesis Expression Comma TypeName CloseParenthesis
| 'CType' OpenParenthesis Expression Comma TypeName CloseParenthesis
| CastTarget OpenParenthesis Expression CloseParenthesis
;
CastTarget
: 'CBool' | 'CByte' | 'CChar' | 'CDate' | 'CDec' | 'CDbl' | 'CInt'
| 'CLng' | 'CObj' | 'CSByte' | 'CShort' | 'CSng' | 'CStr' | 'CUInt'
| 'CULng' | 'CUShort'
;
OperatorExpression
: ArithmeticOperatorExpression
| RelationalOperatorExpression
| LikeOperatorExpression
| ConcatenationOperatorExpression
| ShortCircuitLogicalOperatorExpression
| LogicalOperatorExpression
| ShiftOperatorExpression
| AwaitOperatorExpression
;
ArithmeticOperatorExpression
: UnaryPlusExpression
| UnaryMinusExpression
| AdditionOperatorExpression
| SubtractionOperatorExpression
| MultiplicationOperatorExpression
| DivisionOperatorExpression
| ModuloOperatorExpression
| ExponentOperatorExpression
;
UnaryPlusExpression
: '+' Expression
;
UnaryMinusExpression
: '-' Expression
;
AdditionOperatorExpression
: Expression '+' LineTerminator? Expression
;
SubtractionOperatorExpression
: Expression '-' LineTerminator? Expression
;
MultiplicationOperatorExpression
: Expression '*' LineTerminator? Expression
;
DivisionOperatorExpression
: FPDivisionOperatorExpression
| IntegerDivisionOperatorExpression
;
FPDivisionOperatorExpression
: Expression '/' LineTerminator? Expression
;
IntegerDivisionOperatorExpression
: Expression '\\' LineTerminator? Expression
;
ModuloOperatorExpression
: Expression 'Mod' LineTerminator? Expression
;
ExponentOperatorExpression
: Expression '^' LineTerminator? Expression
;
RelationalOperatorExpression
: Expression '=' LineTerminator? Expression
| Expression '<' '>' LineTerminator? Expression
| Expression '<' LineTerminator? Expression
| Expression '>' LineTerminator? Expression
| Expression '<' '=' LineTerminator? Expression
| Expression '>' '=' LineTerminator? Expression
;
LikeOperatorExpression
: Expression 'Like' LineTerminator? Expression
;
ConcatenationOperatorExpression
: Expression '&' LineTerminator? Expression
;
LogicalOperatorExpression
: 'Not' Expression
| Expression 'And' LineTerminator? Expression
| Expression 'Or' LineTerminator? Expression
| Expression 'Xor' LineTerminator? Expression
;
ShortCircuitLogicalOperatorExpression
: Expression 'AndAlso' LineTerminator? Expression
| Expression 'OrElse' LineTerminator? Expression
;
ShiftOperatorExpression
: Expression '<' '<' LineTerminator? Expression
| Expression '>' '>' LineTerminator? Expression
;
BooleanExpression
: Expression
;
LambdaExpression
: SingleLineLambda
| MultiLineLambda
;
SingleLineLambda
: LambdaModifier* 'Function' ( OpenParenthesis ParameterList? CloseParenthesis )? Expression
| 'Sub' ( OpenParenthesis ParameterList? CloseParenthesis )? Statement
;
MultiLineLambda
: MultiLineFunctionLambda
| MultiLineSubLambda
;
MultiLineFunctionLambda
: LambdaModifier* 'Function' ( OpenParenthesis ParameterList? CloseParenthesis )? ( 'As' TypeName )? LineTerminator
Block
'End' 'Function'
;
MultiLineSubLambda
: LambdaModifier* 'Sub' ( OpenParenthesis ParameterList? CloseParenthesis )? LineTerminator
Block
'End' 'Sub'
;
LambdaModifier
: 'Async' | 'Iterator'
;
QueryExpression
: FromOrAggregateQueryOperator QueryOperator*
;
FromOrAggregateQueryOperator
: FromQueryOperator
| AggregateQueryOperator
;
QueryOperator
: FromQueryOperator
| AggregateQueryOperator
| SelectQueryOperator
| DistinctQueryOperator
| WhereQueryOperator
| OrderByQueryOperator
| PartitionQueryOperator
| LetQueryOperator
| GroupByQueryOperator
| JoinOrGroupJoinQueryOperator
;
JoinOrGroupJoinQueryOperator
: JoinQueryOperator
| GroupJoinQueryOperator
;
CollectionRangeVariableDeclarationList
: CollectionRangeVariableDeclaration ( Comma CollectionRangeVariableDeclaration )*
;
CollectionRangeVariableDeclaration
: Identifier ( 'As' TypeName )? 'In' LineTerminator? Expression
;
ExpressionRangeVariableDeclarationList
: ExpressionRangeVariableDeclaration ( Comma ExpressionRangeVariableDeclaration )*
;
ExpressionRangeVariableDeclaration
: Identifier ( 'As' TypeName )? Equals Expression
;
FromQueryOperator
: LineTerminator? 'From' LineTerminator? CollectionRangeVariableDeclarationList
;
JoinQueryOperator
: LineTerminator? 'Join' LineTerminator? CollectionRangeVariableDeclaration
JoinOrGroupJoinQueryOperator? LineTerminator? 'On' LineTerminator? JoinConditionList
;
JoinConditionList
: JoinCondition ( 'And' LineTerminator? JoinCondition )*
;
JoinCondition
: Expression 'Equals' LineTerminator? Expression
;
LetQueryOperator
: LineTerminator? 'Let' LineTerminator? ExpressionRangeVariableDeclarationList
;
SelectQueryOperator
: LineTerminator? 'Select' LineTerminator? ExpressionRangeVariableDeclarationList
;
DistinctQueryOperator
: LineTerminator? 'Distinct' LineTerminator?
;
WhereQueryOperator
: LineTerminator? 'Where' LineTerminator? BooleanExpression
;
PartitionQueryOperator
: LineTerminator? 'Take' LineTerminator? Expression
| LineTerminator? 'Take' 'While' LineTerminator? BooleanExpression
| LineTerminator? 'Skip' LineTerminator? Expression
| LineTerminator? 'Skip' 'While' LineTerminator? BooleanExpression
;
OrderByQueryOperator
: LineTerminator? 'Order' 'By' LineTerminator? OrderExpressionList
;
OrderExpressionList
: OrderExpression ( Comma OrderExpression )*
;
OrderExpression
: Expression Ordering?
;
Ordering
: 'Ascending' | 'Descending'
;
GroupByQueryOperator
: LineTerminator? 'Group' ( LineTerminator? ExpressionRangeVariableDeclarationList )?
LineTerminator? 'By' LineTerminator? ExpressionRangeVariableDeclarationList
LineTerminator? 'Into' LineTerminator? ExpressionRangeVariableDeclarationList
;
AggregateQueryOperator
: LineTerminator? 'Aggregate' LineTerminator? CollectionRangeVariableDeclaration QueryOperator*
LineTerminator? 'Into' LineTerminator? ExpressionRangeVariableDeclarationList
;
GroupJoinQueryOperator
: LineTerminator? 'Group' 'Join' LineTerminator? CollectionRangeVariableDeclaration
JoinOrGroupJoinQueryOperator? LineTerminator? 'On' LineTerminator? JoinConditionList
LineTerminator? 'Into' LineTerminator? ExpressionRangeVariableDeclarationList
;
ConditionalExpression
: 'If' OpenParenthesis BooleanExpression Comma Expression Comma Expression CloseParenthesis
| 'If' OpenParenthesis Expression Comma Expression CloseParenthesis
;
XMLLiteralExpression
: XMLDocument
| XMLElement
| XMLProcessingInstruction
| XMLComment
| XMLCDATASection
;
XMLCharacter
: '<Unicode tab character (0x0009)>'
| '<Unicode linefeed character (0x000A)>'
| '<Unicode carriage return character (0x000D)>'
| '<Unicode characters 0x0020 - 0xD7FF>'
| '<Unicode characters 0xE000 - 0xFFFD>'
| '<Unicode characters 0x10000 - 0x10FFFF>'
;
XMLString
: XMLCharacter+
;
XMLWhitespace
: XMLWhitespaceCharacter+
;
XMLWhitespaceCharacter
: '<Unicode carriage return character (0x000D)>'
| '<Unicode linefeed character (0x000A)>'
| '<Unicode space character (0x0020)>'
| '<Unicode tab character (0x0009)>'
;
XMLNameCharacter
: XMLLetter
| XMLDigit
| '.'
| '-'
| '_'
| ':'
| XMLCombiningCharacter
| XMLExtender
;
XMLNameStartCharacter
: XMLLetter
| '_'
| ':'
;
XMLName
: XMLNameStartCharacter XMLNameCharacter*
;
XMLLetter
: '<Unicode character as defined in the Letter production of the XML 1.0 specification>'
;
XMLDigit
: '<Unicode character as defined in the Digit production of the XML 1.0 specification>'
;
XMLCombiningCharacter
: '<Unicode character as defined in the CombiningChar production of the XML 1.0 specification>'
;
XMLExtender
: '<Unicode character as defined in the Extender production of the XML 1.0 specification>'
;
XMLEmbeddedExpression
: '<' '%' '=' LineTerminator? Expression LineTerminator? '%' '>'
;
XMLDocument
: XMLDocumentPrologue XMLMisc* XMLDocumentBody XMLMisc*
;
XMLDocumentPrologue
: '<' '?' 'xml' XMLVersion XMLEncoding? XMLStandalone? XMLWhitespace? '?' '>'
;
XMLVersion
: XMLWhitespace 'version' XMLWhitespace? '=' XMLWhitespace? XMLVersionNumberValue
;
XMLVersionNumberValue
: SingleQuoteCharacter '1' '.' '0' SingleQuoteCharacter
| DoubleQuoteCharacter '1' '.' '0' DoubleQuoteCharacter
;
XMLEncoding
: XMLWhitespace 'encoding' XMLWhitespace? '=' XMLWhitespace? XMLEncodingNameValue
;
XMLEncodingNameValue
: SingleQuoteCharacter XMLEncodingName SingleQuoteCharacter
| DoubleQuoteCharacter XMLEncodingName DoubleQuoteCharacter
;
XMLEncodingName
: XMLLatinAlphaCharacter XMLEncodingNameCharacter*
;
XMLEncodingNameCharacter
: XMLUnderscoreCharacter
| XMLLatinAlphaCharacter
| XMLNumericCharacter
| XMLPeriodCharacter
| XMLDashCharacter
;
XMLLatinAlphaCharacter
: '<Unicode Latin alphabetic character (0x0041-0x005a, 0x0061-0x007a)>'
;
XMLNumericCharacter
: '<Unicode digit character (0x0030-0x0039)>'
;
XMLHexNumericCharacter
: XMLNumericCharacter
| '<Unicode Latin hex alphabetic character (0x0041-0x0046, 0x0061-0x0066)>'
;
XMLPeriodCharacter
: '<Unicode period character (0x002e)>'
;
XMLUnderscoreCharacter
: '<Unicode underscore character (0x005f)>'
;
XMLDashCharacter
: '<Unicode dash character (0x002d)>'
;
XMLStandalone
: XMLWhitespace 'standalone' XMLWhitespace? '=' XMLWhitespace? XMLYesNoValue
;
XMLYesNoValue
: SingleQuoteCharacter XMLYesNo SingleQuoteCharacter
| DoubleQuoteCharacter XMLYesNo DoubleQuoteCharacter
;
XMLYesNo
: 'yes'
| 'no'
;
XMLMisc
: XMLComment
| XMLProcessingInstruction
| XMLWhitespace
;
XMLDocumentBody
: XMLElement
| XMLEmbeddedExpression
;
XMLElement
: XMLEmptyElement
| XMLElementStart XMLContent XMLElementEnd
;
XMLEmptyElement
: '<' XMLQualifiedNameOrExpression XMLAttribute* XMLWhitespace? '/' '>'
;
XMLElementStart
: '<' XMLQualifiedNameOrExpression XMLAttribute* XMLWhitespace? '>'
;
XMLElementEnd
: '<' '/' '>'
| '<' '/' XMLQualifiedName XMLWhitespace? '>'
;
XMLContent
: XMLCharacterData? ( XMLNestedContent XMLCharacterData? )+
;
XMLCharacterData
: '<Any XMLCharacterDataString that does not contain the string "]]>">'
;
XMLCharacterDataString
: '<Any Unicode character except < or &>'+
;
XMLNestedContent
: XMLElement
| XMLReference
| XMLCDATASection
| XMLProcessingInstruction
| XMLComment
| XMLEmbeddedExpression
;
XMLAttribute
: XMLWhitespace XMLAttributeName XMLWhitespace? '=' XMLWhitespace? XMLAttributeValue
| XMLWhitespace XMLEmbeddedExpression
;
XMLAttributeName
: XMLQualifiedNameOrExpression
| XMLNamespaceAttributeName
;
XMLAttributeValue
: DoubleQuoteCharacter XMLAttributeDoubleQuoteValueCharacter* DoubleQuoteCharacter
| SingleQuoteCharacter XMLAttributeSingleQuoteValueCharacter* SingleQuoteCharacter
| XMLEmbeddedExpression
;
XMLAttributeDoubleQuoteValueCharacter
: '<Any XMLCharacter except <, &, or DoubleQuoteCharacter>'
| XMLReference
;
XMLAttributeSingleQuoteValueCharacter
: '<Any XMLCharacter except <, &, or SingleQuoteCharacter>'
| XMLReference
;
XMLReference
: XMLEntityReference
| XMLCharacterReference
;
XMLEntityReference
: '&' XMLEntityName ';'
;
XMLEntityName
: 'lt' | 'gt' | 'amp' | 'apos' | 'quot'
;
XMLCharacterReference
: '&' '#' XMLNumericCharacter+ ';'
| '&' '#' 'x' XMLHexNumericCharacter+ ';'
;
XMLNamespaceAttributeName
: XMLPrefixedNamespaceAttributeName
| XMLDefaultNamespaceAttributeName
;
XMLPrefixedNamespaceAttributeName
: 'xmlns' ':' XMLNamespaceName
;
XMLDefaultNamespaceAttributeName
: 'xmlns'
;
XMLNamespaceName
: XMLNamespaceNameStartCharacter XMLNamespaceNameCharacter*
;
XMLNamespaceNameStartCharacter
: '<Any XMLNameCharacter except :>'
;
XMLNamespaceNameCharacter
: XMLLetter
| '_'
;
XMLQualifiedNameOrExpression
: XMLQualifiedName
| XMLEmbeddedExpression
;
XMLQualifiedName
: XMLPrefixedName
| XMLUnprefixedName
;
XMLPrefixedName
: XMLNamespaceName ':' XMLNamespaceName
;
XMLUnprefixedName
: XMLNamespaceName
;
XMLProcessingInstruction
: '<' '?' XMLProcessingTarget ( XMLWhitespace XMLProcessingValue? )? '?' '>'
;
XMLProcessingTarget
: '<Any XMLName except a casing permutation of the string "xml">'
;
XMLProcessingValue
: '<Any XMLString that does not contain a question-mark followed by ">">'
;
XMLComment
: '<' '!' '-' '-' XMLCommentCharacter* '-' '-' '>'
;
XMLCommentCharacter
: '<Any XMLCharacter except dash (0x002D)>'
| '-' '<Any XMLCharacter except dash (0x002D)>'
;
XMLCDATASection
: '<' '!' ( 'CDATA' '[' XMLCDATASectionString? ']' )? '>'
;
XMLCDATASectionString
: '<Any XMLString that does not contain the string "]]>">'
;
XMLMemberAccessExpression
: Expression '.' LineTerminator? '<' XMLQualifiedName '>'
| Expression '.' LineTerminator? '@' LineTerminator? '<' XMLQualifiedName '>'
| Expression '.' LineTerminator? '@' LineTerminator? IdentifierOrKeyword
| Expression '.' '.' '.' LineTerminator? '<' XMLQualifiedName '>'
;
AwaitOperatorExpression
: 'Await' Expression
;
// fragments
| 53,099 | ANTLR | .g4 | 1,999 | 22.117059 | 119 | 0.703707 | steave6/vbtranslator | 0 | 0 | 1 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | db71bb2311d3817375f5e703e91cfa15fdc89207a43bc4304cc650ba5c13d363 | false | false | false | false |
197 | Parser.g4 | wadoon_antlr4-doc/examples/Parser.g4 | grammar Parser;
/**
# Parser Rule
**entry function**
dfsdafsdasdafsda
sdafsda
fsda
fsdafsda
f
sdafsaf
*/
equation
: expression relop expression
;
powExpression
: signedAtom (POW signedAtom)*
;
signedAtom
: PLUS signedAtom
| MINUS signedAtom
| func
| atom
;
atom
: scientific
| variable
| constant
| LPAREN expression RPAREN
;
scientific
: SCIENTIFIC_NUMBER
;
constant
: PI
| EULER
| I
;
variable
: VARIABLE
;
func
: funcname LPAREN expression (COMMA expression)* RPAREN
;
funcname
: COS
| TAN
| SIN
| ACOS
| ATAN
| ASIN
| LOG
| LN
| SQRT
;
relop
: EQ
| GT
| LT
;
COS
: 'cos'
;
SIN
: 'sin'
;
TAN
: 'tan'
;
ACOS
: 'acos'
;
ASIN
: 'asin'
;
ATAN
: 'atan'
;
LN
: 'ln'
;
LOG
: 'log'
;
SQRT
: 'sqrt'
;
LPAREN
: '('
;
RPAREN
: ')'
;
PLUS
: '+'
;
MINUS
: '-'
;
TIMES
: '*'
;
DIV
: '/'
;
GT
: '>'
;
LT
: '<'
;
EQ
: '='
;
COMMA
: ','
;
POINT
: '.'
;
POW
: '^'
;
PI
: 'pi'
;
EULER
: E2
;
I
: 'i'
;
VARIABLE
: VALID_ID_START VALID_ID_CHAR*
;
fragment VALID_ID_START
: ('a' .. 'z') | ('A' .. 'Z') | '_'
;
fragment VALID_ID_CHAR
: VALID_ID_START | ('0' .. '9')
;
SCIENTIFIC_NUMBER
: NUMBER ((E1 | E2) SIGN? NUMBER)?
;
fragment NUMBER
: ('0' .. '9') + ('.' ('0' .. '9') +)?
;
fragment E1
: 'E'
;
fragment E2
: 'e'
;
fragment SIGN
: ('+' | '-')
;
WS
: [ \r\n\t] + -> skip
; | 1,648 | ANTLR | .g4 | 158 | 6.955696 | 58 | 0.502481 | wadoon/antlr4-doc | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 496dc95df487db5a77c7793a1f04e2a04834e1a64c9dd03cb71aaaece3d901bd | false | false | false | false |
198 | ANTLRv4Lexer.g4 | wadoon_antlr4-doc/src/main/antlr4/ANTLRv4Lexer.g4 | /*
* [The "BSD license"]
* Copyright (c) 2012-2015 Terence Parr
* Copyright (c) 2012-2015 Sam Harwell
* Copyright (c) 2015 Gerald Rosenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* A grammar for ANTLR v4 implemented using v4 syntax
*
* Modified 2015.06.16 gbr
* -- update for compatibility with Antlr v4.5
*/
lexer grammar ANTLRv4Lexer;
options { superClass = LexerAdaptor; }
import LexBasic;
// Standard set of fragments
tokens { TOKEN_REF , RULE_REF , LEXER_CHAR_SET }
channels { OFF_CHANNEL , COMMENT }
// ======================================================
// Lexer specification
//
// -------------------------
// Comments
DOC_COMMENT
: DocComment
;
BLOCK_COMMENT
: BlockComment -> channel (COMMENT)
;
LINE_COMMENT
: LineComment -> channel (COMMENT)
;
// -------------------------
// Integer
//
INT
: DecimalNumeral
;
// -------------------------
// Literal string
//
// ANTLR makes no distinction between a single character literal and a
// multi-character string. All literals are single quote delimited and
// may contain unicode escape sequences of the form \uxxxx, where x
// is a valid hexadecimal number (per Unicode standard).
STRING_LITERAL
: SQuoteLiteral
;
UNTERMINATED_STRING_LITERAL
: USQuoteLiteral
;
// -------------------------
// Arguments
//
// Certain argument lists, such as those specifying call parameters
// to a rule invocation, or input parameters to a rule specification
// are contained within square brackets.
BEGIN_ARGUMENT
: LBrack
{ handleBeginArgument(); }
;
// -------------------------
// Actions
BEGIN_ACTION
: LBrace -> pushMode (Action)
;
// -------------------------
// Keywords
//
// Keywords may not be used as labels for rules or in any other context where
// they would be ambiguous with the keyword vs some other identifier. OPTIONS,
// TOKENS, & CHANNELS blocks are handled idiomatically in dedicated lexical modes.
OPTIONS
: 'options' -> pushMode (Options)
;
TOKENS
: 'tokens' -> pushMode (Tokens)
;
CHANNELS
: 'channels' -> pushMode (Channels)
;
IMPORT
: 'import'
;
FRAGMENT
: 'fragment'
;
LEXER
: 'lexer'
;
PARSER
: 'parser'
;
GRAMMAR
: 'grammar'
;
PROTECTED
: 'protected'
;
PUBLIC
: 'public'
;
PRIVATE
: 'private'
;
RETURNS
: 'returns'
;
LOCALS
: 'locals'
;
THROWS
: 'throws'
;
CATCH
: 'catch'
;
FINALLY
: 'finally'
;
MODE
: 'mode'
;
// -------------------------
// Punctuation
COLON
: Colon
;
COLONCOLON
: DColon
;
COMMA
: Comma
;
SEMI
: Semi
;
LPAREN
: LParen
;
RPAREN
: RParen
;
LBRACE
: LBrace
;
RBRACE
: RBrace
;
RARROW
: RArrow
;
LT
: Lt
;
GT
: Gt
;
ASSIGN
: Equal
;
QUESTION
: Question
;
STAR
: Star
;
PLUS_ASSIGN
: PlusAssign
;
PLUS
: Plus
;
OR
: Pipe
;
DOLLAR
: Dollar
;
RANGE
: Range
;
DOT
: Dot
;
AT
: At
;
POUND
: Pound
;
NOT
: Tilde
;
// -------------------------
// Identifiers - allows unicode rule/token names
ID
: Id
;
// -------------------------
// Whitespace
WS
: Ws+ -> channel (OFF_CHANNEL)
;
// -------------------------
// Illegal Characters
//
// This is an illegal character trap which is always the last rule in the
// lexer specification. It matches a single character of any value and being
// the last rule in the file will match when no other rule knows what to do
// about the character. It is reported as an error but is not passed on to the
// parser. This means that the parser to deal with the gramamr file anyway
// but we will not try to analyse or code generate from a file with lexical
// errors.
//
// Comment this rule out to allow the error to be propagated to the parser
ERRCHAR
: . -> channel (HIDDEN)
;
// ======================================================
// Lexer modes
// -------------------------
// Arguments
mode Argument;
// E.g., [int x, List<String> a[]]
NESTED_ARGUMENT
: LBrack -> type (ARGUMENT_CONTENT) , pushMode (Argument)
;
ARGUMENT_ESCAPE
: EscAny -> type (ARGUMENT_CONTENT)
;
ARGUMENT_STRING_LITERAL
: DQuoteLiteral -> type (ARGUMENT_CONTENT)
;
ARGUMENT_CHAR_LITERAL
: SQuoteLiteral -> type (ARGUMENT_CONTENT)
;
END_ARGUMENT
: RBrack
{ handleEndArgument(); }
;
// added this to return non-EOF token type here. EOF does something weird
UNTERMINATED_ARGUMENT
: EOF -> popMode
;
ARGUMENT_CONTENT
: .
;
// -------------------------
// Actions
//
// Many language targets use {} as block delimiters and so we
// must recursively match {} delimited blocks to balance the
// braces. Additionally, we must make some assumptions about
// literal string representation in the target language. We assume
// that they are delimited by ' or " and so consume these
// in their own alts so as not to inadvertantly match {}.
mode Action;
NESTED_ACTION
: LBrace -> type (ACTION_CONTENT) , pushMode (Action)
;
ACTION_ESCAPE
: EscAny -> type (ACTION_CONTENT)
;
ACTION_STRING_LITERAL
: DQuoteLiteral -> type (ACTION_CONTENT)
;
ACTION_CHAR_LITERAL
: SQuoteLiteral -> type (ACTION_CONTENT)
;
ACTION_DOC_COMMENT
: DocComment -> type (ACTION_CONTENT)
;
ACTION_BLOCK_COMMENT
: BlockComment -> type (ACTION_CONTENT)
;
ACTION_LINE_COMMENT
: LineComment -> type (ACTION_CONTENT)
;
END_ACTION
: RBrace
{ handleEndAction(); }
;
UNTERMINATED_ACTION
: EOF -> popMode
;
ACTION_CONTENT
: .
;
// -------------------------
mode Options;
OPT_DOC_COMMENT
: DocComment -> type (DOC_COMMENT) , channel (COMMENT)
;
OPT_BLOCK_COMMENT
: BlockComment -> type (BLOCK_COMMENT) , channel (COMMENT)
;
OPT_LINE_COMMENT
: LineComment -> type (LINE_COMMENT) , channel (COMMENT)
;
OPT_LBRACE
: LBrace -> type (LBRACE)
;
OPT_RBRACE
: RBrace -> type (RBRACE) , popMode
;
OPT_ID
: Id -> type (ID)
;
OPT_DOT
: Dot -> type (DOT)
;
OPT_ASSIGN
: Equal -> type (ASSIGN)
;
OPT_STRING_LITERAL
: SQuoteLiteral -> type (STRING_LITERAL)
;
OPT_INT
: DecimalNumeral -> type (INT)
;
OPT_STAR
: Star -> type (STAR)
;
OPT_SEMI
: Semi -> type (SEMI)
;
OPT_WS
: Ws+ -> type (WS) , channel (OFF_CHANNEL)
;
// -------------------------
mode Tokens;
TOK_DOC_COMMENT
: DocComment -> type (DOC_COMMENT) , channel (COMMENT)
;
TOK_BLOCK_COMMENT
: BlockComment -> type (BLOCK_COMMENT) , channel (COMMENT)
;
TOK_LINE_COMMENT
: LineComment -> type (LINE_COMMENT) , channel (COMMENT)
;
TOK_LBRACE
: LBrace -> type (LBRACE)
;
TOK_RBRACE
: RBrace -> type (RBRACE) , popMode
;
TOK_ID
: Id -> type (ID)
;
TOK_DOT
: Dot -> type (DOT)
;
TOK_COMMA
: Comma -> type (COMMA)
;
TOK_WS
: Ws+ -> type (WS) , channel (OFF_CHANNEL)
;
// -------------------------
mode Channels;
// currently same as Tokens mode; distinguished by keyword
CHN_DOC_COMMENT
: DocComment -> type (DOC_COMMENT) , channel (COMMENT)
;
CHN_BLOCK_COMMENT
: BlockComment -> type (BLOCK_COMMENT) , channel (COMMENT)
;
CHN_LINE_COMMENT
: LineComment -> type (LINE_COMMENT) , channel (COMMENT)
;
CHN_LBRACE
: LBrace -> type (LBRACE)
;
CHN_RBRACE
: RBrace -> type (RBRACE) , popMode
;
CHN_ID
: Id -> type (ID)
;
CHN_DOT
: Dot -> type (DOT)
;
CHN_COMMA
: Comma -> type (COMMA)
;
CHN_WS
: Ws+ -> type (WS) , channel (OFF_CHANNEL)
;
// -------------------------
mode LexerCharSet;
LEXER_CHAR_SET_BODY
: (~ [\]\\] | EscAny)+ -> more
;
LEXER_CHAR_SET
: RBrack -> popMode
;
UNTERMINATED_CHAR_SET
: EOF -> popMode
;
// ------------------------------------------------------------------------------
// Grammar specific Keywords, Punctuation, etc.
fragment Id
: NameStartChar NameChar*
;
| 9,522 | ANTLR | .g4 | 429 | 18.979021 | 85 | 0.627656 | wadoon/antlr4-doc | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 0ebbe7e442539865bc089a209632e13e613a6661814db82efde15b33b32f3c57 | true | true | false | false |
200 | ANTLRv4Parser.g4 | wadoon_antlr4-doc/src/main/antlr4/ANTLRv4Parser.g4 | /*
* [The "BSD license"]
* Copyright (c) 2012-2014 Terence Parr
* Copyright (c) 2012-2014 Sam Harwell
* Copyright (c) 2015 Gerald Rosenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* A grammar for ANTLR v4 written in ANTLR v4.
*
* Modified 2015.06.16 gbr
* -- update for compatibility with Antlr v4.5
* -- add mode for channels
* -- moved members to LexerAdaptor
* -- move fragments to imports
*/
parser grammar ANTLRv4Parser;
options { tokenVocab = ANTLRv4Lexer; }
// The main entry point for parsing a v4 grammar.
grammarSpec
: DOC_COMMENT* grammarDecl prequelConstruct* rules modeSpec* EOF
;
grammarDecl
: grammarType identifier SEMI
;
grammarType
: (LEXER GRAMMAR | PARSER GRAMMAR | GRAMMAR)
;
// This is the list of all constructs that can be declared before
// the set of rules that compose the grammar, and is invoked 0..n
// times by the grammarPrequel rule.
prequelConstruct
: optionsSpec
| delegateGrammars
| tokensSpec
| channelsSpec
| action_
;
// ------------
// Options - things that affect analysis and/or code generation
optionsSpec
: OPTIONS LBRACE (option SEMI)* RBRACE
;
option
: identifier ASSIGN optionValue
;
optionValue
: identifier (DOT identifier)*
| STRING_LITERAL
| actionBlock
| INT
;
// ------------
// Delegates
delegateGrammars
: IMPORT delegateGrammar (COMMA delegateGrammar)* SEMI
;
delegateGrammar
: identifier ASSIGN identifier
| identifier
;
// ------------
// Tokens & Channels
tokensSpec
: TOKENS LBRACE idList? RBRACE
;
channelsSpec
: CHANNELS LBRACE idList? RBRACE
;
idList
: identifier (COMMA identifier)* COMMA?
;
// Match stuff like @parser::members {int i;}
action_
: AT (actionScopeName COLONCOLON)? identifier actionBlock
;
// Scope names could collide with keywords; allow them as ids for action scopes
actionScopeName
: identifier
| LEXER
| PARSER
;
actionBlock
: BEGIN_ACTION ACTION_CONTENT* END_ACTION
;
argActionBlock
: BEGIN_ARGUMENT ARGUMENT_CONTENT* END_ARGUMENT
;
modeSpec
: MODE identifier SEMI lexerRuleSpec*
;
rules
: ruleSpec*
;
ruleSpec
: parserRuleSpec
| lexerRuleSpec
;
parserRuleSpec
: DOC_COMMENT* ruleModifiers? RULE_REF argActionBlock? ruleReturns? throwsSpec? localsSpec? rulePrequel* COLON ruleBlock SEMI exceptionGroup
;
exceptionGroup
: exceptionHandler* finallyClause?
;
exceptionHandler
: CATCH argActionBlock actionBlock
;
finallyClause
: FINALLY actionBlock
;
rulePrequel
: optionsSpec
| ruleAction
;
ruleReturns
: RETURNS argActionBlock
;
// --------------
// Exception spec
throwsSpec
: THROWS identifier (COMMA identifier)*
;
localsSpec
: LOCALS argActionBlock
;
/** Match stuff like @init {int i;} */ ruleAction
: AT identifier actionBlock
;
ruleModifiers
: ruleModifier+
;
// An individual access modifier for a rule. The 'fragment' modifier
// is an internal indication for lexer rules that they do not match
// from the input but are like subroutines for other lexer rules to
// reuse for certain lexical patterns. The other modifiers are passed
// to the code generation templates and may be ignored by the template
// if they are of no use in that language.
ruleModifier
: PUBLIC
| PRIVATE
| PROTECTED
| FRAGMENT
;
ruleBlock
: ruleAltList
;
ruleAltList
: labeledAlt (OR labeledAlt)*
;
labeledAlt
: alternative (POUND identifier)?
;
// --------------------
// Lexer rules
lexerRuleSpec
: DOC_COMMENT* FRAGMENT? TOKEN_REF COLON lexerRuleBlock SEMI
;
lexerRuleBlock
: lexerAltList
;
lexerAltList
: lexerAlt (OR lexerAlt)*
;
lexerAlt
: lexerElements lexerCommands?
|
// explicitly allow empty alts
;
lexerElements
: lexerElement+
;
lexerElement
: labeledLexerElement ebnfSuffix?
| lexerAtom ebnfSuffix?
| lexerBlock ebnfSuffix?
| actionBlock QUESTION?
;
// but preds can be anywhere
labeledLexerElement
: identifier (ASSIGN | PLUS_ASSIGN) (lexerAtom | lexerBlock)
;
lexerBlock
: LPAREN lexerAltList RPAREN
;
// E.g., channel(HIDDEN), skip, more, mode(INSIDE), push(INSIDE), pop
lexerCommands
: RARROW lexerCommand (COMMA lexerCommand)*
;
lexerCommand
: lexerCommandName LPAREN lexerCommandExpr RPAREN
| lexerCommandName
;
lexerCommandName
: identifier
| MODE
;
lexerCommandExpr
: identifier
| INT
;
// --------------------
// Rule Alts
altList
: alternative (OR alternative)*
;
alternative
: elementOptions? element+
|
// explicitly allow empty alts
;
element
: labeledElement (ebnfSuffix |)
| atom (ebnfSuffix |)
| ebnf
| actionBlock QUESTION?
;
labeledElement
: identifier (ASSIGN | PLUS_ASSIGN) (atom | block)
;
// --------------------
// EBNF and blocks
ebnf
: block blockSuffix?
;
blockSuffix
: ebnfSuffix
;
ebnfSuffix
: QUESTION QUESTION?
| STAR QUESTION?
| PLUS QUESTION?
;
lexerAtom
: characterRange
| terminal
| notSet
| LEXER_CHAR_SET
| DOT elementOptions?
;
atom
: terminal
| ruleref
| notSet
| DOT elementOptions?
;
// --------------------
// Inverted element set
notSet
: NOT setElement
| NOT blockSet
;
blockSet
: LPAREN setElement (OR setElement)* RPAREN
;
setElement
: TOKEN_REF elementOptions?
| STRING_LITERAL elementOptions?
| characterRange
| LEXER_CHAR_SET
;
// -------------
// Grammar Block
block
: LPAREN (optionsSpec? ruleAction* COLON)? altList RPAREN
;
// ----------------
// Parser rule ref
ruleref
: RULE_REF argActionBlock? elementOptions?
;
// ---------------
// Character Range
characterRange
: STRING_LITERAL RANGE STRING_LITERAL
;
terminal
: TOKEN_REF elementOptions?
| STRING_LITERAL elementOptions?
;
// Terminals may be adorned with certain options when
// reference in the grammar: TOK<,,,>
elementOptions
: LT elementOption (COMMA elementOption)* GT
;
elementOption
: identifier
| identifier ASSIGN (identifier | STRING_LITERAL)
;
identifier
: RULE_REF
| TOKEN_REF
;
| 7,707 | ANTLR | .g4 | 314 | 21.22293 | 143 | 0.706838 | wadoon/antlr4-doc | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 793385d75b28852671a1b94cc2cf812a54ed32bcc630b26dc5556994a9d0439f | true | true | false | false |
201 | Jasm.g4 | Parisoft_ninjava/ninjava-plugin/src/main/antlr4/Jasm.g4 | grammar Jasm;
file
: (header? EOL)+ dtClass EOL*
;
header
: comment
| dtImport
| iNesMap
| iNesPrg
| iNesChr
| iNesMir
| nes2ChrRAM
| nes2PrgRAM
| nes2Sub
| nes2TV
| nes2VS
| nes2BRAM
| nes2ChrBRAM
;
directive
: dtImport
| dtClass
| dtField
| dtVar
| dtZp
| dtDB
| dtDW
| dtPrg
| dtChr
| dtDmc
| dtFunction
| dtMethod
| dtMacro
| dtIncbin
| dtInclude
;
dtImport
: '.import' qname comment?
;
dtClass
: '.class' dtFinal? dtSingleton? qname dtExtends? dtImplements? comment? (line? EOL)+ '.endclass' comment?
;
dtFinal
: '.final'
;
dtSingleton
: '.singleton'
;
dtExtends
: '.extends' (qname | name)
;
dtImplements
: '.implements' (qname | name) (',' (qname | name))*
;
dtField
: '.field' name expr comment?
;
dtVar
: '.var' name expr comment?
;
dtZp
: '.zp' name expr comment?
;
dtDB
: '.db' expr (',' expr)* comment?
;
dtDW
: '.dw' expr (',' expr)* comment?
;
dtPrg
: '.prg' expr comment?
;
dtChr
: '.chr' expr comment?
;
dtDmc
: '.dmc' expr comment?
;
dtMethod
: '.met' fname comment? EOL body '.endmet' comment?
;
dtFunction
: '.fun' fname comment? EOL body '.endfun' comment?
;
dtMacro
: '.mac' name params comment? EOL body '.endmac' comment?
;
dtInclude
: ('.include' | 'incsrc') string comment?
;
dtIncbin
: '.incbin' string comment?
;
dtFree
: '.free' (name | qname | pname) comment?
;
dtIf
: '.if' expr comment? EOL body dtElse
;
dtElse
: '.else' comment? EOL body '.endif' comment? #Else
| '.else' dtIf #ElseIf
| '.endif' comment? #EndIf
;
dtIfDef
: '.ifdef' (name | qname | pname) comment? EOL body '.endif' comment?
;
dtIfNDef
: '.ifndef' (name | qname | pname) comment? EOL body '.endif' comment?
;
dtRept
: '.rept' expr comment? EOL body '.endrept' comment?
;
iNesMap // Mapper number of NES ROM.
: '.inesmap' expr comment?
;
iNesPrg // Number of 16KiB PRG ROM banks in a NES ROM.
: '.inesprg' expr comment?
;
iNesChr // Number of 8KiB CHR ROM banks in a NES ROM.
: '.ineschr' expr comment?
;
iNesMir // Mirroring mode of a NES ROM.
: '.inesmir' expr comment?
;
nes2ChrRAM // Amount of CHR RAM used by a NES ROM.
: '.nes2chrram' expr comment?
;
nes2PrgRAM // Amount of PRG RAM used by a NES ROM.
: '.nes2prgram' expr comment?
;
nes2Sub // Submapper number of NES ROM.
: '.nes2sub' expr comment?
;
nes2TV // TV mode of NES ROM: NTSC, PAL, or both (0, 1 or 2) ('N', 'P' or 'B')
: '.nes2tv' expr comment?
;
nes2VS // Sets ROM to use the Vs. Unisystem.
: '.nes2vs' expr comment?
;
nes2BRAM // Amount of battery-packed PRG RAM in NES ROM.
: '.nes2bram' expr comment?
;
nes2ChrBRAM // Amount of battery-packed CHR RAM in NES ROM.
: '.nes2chrbram' expr comment?
;
callMacro
: (name | qname) (expr (',' expr)*)? comment?
;
label
: lname comment?
;
symbol
: name '=' expr comment?
;
line
: comment
| directive
| label
| symbol
;
params
: pname*
;
body
: (stmt? EOL)+
;
stmt
: comment
| dtVar
| dtZp
| dtFree
| dtIf
| dtIfDef
| dtIfNDef
| dtRept
| label
| symbol
| callMacro
| instruction
;
instruction
: label? opcode arg? comment?
;
arg
: '#' expr #Immediate
| '(' expr ',' ('x' | 'X') ')' #IndirectX
| '(' expr ')' ',' ('y' | 'Y') #IndirectY
| '(' expr ')' #Indirect
| expr ',' ('x' | 'X') #AbsoluteX
| expr ',' ('y' | 'Y') #AbsoluteY
| expr #Absolute
;
expr
: op=('-' | '+' | '~' | '!' | '<' | '>' | '.sizeof') right=expr #UnaryExpr
| left=expr op=('*' | '/' | '%') right=expr #MultiplicativeExpr
| left=expr op=('+' | '-') right=expr #AdditiveExpr
| left=expr op=('<<' | '>>') right=expr #ShiftExpr
| left=expr op=('<' | '>' | '<=' | '>=') right=expr #RelationalExpr
| left=expr op=('==' | '!=') right=expr #EqualityExpr
| left=expr '&' right=expr #BitAndExpr
| left=expr '^' right=expr #BitXorExpr
| left=expr '|' right=expr #BitOrExpr
| '(' left=expr ')' #ParensExpr
| number #NumLiteral
| identifier #Reference
| '$' #PC
;
identifier
: lname
| fname
| pname
| qname
| name
;
lname
: NAME ':'
| '+'+
| '-'+
;
fname
: NAME '(' (NAME '[]'* (',' NAME '[]'*)*)? ')'
;
pname
: PNAME
;
qname
: NAME ('.' NAME)+
;
name
: NAME
;
string
: STRING
;
number
: HEX_NUM
| BIN_NUM
| DEC_NUM
| CHA_NUM
;
comment
: COMMENT
;
opcode
: ADC
| AND
| ASL
| BCC
| BCS
| BEQ
| BIT
| BMI
| BNE
| BPL
| BVC
| BVS
| CLC
| CLD
| CLI
| CLV
| CMP
| CPX
| CPY
| DEC
| DEX
| DEY
| EOR
| INC
| INX
| INY
| JMP
| JSR
| JSS
| JCC
| JCS
| JEQ
| JMI
| JNE
| JPL
| JVC
| JVS
| LDA
| LDY
| LDX
| LSR
| NOP
| ORA
| PHA
| PHP
| PLA
| PLP
| ROL
| ROR
| RTI
| RTS
| SBC
| SEC
| SED
| SEI
| STA
| STX
| STY
| TAX
| TAY
| TSX
| TXA
| TXS
| TYA
;
fragment A
: ('a' | 'A')
;
fragment B
: ('b' | 'B')
;
fragment C
: ('c' | 'C')
;
fragment D
: ('d' | 'D')
;
fragment E
: ('e' | 'E')
;
fragment F
: ('f' | 'F')
;
fragment G
: ('g' | 'G')
;
fragment H
: ('h' | 'H')
;
fragment I
: ('i' | 'I')
;
fragment J
: ('j' | 'J')
;
fragment K
: ('k' | 'K')
;
fragment L
: ('l' | 'L')
;
fragment M
: ('m' | 'M')
;
fragment N
: ('n' | 'N')
;
fragment O
: ('o' | 'O')
;
fragment P
: ('p' | 'P')
;
fragment Q
: ('q' | 'Q')
;
fragment R
: ('r' | 'R')
;
fragment S
: ('s' | 'S')
;
fragment T
: ('t' | 'T')
;
fragment U
: ('u' | 'U')
;
fragment V
: ('v' | 'V')
;
fragment W
: ('w' | 'W')
;
fragment X
: ('x' | 'X')
;
fragment Y
: ('y' | 'Y')
;
fragment Z
: ('z' | 'Z')
;
ADC
: A D C
;
AND
: A N D
;
ASL
: A S L
;
BCC
: B C C
;
BCS
: B C S
;
BEQ
: B E Q
;
BIT
: B I T
;
BMI
: B M I
;
BNE
: B N E
;
BPL
: B P L
;
BVC
: B V C
;
BVS
: B V S
;
CLC
: C L C
;
CLD
: C L D
;
CLI
: C L I
;
CLV
: C L V
;
CMP
: C M P
;
CPX
: C P X
;
CPY
: C P Y
;
DEC
: D E C
;
DEX
: D E X
;
DEY
: D E Y
;
EOR
: E O R
;
INC
: I N C
;
INX
: I N X
;
INY
: I N Y
;
JMP
: J M P
;
JSR
: J S R
;
JSS
: J S S
;
JCC
: J C C
;
JCS
: J C S
;
JEQ
: J E Q
;
JMI
: J M I
;
JNE
: J N E
;
JPL
: J P L
;
JVC
: J V C
;
JVS
: J V S
;
LDA
: L D A
;
LDY
: L D Y
;
LDX
: L D X
;
LSR
: L S R
;
NOP
: N O P
;
ORA
: O R A
;
PHA
: P H A
;
PHP
: P H P
;
PLA
: P L A
;
PLP
: P L P
;
ROL
: R O L
;
ROR
: R O R
;
RTI
: R T I
;
RTS
: R T S
;
SBC
: S B C
;
SEC
: S E C
;
SED
: S E D
;
SEI
: S E I
;
STA
: S T A
;
STX
: S T X
;
STY
: S T Y
;
TAX
: T A X
;
TAY
: T A Y
;
TSX
: T S X
;
TXA
: T X A
;
TXS
: T X S
;
TYA
: T Y A
;
NAME
: [a-zA-Z_] [a-zA-Z0-9_]*
;
PNAME
: '@' [a-zA-Z_] [a-zA-Z0-9_]*
;
HEX_NUM
: '$' [0-9a-fA-F] +
;
BIN_NUM
: '%' [0-1]+
;
DEC_NUM
: [0-9]+
;
CHA_NUM
: '\''~ ["]'\''
;
COMMENT
: ';' ~ [\r\n]* -> skip
;
STRING
: '"' ~ ["]* '"'
;
EOL
: [\r\n] +
;
WS
: [ \t] -> skip
; | 7,611 | ANTLR | .g4 | 610 | 9.286885 | 110 | 0.511229 | Parisoft/ninjava | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 6ed473fddfb5fbdc928a45bf7cd62dda1767991f3fbfa9ec3ff76d668f8bae9c | false | false | false | false |
202 | makelex.g4 | Icraus_MakefileGrammar/makelex.g4 | lexer grammar makelex;
COMMENT: '#' ~('\r' | '\n')* '\r'? '\n' -> skip;
WS: [ \r\n] -> skip;
INCLUDE: 'include';
DASH: '-';
DEFINE: 'define';
ENDEF: 'endef';
EQUAL: '=';
TARGETSEP: ':' ':'?;
VARSEP: ':' ':'? '=';
VARNOT: '!=';
PLUSEQUAL: '+=';
ELEQUAL: '?=';
EXPORT: 'export';
UNEXPORT: 'unexport';
VPATH: 'vpath';
OVERRIDE: 'override';
ENDIF: 'endif';
ELSE: 'else';
IF: 'ifeq';
IFNEQ: 'ifneq';
IFDEF: 'ifdef';
LBRACE: '(';
RBRACE: ')';
PIPE: '|';
VARTOKEN: '$';
COMMA: ',';
STRING: '"' ~('"')* '"';
SSTRING: '\'' ~('\'')* '\'';
ID: ('_' | [\\/] | '-' | '.' | '*' | '%' | [0-9] | [a-zA-Z])+;
BODYLNSTART: '\t' ~('\t'| '\r' | '\n')+;
| 672 | ANTLR | .g4 | 31 | 19.419355 | 62 | 0.476744 | Icraus/MakefileGrammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 8e1180bf367fc05564c80a8ba3929c99c32d5c86b9f581248095ab2c0708f916 | false | false | false | false |
203 | make.g4 | Icraus_MakefileGrammar/make.g4 | grammar make;
options { tokenVocab=makelex; }
makeFile : (nonblocks)* EOF;
nonblocks : directives | varDeclare | target | ifdefblock| defineBlock | ifblock;
directives: export | unexport | includeDirective | vpath | overrideD ;
includeDirective : DASH ? INCLUDE name+ ;
export: EXPORT (name | varDeclare?);
unexport : UNEXPORT name;
vpath: VPATH name+;
overrideD: OVERRIDE (name | varDeclare?);
varDeclare: name (PLUSEQUAL | EQUAL | VARSEP | ELEQUAL | VARNOT) (name | qstring)+;
target: name+ TARGETSEP (prequesite)? (PIPE orderPrequesites)? makeRule? ;
prequesite: name+;
orderPrequesites : name+;
defineBlock: DEFINE name makeRule ENDEF;
ifblock : ifimpl elseimpl? ENDIF;
ifimpl : (IF | IFNEQ) condition (nonblocks)* ;
condition : LBRACE name COMMA name? RBRACE
| qstring qstring
| sqstring sqstring;
elseimpl: ELSE nonblocks;
ifdefblock : IFDEF name nonblocks ENDEF;
name: VARTOKEN+ LBRACE ID (COMMA name)* RBRACE
| ID (name)*; //deal with names, files, strings later
qstring : STRING;
sqstring : SSTRING;
makeRule: BODYLNSTART+; | 1,086 | ANTLR | .g4 | 27 | 37.444444 | 83 | 0.756385 | Icraus/MakefileGrammar | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | da5517fc4f9fb886f37358e2fa3f958473b6143de325ab4167a7818300774467 | false | false | false | false |
204 | horizon.g4 | leanderlombardi_horizon/horizon.g4 | grammar horizon;
// BASIC
program
:
line* EOF
;
line
:
command
| assignment
| functionCall
| functionBlock
| functionalFunctionBlock
| ifBlock
| whileBlock
| classBlock
| returnStatement
| expression
| reassignment
;
// COMMANDS
includeCommand
:
'include'
(
'<' LIBRARY '>'
)
|
(
'"' LIBRARY '"'
)
;
// NORMAL RULES
command
:
COMMAND
(
includeCommand
)
;
assignment
:
'var' ID
(
'[' INT? ']'
)?
(
':' VTYPE
)? '=' VALUE stropt?
| functionalFunctionCall
;
reassignment
:
(
ID ':' VTYPE
)
|
(
ID ':' VTYPE '=' VALUE stropt?
)
|
(
ID '=' VALUE stropt?
)
;
stropt
:
'.'
(
'replace' '(' VALUE VALUE ')'
)
|
(
'lower' '(' ')'
)
|
(
'upper' '(' ')'
)
;
functionCall
:
(
ID '('
(
VALUE
(
',' VALUE
)*?
)? ')'
)
| 'println' '(' VALUE ')'
| 'print' '(' VALUE ')'
;
functionalFunctionCall
:
'read' '(' STRING? ')'
| 'readkey' '(' STRING? ')'
;
functionBlock
:
'void' ID '('
(
ID
(
'[' INT? ']'
)?
(
':' VTYPE
)?
(
',' ID
(
'[' INT? ']'
)?
(
':' VTYPE
)?
)*?
)? ')' block
;
functionalFunctionBlock
:
'voidf' ID '('
(
ID
(
'[' INT? ']'
)?
(
':' VTYPE
)?
(
',' ID
(
'[' INT? ']'
)?
(
':' VTYPE
)?
)*?
)? ')' blockf
;
ifBlock
:
'if' '(' expression
(
'&&' expression
)*? ')' block
(
elseIfBlock
)?
;
elseIfBlock
:
'else' ifBlock?
| block
;
whileBlock
:
'while' '(' expression
(
'&&' expression
)*? ')' block
;
classBlock
:
'class' ID block
;
returnStatement
:
'return' VALUE
;
expression
:
VALUE BOOLOP VALUE # boolexpr
|
(
INT
| FLOAT
) MULOP
(
INT
| FLOAT
) # mulexpr
|
(
INT
| FLOAT
) ADDOP
(
INT
| FLOAT
) # addexpr
| TYPE # constexpr
| '(' expression ')' # parenexpr
| ID # idexpr
;
// SOME RULES
block
:
'{' line* '}'
;
blockf
:
'{' line* returnStatement '}'
;
ADDOP
:
'+'
| '-'
;
BOOLOP
:
'=='
| '!='
| '>'
| '<'
| '>='
| '<='
;
MULOP
:
'*'
| '/'
;
COMMAND
:
'#'
;
LIBRARY
:
ID '.f'
;
TYPE
:
STRING
| INT
| FLOAT
| BOOL
;
VTYPE
:
VSTRING
| VINT
| VFLOAT
| VBOOL
;
VSTRING
:
'string'
;
VINT
:
'int'
;
VFLOAT
:
'float'
;
VBOOL
:
'bool'
;
INT
:
[0-9]+
;
FLOAT
:
[0-9]+ '.' [0-9]+
;
STRING
:
'"'
(
ID
|
(
'$' '{' ID '}'
)*?
)*? '"'
;
BOOL
:
'true'
| 'false'
;
VALUE
:
INT
| FLOAT
| STRING
| BOOL
;
ID
:
[a-z]+
;
WS
:
[ \t\r\n]+ -> skip
;
| 2,447 | ANTLR | .g4 | 303 | 6.013201 | 33 | 0.525915 | leanderlombardi/horizon | 0 | 0 | 0 | GPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 5e4b17b09e5523cf0525ac140781cb76fcbcd973a244899f9bcec3d5b72c9d71 | false | false | false | false |
205 | DPLLexer.g4 | teragrep_pth_03/src/main/antlr4/com/teragrep/pth_03/antlr/DPLLexer.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
// -*- mode: conf; -*-
lexer grammar DPLLexer;
import GET_BOOLEAN, GET_INTEGER, GET_FIELD, GET_NUMBER, GET_INDEX_STRING, GET_REGEX_STRING, GET_SORT_FIELD, GET_TIME, GET_SPAN, GET_STRING, GET_WHERE_MODE, GET_WHERE_MODE_BY ,GET_T_OR_B, COMMAND_ABSTRACT_MODE, COMMAND_ACCUM_MODE, COMMAND_ADDCOLTOTALS_MODE, COMMAND_ADDINFO_MODE, COMMAND_ADDTOTALS_MODE, COMMAND_AGGREGATION_MODE, COMMAND_ANALYZEFIELDS_MODE, COMMAND_ANOMALIES_MODE, COMMAND_ANOMALOUSVALUE_MODE, COMMAND_ANOMALYDETECTION_MODE, COMMAND_APPENDCOLS_MODE, COMMAND_APPEND_MODE, COMMAND_APPENDPIPE_MODE, COMMAND_ARULES_MODE, COMMAND_ASSOCIATE_MODE, COMMAND_AUDIT_MODE, COMMAND_AUTOREGRESS_MODE, COMMAND_BIN_MODE, COMMAND_BUCKETDIR_MODE, COMMAND_CHART_MODE, COMMAND_CLUSTER_MODE, COMMAND_COFILTER_MODE, COMMAND_COLLAPSE_MODE, COMMAND_COLLECT_MODE, COMMAND_CONCURRENCY_MODE, COMMAND_CONTINGENCY_MODE, COMMAND_CONVERT_MODE, COMMAND_CORRELATE_MODE, COMMAND_DATAMODEL_MODE, COMMAND_DBINSPECT_MODE, COMMAND_DEDUP_MODE, COMMAND_DELETE_MODE, COMMAND_DELTA_MODE, COMMAND_DIFF_MODE, COMMAND_DPL_MODE, COMMAND_DUMP_MODE, COMMAND_EREX_MODE, COMMAND_EVAL_SUBMODE_BASE, EVAL_LANGUAGE_MODE, COMMAND_EVENTCOUNT_MODE, COMMAND_EVENTSTATS_MODE, COMMAND_EXPLAIN_MODE, COMMAND_EXTRACT_MODE, COMMAND_FIELDS_MODE, COMMAND_FIELDFORMAT_MODE, COMMAND_FIELDSUMMARY_MODE, COMMAND_FILLDOWN_MODE, COMMAND_FILLNULL_MODE, COMMAND_FINDKEYWORDS_MODE, COMMAND_FINDTYPES_MODE, COMMAND_FOLDERIZE_MODE, COMMAND_FOREACH_MODE, COMMAND_FORMAT_MODE, COMMAND_FROM_MODE, COMMAND_GAUGE_MODE, COMMAND_GENTIMES_MODE, COMMAND_GEOMFILTER_MODE, COMMAND_GEOM_MODE, COMMAND_GEOSTATS_MODE, COMMAND_HEAD_MODE, COMMAND_HIGHLIGHT_MODE, COMMAND_HISTORY_MODE, COMMAND_ICONIFY_MODE, COMMAND_INPUTCSV_MODE, COMMAND_INPUTLOOKUP_MODE, COMMAND_IPLOCATION_MODE, COMMAND_JOIN_MODE, COMMAND_KMEANS_MODE, COMMAND_KVFORM_MODE, COMMAND_LOADJOB_MODE, COMMAND_LOCALIZE_MODE, COMMAND_LOCALOP_MODE, COMMAND_LOOKUP_MODE, COMMAND_MAKECONTINUOUS_MODE, COMMAND_MAKEJSON_MODE, COMMAND_MAKEMV_MODE, COMMAND_MAKERESULTS_MODE, COMMAND_MAP_MODE, COMMAND_MCATALOG_MODE, COMMAND_MCOLLECT_MODE, COMMAND_METADATA_MODE, COMMAND_METASEARCH_MODE, COMMAND_MEVENTCOLLECT_MODE, COMMAND_MSTATS_MODE, COMMAND_MULTIKV_MODE, COMMAND_MULTISEARCH_MODE, COMMAND_MVCOMBINE_MODE, COMMAND_MVEXPAND_MODE, COMMAND_NOMV_MODE, COMMAND_OUTLIER_MODE, COMMAND_OUTPUTCSV_MODE, COMMAND_OUTPUTLOOKUP_MODE, COMMAND_OUTPUTTEXT_MODE, COMMAND_OVERLAP_MODE, COMMAND_PIVOT_MODE, COMMAND_PREDICT_MODE, COMMAND_RANGEMAP_MODE, COMMAND_RARE_MODE, COMMAND_REDISTRIBUTE_MODE, COMMAND_REGEX_MODE, COMMAND_RELEVANCY_MODE, COMMAND_RELTIME_MODE, COMMAND_RENAME_MODE, COMMAND_REPLACE_MODE, COMMAND_REST_MODE, COMMAND_RETURN_MODE, COMMAND_REVERSE_MODE, COMMAND_REX_MODE, COMMAND_REX4J_MODE, COMMAND_RTORDER_MODE, COMMAND_RUNSHELLSCRIPT_MODE, COMMAND_SAVEDSEARCH_MODE, COMMAND_SCRIPT_MODE, COMMAND_SCRUB_MODE, COMMAND_SEARCH_MODE, COMMAND_SEARCHTXN_MODE, COMMAND_SELFJOIN_MODE, COMMAND_SENDALERT_MODE, COMMAND_SENDEMAIL_MODE, COMMAND_SETFIELDS_MODE, COMMAND_SET_MODE, COMMAND_SICHART_MODE, COMMAND_SIRARE_MODE, COMMAND_SISTATS_MODE, COMMAND_SITIMECHART_MODE, COMMAND_SITOP_MODE, COMMAND_SORT_MODE, COMMAND_SPATH_MODE, COMMAND_STATS_MODE, COMMAND_STRCAT_MODE, COMMAND_STREAMSTATS_MODE, COMMAND_TABLE_MODE, COMMAND_TAGS_MODE, COMMAND_TAIL_MODE, COMMAND_TERAGREP_MODE, COMMAND_TIMECHART_MODE, COMMAND_TIMEWRAP_MODE, COMMAND_TOP_MODE, COMMAND_TRANSACTION_MODE, COMMAND_TRANSPOSE_MODE, COMMAND_TRENDLINE_MODE, COMMAND_TSCOLLECT_MODE, COMMAND_TSTATS_MODE, COMMAND_TYPEAHEAD_MODE, COMMAND_TYPELEARNER_MODE, COMMAND_TYPER_MODE, COMMAND_UNION_MODE, COMMAND_UNIQ_MODE, COMMAND_UNTABLE_MODE, COMMAND_WHERE_MODE, COMMAND_X11_MODE, COMMAND_XMLKV_MODE, COMMAND_XMLUNESCAPE_MODE, COMMAND_XPATH_MODE, COMMAND_XYSERIES_MODE;
channels { DPLCOMMENT, ERRORCHANNEL }
// ++++++++++++++ DEFAULT_MODE ++++++++++++++
// antlr4 bug, can't say it but it's active already so np
//mode DEFAULT_MODE;
STRING_MATCH: 'default_mode_antlr_bug';
// comments
SPEC_DPL_COMMENT: '<!--' .*? '-->' -> channel(DPLCOMMENT);
// skip
SPACE: [ \t\r\n]+ -> channel(HIDDEN);
// valid for fields
// Reserved words
//indexStatement
INDEX_EQ: 'index=' -> pushMode(GET_STRING);
INDEX_SPACE: 'index' (SPACE)* '=' (SPACE)* -> pushMode(GET_STRING);
INDEX_NEG: 'index!=' -> pushMode(GET_STRING);
INDEX_SPACE_NEG: 'index' (SPACE)* '!=' (SPACE)* -> pushMode(GET_STRING);
INDEX_IN: 'index' (SPACE)* 'IN' (SPACE)* -> pushMode(GET_INDEX_STRING);
//thyme
TIMEFORMAT: 'timeformat' (SPACE)* '=' (SPACE)* -> pushMode(GET_STRING);
EARLIEST: 'earliest' (SPACE)* '=' (SPACE)* -> pushMode(GET_TIME);
INDEX_EARLIEST: '_index_earliest' (SPACE)* '=' (SPACE)* -> pushMode(GET_STRING);
STARTDAYSAGO: 'stardaysago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
STARTHOURSAGO: 'starthoursago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
STARTMINUTESAGO: 'startminutesago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
STARTMONTHSAGO: 'startmonthsago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
STARTTIME: 'starttime' (SPACE)* '=' (SPACE)* -> pushMode(GET_STRING);
STARTTIMEU: 'starttimeu' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
LATEST: 'latest' (SPACE)* '=' (SPACE)* -> pushMode(GET_TIME);
INDEX_LATEST: '_index_latest' (SPACE)* '=' (SPACE)* -> pushMode(GET_STRING);
ENDDAYSAGO: 'enddaysago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
ENDHOURSAGO: 'endhoursago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
ENDMINUTESAGO: 'endminutesago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
ENDMONTHSAGO: 'endmonthsago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
ENDTIME: 'endtime' (SPACE)* '=' (SPACE)* -> pushMode(GET_STRING);
ENDTIMEU: 'endtimeu' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
SEARCHTIMESPANDAYS: 'searchtimespandays' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
SEARCHTIMESPANHOURS: 'searchtimespanhours' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
SEARCHTIMESPANMINUTES: 'searchtimespanminutes' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
SEARCHTIMESPANMONHTS: 'searchtimespanmonths' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
MINUTESAGO: 'minutesago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
HOURSAGO: 'hoursago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
DAYSAGO: 'daysago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
MONTHSAGO: 'monthsago' (SPACE)* '=' (SPACE)* -> pushMode(GET_INTEGER);
//rest
EVENTTYPE: 'eventtype';
EVENTTYPETAG: 'eventtypetag';
HOST: 'host';
HOSTTAG: 'hosttag';
SAVEDSEARCH: 'savedsearch';
SOURCE: 'source';
SOURCETYPE: 'sourcetype';
TAG: 'tag';
AND: 'AND';
NOT: 'NOT';
OR: 'OR';
TERM: 'TERM';
CASE: 'CASE';
IN: 'IN';
// charType, common types
PARENTHESIS_L: '(';
PARENTHESIS_R: ')';
BRACKET_L: '[' -> pushMode(COMMAND_MODE);
BRACKET_R: ']' -> popMode, popMode;
C_BRACKET_L: '{';
C_BRACKET_R: '}';
PIPE: '|' -> pushMode(COMMAND_MODE);
COMMA: ',';
COLON: ':';
DOT: '.';
EXCLAMATION: '!';
QUOTE: '" ';
SINGLE_QUOTE: '\'';
DOLLAR: '$';
AT_SIGN: '@';
// charType, operations between fields and integers
MINUS: '-';
PLUS: '+';
PERCENT: '%';
WILDCARD: '*';
SLASH: '/';
// equality
DEQ: '==';
EQ: '=';
NEQ: '!=';
LT: '<';
LTE: '<=';
GT: '>';
GTE: '>=';
// quotation types
DQSTRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"' -> type(GET_STRING_DOUBLE_QUOTED);
SQSTRING: '\'' ( '\\'. | '""' | ~('"'| '\\') )* '\'' -> type(GET_STRING_SINGLE_QUOTED);
// integers
fragment CHAR
:'\u0022' // "
|'\u0023' // #
|'\u0024' // $
|'\u0025' // %
|'\u0026' // &
|'\u0027' // '
// |'\u0028' // (
// |'\u0029' // )
|'\u002A' // *
|'\u002B' // +
//|'\u002C' // ,
|'\u002D' // -
|'\u002E' // .
|'\u002F' // /
|'\u0030' // 0
|'\u0031' // 1
|'\u0032' // 2
|'\u0033' // 3
|'\u0034' // 4
|'\u0035' // 5
|'\u0036' // 6
|'\u0037' // 7
|'\u0038' // 8
|'\u0039' // 9
|'\u003A' // :
|'\u003B' // ;
|'\u003C' // <
|'\u003D' {false}? // =
|'\u003E' // >
|'\u003F' // ?
|'\u0040' // @
|'\u0041' // A
|'\u0042' // B
|'\u0043' // C
|'\u0044' // D
|'\u0045' // E
|'\u0046' // F
|'\u0047' // G
|'\u0048' // H
|'\u0049' // I
|'\u004A' // J
|'\u004B' // K
|'\u004C' // L
|'\u004D' // M
|'\u004E' // N
|'\u004F' // O
|'\u0050' // P
|'\u0051' // Q
|'\u0052' // R
|'\u0053' // S
|'\u0054' // T
|'\u0055' // U
|'\u0056' // V
|'\u0057' // W
|'\u0058' // X
|'\u0059' // Y
|'\u005A' // Z
// |'\u005B' // [
|'\u005C' // \
// |'\u005D' // ]
|'\u005E' // ^
|'\u005F' // _
|'\u0060' // `
|'\u0061' // a
|'\u0062' // b
|'\u0063' // c
|'\u0064' // d
|'\u0065' // e
|'\u0066' // f
|'\u0067' // g
|'\u0068' // h
|'\u0069' // u
|'\u006A' // j
|'\u006B' // k
|'\u006C' // l
|'\u006D' // m
|'\u006E' // n
|'\u006F' // o
|'\u0070' // p
|'\u0071' // q
|'\u0072' // r
|'\u0073' // s
|'\u0074' // t
|'\u0075' // u
|'\u0076' // v
|'\u0077' // w
|'\u0078' // x
|'\u0079' // y
|'\u007A' // z
|'\u007B' // {
// |'\u007C' // |
|'\u007D' // }
|'\u007E' // ~
|'\u007F'..'\uFFFF' // DEL .. inf
;
STRING
// two or more characters, CHAR_MATCH catches shorter ones
// following still is legal | eval a(="a+a"
// use lexical modes?
: (CHAR)+ -> type(GET_STRING_STRING);
//special case
NULL: 'null';
// hide errors
//ERROR_RECONGNIGION: . -> channel(ERRORCHANNEL);
// ++++++++++++++ COMMAND_MODE ++++++++++++++
mode COMMAND_MODE;
// skip
COMMAND_MODE_SPACE: SPACE -> channel(HIDDEN);
COMMAND_MODE_PIPE: '|' -> type(PIPE);
COMMAND_MODE_ABSTRACT: 'abstract' -> pushMode(COMMAND_ABSTRACT_MODE);
COMMAND_MODE_ACCUM: 'accum' -> pushMode(COMMAND_ACCUM_MODE), pushMode(GET_FIELD);
COMMAND_MODE_ADDCOLTOTALS: 'addcoltotals' -> pushMode(COMMAND_ADDCOLTOTALS_MODE);
COMMAND_MODE_ADDINFO: 'addinfo' -> pushMode(COMMAND_ADDINFO_MODE);
COMMAND_MODE_ADDTOTALS: 'addtotals' -> pushMode(COMMAND_ADDTOTALS_MODE);
COMMAND_MODE_ANALYZEFIELDS: 'analyzefields' -> pushMode(COMMAND_ANALYZEFIELDS_MODE);
COMMAND_MODE_ANOMALIES: 'anomalies' -> pushMode(COMMAND_ANOMALIES_MODE);
COMMAND_MODE_ANOMALOUSVALUE: 'anomalousvalue' -> pushMode(COMMAND_ANOMALOUSVALUE_MODE);
COMMAND_MODE_ANOMALYDETECTION: 'anomalydetection' -> pushMode(COMMAND_ANOMALYDETECTION_MODE);
COMMAND_MODE_APPEND: 'append' -> pushMode(COMMAND_APPEND_MODE);
COMMAND_MODE_APPENDCOLS: 'appendcols' -> pushMode(COMMAND_APPENDCOLS_MODE);
COMMAND_MODE_APPENDPIPE: 'appendpipe' -> pushMode(COMMAND_APPENDPIPE_MODE);
COMMAND_MODE_ARULES: 'arules' -> pushMode(COMMAND_ARULES_MODE);
COMMAND_MODE_ASSOCIATE: 'associate' -> pushMode(COMMAND_ASSOCIATE_MODE);
COMMAND_MODE_AUDIT: 'audit' -> pushMode(COMMAND_AUDIT_MODE);
COMMAND_MODE_AUTOREGRESS: 'autoregress' -> pushMode(COMMAND_AUTOREGRESS_MODE);
COMMAND_MODE_BIN: ('bin'|'bucket') -> pushMode(COMMAND_BIN_MODE);
COMMAND_MODE_BUCKETDIR: 'bucketdir' -> pushMode(COMMAND_BUCKETDIR_MODE);
COMMAND_MODE_CHART: 'chart' -> pushMode(COMMAND_CHART_MODE); // implemented
COMMAND_MODE_CLUSTER: 'cluster' -> pushMode(COMMAND_CLUSTER_MODE);
COMMAND_MODE_COFILTER: 'cofilter' -> pushMode(COMMAND_COFILTER_MODE);
COMMAND_MODE_COLLAPSE: 'collapse' -> pushMode(COMMAND_COLLAPSE_MODE);
COMMAND_MODE_COLLECT: 'collect' -> pushMode(COMMAND_COLLECT_MODE);
COMMAND_MODE_CONCURRENCY: 'concurrency' -> pushMode(COMMAND_CONCURRENCY_MODE);
COMMAND_MODE_CONTINGENCY: ('contingency'|'ctable'|'counttable') -> pushMode(COMMAND_CONTINGENCY_MODE);
COMMAND_MODE_CONVERT: 'convert' -> pushMode(COMMAND_CONVERT_MODE);
COMMAND_MODE_CORRELATE: 'correlate' -> pushMode(COMMAND_CORRELATE_MODE);
COMMAND_MODE_DATAMODEL: 'datamodel' -> pushMode(COMMAND_DATAMODEL_MODE);
COMMAND_MODE_DBINSPECT: 'dbinspect' -> pushMode(COMMAND_DBINSPECT_MODE);
COMMAND_MODE_DEDUP: 'dedup' -> pushMode(COMMAND_DEDUP_MODE);
COMMAND_MODE_DELETE: 'delete' -> pushMode(COMMAND_DELETE_MODE);
COMMAND_MODE_DELTA: 'delta' -> pushMode(COMMAND_DELTA_MODE);
COMMAND_MODE_DIFF: 'diff' -> pushMode(COMMAND_DIFF_MODE);
COMMAND_MODE_DPL: 'dpl' -> pushMode(COMMAND_DPL_MODE);
COMMAND_MODE_DUMP: 'dump' -> pushMode(COMMAND_DUMP_MODE);
COMMAND_MODE_EREX: 'erex' -> pushMode(COMMAND_EREX_MODE);
COMMAND_MODE_EVAL: 'eval' -> pushMode(COMMAND_EVAL_SUBMODE_BASE), pushMode(COMMAND_EVAL_SUBMODE_FIELD); // implemented
COMMAND_MODE_EVENTCOUNT: 'eventcount' -> pushMode(COMMAND_EVENTCOUNT_MODE);
COMMAND_MODE_EVENTSTATS: 'eventstats' -> pushMode(COMMAND_EVENTSTATS_MODE);
COMMAND_MODE_EXPLAIN: 'explain' -> pushMode(COMMAND_EXPLAIN_MODE);
COMMAND_MODE_EXTRACT: 'extract' -> pushMode(COMMAND_EXTRACT_MODE);
COMMAND_MODE_FIELDFORMAT: 'fieldformat' -> pushMode(COMMAND_FIELDFORMAT_MODE);
COMMAND_MODE_FIELDS: 'fields' -> pushMode(COMMAND_FIELDS_MODE);
COMMAND_MODE_FIELDSUMMARY: 'fieldsummary' -> pushMode(COMMAND_FIELDSUMMARY_MODE);
COMMAND_MODE_FILLDOWN: 'filldown' -> pushMode(COMMAND_FILLDOWN_MODE);
COMMAND_MODE_FILLNULL: 'fillnull' -> pushMode(COMMAND_FILLNULL_MODE);
COMMAND_MODE_FINDKEYWORDS: 'findkeywords' -> pushMode(COMMAND_FINDKEYWORDS_MODE);
COMMAND_MODE_FINDTYPES: 'findtypes' -> pushMode(COMMAND_FINDTYPES_MODE);
COMMAND_MODE_FOLDERIZE: 'folderize' -> pushMode(COMMAND_FOLDERIZE_MODE);
COMMAND_MODE_FOREACH: 'foreach' -> pushMode(COMMAND_FOREACH_MODE);
COMMAND_MODE_FORMAT: 'format' -> pushMode(COMMAND_FORMAT_MODE);
COMMAND_MODE_FROM: 'from' -> pushMode(COMMAND_FROM_MODE);
COMMAND_MODE_GAUGE: 'gauge' -> pushMode(COMMAND_GAUGE_MODE);
COMMAND_MODE_GENTIMES: 'gentimes' -> pushMode(COMMAND_GENTIMES_MODE);
COMMAND_MODE_GEOM: 'geom' -> pushMode(COMMAND_GEOM_MODE);
COMMAND_MODE_GEOMFILTER: 'geomfilter' -> pushMode(COMMAND_GEOMFILTER_MODE);
COMMAND_MODE_GEOSTATS: 'geostats' -> pushMode(COMMAND_GEOSTATS_MODE);
COMMAND_MODE_HEAD: 'head' -> pushMode(COMMAND_HEAD_MODE);
COMMAND_MODE_HIGHLIGHT: 'highlight' -> pushMode(COMMAND_HIGHLIGHT_MODE);
COMMAND_MODE_HISTORY: 'history' -> pushMode(COMMAND_HISTORY_MODE);
COMMAND_MODE_ICONIFY: 'iconify' -> pushMode(COMMAND_ICONIFY_MODE);
COMMAND_MODE_INPUTCSV: 'inputcsv' -> pushMode(COMMAND_INPUTCSV_MODE);
COMMAND_MODE_INPUTLOOKUP: 'inputlookup' -> pushMode(COMMAND_INPUTLOOKUP_MODE);
COMMAND_MODE_IPLOCATION: 'iplocation' -> pushMode(COMMAND_IPLOCATION_MODE);
COMMAND_MODE_JOIN: 'join' -> pushMode(COMMAND_JOIN_MODE);
COMMAND_MODE_KMEANS: 'kmeans' -> pushMode(COMMAND_KMEANS_MODE);
COMMAND_MODE_KVFORM: 'kvform' -> pushMode(COMMAND_KVFORM_MODE);
COMMAND_MODE_LOADJOB: 'loadjob' -> pushMode(COMMAND_LOADJOB_MODE);
COMMAND_MODE_LOCALIZE: 'localize' -> pushMode(COMMAND_LOCALIZE_MODE);
COMMAND_MODE_LOCALOP: 'localop' -> pushMode(COMMAND_LOCALOP_MODE);
COMMAND_MODE_LOOKUP: 'lookup' -> pushMode(COMMAND_LOOKUP_MODE);
COMMAND_MODE_MAKECONTINUOUS: 'makecontinuous' -> pushMode(COMMAND_MAKECONTINUOUS_MODE);
COMMAND_MODE_MAKEJSON: 'makejson' -> pushMode(COMMAND_MAKEJSON_MODE);
COMMAND_MODE_MAKEMV: 'makemv' -> pushMode(COMMAND_MAKEMV_MODE);
COMMAND_MODE_MAKERESULTS: 'makeresults' -> pushMode(COMMAND_MAKERESULTS_MODE);
COMMAND_MODE_MAP: 'map' -> pushMode(COMMAND_MAP_MODE);
COMMAND_MODE_MCATALOG: 'mcatalog' -> pushMode(COMMAND_MCATALOG_MODE);
COMMAND_MODE_MCOLLECT: 'mcollect' -> pushMode(COMMAND_MCOLLECT_MODE);
COMMAND_MODE_METADATA: 'metadata' -> pushMode(COMMAND_METADATA_MODE);
COMMAND_MODE_METASEARCH: 'metasearch' -> pushMode(COMMAND_METASEARCH_MODE);
COMMAND_MODE_MEVENTCOLLECT: 'meventcollect' -> pushMode(COMMAND_MEVENTCOLLECT_MODE);
COMMAND_MODE_MSTATS: 'mstats' -> pushMode(COMMAND_MSTATS_MODE);
COMMAND_MODE_MULTIKV: 'multikv' -> pushMode(COMMAND_MULTIKV_MODE);
COMMAND_MODE_MULTISEARCH: 'multisearch' -> pushMode(COMMAND_MULTISEARCH_MODE);
COMMAND_MODE_MVCOMBINE: 'mvcombine' -> pushMode(COMMAND_MVCOMBINE_MODE);
COMMAND_MODE_MVEXPAND: 'mvexpand' -> pushMode(COMMAND_MVEXPAND_MODE);
COMMAND_MODE_NOMV: 'nomv' -> pushMode(COMMAND_NOMV_MODE);
COMMAND_MODE_OUTLIER: 'outlier' -> pushMode(COMMAND_OUTLIER_MODE);
COMMAND_MODE_OUTPUTCSV: 'outputcsv' -> pushMode(COMMAND_OUTPUTCSV_MODE);
COMMAND_MODE_OUTPUTLOOKUP: 'outputlookup' -> pushMode(COMMAND_OUTPUTLOOKUP_MODE);
COMMAND_MODE_OUTPUTTEXT: 'outputtext' -> pushMode(COMMAND_OUTPUTTEXT_MODE);
COMMAND_MODE_OVERLAP: 'overlap' -> pushMode(COMMAND_OVERLAP_MODE);
COMMAND_MODE_PIVOT: 'pivot' -> pushMode(COMMAND_PIVOT_MODE);
COMMAND_MODE_PREDICT: 'predict' -> pushMode(COMMAND_PREDICT_MODE);
COMMAND_MODE_RANGEMAP: 'rangemap' -> pushMode(COMMAND_RANGEMAP_MODE);
COMMAND_MODE_RARE: 'rare' -> pushMode(COMMAND_RARE_MODE);
COMMAND_MODE_REDISTRIBUTE: 'redistribute' -> pushMode(COMMAND_REDISTRIBUTE_MODE);
COMMAND_MODE_REGEX: 'regex' -> pushMode(COMMAND_REGEX_MODE);
COMMAND_MODE_RELEVANCY: 'relevancy' -> pushMode(COMMAND_RELEVANCY_MODE);
COMMAND_MODE_RELTIME: 'reltime' -> pushMode(COMMAND_RELTIME_MODE);
COMMAND_MODE_RENAME: 'rename' -> pushMode(COMMAND_RENAME_MODE);
COMMAND_MODE_REPLACE: 'replace' -> pushMode(COMMAND_REPLACE_MODE);
COMMAND_MODE_REST: 'rest' -> pushMode(COMMAND_REST_MODE);
COMMAND_MODE_RETURN: 'return' -> pushMode(COMMAND_RETURN_MODE);
COMMAND_MODE_REVERSE: 'reverse' -> pushMode(COMMAND_REVERSE_MODE);
COMMAND_MODE_REX: 'rex' -> pushMode(COMMAND_REX_MODE);
COMMAND_MODE_REX4J: 'rex4j' -> pushMode(COMMAND_REX4J_MODE);
COMMAND_MODE_RTORDER: 'rtorder' -> pushMode(COMMAND_RTORDER_MODE);
COMMAND_MODE_RUNSHELLSCRIPT: 'runshellscript' -> pushMode(COMMAND_RUNSHELLSCRIPT_MODE);
COMMAND_MODE_SAVEDSEARCH: 'savedsearch' -> pushMode(COMMAND_SAVEDSEARCH_MODE);
COMMAND_MODE_SCRIPT: 'script' -> pushMode(COMMAND_SCRIPT_MODE);
COMMAND_MODE_SCRUB: 'scrub' -> pushMode(COMMAND_SCRUB_MODE);
COMMAND_MODE_SEARCH: 'search' -> pushMode(DEFAULT_MODE);
COMMAND_MODE_SEARCHTXN: 'searchtxn' -> pushMode(COMMAND_SEARCHTXN_MODE);
COMMAND_MODE_SELFJOIN: 'selfjoin' -> pushMode(COMMAND_SELFJOIN_MODE);
COMMAND_MODE_SENDALERT: 'sendalert' -> pushMode(COMMAND_SENDALERT_MODE);
COMMAND_MODE_SENDEMAIL: 'sendemail' -> pushMode(COMMAND_SENDEMAIL_MODE);
COMMAND_MODE_SET: 'set' -> pushMode(COMMAND_SET_MODE);
COMMAND_MODE_SETFIELDS: 'setfields' -> pushMode(COMMAND_SETFIELDS_MODE);
COMMAND_MODE_SICHART: 'sichart' -> pushMode(COMMAND_SICHART_MODE);
COMMAND_MODE_SIRARE: 'sirare' -> pushMode(COMMAND_SIRARE_MODE);
COMMAND_MODE_SISTATS: 'sistats' -> pushMode(COMMAND_SISTATS_MODE);
COMMAND_MODE_SITIMECHART: 'sitimechart' -> pushMode(COMMAND_SITIMECHART_MODE);
COMMAND_MODE_SITOP: 'sitop' -> pushMode(COMMAND_SITOP_MODE);
COMMAND_MODE_SORT: 'sort' -> pushMode(COMMAND_SORT_MODE);
COMMAND_MODE_SPATH: 'spath' -> pushMode(COMMAND_SPATH_MODE);
COMMAND_MODE_STATS: 'stats' -> pushMode(COMMAND_STATS_MODE);
COMMAND_MODE_STRCAT: 'strcat' -> pushMode(COMMAND_STRCAT_MODE);
COMMAND_MODE_STREAMSTATS: 'streamstats' -> pushMode(COMMAND_STREAMSTATS_MODE);
COMMAND_MODE_TABLE: 'table' -> pushMode(COMMAND_TABLE_MODE);
COMMAND_MODE_TAGS: 'tags' -> pushMode(COMMAND_TAGS_MODE);
COMMAND_MODE_TAIL: 'tail' -> pushMode(COMMAND_TAIL_MODE);
COMMAND_MODE_TERAGREP: 'teragrep' -> pushMode(COMMAND_TERAGREP_MODE);
COMMAND_MODE_TIMECHART: 'timechart' -> pushMode(COMMAND_TIMECHART_MODE); // implemented
COMMAND_MODE_TIMEWRAP: 'timewrap' -> pushMode(COMMAND_TIMEWRAP_MODE);
COMMAND_MODE_TOP: 'top' -> pushMode(COMMAND_TOP_MODE);
COMMAND_MODE_TRANSACTION: 'transaction' -> pushMode(COMMAND_TRANSACTION_MODE);
COMMAND_MODE_TRANSPOSE: 'transpose' -> pushMode(COMMAND_TRANSPOSE_MODE);
COMMAND_MODE_TRENDLINE: 'trendline' -> pushMode(COMMAND_TRENDLINE_MODE);
COMMAND_MODE_TSCOLLECT: 'tscollect' -> pushMode(COMMAND_TSCOLLECT_MODE);
COMMAND_MODE_TSTATS: 'tstats' -> pushMode(COMMAND_TSTATS_MODE);
COMMAND_MODE_TYPEAHEAD: 'typeahead' -> pushMode(COMMAND_TYPEAHEAD_MODE);
COMMAND_MODE_TYPELEARNER: 'typelearner' -> pushMode(COMMAND_TYPELEARNER_MODE);
COMMAND_MODE_TYPER: 'typer' -> pushMode(COMMAND_TYPER_MODE);
COMMAND_MODE_UNION: 'union' -> pushMode(COMMAND_UNION_MODE);
COMMAND_MODE_UNIQ: 'uniq' -> pushMode(COMMAND_UNIQ_MODE);
COMMAND_MODE_UNTABLE: 'untable' -> pushMode(COMMAND_UNTABLE_MODE);
COMMAND_MODE_WHERE: 'where' -> pushMode(EVAL_LANGUAGE_MODE); // implemented
COMMAND_MODE_X11: 'x11' -> pushMode(COMMAND_X11_MODE);
COMMAND_MODE_XMLKV: 'xmlkv' -> pushMode(COMMAND_XMLKV_MODE);
COMMAND_MODE_XMLUNESCAPE: 'xmlunescape' -> pushMode(COMMAND_XMLUNESCAPE_MODE);
COMMAND_MODE_XPATH: 'xpath' -> pushMode(COMMAND_XPATH_MODE);
COMMAND_MODE_XYSERIES: 'xyseries' -> pushMode(COMMAND_XYSERIES_MODE);
// -------------- COMMAND_MODE --------------
| 22,860 | ANTLR | .g4 | 404 | 53.175743 | 3,684 | 0.704767 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 2fb631fd7042c7f7b51433d21ac4f1b9b25db6df84513d0052f971155e1c52f1 | false | false | false | false |
206 | DPLParser.g4 | teragrep_pth_03/src/main/antlr4/com/teragrep/pth_03/antlr/DPLParser.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
// -*- mode: conf; -*-
parser grammar DPLParser;
@parser::members {
}
import DPLParserTransform;
options { tokenVocab=DPLLexer; }
root
: searchTransformationRoot? (PIPE transformStatement)? EOF
;
searchTransformationRoot
: directoryStatement
| (logicalStatement AND?)*? directoryStatement (AND? logicalStatement)*?
| directoryStatement OR logicalStatement
| logicalStatement
;
directoryStatement
: subindexStatement
| indexStatement
| directoryStatement OR directoryStatement
| directoryStatement (AND*? logicalStatement)+
| (logicalStatement AND? )+ directoryStatement
;
subindexStatement
: PARENTHESIS_L directoryStatement PARENTHESIS_R
;
indexStatement
: INDEX_EQ (stringType | WILDCARD)
| INDEX_SPACE (stringType | WILDCARD) //CHECK PRIORITY
| INDEX_NEG (stringType | WILDCARD)
| INDEX_SPACE_NEG (stringType | WILDCARD)
;
logicalStatement
: subsearchStatement
| sublogicalStatement
| timeStatement
| searchQualifier
| comparisonStatement
| searchIndexStatement
| NOT logicalStatement
| logicalStatement OR logicalStatement
| logicalStatement AND? logicalStatement
;
timeStatement
: (timeFormatQualifier? (timeQualifier))
;
sublogicalStatement
: PARENTHESIS_L logicalStatement PARENTHESIS_R
;
subsearchStatement
: BRACKET_L PIPE? transformStatement BRACKET_R
;
timeFormatQualifier
: TIMEFORMAT stringType //FIXME implement Time Properties
;
searchIndexStatement //FIXME tests plz
: stringType
| WILDCARD
| termStatement
| caseStatement
;
timeQualifier
: EARLIEST timeType
| INDEX_EARLIEST stringType
| STARTTIME stringType
| STARTDAYSAGO integerType
| STARTMINUTESAGO integerType
| STARTHOURSAGO integerType
| STARTMONTHSAGO integerType
| STARTTIMEU integerType
| LATEST timeType
| INDEX_LATEST stringType
| ENDTIME stringType
| ENDDAYSAGO integerType
| ENDMINUTESAGO integerType
| ENDHOURSAGO integerType
| ENDMONTHSAGO integerType
| ENDTIMEU integerType
| SEARCHTIMESPANHOURS integerType
| SEARCHTIMESPANMINUTES integerType
| SEARCHTIMESPANDAYS integerType
| SEARCHTIMESPANMONHTS integerType
| DAYSAGO integerType
| MINUTESAGO integerType
| HOURSAGO integerType
| MONTHSAGO integerType
;
comparisonStatement
: fieldOrStringType (EQ|NEQ|LT|LTE|GT|GTE) (integerType|stringType|WILDCARD)
| fieldValueInListStatement
| INDEX_EQ (stringType | WILDCARD)
| INDEX_SPACE (stringType | WILDCARD) //CHECK PRIORITY
| INDEX_NEG (stringType | WILDCARD)
| INDEX_SPACE_NEG (stringType | WILDCARD)
;
searchQualifier
: INDEX_IN GET_INDEX_STRING_BRACKET_L indexStringType (COMMA? indexStringType)* GET_INDEX_STRING_BRACKET_R
| SOURCETYPE (EQ|NEQ) (stringType | WILDCARD)
| SOURCETYPE IN PARENTHESIS_L stringType (COMMA? stringType)* PARENTHESIS_R
| HOST (EQ|NEQ) (stringType | WILDCARD)
| SOURCE (EQ|NEQ) (stringType | WILDCARD)
| SAVEDSEARCH (EQ|NEQ) (stringType | WILDCARD )
| EVENTTYPE (EQ|NEQ) (stringType | WILDCARD)
| EVENTTYPETAG (EQ|NEQ) (stringType | WILDCARD)
| HOSTTAG (EQ|NEQ) (stringType |WILDCARD)
| TAG (EQ|NEQ) (stringType | WILDCARD)
;
termStatement
: TERM PARENTHESIS_L stringType PARENTHESIS_R
;
caseStatement
: CASE PARENTHESIS_L stringType PARENTHESIS_R
;
fieldValueInListStatement
: fieldOrStringType IN PARENTHESIS_L stringType (COMMA stringType)* PARENTHESIS_R
;
whereStatement
: (comparisonStatement | searchIndexStatement | timeStatement | fieldValueInListStatement)
;
// types
booleanType
: GET_BOOLEAN_TRUE
| GET_BOOLEAN_FALSE
| GET_BOOLEAN_SPLIT
;
fieldType
: GET_FIELD_SINGLE_QUOTED
| GET_FIELD_DOUBLE_QUOTED
| GET_FIELD_STRING
;
fieldListType //check
: fieldType ((COMMA)? fieldType)*?
;
emailListParameter
: stringType (COMMA stringType)*?
;
integerType
: GET_INTEGER_INTEGER
| GET_INTEGER_RANGE
;
numberType
: GET_NUMBER_SINGLE_QUOTED
| GET_NUMBER_DOUBLE_QUOTED
| GET_NUMBER_NUMBER
;
regexStringType
: GET_REGEX_STRING_DOUBLE_QUOTED
;
sortFieldType
: GET_SORT_FIELD_SINGLE_QUOTED
| GET_SORT_FIELD_DOUBLE_QUOTED
| GET_SORT_FIELD_STRING
;
//relativeTimeQualifier
// : TIMEUNIT
// ;
spanType
: GET_SPAN_SPAN_LOG
| GET_SPAN_SPANUNIT_DURATION
| GET_SPAN_SPANUNIT
| GET_SPAN_SINGLE_QUOTE
| GET_SPAN_DOUBLE_QUOTE
| GET_SPAN_INTEGER_INTEGER
;
timeType
: GET_TIME_SINGLE_QUOTE
| GET_TIME_DOUBLE_QUOTE
| GET_TIME_STRING
| GET_TIME_INTEGER
| GET_TIME_EARLIEST
| GET_TIME_LATEST
;
indexStringType
: GET_INDEX_STRING_WILDCARD
| GET_INDEX_STRING_BRACKET_L
| GET_INDEX_STRING_SINGLE_QUOTED
| GET_INDEX_STRING_DOUBLE_QUOTED
| GET_INDEX_STRING_BRACKET_R
| GET_INDEX_STRING_STRING
;
stringType
: GET_STRING_SINGLE_QUOTED
| GET_STRING_DOUBLE_QUOTED
| GET_STRING_STRING
| GET_STRING_WILDCARD
;
fieldOrStringType
: fieldType
| stringType
;
| 7,800 | ANTLR | .g4 | 234 | 26.897436 | 114 | 0.68067 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 6316b2a3a1ad3307fa33052e6cc41b5c89fa4d63826fc0739ac7b714c92292af | false | false | false | false |
207 | DPLParserTransform_geomfilter.g4 | teragrep_pth_03/src/main/antlr4/imports/DPLParserTransform_geomfilter.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
parser grammar DPLParserTransform_geomfilter;
geomfilterTransformation
: COMMAND_MODE_GEOMFILTER (t_geomfilter_minxParameter)? (t_geomfilter_minyParameter)? (t_geomfilter_maxxParameter)? (t_geomfilter_maxyParameter)?
;
t_geomfilter_maxxParameter
: COMMAND_GEOMFILTER_MODE_MAX_X numberType
;
t_geomfilter_maxyParameter
: COMMAND_GEOMFILTER_MODE_MAX_Y numberType
;
t_geomfilter_minxParameter
: COMMAND_GEOMFILTER_MODE_MIN_X numberType
;
t_geomfilter_minyParameter
: COMMAND_GEOMFILTER_MODE_MIN_Y numberType
;
| 2,620 | ANTLR | .g4 | 61 | 39.688525 | 153 | 0.764637 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | bf4dda2c94bce4a0a54952b01c15ea4553002419b9aebd2117189fa823ce93dc | false | false | false | false |
208 | DPLParserTransform_anomalousvalue.g4 | teragrep_pth_03/src/main/antlr4/imports/DPLParserTransform_anomalousvalue.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
parser grammar DPLParserTransform_anomalousvalue;
anomalousvalueTransformation
: COMMAND_MODE_ANOMALOUSVALUE (t_anomalousvalue_minsupcountParameter|t_anomalousvalue_maxanofreqParameter|t_anomalousvalue_minsupfreqParameter|t_anomalousvalue_minnormfreqParameter|t_anomalousvalue_action_AnomalousvalueParameter|t_anomalousvalue_pthreshParameter)*? (fieldListType)?
;
t_anomalousvalue_action_AnomalousvalueParameter
: COMMAND_ANOMALOUSVALUE_MODE_ACTION (COMMAND_ANOMALOUSVALUE_MODE_GET_ACTION_MODE_ANNOTATE|COMMAND_ANOMALOUSVALUE_MODE_GET_ACTION_MODE_FILTER|COMMAND_ANOMALOUSVALUE_MODE_GET_ACTION_MODE_SUMMARY)
;
t_anomalousvalue_maxanofreqParameter
: COMMAND_ANOMALOUSVALUE_MODE_MAXANOFREQ numberType
;
t_anomalousvalue_minnormfreqParameter
: COMMAND_ANOMALOUSVALUE_MODE_MINNORMFREQ numberType
;
t_anomalousvalue_minsupcountParameter
: COMMAND_ANOMALOUSVALUE_MODE_MINSUPCOUNT integerType
;
t_anomalousvalue_minsupfreqParameter
: COMMAND_ANOMALOUSVALUE_MODE_MINSUPFREQ numberType
;
t_anomalousvalue_pthreshParameter
: COMMAND_ANOMALOUSVALUE_MODE_PTHRESH numberType
;
| 3,204 | ANTLR | .g4 | 67 | 44.343284 | 290 | 0.785417 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 68440b25e6e9b1773d22c6d1e5b8093fa59cb327a448c5989df03ea9159fdef8 | false | false | false | false |
209 | DPLParserTransform_tstats.g4 | teragrep_pth_03/src/main/antlr4/imports/DPLParserTransform_tstats.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
parser grammar DPLParserTransform_tstats;
tstatsTransformation //fix from section with where clause
: COMMAND_MODE_TSTATS (t_tstats_prestatsParameter)? (t_tstats_localParameter)? (t_tstats_appendParameter)? (t_tstats_summariesonlyParameter)? (t_tstats_include_reduced_bucketsParameter)? (t_tstats_allowOldSummariesParameter)? (t_tstats_chunksizeParameter)? t_tstats_fillnull_valueParameter? (t_tstats_statsfunctionInstruction)+ tstats_fromOptions? t_tstats_whereParameter? (COMMAND_TSTATS_MODE_BY (fieldListType | t_tstats_prefixParameter) t_tstats_spanParameter?)?
;
tstats_fromOptions
: COMMAND_TSTATS_MODE_FROM (stringType | t_tstats_sidParameter | (t_tstats_datamodelParameter (COMMAND_TSTATS_MODE_WHERE t_tstats_nodenameParameter)? ) )
;
t_tstats_allowOldSummariesParameter
: COMMAND_TSTATS_MODE_ALLOW_OLD_SUMMARIES booleanType
;
t_tstats_fillnull_valueParameter
: COMMAND_TSTATS_MODE_FILLNULL_VALUE stringType
;
t_tstats_appendParameter
: COMMAND_TSTATS_MODE_APPEND booleanType
;
t_tstats_chunksizeParameter
: COMMAND_TSTATS_MODE_CHUNKSIZE integerType
;
t_tstats_datamodelParameter // COMMAND_MODE_TSTATS
: COMMAND_TSTATS_MODE_DATAMODEL stringType
;
t_tstats_localParameter
: COMMAND_TSTATS_MODE_LOCAL booleanType
;
t_tstats_prestatsParameter
: COMMAND_TSTATS_MODE_PRESTATS booleanType
;
t_tstats_sidParameter
: COMMAND_TSTATS_MODE_SID stringType
;
t_tstats_spanParameter
: COMMAND_TSTATS_MODE_SPAN spanType
;
t_tstats_summariesonlyParameter
: COMMAND_TSTATS_MODE_SUMMARIESONLY booleanType
;
t_tstats_include_reduced_bucketsParameter
: COMMAND_TSTATS_MODE_INCLUDE_REDUCED_BUCKETS booleanType
;
t_tstats_fieldRenameInstruction
: (COMMAND_TSTATS_MODE_AS) fieldType
;
t_tstats_statsfunctionInstruction
: aggregateFunction (t_tstats_fieldRenameInstruction)?
;
t_tstats_prefixParameter
: COMMAND_TSTATS_MODE_PREFIX stringType COMMAND_TSTATS_MODE_PARENTHESIS_R
;
t_tstats_nodenameParameter //FIXME
: COMMAND_TSTATS_MODE_NODENAME stringType
;
t_tstats_whereParameter
: COMMAND_TSTATS_MODE_WHERE ((tstats_indexStatement|tstats_searchQualifier|) | (fieldType (COMMAND_TSTATS_MODE_IN COMMAND_TSTATS_MODE_PARENTHESIS_L? fieldType (COMMA? fieldType)*) COMMAND_TSTATS_MODE_PARENTHESIS_R? ) )
;
tstats_indexStatement
: stringType WILDCARD?
| WILDCARD
| tstats_termStatement
| tstats_caseStatement
;
tstats_searchQualifier
: COMMAND_TSTATS_MODE_INDEX (COMMAND_TSTATS_MODE_EQ|COMMAND_TSTATS_MODE_NEQ) stringType? WILDCARD?
| COMMAND_TSTATS_MODE_SOURCETYPE (COMMAND_TSTATS_MODE_EQ|COMMAND_TSTATS_MODE_NEQ) stringType? WILDCARD?
| COMMAND_TSTATS_MODE_HOST (COMMAND_TSTATS_MODE_EQ|COMMAND_TSTATS_MODE_NEQ) stringType? WILDCARD?
| COMMAND_TSTATS_MODE_SOURCE (COMMAND_TSTATS_MODE_EQ|COMMAND_TSTATS_MODE_NEQ) stringType? WILDCARD?
| COMMAND_TSTATS_MODE_SAVEDSEARCH (COMMAND_TSTATS_MODE_EQ|COMMAND_TSTATS_MODE_NEQ) stringType? WILDCARD?
| COMMAND_TSTATS_MODE_EVENTTYPE (COMMAND_TSTATS_MODE_EQ|COMMAND_TSTATS_MODE_NEQ) stringType? WILDCARD?
| COMMAND_TSTATS_MODE_EVENTTYPETAG (COMMAND_TSTATS_MODE_EQ|COMMAND_TSTATS_MODE_NEQ) stringType? WILDCARD?
| COMMAND_TSTATS_MODE_HOSTTAG (COMMAND_TSTATS_MODE_EQ|COMMAND_TSTATS_MODE_NEQ) stringType? WILDCARD?
| COMMAND_TSTATS_MODE_TAG (COMMAND_TSTATS_MODE_EQ|COMMAND_TSTATS_MODE_NEQ) stringType WILDCARD?
;
tstats_termStatement
: COMMAND_TSTATS_MODE_TERM COMMAND_TSTATS_MODE_PARENTHESIS_L stringType COMMAND_TSTATS_MODE_PARENTHESIS_R
;
tstats_caseStatement
: COMMAND_TSTATS_MODE_CASE COMMAND_TSTATS_MODE_PARENTHESIS_L stringType COMMAND_TSTATS_MODE_PARENTHESIS_R
; | 5,966 | ANTLR | .g4 | 123 | 43.398374 | 473 | 0.750945 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 818c0a768e7ae5f13847619eef9e4cb5197a409ff34f572fe077571a928d8d4c | false | false | false | false |
210 | DPLParserTransform_mcatalog.g4 | teragrep_pth_03/src/main/antlr4/imports/DPLParserTransform_mcatalog.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
parser grammar DPLParserTransform_mcatalog;
mcatalogTransformation
: COMMAND_MODE_MCATALOG (t_mcatalog_prestatsParameter)? (t_mcatalog_appendParameter)? ((COMMAND_MCATALOG_MODE_VALUES COMMAND_MCATALOG_MODE_PARENTHESIS_L fieldType COMMAND_MCATALOG_MODE_PARENTHESIS_R) (COMMAND_MCATALOG_MODE_AS fieldType)) (t_mcatalog_whereParameter)? ((COMMAND_MCATALOG_MODE_WHERE_MODE_BY_BY|COMMAND_MCATALOG_MODE_WHERE_MODE_GROUPBY) fieldListType)?
;
t_mcatalog_appendParameter
: COMMAND_MCATALOG_MODE_APPEND booleanType
;
t_mcatalog_prestatsParameter
: COMMAND_MCATALOG_MODE_PRESTATS booleanType
;
t_mcatalog_whereParameter
: COMMAND_MCATALOG_MODE_WHERE t_mcatalog_whereMcatalogStatement
;
t_mcatalog_whereMcatalogStatement
: t_mcatalog_comparisonStatement
| t_mcatalog_searchQualifier
| t_mcatalog_indexStatement
| t_mcatalog_timeStatement
| COMMAND_MCATALOG_MODE_WHERE_MODE_NOT t_mcatalog_whereMcatalogStatement
| t_mcatalog_whereMcatalogStatement COMMAND_MCATALOG_MODE_WHERE_MODE_OR t_mcatalog_whereMcatalogStatement
;
t_mcatalog_comparisonStatement
: fieldOrStringType (COMMAND_MCATALOG_MODE_WHERE_MODE_EQ|COMMAND_MCATALOG_MODE_WHERE_MODE_NEQ|COMMAND_MCATALOG_MODE_WHERE_MODE_LT|COMMAND_MCATALOG_MODE_WHERE_MODE_LTE|COMMAND_MCATALOG_MODE_WHERE_MODE_GT|COMMAND_MCATALOG_MODE_WHERE_MODE_GTE) (integerType|stringType)
| fieldValueInListStatement
;
t_mcatalog_searchQualifier
: COMMAND_MCATALOG_MODE_WHERE_MODE_INDEX (COMMAND_MCATALOG_MODE_WHERE_MODE_EQ|COMMAND_MCATALOG_MODE_WHERE_MODE_NEQ) stringType COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD?
| COMMAND_MCATALOG_MODE_WHERE_MODE_SOURCETYPE (COMMAND_MCATALOG_MODE_WHERE_MODE_EQ|COMMAND_MCATALOG_MODE_WHERE_MODE_NEQ) stringType COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD?
| COMMAND_MCATALOG_MODE_WHERE_MODE_HOST (COMMAND_MCATALOG_MODE_WHERE_MODE_EQ|COMMAND_MCATALOG_MODE_WHERE_MODE_NEQ) stringType COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD?
| COMMAND_MCATALOG_MODE_WHERE_MODE_SOURCE (COMMAND_MCATALOG_MODE_WHERE_MODE_EQ|COMMAND_MCATALOG_MODE_WHERE_MODE_NEQ) stringType COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD?
| COMMAND_MCATALOG_MODE_WHERE_MODE_SAVEDSEARCH (COMMAND_MCATALOG_MODE_WHERE_MODE_EQ|COMMAND_MCATALOG_MODE_WHERE_MODE_NEQ) stringType COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD?
| COMMAND_MCATALOG_MODE_WHERE_MODE_EVENTTYPE (COMMAND_MCATALOG_MODE_WHERE_MODE_EQ|COMMAND_MCATALOG_MODE_WHERE_MODE_NEQ) stringType COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD?
| COMMAND_MCATALOG_MODE_WHERE_MODE_EVENTTYPETAG (COMMAND_MCATALOG_MODE_WHERE_MODE_EQ|COMMAND_MCATALOG_MODE_WHERE_MODE_NEQ) stringType COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD?
| COMMAND_MCATALOG_MODE_WHERE_MODE_HOSTTAG (COMMAND_MCATALOG_MODE_WHERE_MODE_EQ|COMMAND_MCATALOG_MODE_WHERE_MODE_NEQ) stringType COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD?
| COMMAND_MCATALOG_MODE_WHERE_MODE_TAG (COMMAND_MCATALOG_MODE_WHERE_MODE_EQ|COMMAND_MCATALOG_MODE_WHERE_MODE_NEQ) stringType COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD?
;
t_mcatalog_indexStatement
: stringType COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD?
| COMMAND_MCATALOG_MODE_WHERE_MODE_WILDCARD
;
t_mcatalog_timeStatement
: timeFormatQualifier? (timeQualifier)
;
timeFormatQualifier
: COMMAND_MCATALOG_MODE_WHERE_MODE_TIMEFORMAT stringType //FIXME implement Time Properties
;
timeQualifier
: COMMAND_MCATALOG_MODE_WHERE_MODE_EARLIEST timeType
| COMMAND_MCATALOG_MODE_WHERE_MODE_INDEX_EARLIEST stringType
| COMMAND_MCATALOG_MODE_WHERE_MODE_STARTTIME stringType
| COMMAND_MCATALOG_MODE_WHERE_MODE_STARTDAYSAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_STARTMINUTESAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_STARTHOURSAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_STARTMONTHSAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_STARTTIMEU integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_LATEST timeType
| COMMAND_MCATALOG_MODE_WHERE_MODE_INDEX_LATEST stringType
| COMMAND_MCATALOG_MODE_WHERE_MODE_ENDTIME stringType
| COMMAND_MCATALOG_MODE_WHERE_MODE_ENDDAYSAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_ENDMINUTESAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_ENDHOURSAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_ENDMONTHSAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_ENDTIMEU integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_SEARCHTIMESPANHOURS integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_SEARCHTIMESPANMINUTES integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_SEARCHTIMESPANDAYS integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_SEARCHTIMESPANMONHTS integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_DAYSAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_MINUTESAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_HOURSAGO integerType
| COMMAND_MCATALOG_MODE_WHERE_MODE_MONTHSAGO integerType
; | 7,166 | ANTLR | .g4 | 117 | 55.769231 | 373 | 0.771132 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 3063a7eb6abcc49b8beff58dab8fb8827d6fb233c67d40e578fdf76687ac1dac | false | false | false | false |
211 | DPLParser_where_mode.g4 | teragrep_pth_03/src/main/antlr4/imports/DPLParser_where_mode.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
parser grammar DPLParser_where_mode;
whereModeTransformation
: (comparisonStatement | indexStatement | timeStatement) ((COMMAND_TSTATS_MODE_BY|COMMAND_TSTATS_MODE_GROUPBY) (fieldListType | (t_tstats_prefixParameter t_tstats_spanParameter))?)
; | 2,279 | ANTLR | .g4 | 49 | 44.285714 | 188 | 0.773991 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 9f570b9f644e9f825a81ac7e63e1654dbfa368ea8eb6965a6b4ed58379654d43 | false | false | false | false |
212 | COMMAND_APPEND_MODE.g4 | teragrep_pth_03/src/main/antlr4/imports/COMMAND_APPEND_MODE.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
// -*- mode: conf; -*-
lexer grammar COMMAND_APPEND_MODE;
COMMAND_APPEND_MODE_ANTLR_BUG: 'command_append_mode_antlr_bug' -> type(STRING_MATCH);
// ++++++++++++++ COMMAND_APPEND_MODE ++++++++++++++
mode COMMAND_APPEND_MODE;
// skip
COMMAND_APPEND_MODE_SPACE: SPACE -> channel(HIDDEN);
// exits
COMMAND_APPEND_MODE_PIPE: '|' -> type(PIPE), popMode;
COMMAND_APPEND_MODE_BRACKET_R: ']' -> type(BRACKET_R), popMode, popMode;
// subsearch within append
COMMAND_APPEND_MODE_BRACKET_L: '[' -> type(BRACKET_L), pushMode(COMMAND_MODE);
// tokens
COMMAND_APPEND_MODE_EXTENDTIMERANGE : 'extendtimerange=' -> pushMode(GET_BOOLEAN);
COMMAND_APPEND_MODE_TIMEOUT : 'timeout=' -> pushMode(GET_INTEGER);
COMMAND_APPEND_MODE_MAXTIME : 'maxtime=' -> pushMode(GET_INTEGER);
COMMAND_APPEND_MODE_MAXOUT : 'maxout=' -> pushMode(GET_INTEGER);
COMMAND_APPEND_MODE_COMMENT: '<!--' .*? '-->' -> channel(DPLCOMMENT);
| 2,916 | ANTLR | .g4 | 63 | 44.444444 | 98 | 0.751758 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 311dabfc9ea310f3d7038931f3b57fbf2d88b2c3b1cfafb60f9ea54ca3cdc8cd | false | false | false | false |
213 | DPLParserAggregations.g4 | teragrep_pth_03/src/main/antlr4/imports/DPLParserAggregations.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
// -*- mode: conf; -*-
parser grammar DPLParserAggregations;
// aggregations
aggregateFunction
: aggregateMethodAvg
| aggregateMethodCount
| aggregateMethodDistinctCount
| aggregateMethodEarliest
| aggregateMethodEarliestTime
| aggregateMethodEstimatedDistinctCount
| aggregateMethodEstimatedDistinctErrorCount
| aggregateMethodFirst
| aggregateMethodLast
| aggregateMethodLatest
| aggregateMethodLatestTime
| aggregateMethodList
| aggregateMethodMax
| aggregateMethodMedian
| aggregateMethodMin
| aggregateMethodMode
| aggregateMethodPercentile
| aggregateMethodPercentileVariable
| aggregateMethodRange
| aggregateMethodRate
| aggregateMethodStandardDeviation
| aggregateMethodSum
| aggregateMethodSumSquare
| aggregateMethodValues
| aggregateMethodVariance
| aggregateMethodPercint
| aggregateMethodPerSecond
| aggregateMethodPerHour
| aggregateMethodPerDay
| aggregateMethodPerMinute
;
/*
FIXME, arguments for different methods are not as they should be
they are currently just '"method(" aggregate_fieldType ")"' where ")" pops the mode.
*/
/*
FIXME, per_second etc needs to be implemented
like
t_timechart_binAggTimeParameter
: (COMMAND_TIMECHART_MODE_PER_SECOND(aggregateFunction) | COMMAND_TIMECHART_MODE_PER_MINUTE(aggregateFunction)| COMMAND_TIMECHART_MODE_PER_HOUR(aggregateFunction)| COMMAND_TIMECHART_MODE_PER_DAY(aggregateFunction))
;
add this to parsers for the special agg method
t_timechart_spanOptParameter
: t_timechart_binSpanParameter (aggregateMethodPerSecond | aggregateMethodPerHour | aggregateMethodPerDay | aggregateMethodPerMinute)*?
;
*/
aggregateMethodAvg
: (METHOD_AGGREGATE_AVG|METHOD_AGGREGATE_MEAN) (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodCount
: METHOD_AGGREGATE_COUNT | METHOD_AGGREGATE_COUNT_C
| ((METHOD_AGGREGATE_C|METHOD_AGGREGATE_COUNT_B) ( (METHOD_AGGREGATE_EVAL_L evalStatement EVAL_LANGUAGE_MODE_PARENTHESIS_R)
| aggregate_fieldType ) METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodDistinctCount
: (METHOD_AGGREGATE_DC|METHOD_AGGREGATE_DISTINCT_COUNT) (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodEarliest
: METHOD_AGGREGATE_EARLIEST (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodEarliestTime
: METHOD_AGGREGATE_EARLIEST_TIME (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodEstimatedDistinctCount
: METHOD_AGGREGATE_ESTDC (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodEstimatedDistinctErrorCount
: METHOD_AGGREGATE_ESTDC_ERROR (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodFirst
: METHOD_AGGREGATE_FIRST (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodLast
: METHOD_AGGREGATE_LAST (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodLatest
: METHOD_AGGREGATE_LATEST (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodLatestTime
: METHOD_AGGREGATE_LATEST_TIME (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodList
: METHOD_AGGREGATE_LIST (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodMax
: METHOD_AGGREGATE_MAX (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodMedian
: METHOD_AGGREGATE_MEDIAN (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodMin
: METHOD_AGGREGATE_MIN (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodMode
: METHOD_AGGREGATE_MODE (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodPercentile
: (METHOD_AGGREGATE_P|METHOD_AGGREGATE_PERC|METHOD_AGGREGATE_EXACTPERC|METHOD_AGGREGATE_UPPERPERC) (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodPercentileVariable
: (METHOD_AGGREGATE_P_VARIABLE
|METHOD_AGGREGATE_PERC_VARIABLE
|METHOD_AGGREGATE_EXACTPERC_VARIABLE
|METHOD_AGGREGATE_UPPERPERC_VARIABLE) METHOD_AGGREGATE_PARENTHESIS_L aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R
;
aggregateMethodPercint
: METHOD_AGGREGATE_PERCINT (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodPerSecond
: METHOD_AGGREGATE_PER_SECOND (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodPerHour
: METHOD_AGGREGATE_PER_HOUR (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodPerDay
: METHOD_AGGREGATE_PER_DAY (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodPerMinute
: METHOD_AGGREGATE_PER_MINUTE (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodRange
: METHOD_AGGREGATE_RANGE (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodRate
: METHOD_AGGREGATE_RATE (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodStandardDeviation
: (METHOD_AGGREGATE_STDEV|METHOD_AGGREGATE_STDEVP) (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodSum
: METHOD_AGGREGATE_SUM (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodSumSquare
: METHOD_AGGREGATE_SUMSQ (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodValues
: METHOD_AGGREGATE_VALUES (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregateMethodVariance
: METHOD_AGGREGATE_VAR (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
| METHOD_AGGREGATE_VARP (evalStatement METHOD_AGGREGATE_PARENTHESIS_R?
| aggregate_fieldType METHOD_AGGREGATE_PARENTHESIS_R)
;
aggregate_fieldType
: METHOD_AGGREGATE_DQSTRING
| METHOD_AGGREGATE_STRING_MATCH
;
| 9,848 | ANTLR | .g4 | 224 | 37.866071 | 222 | 0.748618 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 9ce6a7d9df32754d48ca11593a76fcf4c211c02916b37aa387472b6820a66176 | false | false | false | false |
214 | DPLParserTransform_scrub.g4 | teragrep_pth_03/src/main/antlr4/imports/DPLParserTransform_scrub.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
parser grammar DPLParserTransform_scrub;
scrubTransformation
: COMMAND_MODE_SCRUB (t_scrub_publicTermsParameter)? (t_scrub_privateTermsParameter)? (t_scrub_nameTermsParameter)? (t_scrub_dictionaryParameter)? (t_scrub_timeconfigParameter)? (t_scrub_namespaceParameter)?
;
t_scrub_dictionaryParameter
: COMMAND_SCRUB_MODE_DICTIONARY t_scrub_filenameType
;
t_scrub_namespaceParameter
: COMMAND_SCRUB_MODE_NAMESPACE stringType
;
t_scrub_nameTermsParameter
: COMMAND_SCRUB_MODE_NAME_TERMS t_scrub_filenameType
;
t_scrub_privateTermsParameter
: COMMAND_SCRUB_MODE_PRIVATE_TERMS t_scrub_filenameType
;
t_scrub_publicTermsParameter
: COMMAND_SCRUB_MODE_PUBLIC_TERMS t_scrub_filenameType
;
t_scrub_timeconfigParameter
: COMMAND_SCRUB_MODE_TIMECONFIG t_scrub_filenameType
;
t_scrub_filenameType
: ((COMMAND_SCRUB_MODE_SLASH)? stringType (COMMAND_SCRUB_MODE_SLASH))* stringType (COMMAND_SCRUB_MODE_DOT stringType)?
;
| 3,075 | ANTLR | .g4 | 70 | 40.157143 | 215 | 0.759973 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 423a7bdd43a051bf9a1b5864538e233c6e282ed68fcddf07748fb4cb95726acf | false | false | false | false |
215 | DPLParserTransform_timechart.g4 | teragrep_pth_03/src/main/antlr4/imports/DPLParserTransform_timechart.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
parser grammar DPLParserTransform_timechart;
timechartTransformation
: COMMAND_MODE_TIMECHART (t_timechart_sepParameter | t_timechart_formatParameter | t_timechart_partialParameter | t_timechart_fixedrangeParameter | t_timechart_contParameter | t_timechart_limitParameter)*? (t_timechart_aggParameter t_timechart_fieldRenameInstruction?)*? (t_timechart_binOptParameter)*? ((aggregateFunction t_timechart_fieldRenameInstruction? | t_timechart_evaledField t_timechart_fieldRenameInstruction?) t_timechart_divideByInstruction?)+ t_timechart_dedupSplitParameter?
;
t_timechart_aggParameter
: COMMAND_TIMECHART_MODE_AGG(((aggregateFunction | t_timechart_evaledField | fieldType)))
;
t_timechart_binOptParameter
: t_timechart_spanOptParameter | t_timechart_binsParameter | t_timechart_binMinspanParameter | t_timechart_binStartEndParameter | t_timechart_binAligntimeParameter
;
t_timechart_spanOptParameter
: t_timechart_binSpanParameter (aggregateMethodPerSecond | aggregateMethodPerHour | aggregateMethodPerDay | aggregateMethodPerMinute)*?
;
t_timechart_dedupSplitParameter
: COMMAND_TIMECHART_MODE_DEDUP_SPLITVALS booleanType
;
t_timechart_fixedrangeParameter
: COMMAND_TIMECHART_MODE_FIXEDRANGE booleanType
;
t_timechart_binSpanParameter
: COMMAND_TIMECHART_MODE_SPAN spanType
;
t_timechart_binsParameter
: COMMAND_TIMECHART_MODE_BINS integerType
;
t_timechart_binStartEndParameter
: (COMMAND_TIMECHART_MODE_START|COMMAND_TIMECHART_MODE_END) numberType
;
t_timechart_contParameter
: COMMAND_TIMECHART_MODE_CONT booleanType
;
t_timechart_formatParameter
: COMMAND_TIMECHART_MODE_FORMAT stringType
;
t_timechart_limitParameter
: COMMAND_TIMECHART_MODE_LIMIT (COMMAND_TIMECHART_SUBMODE_LIMIT_MODE_TOP_INT | COMMAND_TIMECHART_SUBMODE_LIMIT_MODE_BOTTOM_INT | COMMAND_TIMECHART_SUBMODE_LIMIT_MODE_INTEGER)
;
t_timechart_partialParameter
: COMMAND_TIMECHART_MODE_PARTIAL booleanType
;
t_timechart_sepParameter
: COMMAND_TIMECHART_MODE_SEP stringType
;
t_timechart_binMinspanParameter
: COMMAND_TIMECHART_MODE_MINSPAN spanType
;
t_timechart_binAligntimeParameter
: COMMAND_TIMECHART_MODE_ALIGNTIME timeType
;
t_timechart_divideByInstruction
: (COMMAND_TIMECHART_MODE_BY) fieldType t_timechart_tcOpt*? (t_timechart_whereInstruction)?
;
t_timechart_tcOpt
: t_timechart_binOptParameter
| t_timechart_nullstrParameter
| t_timechart_otherstrParameter
| t_timechart_usenullParameter
| t_timechart_useotherParameter
;
t_timechart_whereInstruction
: (COMMAND_TIMECHART_MODE_WHERE) aggregateFunction (IN|COMMAND_TIMECHART_MODE_NOTIN) (COMMAND_TIMECHART_MODE_TOP|COMMAND_TIMECHART_MODE_BOTTOM) integerType
| (COMMAND_TIMECHART_MODE_WHERE) aggregateFunction (COMMAND_TIMECHART_MODE_LT|COMMAND_TIMECHART_MODE_GT) numberType
;
t_timechart_nullstrParameter
: COMMAND_TIMECHART_MODE_NULLSTR stringType
;
t_timechart_otherstrParameter
: COMMAND_TIMECHART_MODE_OTHERSTR stringType
;
t_timechart_usenullParameter
: COMMAND_TIMECHART_MODE_USENULL booleanType
;
t_timechart_useotherParameter
: COMMAND_TIMECHART_MODE_USEOTHER booleanType
;
t_timechart_evaledField
: COMMAND_TIMECHART_MODE_EVAL_PARENTHESIS_L evalStatement EVAL_LANGUAGE_MODE_PARENTHESIS_R
;
t_timechart_fieldRenameInstruction
: (COMMAND_TIMECHART_MODE_AS) fieldType
;
| 5,697 | ANTLR | .g4 | 126 | 40.111111 | 497 | 0.758397 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 3558e3bb67a996b1d738927a88c67b78a6ae94214652f1733767ea1042dec8b1 | false | false | false | false |
216 | COMMAND_DPL_MODE.g4 | teragrep_pth_03/src/main/antlr4/imports/COMMAND_DPL_MODE.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
// -*- mode: conf; -*-
lexer grammar COMMAND_DPL_MODE;
COMMAND_DPL_MODE_ANTLR_BUG: 'command_dpl_mode_antlr_bug' -> type(STRING_MATCH);
// ++++++++++++++ COMMAND_DPL_MODE ++++++++++++++
mode COMMAND_DPL_MODE;
// skip
COMMAND_DPL_MODE_SPACE: SPACE -> channel(HIDDEN);
// exits
COMMAND_DPL_MODE_PIPE: '|' -> type(PIPE), popMode;
COMMAND_DPL_MODE_BRACKET_R: ']' -> type(BRACKET_R), popMode, popMode;
// tokens
COMMAND_DPL_MODE_DEBUG: 'debug=' -> pushMode(GET_STRING);
COMMAND_DPL_MODE_SUBSEARCH : 'subsearch=' -> pushMode(GET_BOOLEAN);
COMMAND_DPL_MODE_SINGLE_QUOTE: '\'' ( '\\'. | ~('\''| '\\') )* '\''-> type(GET_FIELD_SINGLE_QUOTED);
COMMAND_DPL_MODE_DQSTRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"' -> type(GET_FIELD_DOUBLE_QUOTED);
// characters for string
fragment COMMAND_DPL_MODE_CHAR
:'\u0023' // #
|'\u0024' // $
|'\u0025' // %
|'\u0026' // &
|'\u0027' // '
|'\u0028' // (
|'\u0029' // )
|'\u002A' // *
|'\u002B' // +
|'\u002C' // ,
|'\u002D' // -
|'\u002E' // .
|'\u002F' // /
|'\u0030' // 0
|'\u0031' // 1
|'\u0032' // 2
|'\u0033' // 3
|'\u0034' // 4
|'\u0035' // 5
|'\u0036' // 6
|'\u0037' // 7
|'\u0038' // 8
|'\u0039' // 9
|'\u003A' // :
|'\u003B' // ;
|'\u003C' // <
|'\u003D' {false}? // =
|'\u003E' // >
|'\u003F' // ?
|'\u0040' // DPL
|'\u0041' // A
|'\u0042' // B
|'\u0043' // C
|'\u0044' // D
|'\u0045' // E
|'\u0046' // F
|'\u0047' // G
|'\u0048' // H
|'\u0049' // I
|'\u004A' // J
|'\u004B' // K
|'\u004C' // L
|'\u004D' // M
|'\u004E' // N
|'\u004F' // O
|'\u0050' // P
|'\u0051' // Q
|'\u0052' // R
|'\u0053' // S
|'\u0054' // T
|'\u0055' // U
|'\u0056' // V
|'\u0057' // W
|'\u0058' // X
|'\u0059' // Y
|'\u005A' // Z
|'\u005B' {false}? // [
|'\u005C' // \
|'\u005D' {false}? // ]
|'\u005E' // ^
|'\u005F' // _
|'\u0060' // `
|'\u0061' // a
|'\u0062' // b
|'\u0063' // c
|'\u0064' // d
|'\u0065' // e
|'\u0066' // f
|'\u0067' // g
|'\u0068' // h
|'\u0069' // u
|'\u006A' // j
|'\u006B' // k
|'\u006C' // l
|'\u006D' // m
|'\u006E' // n
|'\u006F' // o
|'\u0070' // p
|'\u0071' // q
|'\u0072' // r
|'\u0073' // s
|'\u0074' // t
|'\u0075' // u
|'\u0076' // v
|'\u0077' // w
|'\u0078' // x
|'\u0079' // y
|'\u007A' // z
|'\u007B' // {
// |'\u007C' // |
|'\u007D' // }
|'\u007E' // ~
|'\u007F'..'\uFFFF' // DEL .. inf
;
COMMAND_DPL_MODE_STRING
// one or more characters
: (COMMAND_DPL_MODE_CHAR)+ -> type(GET_FIELD_STRING);
COMMAND_DPL_MODE_COMMENT: '<!--' .*? '-->' -> channel(DPLCOMMENT); | 5,308 | ANTLR | .g4 | 160 | 26.40625 | 101 | 0.523383 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | e83a6a0b46c8f9aa49a94698df185804d2d165937dce79a47afb3910f3142b0a | false | false | false | false |
217 | COMMAND_LOCALIZE_MODE.g4 | teragrep_pth_03/src/main/antlr4/imports/COMMAND_LOCALIZE_MODE.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
// -*- mode: conf; -*-
lexer grammar COMMAND_LOCALIZE_MODE;
COMMAND_LOCALIZE_MODE_ANTLR_BUG: 'command_localize_mode_antlr_bug' -> type(STRING_MATCH);
// ++++++++++++++ COMMAND_LOCALIZE_MODE ++++++++++++++
mode COMMAND_LOCALIZE_MODE;
// skip
COMMAND_LOCALIZE_MODE_SPACE: SPACE -> channel(HIDDEN);
// exits
COMMAND_LOCALIZE_MODE_PIPE: '|' -> type(PIPE), popMode;
COMMAND_LOCALIZE_MODE_BRACKET_R: ']' -> type(BRACKET_R), popMode, popMode;
// tokens
COMMAND_LOCALIZE_MODE_TIMEBEFORE : 'timebefore=' -> pushMode(GET_SPAN);
COMMAND_LOCALIZE_MODE_TIMEAFTER : 'timeafter=' -> pushMode(GET_SPAN);
COMMAND_LOCALIZE_MODE_MAXPAUSE : 'maxpause=' -> pushMode(GET_SPAN);
COMMAND_LOCALIZE_MODE_COMMENT: '<!--' .*? '-->' -> channel(DPLCOMMENT);
| 2,756 | ANTLR | .g4 | 60 | 44.066667 | 98 | 0.753348 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 4898c6c305555a2ce90d5ad9c3d7d298654574ad827b5c33ab63c5ec8538ad2a | false | false | false | false |
218 | DPLParserTransform_history.g4 | teragrep_pth_03/src/main/antlr4/imports/DPLParserTransform_history.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
parser grammar DPLParserTransform_history;
historyTransformation
: COMMAND_MODE_HISTORY (t_history_eventsParameter)?
;
t_history_eventsParameter
: COMMAND_HISTORY_MODE_EVENTS booleanType
;
| 2,242 | ANTLR | .g4 | 52 | 40.615385 | 98 | 0.770567 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 42a2d4d2038b043422330d38c22971a1c32f005d1924ff67538808eb43b664cc | false | false | false | false |
219 | COMMAND_X11_MODE.g4 | teragrep_pth_03/src/main/antlr4/imports/COMMAND_X11_MODE.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
// -*- mode: conf; -*-
lexer grammar COMMAND_X11_MODE;
COMMAND_X11_MODE_ANTLR_BUG: 'command_x11_mode_antlr_bug' -> type(STRING_MATCH);
// ++++++++++++++ COMMAND_X11_MODE ++++++++++++++
mode COMMAND_X11_MODE;
// skip
COMMAND_X11_MODE_SPACE: SPACE -> channel(HIDDEN);
// exits
COMMAND_X11_MODE_PIPE: '|' -> type(PIPE), popMode;
COMMAND_X11_MODE_BRACKET_R: ']' -> type(BRACKET_R), popMode, popMode;
// tokens
COMMAND_X11_MODE_PARENTHESIS_R : ')';
COMMAND_X11_MODE_PARENTHESIS_L : '(';
fragment COMMAND_X11_MODE_DIGIT: [0-9];
COMMAND_X11_MODE_INTEGER : (MINUS)? DIGIT+;
COMMAND_X11_MODE_FUNC : ('mult'|'add') (COMMAND_X11_MODE_INTEGER)?;
COMMAND_X11_MODE_SINGLE_QUOTE: '\'' ( '\\'. | ~('\''| '\\') )* '\'' -> type(GET_FIELD_SINGLE_QUOTED);
COMMAND_X11_MODE_DQSTRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"' -> type(GET_FIELD_DOUBLE_QUOTED);
COMMAND_X11_MODE_AS: ('AS'|'as');
// characters for string
fragment COMMAND_X11_MODE_CHAR
:'\u0023' // #
|'\u0024' // $
|'\u0025' // %
|'\u0026' // &
|'\u0027' // '
// |'\u0028' // (
// |'\u0029' // )
|'\u002A' // *
|'\u002B' // +
|'\u002C' // ,
|'\u002D' // -
|'\u002E' // .
|'\u002F' // /
|'\u0030' // 0
|'\u0031' // 1
|'\u0032' // 2
|'\u0033' // 3
|'\u0034' // 4
|'\u0035' // 5
|'\u0036' // 6
|'\u0037' // 7
|'\u0038' // 8
|'\u0039' // 9
|'\u003A' // :
|'\u003B' // ;
|'\u003C' // <
|'\u003D' {false}? // =
|'\u003E' // >
|'\u003F' // ?
|'\u0040' // X11
|'\u0041' // A
|'\u0042' // B
|'\u0043' // C
|'\u0044' // D
|'\u0045' // E
|'\u0046' // F
|'\u0047' // G
|'\u0048' // H
|'\u0049' // I
|'\u004A' // J
|'\u004B' // K
|'\u004C' // L
|'\u004D' // M
|'\u004E' // N
|'\u004F' // O
|'\u0050' // P
|'\u0051' // Q
|'\u0052' // R
|'\u0053' // S
|'\u0054' // T
|'\u0055' // U
|'\u0056' // V
|'\u0057' // W
|'\u0058' // X
|'\u0059' // Y
|'\u005A' // Z
|'\u005B' {false}? // [
|'\u005C' // \
|'\u005D' {false}? // ]
|'\u005E' // ^
|'\u005F' // _
|'\u0060' // `
|'\u0061' // a
|'\u0062' // b
|'\u0063' // c
|'\u0064' // d
|'\u0065' // e
|'\u0066' // f
|'\u0067' // g
|'\u0068' // h
|'\u0069' // u
|'\u006A' // j
|'\u006B' // k
|'\u006C' // l
|'\u006D' // m
|'\u006E' // n
|'\u006F' // o
|'\u0070' // p
|'\u0071' // q
|'\u0072' // r
|'\u0073' // s
|'\u0074' // t
|'\u0075' // u
|'\u0076' // v
|'\u0077' // w
|'\u0078' // x
|'\u0079' // y
|'\u007A' // z
|'\u007B' // {
|'\u007C' // |
|'\u007D' // }
|'\u007E' // ~
|'\u007F'..'\uFFFF' // DEL .. inf
;
COMMAND_X11_MODE_STRING
// one or more characters
: (COMMAND_X11_MODE_CHAR)+ -> type(GET_FIELD_STRING);
COMMAND_X11_MODE_COMMENT: '<!--' .*? '-->' -> channel(DPLCOMMENT);
| 5,450 | ANTLR | .g4 | 164 | 26.597561 | 102 | 0.526286 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | 2e57c38a2260df46a5a0569724cbd9745dc4350fa67387940075145f77cc3deb | false | false | false | false |
220 | DPLParserTransform_bin.g4 | teragrep_pth_03/src/main/antlr4/imports/DPLParserTransform_bin.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
parser grammar DPLParserTransform_bin;
binTransformation
: COMMAND_MODE_BIN (t_bin_binsParameter|t_bin_minspanParameter|t_bin_spanParameter|t_bin_startParameter|t_bin_endParameter|t_bin_alignTimeParameter)*? (t_bin_fieldRenameInstruction)
;
t_bin_alignTimeParameter
: COMMAND_BIN_MODE_ALIGNTIME (timeType)
;
t_bin_binsParameter
: COMMAND_BIN_MODE_BINS integerType
;
t_bin_endParameter
: COMMAND_BIN_MODE_END numberType
;
t_bin_minspanParameter
: COMMAND_BIN_MODE_MINSPAN spanType
;
t_bin_spanParameter
: COMMAND_BIN_MODE_SPAN spanType
;
t_bin_startParameter
: COMMAND_BIN_MODE_START numberType
;
t_bin_fieldRenameInstruction
: fieldType (COMMAND_BIN_MODE_AS fieldType)?
;
| 2,833 | ANTLR | .g4 | 70 | 36.814286 | 189 | 0.753001 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | d9f06e6eddd33eb5f3381757f488f0763591d5fae84afaa6a8240a888d356265 | false | false | false | false |
221 | COMMAND_PREDICT_MODE.g4 | teragrep_pth_03/src/main/antlr4/imports/COMMAND_PREDICT_MODE.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
// -*- mode: conf; -*-
lexer grammar COMMAND_PREDICT_MODE;
COMMAND_PREDICT_MODE_ANTLR_BUG: 'command_predict_mode_antlr_bug' -> type(STRING_MATCH);
// ++++++++++++++ COMMAND_PREDICT_MODE ++++++++++++++
mode COMMAND_PREDICT_MODE;
// skip
COMMAND_PREDICT_MODE_SPACE: SPACE -> channel(HIDDEN);
// exits
COMMAND_PREDICT_MODE_PIPE: '|' -> type(PIPE), popMode;
COMMAND_PREDICT_MODE_BRACKET_R: ']' -> type(BRACKET_R), popMode, popMode;
// tokens
COMMAND_PREDICT_MODE_CORRELATE: 'correlate=' -> pushMode(GET_FIELD);
COMMAND_PREDICT_MODE_FUTURE_TIMESPAN : 'future_timespan=' -> pushMode(GET_NUMBER);
COMMAND_PREDICT_MODE_ALGORITHM : 'algorithm=' -> pushMode(COMMAND_PREDICT_ALGORITHM_MODE);
COMMAND_PREDICT_MODE_SUPPRESS : 'suppress=' -> pushMode(GET_FIELD);
COMMAND_PREDICT_MODE_HOLDBACK : 'holdback=' -> pushMode(GET_NUMBER);
COMMAND_PREDICT_MODE_PERIOD : 'period=' -> pushMode(GET_NUMBER);
COMMAND_PREDICT_MODE_UPPER : 'upper' -> pushMode(GET_INTEGER);
COMMAND_PREDICT_MODE_LOWER : 'lower' -> pushMode(GET_INTEGER);
COMMAND_PREDICT_MODE_END : '=' -> pushMode(GET_FIELD);
COMMAND_PREDICT_MODE_DOT: '.';
COMMAND_PREDICT_MODE_DECIMAL: [0-9]+;
COMMAND_PREDICT_MODE_SINGLE_QUOTE: '\'' ( '\\'. | ~('\''| '\\') )* '\'' -> type(GET_FIELD_SINGLE_QUOTED);
COMMAND_PREDICT_MODE_DQSTRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"' -> type(GET_FIELD_DOUBLE_QUOTED);
COMMAND_PREDICT_MODE_AS: ('AS'|'as');
// characters for string
fragment COMMAND_PREDICT_MODE_CHAR
:'\u0023' // #
|'\u0024' // $
|'\u0025' // %
|'\u0026' // &
// |'\u0027' // '
// |'\u0028' // (
// |'\u0029' // )
|'\u002A' // *
|'\u002B' // +
// |'\u002C' // ,
|'\u002D' // -
|'\u002E' // .
|'\u002F' // /
|'\u0030' // 0
|'\u0031' // 1
|'\u0032' // 2
|'\u0033' // 3
|'\u0034' // 4
|'\u0035' // 5
|'\u0036' // 6
|'\u0037' // 7
|'\u0038' // 8
|'\u0039' // 9
|'\u003A' // :
|'\u003B' // ;
|'\u003C' // <
|'\u003D' {false}? // =
|'\u003E' // >
|'\u003F' // ?
|'\u0040' // PREDICT
|'\u0041' // A
|'\u0042' // B
|'\u0043' // C
|'\u0044' // D
|'\u0045' // E
|'\u0046' // F
|'\u0047' // G
|'\u0048' // H
|'\u0049' // I
|'\u004A' // J
|'\u004B' // K
|'\u004C' // L
|'\u004D' // M
|'\u004E' // N
|'\u004F' // O
|'\u0050' // P
|'\u0051' // Q
|'\u0052' // R
|'\u0053' // S
|'\u0054' // T
|'\u0055' // U
|'\u0056' // V
|'\u0057' // W
|'\u0058' // X
|'\u0059' // Y
|'\u005A' // Z
|'\u005B' {false}? // [
|'\u005C' // \
|'\u005D' {false}? // ]
|'\u005E' // ^
|'\u005F' // _
|'\u0060' // `
|'\u0061' // a
|'\u0062' // b
|'\u0063' // c
|'\u0064' // d
|'\u0065' // e
|'\u0066' // f
|'\u0067' // g
|'\u0068' // h
|'\u0069' // u
|'\u006A' // j
|'\u006B' // k
|'\u006C' // l
|'\u006D' // m
|'\u006E' // n
|'\u006F' // o
|'\u0070' // p
|'\u0071' // q
|'\u0072' // r
|'\u0073' // s
|'\u0074' // t
|'\u0075' // u
|'\u0076' // v
|'\u0077' // w
|'\u0078' // x
|'\u0079' // y
|'\u007A' // z
|'\u007B' // {
// |'\u007C' // |
|'\u007D' // }
|'\u007E' // ~
|'\u007F'..'\uFFFF' // DEL .. inf
;
COMMAND_PREDICT_MODE_STRING
// one or more characters
: (COMMAND_PREDICT_MODE_CHAR)+ -> type(GET_FIELD_STRING);
COMMAND_PREDICT_MODE_COMMENT: '<!--' .*? '-->' -> channel(DPLCOMMENT);
mode COMMAND_PREDICT_ALGORITHM_MODE;
COMMAND_PREDICT_ALGORITHM_MODE_Ll: 'LL' -> popMode;
COMMAND_PREDICT_ALGORITHM_MODE_Llt: 'LLT' -> popMode;
COMMAND_PREDICT_ALGORITHM_MODE_Llp: 'LLP' -> popMode;
COMMAND_PREDICT_ALGORITHM_MODE_Llp5: 'LLP5' -> popMode;
COMMAND_PREDICT_ALGORITHM_MODE_Llb: 'LLB' -> popMode;
COMMAND_PREDICT_ALGORITHM_MODE_BILL: 'BiLL' -> popMode; | 6,354 | ANTLR | .g4 | 177 | 29.672316 | 105 | 0.562267 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | cf801898857ba2143d7daba40e8fed467b241e10e05f23c51c49dd4e1234ebe8 | false | false | false | false |
222 | GET_FIELD.g4 | teragrep_pth_03/src/main/antlr4/imports/GET_FIELD.g4 | /*
* Teragrep Data Processing Language Parser Library PTH-03
* Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
// -*- mode: conf; -*-
lexer grammar GET_FIELD;
GET_FIELD_ANTLR_BUG: 'get_field_antlr_bug' -> type(STRING_MATCH);
// ++++++++++++++ GET_INTEGER ++++++++++++++
mode GET_FIELD;
// skip
GET_FIELD_SPACE: SPACE -> channel(HIDDEN);
// tokens
GET_FIELD_SINGLE_QUOTED: '\'' ( '\\'. | ~('\''| '\\'))* '\'' -> popMode;
GET_FIELD_DOUBLE_QUOTED: '"' ( '\\'. | ~('"'| '\\'))* '"' -> popMode;
GET_FIELD_COMMA: ',' ->type(COMMA);
GET_FIELD_STRING
// one or more characters
: (GET_FIELD_CHAR)+ -> popMode;
GET_FIELD_NULL: 'null';
fragment GET_FIELD_CHAR
:'\u0023' // #
|'\u0024' // $
|'\u0025' // %
|'\u0026' // &
//|'\u0027' // '
//|'\u0028' // (
//|'\u0029' // )
|'\u002A' // *
|'\u002B' // +
//|'\u002C' // ,
|'\u002D' // -
|'\u002E' // .
|'\u002F' // /
|'\u0030' // 0
|'\u0031' // 1
|'\u0032' // 2
|'\u0033' // 3
|'\u0034' // 4
|'\u0035' // 5
|'\u0036' // 6
|'\u0037' // 7
|'\u0038' // 8
|'\u0039' // 9
|'\u003A' // :
|'\u003B' // ;
|'\u003C' // <
|'\u003D' // =
|'\u003E' // >
|'\u003F' // ?
|'\u0040' // @
|'\u0041' // A
|'\u0042' // B
|'\u0043' // C
|'\u0044' // D
|'\u0045' // E
|'\u0046' // F
|'\u0047' // G
|'\u0048' // H
|'\u0049' // I
|'\u004A' // J
|'\u004B' // K
|'\u004C' // L
|'\u004D' // M
|'\u004E' // N
|'\u004F' // O
|'\u0050' // P
|'\u0051' // Q
|'\u0052' // R
|'\u0053' // S
|'\u0054' // T
|'\u0055' // U
|'\u0056' // V
|'\u0057' // W
|'\u0058' // X
|'\u0059' // Y
|'\u005A' // Z
// |'\u005B' // [
|'\u005C' // \
// |'\u005D' // ]
|'\u005E' // ^
|'\u005F' // _
|'\u0060' // `
|'\u0061' // a
|'\u0062' // b
|'\u0063' // c
|'\u0064' // d
|'\u0065' // e
|'\u0066' // f
|'\u0067' // g
|'\u0068' // h
|'\u0069' // u
|'\u006A' // j
|'\u006B' // k
|'\u006C' // l
|'\u006D' // m
|'\u006E' // n
|'\u006F' // o
|'\u0070' // p
|'\u0071' // q
|'\u0072' // r
|'\u0073' // s
|'\u0074' // t
|'\u0075' // u
|'\u0076' // v
|'\u0077' // w
|'\u0078' // x
|'\u0079' // y
|'\u007A' // z
|'\u007B' // {
// |'\u007C' // |
|'\u007D' // }
|'\u007E' // ~
|'\u007F'..'\uFFFF' // DEL .. inf
;
COMMAND_GET_FIELD_COMMENT: '<!--' .*? '-->' -> channel(DPLCOMMENT); | 4,925 | ANTLR | .g4 | 156 | 24.730769 | 98 | 0.505248 | teragrep/pth_03 | 0 | 4 | 34 | AGPL-3.0 | 9/19/2024, 2:49:36 PM (Europe/Amsterdam) | c9896e944441f05b9ce7e510c9aad66e45cf9ffeee3dd211f5b70494f73c9c2f | false | false | false | false |