]> git.llucax.com Git - z.facultad/75.00/informe.git/blob - ext/pcodehl.py
Ordenar alfabéticamente las referencias
[z.facultad/75.00/informe.git] / ext / pcodehl.py
1
2 from pygments.lexer import RegexLexer, include, bygroups, using, this
3 from pygments.token import *
4
5 class PseudoCodeLexer(RegexLexer):
6     name = 'PseudoCode'
7     aliases = ['pcode']
8     filenames = ['*.pcode']
9
10     #: optional Comment or Whitespace
11     _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
12
13     tokens = {
14         'whitespace': [
15             (r'\n', Text),
16             (r'\s+', Text),
17             (r'\\\n', Text), # line continuation
18             (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
19             (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
20         ],
21         'statements': [
22             (r'L?"', String, 'string'),
23             (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
24             (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
25             (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
26             (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
27             (r'0[0-7]+[Ll]?', Number.Oct),
28             (r'\d+[Ll]?', Number.Integer),
29             (r'\*/', Error),
30             (r'[~!%^&*+=|?:<>/-]', Operator),
31             (r'[()\[\],.]', Punctuation),
32             (r'(auto|break|continue|else|function|is|in|not|and|or|while|'
33              r'foreach|if|return|throw|do|cast)\b', Keyword),
34             (r'(true|false|null|global|exit|fflush|fork|wait|try_wait)\b',
35                 Name.Builtin),
36             ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
37         ],
38         'root': [
39             include('whitespace'),
40             ('', Text, 'statement'),
41         ],
42         'statement' : [
43             include('whitespace'),
44             include('statements'),
45             ('[{}]', Punctuation),
46             (';', Punctuation, '#pop'),
47         ],
48         'string': [
49             (r'"', String, '#pop'),
50             (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
51             (r'[^\\"\n]+', String), # all other characters
52             (r'\\\n', String), # line continuation
53             (r'\\', String), # stray backslash
54         ],
55     }
56
57 def setup(app):
58     from sphinx.highlighting import lexers
59     lexers['pcode'] = PseudoCodeLexer()
60
61 # vim: set et sw=4 sts=4 :