diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-12 15:31:59 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-12 15:32:04 -0700 |
| commit | ea310306d73e0bc6542f7133825549ae4471b06a (patch) | |
| tree | fcc2a5a868fe09fb599d8261f66dad96ac69bb0b /nomsu.moon | |
| parent | 9e10c8bf006f42e90a011b8f9284e3ffa52a5859 (diff) | |
Initial working version.
Diffstat (limited to 'nomsu.moon')
| -rwxr-xr-x | nomsu.moon | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -20,7 +20,7 @@ else usage = [=[ Nomsu Compiler -Usage: (nomsu | lua nomsu.lua | moon nomsu.moon) [-V version] [-O optimization level] [-v] [-c] [-s] [-t] [-I file] [--help | -h] [--version] [--no-core] [file [nomsu args...]] +Usage: (nomsu | lua nomsu.lua | moon nomsu.moon) [-V version] [-O optimization level] [-v] [-c] [-s] [-I file] [--help | -h] [--version] [--no-core] [file [nomsu args...]] OPTIONS -O <level> Run the compiler with the given optimization level (>0: use precompiled .lua versions of Nomsu files, when available). @@ -57,24 +57,23 @@ if not arg or debug.getinfo(2).func == require file_queue = {} sep = "\3" parser = re.compile([[ - args <- {| (flag %sep)* (({~ file ~} -> add_file) {:primary_file: '' -> true :} %sep)? + args <- {| (flag %sep)* (({~ file ~} -> add_file) {:primary_file: %true :} %sep)? {:nomsu_args: {| ({(!%sep .)*} %sep)* |} :} %sep? |} !. flag <- - {:optimization: "-O" (%sep? (([0-9]+) -> tonumber))? :} + {:optimization: "-O" (%sep? %number)? :} / ("-I" %sep? ({~ file ~} -> add_file)) - / ("-e" %sep? (({} {~ file ~}) -> add_exec_string) {:exec_strings: '' -> true :}) - / ({:check_syntax: ("-s" -> true):}) - / ({:compile: ("-c" -> true):}) - / ({:compile: ("-c" -> true):}) - / {:verbose: ("-v" -> true) :} - / {:help: (("-h" / "--help") -> true) :} - / {:version: ("--version" -> true) :} - / {:no_core: ("--no-core" -> true) :} + / ("-e" %sep? (({} {~ file ~}) -> add_exec_string) {:exec_strings: %true :}) + / ({:check_syntax: "-s" %true:}) + / ({:compile: "-c" %true:}) + / {:verbose: "-v" %true :} + / {:help: ("-h" / "--help") %true :} + / {:version: "--version" %true :} + / {:no_core: "--no-core" %true :} / {:debugger: ("-d" %sep? {(!%sep .)*}) :} / {:requested_version: "-V" (%sep? {([0-9.])+})? :} file <- ("-" -> "stdin") / {(!%sep .)+} ]], { - true:(-> true), tonumber:(=>tonumber(@)), sep:lpeg.P(sep) + true:lpeg.Cc(true), number:lpeg.R("09")^1/tonumber, sep:lpeg.P(sep) add_file: (f)-> table.insert(file_queue, f) add_exec_string: (pos, s)-> name = "command line arg @#{pos}.nom" @@ -165,7 +164,7 @@ run = -> -- Check syntax file, source = get_file_and_source(filename) continue unless file - nomsu\parse(file, source) + tree = nomsu\parse(file, source) print("Parse succeeded: #{filename}") if args.compile |
