aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/text/lexer.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-08-21 00:35:28 -0400
committerEduardo Julian2018-08-21 00:35:28 -0400
commit81a04b5935cd755efb4096d5e3f347cd0bb6cdef (patch)
treecb885b69dddb07e5ed331d3e0e9598661316e90e /stdlib/source/lux/data/text/lexer.lux
parent9ccc8ea44ebe4f9a3d40c8e94b55f77c0d815099 (diff)
Minor optimizations + timing.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/data/text/lexer.lux22
1 files changed, 12 insertions, 10 deletions
diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux
index 677810eb8..e6186aea8 100644
--- a/stdlib/source/lux/data/text/lexer.lux
+++ b/stdlib/source/lux/data/text/lexer.lux
@@ -58,7 +58,7 @@
slices lexer]
(wrap (list/fold (function (_ [slice::basis slice::distance]
[total::basis total::distance])
- [total::basis (n/+ slice::distance total::distance)])
+ [total::basis ("lux i64 +" slice::distance total::distance)])
{#basis offset
#distance 0}
slices))))
@@ -69,7 +69,7 @@
(function (_ [offset tape])
(case (//.nth offset tape)
(#.Some output)
- (#e.Success [[(inc offset) tape] (//.from-code output)])
+ (#e.Success [[("lux i64 +" 1 offset) tape] (//.from-code output)])
_
(#e.Error cannot-lex-error))))
@@ -78,7 +78,7 @@
{#.doc "Just returns the next character without applying any logic."}
(Lexer Slice)
(function (_ [offset tape])
- (#e.Success [[(inc offset) tape]
+ (#e.Success [[("lux i64 +" 1 offset) tape]
{#basis offset
#distance 1}])))
@@ -105,7 +105,8 @@
(case (//.index-of' reference offset tape)
(#.Some where)
(if (n/= offset where)
- (#e.Success [[(n/+ (//.size reference) offset) tape] []])
+ (#e.Success [[("lux i64 +" (//.size reference) offset) tape]
+ []])
(#e.Error ($_ text/compose "Could not match: " (//.encode reference) " @ " (maybe.assume (//.clip' offset tape)))))
_
@@ -117,7 +118,8 @@
(function (_ (^@ input [offset tape]))
(case (//.index-of' reference offset tape)
(^multi (#.Some where) (n/= offset where))
- (#e.Success [[(n/+ (//.size reference) offset) tape] #1])
+ (#e.Success [[("lux i64 +" (//.size reference) offset) tape]
+ #1])
_
(#e.Success [input #0]))))
@@ -203,7 +205,7 @@
(#.Some output)
(let [output (//.from-code output)]
(if (<modifier> (//.contains? output options))
- (#e.Success [[(inc offset) tape] output])
+ (#e.Success [[("lux i64 +" 1 offset) tape] output])
(#e.Error ($_ text/compose "Character (" output
") is should " <description-modifier>
"be one of: " options))))
@@ -224,7 +226,7 @@
(#.Some output)
(let [output (//.from-code output)]
(if (<modifier> (//.contains? output options))
- (#e.Success [[(inc offset) tape]
+ (#e.Success [[("lux i64 +" 1 offset) tape]
{#basis offset
#distance 1}])
(#e.Error ($_ text/compose "Character (" output
@@ -245,7 +247,7 @@
(case (//.nth offset tape)
(#.Some output)
(if (p output)
- (#e.Success [[(inc offset) tape] (//.from-code output)])
+ (#e.Success [[("lux i64 +" 1 offset) tape] (//.from-code output)])
(#e.Error ($_ text/compose "Character does not satisfy predicate: " (//.from-code output))))
_
@@ -268,7 +270,7 @@
(do p.Monad<Parser>
[[left::basis left::distance] left
[right::basis right::distance] right]
- (wrap [left::basis (n/+ left::distance right::distance)])))
+ (wrap [left::basis ("lux i64 +" left::distance right::distance)])))
(do-template [<name> <base> <doc-modifier>]
[(def: #export (<name> lexer)
@@ -344,7 +346,7 @@
(do p.Monad<Parser>
[[basis distance] lexer]
(function (_ (^@ input [offset tape]))
- (case (//.clip basis (n/+ basis distance) tape)
+ (case (//.clip basis ("lux i64 +" basis distance) tape)
(#.Some output)
(#e.Success [input output])