// Note that inside a quoted string (Section 6.1.3), these character
// pairs are never interpreted as the start or end of a comment.
//
-// What constitutes 'end of the line' is not specified in RFC7950, hence
+// What constitutes 'end of the line' is not specified in RFC6020, hence
// we are using RFC7950-clarified definition. Note we also need to handle
// the case of EOF, as the user may not have included a newline.
LINE_COMMENT : '//' .*? '\r'? ('\n' | EOF) -> skip;
//
parser grammar YangStatementParser;
+// This ANTLR4 grammar serves as the lexer for the actual YANG parser, which
+// is built on top of it in Java code. The reason for this split is that we
+// need to perform string interpretation in a way which takes into account
+// yang-version, since RFC7950 (YANG 1.1) is stricter (and saner) when it comes
+// to escaping and similar.
options {
tokenVocab = YangStatementLexer;
}
// Quoted string and concatenations thereof. We are sacrificing brewity
// here to eliminate the need for another parser construct. Quoted strings
// account for about 50% of all arguments encountered -- hence the added
- // parse tree indirection is very visible.
+ // parse tree indirection is very visible in terms of memory usage.
(DQUOT_STRING? DQUOT_END | SQUOT_STRING? SQUOT_END)
(SEP* PLUS SEP* (DQUOT_STRING? DQUOT_END | SQUOT_STRING? SQUOT_END))*
|
// having one level for each such concatenation. For a test case imagine
// how "a*b/c*d*e**f" would get parsed with a recursive grammar.
//
- // Now we cannot do much aboud tokenization, but we can statically express
+ // Now we cannot do much about tokenization, but we can statically express
// the shape we are looking for:
// so an unquoted string may optionally start with a single SLASH or any