From 7c52f72aad338a0f14ed173926784373e551be71 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 23 Aug 2018 22:45:31 -0400 Subject: More inlining. --- stdlib/source/lux/compiler/default/syntax.lux | 58 ++++++++++++++++----------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux index 1584321e5..d281cc168 100644 --- a/stdlib/source/lux/compiler/default/syntax.lux +++ b/stdlib/source/lux/compiler/default/syntax.lux @@ -237,17 +237,16 @@ g!_ body)) -(def: (read-text [where offset source-code]) - Parser +(template: (!read-text where offset source-code) (case ("lux text index" source-code (static ..text-delimiter) offset) - (#.Some end) - (let [content (!clip offset end source-code)] - (<| (!guarantee-no-new-lines content) - (#error.Success [[(update@ #.column (n/+ (!n/- offset end)) where) - (!inc end) + (#.Some g!end) + (let [g!content (!clip offset g!end source-code)] + (<| (!guarantee-no-new-lines g!content) + (#error.Success [[(update@ #.column (n/+ (!n/- offset g!end)) where) + (!inc g!end) source-code] [where - (#.Text content)]]))) + (#.Text g!content)]]))) _ (ex.throw unrecognized-input where))) @@ -289,11 +288,11 @@ (or (!strict-name-char? char) (!digit? char))) -(template: (!discrete-output ) - (case (:: decode (!clip start end source-code)) +(template: (!discrete-output ) + (case (:: decode (!clip source-code)) (#error.Success output) - (#error.Success [[(update@ #.column (n/+ (!n/- start end)) where) - end + (#error.Success [[(update@ #.column (n/+ (!n/- )) where) + source-code] [where ( output)]]) @@ -305,17 +304,27 @@ (-> Offset Parser) (let [source-code//size ("lux text size" source-code)] (loop [end offset] - (<| (!with-char+ source-code//size source-code end char (!discrete-output )) + (<| (!with-char+ source-code//size source-code end char (!discrete-output start end )) (if (!digit?+ char) (recur (!inc end)) - (!discrete-output ))))))] + (!discrete-output start end ))))))] - [parse-nat number.Codec #.Nat] [parse-int number.Codec #.Int] - [parse-rev number.Codec #.Rev] ) -(template: (!parse-int source-code//size offset where source-code @end) +(do-template [ ] + [(template: ( source-code//size start where offset source-code) + (loop [g!end offset] + (<| (!with-char+ source-code//size source-code g!end g!char (!discrete-output start g!end )) + (if (!digit?+ g!char) + (recur (!inc g!end)) + (!discrete-output start g!end )))))] + + [!parse-nat number.Codec #.Nat] + [!parse-rev number.Codec #.Rev] + ) + +(template: (!parse-signed source-code//size offset where source-code @end) (let [g!offset/1 (!inc offset)] (<| (!with-char+ source-code//size source-code g!offset/1 g!char/1 @end) (if (!digit? g!char/1) @@ -446,7 +455,8 @@ ## Text (~~ (static ..text-delimiter)) - (read-text ) + (let [offset/1 (!inc offset/0)] + (!read-text where offset/1 source-code)) ## Special code (~~ (static ..sigil)) @@ -486,21 +496,23 @@ (let [offset/1 (!inc offset/0)] (<| (!with-char+ source-code//size source-code offset/1 char/1 ) (if (!digit? char/1) - (parse-rev offset/0 [where (!inc offset/1) source-code]) + (let [offset/2 (!inc offset/1)] + (!parse-rev source-code//size offset/0 where offset/2 source-code)) (!parse-short-name current-module where #.Identifier)))) (~~ (static ..positive-sign)) - (!parse-int source-code//size offset/0 where source-code ) + (!parse-signed source-code//size offset/0 where source-code ) (~~ (static ..negative-sign)) - (!parse-int source-code//size offset/0 where source-code )] + (!parse-signed source-code//size offset/0 where source-code )] ## else (cond (!digit? char/0) ## Natural number - (parse-nat offset/0 ) + (let [offset/1 (!inc offset/0)] + (!parse-nat source-code//size offset/0 where offset/1 source-code)) ## Identifier - (!name-char?|head char/0) + (!strict-name-char? char/0) (!parse-full-name offset/0 where #.Identifier) ## else -- cgit v1.2.3