aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtienne Bergeron2013-12-05 14:51:59 (EST)
committerMatthew Khouzam2013-12-09 09:34:08 (EST)
commita6e16c8961cc0ed3b5861525ec390604eb4a0c24 (patch)
tree156a48a0799f706108b5b5c7f411491e923c84a2
parent46b609b9ac92180300efe2f3c03d16c1e6eb0c91 (diff)
downloadorg.eclipse.linuxtools-a6e16c8961cc0ed3b5861525ec390604eb4a0c24.zip
org.eclipse.linuxtools-a6e16c8961cc0ed3b5861525ec390604eb4a0c24.tar.gz
org.eclipse.linuxtools-a6e16c8961cc0ed3b5861525ec390604eb4a0c24.tar.bz2
ctf: Some little refactoring in the ctf lexer.refs/changes/11/19411/2
Mostly only moving rules aroung to ease the reading. The rule to match c++-like comment do not need to take care of '\r'. It's a caractere like the others, and the comment will be tuncante to the '\n'. Signed-off-by: Etienne Bergeron <etienne.bergeron@gmail.com> Change-Id: I7fdb6dbd05729c6502ee987dec47b3cfd65806bc Reviewed-on: https://git.eclipse.org/r/19411 Tested-by: Hudson CI Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.parser/src/main/antlr3/org/eclipse/linuxtools/ctf/parser/CTFLexer.g47
1 files changed, 23 insertions, 24 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.parser/src/main/antlr3/org/eclipse/linuxtools/ctf/parser/CTFLexer.g b/lttng/org.eclipse.linuxtools.ctf.parser/src/main/antlr3/org/eclipse/linuxtools/ctf/parser/CTFLexer.g
index 82f81e8..b9dec39 100644
--- a/lttng/org.eclipse.linuxtools.ctf.parser/src/main/antlr3/org/eclipse/linuxtools/ctf/parser/CTFLexer.g
+++ b/lttng/org.eclipse.linuxtools.ctf.parser/src/main/antlr3/org/eclipse/linuxtools/ctf/parser/CTFLexer.g
@@ -9,7 +9,7 @@ options {
}
/*
- * Lexer grammers
+ * Lexer tokens
*/
/*
@@ -43,13 +43,14 @@ IMAGINARYTOK : '_Imaginary' ;
ENVTOK : 'env' ;
CLOCKTOK : 'clock' ;
/*
- * Callsite tokens (v1.9)
+ * Callsite tokens (CTF v1.9)
*/
CALLSITETOK : 'callsite' ;
/*
- * Spec still to come.
+ * These tokens are not part of the CTF standard.
+ * There are planned to be in CTF v1.9
*/
NANNUMBERTOK : 'NaN' ;
INFINITYTOK : '+inf' ;
@@ -78,30 +79,28 @@ ARROW : '->' ;
DOT : '.' ;
fragment BACKSLASH : '\\' ;
+/* Helpers for integer literals */
+fragment DIGIT : '0'..'9' ;
+fragment OCT_DIGIT : '0'..'7' ;
+fragment OCT_PREFIX : '0' ;
+fragment NONZERO_DIGIT : '1'..'9' ;
+fragment HEX_DIGIT : DIGIT | ('a'..'f') | ('A'..'F') ;
+fragment HEX_PREFIX : '0' ('x' | 'X') ;
/*
* Integer literals
*/
-OCTAL_LITERAL : '0' ('0'..'7')+ INTEGER_TYPES_SUFFIX? ;
-
+OCTAL_LITERAL : OCT_PREFIX (OCT_DIGIT)+ INTEGER_TYPES_SUFFIX? ;
DECIMAL_LITERAL : DIGIT+ INTEGER_TYPES_SUFFIX? ;
-
HEX_LITERAL : HEX_PREFIX HEX_DIGIT+ INTEGER_TYPES_SUFFIX? ;
-fragment HEX_DIGIT : DIGIT | ('a'..'f') | ('A'..'F') ;
-fragment HEX_PREFIX : '0' ('x' | 'X') ;
-
-/* Helpers for integer literals */
-fragment DIGIT : '0'..'9' ;
-fragment NONZERO_DIGIT : '1'..'9' ;
-
/**
* Integer suffix for long, long long and unsigned.
*
* Matches all possible combination of L, LL and U.
*/
-fragment INTEGER_TYPES_SUFFIX :
- ('l' ('l')? | 'L' ('L')?) // l, ll
+fragment INTEGER_TYPES_SUFFIX
+ : ('l' ('l')? | 'L' ('L')?) // l, ll
| ('u' | 'U') // u
| ('u' | 'U') ('l' ('l')? | 'L' ('L')?) // ul, ull
| ('l' ('l')? | 'L' ('L')?) ('u'| 'U') // lu, llu
@@ -110,8 +109,8 @@ fragment INTEGER_TYPES_SUFFIX :
/**
* Escape sequences
*/
-fragment ESCAPE_SEQUENCE :
- BACKSLASH ('\'' | '"' | '?' | BACKSLASH | 'a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' )
+fragment ESCAPE_SEQUENCE
+ : BACKSLASH ('\'' | '"' | '?' | BACKSLASH | 'a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' )
| OCTAL_ESCAPE
| UNICODE_ESCAPE
| HEXADECIMAL_ESCAPE
@@ -120,8 +119,8 @@ fragment ESCAPE_SEQUENCE :
/**
* Octal escape sequence
*/
-fragment OCTAL_ESCAPE :
- BACKSLASH ('0'..'3') ('0'..'7') ('0'..'7')
+fragment OCTAL_ESCAPE
+ : BACKSLASH ('0'..'3') ('0'..'7') ('0'..'7')
| BACKSLASH ('0'..'7') ('0'..'7')
| BACKSLASH ('0'..'7')
;
@@ -134,8 +133,8 @@ fragment HEXADECIMAL_ESCAPE : BACKSLASH 'x' HEX_DIGIT+ ;
/**
* Unicode escape sequence
*/
-fragment UNICODE_ESCAPE :
- BACKSLASH 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+fragment UNICODE_ESCAPE
+ : BACKSLASH 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
| BACKSLASH 'U' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
;
@@ -160,13 +159,13 @@ fragment DOUBLEQUOTE : '"' ;
/**
* Whitespaces
*/
-WS : (' ' | '\r' | '\t' | '\u000C' | '\n') { $channel=HIDDEN; } ;
+WS : (' ' | '\r' | '\t' | '\u000C' | '\n') { $channel = HIDDEN; } ;
/**
* Multiline comment
*/
// About the greedy option: see page 100-101 of The Definitive ANTLR reference
-// COMMENT : '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;} ;
+// COMMENT : '/*' ( options { greedy = false; } : . )* '*/' { $channel = HIDDEN; } ;
COMMENT : COMMENT_OPEN .* COMMENT_CLOSE { $channel = HIDDEN; } ;
fragment COMMENT_OPEN : '/*';
fragment COMMENT_CLOSE : '*/';
@@ -174,7 +173,7 @@ fragment COMMENT_CLOSE : '*/';
/**
* Single line comment
*/
-LINE_COMMENT : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;} ;
+LINE_COMMENT : '//' ~('\n')* '\n' { $channel = HIDDEN; } ;
/**
* Identifiers