@@ -147,13 +147,13 @@ private String getText() {
147
147
148
148
// abnf: placeholder = expression / markup
149
149
// abnf: expression = literal-expression
150
- // abnf: / variable-expression
151
- // abnf: / annotation-expression
150
+ // abnf: / variable-expression
151
+ // abnf: / annotation-expression
152
152
// abnf: literal-expression = "{" [s] literal [s annotation] *(s attribute) [s] "}"
153
153
// abnf: variable-expression = "{" [s] variable [s annotation] *(s attribute) [s] "}"
154
154
// abnf: annotation-expression = "{" [s] annotation *(s attribute) [s] "}"
155
155
// abnf: markup = "{" [s] "#" identifier *(s option) *(s attribute) [s] ["/"] "}" ; open and standalone
156
- // abnf: / "{" [s] "/" identifier *(s option) *(s attribute) [s] "}" ; close
156
+ // abnf: / "{" [s] "/" identifier *(s option) *(s attribute) [s] "}" ; close
157
157
private MFDataModel .Expression getPlaceholder () throws MFParseException {
158
158
int cp = input .peekChar ();
159
159
if (cp != '{' ) {
@@ -168,9 +168,7 @@ private MFDataModel.Expression getPlaceholder() throws MFParseException {
168
168
result = getMarkup ();
169
169
} else if (cp == '$' ) {
170
170
result = getVariableExpression ();
171
- } else if (StringUtils .isFunctionSigil (cp )
172
- || StringUtils .isPrivateAnnotationSigil (cp )
173
- || StringUtils .isReservedAnnotationSigil (cp )) {
171
+ } else if (StringUtils .isFunctionSigil (cp )) {
174
172
result = getAnnotationExpression ();
175
173
} else {
176
174
result = getLiteralExpression ();
@@ -214,16 +212,8 @@ private MFDataModel.Annotation getAnnotation(boolean whitespaceRequired) throws
214
212
checkCondition (identifier != null , "Annotation / function name missing" );
215
213
Map <String , MFDataModel .Option > options = getOptions ();
216
214
return new MFDataModel .FunctionAnnotation (identifier , options );
217
- default : // reserved && private
218
- if (StringUtils .isReservedAnnotationSigil (cp )
219
- || StringUtils .isPrivateAnnotationSigil (cp )) {
220
- cp = input .readCodePoint ();
221
- // The sigil is part of the body.
222
- // Safe to cast to char, the code point is in BMP
223
- identifier = (char ) cp + getIdentifier ();
224
- String body = getReservedBody ();
225
- return new MFDataModel .UnsupportedAnnotation (identifier + body );
226
- }
215
+ default :
216
+ // OK to continue and return null, it is an error.
227
217
}
228
218
input .gotoPosition (position );
229
219
return null ;
@@ -246,7 +236,7 @@ private MFDataModel.Annotation getMarkupAnnotation() throws MFParseException {
246
236
Map <String , MFDataModel .Option > options = getOptions ();
247
237
return new MFDataModel .FunctionAnnotation (identifier , options );
248
238
default :
249
- // reserved, private, function, something else,
239
+ // function or something else,
250
240
return null ;
251
241
}
252
242
}
@@ -290,17 +280,14 @@ private MFDataModel.Expression getAnnotationExpression() throws MFParseException
290
280
if (annotation instanceof MFDataModel .FunctionAnnotation ) {
291
281
return new MFDataModel .FunctionExpression (
292
282
(MFDataModel .FunctionAnnotation ) annotation , attributes );
293
- } else if (annotation instanceof MFDataModel .UnsupportedAnnotation ) {
294
- return new MFDataModel .UnsupportedExpression (
295
- (MFDataModel .UnsupportedAnnotation ) annotation , attributes );
296
283
} else {
297
284
error ("Unexpected annotation : " + annotation );
298
285
}
299
286
return null ;
300
287
}
301
288
302
289
// abnf: markup = "{" [s] "#" identifier *(s option) *(s attribute) [s] ["/"] "}" ; open and standalone
303
- // abnf: / "{" [s] "/" identifier *(s option) *(s attribute) [s] "}" ; close
290
+ // abnf: / "{" [s] "/" identifier *(s option) *(s attribute) [s] "}" ; close
304
291
private MFDataModel .Markup getMarkup () throws MFParseException {
305
292
int cp = input .peekChar (); // consume the '{'
306
293
checkCondition (cp == '#' || cp == '/' , "Should not happen. Expecting a markup." );
@@ -370,39 +357,6 @@ private MFDataModel.Attribute getAttribute() throws MFParseException {
370
357
return null ;
371
358
}
372
359
373
- // abnf: reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
374
- // abnf: reserved-escape = backslash ( backslash / "{" / "|" / "}" )
375
- private String getReservedBody () throws MFParseException {
376
- int spaceCount = skipWhitespaces ();
377
- StringBuilder result = new StringBuilder ();
378
- while (true ) {
379
- int cp = input .readCodePoint ();
380
- if (StringUtils .isReservedChar (cp )) {
381
- result .appendCodePoint (cp );
382
- } else if (cp == '\\' ) {
383
- cp = input .readCodePoint ();
384
- checkCondition (
385
- cp == '{' || cp == '|' || cp == '}' ,
386
- "Invalid escape sequence. Only \\ {, \\ | and \\ } are valid here." );
387
- result .append (cp );
388
- } else if (cp == '|' ) {
389
- input .backup (1 );
390
- MFDataModel .Literal quoted = getQuotedLiteral ();
391
- result .append (quoted .value );
392
- } else if (cp == EOF ) {
393
- return result .toString ();
394
- } else {
395
- if (result .length () == 0 ) {
396
- input .backup (spaceCount + 1 );
397
- return "" ;
398
- } else {
399
- input .backup (1 );
400
- return result .toString ();
401
- }
402
- }
403
- }
404
- }
405
-
406
360
// abnf: identifier = [namespace ":"] name
407
361
// abnf: namespace = name
408
362
// abnf: name = name-start *name-char
@@ -650,7 +604,7 @@ private MFDataModel.SelectMessage getMatch(List<MFDataModel.Declaration> declara
650
604
// abnf: key = literal / "*"
651
605
private MFDataModel .Variant getVariant () throws MFParseException {
652
606
List <MFDataModel .LiteralOrCatchallKey > keys = new ArrayList <>();
653
- // abnf variant = key *(s key) [s] quoted-pattern
607
+ // abnf: variant = key *(s key) [s] quoted-pattern
654
608
while (true ) {
655
609
// Space is required between keys
656
610
MFDataModel .LiteralOrCatchallKey key = getKey (!keys .isEmpty ());
@@ -705,8 +659,6 @@ private static class MatchDeclaration implements MFDataModel.Declaration {
705
659
706
660
// abnf: input-declaration = input [s] variable-expression
707
661
// abnf: local-declaration = local s variable [s] "=" [s] expression
708
- // abnf: reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression)
709
- // abnf: reserved-keyword = "." name
710
662
private MFDataModel .Declaration getDeclaration () throws MFParseException {
711
663
int position = input .getPosition ();
712
664
skipOptionalWhitespaces ();
@@ -745,32 +697,8 @@ private MFDataModel.Declaration getDeclaration() throws MFParseException {
745
697
break ;
746
698
case "match" :
747
699
return new MatchDeclaration ();
748
- default : // abnf: reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression)
749
- skipOptionalWhitespaces ();
750
- String body = getReservedBody ();
751
- List <MFDataModel .Expression > expressions = new ArrayList <>();
752
- while (true ) {
753
- skipOptionalWhitespaces ();
754
- // Look ahead to detect the end of the unsupported statement
755
- // (next token either begins a placeholder or begins a complex body)
756
- cp = input .readCodePoint ();
757
- int cp1 = input .readCodePoint ();
758
- if (cp == '{' && cp1 == '{' ) {
759
- // End of unsupported statement
760
- input .backup (2 );
761
- break ;
762
- } else {
763
- input .backup (2 );
764
- }
765
- expression = getPlaceholder ();
766
- // This also covers != null
767
- if (expression instanceof MFDataModel .VariableExpression ) {
768
- expressions .add (expression );
769
- } else {
770
- break ;
771
- }
772
- }
773
- return new MFDataModel .UnsupportedStatement (declName , body , expressions );
700
+ default :
701
+ // OK to continue and return null, it is an error.
774
702
}
775
703
return null ;
776
704
}
0 commit comments