aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2022-06-27 03:26:33 -0400
committerEduardo Julian2022-06-27 03:26:33 -0400
commit149515fd173947dcff20558fca077fbd16dc9b6c (patch)
tree3271f60268a35a132391b857b9f7985f75cbfcd8 /stdlib/source
parent3265f6a71723c100559eaea188d3762ceedce3b9 (diff)
New "parser" hierarchy. [Part 5]
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/documentation/lux/target.lux15
-rw-r--r--stdlib/source/documentation/lux/target/js.lux2
-rw-r--r--stdlib/source/documentation/lux/target/jvm.lux2
-rw-r--r--stdlib/source/documentation/lux/target/jvm/type.lux2
-rw-r--r--stdlib/source/documentation/lux/target/jvm/type/alias.lux2
-rw-r--r--stdlib/source/documentation/lux/target/jvm/type/box.lux2
-rw-r--r--stdlib/source/documentation/lux/target/jvm/type/category.lux2
-rw-r--r--stdlib/source/documentation/lux/target/jvm/type/descriptor.lux2
-rw-r--r--stdlib/source/documentation/lux/target/jvm/type/lux.lux2
-rw-r--r--stdlib/source/documentation/lux/target/jvm/type/parser.lux2
-rw-r--r--stdlib/source/documentation/lux/target/jvm/type/reflection.lux2
-rw-r--r--stdlib/source/documentation/lux/target/jvm/type/signature.lux2
-rw-r--r--stdlib/source/documentation/lux/target/lua.lux2
-rw-r--r--stdlib/source/documentation/lux/target/python.lux2
-rw-r--r--stdlib/source/documentation/lux/target/ruby.lux2
-rw-r--r--stdlib/source/documentation/lux/time.lux103
-rw-r--r--stdlib/source/documentation/lux/time/date.lux31
-rw-r--r--stdlib/source/documentation/lux/time/day.lux20
-rw-r--r--stdlib/source/documentation/lux/time/duration.lux22
-rw-r--r--stdlib/source/documentation/lux/time/instant.lux81
-rw-r--r--stdlib/source/documentation/lux/time/month.lux38
-rw-r--r--stdlib/source/documentation/lux/time/year.lux58
-rw-r--r--stdlib/source/library/lux/program.lux18
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cli.lux29
-rw-r--r--stdlib/source/parser/lux/data/collection/tree.lux (renamed from stdlib/source/library/lux/control/parser/tree.lux)11
-rw-r--r--stdlib/source/parser/lux/program.lux (renamed from stdlib/source/library/lux/control/parser/cli.lux)4
-rw-r--r--stdlib/source/test/lux/control/parser.lux6
-rw-r--r--stdlib/source/test/lux/control/parser/cli.lux86
-rw-r--r--stdlib/source/test/lux/control/parser/tree.lux178
-rw-r--r--stdlib/source/test/lux/data/collection/tree.lux168
-rw-r--r--stdlib/source/test/lux/program.lux162
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/cli.lux15
32 files changed, 503 insertions, 570 deletions
diff --git a/stdlib/source/documentation/lux/target.lux b/stdlib/source/documentation/lux/target.lux
index 306876f18..70ba24c62 100644
--- a/stdlib/source/documentation/lux/target.lux
+++ b/stdlib/source/documentation/lux/target.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
@@ -16,16 +16,11 @@
["[1][0]" python]
["[1][0]" ruby]])
-(documentation: /.Target
- (format "The name/ID of a platform targetted by a Lux compiler."
- \n "This information can be used to generate code targetting specific platforms, and to make programs cross-platform."))
-
(.def .public documentation
(.List $.Module)
($.module /._
""
- [..Target
- ($.default /.old)
+ [($.default /.old)
($.default /.js)
($.default /.jvm)
($.default /.lua)
@@ -34,7 +29,11 @@
($.default /.common_lisp)
($.default /.php)
($.default /.r)
- ($.default /.scheme)]
+ ($.default /.scheme)
+
+ ($.documentation /.Target
+ (format "The name/ID of a platform targetted by a Lux compiler."
+ \n "This information can be used to generate code targetting specific platforms, and to make programs cross-platform."))]
[/js.documentation
/jvm.documentation
/lua.documentation
diff --git a/stdlib/source/documentation/lux/target/js.lux b/stdlib/source/documentation/lux/target/js.lux
index 864a5e2c7..68f67d560 100644
--- a/stdlib/source/documentation/lux/target/js.lux
+++ b/stdlib/source/documentation/lux/target/js.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/jvm.lux b/stdlib/source/documentation/lux/target/jvm.lux
index 85ec6ea01..440ef5775 100644
--- a/stdlib/source/documentation/lux/target/jvm.lux
+++ b/stdlib/source/documentation/lux/target/jvm.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/jvm/type.lux b/stdlib/source/documentation/lux/target/jvm/type.lux
index 902683d16..39bded852 100644
--- a/stdlib/source/documentation/lux/target/jvm/type.lux
+++ b/stdlib/source/documentation/lux/target/jvm/type.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/jvm/type/alias.lux b/stdlib/source/documentation/lux/target/jvm/type/alias.lux
index 3af9a8997..d8e17f39a 100644
--- a/stdlib/source/documentation/lux/target/jvm/type/alias.lux
+++ b/stdlib/source/documentation/lux/target/jvm/type/alias.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/jvm/type/box.lux b/stdlib/source/documentation/lux/target/jvm/type/box.lux
index 04ddd5a9d..1f393eb2e 100644
--- a/stdlib/source/documentation/lux/target/jvm/type/box.lux
+++ b/stdlib/source/documentation/lux/target/jvm/type/box.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/jvm/type/category.lux b/stdlib/source/documentation/lux/target/jvm/type/category.lux
index 1b17ca5a7..123041fcb 100644
--- a/stdlib/source/documentation/lux/target/jvm/type/category.lux
+++ b/stdlib/source/documentation/lux/target/jvm/type/category.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/jvm/type/descriptor.lux b/stdlib/source/documentation/lux/target/jvm/type/descriptor.lux
index 9eaa79e17..8a484151c 100644
--- a/stdlib/source/documentation/lux/target/jvm/type/descriptor.lux
+++ b/stdlib/source/documentation/lux/target/jvm/type/descriptor.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/jvm/type/lux.lux b/stdlib/source/documentation/lux/target/jvm/type/lux.lux
index 0b09556dc..408b5c6f4 100644
--- a/stdlib/source/documentation/lux/target/jvm/type/lux.lux
+++ b/stdlib/source/documentation/lux/target/jvm/type/lux.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/jvm/type/parser.lux b/stdlib/source/documentation/lux/target/jvm/type/parser.lux
index afd3515f2..81e9d4bee 100644
--- a/stdlib/source/documentation/lux/target/jvm/type/parser.lux
+++ b/stdlib/source/documentation/lux/target/jvm/type/parser.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/jvm/type/reflection.lux b/stdlib/source/documentation/lux/target/jvm/type/reflection.lux
index 4cd2327ee..64ecb135c 100644
--- a/stdlib/source/documentation/lux/target/jvm/type/reflection.lux
+++ b/stdlib/source/documentation/lux/target/jvm/type/reflection.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/jvm/type/signature.lux b/stdlib/source/documentation/lux/target/jvm/type/signature.lux
index dd2234c90..8991f34ee 100644
--- a/stdlib/source/documentation/lux/target/jvm/type/signature.lux
+++ b/stdlib/source/documentation/lux/target/jvm/type/signature.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except char)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/lua.lux b/stdlib/source/documentation/lux/target/lua.lux
index 651d70c7b..dbbd515a5 100644
--- a/stdlib/source/documentation/lux/target/lua.lux
+++ b/stdlib/source/documentation/lux/target/lua.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/python.lux b/stdlib/source/documentation/lux/target/python.lux
index 69bec7b7e..c531707ae 100644
--- a/stdlib/source/documentation/lux/target/python.lux
+++ b/stdlib/source/documentation/lux/target/python.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/target/ruby.lux b/stdlib/source/documentation/lux/target/ruby.lux
index bddc34acc..a678fe81b 100644
--- a/stdlib/source/documentation/lux/target/ruby.lux
+++ b/stdlib/source/documentation/lux/target/ruby.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]
diff --git a/stdlib/source/documentation/lux/time.lux b/stdlib/source/documentation/lux/time.lux
index 1b0b5ac6c..3041638d5 100644
--- a/stdlib/source/documentation/lux/time.lux
+++ b/stdlib/source/documentation/lux/time.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except and)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
["[0]" text (.only \n)
["%" \\format (.only format)]]]
@@ -17,68 +17,57 @@
["[1][0]" month]
["[1][0]" year]])
-(with_template [<name> <doc>]
- [(documentation: <name>
- <doc>)]
+(`` (.def .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [($.default /.time_exceeds_a_day)
+ ($.default /.invalid_hour)
+ ($.default /.invalid_minute)
+ ($.default /.invalid_second)
+ ($.default /.millis)
+ ($.default /.equivalence)
+ ($.default /.order)
+ ($.default /.enum)
+ ($.default /.parser)
- [/.milli_seconds "Number of milli-seconds in a second."]
- [/.seconds "Number of seconds in a minute."]
- [/.minutes "Number of minutes in an hour."]
- [/.hours "Number of hours in an day."]
- )
+ (~~ (with_template [<name> <doc>]
+ [($.documentation <name>
+ <doc>)]
-(documentation: /.Time
- "Time is defined as milliseconds since the start of the day (00:00:00.000).")
+ [/.milli_seconds "Number of milli-seconds in a second."]
+ [/.seconds "Number of seconds in a minute."]
+ [/.minutes "Number of minutes in an hour."]
+ [/.hours "Number of hours in an day."]
+ ))
-(documentation: /.midnight
- "The instant corresponding to the start of the day: 00:00:00.000")
+ ($.documentation /.Time
+ "Time is defined as milliseconds since the start of the day (00:00:00.000).")
-(documentation: /.of_millis
- ""
- [(of_millis milli_seconds)])
+ ($.documentation /.midnight
+ "The instant corresponding to the start of the day: 00:00:00.000")
-(documentation: /.Clock
- "A clock marking the specific hour, minute, second, and milli-second in a day.")
+ ($.documentation /.of_millis
+ ""
+ [(of_millis milli_seconds)])
-(documentation: /.clock
- ""
- [(clock time)])
+ ($.documentation /.Clock
+ "A clock marking the specific hour, minute, second, and milli-second in a day.")
-(documentation: /.time
- ""
- [(time clock)])
+ ($.documentation /.clock
+ ""
+ [(clock time)])
-(documentation: /.codec
- (format "Based on ISO 8601."
- \n "For example: 21:14:51.827"))
+ ($.documentation /.time
+ ""
+ [(time clock)])
-(.def .public documentation
- (.List $.Module)
- ($.module /._
- ""
- [..milli_seconds
- ..seconds
- ..minutes
- ..hours
- ..Time
- ..midnight
- ..of_millis
- ..Clock
- ..clock
- ..time
- ..codec
- ($.default /.time_exceeds_a_day)
- ($.default /.invalid_hour)
- ($.default /.invalid_minute)
- ($.default /.invalid_second)
- ($.default /.millis)
- ($.default /.equivalence)
- ($.default /.order)
- ($.default /.enum)
- ($.default /.parser)]
- [/date.documentation
- /day.documentation
- /duration.documentation
- /instant.documentation
- /month.documentation
- /year.documentation]))
+ ($.documentation /.codec
+ (format "Based on ISO 8601."
+ \n "For example: 21:14:51.827"))]
+ [/date.documentation
+ /day.documentation
+ /duration.documentation
+ /instant.documentation
+ /month.documentation
+ /year.documentation])))
diff --git a/stdlib/source/documentation/lux/time/date.lux b/stdlib/source/documentation/lux/time/date.lux
index 818371741..15bfdafbb 100644
--- a/stdlib/source/documentation/lux/time/date.lux
+++ b/stdlib/source/documentation/lux/time/date.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except and)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
["[0]" text (.only \n)
["%" \\format (.only format)]]]
@@ -10,25 +10,11 @@
[\\library
["[0]" /]])
-(documentation: /.Date
- "A date specified as a year/month/day triplet.")
-
-(documentation: /.date
- "A date, within the allowed limits."
- [(date year month day_of_month)])
-
-(documentation: /.codec
- (format "Based on ISO 8601."
- \n "For example: 2017-01-15"))
-
(.def .public documentation
(.List $.Module)
($.module /._
""
- [..Date
- ..date
- ..codec
- ($.default /.invalid_day)
+ [($.default /.invalid_day)
($.default /.epoch)
($.default /.year)
($.default /.month)
@@ -39,5 +25,16 @@
($.default /.parser)
($.default /.days)
($.default /.of_days)
- ($.default /.enum)]
+ ($.default /.enum)
+
+ ($.documentation /.Date
+ "A date specified as a year/month/day triplet.")
+
+ ($.documentation /.date
+ "A date, within the allowed limits."
+ [(date year month day_of_month)])
+
+ ($.documentation /.codec
+ (format "Based on ISO 8601."
+ \n "For example: 2017-01-15"))]
[]))
diff --git a/stdlib/source/documentation/lux/time/day.lux b/stdlib/source/documentation/lux/time/day.lux
index 5cd046493..29db3b570 100644
--- a/stdlib/source/documentation/lux/time/day.lux
+++ b/stdlib/source/documentation/lux/time/day.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except and)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
["[0]" text (.only \n)
["%" \\format (.only format)]]]
@@ -10,19 +10,11 @@
[\\library
["[0]" /]])
-(documentation: /.Day
- "A day of the week.")
-
-(documentation: /.week
- "All the days, ordered by when they come in a week.")
-
(.def .public documentation
(.List $.Module)
($.module /._
""
- [..Day
- ..week
- ($.default /.equivalence)
+ [($.default /.equivalence)
($.default /.order)
($.default /.enum)
($.default /.not_a_day_of_the_week)
@@ -30,5 +22,11 @@
($.default /.number)
($.default /.invalid_day)
($.default /.by_number)
- ($.default /.hash)]
+ ($.default /.hash)
+
+ ($.documentation /.Day
+ "A day of the week.")
+
+ ($.documentation /.week
+ "All the days, ordered by when they come in a week.")]
[]))
diff --git a/stdlib/source/documentation/lux/time/duration.lux b/stdlib/source/documentation/lux/time/duration.lux
index 448ea46eb..1340f3460 100644
--- a/stdlib/source/documentation/lux/time/duration.lux
+++ b/stdlib/source/documentation/lux/time/duration.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except and)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
["[0]" text (.only \n)
["%" \\format (.only format)]]]
@@ -10,20 +10,11 @@
[\\library
["[0]" /]])
-(documentation: /.Duration
- "Durations have a resolution of milli-seconds.")
-
-(documentation: /.difference
- ""
- [(difference from to)])
-
(.def .public documentation
(.List $.Module)
($.module /._
""
- [..Duration
- ..difference
- ($.default /.of_millis)
+ [($.default /.of_millis)
($.default /.millis)
($.default /.composite)
($.default /.framed)
@@ -47,5 +38,12 @@
($.default /.leap_year)
($.default /.monoid)
($.default /.codec)
- ($.default /.enum)]
+ ($.default /.enum)
+
+ ($.documentation /.Duration
+ "Durations have a resolution of milli-seconds.")
+
+ ($.documentation /.difference
+ ""
+ [(difference from to)])]
[]))
diff --git a/stdlib/source/documentation/lux/time/instant.lux b/stdlib/source/documentation/lux/time/instant.lux
index 9eb35f53d..b40489b5c 100644
--- a/stdlib/source/documentation/lux/time/instant.lux
+++ b/stdlib/source/documentation/lux/time/instant.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except and)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
["[0]" text (.only \n)
["%" \\format (.only format)]]]
@@ -10,58 +10,49 @@
[\\library
["[0]" /]])
-(documentation: /.Instant
- "Instant is defined as milli-seconds since the epoch.")
-
-(documentation: /.span
- ""
- [(span from to)])
-
-(documentation: /.after
- ""
- [(after duration instant)])
-
-(documentation: /.relative
- ""
- [(relative instant)])
-
-(documentation: /.absolute
- ""
- [(absolute offset)])
-
-(documentation: /.epoch
- "The instant corresponding to 1970-01-01T00:00:00Z.")
-
-(documentation: /.codec
- (format "Based on ISO 8601."
- \n "For example: 2017-01-15T21:14:51.827Z"))
-
-(documentation: /.now
- "Yields the current instant, as measured from the operating-system's clock.")
-
-(documentation: /.of_date_time
- ""
- [(of_date_time date time)])
-
(.def .public documentation
(.List $.Module)
($.module /._
""
- [..Instant
- ..span
- ..after
- ..relative
- ..absolute
- ..epoch
- ..codec
- ..now
- ..of_date_time
- ($.default /.of_millis)
+ [($.default /.of_millis)
($.default /.millis)
($.default /.equivalence)
($.default /.order)
($.default /.enum)
($.default /.date)
($.default /.time)
- ($.default /.day_of_week)]
+ ($.default /.day_of_week)
+
+ ($.documentation /.Instant
+ "Instant is defined as milli-seconds since the epoch.")
+
+ ($.documentation /.span
+ ""
+ [(span from to)])
+
+ ($.documentation /.after
+ ""
+ [(after duration instant)])
+
+ ($.documentation /.relative
+ ""
+ [(relative instant)])
+
+ ($.documentation /.absolute
+ ""
+ [(absolute offset)])
+
+ ($.documentation /.epoch
+ "The instant corresponding to 1970-01-01T00:00:00Z.")
+
+ ($.documentation /.codec
+ (format "Based on ISO 8601."
+ \n "For example: 2017-01-15T21:14:51.827Z"))
+
+ ($.documentation /.now
+ "Yields the current instant, as measured from the operating-system's clock.")
+
+ ($.documentation /.of_date_time
+ ""
+ [(of_date_time date time)])]
[]))
diff --git a/stdlib/source/documentation/lux/time/month.lux b/stdlib/source/documentation/lux/time/month.lux
index ccd31a8c4..05103ec1f 100644
--- a/stdlib/source/documentation/lux/time/month.lux
+++ b/stdlib/source/documentation/lux/time/month.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except and)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
["[0]" text (.only \n)
["%" \\format (.only format)]]]
@@ -10,29 +10,11 @@
[\\library
["[0]" /]])
-(documentation: /.Month
- "A month of the year.")
-
-(documentation: /.days
- "The amount of days of a month."
- [(days month)])
-
-(documentation: /.leap_year_days
- "The amount of days of a month (in a leap year)."
- [(leap_year_days month)])
-
-(documentation: /.year
- "All the months, ordered by when they come in a year.")
-
(.def .public documentation
(.List $.Module)
($.module /._
""
- [..Month
- ..days
- ..leap_year_days
- ..year
- ($.default /.equivalence)
+ [($.default /.equivalence)
($.default /.number)
($.default /.invalid_month)
($.default /.by_number)
@@ -40,5 +22,19 @@
($.default /.order)
($.default /.enum)
($.default /.not_a_month_of_the_year)
- ($.default /.codec)]
+ ($.default /.codec)
+
+ ($.documentation /.Month
+ "A month of the year.")
+
+ ($.documentation /.days
+ "The amount of days of a month."
+ [(days month)])
+
+ ($.documentation /.leap_year_days
+ "The amount of days of a month (in a leap year)."
+ [(leap_year_days month)])
+
+ ($.documentation /.year
+ "All the months, ordered by when they come in a year.")]
[]))
diff --git a/stdlib/source/documentation/lux/time/year.lux b/stdlib/source/documentation/lux/time/year.lux
index b8dc23837..85341eb24 100644
--- a/stdlib/source/documentation/lux/time/year.lux
+++ b/stdlib/source/documentation/lux/time/year.lux
@@ -1,7 +1,7 @@
(.require
[library
[lux (.except and)
- ["$" documentation (.only documentation:)]
+ ["$" documentation]
[data
["[0]" text (.only \n)
["%" \\format (.only format)]]]
@@ -10,40 +10,11 @@
[\\library
["[0]" /]])
-(documentation: /.Year
- (format "A year in the gregorian calendar."
- \n "Both negative (< 0) and positive (> 0) values are valid, but not 0."
- \n "This is because the first year of the gregorian calendar was year 1."))
-
-(documentation: /.year
- "A valid year in the gregorian calendar, if possible."
- [(year value)])
-
-(documentation: /.days
- "The amount of days in a typical year.")
-
-(documentation: /.Period
- "An amount of years.")
-
-(documentation: /.leaps
- "The number of leap years in a period of years."
- [(leaps year)])
-
-(documentation: /.codec
- (format "Based on ISO 8601."
- \n "For example: 2017"))
-
(.def .public documentation
(.List $.Module)
($.module /._
""
- [..Year
- ..year
- ..days
- ..Period
- ..leaps
- ..codec
- ($.default /.there_is_no_year_0)
+ [($.default /.there_is_no_year_0)
($.default /.value)
($.default /.epoch)
($.default /.leap)
@@ -52,5 +23,28 @@
($.default /.leap?)
($.default /.parser)
($.default /.equivalence)
- ($.default /.order)]
+ ($.default /.order)
+
+ ($.documentation /.Year
+ (format "A year in the gregorian calendar."
+ \n "Both negative (< 0) and positive (> 0) values are valid, but not 0."
+ \n "This is because the first year of the gregorian calendar was year 1."))
+
+ ($.documentation /.year
+ "A valid year in the gregorian calendar, if possible."
+ [(year value)])
+
+ ($.documentation /.days
+ "The amount of days in a typical year.")
+
+ ($.documentation /.Period
+ "An amount of years.")
+
+ ($.documentation /.leaps
+ "The number of leap years in a period of years."
+ [(leaps year)])
+
+ ($.documentation /.codec
+ (format "Based on ISO 8601."
+ \n "For example: 2017"))]
[]))
diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux
index 99fb1832e..81b455cb1 100644
--- a/stdlib/source/library/lux/program.lux
+++ b/stdlib/source/library/lux/program.lux
@@ -5,15 +5,15 @@
[abstract
[monad (.only do)]]
[control
+ ["<>" parser]
["[0]" io]
[concurrency
- ["[0]" thread]]
- ["<>" parser (.only)
- ["<[0]>" cli]]]
+ ["[0]" thread]]]
[macro (.only with_symbols)
[syntax (.only syntax)]
["[0]" code (.only)
- ["<[1]>" \\parser]]]]])
+ ["<[1]>" \\parser]]]]]
+ ["</>" \\parser])
(type Arguments
(Variant
@@ -46,11 +46,11 @@
{#Parsed args}
(` (.function ((~ g!program) (~ g!args))
- (case ((~! <cli>.result) (.is (~! (<cli>.Parser (io.IO .Any)))
- ((~! do) (~! <>.monad)
- [(~+ args)
- (~ g!_) (~! <cli>.end)]
- ((~' in) (~ initialization+event_loop))))
+ (case ((~! </>.result) (.is (~! (</>.Parser (io.IO .Any)))
+ ((~! do) (~! <>.monad)
+ [(~+ args)
+ (~ g!_) (~! </>.end)]
+ ((~' in) (~ initialization+event_loop))))
(~ g!args))
{.#Right (~ g!output)}
(~ g!output)
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cli.lux b/stdlib/source/library/lux/tool/compiler/meta/cli.lux
index 685467d32..caeb07961 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/cli.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/cli.lux
@@ -5,9 +5,8 @@
[monad (.only do)]
[equivalence (.only Equivalence)]]
[control
- ["[0]" pipe]
- ["<>" parser (.only)
- ["<[0]>" cli (.only Parser)]]]
+ ["<>" parser]
+ ["[0]" pipe]]
[data
["[0]" product]
["[0]" text (.only)
@@ -22,6 +21,8 @@
[meta
["[0]" symbol]
["[0]" configuration (.only Configuration)]]
+ ["[0]" program
+ ["<[1]>" \\parser (.only Parser)]]
[tool
[compiler
[meta
@@ -73,15 +74,15 @@
(with_template [<name> <long> <type> <parser>]
[(def <name>
(Parser <type>)
- (<cli>.named <long> <parser>))]
+ (<program>.named <long> <parser>))]
- [host_dependency_parser "--host_dependency" Host_Dependency <cli>.any]
- [library_parser "--library" Library <cli>.any]
- [compiler_parser "--compiler" Compiler (<text>.then /compiler.parser <cli>.any)]
- [source_parser "--source" Source <cli>.any]
- [target_parser "--target" Target <cli>.any]
- [module_parser "--module" Module <cli>.any]
- [configuration_parser "--configuration" Configuration (<text>.then configuration.parser <cli>.any)]
+ [host_dependency_parser "--host_dependency" Host_Dependency <program>.any]
+ [library_parser "--library" Library <program>.any]
+ [compiler_parser "--compiler" Compiler (<text>.then /compiler.parser <program>.any)]
+ [source_parser "--source" Source <program>.any]
+ [target_parser "--target" Target <program>.any]
+ [module_parser "--module" Module <program>.any]
+ [configuration_parser "--configuration" Configuration (<text>.then configuration.parser <program>.any)]
)
(def .public service
@@ -96,11 +97,11 @@
..module_parser
(<>.else configuration.empty ..configuration_parser)))]
(all <>.or
- (<>.after (<cli>.this "build")
+ (<>.after (<program>.this "build")
compilation)
- (<>.after (<cli>.this "repl")
+ (<>.after (<program>.this "repl")
compilation)
- (<>.after (<cli>.this "export")
+ (<>.after (<program>.this "export")
(all <>.and
(<>.some ..source_parser)
..target_parser))
diff --git a/stdlib/source/library/lux/control/parser/tree.lux b/stdlib/source/parser/lux/data/collection/tree.lux
index e94e8a96c..5d10ce15b 100644
--- a/stdlib/source/library/lux/control/parser/tree.lux
+++ b/stdlib/source/parser/lux/data/collection/tree.lux
@@ -4,13 +4,12 @@
[abstract
[monad (.only do)]]
[control
+ ["//" parser]
["[0]" try (.only Try)]
- ["[0]" exception (.only exception)]]
- [data
- [collection
- [tree (.only Tree)
- ["[0]" zipper (.only Zipper)]]]]]]
- ["[0]" //])
+ ["[0]" exception (.only exception)]]]]
+ [\\library
+ [/ (.only Tree)
+ ["[0]" zipper (.only Zipper)]]])
(type .public (Parser t a)
(//.Parser (Zipper t) a))
diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/parser/lux/program.lux
index 694cb93fc..e834136d8 100644
--- a/stdlib/source/library/lux/control/parser/cli.lux
+++ b/stdlib/source/parser/lux/program.lux
@@ -4,11 +4,11 @@
[abstract
[monad (.only do)]]
[control
+ ["//" parser]
["[0]" try (.only Try)]]
[data
["[0]" text (.use "[1]#[0]" equivalence)
- ["%" \\format (.only format)]]]]]
- ["[0]" //])
+ ["%" \\format (.only format)]]]]])
(type .public (Parser a)
(//.Parser (List Text) a))
diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux
index e977e9df3..624999201 100644
--- a/stdlib/source/test/lux/control/parser.lux
+++ b/stdlib/source/test/lux/control/parser.lux
@@ -27,9 +27,7 @@
[\\library
["[0]" / (.only Parser)]]
["[0]" /
- ["[1][0]" cli]
- ["[1][0]" environment]
- ["[1][0]" tree]])
+ ["[1][0]" environment]])
(def (should_fail expected input)
(All (_ a) (-> Text (Try a) Bit))
@@ -377,7 +375,5 @@
..combinators_1
..combinators_2
- /cli.test
/environment.test
- /tree.test
))))
diff --git a/stdlib/source/test/lux/control/parser/cli.lux b/stdlib/source/test/lux/control/parser/cli.lux
deleted file mode 100644
index 46f04712c..000000000
--- a/stdlib/source/test/lux/control/parser/cli.lux
+++ /dev/null
@@ -1,86 +0,0 @@
-(.require
- [library
- [lux (.except)
- ["_" test (.only Test)]
- [abstract
- [monad (.only do)]]
- [control
- ["[0]" try]
- ["<>" parser]]
- [data
- ["[0]" text (.use "[1]#[0]" equivalence)]
- [collection
- ["[0]" list]]]
- [macro
- ["^" pattern]]
- [math
- ["[0]" random]
- [number
- ["n" nat (.use "[1]#[0]" decimal)]]]]]
- [\\library
- ["[0]" /]])
-
-(def !expect
- (template (_ <pattern> <value>)
- [(case <value>
- <pattern>
- true
-
- _
- false)]))
-
-(def .public test
- Test
- (<| (_.covering /._)
- (_.for [/.Parser])
- (do [! random.monad]
- [expected (at ! each n#encoded random.nat)
- .let [random_dummy (random.only (|>> (text#= expected) not)
- (random.unicode 5))]
- dummy random_dummy
- short (random.unicode 1)
- long (random.unicode 2)
- pre_ignore (random.list 5 random_dummy)
- post_ignore (random.list 5 random_dummy)]
- (all _.and
- (_.coverage [/.result /.any]
- (|> (/.result /.any (list expected))
- (!expect (^.multi {try.#Success actual}
- (text#= expected actual)))))
- (_.coverage [/.parse]
- (|> (/.result (/.parse n#decoded) (list expected))
- (!expect (^.multi {try.#Success actual}
- (text#= expected
- (n#encoded actual))))))
- (_.coverage [/.this]
- (and (|> (/.result (/.this expected) (list expected))
- (!expect {try.#Success _}))
- (|> (/.result (/.this expected) (list dummy))
- (!expect {try.#Failure _}))))
- (_.coverage [/.somewhere]
- (|> (/.result (|> (/.somewhere (/.this expected))
- (<>.before (<>.some /.any)))
- (list.together (list pre_ignore (list expected) post_ignore)))
- (!expect {try.#Success _})))
- (_.coverage [/.end]
- (and (|> (/.result /.end (list))
- (!expect {try.#Success _}))
- (|> (/.result (<>.not /.end) (list expected))
- (!expect {try.#Failure _}))))
- (_.coverage [/.named]
- (|> (/.result (/.named dummy /.any) (list dummy expected))
- (!expect (^.multi {try.#Success actual}
- (text#= expected actual)))))
- (_.coverage [/.parameter]
- (and (|> (/.result (/.parameter [short long] /.any)
- (list short expected))
- (!expect (^.multi {try.#Success actual}
- (text#= expected actual))))
- (|> (/.result (/.parameter [short long] /.any)
- (list long expected))
- (!expect (^.multi {try.#Success actual}
- (text#= expected actual))))
- (|> (/.result (/.parameter [short long] /.any)
- (list dummy expected))
- (!expect {try.#Failure _}))))
- ))))
diff --git a/stdlib/source/test/lux/control/parser/tree.lux b/stdlib/source/test/lux/control/parser/tree.lux
deleted file mode 100644
index 9ac82705e..000000000
--- a/stdlib/source/test/lux/control/parser/tree.lux
+++ /dev/null
@@ -1,178 +0,0 @@
-(.require
- [library
- [lux (.except)
- ["_" test (.only Test)]
- [abstract
- [monad (.only do)]]
- [control
- ["[0]" try]
- ["[0]" exception]]
- [data
- [collection
- ["[0]" tree (.only)
- ["[0]" zipper]]]]
- [macro
- ["^" pattern]]
- [math
- ["[0]" random]
- [number
- ["n" nat]]]]]
- [\\library
- ["[0]" / (.only)
- ["/[1]" //]]])
-
-(def !expect
- (template (_ <pattern> <value>)
- [(case <value>
- <pattern>
- true
-
- _
- false)]))
-
-(def !cover
- (template (_ <coverage> <parser> <sample>)
- [(do [! random.monad]
- [dummy random.nat
- expected (|> random.nat (random.only (|>> (n.= dummy) not)))]
- (_.coverage <coverage>
- (|> (/.result <parser>
- <sample>)
- (!expect (^.multi {try.#Success actual}
- (n.= expected actual))))))]))
-
-(def !cover/2
- (template (_ <coverage> <parser> <sample0> <sample1>)
- [(do [! random.monad]
- [dummy random.nat
- expected (|> random.nat (random.only (|>> (n.= dummy) not)))]
- (_.coverage <coverage>
- (and (|> (/.result <parser> <sample0>)
- (!expect (^.multi {try.#Success actual}
- (n.= expected actual))))
- (|> (/.result <parser> <sample1>)
- (!expect (^.multi {try.#Success actual}
- (n.= expected actual)))))))]))
-
-(def .public test
- Test
- (<| (_.covering /._)
- (_.for [/.Parser])
- (all _.and
- (!cover [/.result /.value]
- /.value
- (tree.leaf expected))
- (do [! random.monad]
- [expected random.nat]
- (_.coverage [/.result']
- (|> (/.result' /.value
- (zipper.zipper (tree.leaf expected)))
- (!expect (^.multi {try.#Success actual}
- (n.= expected actual))))))
- (!cover [/.down]
- (do //.monad
- [_ /.down]
- /.value)
- (tree.branch dummy
- (list (tree.leaf expected))))
- (!cover [/.up]
- (do //.monad
- [_ /.down
- _ /.up]
- /.value)
- (tree.branch expected
- (list (tree.leaf dummy))))
- (!cover [/.right]
- (do //.monad
- [_ /.down
- _ /.right]
- /.value)
- (tree.branch dummy
- (list (tree.leaf dummy)
- (tree.leaf expected))))
- (!cover [/.left]
- (do //.monad
- [_ /.down
- _ /.right
- _ /.left]
- /.value)
- (tree.branch dummy
- (list (tree.leaf expected)
- (tree.leaf dummy))))
- (!cover [/.rightmost]
- (do //.monad
- [_ /.down
- _ /.rightmost]
- /.value)
- (tree.branch dummy
- (list (tree.leaf dummy)
- (tree.leaf dummy)
- (tree.leaf expected))))
- (!cover [/.leftmost]
- (do //.monad
- [_ /.down
- _ /.rightmost
- _ /.leftmost]
- /.value)
- (tree.branch dummy
- (list (tree.leaf expected)
- (tree.leaf dummy)
- (tree.leaf dummy))))
- (!cover/2 [/.next]
- (do //.monad
- [_ /.next
- _ /.next]
- /.value)
- (tree.branch dummy
- (list (tree.branch dummy
- (list (tree.leaf expected)))))
- (tree.branch dummy
- (list (tree.leaf dummy)
- (tree.leaf expected))))
- (!cover/2 [/.previous]
- (do //.monad
- [_ /.next
- _ /.next
- _ /.previous]
- /.value)
- (tree.branch dummy
- (list (tree.branch expected
- (list (tree.leaf dummy)))))
- (tree.branch dummy
- (list (tree.leaf expected)
- (tree.leaf dummy))))
- (!cover/2 [/.end]
- (do //.monad
- [_ /.end]
- /.value)
- (tree.branch dummy
- (list (tree.branch dummy
- (list (tree.leaf expected)))))
- (tree.branch dummy
- (list (tree.leaf dummy)
- (tree.leaf expected))))
- (!cover/2 [/.start]
- (do //.monad
- [_ /.end
- _ /.start]
- /.value)
- (tree.branch expected
- (list (tree.branch dummy
- (list (tree.leaf dummy)))))
- (tree.branch expected
- (list (tree.leaf dummy)
- (tree.leaf dummy))))
- (do [! random.monad]
- [dummy random.nat]
- (_.coverage [/.cannot_move_further]
- (`` (and (~~ (with_template [<parser>]
- [(|> (/.result <parser>
- (tree.leaf dummy))
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.cannot_move_further error))))]
-
- [/.down] [/.up]
- [/.right] [/.left]
- [/.next] [/.previous]
- ))))))
- )))
diff --git a/stdlib/source/test/lux/data/collection/tree.lux b/stdlib/source/test/lux/data/collection/tree.lux
index 6e5c5fde7..f03c2725f 100644
--- a/stdlib/source/test/lux/data/collection/tree.lux
+++ b/stdlib/source/test/lux/data/collection/tree.lux
@@ -8,16 +8,180 @@
["$[0]" equivalence]
["$[0]" mix]
["$[0]" functor]]]
+ [control
+ ["//" parser]
+ ["[0]" try]
+ ["[0]" exception]]
[data
["[0]" product]
[collection
["[0]" list (.use "[1]#[0]" functor mix)]]]
+ [macro
+ ["^" pattern]]
[math
["[0]" random (.only Random)]
[number
["n" nat]]]]]
+ ["[0]" \\parser]
[\\library
- ["[0]" / (.only Tree)]])
+ ["[0]" / (.only Tree)
+ ["[0]" zipper]]])
+
+(def !expect
+ (template (_ <pattern> <value>)
+ [(case <value>
+ <pattern>
+ true
+
+ _
+ false)]))
+
+(def !cover
+ (template (_ <coverage> <parser> <sample>)
+ [(do [! random.monad]
+ [dummy random.nat
+ expected (|> random.nat (random.only (|>> (n.= dummy) not)))]
+ (_.coverage <coverage>
+ (|> (\\parser.result <parser>
+ <sample>)
+ (!expect (^.multi {try.#Success actual}
+ (n.= expected actual))))))]))
+
+(def !cover/2
+ (template (_ <coverage> <parser> <sample0> <sample1>)
+ [(do [! random.monad]
+ [dummy random.nat
+ expected (|> random.nat (random.only (|>> (n.= dummy) not)))]
+ (_.coverage <coverage>
+ (and (|> (\\parser.result <parser> <sample0>)
+ (!expect (^.multi {try.#Success actual}
+ (n.= expected actual))))
+ (|> (\\parser.result <parser> <sample1>)
+ (!expect (^.multi {try.#Success actual}
+ (n.= expected actual)))))))]))
+
+(def \\parser
+ Test
+ (<| (_.covering \\parser._)
+ (_.for [\\parser.Parser])
+ (all _.and
+ (!cover [\\parser.result \\parser.value]
+ \\parser.value
+ (/.leaf expected))
+ (do [! random.monad]
+ [expected random.nat]
+ (_.coverage [\\parser.result']
+ (|> (\\parser.result' \\parser.value
+ (zipper.zipper (/.leaf expected)))
+ (!expect (^.multi {try.#Success actual}
+ (n.= expected actual))))))
+ (!cover [\\parser.down]
+ (do //.monad
+ [_ \\parser.down]
+ \\parser.value)
+ (/.branch dummy
+ (list (/.leaf expected))))
+ (!cover [\\parser.up]
+ (do //.monad
+ [_ \\parser.down
+ _ \\parser.up]
+ \\parser.value)
+ (/.branch expected
+ (list (/.leaf dummy))))
+ (!cover [\\parser.right]
+ (do //.monad
+ [_ \\parser.down
+ _ \\parser.right]
+ \\parser.value)
+ (/.branch dummy
+ (list (/.leaf dummy)
+ (/.leaf expected))))
+ (!cover [\\parser.left]
+ (do //.monad
+ [_ \\parser.down
+ _ \\parser.right
+ _ \\parser.left]
+ \\parser.value)
+ (/.branch dummy
+ (list (/.leaf expected)
+ (/.leaf dummy))))
+ (!cover [\\parser.rightmost]
+ (do //.monad
+ [_ \\parser.down
+ _ \\parser.rightmost]
+ \\parser.value)
+ (/.branch dummy
+ (list (/.leaf dummy)
+ (/.leaf dummy)
+ (/.leaf expected))))
+ (!cover [\\parser.leftmost]
+ (do //.monad
+ [_ \\parser.down
+ _ \\parser.rightmost
+ _ \\parser.leftmost]
+ \\parser.value)
+ (/.branch dummy
+ (list (/.leaf expected)
+ (/.leaf dummy)
+ (/.leaf dummy))))
+ (!cover/2 [\\parser.next]
+ (do //.monad
+ [_ \\parser.next
+ _ \\parser.next]
+ \\parser.value)
+ (/.branch dummy
+ (list (/.branch dummy
+ (list (/.leaf expected)))))
+ (/.branch dummy
+ (list (/.leaf dummy)
+ (/.leaf expected))))
+ (!cover/2 [\\parser.previous]
+ (do //.monad
+ [_ \\parser.next
+ _ \\parser.next
+ _ \\parser.previous]
+ \\parser.value)
+ (/.branch dummy
+ (list (/.branch expected
+ (list (/.leaf dummy)))))
+ (/.branch dummy
+ (list (/.leaf expected)
+ (/.leaf dummy))))
+ (!cover/2 [\\parser.end]
+ (do //.monad
+ [_ \\parser.end]
+ \\parser.value)
+ (/.branch dummy
+ (list (/.branch dummy
+ (list (/.leaf expected)))))
+ (/.branch dummy
+ (list (/.leaf dummy)
+ (/.leaf expected))))
+ (!cover/2 [\\parser.start]
+ (do //.monad
+ [_ \\parser.end
+ _ \\parser.start]
+ \\parser.value)
+ (/.branch expected
+ (list (/.branch dummy
+ (list (/.leaf dummy)))))
+ (/.branch expected
+ (list (/.leaf dummy)
+ (/.leaf dummy))))
+ (do [! random.monad]
+ [dummy random.nat]
+ (_.coverage [\\parser.cannot_move_further]
+ (`` (and (~~ (with_template [<parser>]
+ [(|> (\\parser.result <parser>
+ (/.leaf dummy))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.cannot_move_further error))))]
+
+ [\\parser.down] [\\parser.up]
+ [\\parser.right] [\\parser.left]
+ [\\parser.next] [\\parser.previous]
+ ))))))
+ )))
(def .public (tree gen_value)
(All (_ a) (-> (Random a) (Random [Nat (Tree a)])))
@@ -88,4 +252,6 @@
expected/2 {expected/3 {}
expected/4 {expected/5 {}}}})))
)))
+
+ ..\\parser
)))
diff --git a/stdlib/source/test/lux/program.lux b/stdlib/source/test/lux/program.lux
index 6b462da5e..8d534dd6e 100644
--- a/stdlib/source/test/lux/program.lux
+++ b/stdlib/source/test/lux/program.lux
@@ -5,23 +5,91 @@
[abstract
[monad (.only do)]]
[control
+ ["<>" parser]
["[0]" io]
- ["[0]" try]
- ["<>" parser (.only)
- ["<[0]>" cli]]]
+ ["[0]" try]]
[data
- ["[0]" text]
+ ["[0]" text (.use "[1]#[0]" equivalence)]
[collection
["[0]" list]]]
[macro
[syntax (.only syntax)]
+ ["^" pattern]
["[0]" code
["<[1]>" \\parser]]]
[math
- ["[0]" random]]]]
+ ["[0]" random]
+ [number
+ ["n" nat (.use "[1]#[0]" decimal)]]]]]
+ ["[0]" \\parser]
[\\library
["[0]" /]])
+(def !expect
+ (template (_ <pattern> <value>)
+ [(case <value>
+ <pattern>
+ true
+
+ _
+ false)]))
+
+(def \\parser
+ Test
+ (<| (_.covering \\parser._)
+ (_.for [\\parser.Parser])
+ (do [! random.monad]
+ [expected (at ! each n#encoded random.nat)
+ .let [random_dummy (random.only (|>> (text#= expected) not)
+ (random.unicode 5))]
+ dummy random_dummy
+ short (random.unicode 1)
+ long (random.unicode 2)
+ pre_ignore (random.list 5 random_dummy)
+ post_ignore (random.list 5 random_dummy)]
+ (all _.and
+ (_.coverage [\\parser.result \\parser.any]
+ (|> (\\parser.result \\parser.any (list expected))
+ (!expect (^.multi {try.#Success actual}
+ (text#= expected actual)))))
+ (_.coverage [\\parser.parse]
+ (|> (\\parser.result (\\parser.parse n#decoded) (list expected))
+ (!expect (^.multi {try.#Success actual}
+ (text#= expected
+ (n#encoded actual))))))
+ (_.coverage [\\parser.this]
+ (and (|> (\\parser.result (\\parser.this expected) (list expected))
+ (!expect {try.#Success _}))
+ (|> (\\parser.result (\\parser.this expected) (list dummy))
+ (!expect {try.#Failure _}))))
+ (_.coverage [\\parser.somewhere]
+ (|> (\\parser.result (|> (\\parser.somewhere (\\parser.this expected))
+ (<>.before (<>.some \\parser.any)))
+ (list.together (list pre_ignore (list expected) post_ignore)))
+ (!expect {try.#Success _})))
+ (_.coverage [\\parser.end]
+ (and (|> (\\parser.result \\parser.end (list))
+ (!expect {try.#Success _}))
+ (|> (\\parser.result (<>.not \\parser.end) (list expected))
+ (!expect {try.#Failure _}))))
+ (_.coverage [\\parser.named]
+ (|> (\\parser.result (\\parser.named dummy \\parser.any) (list dummy expected))
+ (!expect (^.multi {try.#Success actual}
+ (text#= expected actual)))))
+ (_.coverage [\\parser.parameter]
+ (and (|> (\\parser.result (\\parser.parameter [short long] \\parser.any)
+ (list short expected))
+ (!expect (^.multi {try.#Success actual}
+ (text#= expected actual))))
+ (|> (\\parser.result (\\parser.parameter [short long] \\parser.any)
+ (list long expected))
+ (!expect (^.multi {try.#Success actual}
+ (text#= expected actual))))
+ (|> (\\parser.result (\\parser.parameter [short long] \\parser.any)
+ (list dummy expected))
+ (!expect {try.#Failure _}))))
+ ))))
+
(def actual_program
(syntax (_ [actual_program (<| <code>.form
(<>.after (<code>.this_text "lux def program"))
@@ -33,43 +101,47 @@
(<| (_.covering /._)
(do random.monad
[inputs (random.list 5 (random.upper_case 5))]
- (_.coverage [/.program:]
- (let [(open "list#[0]") (list.equivalence text.equivalence)]
- (and (with_expansions [<program> (/.program: all_arguments
- (io.io all_arguments))]
- (let [outcome ((is (-> (List Text) (io.IO Any))
- (..actual_program <program>))
- inputs)]
- (same? (is Any inputs)
- (io.run! outcome))))
- (with_expansions [<program> (/.program: [arg/0 <cli>.any
- arg/1 <cli>.any
- arg/2 <cli>.any
- arg/3 <cli>.any
- arg/4 <cli>.any]
- (io.io (list arg/4 arg/3 arg/2 arg/1 arg/0)))]
- (let [outcome ((is (-> (List Text) (io.IO Any))
- (..actual_program <program>))
- inputs)]
- (list#= (list.reversed inputs)
- (as (List Text) (io.run! outcome)))))
- (with_expansions [<program> (/.program: [all_arguments (<>.many <cli>.any)]
- (io.io all_arguments))]
- (let [outcome ((is (-> (List Text) (io.IO Any))
- (..actual_program <program>))
- inputs)]
- (list#= inputs
- (as (List Text) (io.run! outcome)))))
- (with_expansions [<program> (/.program: [arg/0 <cli>.any
- arg/1 <cli>.any
- arg/2 <cli>.any
- arg/3 <cli>.any]
- (io.io []))]
- (case (try ((is (-> (List Text) (io.IO Any))
- (..actual_program <program>))
- inputs))
- {try.#Success _}
- false
-
- {try.#Failure _}
- true))))))))
+ (all _.and
+ (_.coverage [/.program:]
+ (let [(open "list#[0]") (list.equivalence text.equivalence)]
+ (and (with_expansions [<program> (/.program: all_arguments
+ (io.io all_arguments))]
+ (let [outcome ((is (-> (List Text) (io.IO Any))
+ (..actual_program <program>))
+ inputs)]
+ (same? (is Any inputs)
+ (io.run! outcome))))
+ (with_expansions [<program> (/.program: [arg/0 \\parser.any
+ arg/1 \\parser.any
+ arg/2 \\parser.any
+ arg/3 \\parser.any
+ arg/4 \\parser.any]
+ (io.io (list arg/4 arg/3 arg/2 arg/1 arg/0)))]
+ (let [outcome ((is (-> (List Text) (io.IO Any))
+ (..actual_program <program>))
+ inputs)]
+ (list#= (list.reversed inputs)
+ (as (List Text) (io.run! outcome)))))
+ (with_expansions [<program> (/.program: [all_arguments (<>.many \\parser.any)]
+ (io.io all_arguments))]
+ (let [outcome ((is (-> (List Text) (io.IO Any))
+ (..actual_program <program>))
+ inputs)]
+ (list#= inputs
+ (as (List Text) (io.run! outcome)))))
+ (with_expansions [<program> (/.program: [arg/0 \\parser.any
+ arg/1 \\parser.any
+ arg/2 \\parser.any
+ arg/3 \\parser.any]
+ (io.io []))]
+ (case (try ((is (-> (List Text) (io.IO Any))
+ (..actual_program <program>))
+ inputs))
+ {try.#Success _}
+ false
+
+ {try.#Failure _}
+ true)))))
+
+ ..\\parser
+ ))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli.lux b/stdlib/source/test/lux/tool/compiler/meta/cli.lux
index fe630e128..dcf28757f 100644
--- a/stdlib/source/test/lux/tool/compiler/meta/cli.lux
+++ b/stdlib/source/test/lux/tool/compiler/meta/cli.lux
@@ -5,10 +5,9 @@
[abstract
[monad (.only do)]]
[control
+ ["<>" parser]
["[0]" pipe]
- ["[0]" try (.use "[1]#[0]" functor)]
- ["<>" parser (.only)
- ["<[0]>" cli]]]
+ ["[0]" try (.use "[1]#[0]" functor)]]
[data
["[0]" product]
["[0]" text]
@@ -20,7 +19,9 @@
["n" nat]]]
[meta
["[0]" configuration (.use "[1]#[0]" equivalence)
- ["$[1]" \\test]]]]]
+ ["$[1]" \\test]]]
+ ["[0]" program
+ ["<[1]>" \\parser]]]]
[\\library
["[0]" / (.only)
["[1][0]" compiler (.only Compiler)]]]
@@ -58,7 +59,7 @@
(~~ (with_template [<type> <slot> <?>]
[(_.coverage [<type>]
(|> (list.partial "build" compilation')
- (<cli>.result /.service)
+ (<program>.result /.service)
(try#each (|>> (pipe.case
{/.#Compilation it}
(|> it
@@ -81,7 +82,7 @@
(_.coverage [/.Interpretation]
(`` (and (~~ (with_template [<slot> <?>]
[(|> (list.partial "repl" compilation')
- (<cli>.result /.service)
+ (<program>.result /.service)
(try#each (|>> (pipe.case
{/.#Interpretation it}
(|> it
@@ -103,7 +104,7 @@
(_.coverage [/.Export]
(`` (and (~~ (with_template [<side> <?>]
[(|> (list.partial "export" export)
- (<cli>.result /.service)
+ (<program>.result /.service)
(try#each (|>> (pipe.case
{/.#Export it}
(|> it