diff options
-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)))))) |