feat: add async/await keywords, Num/String extensions, and Jinja markdown example
Add `async` and `await` token support to the Wren compiler with scheduler resolution logic, extend `Num` with `e` constant, hyperbolic trig, base conversion, and new methods (`isZero`, `gcd`, `lcm`, `digits`, etc.), extend `String` with `lower`, `upper`, `capitalize`, `title`, and regenerate `wren_core.wren.inc`. Include `Makefile` for multi-platform builds, rewrite `README.md` with updated build instructions, and add `example/await_demo.wren` and `example/jinja_markdown.wren` demonstrating new features.
This commit is contained in:
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
parser.addArgument("-l", {"long": "--level", "choices": ["debug", "info", "warn", "error"]})
|
||||
|
||||
var args = parser.parseArgs(["-l", "info"])
|
||||
System.print(args["level"]) // expect: info
|
||||
|
||||
var args2 = parser.parseArgs(["--level", "error"])
|
||||
System.print(args2["level"]) // expect: error
|
||||
|
||||
var args3 = parser.parseArgs(["--level", "debug"])
|
||||
System.print(args3["level"]) // expect: debug
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
parser.addArgument("-l", {"choices": ["debug", "info", "warn", "error"]})
|
||||
|
||||
var args = parser.parseArgs(["-l", "trace"]) // expect runtime error: Invalid choice 'trace' for -l
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
parser.addArgument("-o", {"required": true})
|
||||
|
||||
var args = parser.parseArgs([]) // expect runtime error: Missing required option: -o
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
parser.addArgument("filename")
|
||||
|
||||
var args = parser.parseArgs([]) // expect runtime error: Missing required argument: filename
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
parser.addArgument("-f", {"nargs": "+"})
|
||||
|
||||
var args = parser.parseArgs(["-f"]) // expect runtime error: Option -f requires at least one value
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
|
||||
var args = parser.parseArgs(["extra"]) // expect runtime error: Unexpected argument: extra
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
|
||||
var args = parser.parseArgs(["--unknown"]) // expect runtime error: Unknown option: --unknown
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new("A test program")
|
||||
parser.prog = "myapp"
|
||||
parser.addArgument("input", {"help": "Input file path"})
|
||||
parser.addArgument("-o", {"long": "--output", "help": "Output file path"})
|
||||
parser.addArgument("-v", {"long": "--verbose", "action": "storeTrue", "help": "Enable verbose mode"})
|
||||
|
||||
parser.printHelp()
|
||||
// expect: usage: myapp [options] input
|
||||
// expect:
|
||||
// expect: A test program
|
||||
// expect:
|
||||
// expect: positional arguments:
|
||||
// expect: input Input file path
|
||||
// expect:
|
||||
// expect: optional arguments:
|
||||
// expect: -o, --output Output file path
|
||||
// expect: -v, --verbose Enable verbose mode
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
parser.addArgument("input")
|
||||
parser.addArgument("-o", {"long": "--output", "default": "out.txt"})
|
||||
parser.addArgument("-v", {"action": "storeTrue"})
|
||||
parser.addArgument("-n", {"type": "int", "default": 1})
|
||||
|
||||
var args = parser.parseArgs(["data.csv", "-o", "result.json", "-v", "-n", "10"])
|
||||
System.print(args["input"]) // expect: data.csv
|
||||
System.print(args["output"]) // expect: result.json
|
||||
System.print(args["v"]) // expect: true
|
||||
System.print(args["n"]) // expect: 10
|
||||
|
||||
var args2 = parser.parseArgs(["data.csv"])
|
||||
System.print(args2["input"]) // expect: data.csv
|
||||
System.print(args2["output"]) // expect: out.txt
|
||||
System.print(args2["v"]) // expect: false
|
||||
System.print(args2["n"]) // expect: 1
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
parser.addArgument("-p", {"long": "--point", "nargs": 2, "type": "int"})
|
||||
|
||||
var args = parser.parseArgs(["-p", "10", "20"])
|
||||
System.print(args["point"].count) // expect: 2
|
||||
System.print(args["point"][0]) // expect: 10
|
||||
System.print(args["point"][1]) // expect: 20
|
||||
|
||||
var args2 = parser.parseArgs(["--point", "5", "15"])
|
||||
System.print(args2["point"].count) // expect: 2
|
||||
System.print(args2["point"][0]) // expect: 5
|
||||
System.print(args2["point"][1]) // expect: 15
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
parser.addArgument("-f", {"long": "--files", "nargs": "+"})
|
||||
|
||||
var args = parser.parseArgs(["-f", "a.txt", "b.txt"])
|
||||
System.print(args["files"].count) // expect: 2
|
||||
System.print(args["files"][0]) // expect: a.txt
|
||||
System.print(args["files"][1]) // expect: b.txt
|
||||
|
||||
var args2 = parser.parseArgs(["--files", "single.txt"])
|
||||
System.print(args2["files"].count) // expect: 1
|
||||
System.print(args2["files"][0]) // expect: single.txt
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
parser.addArgument("files", {"nargs": "*", "required": false})
|
||||
|
||||
var args = parser.parseArgs(["a.txt", "b.txt", "c.txt"])
|
||||
System.print(args["files"].count) // expect: 3
|
||||
System.print(args["files"][0]) // expect: a.txt
|
||||
System.print(args["files"][1]) // expect: b.txt
|
||||
System.print(args["files"][2]) // expect: c.txt
|
||||
|
||||
var parser2 = ArgumentParser.new()
|
||||
parser2.addArgument("files", {"nargs": "+"})
|
||||
|
||||
var args2 = parser2.parseArgs(["x.txt", "y.txt"])
|
||||
System.print(args2["files"].count) // expect: 2
|
||||
System.print(args2["files"][0]) // expect: x.txt
|
||||
System.print(args2["files"][1]) // expect: y.txt
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "argparse" for ArgumentParser
|
||||
|
||||
var parser = ArgumentParser.new()
|
||||
parser.addArgument("-f", {"long": "--files", "nargs": "*"})
|
||||
|
||||
var args = parser.parseArgs(["-f", "a.txt", "b.txt", "c.txt"])
|
||||
System.print(args["files"].count) // expect: 3
|
||||
System.print(args["files"][0]) // expect: a.txt
|
||||
System.print(args["files"][1]) // expect: b.txt
|
||||
System.print(args["files"][2]) // expect: c.txt
|
||||
|
||||
var args2 = parser.parseArgs(["--files"])
|
||||
System.print(args2["files"].count) // expect: 0
|
||||
Reference in New Issue
Block a user