YUESCRIPT เป็นภาษา MOONSCRIPT มันมาจากภาษา Moonscript 0.5.0 และใช้คุณสมบัติใหม่อย่างต่อเนื่องเพื่อให้ทันสมัยมากขึ้น
Moonscript เป็นภาษาที่รวบรวม Lua เนื่องจาก Moonscript ต้นฉบับถูกใช้เพื่อเขียน Framework Lapis และเรียกใช้เว็บไซต์ธุรกิจบางอย่างเช่น itch.io และ streak.club ด้วยฐานรหัสขนาดใหญ่ ภาษาดั้งเดิมนั้นยากเกินไปที่จะนำคุณสมบัติใหม่มาใช้สำหรับผู้ที่อาจทำลายความคลาดเคลื่อนสำหรับแอปพลิเคชันที่มีอยู่
ดังนั้น YUEScript จึงเป็นฐานรหัสใหม่สำหรับการผลักดันภาษาให้ก้าวไปข้างหน้าและเป็นสนามเด็กเล่นเพื่อลองแนะนำไวยากรณ์ภาษาใหม่หรือกระบวนทัศน์การเขียนโปรแกรมเพื่อให้ภาษาดวงจันทร์มีความแสดงออกและมีประสิทธิผลมากขึ้น
Yue (月) เป็นชื่อของดวงจันทร์ในภาษาจีนและออกเสียงว่า [JYɛ]
สร้างไฟล์ yue.so ด้วย
> make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua จากนั้นรับไฟล์ไบนารีจาก Path bin/shared/yue.so
หรือคุณสามารถติดตั้ง Luarocks ผู้จัดการแพ็คเกจสำหรับโมดูล LUA จากนั้นติดตั้งเป็นโมดูล LUA ด้วย
> luarocks install yuescriptจากนั้นต้องการโมดูล yuescript ใน Lua:
require ( " yue " )( " main " ) -- require `main.yue`
local yue = require ( " yue " )
local codes , err , globals = yue . to_lua ( [[
f = ->
print "hello world"
f!
]] ,{
implicit_return_root = true ,
reserve_line_number = true ,
lint_global = true
})โคลน repo นี้จากนั้นสร้างและติดตั้งปฏิบัติการด้วย:
> make installสร้างเครื่องมือ YUESCRIPT โดยไม่มีคุณสมบัติมาโคร:
> make install NO_MACRO=trueสร้างเครื่องมือ YUESCRIPT โดยไม่มี LUA Binary ในตัว:
> make install NO_LUA=trueใช้เครื่องมือ yuescript ด้วย:
> yue -h
Usage: yue [options | files | directories] ...
-h Print this message
-e str Execute a file or raw codes
-m Generate minified codes
-r Rewrite output to match original line numbers
-t path Specify where to place compiled files
-o file Write output to file
-s Use spaces in generated codes instead of tabs
-p Write output to standard out
-b Dump compile time (doesn ' t write output)
-g Dump global variables used in NAME LINE COLUMN
-l Write line numbers from source codes
-c Reserve comments before statement from source codes
-w path Watch changes and compile every file under directory
-v Print version
-- Read from standard in, print to standard out
(Must be first and only argument)
--target=version Specify the Lua version that codes will be generated to
(version can only be 5.1, 5.2, 5.3 or 5.4)
--path=path_str Append an extra Lua search path string to package.path
Execute without options to enter REPL, type symbol ' $'
in a single line to start/stop multi-line mode ใช้กรณี:
รวบรวมทุกไฟล์ YUESCRIPT ทุกไฟล์ด้วยส่วนขยาย .yue ภายใต้เส้นทางปัจจุบัน: yue .
รวบรวมและบันทึกผลลัพธ์ไปยังเส้นทางเป้าหมาย: yue -t /target/path/ .
รวบรวมและสำรองข้อมูลการดีบัก: yue -l .
คอมไพล์และสร้างรหัสขนาดเล็ก: yue -m .
เรียกใช้รหัสดิบ: yue -e 'print 123'
เรียกใช้ไฟล์ yuescript: yue -e main.yue
มิกซ์