diff options
author | Tim Hatch <tim@timhatch.com> | 2014-06-05 16:23:02 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-06-05 16:23:02 -0700 |
commit | 1725e215f9833d271462ccc7d3bd5fc7c0e41bab (patch) | |
tree | ac8f4836d453157b0b86aa56c69d3e49ae3d93f8 | |
parent | 9d5a623b666c12b243c096fa48945536bdd5e1c2 (diff) | |
parent | ad0bd3e40bff8d2735d8ec6b08b3b71622821184 (diff) | |
download | pygments-1725e215f9833d271462ccc7d3bd5fc7c0e41bab.tar.gz |
Merged in llllllllll/pygments-main (pull request #369)
Adds commented form #;(sexpr) to comment out whole sexprs and support
-rw-r--r-- | pygments/lexers/functional.py | 12 | ||||
-rw-r--r-- | tests/examplefiles/r6rs-comments.scm | 23 |
2 files changed, 34 insertions, 1 deletions
diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py index efe4d240..bbee8c83 100644 --- a/pygments/lexers/functional.py +++ b/pygments/lexers/functional.py @@ -999,11 +999,16 @@ class SchemeLexer(RegexLexer): tokens = { 'root' : [ - # the comments - always starting with semicolon + # the comments # and going to the end of the line (r';.*$', Comment.Single), # multi-line comment (r'#\|', Comment.Multiline, 'multiline-comment'), + # commented form (entire sexpr folliwng) + (r'#;\s*\(', Comment, 'commented-form'), + # signifies that the program text that follows is written with the + # lexical and datum syntax described in r6rs + (r'#!r6rs', Comment), # whitespaces - usually not relevant (r'\s+', Text), @@ -1058,6 +1063,11 @@ class SchemeLexer(RegexLexer): (r'[^|#]+', Comment.Multiline), (r'[|#]', Comment.Multiline), ], + 'commented-form' : [ + (r'\(', Comment, '#push'), + (r'\)', Comment, '#pop'), + (r'[^()]+', Comment), + ], } diff --git a/tests/examplefiles/r6rs-comments.scm b/tests/examplefiles/r6rs-comments.scm new file mode 100644 index 00000000..cd5c3636 --- /dev/null +++ b/tests/examplefiles/r6rs-comments.scm @@ -0,0 +1,23 @@ +#!r6rs + +#| + + The FACT procedure computes the factorial + + of a non-negative integer. + +|# + +(define fact + + (lambda (n) + + ;; base case + + (if (= n 0) + + #;(= n 1) + + 1 ; identity of * + + (* n (fact (- n 1)))))) |