Commits

Tim Hatch committed 4af43be Merge

Merged in llllllllll/pygments-main (pull request #369)

Adds commented form #;(sexpr) to comment out whole sexprs and support

  • Participants
  • Parent commits 4503df6, 2d1c1c9

Comments (0)

Files changed (2)

File pygments/lexers/functional.py

 
     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),
             (r'[^|#]+', Comment.Multiline),
             (r'[|#]', Comment.Multiline),
         ],
+        'commented-form' : [
+            (r'\(', Comment, '#push'),
+            (r'\)', Comment, '#pop'),
+            (r'[^()]+', Comment),
+        ],
     }
 
 

File tests/examplefiles/r6rs-comments.scm

+#!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))))))