eric6/ThirdParty/Pygments/pygments/lexers/r.py

changeset 7701
25f42e208e08
parent 7547
21b0534faebc
child 7983
54c5cfbb1e29
equal deleted inserted replaced
7700:a3cf077a8db3 7701:25f42e208e08
3 pygments.lexers.r 3 pygments.lexers.r
4 ~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~
5 5
6 Lexers for the R/S languages. 6 Lexers for the R/S languages.
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
47 else: 47 else:
48 # We have reached a non-prompt line! 48 # We have reached a non-prompt line!
49 # If we have stored prompt lines, need to process them first. 49 # If we have stored prompt lines, need to process them first.
50 if current_code_block: 50 if current_code_block:
51 # Weave together the prompts and highlight code. 51 # Weave together the prompts and highlight code.
52 for item in do_insertions( 52 yield from do_insertions(
53 insertions, slexer.get_tokens_unprocessed(current_code_block)): 53 insertions, slexer.get_tokens_unprocessed(current_code_block))
54 yield item
55 # Reset vars for next code block. 54 # Reset vars for next code block.
56 current_code_block = '' 55 current_code_block = ''
57 insertions = [] 56 insertions = []
58 # Now process the actual line itself, this is output from R. 57 # Now process the actual line itself, this is output from R.
59 yield match.start(), Generic.Output, line 58 yield match.start(), Generic.Output, line
60 59
61 # If we happen to end on a code block with nothing after it, need to 60 # If we happen to end on a code block with nothing after it, need to
62 # process the last code block. This is neither elegant nor DRY so 61 # process the last code block. This is neither elegant nor DRY so
63 # should be changed. 62 # should be changed.
64 if current_code_block: 63 if current_code_block:
65 for item in do_insertions( 64 yield from do_insertions(
66 insertions, slexer.get_tokens_unprocessed(current_code_block)): 65 insertions, slexer.get_tokens_unprocessed(current_code_block))
67 yield item
68 66
69 67
70 class SLexer(RegexLexer): 68 class SLexer(RegexLexer):
71 """ 69 """
72 For S, S-plus, and R source code. 70 For S, S-plus, and R source code.
78 aliases = ['splus', 's', 'r'] 76 aliases = ['splus', 's', 'r']
79 filenames = ['*.S', '*.R', '.Rhistory', '.Rprofile', '.Renviron'] 77 filenames = ['*.S', '*.R', '.Rhistory', '.Rprofile', '.Renviron']
80 mimetypes = ['text/S-plus', 'text/S', 'text/x-r-source', 'text/x-r', 78 mimetypes = ['text/S-plus', 'text/S', 'text/x-r-source', 'text/x-r',
81 'text/x-R', 'text/x-r-history', 'text/x-r-profile'] 79 'text/x-R', 'text/x-r-history', 'text/x-r-profile']
82 80
83 valid_name = r'`[^`\\]*(?:\\.[^`\\]*)*`|(?:[a-zA-Z]|\.[A-Za-z_.])[\w_.]*|\.' 81 valid_name = r'`[^`\\]*(?:\\.[^`\\]*)*`|(?:[a-zA-Z]|\.[A-Za-z_.])[\w.]*|\.'
84 tokens = { 82 tokens = {
85 'comments': [ 83 'comments': [
86 (r'#.*$', Comment.Single), 84 (r'#.*$', Comment.Single),
87 ], 85 ],
88 'valid_name': [ 86 'valid_name': [

eric ide

mercurial