Closed dxxb closed 1 year ago
Neat idea, I never considered using operators that are not on my keyboard, but it indeed is nice to reduce the noise and avoid confusion with the zero-or-more Kleene star. Not sure if the specific unicode handing is needed though, this works just fine for me?
--- a/src/npeg/parsepatt.nim
+++ b/src/npeg/parsepatt.nim
@@ -115,6 +115,7 @@ proc parsePatt*(pattName: string, nn: NimNode, grammar: Grammar, dot: Dot = nil)
of nnkInfix:
case n[0].strVal:
+ of "∙": result = aux(n[1]) * aux(n[2])
of "*": result = aux(n[1]) * aux(n[2])
of "-": result = aux(n[1]) - aux(n[2])
of "^": result = newPattAssoc(aux(n[1]), intVal(n[2]), assocLeft)
Not sure if the specific unicode handing is needed though, this works just fine for me?
You are correct. I just tested it and the unicode specific dance is not required. I will update the PR accordingly.
Thanks.
Thank you!
Just added ∙
to tests and README as well. I'll spin a release shortly (Waiting for an update on the last open PR)
I personally find using '' for concatenation visually "noisy". I understand an operator with the right precedence is required and so I went looking for an alternative that would not look like zero or more ''. This PR implements support for
\bullet
(∙
) because it is listed among Unicode operators here https://nim-lang.org/docs/manual.html#lexical-analysis-unicode-operators. I also tried adding\cdot
(⋅
), which seems more appropriate because it is normally used as concatenation symbol in math script, but it currently won't work.Not sure if this is something you would be interested in merging but it works and maybe someone else will find it useful.