diff options
author | Masen Furer <devnull@localhost> | 2013-01-11 19:07:52 -0800 |
---|---|---|
committer | Masen Furer <devnull@localhost> | 2013-01-11 19:07:52 -0800 |
commit | d1bf5aa4a25005e8630bb639053c4340475bff6e (patch) | |
tree | 22160b51fceb3c14393114ba695f9b89830e22b4 | |
parent | 852c13d0adecc3b618a3d8a7297aead53b1bb2e5 (diff) | |
download | pygments-d1bf5aa4a25005e8630bb639053c4340475bff6e.tar.gz |
AdaLexer: fix support for record types
In the previous implementation, a record type would
trigger a descent into 'formal_part' which is
for formal parameter lists in a task, procedure, or function
declaration.
The 'formal_part' is inappropriate for the record type, which
lists Variable_Name : Variable_Type for all members of the
record, like the declaration section of a procedure.
Now the code can take advantage of highlighting
built-in types for record declarations.
Further, the 'formal_part' only pops on a right paren \)
This doesn't work for record declarations which end with a
'end record'. The previous implementation caused highlighting
inconsistencies after a record declaration because the lexer would
get stuck in 'formal_part' and wouldn't pop on 'end record'
Finally, null records would also exhibit the same behavior
described, however a null record declaration doesn't contain
an 'end record'. It is a shorthand notation which has been
special-cased into 'type_def'.
For a comparison, look at output before and after this commit
on: tests/examplefiles/test.adb
-rw-r--r-- | pygments/lexers/compiled.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index 4eadbe7e..b6fbbba5 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -2250,7 +2250,8 @@ class AdaLexer(RegexLexer): (r'\(', Punctuation, 'formal_part'), (r'with|and|use', Keyword.Reserved), (r'array\b', Keyword.Reserved, ('#pop', 'array_def')), - (r'record\b', Keyword.Reserved, ('formal_part')), + (r'record\b', Keyword.Reserved, ('record_def')), + (r'(null record)(;)', bygroups(Keyword.Reserved, Punctuation), '#pop'), include('root'), ], 'array_def' : [ @@ -2259,6 +2260,10 @@ class AdaLexer(RegexLexer): Keyword.Reserved)), include('root'), ], + 'record_def' : [ + (r'end record', Keyword.Reserved, '#pop'), + include('root'), + ], 'import': [ (r'[a-z0-9_.]+', Name.Namespace, '#pop'), (r'', Text, '#pop'), |