a9e19acf6cf2b09cfdfa02cfc8e77f02f45914b6
[yangtools.git] / yang / yang-parser-impl / src / main / 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 @header {
11 package org.opendaylight.yangtools.antlrv4.code.gen;
12 }
13
14 tokens{
15     SEMICOLON,
16     LEFT_BRACE,
17     RIGHT_BRACE,
18     SEP,
19     IDENTIFIER,
20     COLON,
21     PLUS
22 }
23
24 SEMICOLON : ';' -> type(SEMICOLON);
25 LEFT_BRACE : '{' -> type(LEFT_BRACE);
26 RIGHT_BRACE : '}' -> type(RIGHT_BRACE);
27 COLON : ':' -> type(COLON);
28 PLUS : '+' -> type(PLUS);
29
30 LINE_COMMENT :  [ \n\r\t]* ('//' (~[\r\n]*)) [ \n\r\t]* -> skip;
31
32 START_BLOCK_COMMENT : '/*' ->pushMode(BLOCK_COMMENT_MODE), skip;
33
34 SEP: [ \n\r\t]+ -> type(SEP);
35 IDENTIFIER : [a-zA-Z_/][a-zA-Z0-9_\-.:/]* -> type(IDENTIFIER);
36
37 fragment SUB_STRING : ('"' (ESC | ~["])*'"') | ('\'' (ESC | ~['])*'\'');
38 fragment ESC : '\\' (["\\/bfnrt] | UNICODE);
39 fragment UNICODE : 'u' HEX HEX HEX HEX;
40 fragment HEX : [0-9a-fA-F] ;
41
42 STRING : ((~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '"' | '\'' | '/' | '=' | '[' | ']' | '+' | '}' )~( '\r' | '\n' |
43 '\t' | ' ' | ';' | '{' | '/' | '=' | '[' | ']' | '}')* ) | SUB_STRING );
44
45 mode BLOCK_COMMENT_MODE;
46 END_BLOCK_COMMENT : '*/' -> popMode, skip;
47 BLOCK_COMMENT :  . -> more, skip;