362 # optionsSpec |
362 # optionsSpec |
363 (r'options\b', Keyword, 'options'), |
363 (r'options\b', Keyword, 'options'), |
364 # tokensSpec |
364 # tokensSpec |
365 (r'tokens\b', Keyword, 'tokens'), |
365 (r'tokens\b', Keyword, 'tokens'), |
366 # attrScope |
366 # attrScope |
367 (r'(scope)(\s*)(' + _id + ')(\s*)(\{)', |
367 (r'(scope)(\s*)(' + _id + r')(\s*)(\{)', |
368 bygroups(Keyword, Whitespace, Name.Variable, Whitespace, |
368 bygroups(Keyword, Whitespace, Name.Variable, Whitespace, |
369 Punctuation), 'action'), |
369 Punctuation), 'action'), |
370 # exception |
370 # exception |
371 (r'(catch|finally)\b', Keyword, 'exception'), |
371 (r'(catch|finally)\b', Keyword, 'exception'), |
372 # action |
372 # action |
373 (r'(@' + _id + ')(\s*)(::)?(\s*)(' + _id + ')(\s*)(\{)', |
373 (r'(@' + _id + r')(\s*)(::)?(\s*)(' + _id + r')(\s*)(\{)', |
374 bygroups(Name.Label, Whitespace, Punctuation, Whitespace, |
374 bygroups(Name.Label, Whitespace, Punctuation, Whitespace, |
375 Name.Label, Whitespace, Punctuation), 'action'), |
375 Name.Label, Whitespace, Punctuation), 'action'), |
376 # rule |
376 # rule |
377 (r'((?:protected|private|public|fragment)\b)?(\s*)(' + _id + ')(!)?', |
377 (r'((?:protected|private|public|fragment)\b)?(\s*)(' + _id + ')(!)?', |
378 bygroups(Keyword, Whitespace, Name.Label, Punctuation), |
378 bygroups(Keyword, Whitespace, Name.Label, Punctuation), |
403 # ruleScopeSpec - scope followed by target language code or name of action |
403 # ruleScopeSpec - scope followed by target language code or name of action |
404 # TODO finish implementing other possibilities for scope |
404 # TODO finish implementing other possibilities for scope |
405 # L173 ANTLRv3.g from ANTLR book |
405 # L173 ANTLRv3.g from ANTLR book |
406 (r'(scope)(\s+)(\{)', bygroups(Keyword, Whitespace, Punctuation), |
406 (r'(scope)(\s+)(\{)', bygroups(Keyword, Whitespace, Punctuation), |
407 'action'), |
407 'action'), |
408 (r'(scope)(\s+)(' + _id + ')(\s*)(;)', |
408 (r'(scope)(\s+)(' + _id + r')(\s*)(;)', |
409 bygroups(Keyword, Whitespace, Name.Label, Whitespace, Punctuation)), |
409 bygroups(Keyword, Whitespace, Name.Label, Whitespace, Punctuation)), |
410 # ruleAction |
410 # ruleAction |
411 (r'(@' + _id + ')(\s*)(\{)', |
411 (r'(@' + _id + r')(\s*)(\{)', |
412 bygroups(Name.Label, Whitespace, Punctuation), 'action'), |
412 bygroups(Name.Label, Whitespace, Punctuation), 'action'), |
413 # finished prelims, go to rule alts! |
413 # finished prelims, go to rule alts! |
414 (r':', Punctuation, '#pop') |
414 (r':', Punctuation, '#pop') |
415 ], |
415 ], |
416 'rule-alts': [ |
416 'rule-alts': [ |
440 'tokens': [ |
440 'tokens': [ |
441 include('whitespace'), |
441 include('whitespace'), |
442 include('comments'), |
442 include('comments'), |
443 (r'\{', Punctuation), |
443 (r'\{', Punctuation), |
444 (r'(' + _TOKEN_REF + r')(\s*)(=)?(\s*)(' + _STRING_LITERAL |
444 (r'(' + _TOKEN_REF + r')(\s*)(=)?(\s*)(' + _STRING_LITERAL |
445 + ')?(\s*)(;)', |
445 + r')?(\s*)(;)', |
446 bygroups(Name.Label, Whitespace, Punctuation, Whitespace, |
446 bygroups(Name.Label, Whitespace, Punctuation, Whitespace, |
447 String, Whitespace, Punctuation)), |
447 String, Whitespace, Punctuation)), |
448 (r'\}', Punctuation, '#pop'), |
448 (r'\}', Punctuation, '#pop'), |
449 ], |
449 ], |
450 'options': [ |
450 'options': [ |
451 include('whitespace'), |
451 include('whitespace'), |
452 include('comments'), |
452 include('comments'), |
453 (r'\{', Punctuation), |
453 (r'\{', Punctuation), |
454 (r'(' + _id + r')(\s*)(=)(\s*)(' + |
454 (r'(' + _id + r')(\s*)(=)(\s*)(' + |
455 '|'.join((_id, _STRING_LITERAL, _INT, '\*')) + ')(\s*)(;)', |
455 '|'.join((_id, _STRING_LITERAL, _INT, r'\*')) + r')(\s*)(;)', |
456 bygroups(Name.Variable, Whitespace, Punctuation, Whitespace, |
456 bygroups(Name.Variable, Whitespace, Punctuation, Whitespace, |
457 Text, Whitespace, Punctuation)), |
457 Text, Whitespace, Punctuation)), |
458 (r'\}', Punctuation, '#pop'), |
458 (r'\}', Punctuation, '#pop'), |
459 ], |
459 ], |
460 'action': [ |
460 'action': [ |