Split out RFC7950 ANTLR grammars
[yangtools.git] / yang / yang-parser-antlr / src / main / antlr4 / org / opendaylight / yangtools / yang / parser / antlr / YangStatementLexer.g4
diff --git a/yang/yang-parser-antlr/src/main/antlr4/org/opendaylight/yangtools/yang/parser/antlr/YangStatementLexer.g4 b/yang/yang-parser-antlr/src/main/antlr4/org/opendaylight/yangtools/yang/parser/antlr/YangStatementLexer.g4
new file mode 100644 (file)
index 0000000..8185545
--- /dev/null
@@ -0,0 +1,42 @@
+//
+// Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+//
+// This program and the accompanying materials are made available under the
+// terms of the Eclipse Public License v1.0 which accompanies this distribution,
+// and is available at http://www.eclipse.org/legal/epl-v10.html
+//
+lexer grammar YangStatementLexer;
+
+tokens {
+    SEMICOLON,
+    LEFT_BRACE,
+    RIGHT_BRACE,
+    SEP,
+    IDENTIFIER,
+    COLON,
+    PLUS
+}
+
+SEMICOLON : ';' -> type(SEMICOLON);
+LEFT_BRACE : '{' -> type(LEFT_BRACE);
+RIGHT_BRACE : '}' -> type(RIGHT_BRACE);
+COLON : ':' -> type(COLON);
+PLUS : '+' -> type(PLUS);
+
+LINE_COMMENT :  [ \n\r\t]* ('//' (~[\r\n]*)) [ \n\r\t]* -> skip;
+
+START_BLOCK_COMMENT : '/*' ->pushMode(BLOCK_COMMENT_MODE), skip;
+
+SEP: [ \n\r\t]+ -> type(SEP);
+IDENTIFIER : [a-zA-Z_/][a-zA-Z0-9_\-.:/]* -> type(IDENTIFIER);
+
+fragment SUB_STRING : ('"' (ESC | ~["])*? '"') | ('\'' (ESC | ~['])* '\'');
+fragment ESC : '\\' (["\\/bfnrt] | UNICODE);
+fragment UNICODE : 'u' HEX HEX HEX HEX;
+fragment HEX : [0-9a-fA-F] ;
+
+STRING: ((~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '"' | '\'' | '}' | '/' | '+')~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '}' )* ) | SUB_STRING );
+
+mode BLOCK_COMMENT_MODE;
+END_BLOCK_COMMENT : '*/' -> popMode, skip;
+BLOCK_COMMENT :  . -> skip;