3 pygments.lexers.crystal |
3 pygments.lexers.crystal |
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Lexer for Crystal. |
6 Lexer for Crystal. |
7 |
7 |
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
11 |
12 import re |
12 import re |
13 |
13 |
56 heredocstack.append((match.group(1) == '<<-', match.group(3))) |
56 heredocstack.append((match.group(1) == '<<-', match.group(3))) |
57 |
57 |
58 ctx.pos = match.start(5) |
58 ctx.pos = match.start(5) |
59 ctx.end = match.end(5) |
59 ctx.end = match.end(5) |
60 # this may find other heredocs |
60 # this may find other heredocs |
61 for i, t, v in self.get_tokens_unprocessed(context=ctx): |
61 yield from self.get_tokens_unprocessed(context=ctx) |
62 yield i, t, v |
|
63 ctx.pos = match.end() |
62 ctx.pos = match.end() |
64 |
63 |
65 if outermost: |
64 if outermost: |
66 # this is the outer heredoc again, now we can process them all |
65 # this is the outer heredoc again, now we can process them all |
67 for tolerant, hdname in heredocstack: |
66 for tolerant, hdname in heredocstack: |
133 ('\\{', '\\}', '{}', 'cb'), \ |
132 ('\\{', '\\}', '{}', 'cb'), \ |
134 ('\\[', '\\]', '\\[\\]', 'sb'), \ |
133 ('\\[', '\\]', '\\[\\]', 'sb'), \ |
135 ('\\(', '\\)', '()', 'pa'), \ |
134 ('\\(', '\\)', '()', 'pa'), \ |
136 ('<', '>', '<>', 'ab'): |
135 ('<', '>', '<>', 'ab'): |
137 states[name+'-intp-string'] = [ |
136 states[name+'-intp-string'] = [ |
138 (r'\\[' + lbrace + ']', String.Other), |
137 (r'\\' + lbrace, String.Other), |
139 (lbrace, String.Other, '#push'), |
138 (lbrace, String.Other, '#push'), |
140 (rbrace, String.Other, '#pop'), |
139 (rbrace, String.Other, '#pop'), |
141 include('string-intp-escaped'), |
140 include('string-intp-escaped'), |
142 (r'[\\#' + bracecc + ']', String.Other), |
141 (r'[\\#' + bracecc + ']', String.Other), |
143 (r'[^\\#' + bracecc + ']+', String.Other), |
142 (r'[^\\#' + bracecc + ']+', String.Other), |