56 heredocstack.append((match.group(1) in ('<<-', '<<~'), match.group(3))) |
56 heredocstack.append((match.group(1) in ('<<-', '<<~'), 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: |
107 states['strings'] = [ |
106 states['strings'] = [ |
108 # easy ones |
107 # easy ones |
109 (r'\:@{0,2}[a-zA-Z_]\w*[!?]?', String.Symbol), |
108 (r'\:@{0,2}[a-zA-Z_]\w*[!?]?', String.Symbol), |
110 (words(RUBY_OPERATORS, prefix=r'\:@{0,2}'), String.Symbol), |
109 (words(RUBY_OPERATORS, prefix=r'\:@{0,2}'), String.Symbol), |
111 (r":'(\\\\|\\'|[^'])*'", String.Symbol), |
110 (r":'(\\\\|\\'|[^'])*'", String.Symbol), |
112 (r"'(\\\\|\\'|[^'])*'", String.Single), |
|
113 (r':"', String.Symbol, 'simple-sym'), |
111 (r':"', String.Symbol, 'simple-sym'), |
114 (r'([a-zA-Z_]\w*)(:)(?!:)', |
112 (r'([a-zA-Z_]\w*)(:)(?!:)', |
115 bygroups(String.Symbol, Punctuation)), # Since Ruby 1.9 |
113 bygroups(String.Symbol, Punctuation)), # Since Ruby 1.9 |
116 (r'"', String.Double, 'simple-string'), |
114 (r'"', String.Double, 'simple-string-double'), |
|
115 (r"'", String.Single, 'simple-string-single'), |
117 (r'(?<!\.)`', String.Backtick, 'simple-backtick'), |
116 (r'(?<!\.)`', String.Backtick, 'simple-backtick'), |
118 ] |
117 ] |
119 |
118 |
120 # double-quoted string and symbol |
119 # quoted string and symbol |
121 for name, ttype, end in ('string', String.Double, '"'), \ |
120 for name, ttype, end in ('string-double', String.Double, '"'), \ |
|
121 ('string-single', String.Single, "'"),\ |
122 ('sym', String.Symbol, '"'), \ |
122 ('sym', String.Symbol, '"'), \ |
123 ('backtick', String.Backtick, '`'): |
123 ('backtick', String.Backtick, '`'): |
124 states['simple-'+name] = [ |
124 states['simple-'+name] = [ |
125 include('string-intp-escaped'), |
125 include('string-intp-escaped'), |
126 (r'[^\\%s#]+' % end, ttype), |
126 (r'[^\\%s#]+' % end, ttype), |
419 insertions.append((len(curcode), |
419 insertions.append((len(curcode), |
420 [(0, Generic.Prompt, line[:end])])) |
420 [(0, Generic.Prompt, line[:end])])) |
421 curcode += line[end:] |
421 curcode += line[end:] |
422 else: |
422 else: |
423 if curcode: |
423 if curcode: |
424 for item in do_insertions( |
424 yield from do_insertions( |
425 insertions, rblexer.get_tokens_unprocessed(curcode)): |
425 insertions, rblexer.get_tokens_unprocessed(curcode)) |
426 yield item |
|
427 curcode = '' |
426 curcode = '' |
428 insertions = [] |
427 insertions = [] |
429 yield match.start(), Generic.Output, line |
428 yield match.start(), Generic.Output, line |
430 if curcode: |
429 if curcode: |
431 for item in do_insertions( |
430 yield from do_insertions( |
432 insertions, rblexer.get_tokens_unprocessed(curcode)): |
431 insertions, rblexer.get_tokens_unprocessed(curcode)) |
433 yield item |
|
434 |
432 |
435 |
433 |
436 class FancyLexer(RegexLexer): |
434 class FancyLexer(RegexLexer): |
437 """ |
435 """ |
438 Pygments Lexer For `Fancy <http://www.fancy-lang.org/>`_. |
436 Pygments Lexer For `Fancy <http://www.fancy-lang.org/>`_. |