aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/parser.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/program/aedifex/parser.lux')
-rw-r--r--stdlib/source/program/aedifex/parser.lux140
1 files changed, 140 insertions, 0 deletions
diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux
new file mode 100644
index 000000000..f3bdbe34f
--- /dev/null
+++ b/stdlib/source/program/aedifex/parser.lux
@@ -0,0 +1,140 @@
+(.module:
+ [lux (#- type)
+ [abstract
+ [monad (#+ do)]]
+ [control
+ ["<>" parser
+ ["<c>" code (#+ Parser)]]]
+ [data
+ ["." text]]
+ [world
+ [net (#+ URL)]]]
+ [//
+ ["/" project]
+ ["//." dependency]])
+
+(def: group
+ (Parser /.Group)
+ <c>.text)
+
+(def: name
+ (Parser /.Name)
+ <c>.text)
+
+(def: version
+ (Parser /.Version)
+ <c>.text)
+
+(def: artifact'
+ (Parser /.Artifact)
+ ($_ <>.and ..group ..name ..version))
+
+(def: artifact
+ (Parser /.Artifact)
+ (<c>.tuple ..artifact'))
+
+(def: url
+ (Parser URL)
+ <c>.text)
+
+(def: scm
+ (Parser /.SCM)
+ ..url)
+
+(def: license
+ (Parser /.License)
+ (<c>.tuple ($_ <>.and
+ ..name
+ ..url
+ (<>.default #/.Repo
+ (<>.or (<c>.this! (' #repo))
+ (<c>.this! (' #manual)))))))
+
+(def: organization
+ (Parser /.Organization)
+ (<| <c>.form
+ (<>.after (<c>.this! (' #organization)))
+ ($_ <>.and
+ ..name
+ ..url)))
+
+(def: developer'
+ (Parser /.Developer)
+ ($_ <>.and
+ ..name
+ ..url
+ (<>.maybe ..organization)
+ ))
+
+(def: developer
+ (Parser /.Developer)
+ (<| <c>.form
+ (<>.after (<c>.this! (' #developer)))
+ ..developer'))
+
+(def: contributor
+ (Parser /.Contributor)
+ (<| <c>.form
+ (<>.after (<c>.this! (' #contributor)))
+ ..developer'))
+
+(def: no-info
+ /.Info
+ {#/.url #.None
+ #/.scm #.None
+ #/.description #.None
+ #/.licenses (list)
+ #/.organization #.None
+ #/.developers (list)
+ #/.contributors (list)})
+
+(def: (bundle tag parser)
+ (All [a] (-> Code (Parser a) (Parser (List a))))
+ (<c>.form (<>.after (<c>.this! tag)
+ (<>.some parser))))
+
+(def: info
+ (Parser /.Info)
+ ($_ <>.and
+ (<>.maybe ..url)
+ (<>.maybe ..scm)
+ (<>.maybe <c>.text)
+ (<>.default (list) (..bundle (' #licenses) ..license))
+ (<>.maybe ..organization)
+ (<>.default (list) (..bundle (' #developers) ..developer))
+ (<>.default (list) (..bundle (' #contributors) ..contributor))
+ ))
+
+(def: repository
+ (Parser /.Repository)
+ ..url)
+
+(def: type
+ (Parser //dependency.Type)
+ <c>.text)
+
+(def: dependency
+ (Parser /.Dependency)
+ (<c>.tuple
+ ($_ <>.and
+ ..artifact'
+ (<>.default //dependency.lux-library ..type)
+ )))
+
+(def: #export project
+ (Parser /.Project)
+ (<| <c>.form
+ (<>.after (<c>.this! (' project:)))
+ (`` ($_ <>.and
+ ..artifact
+ (<| (<>.default ..no-info)
+ <c>.form
+ (<>.after (<c>.this! (' #info)))
+ ..info)
+ (<| (<>.default (list))
+ (..bundle (' #repositories))
+ ..repository)
+ (<| (<>.default (list))
+ (..bundle (' #dependencies))
+ ..dependency)
+ ))))