diff options
author | jiyinyiyong <jiyinyiyong@gmail.com> | 2015-11-24 17:42:57 +0800 |
---|---|---|
committer | jiyinyiyong <jiyinyiyong@gmail.com> | 2015-11-24 17:42:57 +0800 |
commit | 174e34b3cf0736e1bf8134adaed567a5c56d131f (patch) | |
tree | 3e96953f28efd321a94d250078e790ae06046aae | |
parent | 2b910cf6b576321b1261379ca2be2d2f19d88ae1 (diff) | |
download | pygments-174e34b3cf0736e1bf8134adaed567a5c56d131f.tar.gz |
Cirru update, on dollar in variables
-rw-r--r-- | pygments/lexers/webmisc.py | 15 | ||||
-rw-r--r-- | tests/examplefiles/scope.cirru | 26 |
2 files changed, 34 insertions, 7 deletions
diff --git a/pygments/lexers/webmisc.py b/pygments/lexers/webmisc.py index def11dba..a18d2b09 100644 --- a/pygments/lexers/webmisc.py +++ b/pygments/lexers/webmisc.py @@ -437,7 +437,7 @@ class XQueryLexer(ExtendedRegexLexer): # Marklogic specific type? (r'(processing-instruction)(\s*)(\()', bygroups(Keyword, Text, Punctuation), - ('occurrenceindicator', 'kindtestforpi')), + ('occurrenceindicator', 'kindtestforpi')), (r'(item)(\s*)(\()(\s*)(\))(?=[*+?])', bygroups(Keyword, Text, Punctuation, Text, Punctuation), 'occurrenceindicator'), @@ -833,10 +833,11 @@ class CirruLexer(RegexLexer): Syntax rules of Cirru can be found at: http://cirru.org/ - * using ``()`` to markup blocks, but limited in the same line - * using ``""`` to markup strings, allow ``\`` to escape - * using ``$`` as a shorthand for ``()`` till indentation end or ``)`` - * using indentations for create nesting + * using ``()`` for expressions, but restricted in a same line + * using ``""`` for strings, with ``\`` for escaping chars + * using ``$`` as folding operator + * using ``,`` as unfolding operator + * using indentations for nested blocks .. versionadded:: 2.0 """ @@ -857,16 +858,16 @@ class CirruLexer(RegexLexer): (r'.', String.Escape, '#pop'), ], 'function': [ + (r'\,', Operator, '#pop'), (r'[^\s"()]+', Name.Function, '#pop'), (r'\)', Operator, '#pop'), (r'(?=\n)', Text, '#pop'), (r'\(', Operator, '#push'), (r'"', String, ('#pop', 'string')), (r'[ ]+', Text.Whitespace), - (r'\,', Operator, '#pop'), ], 'line': [ - (r'\$', Operator, 'function'), + (r'(?<!\w)\$(?!\w)', Operator, 'function'), (r'\(', Operator, 'function'), (r'\)', Operator), (r'\n', Text, '#pop'), diff --git a/tests/examplefiles/scope.cirru b/tests/examplefiles/scope.cirru index d3bd8f16..c3d1a2c6 100644 --- a/tests/examplefiles/scope.cirru +++ b/tests/examplefiles/scope.cirru @@ -209,3 +209,29 @@ for (a x i) (.log console x i) set a 0 while (< a 10) (+= a 1) (.log console a) + +-- WebAssembly variable names + +-- ":(c) 2015 Andreas Rossberg" + +module + export :even $even + export "odd" $odd + + func $even (param $n i32) (result i32) + if (i32.eq (get_local $n) (i32.const 0)) + i32.const 1 + call $odd (i32.sub (get_local $n) (i32.const 1)) + + func $odd (param $n i32) (result i32) + store_global $scratch (get_local $n) + if (i32.eq (get_local $n) (i32.const 0) + i32.const 0 + call $even (i32.sub (get_local $n) (i32.const 1)) + + global $scratch i32 + +assert_eq (invoke :even (i32.const 13)) (i32.const 0) +assert_eq (invoke :even (i32.const 20)) (i32.const 1) +assert_eq (invoke :odd (i32.const 13)) (i32.const 1) +assert_eq (invoke :odd (i32.const 20)) (i32.const 0) |