X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-rfc7950%2Fsrc%2Fmain%2Fantlr%2Forg%2Fopendaylight%2Fyangtools%2Fantlrv4%2Fcode%2Fgen%2FYangStatementParser.g4;fp=yang%2Fyang-parser-rfc7950%2Fsrc%2Fmain%2Fantlr%2Forg%2Fopendaylight%2Fyangtools%2Fantlrv4%2Fcode%2Fgen%2FYangStatementParser.g4;h=cbfeee38c7b5211477ff370d074508732fb5f841;hb=52af09aeb286b3c53fc9bd0c84eaf49f05ebc618;hp=1d7554bf781b553beeff994d68a8d941788d8f84;hpb=a33ccd1aec56b0ea227f7b9dc73ac282e179382d;p=yangtools.git diff --git a/yang/yang-parser-rfc7950/src/main/antlr/org/opendaylight/yangtools/antlrv4/code/gen/YangStatementParser.g4 b/yang/yang-parser-rfc7950/src/main/antlr/org/opendaylight/yangtools/antlrv4/code/gen/YangStatementParser.g4 index 1d7554bf78..cbfeee38c7 100644 --- a/yang/yang-parser-rfc7950/src/main/antlr/org/opendaylight/yangtools/antlrv4/code/gen/YangStatementParser.g4 +++ b/yang/yang-parser-rfc7950/src/main/antlr/org/opendaylight/yangtools/antlrv4/code/gen/YangStatementParser.g4 @@ -17,4 +17,28 @@ file : SEP* statement SEP* EOF; statement : keyword (SEP+ argument)? SEP* (SEMICOLON | LEFT_BRACE SEP* (statement SEP*)* RIGHT_BRACE); keyword : IDENTIFIER (COLON IDENTIFIER)?; -argument : STRING (SEP* PLUS SEP* STRING)* | IDENTIFIER; +// Alright, so what constitutes a string is rather funky. We need to deal with +// the flaky definitions of RFC6020, which allow for insane quoting as well as +// exclusion of comments. We also need to allow for stitching back tokens like +// PLUS/COLON, which may end up being valid identifiers. Finally we need to allow +// IDENTIFIER to be concatenated back to a string +argument : unquotedString | quotedString (SEP* PLUS SEP* quotedString)*; + +quotedString : + DQUOT_START DQUOT_STRING? DQUOT_END + | + SQUOT_START SQUOT_STRING? SQUOT_END + ; + +unquotedString : SLASH | STAR+ | (SLASH? | STAR*) stringPart+ (SLASH? | STAR*); + +// A string which is guaranteed to not have slash/star in either start or end +// and can thus be concatenated without allowing '/*', '//' and '*/' to appear. +stringPart: + (IDENTIFIER | COLON | PLUS | UQUOT_STRING)+ + | + stringPart SLASH stringPart + | + stringPart STAR+ stringPart + ; +