1 // $ANTLR 2.7.4: "langparser.g" -> "AspectLanguageParser.cs"$
5 using AspectSharp
.Lang
.AST
;
7 // Generate the header common to all output files.
10 using TokenBuffer
= antlr
.TokenBuffer
;
11 using TokenStreamException
= antlr
.TokenStreamException
;
12 using TokenStreamIOException
= antlr
.TokenStreamIOException
;
13 using ANTLRException
= antlr
.ANTLRException
;
14 using LLkParser
= antlr
.LLkParser
;
15 using Token
= antlr
.Token
;
16 using TokenStream
= antlr
.TokenStream
;
17 using RecognitionException
= antlr
.RecognitionException
;
18 using NoViableAltException
= antlr
.NoViableAltException
;
19 using MismatchedTokenException
= antlr
.MismatchedTokenException
;
20 using SemanticException
= antlr
.SemanticException
;
21 using ParserSharedInputState
= antlr
.ParserSharedInputState
;
22 using BitSet
= antlr
.collections
.impl
.BitSet
;
24 public class AspectLanguageParser
: antlr
.LLkParser
26 public const int EOF
= 1;
27 public const int NULL_TREE_LOOKAHEAD
= 3;
28 public const int ASPECT
= 4;
29 public const int FOR
= 5;
30 public const int IN
= 6;
31 public const int END
= 7;
32 public const int IMPORT
= 8;
33 public const int MIXINS
= 9;
34 public const int INCLUDE
= 10;
35 public const int INTERCEPTORS
= 11;
36 public const int ADVICEINTERCEPTOR
= 12;
37 public const int POINTCUT
= 13;
38 public const int METHOD
= 14;
39 public const int PROPERTY
= 15;
40 public const int PROPERTY_READ
= 16;
41 public const int PROPERTY_WRITE
= 17;
42 public const int ASSIGNFROM
= 18;
43 public const int CUSTOMMATCHER
= 19;
44 public const int EXCLUDES
= 20;
45 public const int INCLUDES
= 21;
46 public const int EOS
= 22;
47 public const int LBRACK
= 23;
48 public const int SEMI
= 24;
49 public const int RBRACK
= 25;
50 public const int STRING_LITERAL
= 26;
51 public const int COLON
= 27;
52 public const int ID
= 28;
53 public const int LCURLY
= 29;
54 public const int RCURLY
= 30;
55 public const int OR
= 31;
56 public const int ALL
= 32;
57 public const int COMMA
= 33;
58 public const int DOT
= 34;
59 public const int WS
= 35;
62 protected StringBuilder sbuilder
= new StringBuilder();
64 protected LexicalInfo
ToLexicalInfo(antlr
.IToken token
)
66 int line
= token
.getLine();
67 int startColumn
= token
.getColumn();
68 int endColumn
= token
.getColumn() + token
.getText().Length
;
69 String filename
= token
.getFilename();
70 return new LexicalInfo(filename
, line
, startColumn
, endColumn
);
73 protected String
methodAll(String s
)
80 protected void initialize()
82 tokenNames
= tokenNames_
;
86 protected AspectLanguageParser(TokenBuffer tokenBuf
, int k
) : base(tokenBuf
, k
)
91 public AspectLanguageParser(TokenBuffer tokenBuf
) : this(tokenBuf
,1)
95 protected AspectLanguageParser(TokenStream lexer
, int k
) : base(lexer
,k
)
100 public AspectLanguageParser(TokenStream lexer
) : this(lexer
,1)
104 public AspectLanguageParser(ParserSharedInputState state
) : base(state
,1)
109 public EngineConfiguration
start() //throws RecognitionException, TokenStreamException
111 EngineConfiguration conf
;
114 conf
= new EngineConfiguration();
117 try { // for error handling
127 goto _loop3_breakloop
;
138 import_directive(conf
);
142 goto _loop5_breakloop
;
151 if ((LA(1)==INTERCEPTORS
))
153 interceptors_global(conf
);
157 goto _loop7_breakloop
;
172 goto _loop9_breakloop
;
187 goto _loop11_breakloop
;
193 match(Token
.EOF_TYPE
);
195 catch (RecognitionException ex
)
199 consumeUntil(tokenSet_0_
);
204 protected void import_directive(
205 EngineConfiguration conf
206 ) //throws RecognitionException, TokenStreamException
213 ImportDirective import
= null;
216 try { // for error handling
221 import
= new ImportDirective( ToLexicalInfo(i
), ns
);
222 conf
.Imports
.Add(import
);
230 assemblyName
=identifier();
232 import
.AssemblyReference
= new AssemblyReference( ToLexicalInfo(i
), assemblyName
);
246 throw new NoViableAltException(LT(1), getFilename());
251 catch (RecognitionException ex
)
255 consumeUntil(tokenSet_1_
);
259 protected void interceptors_global(
260 EngineConfiguration conf
261 ) //throws RecognitionException, TokenStreamException
265 try { // for error handling
267 keytypepair(conf
.Interceptors
);
271 catch (RecognitionException ex
)
275 consumeUntil(tokenSet_2_
);
279 protected void mixins_global(
280 EngineConfiguration conf
281 ) //throws RecognitionException, TokenStreamException
285 try { // for error handling
287 keytypepair(conf
.Mixins
);
291 catch (RecognitionException ex
)
295 consumeUntil(tokenSet_3_
);
299 protected void aspects(
300 EngineConfiguration conf
301 ) //throws RecognitionException, TokenStreamException
305 IToken aspectId
= null;
307 AspectDefinition aspect
= null;
308 TargetTypeDefinition target
= null;
309 TypeReference tr
= null;
312 try { // for error handling
319 aspect
= new AspectDefinition( ToLexicalInfo(a
), aspectId
.getText() );
320 conf
.Aspects
.Add(aspect
);
329 target
= new TargetTypeDefinition( tr
);
330 target
.TargetStrategy
= TargetStrategyEnum
.SingleType
;
331 aspect
.TargetType
= target
;
339 target
= new TargetTypeDefinition( );
340 aspect
.TargetType
= target
;
341 String namespaceRegEx
= null;
353 target
.TargetStrategy
= TargetStrategyEnum
.Assignable
;
354 target
.AssignType
= tr
;
360 match(CUSTOMMATCHER
);
365 target
.TargetStrategy
= TargetStrategyEnum
.Custom
;
366 target
.CustomMatcherType
= tr
;
373 namespaceRegEx
=identifier();
375 target
.TargetStrategy
= TargetStrategyEnum
.Namespace
;
376 target
.NamespaceRoot
= namespaceRegEx
;
385 type_list(target
.Excludes
);
395 throw new NoViableAltException(LT(1), getFilename());
404 throw new NoViableAltException(LT(1), getFilename());
413 throw new NoViableAltException(LT(1), getFilename());
421 if ((LA(1)==INCLUDE
))
427 goto _loop33_breakloop
;
436 if ((LA(1)==POINTCUT
))
442 goto _loop35_breakloop
;
451 catch (RecognitionException ex
)
455 consumeUntil(tokenSet_4_
);
459 protected String
identifier() //throws RecognitionException, TokenStreamException
466 value = null; sbuilder
.Length
= 0;
469 try { // for error handling
473 sbuilder
.Append(id
.getText());
474 value = sbuilder
.ToString();
485 sbuilder
.Append('.');
486 sbuilder
.Append(id2
.getText());
491 goto _loop65_breakloop
;
498 value = sbuilder
.ToString();
501 catch (RecognitionException ex
)
505 consumeUntil(tokenSet_5_
);
510 protected void keytypepair(
511 IDeclarationCollection collection
512 ) //throws RecognitionException, TokenStreamException
516 try { // for error handling
520 pairvalue(collection
);
527 pairvalue(collection
);
531 goto _loop20_breakloop
;
541 catch (RecognitionException ex
)
545 consumeUntil(tokenSet_2_
);
549 protected void pairvalue(
550 IDeclarationCollection collection
551 ) //throws RecognitionException, TokenStreamException
554 IToken keyToken
= null;
556 DefinitionBase definition
= null;
559 try { // for error handling
561 match(STRING_LITERAL
);
564 String key
= keyToken
.getText();
565 definition
= collection
.Add( key
, ToLexicalInfo(keyToken
) );
567 type_name(definition
);
569 catch (RecognitionException ex
)
573 consumeUntil(tokenSet_6_
);
577 protected void type_name(
578 DefinitionBase definition
579 ) //throws RecognitionException, TokenStreamException
583 TypeReference tr
= null;
586 try { // for error handling
589 definition
.TypeReference
= tr
;
592 catch (RecognitionException ex
)
596 consumeUntil(tokenSet_6_
);
600 protected TypeReference
type_name_or_ref() //throws RecognitionException, TokenStreamException
604 IToken refTypeToken
= null;
609 try { // for error handling
614 refTypeToken
= LT(1);
615 match(STRING_LITERAL
);
617 type
= new TypeReference();
618 type
.LinkRef
= refTypeToken
.getText();
624 type
=type_name_def();
629 throw new NoViableAltException(LT(1), getFilename());
633 catch (RecognitionException ex
)
637 consumeUntil(tokenSet_7_
);
642 protected TypeReference
type_name_def() //throws RecognitionException, TokenStreamException
648 type
= new TypeReference();
649 String typeToken
= null;
650 String assemblyToken
= null;
653 try { // for error handling
654 typeToken
=identifier();
656 type
.TypeName
= typeToken
;
665 assemblyToken
=identifier();
667 type
.AssemblyReference
= new AssemblyReference( ToLexicalInfo(i
), assemblyToken
);
682 throw new NoViableAltException(LT(1), getFilename());
687 catch (RecognitionException ex
)
691 consumeUntil(tokenSet_8_
);
696 protected void type_list(
697 TypeReferenceCollection types
698 ) //throws RecognitionException, TokenStreamException
702 TypeReference tr
= null;
705 try { // for error handling
723 goto _loop38_breakloop
;
730 catch (RecognitionException ex
)
734 consumeUntil(tokenSet_9_
);
738 protected void include(
739 AspectDefinition aspect
740 ) //throws RecognitionException, TokenStreamException
745 TypeReference tr
= null;
749 try { // for error handling
753 md
= new MixinDefinition( ToLexicalInfo(i
) );
755 tr
=type_name_or_ref();
757 md
.TypeReference
= tr
;
758 aspect
.Mixins
.Add( md
);
761 catch (RecognitionException ex
)
765 consumeUntil(tokenSet_10_
);
769 protected void pointcut(
770 AspectDefinition aspect
771 ) //throws RecognitionException, TokenStreamException
776 PointCutDefinition pointcut
= null;
777 PointCutFlags flags
= PointCutFlags
.Unspecified
;
780 try { // for error handling
783 flags
=pointcutflags();
785 pointcut
= new PointCutDefinition( ToLexicalInfo(p
), flags
);
786 aspect
.PointCuts
.Add( pointcut
);
788 pointcuttarget(pointcut
);
792 catch (RecognitionException ex
)
796 consumeUntil(tokenSet_11_
);
800 protected PointCutFlags
pointcutflags() //throws RecognitionException, TokenStreamException
805 flags
= PointCutFlags
.Unspecified
;
808 try { // for error handling
809 flags
=pointcutflag(flags
);
816 flags
=pointcutflag(flags
);
825 throw new NoViableAltException(LT(1), getFilename());
830 catch (RecognitionException ex
)
834 consumeUntil(tokenSet_12_
);
839 protected void pointcuttarget(
840 PointCutDefinition pointcut
841 ) //throws RecognitionException, TokenStreamException
845 try { // for error handling
847 pointcutsignature(pointcut
);
849 catch (RecognitionException ex
)
853 consumeUntil(tokenSet_13_
);
857 protected void advices(
858 PointCutDefinition pointcut
859 ) //throws RecognitionException, TokenStreamException
863 try { // for error handling
867 if ((LA(1)==ADVICEINTERCEPTOR
))
873 goto _loop43_breakloop
;
880 catch (RecognitionException ex
)
884 consumeUntil(tokenSet_14_
);
888 protected void advice(
889 PointCutDefinition pointcut
890 ) //throws RecognitionException, TokenStreamException
895 TypeReference tr
= null;
896 InterceptorDefinition interDef
= null;
899 try { // for error handling
901 match(ADVICEINTERCEPTOR
);
903 interDef
= new InterceptorDefinition( ToLexicalInfo(i
) );
906 tr
=type_name_or_ref();
908 interDef
.TypeReference
= tr
;
909 pointcut
.Advices
.Add( interDef
);
913 catch (RecognitionException ex
)
917 consumeUntil(tokenSet_13_
);
921 protected PointCutFlags
pointcutflag(
923 ) //throws RecognitionException, TokenStreamException
925 PointCutFlags retValue
;
931 try { // for error handling
937 retValue
|= PointCutFlags
.Method
;
943 retValue
|= PointCutFlags
.Property
;
948 match(PROPERTY_READ
);
949 retValue
|= PointCutFlags
.PropertyRead
;
954 match(PROPERTY_WRITE
);
955 retValue
|= PointCutFlags
.PropertyWrite
;
960 throw new NoViableAltException(LT(1), getFilename());
964 catch (RecognitionException ex
)
968 consumeUntil(tokenSet_15_
);
973 protected void pointcutsignature(
974 PointCutDefinition pointcut
975 ) //throws RecognitionException, TokenStreamException
979 try { // for error handling
980 pointcutsig1(pointcut
);
982 catch (RecognitionException ex
)
986 consumeUntil(tokenSet_13_
);
990 protected void pointcutsig1(
991 PointCutDefinition pointcut
992 ) //throws RecognitionException, TokenStreamException
997 MethodSignature ms
= null;
1000 try { // for error handling
1009 ms
= AllMethodSignature
.Instance
;
1016 ms
= new MethodSignature(part1
, methodAll("*"));
1021 throw new NoViableAltException(LT(1), getFilename());
1025 pointcut
.Method
= pointcutsig2(part1
, ms
);
1027 catch (RecognitionException ex
)
1031 consumeUntil(tokenSet_13_
);
1035 protected String
reg_ex(
1037 ) //throws RecognitionException, TokenStreamException
1043 value = null; sbuilder
.Length
= 0;
1046 try { // for error handling
1051 sbuilder
.Append(id
.getText());
1052 value = sbuilder
.ToString();
1066 sbuilder
.Append('.');
1070 sbuilder
.Append('*');
1075 if ((tokenSet_16_
.member(LA(1))))
1081 throw new NoViableAltException(LT(1), getFilename());
1085 else if ((tokenSet_16_
.member(LA(1)))) {
1089 throw new NoViableAltException(LT(1), getFilename());
1095 value = sbuilder
.ToString();
1098 catch (RecognitionException ex
)
1102 consumeUntil(tokenSet_16_
);
1107 protected MethodSignature
pointcutsig2(
1108 String part1
, MethodSignature ms
1109 ) //throws RecognitionException, TokenStreamException
1111 MethodSignature ret
;
1118 try { // for error handling
1126 ret
=pointcutsig3(part1
, part2
, ms
);
1132 pointcutarguments(ms
);
1147 ret
=pointcutsig3(part1
, part2
, ms
);
1152 throw new NoViableAltException(LT(1), getFilename());
1157 catch (RecognitionException ex
)
1161 consumeUntil(tokenSet_0_
);
1166 protected MethodSignature
pointcutsig3(
1167 String part1
, String part2
, MethodSignature ms
1168 ) //throws RecognitionException, TokenStreamException
1170 MethodSignature ret
;
1177 try { // for error handling
1185 ms
= new MethodSignature(part1
, part2
, methodAll(part3
));
1192 ms
= new MethodSignature(part1
, methodAll(part2
));
1193 pointcutarguments(ms
);
1201 ms
= new MethodSignature(part1
, methodAll(part2
));
1206 part3
=reg_ex(false);
1207 ms
= new MethodSignature(part1
, part2
, methodAll(part3
));
1213 throw new NoViableAltException(LT(1), getFilename());
1219 catch (RecognitionException ex
)
1223 consumeUntil(tokenSet_0_
);
1228 protected void pointcutarguments(
1230 ) //throws RecognitionException, TokenStreamException
1234 try { // for error handling
1241 pointcutargument(ms
);
1248 pointcutargument(ms
);
1252 goto _loop61_breakloop
;
1256 _loop61_breakloop: ;
1266 throw new NoViableAltException(LT(1), getFilename());
1271 catch (RecognitionException ex
)
1275 consumeUntil(tokenSet_9_
);
1279 protected void pointcutsig4(
1281 ) //throws RecognitionException, TokenStreamException
1285 try { // for error handling
1292 pointcutarguments(ms
);
1304 throw new NoViableAltException(LT(1), getFilename());
1309 catch (RecognitionException ex
)
1313 consumeUntil(tokenSet_0_
);
1317 protected void pointcutargument(
1319 ) //throws RecognitionException, TokenStreamException
1323 String argType
= String
.Empty
;
1326 try { // for error handling
1333 ms
.AddArgumentType( "*" );
1339 argType
=reg_ex(false);
1341 ms
.AddArgumentType( argType
);
1347 throw new NoViableAltException(LT(1), getFilename());
1351 catch (RecognitionException ex
)
1355 consumeUntil(tokenSet_17_
);
1359 private void initializeFactory()
1363 public static readonly string[] tokenNames_
= new string[] {
1367 @"""NULL_TREE_LOOKAHEAD""",
1375 @"""interceptors""",
1380 @"""propertyread""",
1381 @"""propertywrite""",
1382 @"""assignableFrom""",
1383 @"""customMatcher""",
1390 @"""STRING_LITERAL""",
1402 private static long[] mk_tokenSet_0_()
1404 long[] data
= { 2L, 0L}
;
1407 public static readonly BitSet tokenSet_0_
= new BitSet(mk_tokenSet_0_());
1408 private static long[] mk_tokenSet_1_()
1410 long[] data
= { 2834L, 0L}
;
1413 public static readonly BitSet tokenSet_1_
= new BitSet(mk_tokenSet_1_());
1414 private static long[] mk_tokenSet_2_()
1416 long[] data
= { 2578L, 0L}
;
1419 public static readonly BitSet tokenSet_2_
= new BitSet(mk_tokenSet_2_());
1420 private static long[] mk_tokenSet_3_()
1422 long[] data
= { 530L, 0L}
;
1425 public static readonly BitSet tokenSet_3_
= new BitSet(mk_tokenSet_3_());
1426 private static long[] mk_tokenSet_4_()
1428 long[] data
= { 18L, 0L}
;
1431 public static readonly BitSet tokenSet_4_
= new BitSet(mk_tokenSet_4_());
1432 private static long[] mk_tokenSet_5_()
1434 long[] data
= { 1125134290L, 0L}
;
1437 public static readonly BitSet tokenSet_5_
= new BitSet(mk_tokenSet_5_());
1438 private static long[] mk_tokenSet_6_()
1440 long[] data
= { 50331648L, 0L}
;
1443 public static readonly BitSet tokenSet_6_
= new BitSet(mk_tokenSet_6_());
1444 private static long[] mk_tokenSet_7_()
1446 long[] data
= { 1073751168L, 0L}
;
1449 public static readonly BitSet tokenSet_7_
= new BitSet(mk_tokenSet_7_());
1450 private static long[] mk_tokenSet_8_()
1452 long[] data
= { 1124082816L, 0L}
;
1455 public static readonly BitSet tokenSet_8_
= new BitSet(mk_tokenSet_8_());
1456 private static long[] mk_tokenSet_9_()
1458 long[] data
= { 1073741824L, 0L}
;
1461 public static readonly BitSet tokenSet_9_
= new BitSet(mk_tokenSet_9_());
1462 private static long[] mk_tokenSet_10_()
1464 long[] data
= { 9344L, 0L}
;
1467 public static readonly BitSet tokenSet_10_
= new BitSet(mk_tokenSet_10_());
1468 private static long[] mk_tokenSet_11_()
1470 long[] data
= { 8320L, 0L}
;
1473 public static readonly BitSet tokenSet_11_
= new BitSet(mk_tokenSet_11_());
1474 private static long[] mk_tokenSet_12_()
1476 long[] data
= { 536870912L, 0L}
;
1479 public static readonly BitSet tokenSet_12_
= new BitSet(mk_tokenSet_12_());
1480 private static long[] mk_tokenSet_13_()
1482 long[] data
= { 4224L, 0L}
;
1485 public static readonly BitSet tokenSet_13_
= new BitSet(mk_tokenSet_13_());
1486 private static long[] mk_tokenSet_14_()
1488 long[] data
= { 128L, 0L}
;
1491 public static readonly BitSet tokenSet_14_
= new BitSet(mk_tokenSet_14_());
1492 private static long[] mk_tokenSet_15_()
1494 long[] data
= { 2684354560L, 0L}
;
1497 public static readonly BitSet tokenSet_15_
= new BitSet(mk_tokenSet_15_());
1498 private static long[] mk_tokenSet_16_()
1500 long[] data
= { 14763954304L, 0L}
;
1503 public static readonly BitSet tokenSet_16_
= new BitSet(mk_tokenSet_16_());
1504 private static long[] mk_tokenSet_17_()
1506 long[] data
= { 9663676416L, 0L}
;
1509 public static readonly BitSet tokenSet_17_
= new BitSet(mk_tokenSet_17_());