improved assignment
This commit is contained in:
parent
b8c0315697
commit
5984316fde
2 changed files with 20 additions and 3 deletions
|
@ -57,7 +57,7 @@ fontMap = [ (attrName "assignment" , fg Vty.blue)
|
||||||
, (attrName "return" , fg Vty.green)
|
, (attrName "return" , fg Vty.green)
|
||||||
, (attrName "guard" , fg Vty.yellow)
|
, (attrName "guard" , fg Vty.yellow)
|
||||||
, (attrName "comment" , fg Vty.magenta)
|
, (attrName "comment" , fg Vty.magenta)
|
||||||
, (attrName "string" , fg Vty.green)
|
, (attrName "string" , fg Vty.cyan)
|
||||||
, (attrName "err_brackets" , bg Vty.red) -- unbalanced brackets
|
, (attrName "err_brackets" , bg Vty.red) -- unbalanced brackets
|
||||||
, (attrName "err_quotes" , Vty.withStyle (fg Vty.red) Vty.underline) -- unbalanced quotes
|
, (attrName "err_quotes" , Vty.withStyle (fg Vty.red) Vty.underline) -- unbalanced quotes
|
||||||
, (attrName "err_unterm" , Vty.withStyle (fg Vty.red) Vty.underline) -- missing ;
|
, (attrName "err_unterm" , Vty.withStyle (fg Vty.red) Vty.underline) -- missing ;
|
||||||
|
@ -85,9 +85,9 @@ concatApply (f:fs) s = f s ++ concatApply fs s
|
||||||
{- Regex-Based -}
|
{- Regex-Based -}
|
||||||
|
|
||||||
comments = slicesToFT §: "comment" §. matchAll §~ "%.*"
|
comments = slicesToFT §: "comment" §. matchAll §~ "%.*"
|
||||||
assignments = slicesToFT §: "assignment" §. matchStripCmts §~ "\\**.+=.+;"
|
assignments = slicesToFT §: "assignment" §. matchGrpStripCmts 1 §~ "(\\**[[:word:]]+)[[:blank:]]*="
|
||||||
returns = slicesToFT §: "return" §. matchStripCmts §~ "\\^.+;"
|
returns = slicesToFT §: "return" §. matchStripCmts §~ "\\^.+;"
|
||||||
strings = slicesToFT §: "string" §. matchStripCmts §~ "\"[^%]*\""
|
strings = slicesToFT §: "string" §. matchStripCmts §~ "\"[^%\"]*\""
|
||||||
guards = slicesToFT §: "guard" §. matchGrpStripCmts 1 §~ "\\[(.+):.+\\]"
|
guards = slicesToFT §: "guard" §. matchGrpStripCmts 1 §~ "\\[(.+):.+\\]"
|
||||||
|
|
||||||
{- Custom/Function-Based -}
|
{- Custom/Function-Based -}
|
||||||
|
|
17
test
Normal file
17
test
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
max = { % number a, number b, number c -> number or "error"
|
||||||
|
[ c = "" : c = "0"; ] % by default use "0" if c not specified
|
||||||
|
ab = {} + ("test " + a + " -le " + b).syscall;
|
||||||
|
[ ab = "1" :
|
||||||
|
ac = {} + ("test " + a + " -le " + c).syscall;
|
||||||
|
[ ac = "1" : ^c; ]
|
||||||
|
[ ac = "0" : ^a; ]
|
||||||
|
][ ab = "0" :
|
||||||
|
^ { a = *a; b = *c; c = *b; } + *max;
|
||||||
|
]
|
||||||
|
^ "error";
|
||||||
|
}
|
||||||
|
result = { a = "12"; b = "27"; c = "18"; } + max;
|
||||||
|
{} + ("echo " + result).syscall;
|
||||||
|
{} + ("echo " + ({ a = "-12"; b = "-27"; } + max)).syscall;
|
||||||
|
}
|
Loading…
Reference in a new issue