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
+63
@@ -0,0 +1,63 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print("=== String Methods Demo ===\n")
|
||||
|
||||
System.print("--- Case Conversion ---")
|
||||
var text = "Hello World"
|
||||
System.print("Original: %(text)")
|
||||
System.print("lower: %(text.lower)")
|
||||
System.print("upper: %(text.upper)")
|
||||
System.print("capitalize: %("hello world".capitalize)")
|
||||
System.print("title: %("hello world".title)")
|
||||
System.print("swapCase: %(text.swapCase)")
|
||||
|
||||
System.print("\n--- Character Testing ---")
|
||||
System.print("\"hello\".isLower: %("hello".isLower)")
|
||||
System.print("\"HELLO\".isUpper: %("HELLO".isUpper)")
|
||||
System.print("\"12345\".isDigit: %("12345".isDigit)")
|
||||
System.print("\"hello\".isAlpha: %("hello".isAlpha)")
|
||||
System.print("\"hello1\".isAlphaNumeric: %("hello1".isAlphaNumeric)")
|
||||
System.print("\" \".isSpace: %(" ".isSpace)")
|
||||
System.print("\"hello\".isAscii: %("hello".isAscii)")
|
||||
|
||||
System.print("\n--- Search ---")
|
||||
var sentence = "hello world hello"
|
||||
System.print("Text: %(sentence)")
|
||||
System.print("lastIndexOf(\"hello\"): %(sentence.lastIndexOf("hello"))")
|
||||
System.print("lastIndexOf(\"hello\", 11): %(sentence.lastIndexOf("hello", 11))")
|
||||
|
||||
System.print("\n--- Transformation ---")
|
||||
System.print("\"hello\".reverse: %("hello".reverse)")
|
||||
System.print("\"hi\".center(10, \"-\"): %("hi".center(10, "-"))")
|
||||
System.print("\"42\".lpad(5, \"0\"): %("42".lpad(5, "0"))")
|
||||
System.print("\"hi\".rpad(5, \".\"): %("hi".rpad(5, "."))")
|
||||
System.print("\"42\".zfill(5): %("42".zfill(5))")
|
||||
System.print("\"-42\".zfill(6): %("-42".zfill(6))")
|
||||
|
||||
System.print("\n--- Prefix/Suffix ---")
|
||||
System.print("removePrefix(\"Hello\"): %("HelloWorld".removePrefix("Hello"))")
|
||||
System.print("removeSuffix(\"World\"): %("HelloWorld".removeSuffix("World"))")
|
||||
|
||||
System.print("\n--- Comparison ---")
|
||||
System.print("\"apple\" < \"banana\": %("apple" < "banana")")
|
||||
System.print("\"banana\" > \"apple\": %("banana" > "apple")")
|
||||
System.print("\"abc\" <= \"abc\": %("abc" <= "abc")")
|
||||
System.print("\"abc\" >= \"abc\": %("abc" >= "abc")")
|
||||
System.print("\"abc\" < \"abcd\": %("abc" < "abcd")")
|
||||
System.print("\"abcd\" > \"abc\": %("abcd" > "abc")")
|
||||
System.print("\"Z\" < \"a\": %("Z" < "a")")
|
||||
|
||||
var fruits = ["cherry", "apple", "banana"]
|
||||
System.print("Sorted: %(fruits.sort {|a, b| a < b})")
|
||||
|
||||
System.print("\n--- Splitting ---")
|
||||
var lines = "line1\nline2\nline3".splitLines
|
||||
System.print("splitLines: %(lines)")
|
||||
|
||||
var chars = "abc".chars
|
||||
System.print("chars: %(chars)")
|
||||
|
||||
System.print("\n--- Conversion ---")
|
||||
System.print("\"42\".toNum: %("42".toNum)")
|
||||
System.print("\"3.14\".toNum: %("3.14".toNum)")
|
||||
System.print("\"abc\".toNum: %("abc".toNum)")
|
||||
Reference in New Issue
Block a user