aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2019-04-19 01:27:10 -0400
committerEduardo Julian2019-04-19 01:27:10 -0400
commit0ed7cb3a7d07cf92be57a8f26355212bcee0325d (patch)
tree935d5ff38d6494971b2d2661e60513401a94cf26
parent692f9751f36fbfc4a5f1148c7b1fadc03495fa6b (diff)
Renamed both "Poly" and "Lexer" to "Parser" in order to normalize naming a bit.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/control/parser/text.lux66
-rw-r--r--stdlib/source/lux/control/parser/type.lux50
-rw-r--r--stdlib/source/lux/data/format/json.lux28
-rw-r--r--stdlib/source/lux/data/format/xml.lux32
-rw-r--r--stdlib/source/lux/data/text/regex.lux82
-rw-r--r--stdlib/source/lux/macro/poly/functor.lux6
-rw-r--r--stdlib/source/lux/math/modular.lux4
-rw-r--r--stdlib/source/lux/time/date.lux8
-rw-r--r--stdlib/source/lux/time/instant.lux10
-rw-r--r--stdlib/source/lux/tool/interpreter/type.lux19
-rw-r--r--stdlib/source/lux/world/net/http/cookie.lux6
-rw-r--r--stdlib/source/lux/world/net/http/query.lux6
-rw-r--r--stdlib/source/test/lux/control/parser/text.lux6
-rw-r--r--stdlib/source/test/lux/data/text/regex.lux8
14 files changed, 167 insertions, 164 deletions
diff --git a/stdlib/source/lux/control/parser/text.lux b/stdlib/source/lux/control/parser/text.lux
index 22f49a572..bf4c45867 100644
--- a/stdlib/source/lux/control/parser/text.lux
+++ b/stdlib/source/lux/control/parser/text.lux
@@ -21,7 +21,7 @@
(def: start-offset Offset 0)
-(type: #export Lexer
+(type: #export Parser
(//.Parser [Offset Text]))
(type: #export Slice
@@ -41,7 +41,7 @@
["Remaining input" (remaining offset tape)]))
(def: #export (run input lexer)
- (All [a] (-> Text (Lexer a) (Error a)))
+ (All [a] (-> Text (Parser a) (Error a)))
(case (lexer [start-offset input])
(#error.Failure msg)
(#error.Failure msg)
@@ -52,12 +52,12 @@
(exception.throw unconsumed-input [end-offset input]))))
(def: #export offset
- (Lexer Offset)
+ (Parser Offset)
(function (_ (^@ input [offset tape]))
(#error.Success [input offset])))
(def: (with-slices lexer)
- (-> (Lexer (List Slice)) (Lexer Slice))
+ (-> (Parser (List Slice)) (Parser Slice))
(do //.monad
[offset ..offset
slices lexer]
@@ -70,7 +70,7 @@
(def: #export any
{#.doc "Just returns the next character without applying any logic."}
- (Lexer Text)
+ (Parser Text)
(function (_ [offset tape])
(case (/.nth offset tape)
(#.Some output)
@@ -81,7 +81,7 @@
(def: #export any!
{#.doc "Just returns the next character without applying any logic."}
- (Lexer Slice)
+ (Parser Slice)
(function (_ [offset tape])
(#error.Success [[("lux i64 +" 1 offset) tape]
{#basis offset
@@ -90,7 +90,7 @@
(template [<name> <type> <any>]
[(def: #export (<name> p)
{#.doc "Produce a character if the lexer fails."}
- (All [a] (-> (Lexer a) (Lexer <type>)))
+ (All [a] (-> (Parser a) (Parser <type>)))
(function (_ input)
(case (p input)
(#error.Failure msg)
@@ -105,7 +105,7 @@
(def: #export (this reference)
{#.doc "Lex a text if it matches the given sample."}
- (-> Text (Lexer Any))
+ (-> Text (Parser Any))
(function (_ [offset tape])
(case (/.index-of' reference offset tape)
(#.Some where)
@@ -119,7 +119,7 @@
(def: #export (this? reference)
{#.doc "Lex a text if it matches the given sample."}
- (-> Text (Lexer Bit))
+ (-> Text (Parser Bit))
(function (_ (^@ input [offset tape]))
(case (/.index-of' reference offset tape)
(^multi (#.Some where) (n/= offset where))
@@ -131,7 +131,7 @@
(def: #export end
{#.doc "Ensure the lexer's input is empty."}
- (Lexer Any)
+ (Parser Any)
(function (_ (^@ input [offset tape]))
(if (n/= offset (/.size tape))
(#error.Success [input []])
@@ -139,13 +139,13 @@
(def: #export end?
{#.doc "Ask if the lexer's input is empty."}
- (Lexer Bit)
+ (Parser Bit)
(function (_ (^@ input [offset tape]))
(#error.Success [input (n/= offset (/.size tape))])))
(def: #export peek
{#.doc "Lex the next character (without consuming it from the input)."}
- (Lexer Text)
+ (Parser Text)
(function (_ (^@ input [offset tape]))
(case (/.nth offset tape)
(#.Some output)
@@ -156,13 +156,13 @@
(def: #export get-input
{#.doc "Get all of the remaining input (without consuming it)."}
- (Lexer Text)
+ (Parser Text)
(function (_ (^@ input [offset tape]))
(#error.Success [input (remaining offset tape)])))
(def: #export (range bottom top)
{#.doc "Only lex characters within a range."}
- (-> Nat Nat (Lexer Text))
+ (-> Nat Nat (Parser Text))
(do //.monad
[char any
#let [char' (maybe.assume (/.nth 0 char))]
@@ -174,7 +174,7 @@
(template [<name> <bottom> <top> <desc>]
[(def: #export <name>
{#.doc (code.text ($_ /@compose "Only lex " <desc> " characters."))}
- (Lexer Text)
+ (Parser Text)
(range (char <bottom>) (char <top>)))]
[upper "A" "Z" "uppercase"]
@@ -185,17 +185,17 @@
(def: #export alpha
{#.doc "Only lex alphabetic characters."}
- (Lexer Text)
+ (Parser Text)
(//.either lower upper))
(def: #export alpha-num
{#.doc "Only lex alphanumeric characters."}
- (Lexer Text)
+ (Parser Text)
(//.either alpha decimal))
(def: #export hexadecimal
{#.doc "Only lex hexadecimal digits."}
- (Lexer Text)
+ (Parser Text)
($_ //.either
decimal
(range (char "a") (char "f"))
@@ -204,7 +204,7 @@
(template [<name> <description-modifier> <modifier>]
[(def: #export (<name> options)
{#.doc (code.text ($_ /@compose "Only lex characters that are" <description-modifier> " part of a piece of text."))}
- (-> Text (Lexer Text))
+ (-> Text (Parser Text))
(function (_ [offset tape])
(case (/.nth offset tape)
(#.Some output)
@@ -225,7 +225,7 @@
(template [<name> <description-modifier> <modifier>]
[(def: #export (<name> options)
{#.doc (code.text ($_ /@compose "Only lex characters that are" <description-modifier> " part of a piece of text."))}
- (-> Text (Lexer Slice))
+ (-> Text (Parser Slice))
(function (_ [offset tape])
(case (/.nth offset tape)
(#.Some output)
@@ -247,7 +247,7 @@
(def: #export (satisfies p)
{#.doc "Only lex characters that satisfy a predicate."}
- (-> (-> Nat Bit) (Lexer Text))
+ (-> (-> Nat Bit) (Parser Text))
(function (_ [offset tape])
(case (/.nth offset tape)
(#.Some output)
@@ -260,18 +260,18 @@
(def: #export space
{#.doc "Only lex white-space."}
- (Lexer Text)
+ (Parser Text)
(satisfies /.space?))
(def: #export (and left right)
- (-> (Lexer Text) (Lexer Text) (Lexer Text))
+ (-> (Parser Text) (Parser Text) (Parser Text))
(do //.monad
[=left left
=right right]
(wrap ($_ /@compose =left =right))))
(def: #export (and! left right)
- (-> (Lexer Slice) (Lexer Slice) (Lexer Slice))
+ (-> (Parser Slice) (Parser Slice) (Parser Slice))
(do //.monad
[[left::basis left::distance] left
[right::basis right::distance] right]
@@ -280,7 +280,7 @@
(template [<name> <base> <doc-modifier>]
[(def: #export (<name> lexer)
{#.doc (code.text ($_ /@compose "Lex " <doc-modifier> " characters as a single continuous text."))}
- (-> (Lexer Text) (Lexer Text))
+ (-> (Parser Text) (Parser Text))
(|> lexer <base> (:: //.monad map /.concat)))]
[some //.some "some"]
@@ -290,7 +290,7 @@
(template [<name> <base> <doc-modifier>]
[(def: #export (<name> lexer)
{#.doc (code.text ($_ /@compose "Lex " <doc-modifier> " characters as a single continuous text."))}
- (-> (Lexer Slice) (Lexer Slice))
+ (-> (Parser Slice) (Parser Slice))
(with-slices (<base> lexer)))]
[some! //.some "some"]
@@ -300,7 +300,7 @@
(template [<name> <base> <doc-modifier>]
[(def: #export (<name> amount lexer)
{#.doc (code.text ($_ /@compose "Lex " <doc-modifier> " N characters."))}
- (-> Nat (Lexer Text) (Lexer Text))
+ (-> Nat (Parser Text) (Parser Text))
(|> lexer (<base> amount) (:: //.monad map /.concat)))]
[exactly //.exactly "exactly"]
@@ -311,7 +311,7 @@
(template [<name> <base> <doc-modifier>]
[(def: #export (<name> amount lexer)
{#.doc (code.text ($_ /@compose "Lex " <doc-modifier> " N characters."))}
- (-> Nat (Lexer Slice) (Lexer Slice))
+ (-> Nat (Parser Slice) (Parser Slice))
(with-slices (<base> amount lexer)))]
[exactly! //.exactly "exactly"]
@@ -321,23 +321,23 @@
(def: #export (between from to lexer)
{#.doc "Lex between N and M characters."}
- (-> Nat Nat (Lexer Text) (Lexer Text))
+ (-> Nat Nat (Parser Text) (Parser Text))
(|> lexer (//.between from to) (:: //.monad map /.concat)))
(def: #export (between! from to lexer)
{#.doc "Lex between N and M characters."}
- (-> Nat Nat (Lexer Slice) (Lexer Slice))
+ (-> Nat Nat (Parser Slice) (Parser Slice))
(with-slices (//.between from to lexer)))
(def: #export (enclosed [start end] lexer)
- (All [a] (-> [Text Text] (Lexer a) (Lexer a)))
+ (All [a] (-> [Text Text] (Parser a) (Parser a)))
(|> lexer
(//.before (this end))
(//.after (this start))))
(def: #export (local local-input lexer)
{#.doc "Run a lexer with the given input, instead of the real one."}
- (All [a] (-> Text (Lexer a) (Lexer a)))
+ (All [a] (-> Text (Parser a) (Parser a)))
(function (_ real-input)
(case (run local-input lexer)
(#error.Failure error)
@@ -347,7 +347,7 @@
(#error.Success [real-input value]))))
(def: #export (slice lexer)
- (-> (Lexer Slice) (Lexer Text))
+ (-> (Parser Slice) (Parser Text))
(do //.monad
[[basis distance] lexer]
(function (_ (^@ input [offset tape]))
diff --git a/stdlib/source/lux/control/parser/type.lux b/stdlib/source/lux/control/parser/type.lux
index 56942e5c4..8625901af 100644
--- a/stdlib/source/lux/control/parser/type.lux
+++ b/stdlib/source/lux/control/parser/type.lux
@@ -19,7 +19,7 @@
["." code]]
["." type ("#@." equivalence)
["." check]]]
- ["." // (#+ Parser)])
+ ["." //])
(template [<name>]
[(exception: #export (<name> {type Type})
@@ -57,13 +57,13 @@
(type: #export Env
(Dictionary Nat [Type Code]))
-(type: #export (Poly a)
- (Parser [Env (List Type)] a))
+(type: #export (Parser a)
+ (//.Parser [Env (List Type)] a))
(def: #export fresh Env (dictionary.new nat.hash))
(def: (run' env types poly)
- (All [a] (-> Env (List Type) (Poly a) (Error a)))
+ (All [a] (-> Env (List Type) (Parser a) (Error a)))
(case (//.run [env types] poly)
(#error.Failure error)
(#error.Failure error)
@@ -77,16 +77,16 @@
(exception.throw unconsumed remaining))))
(def: #export (run type poly)
- (All [a] (-> Type (Poly a) (Error a)))
+ (All [a] (-> Type (Parser a) (Error a)))
(run' fresh (list type) poly))
(def: #export env
- (Poly Env)
+ (Parser Env)
(.function (_ [env inputs])
(#error.Success [[env inputs] env])))
(def: (with-env temp poly)
- (All [a] (-> Env (Poly a) (Poly a)))
+ (All [a] (-> Env (Parser a) (Parser a)))
(.function (_ [env inputs])
(case (//.run [temp inputs] poly)
(#error.Failure error)
@@ -96,7 +96,7 @@
(#error.Success [[env remaining] output]))))
(def: #export peek
- (Poly Type)
+ (Parser Type)
(.function (_ [env inputs])
(case inputs
#.Nil
@@ -106,7 +106,7 @@
(#error.Success [[env inputs] headT]))))
(def: #export any
- (Poly Type)
+ (Parser Type)
(.function (_ [env inputs])
(case inputs
#.Nil
@@ -116,7 +116,7 @@
(#error.Success [[env tail] headT]))))
(def: #export (local types poly)
- (All [a] (-> (List Type) (Poly a) (Poly a)))
+ (All [a] (-> (List Type) (Parser a) (Parser a)))
(.function (_ [env pass-through])
(case (run' env types poly)
(#error.Failure error)
@@ -130,7 +130,7 @@
(code.local-identifier ($_ text@compose "label" text.tab (nat@encode idx))))
(def: #export (with-extension type poly)
- (All [a] (-> Type (Poly a) (Poly [Code a])))
+ (All [a] (-> Type (Parser a) (Parser [Code a])))
(.function (_ [env inputs])
(let [current-id (dictionary.size env)
g!var (label current-id)]
@@ -145,7 +145,7 @@
(template [<name> <flattener> <tag> <exception>]
[(def: #export (<name> poly)
- (All [a] (-> (Poly a) (Poly a)))
+ (All [a] (-> (Parser a) (Parser a)))
(do //.monad
[headT any]
(let [members (<flattener> (type.un-name headT))]
@@ -158,7 +158,7 @@
)
(def: polymorphic'
- (Poly [Nat Type])
+ (Parser [Nat Type])
(do //.monad
[headT any
#let [[num-arg bodyT] (type.flatten-univ-q (type.un-name headT))]]
@@ -167,7 +167,7 @@
(wrap [num-arg bodyT]))))
(def: #export (polymorphic poly)
- (All [a] (-> (Poly a) (Poly [Code (List Code) a])))
+ (All [a] (-> (Parser a) (Parser [Code (List Code) a])))
(do //.monad
[headT any
funcI (:: @ map dictionary.size ..env)
@@ -204,7 +204,7 @@
(with-env env'))))
(def: #export (function in-poly out-poly)
- (All [i o] (-> (Poly i) (Poly o) (Poly [i o])))
+ (All [i o] (-> (Parser i) (Parser o) (Parser [i o])))
(do //.monad
[headT any
#let [[inputsT outputT] (type.flatten-function (type.un-name headT))]]
@@ -214,7 +214,7 @@
(//.fail (exception.construct not-function headT)))))
(def: #export (apply poly)
- (All [a] (-> (Poly a) (Poly a)))
+ (All [a] (-> (Parser a) (Parser a)))
(do //.monad
[headT any
#let [[funcT paramsT] (type.flatten-application (type.un-name headT))]]
@@ -224,7 +224,7 @@
(template [<name> <test>]
[(def: #export (<name> expected)
- (-> Type (Poly Any))
+ (-> Type (Parser Any))
(do //.monad
[actual any]
(if (<test> expected actual)
@@ -244,7 +244,7 @@
(|> env-level dec (n/- parameter-level) (n/* 2) (n/+ parameter-idx))))
(def: #export parameter
- (Poly Code)
+ (Parser Code)
(do //.monad
[env ..env
headT any]
@@ -261,7 +261,7 @@
(//.fail (exception.construct not-parameter headT)))))
(def: #export (parameter! id)
- (-> Nat (Poly Any))
+ (-> Nat (Parser Any))
(do //.monad
[env ..env
headT any]
@@ -275,7 +275,7 @@
(//.fail (exception.construct not-parameter headT)))))
(def: #export existential
- (Poly Nat)
+ (Parser Nat)
(do //.monad
[headT any]
(case headT
@@ -286,7 +286,7 @@
(//.fail (exception.construct not-existential headT)))))
(def: #export named
- (Poly [Name Type])
+ (Parser [Name Type])
(do //.monad
[inputT any]
(case inputT
@@ -297,7 +297,7 @@
(//.fail (exception.construct not-named inputT)))))
(def: #export (recursive poly)
- (All [a] (-> (Poly a) (Poly [Code a])))
+ (All [a] (-> (Parser a) (Parser [Code a])))
(do //.monad
[headT any]
(case (type.un-name headT)
@@ -313,7 +313,7 @@
(//.fail (exception.construct not-recursive headT)))))
(def: #export recursive-self
- (Poly Code)
+ (Parser Code)
(do //.monad
[env ..env
headT any]
@@ -327,7 +327,7 @@
(//.fail (exception.construct not-recursive headT)))))
(def: #export recursive-call
- (Poly Code)
+ (Parser Code)
(do //.monad
[env ..env
[funcT argsT] (apply (//.and any (//.many any)))
@@ -339,7 +339,7 @@
(wrap (` ((~+ allC))))))
(def: #export log!
- (All [a] (Poly a))
+ (All [a] (Parser a))
(do //.monad
[current any
#let [_ (.log! ($_ text@compose
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index beb5eca8d..162cf8387 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -7,8 +7,8 @@
codec]
[control
pipe
- ["p" parser (#+ Parser) ("#@." monad)
- ["l" text]]
+ ["p" parser ("#@." monad)
+ ["l" text (#+ Parser)]]
["ex" exception (#+ exception:)]]
[data
["." bit]
@@ -53,7 +53,7 @@
(type: #export (Reader a)
{#.doc "JSON reader."}
- (Parser (List JSON) a))
+ (p.Parser (List JSON) a))
(syntax: #export (json token)
{#.doc (doc "A simple way to produce JSON literals."
@@ -436,22 +436,22 @@
############################################################
(def: space~
- (l.Lexer Text)
+ (Parser Text)
(l.some l.space))
(def: data-sep
- (l.Lexer [Text Any Text])
+ (Parser [Text Any Text])
($_ p.and space~ (l.this ",") space~))
(def: null~
- (l.Lexer Null)
+ (Parser Null)
(do p.monad
[_ (l.this "null")]
(wrap [])))
(template [<name> <token> <value>]
[(def: <name>
- (l.Lexer Boolean)
+ (Parser Boolean)
(do p.monad
[_ (l.this <token>)]
(wrap <value>)))]
@@ -461,11 +461,11 @@
)
(def: boolean~
- (l.Lexer Boolean)
+ (Parser Boolean)
(p.either true~ false~))
(def: number~
- (l.Lexer Number)
+ (Parser Number)
(do p.monad
[signed? (l.this? "-")
digits (l.many l.decimal)
@@ -487,7 +487,7 @@
(wrap value))))
(def: escaped~
- (l.Lexer Text)
+ (Parser Text)
($_ p.either
(p.after (l.this "\t")
(p@wrap text.tab))
@@ -505,7 +505,7 @@
(p@wrap "\"))))
(def: string~
- (l.Lexer String)
+ (Parser String)
(<| (l.enclosed [text.double-quote text.double-quote])
(loop [_ []])
(do p.monad
@@ -519,7 +519,7 @@
(wrap chars))))
(def: (kv~ json~)
- (-> (-> Any (l.Lexer JSON)) (l.Lexer [String JSON]))
+ (-> (-> Any (Parser JSON)) (Parser [String JSON]))
(do p.monad
[key string~
_ space~
@@ -530,7 +530,7 @@
(template [<name> <type> <open> <close> <elem-parser> <prep>]
[(def: (<name> json~)
- (-> (-> Any (l.Lexer JSON)) (l.Lexer <type>))
+ (-> (-> Any (Parser JSON)) (Parser <type>))
(do p.monad
[_ (l.this <open>)
_ space~
@@ -544,7 +544,7 @@
)
(def: (json~' _)
- (-> Any (l.Lexer JSON))
+ (-> Any (Parser JSON))
($_ p.or null~ boolean~ number~ string~ (array~ json~') (object~ json~')))
(structure: #export codec (Codec Text JSON)
diff --git a/stdlib/source/lux/data/format/xml.lux b/stdlib/source/lux/data/format/xml.lux
index 29a77c0df..515243f6b 100644
--- a/stdlib/source/lux/data/format/xml.lux
+++ b/stdlib/source/lux/data/format/xml.lux
@@ -6,7 +6,7 @@
codec]
[control
["p" parser ("#;." monad)
- ["l" text]]
+ ["l" text (#+ Parser)]]
["ex" exception (#+ exception:)]]
[data
["." error (#+ Error)]
@@ -29,7 +29,7 @@
(#Node Tag Attrs (List XML)))
(def: xml-standard-escape-char^
- (l.Lexer Text)
+ (Parser Text)
($_ p.either
(p.after (l.this "&lt;") (p;wrap "<"))
(p.after (l.this "&gt;") (p;wrap ">"))
@@ -38,7 +38,7 @@
(p.after (l.this "&quot;") (p;wrap text.double-quote))))
(def: xml-unicode-escape-char^
- (l.Lexer Text)
+ (Parser Text)
(|> (do p.monad
[hex? (p.maybe (l.this "x"))
code (case hex?
@@ -52,17 +52,17 @@
(p.after (l.this "&#"))))
(def: xml-escape-char^
- (l.Lexer Text)
+ (Parser Text)
(p.either xml-standard-escape-char^
xml-unicode-escape-char^))
(def: xml-char^
- (l.Lexer Text)
+ (Parser Text)
(p.either (l.none-of ($_ text;compose "<>&'" text.double-quote))
xml-escape-char^))
(def: xml-identifier
- (l.Lexer Text)
+ (Parser Text)
(do p.monad
[head (p.either (l.one-of "_")
l.alpha)
@@ -71,7 +71,7 @@
(wrap ($_ text;compose head tail))))
(def: namespaced-symbol^
- (l.Lexer Name)
+ (Parser Name)
(do p.monad
[first-part xml-identifier
?second-part (<| p.maybe (p.after (l.this ":")) xml-identifier)]
@@ -86,19 +86,19 @@
(def: attr-name^ namespaced-symbol^)
(def: spaced^
- (All [a] (-> (l.Lexer a) (l.Lexer a)))
+ (All [a] (-> (Parser a) (Parser a)))
(let [white-space^ (p.some l.space)]
(|>> (p.before white-space^)
(p.after white-space^))))
(def: attr-value^
- (l.Lexer Text)
+ (Parser Text)
(let [value^ (l.some xml-char^)]
(p.either (l.enclosed [text.double-quote text.double-quote] value^)
(l.enclosed ["'" "'"] value^))))
(def: attrs^
- (l.Lexer Attrs)
+ (Parser Attrs)
(<| (:: p.monad map (d.from-list name.hash))
p.some
(p.and (spaced^ attr-name^))
@@ -106,7 +106,7 @@
(spaced^ attr-value^)))
(def: (close-tag^ expected)
- (-> Tag (l.Lexer []))
+ (-> Tag (Parser []))
(do p.monad
[actual (|> tag^
spaced^
@@ -118,21 +118,21 @@
(name;= expected actual))))
(def: comment^
- (l.Lexer Text)
+ (Parser Text)
(|> (l.not (l.this "--"))
l.some
(l.enclosed ["<--" "-->"])
spaced^))
(def: xml-header^
- (l.Lexer Attrs)
+ (Parser Attrs)
(|> (spaced^ attrs^)
(p.before (l.this "?>"))
(p.after (l.this "<?xml"))
spaced^))
(def: cdata^
- (l.Lexer Text)
+ (Parser Text)
(let [end (l.this "]]>")]
(|> (l.some (l.not end))
(p.after end)
@@ -140,13 +140,13 @@
spaced^)))
(def: text^
- (l.Lexer XML)
+ (Parser XML)
(|> (p.either cdata^
(l.many xml-char^))
(p;map (|>> #Text))))
(def: xml^
- (l.Lexer XML)
+ (Parser XML)
(|> (p.rec
(function (_ node^)
(p.either text^
diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux
index ad648677d..b18fdfe0e 100644
--- a/stdlib/source/lux/data/text/regex.lux
+++ b/stdlib/source/lux/data/text/regex.lux
@@ -4,7 +4,7 @@
monad]
[control
["p" parser ("#@." monad)
- ["l" text]]]
+ ["l" text (#+ Parser)]]]
[data
["." product]
["." error]
@@ -20,11 +20,11 @@
format])
(def: regex-char^
- (l.Lexer Text)
+ (Parser Text)
(l.none-of "\.|&()[]{}"))
(def: escaped-char^
- (l.Lexer Text)
+ (Parser Text)
(do p.monad
[? (l.this? "\")]
(if ?
@@ -32,33 +32,33 @@
regex-char^)))
(def: (refine^ refinement^ base^)
- (All [a] (-> (l.Lexer a) (l.Lexer Text) (l.Lexer Text)))
+ (All [a] (-> (Parser a) (Parser Text) (Parser Text)))
(do p.monad
[output base^
_ (l.local output refinement^)]
(wrap output)))
(def: word^
- (l.Lexer Text)
+ (Parser Text)
(p.either l.alpha-num
(l.one-of "_")))
(def: (copy reference)
- (-> Text (l.Lexer Text))
+ (-> Text (Parser Text))
(p.after (l.this reference) (p@wrap reference)))
(def: (join-text^ part^)
- (-> (l.Lexer (List Text)) (l.Lexer Text))
+ (-> (Parser (List Text)) (Parser Text))
(do p.monad
[parts part^]
(wrap (//.join-with "" parts))))
(def: name-char^
- (l.Lexer Text)
+ (Parser Text)
(l.none-of (format "[]{}()s#.<>" //.double-quote)))
(def: name-part^
- (l.Lexer Text)
+ (Parser Text)
(do p.monad
[head (refine^ (l.not l.decimal)
name-char^)
@@ -66,7 +66,7 @@
(wrap (format head tail))))
(def: (name^ current-module)
- (-> Text (l.Lexer Name))
+ (-> Text (Parser Name))
($_ p.either
(p.and (p@wrap current-module) (p.after (l.this "..") name-part^))
(p.and name-part^ (p.after (l.this ".") name-part^))
@@ -74,13 +74,13 @@
(p.and (p@wrap "") name-part^)))
(def: (re-var^ current-module)
- (-> Text (l.Lexer Code))
+ (-> Text (Parser Code))
(do p.monad
[name (l.enclosed ["\@<" ">"] (name^ current-module))]
- (wrap (` (: (l.Lexer Text) (~ (code.identifier name)))))))
+ (wrap (` (: (Parser Text) (~ (code.identifier name)))))))
(def: re-range^
- (l.Lexer Code)
+ (Parser Code)
(do p.monad
[from (|> regex-char^ (:: @ map (|>> (//.nth 0) maybe.assume)))
_ (l.this "-")
@@ -88,19 +88,19 @@
(wrap (` (l.range (~ (code.nat from)) (~ (code.nat to)))))))
(def: re-char^
- (l.Lexer Code)
+ (Parser Code)
(do p.monad
[char escaped-char^]
(wrap (` ((~! ..copy) (~ (code.text char)))))))
(def: re-options^
- (l.Lexer Code)
+ (Parser Code)
(do p.monad
[options (l.many escaped-char^)]
(wrap (` (l.one-of (~ (code.text options)))))))
(def: re-user-class^'
- (l.Lexer Code)
+ (Parser Code)
(do p.monad
[negate? (p.maybe (l.this "^"))
parts (p.many ($_ p.either
@@ -111,7 +111,7 @@
#.None (` ($_ p.either (~+ parts)))))))
(def: re-user-class^
- (l.Lexer Code)
+ (Parser Code)
(do p.monad
[_ (wrap [])
init re-user-class^'
@@ -122,34 +122,34 @@
rest))))
(def: blank^
- (l.Lexer Text)
+ (Parser Text)
(l.one-of (format " " //.tab)))
(def: ascii^
- (l.Lexer Text)
+ (Parser Text)
(l.range (hex "0") (hex "7F")))
(def: control^
- (l.Lexer Text)
+ (Parser Text)
(p.either (l.range (hex "0") (hex "1F"))
(l.one-of (//.from-code (hex "7F")))))
(def: punct^
- (l.Lexer Text)
+ (Parser Text)
(l.one-of (format "!#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
//.double-quote)))
(def: graph^
- (l.Lexer Text)
+ (Parser Text)
(p.either punct^ l.alpha-num))
(def: print^
- (l.Lexer Text)
+ (Parser Text)
(p.either graph^
(l.one-of (//.from-code (hex "20")))))
(def: re-system-class^
- (l.Lexer Code)
+ (Parser Code)
(do p.monad
[]
($_ p.either
@@ -178,17 +178,17 @@
)))
(def: re-class^
- (l.Lexer Code)
+ (Parser Code)
(p.either re-system-class^
(l.enclosed ["[" "]"] re-user-class^)))
(def: number^
- (l.Lexer Nat)
+ (Parser Nat)
(|> (l.many l.decimal)
(p.codec nat.decimal)))
(def: re-back-reference^
- (l.Lexer Code)
+ (Parser Code)
(p.either (do p.monad
[_ (l.this "\")
id number^]
@@ -200,7 +200,7 @@
(wrap (` ((~! ..copy) (~ (code.identifier ["" captured-name]))))))))
(def: (re-simple^ current-module)
- (-> Text (l.Lexer Code))
+ (-> Text (Parser Code))
($_ p.either
re-class^
(re-var^ current-module)
@@ -209,7 +209,7 @@
))
(def: (re-simple-quantified^ current-module)
- (-> Text (l.Lexer Code))
+ (-> Text (Parser Code))
(do p.monad
[base (re-simple^ current-module)
quantifier (l.one-of "?*+")]
@@ -226,7 +226,7 @@
)))
(def: (re-counted-quantified^ current-module)
- (-> Text (l.Lexer Code))
+ (-> Text (Parser Code))
(do p.monad
[base (re-simple^ current-module)]
(l.enclosed ["{" "}"]
@@ -247,12 +247,12 @@
(wrap (` ((~! join-text^) (p.exactly (~ (code.nat limit)) (~ base))))))))))
(def: (re-quantified^ current-module)
- (-> Text (l.Lexer Code))
+ (-> Text (Parser Code))
(p.either (re-simple-quantified^ current-module)
(re-counted-quantified^ current-module)))
(def: (re-complex^ current-module)
- (-> Text (l.Lexer Code))
+ (-> Text (Parser Code))
($_ p.either
(re-quantified^ current-module)
(re-simple^ current-module)))
@@ -263,9 +263,9 @@
(def: (re-sequential^ capturing? re-scoped^ current-module)
(-> Bit
- (-> Text (l.Lexer [Re-Group Code]))
+ (-> Text (Parser [Re-Group Code]))
Text
- (l.Lexer [Nat Code]))
+ (Parser [Nat Code]))
(do p.monad
[parts (p.many (p.or (re-complex^ current-module)
(re-scoped^ current-module)))
@@ -313,11 +313,11 @@
))
(def: (unflatten^ lexer)
- (-> (l.Lexer Text) (l.Lexer [Text Any]))
+ (-> (Parser Text) (Parser [Text Any]))
(p.and lexer (:: p.monad wrap [])))
(def: (|||^ left right)
- (All [l r] (-> (l.Lexer [Text l]) (l.Lexer [Text r]) (l.Lexer [Text (| l r)])))
+ (All [l r] (-> (Parser [Text l]) (Parser [Text r]) (Parser [Text (| l r)])))
(function (_ input)
(case (left input)
(#error.Success [input' [lt lv]])
@@ -332,7 +332,7 @@
(#error.Failure error)))))
(def: (|||_^ left right)
- (All [l r] (-> (l.Lexer [Text l]) (l.Lexer [Text r]) (l.Lexer Text)))
+ (All [l r] (-> (Parser [Text l]) (Parser [Text r]) (Parser Text)))
(function (_ input)
(case (left input)
(#error.Success [input' [lt lv]])
@@ -354,9 +354,9 @@
(def: (re-alternative^ capturing? re-scoped^ current-module)
(-> Bit
- (-> Text (l.Lexer [Re-Group Code]))
+ (-> Text (Parser [Re-Group Code]))
Text
- (l.Lexer [Nat Code]))
+ (Parser [Nat Code]))
(do p.monad
[#let [sub^ (re-sequential^ capturing? re-scoped^ current-module)]
head sub^
@@ -371,7 +371,7 @@
(~+ (list@map prep-alternative tail))))]))))
(def: (re-scoped^ current-module)
- (-> Text (l.Lexer [Re-Group Code]))
+ (-> Text (Parser [Re-Group Code]))
($_ p.either
(do p.monad
[_ (l.this "(?:")
@@ -395,7 +395,7 @@
(wrap [(#Capturing [#.None num-captures]) pattern]))))
(def: (regex^ current-module)
- (-> Text (l.Lexer Code))
+ (-> Text (Parser Code))
(:: p.monad map product.right (re-alternative^ #1 re-scoped^ current-module)))
(syntax: #export (regex {pattern s.text})
diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux
index 4a2d44e38..4ae02b8a3 100644
--- a/stdlib/source/lux/macro/poly/functor.lux
+++ b/stdlib/source/lux/macro/poly/functor.lux
@@ -36,7 +36,7 @@
(let [paramsC (|> num-vars dec list.indices (list;map (|>> %n code.local-identifier)))]
(` (All [(~+ paramsC)]
((~! functor.Functor) ((~ (poly.to-code *env* unwrappedT)) (~+ paramsC)))))))))
- Arg<?> (: (-> Code (<type>.Poly Code))
+ Arg<?> (: (-> Code (<type>.Parser Code))
(function (Arg<?> valueC)
($_ p.either
## Type-var
@@ -55,7 +55,7 @@
(list.enumerate membersC))))))))
## Tuples
(do p.monad
- [pairsCC (: (<type>.Poly (List [Code Code]))
+ [pairsCC (: (<type>.Parser (List [Code Code]))
(<type>.tuple (loop [idx 0
pairsCC (: (List [Code Code])
(list))]
@@ -91,7 +91,7 @@
[_ <type>.any]
(wrap valueC))
)))]
- [_ _ outputC] (: (<type>.Poly [Code (List Code) Code])
+ [_ _ outputC] (: (<type>.Parser [Code (List Code) Code])
(p.either (<type>.polymorphic
(Arg<?> inputC))
(p.fail (format "Cannot create Functor for: " (%type inputT)))))]
diff --git a/stdlib/source/lux/math/modular.lux b/stdlib/source/lux/math/modular.lux
index 07fa14c3d..a6b905360 100644
--- a/stdlib/source/lux/math/modular.lux
+++ b/stdlib/source/lux/math/modular.lux
@@ -6,7 +6,7 @@
[control
["ex" exception (#+ exception:)]
["p" parser
- ["l" text (#+ Lexer)]]]
+ ["l" text (#+ Parser)]]]
[data
["." error (#+ Error)]
[number
@@ -63,7 +63,7 @@
(p.fail error)))
(def: intL
- (Lexer Int)
+ (Parser Int)
(p.codec int.decimal
(l.and (l.one-of "-+") (l.many l.decimal))))
diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux
index 383988c14..3a1df14c1 100644
--- a/stdlib/source/lux/time/date.lux
+++ b/stdlib/source/lux/time/date.lux
@@ -8,7 +8,7 @@
[monad (#+ do)]]
[control
["p" parser ("#@." functor)
- ["l" text]]]
+ ["l" text (#+ Parser)]]]
[data
["." error (#+ Error)]
["." maybe]
@@ -73,7 +73,7 @@
(pad (|> day .inc .int))))
(def: lex-year
- (l.Lexer Int)
+ (Parser Int)
(do p.monad
[sign (p.maybe (l.this "-"))
raw-year (p.codec nat.decimal (l.many l.decimal))
@@ -86,7 +86,7 @@
(wrap (i/* signum (.int raw-year)))))
(def: lex-section
- (l.Lexer Int)
+ (Parser Int)
(p@map .int (p.codec nat.decimal (l.exactly 2 l.decimal))))
(def: (leap-years year)
@@ -118,7 +118,7 @@
## Based on: https://stackoverflow.com/a/3309340/6823464
(def: lex-date
- (l.Lexer Date)
+ (Parser Date)
(do p.monad
[utc-year lex-year
_ (l.this "-")
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index fcde19a3f..2b4d10394 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -9,7 +9,7 @@
[control
[io (#+ IO io)]
["p" parser
- ["l" text]]]
+ ["l" text (#+ Parser)]]]
[data
["." error (#+ Error)]
["." maybe]
@@ -216,7 +216,7 @@
## Codec::decode
(def: lex-year
- (l.Lexer Int)
+ (Parser Int)
(do p.monad
[sign (p.or (l.this "-") (l.this "+"))
raw-year (p.codec int.decimal (l.many l.decimal))
@@ -226,11 +226,11 @@
(wrap (i/* signum raw-year))))
(def: lex-section
- (l.Lexer Int)
+ (Parser Int)
(p.codec int.decimal (l.exactly 2 l.decimal)))
(def: lex-millis
- (l.Lexer Int)
+ (Parser Int)
(p.either (|> (l.at-most 3 l.decimal)
(p.codec int.decimal)
(p.after (l.this ".")))
@@ -244,7 +244,7 @@
## Based on: https://stackoverflow.com/a/3309340/6823464
## (def: lex-instant
-## (l.Lexer Instant)
+## (Parser Instant)
## (do p.monad
## [utc-year lex-year
## _ (l.this "-")
diff --git a/stdlib/source/lux/tool/interpreter/type.lux b/stdlib/source/lux/tool/interpreter/type.lux
index 19f94af1b..b9d4ebb5b 100644
--- a/stdlib/source/lux/tool/interpreter/type.lux
+++ b/stdlib/source/lux/tool/interpreter/type.lux
@@ -3,7 +3,8 @@
[control
[monad (#+ do)]
["ex" exception (#+ exception:)]
- ["p" parser]
+ ["p" parser
+ ["<.>" type (#+ Parser)]]
pipe]
[data
["." error (#+ Error)]
@@ -22,7 +23,7 @@
["." type]
["." macro
["." code]
- ["." poly (#+ Poly)]]])
+ ["." poly]]])
(exception: #export (cannot-represent-value {type Type})
(ex.report ["Type" (%type type)]))
@@ -30,7 +31,7 @@
(type: Representation (-> Any Text))
(def: primitive-representation
- (Poly Representation)
+ (Parser Representation)
(`` ($_ p.either
(do p.monad
[_ (poly.exactly Any)]
@@ -49,7 +50,7 @@
[Text %t])))))
(def: (special-representation representation)
- (-> (Poly Representation) (Poly Representation))
+ (-> (Parser Representation) (Parser Representation))
(`` ($_ p.either
(~~ (template [<type> <formatter>]
[(do p.monad
@@ -80,7 +81,7 @@
(format "(#.Some " (elemR elemV) ")"))))))))
(def: (record-representation tags representation)
- (-> (List Name) (Poly Representation) (Poly Representation))
+ (-> (List Name) (Parser Representation) (Parser Representation))
(do p.monad
[membersR+ (poly.tuple (p.many representation))
_ (p.assert "Number of tags does not match record type size."
@@ -102,7 +103,7 @@
(format "{" record-body "}"))))))
(def: (variant-representation tags representation)
- (-> (List Name) (Poly Representation) (Poly Representation))
+ (-> (List Name) (Parser Representation) (Parser Representation))
(do p.monad
[casesR+ (poly.variant (p.many representation))
#let [num-tags (list.size tags)]
@@ -130,7 +131,7 @@
(recur tail variantV)))))))))
(def: (tagged-representation compiler representation)
- (-> Lux (Poly Representation) (Poly Representation))
+ (-> Lux (Parser Representation) (Parser Representation))
(do p.monad
[[name anonymous] poly.named]
(case (macro.run compiler (macro.tags-of name))
@@ -148,7 +149,7 @@
(p.fail error))))
(def: (tuple-representation representation)
- (-> (Poly Representation) (Poly Representation))
+ (-> (Parser Representation) (Parser Representation))
(do p.monad
[membersR+ (poly.tuple (p.many representation))]
(wrap (function (_ tupleV)
@@ -167,7 +168,7 @@
(format "[" tuple-body "]"))))))
(def: (representation compiler)
- (-> Lux (Poly Representation))
+ (-> Lux (Parser Representation))
(p.rec
(function (_ representation)
($_ p.either
diff --git a/stdlib/source/lux/world/net/http/cookie.lux b/stdlib/source/lux/world/net/http/cookie.lux
index 174231251..d2899d106 100644
--- a/stdlib/source/lux/world/net/http/cookie.lux
+++ b/stdlib/source/lux/world/net/http/cookie.lux
@@ -3,7 +3,7 @@
[control
[monad (#+ do)]
["p" parser ("#;." monad)
- ["l" text (#+ Lexer)]]]
+ ["l" text (#+ Parser)]]]
[data
["." error (#+ Error)]
[text
@@ -64,7 +64,7 @@
#Lax "Lax"))))
(def: (cookie context)
- (-> Context (Lexer Context))
+ (-> Context (Parser Context))
(do p.monad
[key (l.slice (l.many! (l.none-of! "=")))
_ (l.this "=")
@@ -72,7 +72,7 @@
(wrap (dictionary.put key value context))))
(def: (cookies context)
- (-> Context (Lexer Context))
+ (-> Context (Parser Context))
($_ p.either
(do p.monad
[context' (..cookie context)
diff --git a/stdlib/source/lux/world/net/http/query.lux b/stdlib/source/lux/world/net/http/query.lux
index 8b0379108..516c67ff8 100644
--- a/stdlib/source/lux/world/net/http/query.lux
+++ b/stdlib/source/lux/world/net/http/query.lux
@@ -4,7 +4,7 @@
pipe
[monad (#+ do)]
["p" parser
- ["l" text (#+ Lexer)]]]
+ ["l" text (#+ Parser)]]]
[data
["." error (#+ Error)]
[number
@@ -17,7 +17,7 @@
["." dictionary]]]])
(def: component
- (Lexer Text)
+ (Parser Text)
(p.rec
(function (_ component)
(do p.monad
@@ -39,7 +39,7 @@
(wrap (format head code tail))))))))
(def: (form context)
- (-> Context (Lexer Context))
+ (-> Context (Parser Context))
($_ p.either
(do p.monad
[_ l.end]
diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux
index 3693b0fd0..1686bb27c 100644
--- a/stdlib/source/test/lux/control/parser/text.lux
+++ b/stdlib/source/test/lux/control/parser/text.lux
@@ -1,6 +1,8 @@
(.module:
[lux #*
- data/text/format
+ [data
+ text/format
+ ["." name]]
["_" test (#+ Test)]
[abstract/monad (#+ do)]
[control
@@ -33,7 +35,7 @@
(def: #export test
Test
- (<| (_.context (%name (name-of /.Lexer)))
+ (<| (_.context (name.module (name-of /._)))
($_ _.and
(_.test "Can detect the end of the input."
(|> (/.run ""
diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux
index eeec23d2f..f456aac73 100644
--- a/stdlib/source/test/lux/data/text/regex.lux
+++ b/stdlib/source/test/lux/data/text/regex.lux
@@ -6,7 +6,7 @@
[control
pipe
["p" parser
- ["<.>" text (#+ Lexer)]]]
+ ["<.>" text (#+ Parser)]]]
[data
[number (#+ hex)]
["." error]
@@ -19,7 +19,7 @@
["." /]})
(def: (should-pass regex input)
- (-> (Lexer Text) Text Bit)
+ (-> (Parser Text) Text Bit)
(|> (<text>.run input regex)
(case> (#error.Success parsed)
(text@= parsed input)
@@ -28,7 +28,7 @@
#0)))
(def: (text-should-pass test regex input)
- (-> Text (Lexer Text) Text Bit)
+ (-> Text (Parser Text) Text Bit)
(|> (<text>.run input regex)
(case> (#error.Success parsed)
(text@= test parsed)
@@ -37,7 +37,7 @@
false)))
(def: (should-fail regex input)
- (All [a] (-> (Lexer a) Text Bit))
+ (All [a] (-> (Parser a) Text Bit))
(|> (<text>.run input regex)
(case> (#error.Failure _)
true