diff options
author | jiyinyiyong <jiyinyiyong@gmail.com> | 2014-11-04 20:42:45 +0800 |
---|---|---|
committer | jiyinyiyong <jiyinyiyong@gmail.com> | 2014-11-04 20:42:45 +0800 |
commit | 972e09563f6cf6817419f6d01295309e1ddda21e (patch) | |
tree | 85fc74151f882215a60c95bddff575bb19ab797e | |
parent | 3fab67d1733e969bbde92669f7dbf25acfa8d885 (diff) | |
download | pygments-972e09563f6cf6817419f6d01295309e1ddda21e.tar.gz |
update Cirru tests and rules
-rw-r--r-- | pygments/lexers/webmisc.py | 20 | ||||
-rw-r--r-- | tests/examplefiles/scope.cirru | 222 |
2 files changed, 203 insertions, 39 deletions
diff --git a/pygments/lexers/webmisc.py b/pygments/lexers/webmisc.py index 6dd9cede..a1f0fe93 100644 --- a/pygments/lexers/webmisc.py +++ b/pygments/lexers/webmisc.py @@ -795,7 +795,7 @@ class QmlLexer(RegexLexer): class CirruLexer(RegexLexer): """ Syntax rules of Cirru can be found at: - http://grammar.cirru.org/ + http://cirru.org/ * using ``()`` to markup blocks, but limited in the same line * using ``""`` to markup strings, allow ``\`` to escape @@ -807,7 +807,7 @@ class CirruLexer(RegexLexer): name = 'Cirru' aliases = ['cirru'] - filenames = ['*.cirru', '*.cr'] + filenames = ['*.cirru'] mimetypes = ['text/x-cirru'] flags = re.MULTILINE @@ -821,30 +821,26 @@ class CirruLexer(RegexLexer): (r'.', String.Escape, '#pop'), ], 'function': [ - (r'[\w-][^\s\(\)\"]*', Name.Function, '#pop'), + (r'[^\s\"\(\)]+', Name.Function, '#pop'), (r'\)', Operator, '#pop'), (r'(?=\n)', Text, '#pop'), (r'\(', Operator, '#push'), (r'"', String, ('#pop', 'string')), - (r'\s+', Text.Whitespace), + (r'[ ]+', Text.Whitespace), (r'\,', Operator, '#pop'), ], 'line': [ - (r'^\B', Text.Whitespace, 'function'), (r'\$', Operator, 'function'), (r'\(', Operator, 'function'), (r'\)', Operator), (r'(?=\n)', Text, '#pop'), - (r'\n', Text, '#pop'), (r'"', String, 'string'), - (r'\s+', Text.Whitespace), - (r'[\d\.]+', Number), - (r'[\w-][^\"\(\)\s]*', Name.Variable), - (r'--', Comment.Single) + (r'[ ]+', Text.Whitespace), + (r'[\+\-]?[\d\.]+\b', Number), + (r'[^\s\"\(\)]+', Name.Variable) ], 'root': [ - (r'^\s*', Text.Whitespace, ('line', 'function')), - (r'^\s+$', Text.Whitespace), + (r'^\n*', Text.Whitespace, ('line', 'function')), ] } diff --git a/tests/examplefiles/scope.cirru b/tests/examplefiles/scope.cirru index 728bcabf..d3bd8f16 100644 --- a/tests/examplefiles/scope.cirru +++ b/tests/examplefiles/scope.cirru @@ -1,43 +1,211 @@ --- https://github.com/Cirru/cirru-gopher/blob/master/code/scope.cr +-- demo -set a (int 2) +define a (read cd) $ if (> a cd) + print demo + print "not demo" -print (self) +say $ print a $ save $ b $ x $ c 8 -set c (child) +print fun -under c - under parent - print a +-- test on folding -print $ get c a +a $ -set c x (int 3) -print $ get c x +b $ c -set just-print $ code - print a +d $ e $ f -print just-print +g $ h $ i j $ k $ -eval (self) just-print -eval just-print +-- test on comma -print (string "string with space") -print (string "escapes \n \"\\") +print (, a) + a + , b + , c (, d) -brackets ((((())))) +-- test on HTML -"eval" $ string "eval" +doctype -print (add $ (int 1) (int 2)) +html + head + title $ = Cirru + script (:defer) $ :src build/build.js + link (:rel stylesheet) $ :href css/page.css + link (:rel icon) + :href http://logo.cirru.org/cirru-32x32.png?v=3 + body + textarea.demo.source $ :placeholder "Source Code" + textarea.demo.target $ :placeholder "Compiled Data" + @insert ../html/ga.html -print $ unwrap $ - map (a $ int 1) (b $ int 2) +-- test on indentation -print a - int 1 - , b c - int 2 - , d
\ No newline at end of file +a $ b $ c + +e f + (g) + h + +-- test on parentheses + +3 4 (1) 4 + +((((1)))) + +x + +-- test on quotes + +a b c d + +"a b c d" + +"a b \" c d" + +"a b" "c d" + +-- test on unfolding + +set + add 1 $ + , x y + add 5 $ + add 2 + +-- test on HTML attributes + +div + div + :class a + div + :class a b c d + + div + :class a (@ b) (@ c) d + + div + :class a + @if (@ b) + div b + div c + div + :class a + @if (@ b) b c + +-- test on helpers + +@if (@call a b) (div) (span) + +@each members + div (@ name) + +@each a + div (@ b) + @each c + div (@ d) + +-- test on HTML structure + +@rich more + #demo-more-box + #demo-more + :data-lang-text demo-more + #demo-more-list + @each room + .demo-more-room + span.demo-name + @ topic + span.demo-join + :data-lang-text demo-join + :data-id (@ id) + +-- text on bool + +print #true +print #false +print #yes +print #no +print #t +print #f + +-- test on Cirru js + +set a 1 +set a (= "This is a string") +set b #t + +-- this is comment + +number 1.4 +string x +regex ^\s$ +regex "^\\s-\"$" +sentence this is a string + +array 1 2 3 (= nothing) #t (= #t) + +set c (array 1 (= nothing)) + +set d $ object (a (= google)) + b (= reader) + c 1 + d $ array 1 2 (= string) + +1 c +-1 c + +:b d +.log console a 2 +.log console + +set demo $ object + call $ \ x (.log console x) (. this call) +. demo (.call 1) (.call 4) + +=.x d 3 + +set d null + +new Array 1 2 3 + +set x (:length c) +set str (= str) +set c (.toUpperCase str) + +\ x (+ x 1) +\ (x y) (+ x y) +\ x (set aa 1) (+ aa x) + +set f (\ x (+ x 1)) + ++ a 1 2 ++= a 1 + +> 1 2 3 + +if (> 2 1) (+ a 1) +else 2 + +if (> a 2) + .log console (= "large") +elseif (> a 1) + .log console (= "still good") +else + .log console (= "so so") + +set a $ if (> 2 1) #t #f + +switch a + 1 (.log console 1) + 2 (.log console 2) + else (.log console (= "something else")) + +set a $ array 2 +3 -4 +for (a x i) (.log console x i) + +set a 0 +while (< a 10) (+= a 1) (.log console a) |