3788c9cf928ff51c5863d8e6a8bf23c7458c80e3
[yangtools.git] / yang / yang-parser-antlr / src / main / antlr4 / org / opendaylight / yangtools / yang / parser / antlr / YangStatementLexer.g4
1 //
2 // Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3 //
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 // and is available at http://www.eclipse.org/legal/epl-v10.html
7 //
8 lexer grammar YangStatementLexer;
9
10 tokens {
11     SEMICOLON,
12     LEFT_BRACE,
13     RIGHT_BRACE,
14     SEP,
15     IDENTIFIER,
16     COLON,
17     PLUS
18 }
19
20 SEMICOLON : ';' -> type(SEMICOLON);
21 LEFT_BRACE : '{' -> type(LEFT_BRACE);
22 RIGHT_BRACE : '}' -> type(RIGHT_BRACE);
23 COLON : ':' -> type(COLON);
24 PLUS : '+' -> type(PLUS);
25
26 LINE_COMMENT : [ \n\r\t]* ('//' (~[\r\n]*)) [ \n\r\t]* -> skip;
27 BLOCK_COMMENT : '/*' .*? '*/' -> skip;
28
29 SEP: [ \n\r\t]+ -> type(SEP);
30 IDENTIFIER : [a-zA-Z_/][a-zA-Z0-9_\-.:/]* -> type(IDENTIFIER);
31
32 fragment SUB_STRING : ('"' (ESC | ~["])*? '"') | ('\'' (ESC | ~['])* '\'');
33 fragment ESC : '\\' (["\\/bfnrt] | UNICODE);
34 fragment UNICODE : 'u' HEX HEX HEX HEX;
35 fragment HEX : [0-9a-fA-F] ;
36
37 STRING: ((~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '"' | '\'' | '}' | '/' | '+')~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '}' )* ) | SUB_STRING );
38