@@ -64,6 +64,15 @@ package org.sonar.plugins.delphi.antlr;
64
64
**/
65
65
}
66
66
67
+ @lexer:: members {
68
+ private boolean isControlchar() {
69
+ // TODO
70
+ // - check if there are actually 2 chars ahead and not an EOF
71
+ // - perhaps something else than a regex match here
72
+ return ((char)input.LA(1 ) + " " + (char)input.LA(2 )).matches(" \\ w\\ W" );
73
+ }
74
+ }
75
+
67
76
//****************************
68
77
// section start
69
78
//****************************
@@ -480,15 +489,16 @@ factor : '@' factor
480
489
| designator
481
490
| typeId ' (' expression ' )'
482
491
;
483
- stringFactor : ControlString (QuotedString ControlString)* (QuotedString)?
484
- | QuotedString (ControlString QuotedString)* (ControlString)?
492
+ stringFactor : ( ControlString | ControlChar) (QuotedString ( ControlString | ControlChar) )* (QuotedString)?
493
+ | QuotedString (( ControlString | ControlChar) QuotedString)* (ControlString | ControlChar )?
485
494
;
486
495
setSection : ' [ ' (expression ((' ,' | ' .. ' ) expression)*)? ' ] '
487
496
;
488
497
489
498
designator : (' inherited' )? ( (qualifiedIdent | typeId) )? (designatorItem)*
490
499
;
491
500
designatorItem : ' ^ '
501
+ | ' ^^ '
492
502
| (' .' | ' @' ) ident //CHANGED added ' @'
493
503
| (' < ' genericTypeIdent (' ,' genericTypeIdent)* ' > ' ) //ADDED for proc<sth, sth>.foo;
494
504
| ' [ ' expressionList ' ] '
@@ -940,14 +950,15 @@ TkRealNum : Digitseq ( ((DOT Digitseq)? (('e'|'E') ('+'|'-')? Digi
940
950
;
941
951
TkHexNum : ' $' Hexdigitseq
942
952
;
943
- QuotedString : ' \' ' (' \'\' ' | ~ (' \' ' ))* ' \' ' // taken from PASCAL grammar
953
+ ControlChar : ' ^ ' ( {isControlchar()}?=> Alpha
954
+ | {$type=POINTER2;}
955
+ )
956
+ | ' # ' Digitseq
957
+ | ' #' ' $' Hexdigitseq
944
958
;
945
- ControlString : Controlchar (Controlchar) *
959
+ QuotedString : ' \' ' ( ' \'\' ' | ~ ( ' \' ' )) * ' \' ' // taken from PASCAL grammar
946
960
;
947
-
948
- fragment
949
- Controlchar : ' #' Digitseq
950
- | ' #' ' $' Hexdigitseq
961
+ ControlString : ControlChar (ControlChar)*
951
962
;
952
963
fragment
953
964
Alpha : ' a' .. ' z'
0 commit comments