From 83c3e1ccde72d133524c86b707ed11d75c427304 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Sat, 21 Feb 2026 21:53:45 +0800 Subject: Add Mascot to documentation And minor tweaks to documentation structure --- doc/docs/.vitepress/config.mts | 28 +- .../electrichearts_20260211A_yuescript_xiaoyu.png | Bin 0 -> 2478544 bytes .../electrichearts_20260211A_yuescript_xiaoyu.zip | Bin 0 -> 10132610 bytes ...ctrichearts_20260211A_yuescript_xiaoyu_full.png | Bin 0 -> 3464576 bytes ...trichearts_20260211A_yuescript_xiaoyu_trans.png | Bin 0 -> 3199600 bytes doc/docs/.vitepress/theme/custom.css | 30 +- doc/docs/de/doc/advanced/the-yuescript-library.md | 860 +++++++++++++++++++++ doc/docs/de/doc/reference/mascot.md | 39 + doc/docs/de/doc/reference/the-yuescript-library.md | 860 --------------------- doc/docs/doc/advanced/the-yuescript-library.md | 860 +++++++++++++++++++++ doc/docs/doc/reference/mascot.md | 39 + doc/docs/doc/reference/the-yuescript-library.md | 860 --------------------- .../id-id/doc/advanced/the-yuescript-library.md | 860 +++++++++++++++++++++ doc/docs/id-id/doc/reference/mascot.md | 39 + .../id-id/doc/reference/the-yuescript-library.md | 860 --------------------- doc/docs/index.md | 2 +- .../pt-br/doc/advanced/the-yuescript-library.md | 860 +++++++++++++++++++++ doc/docs/pt-br/doc/reference/mascot.md | 39 + .../pt-br/doc/reference/the-yuescript-library.md | 860 --------------------- doc/docs/zh/doc/advanced/the-yuescript-library.md | 860 +++++++++++++++++++++ doc/docs/zh/doc/reference/mascot.md | 39 + doc/docs/zh/doc/reference/the-yuescript-library.md | 860 --------------------- 22 files changed, 4538 insertions(+), 4317 deletions(-) create mode 100644 doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png create mode 100644 doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.zip create mode 100644 doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu_full.png create mode 100644 doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu_trans.png create mode 100644 doc/docs/de/doc/advanced/the-yuescript-library.md create mode 100644 doc/docs/de/doc/reference/mascot.md delete mode 100644 doc/docs/de/doc/reference/the-yuescript-library.md create mode 100644 doc/docs/doc/advanced/the-yuescript-library.md create mode 100644 doc/docs/doc/reference/mascot.md delete mode 100644 doc/docs/doc/reference/the-yuescript-library.md create mode 100644 doc/docs/id-id/doc/advanced/the-yuescript-library.md create mode 100644 doc/docs/id-id/doc/reference/mascot.md delete mode 100644 doc/docs/id-id/doc/reference/the-yuescript-library.md create mode 100644 doc/docs/pt-br/doc/advanced/the-yuescript-library.md create mode 100644 doc/docs/pt-br/doc/reference/mascot.md delete mode 100644 doc/docs/pt-br/doc/reference/the-yuescript-library.md create mode 100644 doc/docs/zh/doc/advanced/the-yuescript-library.md create mode 100644 doc/docs/zh/doc/reference/mascot.md delete mode 100644 doc/docs/zh/doc/reference/the-yuescript-library.md diff --git a/doc/docs/.vitepress/config.mts b/doc/docs/.vitepress/config.mts index 872791c..01a0854 100644 --- a/doc/docs/.vitepress/config.mts +++ b/doc/docs/.vitepress/config.mts @@ -64,6 +64,7 @@ const sidebarText = { functionStubs: "Funktions-Stubs", usingClause: "Die Using-Klausel; Kontrolle destruktiver Zuweisung", yuescriptLibrary: "Die YueScript-Bibliothek", + mascot: "Maskottchen – Xiaoyu", licenseMit: "Lizenz: MIT", }, en: { @@ -99,6 +100,7 @@ const sidebarText = { functionStubs: "Function Stubs", usingClause: "The Using Clause; Controlling Destructive Assignment", yuescriptLibrary: "The YueScript Library", + mascot: "Mascot - Xiaoyu", licenseMit: "License: MIT", }, idId: { @@ -134,6 +136,7 @@ const sidebarText = { functionStubs: "Fungsi Sementara", usingClause: "Klausa Using; Mengontrol Penugasan Destruktif", yuescriptLibrary: "Pustaka YueScript", + mascot: "Maskot – Xiaoyu", licenseMit: "Lisensi: MIT", }, ptBr: { @@ -169,6 +172,7 @@ const sidebarText = { functionStubs: "Stubs de função", usingClause: "Cláusula using; controlando atribuição destrutiva", yuescriptLibrary: "A biblioteca do YueScript", + mascot: "Mascote – Xiaoyu", licenseMit: "Licença: MIT", }, zh: { @@ -204,6 +208,7 @@ const sidebarText = { functionStubs: "函数存根", usingClause: "使用 using 语句:防止破坏性赋值", yuescriptLibrary: "月之脚本语言库", + mascot: "吉祥物 – 小玉", licenseMit: "MIT 许可证", }, } as const; @@ -219,7 +224,7 @@ type SidebarGroupText = { dataStructures: string; objects: string; advancedFeatures: string; - reference: string; + extras: string; }; const sidebarGroups: Record = { @@ -232,7 +237,7 @@ const sidebarGroups: Record = { dataStructures: "Datenstrukturen", objects: "Objekte", advancedFeatures: "Erweiterte Funktionen", - reference: "Referenz", + extras: "Extras", }, en: { gettingStarted: "Getting Started", @@ -243,7 +248,7 @@ const sidebarGroups: Record = { dataStructures: "Data Structures", objects: "Objects", advancedFeatures: "Advanced Features", - reference: "Reference", + extras: "Extras", }, idId: { gettingStarted: "Memulai", @@ -254,7 +259,7 @@ const sidebarGroups: Record = { dataStructures: "Struktur Data", objects: "Objek", advancedFeatures: "Fitur Lanjutan", - reference: "Referensi", + extras: "Ekstra", }, ptBr: { gettingStarted: "Primeiros passos", @@ -265,7 +270,7 @@ const sidebarGroups: Record = { dataStructures: "Estruturas de dados", objects: "Objetos", advancedFeatures: "Recursos avançados", - reference: "Referência", + extras: "Extras", }, zh: { gettingStarted: "起步", @@ -276,7 +281,7 @@ const sidebarGroups: Record = { dataStructures: "数据结构", objects: "面向对象", advancedFeatures: "高级特性", - reference: "参考", + extras: "其他", }, }; @@ -414,16 +419,17 @@ function createSidebar(basePath: string, locale: SidebarLocale) { }, { text: text.do, link: `${basePath}/advanced/do` }, { text: text.try, link: `${basePath}/advanced/try` }, + { + text: text.yuescriptLibrary, + link: `${basePath}/advanced/the-yuescript-library`, + }, ], }, { - text: group.reference, + text: group.extras, collapsed: true, items: [ - { - text: text.yuescriptLibrary, - link: `${basePath}/reference/the-yuescript-library`, - }, + { text: text.mascot, link: `${basePath}/reference/mascot` }, { text: text.licenseMit, link: `${basePath}/reference/license-mit` }, ], }, diff --git a/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png b/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png new file mode 100644 index 0000000..5bab134 Binary files /dev/null and b/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png differ diff --git a/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.zip b/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.zip new file mode 100644 index 0000000..e84ff36 Binary files /dev/null and b/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.zip differ diff --git a/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu_full.png b/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu_full.png new file mode 100644 index 0000000..fdf8475 Binary files /dev/null and b/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu_full.png differ diff --git a/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu_trans.png b/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu_trans.png new file mode 100644 index 0000000..90e4f47 Binary files /dev/null and b/doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu_trans.png differ diff --git a/doc/docs/.vitepress/theme/custom.css b/doc/docs/.vitepress/theme/custom.css index 4050784..a4ae4d3 100644 --- a/doc/docs/.vitepress/theme/custom.css +++ b/doc/docs/.vitepress/theme/custom.css @@ -40,16 +40,36 @@ --vp-c-text-2: #4a5568; } -/* Hero image - enlarge container to fit 450px image without overflow */ +/* Hero image - adjust container to fit mascot artwork without overflow */ @media (min-width: 960px) { .VPHero .image-container { - width: 450px !important; + width: 420px !important; + } + + .VPHero .image-src { + margin-top: 2.7rem !important; + padding-bottom: 2.7rem !important; + } +} + +@media (max-width: 960px) { + .VPHero .image-src { + margin-top: 1rem !important; + padding-bottom: 3.2rem !important; + } +} + +@media (max-width: 639px) { + .VPHero .image-src { + margin-top: 3.2rem !important; + padding-bottom: 7.4rem !important; } } -.VPHero :deep(.image-src) { - max-width: 450px; - max-height: 450px; +.VPHero .image-src { + max-width: 420px; + max-height: 360px; + object-fit: contain; } /* --- DARK MODE THEME (Midnight Blue) --- */ diff --git a/doc/docs/de/doc/advanced/the-yuescript-library.md b/doc/docs/de/doc/advanced/the-yuescript-library.md new file mode 100644 index 0000000..0c371bf --- /dev/null +++ b/doc/docs/de/doc/advanced/the-yuescript-library.md @@ -0,0 +1,860 @@ +# Die YueScript-Bibliothek + +Zugriff in Lua über `local yue = require("yue")`. + +## yue + +**Beschreibung:** + +Die YueScript-Sprachbibliothek. + +### version + +**Typ:** Feld. + +**Beschreibung:** + +Die YueScript-Version. + +**Signatur:** + +```lua +version: string +``` + +### dirsep + +**Typ:** Feld. + +**Beschreibung:** + +Der Dateitrennzeichen-String der aktuellen Plattform. + +**Signatur:** + +```lua +dirsep: string +``` + +### yue_compiled + +**Typ:** Feld. + +**Beschreibung:** + +Der Cache für kompilierten Modulcode. + +**Signatur:** + +```lua +yue_compiled: {string: string} +``` + +### to_lua + +**Typ:** Funktion. + +**Beschreibung:** + +Die YueScript-Compilerfunktion. Sie kompiliert YueScript-Code zu Lua-Code. + +**Signatur:** + +```lua +to_lua: function(code: string, config?: Config): + --[[codes]] string | nil, + --[[error]] string | nil, + --[[globals]] {{string, integer, integer}} | nil +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | --------------------------------- | +| code | string | Der YueScript-Code. | +| config | Config | [Optional] Die Compiler-Optionen. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| string \| nil | Der kompilierte Lua-Code oder `nil`, falls die Kompilierung fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls die Kompilierung erfolgreich war. | +| {{string, integer, integer}} \| nil | Die globalen Variablen im Code (mit Name, Zeile und Spalte) oder `nil`, wenn die Compiler-Option `lint_global` false ist. | + +### file_exist + +**Typ:** Funktion. + +**Beschreibung:** + +Prüft, ob eine Quelldatei existiert. Kann überschrieben werden, um das Verhalten anzupassen. + +**Signatur:** + +```lua +file_exist: function(filename: string): boolean +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | -------------- | +| filename | string | Der Dateiname. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | ----------------------- | +| boolean | Ob die Datei existiert. | + +### read_file + +**Typ:** Funktion. + +**Beschreibung:** + +Liest eine Quelldatei. Kann überschrieben werden, um das Verhalten anzupassen. + +**Signatur:** + +```lua +read_file: function(filename: string): string +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | -------------- | +| filename | string | Der Dateiname. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | ---------------- | +| string | Der Dateiinhalt. | + +### insert_loader + +**Typ:** Funktion. + +**Beschreibung:** + +Fügt den YueScript-Loader in die Package-Loader (Searcher) ein. + +**Signatur:** + +```lua +insert_loader: function(pos?: integer): boolean +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------- | ---------------------------------------------------------------------- | +| pos | integer | [Optional] Position, an der der Loader eingefügt wird. Standard ist 3. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | ------------------------------------------------------------------------------------ | +| boolean | Ob der Loader erfolgreich eingefügt wurde. Scheitert, wenn er bereits eingefügt ist. | + +### remove_loader + +**Typ:** Funktion. + +**Beschreibung:** + +Entfernt den YueScript-Loader aus den Package-Loadern (Searchern). + +**Signatur:** + +```lua +remove_loader: function(): boolean +``` + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | --------------------------------------------------------------------------------- | +| boolean | Ob der Loader erfolgreich entfernt wurde. Scheitert, wenn er nicht eingefügt ist. | + +### loadstring + +**Typ:** Funktion. + +**Beschreibung:** + +Lädt YueScript-Code aus einem String in eine Funktion. + +**Signatur:** + +```lua +loadstring: function(input: string, chunkname: string, env: table, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | --------------------------------- | +| input | string | Der YueScript-Code. | +| chunkname | string | Der Name des Code-Chunks. | +| env | table | Die Environment-Tabelle. | +| config | Config | [Optional] Die Compiler-Optionen. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| --------------- | --------------------------------------------------------------------- | +| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | + +### loadstring + +**Typ:** Funktion. + +**Beschreibung:** + +Lädt YueScript-Code aus einem String in eine Funktion. + +**Signatur:** + +```lua +loadstring: function(input: string, chunkname: string, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | --------------------------------- | +| input | string | Der YueScript-Code. | +| chunkname | string | Der Name des Code-Chunks. | +| config | Config | [Optional] Die Compiler-Optionen. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| --------------- | --------------------------------------------------------------------- | +| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | + +### loadstring + +**Typ:** Funktion. + +**Beschreibung:** + +Lädt YueScript-Code aus einem String in eine Funktion. + +**Signatur:** + +```lua +loadstring: function(input: string, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | --------------------------------- | +| input | string | Der YueScript-Code. | +| config | Config | [Optional] Die Compiler-Optionen. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| --------------- | --------------------------------------------------------------------- | +| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | + +### loadfile + +**Typ:** Funktion. + +**Beschreibung:** + +Lädt YueScript-Code aus einer Datei in eine Funktion. + +**Signatur:** + +```lua +loadfile: function(filename: string, env: table, config?: Config): + nil | function(...: any): (any...), + string | nil +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | --------------------------------- | +| filename | string | Der Dateiname. | +| env | table | Die Environment-Tabelle. | +| config | Config | [Optional] Die Compiler-Optionen. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| --------------- | --------------------------------------------------------------------- | +| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | + +### loadfile + +**Typ:** Funktion. + +**Beschreibung:** + +Lädt YueScript-Code aus einer Datei in eine Funktion. + +**Signatur:** + +```lua +loadfile: function(filename: string, config?: Config): + nil | function(...: any): (any...), + string | nil +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | --------------------------------- | +| filename | string | Der Dateiname. | +| config | Config | [Optional] Die Compiler-Optionen. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| --------------- | --------------------------------------------------------------------- | +| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | + +### dofile + +**Typ:** Funktion. + +**Beschreibung:** + +Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. + +**Signatur:** + +```lua +dofile: function(filename: string, env: table, config?: Config): any... +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | --------------------------------- | +| filename | string | Der Dateiname. | +| env | table | Die Environment-Tabelle. | +| config | Config | [Optional] Die Compiler-Optionen. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | ----------------------------------------- | +| any... | Die Rückgabewerte der geladenen Funktion. | + +### dofile + +**Typ:** Funktion. + +**Beschreibung:** + +Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. + +**Signatur:** + +```lua +dofile: function(filename: string, config?: Config): any... +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | --------------------------------- | +| filename | string | Der Dateiname. | +| config | Config | [Optional] Die Compiler-Optionen. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | ----------------------------------------- | +| any... | Die Rückgabewerte der geladenen Funktion. | + +### find_modulepath + +**Typ:** Funktion. + +**Beschreibung:** + +Löst den YueScript-Modulnamen in einen Dateipfad auf. + +**Signatur:** + +```lua +find_modulepath: function(name: string): string +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | -------------- | +| name | string | Der Modulname. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | -------------- | +| string | Der Dateipfad. | + +### pcall + +**Typ:** Funktion. + +**Beschreibung:** + +Ruft eine Funktion im geschützten Modus auf. +Fängt Fehler ab und gibt einen Statuscode sowie Ergebnisse oder ein Fehlerobjekt zurück. +Schreibt die Fehlerzeilennummer bei Fehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. + +**Signatur:** + +```lua +pcall: function(f: function, ...: any): boolean, any... +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | -------- | --------------------------- | +| f | function | Die aufzurufende Funktion. | +| ... | any | Argumente für die Funktion. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ------------ | ---------------------------------------------------- | +| boolean, ... | Statuscode und Funktionsresultate oder Fehlerobjekt. | + +### require + +**Typ:** Funktion. + +**Beschreibung:** + +Lädt ein Modul (Lua oder YueScript). +Schreibt die Fehlerzeilennummer auf die ursprüngliche Zeilennummer im YueScript-Code um, wenn das Modul ein YueScript-Modul ist und das Laden fehlschlägt. + +**Signatur:** + +```lua +require: function(name: string): any... +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | -------------------------------- | +| modname | string | Der Name des zu ladenden Moduls. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| any | Der Wert in `package.loaded[modname]`, falls das Modul bereits geladen ist. Andernfalls wird ein Loader gesucht und der finale Wert von `package.loaded[modname]` sowie Loader-Daten als zweites Ergebnis zurückgegeben. | + +### p + +**Typ:** Funktion. + +**Beschreibung:** + +Inspiziert die Struktur der übergebenen Werte und gibt String-Repräsentationen aus. + +**Signatur:** + +```lua +p: function(...: any) +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | --- | ---------------------------- | +| ... | any | Die zu inspizierenden Werte. | + +### options + +**Typ:** Feld. + +**Beschreibung:** + +Die aktuellen Compiler-Optionen. + +**Signatur:** + +```lua +options: Config.Options +``` + +### traceback + +**Typ:** Funktion. + +**Beschreibung:** + +Die Traceback-Funktion, die Stacktrace-Zeilennummern auf die ursprünglichen Zeilennummern im YueScript-Code umschreibt. + +**Signatur:** + +```lua +traceback: function(message: string): string +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | ------------------------ | +| message | string | Die Traceback-Nachricht. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | --------------------------------------- | +| string | Die umgeschriebene Traceback-Nachricht. | + +### is_ast + +**Typ:** Funktion. + +**Beschreibung:** + +Prüft, ob der Code dem angegebenen AST entspricht. + +**Signatur:** + +```lua +is_ast: function(astName: string, code: string): boolean +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | ------------- | +| astName | string | Der AST-Name. | +| code | string | Der Code. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | ------------------------------- | +| boolean | Ob der Code dem AST entspricht. | + +### AST + +**Typ:** Feld. + +**Beschreibung:** + +Die AST-Typdefinition mit Name, Zeile, Spalte und Unterknoten. + +**Signatur:** + +```lua +type AST = {string, integer, integer, any} +``` + +### to_ast + +**Typ:** Funktion. + +**Beschreibung:** + +Konvertiert Code in AST. + +**Signatur:** + +```lua +to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): + --[[AST]] AST | nil, + --[[error]] nil | string +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| -------------- | ------- | -------------------------------------------------------------------------------------------- | +| code | string | Der Code. | +| flattenLevel | integer | [Optional] Der Flatten-Level. Höher bedeutet mehr Flattening. Standard ist 0. Maximum ist 2. | +| astName | string | [Optional] Der AST-Name. Standard ist "File". | +| reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist false. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ------------- | ---------------------------------------------------------------------- | +| AST \| nil | Der AST oder `nil`, falls die Konvertierung fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls die Konvertierung erfolgreich war. | + +### format + +**Typ:** Funktion. + +**Beschreibung:** + +Formatiert den YueScript-Code. + +**Signatur:** + +```lua +format: function(code: string, tabSize?: number, reserveComment?: boolean): string +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| -------------- | ------- | ---------------------------------------------------------------------------------- | +| code | string | Der Code. | +| tabSize | integer | [Optional] Die Tab-Größe. Standard ist 4. | +| reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist true. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | --------------------- | +| string | Der formatierte Code. | + +### \_\_call + +**Typ:** Metamethod. + +**Beschreibung:** + +Required das YueScript-Modul. +Schreibt die Fehlerzeilennummer bei Ladefehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. + +**Signatur:** + +```lua +metamethod __call: function(self: yue, module: string): any... +``` + +**Parameter:** + +| Parameter | Typ | Beschreibung | +| --------- | ------ | -------------- | +| module | string | Der Modulname. | + +**Rückgabe:** + +| Rückgabetyp | Beschreibung | +| ----------- | -------------- | +| any | Der Modulwert. | + +## Config + +**Beschreibung:** + +Die Compiler-Optionen. + +### lint_global + +**Typ:** Feld. + +**Beschreibung:** + +Ob der Compiler die globalen Variablen im Code sammeln soll. + +**Signatur:** + +```lua +lint_global: boolean +``` + +### implicit_return_root + +**Typ:** Feld. + +**Beschreibung:** + +Ob der Compiler für den Root-Codeblock ein implizites Return verwenden soll. + +**Signatur:** + +```lua +implicit_return_root: boolean +``` + +### reserve_line_number + +**Typ:** Feld. + +**Beschreibung:** + +Ob der Compiler die ursprüngliche Zeilennummer im kompilierten Code beibehalten soll. + +**Signatur:** + +```lua +reserve_line_number: boolean +``` + +### reserve_comment + +**Typ:** Feld. + +**Beschreibung:** + +Ob der Compiler die ursprünglichen Kommentare im kompilierten Code beibehalten soll. + +**Signatur:** + +```lua +reserve_comment: boolean +``` + +### space_over_tab + +**Typ:** Feld. + +**Beschreibung:** + +Ob der Compiler statt Tabzeichen Leerzeichen verwenden soll. + +**Signatur:** + +```lua +space_over_tab: boolean +``` + +### same_module + +**Typ:** Feld. + +**Beschreibung:** + +Ob der Compiler den zu kompilierenden Code als dasselbe aktuell kompilierte Modul behandeln soll. Nur für internen Gebrauch. + +**Signatur:** + +```lua +same_module: boolean +``` + +### line_offset + +**Typ:** Feld. + +**Beschreibung:** + +Ob die Compiler-Fehlermeldung einen Zeilennummern-Offset enthalten soll. Nur für internen Gebrauch. + +**Signatur:** + +```lua +line_offset: integer +``` + +### yue.Config.LuaTarget + +**Typ:** Enumeration. + +**Beschreibung:** + +Die Ziel-Lua-Version. + +**Signatur:** + +```lua +enum LuaTarget + "5.1" + "5.2" + "5.3" + "5.4" + "5.5" +end +``` + +### options + +**Typ:** Feld. + +**Beschreibung:** + +Zusätzliche Optionen für die Kompilierung. + +**Signatur:** + +```lua +options: Options +``` + +## Options + +**Beschreibung:** + +Zusätzliche Compiler-Optionen. + +### target + +**Typ:** Feld. + +**Beschreibung:** + +Die Ziel-Lua-Version für die Kompilierung. + +**Signatur:** + +```lua +target: LuaTarget +``` + +### path + +**Typ:** Feld. + +**Beschreibung:** + +Zusätzlicher Modul-Suchpfad. + +**Signatur:** + +```lua +path: string +``` + +### dump_locals + +**Typ:** Feld. + +**Beschreibung:** + +Ob lokale Variablen in Traceback-Fehlermeldungen ausgegeben werden sollen. Standard ist false. + +**Signatur:** + +```lua +dump_locals: boolean +``` + +### simplified + +**Typ:** Feld. + +**Beschreibung:** + +Ob Fehlermeldungen vereinfacht werden sollen. Standard ist true. + +**Signatur:** + +```lua +simplified: boolean +``` diff --git a/doc/docs/de/doc/reference/mascot.md b/doc/docs/de/doc/reference/mascot.md new file mode 100644 index 0000000..ad0e982 --- /dev/null +++ b/doc/docs/de/doc/reference/mascot.md @@ -0,0 +1,39 @@ +# Maskottchen – Xiaoyu + +## Über + +Xiaoyu das Cyber-Kaninchen + +Xiaoyu (小玉, „kleines Jade") ist ein Cyber-Kaninchen und das offizielle Maskottchen des YueScript-Projekts. Man findet sie meistens auf einer Mondsichel sitzend, an ihrem Laptop tüftelnd – natürlich YueScript schreibend. + +Ihr vollständiger Titel ist Xiaoyu das Cyber-Kaninchen (机兔小玉), und sie verkörpert alles, was YueScript sein möchte: elegant, ausdrucksstark und ein kleines bisschen verspielt. + +Xiaoyu wurde von **[Tyson Tan](https://tysontan.com)** entworfen und illustriert, der sie großzügigerweise kostenlos für das Projekt erstellt hat – wofür wir unglaublich dankbar sind. + +## Bilder + +Hochauflösende Kunstwerke stehen unten zum Download bereit. Klicken Sie auf ein Bild, um es in voller Größe zu öffnen. + +### Vollständiges Kunstwerk + + + Xiaoyu — vollständiges Kunstwerk mit Hintergrund + + +

Vollständiges PNG herunterladen

+ +### Transparenter Hintergrund + + + Xiaoyu — transparenter Hintergrund + + +

Transparentes PNG herunterladen

+ +### Gezippte .kra-Datei + +

Gezippte .kra-Datei herunterladen

+ +## Lizenz + +Xiaoyu ist unter der [MIT-Lizenz](https://opensource.org/licenses/MIT) und der Creative-Commons-Lizenz [CC‑BY‑SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) doppelt lizenziert. diff --git a/doc/docs/de/doc/reference/the-yuescript-library.md b/doc/docs/de/doc/reference/the-yuescript-library.md deleted file mode 100644 index 0c371bf..0000000 --- a/doc/docs/de/doc/reference/the-yuescript-library.md +++ /dev/null @@ -1,860 +0,0 @@ -# Die YueScript-Bibliothek - -Zugriff in Lua über `local yue = require("yue")`. - -## yue - -**Beschreibung:** - -Die YueScript-Sprachbibliothek. - -### version - -**Typ:** Feld. - -**Beschreibung:** - -Die YueScript-Version. - -**Signatur:** - -```lua -version: string -``` - -### dirsep - -**Typ:** Feld. - -**Beschreibung:** - -Der Dateitrennzeichen-String der aktuellen Plattform. - -**Signatur:** - -```lua -dirsep: string -``` - -### yue_compiled - -**Typ:** Feld. - -**Beschreibung:** - -Der Cache für kompilierten Modulcode. - -**Signatur:** - -```lua -yue_compiled: {string: string} -``` - -### to_lua - -**Typ:** Funktion. - -**Beschreibung:** - -Die YueScript-Compilerfunktion. Sie kompiliert YueScript-Code zu Lua-Code. - -**Signatur:** - -```lua -to_lua: function(code: string, config?: Config): - --[[codes]] string | nil, - --[[error]] string | nil, - --[[globals]] {{string, integer, integer}} | nil -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | --------------------------------- | -| code | string | Der YueScript-Code. | -| config | Config | [Optional] Die Compiler-Optionen. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -| string \| nil | Der kompilierte Lua-Code oder `nil`, falls die Kompilierung fehlgeschlagen ist. | -| string \| nil | Die Fehlermeldung oder `nil`, falls die Kompilierung erfolgreich war. | -| {{string, integer, integer}} \| nil | Die globalen Variablen im Code (mit Name, Zeile und Spalte) oder `nil`, wenn die Compiler-Option `lint_global` false ist. | - -### file_exist - -**Typ:** Funktion. - -**Beschreibung:** - -Prüft, ob eine Quelldatei existiert. Kann überschrieben werden, um das Verhalten anzupassen. - -**Signatur:** - -```lua -file_exist: function(filename: string): boolean -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | -------------- | -| filename | string | Der Dateiname. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | ----------------------- | -| boolean | Ob die Datei existiert. | - -### read_file - -**Typ:** Funktion. - -**Beschreibung:** - -Liest eine Quelldatei. Kann überschrieben werden, um das Verhalten anzupassen. - -**Signatur:** - -```lua -read_file: function(filename: string): string -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | -------------- | -| filename | string | Der Dateiname. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | ---------------- | -| string | Der Dateiinhalt. | - -### insert_loader - -**Typ:** Funktion. - -**Beschreibung:** - -Fügt den YueScript-Loader in die Package-Loader (Searcher) ein. - -**Signatur:** - -```lua -insert_loader: function(pos?: integer): boolean -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------- | ---------------------------------------------------------------------- | -| pos | integer | [Optional] Position, an der der Loader eingefügt wird. Standard ist 3. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | ------------------------------------------------------------------------------------ | -| boolean | Ob der Loader erfolgreich eingefügt wurde. Scheitert, wenn er bereits eingefügt ist. | - -### remove_loader - -**Typ:** Funktion. - -**Beschreibung:** - -Entfernt den YueScript-Loader aus den Package-Loadern (Searchern). - -**Signatur:** - -```lua -remove_loader: function(): boolean -``` - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | --------------------------------------------------------------------------------- | -| boolean | Ob der Loader erfolgreich entfernt wurde. Scheitert, wenn er nicht eingefügt ist. | - -### loadstring - -**Typ:** Funktion. - -**Beschreibung:** - -Lädt YueScript-Code aus einem String in eine Funktion. - -**Signatur:** - -```lua -loadstring: function(input: string, chunkname: string, env: table, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | --------------------------------- | -| input | string | Der YueScript-Code. | -| chunkname | string | Der Name des Code-Chunks. | -| env | table | Die Environment-Tabelle. | -| config | Config | [Optional] Die Compiler-Optionen. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| --------------- | --------------------------------------------------------------------- | -| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | -| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | - -### loadstring - -**Typ:** Funktion. - -**Beschreibung:** - -Lädt YueScript-Code aus einem String in eine Funktion. - -**Signatur:** - -```lua -loadstring: function(input: string, chunkname: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | --------------------------------- | -| input | string | Der YueScript-Code. | -| chunkname | string | Der Name des Code-Chunks. | -| config | Config | [Optional] Die Compiler-Optionen. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| --------------- | --------------------------------------------------------------------- | -| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | -| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | - -### loadstring - -**Typ:** Funktion. - -**Beschreibung:** - -Lädt YueScript-Code aus einem String in eine Funktion. - -**Signatur:** - -```lua -loadstring: function(input: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | --------------------------------- | -| input | string | Der YueScript-Code. | -| config | Config | [Optional] Die Compiler-Optionen. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| --------------- | --------------------------------------------------------------------- | -| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | -| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | - -### loadfile - -**Typ:** Funktion. - -**Beschreibung:** - -Lädt YueScript-Code aus einer Datei in eine Funktion. - -**Signatur:** - -```lua -loadfile: function(filename: string, env: table, config?: Config): - nil | function(...: any): (any...), - string | nil -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | --------------------------------- | -| filename | string | Der Dateiname. | -| env | table | Die Environment-Tabelle. | -| config | Config | [Optional] Die Compiler-Optionen. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| --------------- | --------------------------------------------------------------------- | -| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | -| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | - -### loadfile - -**Typ:** Funktion. - -**Beschreibung:** - -Lädt YueScript-Code aus einer Datei in eine Funktion. - -**Signatur:** - -```lua -loadfile: function(filename: string, config?: Config): - nil | function(...: any): (any...), - string | nil -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | --------------------------------- | -| filename | string | Der Dateiname. | -| config | Config | [Optional] Die Compiler-Optionen. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| --------------- | --------------------------------------------------------------------- | -| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | -| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | - -### dofile - -**Typ:** Funktion. - -**Beschreibung:** - -Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. - -**Signatur:** - -```lua -dofile: function(filename: string, env: table, config?: Config): any... -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | --------------------------------- | -| filename | string | Der Dateiname. | -| env | table | Die Environment-Tabelle. | -| config | Config | [Optional] Die Compiler-Optionen. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | ----------------------------------------- | -| any... | Die Rückgabewerte der geladenen Funktion. | - -### dofile - -**Typ:** Funktion. - -**Beschreibung:** - -Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. - -**Signatur:** - -```lua -dofile: function(filename: string, config?: Config): any... -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | --------------------------------- | -| filename | string | Der Dateiname. | -| config | Config | [Optional] Die Compiler-Optionen. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | ----------------------------------------- | -| any... | Die Rückgabewerte der geladenen Funktion. | - -### find_modulepath - -**Typ:** Funktion. - -**Beschreibung:** - -Löst den YueScript-Modulnamen in einen Dateipfad auf. - -**Signatur:** - -```lua -find_modulepath: function(name: string): string -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | -------------- | -| name | string | Der Modulname. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | -------------- | -| string | Der Dateipfad. | - -### pcall - -**Typ:** Funktion. - -**Beschreibung:** - -Ruft eine Funktion im geschützten Modus auf. -Fängt Fehler ab und gibt einen Statuscode sowie Ergebnisse oder ein Fehlerobjekt zurück. -Schreibt die Fehlerzeilennummer bei Fehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. - -**Signatur:** - -```lua -pcall: function(f: function, ...: any): boolean, any... -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | -------- | --------------------------- | -| f | function | Die aufzurufende Funktion. | -| ... | any | Argumente für die Funktion. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ------------ | ---------------------------------------------------- | -| boolean, ... | Statuscode und Funktionsresultate oder Fehlerobjekt. | - -### require - -**Typ:** Funktion. - -**Beschreibung:** - -Lädt ein Modul (Lua oder YueScript). -Schreibt die Fehlerzeilennummer auf die ursprüngliche Zeilennummer im YueScript-Code um, wenn das Modul ein YueScript-Modul ist und das Laden fehlschlägt. - -**Signatur:** - -```lua -require: function(name: string): any... -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | -------------------------------- | -| modname | string | Der Name des zu ladenden Moduls. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| any | Der Wert in `package.loaded[modname]`, falls das Modul bereits geladen ist. Andernfalls wird ein Loader gesucht und der finale Wert von `package.loaded[modname]` sowie Loader-Daten als zweites Ergebnis zurückgegeben. | - -### p - -**Typ:** Funktion. - -**Beschreibung:** - -Inspiziert die Struktur der übergebenen Werte und gibt String-Repräsentationen aus. - -**Signatur:** - -```lua -p: function(...: any) -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | --- | ---------------------------- | -| ... | any | Die zu inspizierenden Werte. | - -### options - -**Typ:** Feld. - -**Beschreibung:** - -Die aktuellen Compiler-Optionen. - -**Signatur:** - -```lua -options: Config.Options -``` - -### traceback - -**Typ:** Funktion. - -**Beschreibung:** - -Die Traceback-Funktion, die Stacktrace-Zeilennummern auf die ursprünglichen Zeilennummern im YueScript-Code umschreibt. - -**Signatur:** - -```lua -traceback: function(message: string): string -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | ------------------------ | -| message | string | Die Traceback-Nachricht. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | --------------------------------------- | -| string | Die umgeschriebene Traceback-Nachricht. | - -### is_ast - -**Typ:** Funktion. - -**Beschreibung:** - -Prüft, ob der Code dem angegebenen AST entspricht. - -**Signatur:** - -```lua -is_ast: function(astName: string, code: string): boolean -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | ------------- | -| astName | string | Der AST-Name. | -| code | string | Der Code. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | ------------------------------- | -| boolean | Ob der Code dem AST entspricht. | - -### AST - -**Typ:** Feld. - -**Beschreibung:** - -Die AST-Typdefinition mit Name, Zeile, Spalte und Unterknoten. - -**Signatur:** - -```lua -type AST = {string, integer, integer, any} -``` - -### to_ast - -**Typ:** Funktion. - -**Beschreibung:** - -Konvertiert Code in AST. - -**Signatur:** - -```lua -to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): - --[[AST]] AST | nil, - --[[error]] nil | string -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| -------------- | ------- | -------------------------------------------------------------------------------------------- | -| code | string | Der Code. | -| flattenLevel | integer | [Optional] Der Flatten-Level. Höher bedeutet mehr Flattening. Standard ist 0. Maximum ist 2. | -| astName | string | [Optional] Der AST-Name. Standard ist "File". | -| reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist false. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ------------- | ---------------------------------------------------------------------- | -| AST \| nil | Der AST oder `nil`, falls die Konvertierung fehlgeschlagen ist. | -| string \| nil | Die Fehlermeldung oder `nil`, falls die Konvertierung erfolgreich war. | - -### format - -**Typ:** Funktion. - -**Beschreibung:** - -Formatiert den YueScript-Code. - -**Signatur:** - -```lua -format: function(code: string, tabSize?: number, reserveComment?: boolean): string -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| -------------- | ------- | ---------------------------------------------------------------------------------- | -| code | string | Der Code. | -| tabSize | integer | [Optional] Die Tab-Größe. Standard ist 4. | -| reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist true. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | --------------------- | -| string | Der formatierte Code. | - -### \_\_call - -**Typ:** Metamethod. - -**Beschreibung:** - -Required das YueScript-Modul. -Schreibt die Fehlerzeilennummer bei Ladefehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. - -**Signatur:** - -```lua -metamethod __call: function(self: yue, module: string): any... -``` - -**Parameter:** - -| Parameter | Typ | Beschreibung | -| --------- | ------ | -------------- | -| module | string | Der Modulname. | - -**Rückgabe:** - -| Rückgabetyp | Beschreibung | -| ----------- | -------------- | -| any | Der Modulwert. | - -## Config - -**Beschreibung:** - -Die Compiler-Optionen. - -### lint_global - -**Typ:** Feld. - -**Beschreibung:** - -Ob der Compiler die globalen Variablen im Code sammeln soll. - -**Signatur:** - -```lua -lint_global: boolean -``` - -### implicit_return_root - -**Typ:** Feld. - -**Beschreibung:** - -Ob der Compiler für den Root-Codeblock ein implizites Return verwenden soll. - -**Signatur:** - -```lua -implicit_return_root: boolean -``` - -### reserve_line_number - -**Typ:** Feld. - -**Beschreibung:** - -Ob der Compiler die ursprüngliche Zeilennummer im kompilierten Code beibehalten soll. - -**Signatur:** - -```lua -reserve_line_number: boolean -``` - -### reserve_comment - -**Typ:** Feld. - -**Beschreibung:** - -Ob der Compiler die ursprünglichen Kommentare im kompilierten Code beibehalten soll. - -**Signatur:** - -```lua -reserve_comment: boolean -``` - -### space_over_tab - -**Typ:** Feld. - -**Beschreibung:** - -Ob der Compiler statt Tabzeichen Leerzeichen verwenden soll. - -**Signatur:** - -```lua -space_over_tab: boolean -``` - -### same_module - -**Typ:** Feld. - -**Beschreibung:** - -Ob der Compiler den zu kompilierenden Code als dasselbe aktuell kompilierte Modul behandeln soll. Nur für internen Gebrauch. - -**Signatur:** - -```lua -same_module: boolean -``` - -### line_offset - -**Typ:** Feld. - -**Beschreibung:** - -Ob die Compiler-Fehlermeldung einen Zeilennummern-Offset enthalten soll. Nur für internen Gebrauch. - -**Signatur:** - -```lua -line_offset: integer -``` - -### yue.Config.LuaTarget - -**Typ:** Enumeration. - -**Beschreibung:** - -Die Ziel-Lua-Version. - -**Signatur:** - -```lua -enum LuaTarget - "5.1" - "5.2" - "5.3" - "5.4" - "5.5" -end -``` - -### options - -**Typ:** Feld. - -**Beschreibung:** - -Zusätzliche Optionen für die Kompilierung. - -**Signatur:** - -```lua -options: Options -``` - -## Options - -**Beschreibung:** - -Zusätzliche Compiler-Optionen. - -### target - -**Typ:** Feld. - -**Beschreibung:** - -Die Ziel-Lua-Version für die Kompilierung. - -**Signatur:** - -```lua -target: LuaTarget -``` - -### path - -**Typ:** Feld. - -**Beschreibung:** - -Zusätzlicher Modul-Suchpfad. - -**Signatur:** - -```lua -path: string -``` - -### dump_locals - -**Typ:** Feld. - -**Beschreibung:** - -Ob lokale Variablen in Traceback-Fehlermeldungen ausgegeben werden sollen. Standard ist false. - -**Signatur:** - -```lua -dump_locals: boolean -``` - -### simplified - -**Typ:** Feld. - -**Beschreibung:** - -Ob Fehlermeldungen vereinfacht werden sollen. Standard ist true. - -**Signatur:** - -```lua -simplified: boolean -``` diff --git a/doc/docs/doc/advanced/the-yuescript-library.md b/doc/docs/doc/advanced/the-yuescript-library.md new file mode 100644 index 0000000..817bfab --- /dev/null +++ b/doc/docs/doc/advanced/the-yuescript-library.md @@ -0,0 +1,860 @@ +# The YueScript Library + +Access it by `local yue = require("yue")` in Lua. + +## yue + +**Description:** + +The YueScript language library. + +### version + +**Type:** Field. + +**Description:** + +The YueScript version. + +**Signature:** + +```lua +version: string +``` + +### dirsep + +**Type:** Field. + +**Description:** + +The file separator for the current platform. + +**Signature:** + +```lua +dirsep: string +``` + +### yue_compiled + +**Type:** Field. + +**Description:** + +The compiled module code cache. + +**Signature:** + +```lua +yue_compiled: {string: string} +``` + +### to_lua + +**Type:** Function. + +**Description:** + +The YueScript compiling function. It compiles the YueScript code to Lua code. + +**Signature:** + +```lua +to_lua: function(code: string, config?: Config): + --[[codes]] string | nil, + --[[error]] string | nil, + --[[globals]] {{string, integer, integer}} | nil +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | -------------------------------- | +| code | string | The YueScript code. | +| config | Config | [Optional] The compiler options. | + +**Returns:** + +| Return Type | Description | +| ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | +| string \| nil | The compiled Lua code, or nil if the compilation failed. | +| string \| nil | The error message, or nil if the compilation succeeded. | +| {{string, integer, integer}} \| nil | The global variables appearing in the code (with name, row and column), or nil if the compiler option `lint_global` is false. | + +### file_exist + +**Type:** Function. + +**Description:** + +The source file existence checking function. Can be overridden to customize the behavior. + +**Signature:** + +```lua +file_exist: function(filename: string): boolean +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | -------------- | +| filename | string | The file name. | + +**Returns:** + +| Return Type | Description | +| ----------- | ------------------------ | +| boolean | Whether the file exists. | + +### read_file + +**Type:** Function. + +**Description:** + +The source file reading function. Can be overridden to customize the behavior. + +**Signature:** + +```lua +read_file: function(filename: string): string +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | -------------- | +| filename | string | The file name. | + +**Returns:** + +| Return Type | Description | +| ----------- | ----------------- | +| string | The file content. | + +### insert_loader + +**Type:** Function. + +**Description:** + +Insert the YueScript loader to the package loaders (searchers). + +**Signature:** + +```lua +insert_loader: function(pos?: integer): boolean +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------- | ----------------------------------------------------------- | +| pos | integer | [Optional] The position to insert the loader. Default is 3. | + +**Returns:** + +| Return Type | Description | +| ----------- | -------------------------------------------------------------------------------------------- | +| boolean | Whether the loader is inserted successfully. It will fail if the loader is already inserted. | + +### remove_loader + +**Type:** Function. + +**Description:** + +Remove the YueScript loader from the package loaders (searchers). + +**Signature:** + +```lua +remove_loader: function(): boolean +``` + +**Returns:** + +| Return Type | Description | +| ----------- | --------------------------------------------------------------------------------------- | +| boolean | Whether the loader is removed successfully. It will fail if the loader is not inserted. | + +### loadstring + +**Type:** Function. + +**Description:** + +Loads YueScript code from a string into a function. + +**Signature:** + +```lua +loadstring: function(input: string, chunkname: string, env: table, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | -------------------------------- | +| input | string | The YueScript code. | +| chunkname | string | The name of the code chunk. | +| env | table | The environment table. | +| config | Config | [Optional] The compiler options. | + +**Returns:** + +| Return Type | Description | +| --------------- | --------------------------------------------------- | +| function \| nil | The loaded function, or nil if the loading failed. | +| string \| nil | The error message, or nil if the loading succeeded. | + +### loadstring + +**Type:** Function. + +**Description:** + +Loads YueScript code from a string into a function. + +**Signature:** + +```lua +loadstring: function(input: string, chunkname: string, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | -------------------------------- | +| input | string | The YueScript code. | +| chunkname | string | The name of the code chunk. | +| config | Config | [Optional] The compiler options. | + +**Returns:** + +| Return Type | Description | +| --------------- | --------------------------------------------------- | +| function \| nil | The loaded function, or nil if the loading failed. | +| string \| nil | The error message, or nil if the loading succeeded. | + +### loadstring + +**Type:** Function. + +**Description:** + +Loads YueScript code from a string into a function. + +**Signature:** + +```lua +loadstring: function(input: string, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | -------------------------------- | +| input | string | The YueScript code. | +| config | Config | [Optional] The compiler options. | + +**Returns:** + +| Return Type | Description | +| --------------- | --------------------------------------------------- | +| function \| nil | The loaded function, or nil if the loading failed. | +| string \| nil | The error message, or nil if the loading succeeded. | + +### loadfile + +**Type:** Function. + +**Description:** + +Loads YueScript code from a file into a function. + +**Signature:** + +```lua +loadfile: function(filename: string, env: table, config?: Config): + nil | function(...: any): (any...), + string | nil +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | -------------------------------- | +| filename | string | The file name. | +| env | table | The environment table. | +| config | Config | [Optional] The compiler options. | + +**Returns:** + +| Return Type | Description | +| --------------- | --------------------------------------------------- | +| function \| nil | The loaded function, or nil if the loading failed. | +| string \| nil | The error message, or nil if the loading succeeded. | + +### loadfile + +**Type:** Function. + +**Description:** + +Loads YueScript code from a file into a function. + +**Signature:** + +```lua +loadfile: function(filename: string, config?: Config): + nil | function(...: any): (any...), + string | nil +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | -------------------------------- | +| filename | string | The file name. | +| config | Config | [Optional] The compiler options. | + +**Returns:** + +| Return Type | Description | +| --------------- | --------------------------------------------------- | +| function \| nil | The loaded function, or nil if the loading failed. | +| string \| nil | The error message, or nil if the loading succeeded. | + +### dofile + +**Type:** Function. + +**Description:** + +Loads YueScript code from a file into a function and executes it. + +**Signature:** + +```lua +dofile: function(filename: string, env: table, config?: Config): any... +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | -------------------------------- | +| filename | string | The file name. | +| env | table | The environment table. | +| config | Config | [Optional] The compiler options. | + +**Returns:** + +| Return Type | Description | +| ----------- | ----------------------------------------- | +| any... | The return values of the loaded function. | + +### dofile + +**Type:** Function. + +**Description:** + +Loads YueScript code from a file into a function and executes it. + +**Signature:** + +```lua +dofile: function(filename: string, config?: Config): any... +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | -------------------------------- | +| filename | string | The file name. | +| config | Config | [Optional] The compiler options. | + +**Returns:** + +| Return Type | Description | +| ----------- | ----------------------------------------- | +| any... | The return values of the loaded function. | + +### find_modulepath + +**Type:** Function. + +**Description:** + +Resolves the YueScript module name to the file path. + +**Signature:** + +```lua +find_modulepath: function(name: string): string +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | ---------------- | +| name | string | The module name. | + +**Returns:** + +| Return Type | Description | +| ----------- | -------------- | +| string | The file path. | + +### pcall + +**Type:** Function. + +**Description:** + +Calls a function in protected mode. +Catches any errors and returns a status code and results or error object. +Rewrites the error line number to the original line number in the YueScript code when errors occur. + +**Signature:** + +```lua +pcall: function(f: function, ...: any): boolean, any... +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | -------- | ---------------------------------- | +| f | function | The function to call. | +| ... | any | Arguments to pass to the function. | + +**Returns:** + +| Return Type | Description | +| ------------ | ------------------------------------------------- | +| boolean, ... | Status code and function results or error object. | + +### require + +**Type:** Function. + +**Description:** + +Loads a given module. Can be either a Lua module or a YueScript module. +Rewrites the error line number to the original line number in the YueScript code if the module is a YueScript module and loading fails. + +**Signature:** + +```lua +require: function(name: string): any... +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | ------------------------------- | +| modname | string | The name of the module to load. | + +**Returns:** + +| Return Type | Description | +| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| any | The value stored at package.loaded[modname] if the module is already loaded.Otherwise, tries to find a loader and returns the final value of package.loaded[modname] and a loader data as a second result. | + +### p + +**Type:** Function. + +**Description:** + +Inspects the structures of the passed values and prints string representations. + +**Signature:** + +```lua +p: function(...: any) +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ---- | ---------------------- | +| ... | any | The values to inspect. | + +### options + +**Type:** Field. + +**Description:** + +The current compiler options. + +**Signature:** + +```lua +options: Config.Options +``` + +### traceback + +**Type:** Function. + +**Description:** + +The traceback function that rewrites the stack trace line numbers to the original line numbers in the YueScript code. + +**Signature:** + +```lua +traceback: function(message: string): string +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | ---------------------- | +| message | string | The traceback message. | + +**Returns:** + +| Return Type | Description | +| ----------- | -------------------------------- | +| string | The rewritten traceback message. | + +### is_ast + +**Type:** Function. + +**Description:** + +Checks whether the code matches the specified AST. + +**Signature:** + +```lua +is_ast: function(astName: string, code: string): boolean +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | ------------- | +| astName | string | The AST name. | +| code | string | The code. | + +**Returns:** + +| Return Type | Description | +| ----------- | --------------------------------- | +| boolean | Whether the code matches the AST. | + +### AST + +**Type:** Field. + +**Description:** + +The AST type definition with name, row, column and sub nodes. + +**Signature:** + +```lua +type AST = {string, integer, integer, any} +``` + +### to_ast + +**Type:** Function. + +**Description:** + +Converts the code to the AST. + +**Signature:** + +```lua +to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): + --[[AST]] AST | nil, + --[[error]] nil | string +``` + +**Parameters:** + +| Parameter | Type | Description | +| -------------- | ------- | --------------------------------------------------------------------------------------------- | +| code | string | The code. | +| flattenLevel | integer | [Optional] The flatten level. Higher level means more flattening. Default is 0. Maximum is 2. | +| astName | string | [Optional] The AST name. Default is "File". | +| reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is false. | + +**Returns:** + +| Return Type | Description | +| ------------- | ------------------------------------------------------ | +| AST \| nil | The AST, or nil if the conversion failed. | +| string \| nil | The error message, or nil if the conversion succeeded. | + +### format + +**Type:** Function. + +**Description:** + +Formats the YueScript code. + +**Signature:** + +```lua +format: function(code: string, tabSize?: number, reserveComment?: boolean): string +``` + +**Parameters:** + +| Parameter | Type | Description | +| -------------- | ------- | --------------------------------------------------------------------- | +| code | string | The code. | +| tabSize | integer | [Optional] The tab size. Default is 4. | +| reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is true. | + +**Returns:** + +| Return Type | Description | +| ----------- | ------------------- | +| string | The formatted code. | + +### \_\_call + +**Type:** Metamethod. + +**Description:** + +Requires the YueScript module. +Rewrites the error line number to the original line number in the YueScript code when loading fails. + +**Signature:** + +```lua +metamethod __call: function(self: yue, module: string): any... +``` + +**Parameters:** + +| Parameter | Type | Description | +| --------- | ------ | ---------------- | +| module | string | The module name. | + +**Returns:** + +| Return Type | Description | +| ----------- | ----------------- | +| any | The module value. | + +## Config + +**Description:** + +The compiler compile options. + +### lint_global + +**Type:** Field. + +**Description:** + +Whether the compiler should collect the global variables appearing in the code. + +**Signature:** + +```lua +lint_global: boolean +``` + +### implicit_return_root + +**Type:** Field. + +**Description:** + +Whether the compiler should do an implicit return for the root code block. + +**Signature:** + +```lua +implicit_return_root: boolean +``` + +### reserve_line_number + +**Type:** Field. + +**Description:** + +Whether the compiler should reserve the original line number in the compiled code. + +**Signature:** + +```lua +reserve_line_number: boolean +``` + +### reserve_comment + +**Type:** Field. + +**Description:** + +Whether the compiler should reserve the original comments in the compiled code. + +**Signature:** + +```lua +reserve_comment: boolean +``` + +### space_over_tab + +**Type:** Field. + +**Description:** + +Whether the compiler should use the space character instead of the tab character in the compiled code. + +**Signature:** + +```lua +space_over_tab: boolean +``` + +### same_module + +**Type:** Field. + +**Description:** + +Whether the compiler should treat the code to be compiled as the same currently being compiled module. For internal use only. + +**Signature:** + +```lua +same_module: boolean +``` + +### line_offset + +**Type:** Field. + +**Description:** + +Whether the compiler error message should include the line number offset. For internal use only. + +**Signature:** + +```lua +line_offset: integer +``` + +### yue.Config.LuaTarget + +**Type:** Enumeration. + +**Description:** + +The target Lua version enumeration. + +**Signature:** + +```lua +enum LuaTarget + "5.1" + "5.2" + "5.3" + "5.4" + "5.5" +end +``` + +### options + +**Type:** Field. + +**Description:** + +The extra options to be passed to the compilation function. + +**Signature:** + +```lua +options: Options +``` + +## Options + +**Description:** + +The extra compiler options definition. + +### target + +**Type:** Field. + +**Description:** + +The target Lua version for the compilation. + +**Signature:** + +```lua +target: LuaTarget +``` + +### path + +**Type:** Field. + +**Description:** + +The extra module search path. + +**Signature:** + +```lua +path: string +``` + +### dump_locals + +**Type:** Field. + +**Description:** + +Whether to dump the local variables in the traceback error message. Default is false. + +**Signature:** + +```lua +dump_locals: boolean +``` + +### simplified + +**Type:** Field. + +**Description:** + +Whether to simplify the error message. Default is true. + +**Signature:** + +```lua +simplified: boolean +``` diff --git a/doc/docs/doc/reference/mascot.md b/doc/docs/doc/reference/mascot.md new file mode 100644 index 0000000..028d17f --- /dev/null +++ b/doc/docs/doc/reference/mascot.md @@ -0,0 +1,39 @@ +# Mascot - Xiaoyu + +## About + +Xiaoyu the Cyber Rabbit + +Xiaoyu (小玉, "little jade") is a cyber rabbit and the official mascot of the YueScript project. She can usually be found perched atop a crescent moon, tinkering away on her laptop - writing YueScript, naturally. + +Her full title is Xiaoyu the Cyber Rabbit (机兔小玉), and she embodies everything YueScript strives to be: elegant, expressive, and a little bit playful. + +Xiaoyu was designed and illustrated by **[Tyson Tan](https://tysontan.com)**, who generously created her for the project free of charge - something we're incredibly grateful for. + +## Images + +Full‑resolution artwork is available for download below. Click any image to open it at full size. + +### Full Artwork + + + Xiaoyu — full artwork with background + + +

Download full-size PNG

+ +### Transparent Background + + + Xiaoyu — transparent background + + +

Download transparent PNG

+ +### Zipped .kra File + +

Download zipped .kra file

+ +## License + +Xiaoyu is dual‑licensed under the [MIT License](https://opensource.org/licenses/MIT) and the Creative Commons [CC‑BY‑SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). diff --git a/doc/docs/doc/reference/the-yuescript-library.md b/doc/docs/doc/reference/the-yuescript-library.md deleted file mode 100644 index 817bfab..0000000 --- a/doc/docs/doc/reference/the-yuescript-library.md +++ /dev/null @@ -1,860 +0,0 @@ -# The YueScript Library - -Access it by `local yue = require("yue")` in Lua. - -## yue - -**Description:** - -The YueScript language library. - -### version - -**Type:** Field. - -**Description:** - -The YueScript version. - -**Signature:** - -```lua -version: string -``` - -### dirsep - -**Type:** Field. - -**Description:** - -The file separator for the current platform. - -**Signature:** - -```lua -dirsep: string -``` - -### yue_compiled - -**Type:** Field. - -**Description:** - -The compiled module code cache. - -**Signature:** - -```lua -yue_compiled: {string: string} -``` - -### to_lua - -**Type:** Function. - -**Description:** - -The YueScript compiling function. It compiles the YueScript code to Lua code. - -**Signature:** - -```lua -to_lua: function(code: string, config?: Config): - --[[codes]] string | nil, - --[[error]] string | nil, - --[[globals]] {{string, integer, integer}} | nil -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | -------------------------------- | -| code | string | The YueScript code. | -| config | Config | [Optional] The compiler options. | - -**Returns:** - -| Return Type | Description | -| ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -| string \| nil | The compiled Lua code, or nil if the compilation failed. | -| string \| nil | The error message, or nil if the compilation succeeded. | -| {{string, integer, integer}} \| nil | The global variables appearing in the code (with name, row and column), or nil if the compiler option `lint_global` is false. | - -### file_exist - -**Type:** Function. - -**Description:** - -The source file existence checking function. Can be overridden to customize the behavior. - -**Signature:** - -```lua -file_exist: function(filename: string): boolean -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | -------------- | -| filename | string | The file name. | - -**Returns:** - -| Return Type | Description | -| ----------- | ------------------------ | -| boolean | Whether the file exists. | - -### read_file - -**Type:** Function. - -**Description:** - -The source file reading function. Can be overridden to customize the behavior. - -**Signature:** - -```lua -read_file: function(filename: string): string -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | -------------- | -| filename | string | The file name. | - -**Returns:** - -| Return Type | Description | -| ----------- | ----------------- | -| string | The file content. | - -### insert_loader - -**Type:** Function. - -**Description:** - -Insert the YueScript loader to the package loaders (searchers). - -**Signature:** - -```lua -insert_loader: function(pos?: integer): boolean -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------- | ----------------------------------------------------------- | -| pos | integer | [Optional] The position to insert the loader. Default is 3. | - -**Returns:** - -| Return Type | Description | -| ----------- | -------------------------------------------------------------------------------------------- | -| boolean | Whether the loader is inserted successfully. It will fail if the loader is already inserted. | - -### remove_loader - -**Type:** Function. - -**Description:** - -Remove the YueScript loader from the package loaders (searchers). - -**Signature:** - -```lua -remove_loader: function(): boolean -``` - -**Returns:** - -| Return Type | Description | -| ----------- | --------------------------------------------------------------------------------------- | -| boolean | Whether the loader is removed successfully. It will fail if the loader is not inserted. | - -### loadstring - -**Type:** Function. - -**Description:** - -Loads YueScript code from a string into a function. - -**Signature:** - -```lua -loadstring: function(input: string, chunkname: string, env: table, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | -------------------------------- | -| input | string | The YueScript code. | -| chunkname | string | The name of the code chunk. | -| env | table | The environment table. | -| config | Config | [Optional] The compiler options. | - -**Returns:** - -| Return Type | Description | -| --------------- | --------------------------------------------------- | -| function \| nil | The loaded function, or nil if the loading failed. | -| string \| nil | The error message, or nil if the loading succeeded. | - -### loadstring - -**Type:** Function. - -**Description:** - -Loads YueScript code from a string into a function. - -**Signature:** - -```lua -loadstring: function(input: string, chunkname: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | -------------------------------- | -| input | string | The YueScript code. | -| chunkname | string | The name of the code chunk. | -| config | Config | [Optional] The compiler options. | - -**Returns:** - -| Return Type | Description | -| --------------- | --------------------------------------------------- | -| function \| nil | The loaded function, or nil if the loading failed. | -| string \| nil | The error message, or nil if the loading succeeded. | - -### loadstring - -**Type:** Function. - -**Description:** - -Loads YueScript code from a string into a function. - -**Signature:** - -```lua -loadstring: function(input: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | -------------------------------- | -| input | string | The YueScript code. | -| config | Config | [Optional] The compiler options. | - -**Returns:** - -| Return Type | Description | -| --------------- | --------------------------------------------------- | -| function \| nil | The loaded function, or nil if the loading failed. | -| string \| nil | The error message, or nil if the loading succeeded. | - -### loadfile - -**Type:** Function. - -**Description:** - -Loads YueScript code from a file into a function. - -**Signature:** - -```lua -loadfile: function(filename: string, env: table, config?: Config): - nil | function(...: any): (any...), - string | nil -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | -------------------------------- | -| filename | string | The file name. | -| env | table | The environment table. | -| config | Config | [Optional] The compiler options. | - -**Returns:** - -| Return Type | Description | -| --------------- | --------------------------------------------------- | -| function \| nil | The loaded function, or nil if the loading failed. | -| string \| nil | The error message, or nil if the loading succeeded. | - -### loadfile - -**Type:** Function. - -**Description:** - -Loads YueScript code from a file into a function. - -**Signature:** - -```lua -loadfile: function(filename: string, config?: Config): - nil | function(...: any): (any...), - string | nil -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | -------------------------------- | -| filename | string | The file name. | -| config | Config | [Optional] The compiler options. | - -**Returns:** - -| Return Type | Description | -| --------------- | --------------------------------------------------- | -| function \| nil | The loaded function, or nil if the loading failed. | -| string \| nil | The error message, or nil if the loading succeeded. | - -### dofile - -**Type:** Function. - -**Description:** - -Loads YueScript code from a file into a function and executes it. - -**Signature:** - -```lua -dofile: function(filename: string, env: table, config?: Config): any... -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | -------------------------------- | -| filename | string | The file name. | -| env | table | The environment table. | -| config | Config | [Optional] The compiler options. | - -**Returns:** - -| Return Type | Description | -| ----------- | ----------------------------------------- | -| any... | The return values of the loaded function. | - -### dofile - -**Type:** Function. - -**Description:** - -Loads YueScript code from a file into a function and executes it. - -**Signature:** - -```lua -dofile: function(filename: string, config?: Config): any... -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | -------------------------------- | -| filename | string | The file name. | -| config | Config | [Optional] The compiler options. | - -**Returns:** - -| Return Type | Description | -| ----------- | ----------------------------------------- | -| any... | The return values of the loaded function. | - -### find_modulepath - -**Type:** Function. - -**Description:** - -Resolves the YueScript module name to the file path. - -**Signature:** - -```lua -find_modulepath: function(name: string): string -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | ---------------- | -| name | string | The module name. | - -**Returns:** - -| Return Type | Description | -| ----------- | -------------- | -| string | The file path. | - -### pcall - -**Type:** Function. - -**Description:** - -Calls a function in protected mode. -Catches any errors and returns a status code and results or error object. -Rewrites the error line number to the original line number in the YueScript code when errors occur. - -**Signature:** - -```lua -pcall: function(f: function, ...: any): boolean, any... -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | -------- | ---------------------------------- | -| f | function | The function to call. | -| ... | any | Arguments to pass to the function. | - -**Returns:** - -| Return Type | Description | -| ------------ | ------------------------------------------------- | -| boolean, ... | Status code and function results or error object. | - -### require - -**Type:** Function. - -**Description:** - -Loads a given module. Can be either a Lua module or a YueScript module. -Rewrites the error line number to the original line number in the YueScript code if the module is a YueScript module and loading fails. - -**Signature:** - -```lua -require: function(name: string): any... -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | ------------------------------- | -| modname | string | The name of the module to load. | - -**Returns:** - -| Return Type | Description | -| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| any | The value stored at package.loaded[modname] if the module is already loaded.Otherwise, tries to find a loader and returns the final value of package.loaded[modname] and a loader data as a second result. | - -### p - -**Type:** Function. - -**Description:** - -Inspects the structures of the passed values and prints string representations. - -**Signature:** - -```lua -p: function(...: any) -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ---- | ---------------------- | -| ... | any | The values to inspect. | - -### options - -**Type:** Field. - -**Description:** - -The current compiler options. - -**Signature:** - -```lua -options: Config.Options -``` - -### traceback - -**Type:** Function. - -**Description:** - -The traceback function that rewrites the stack trace line numbers to the original line numbers in the YueScript code. - -**Signature:** - -```lua -traceback: function(message: string): string -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | ---------------------- | -| message | string | The traceback message. | - -**Returns:** - -| Return Type | Description | -| ----------- | -------------------------------- | -| string | The rewritten traceback message. | - -### is_ast - -**Type:** Function. - -**Description:** - -Checks whether the code matches the specified AST. - -**Signature:** - -```lua -is_ast: function(astName: string, code: string): boolean -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | ------------- | -| astName | string | The AST name. | -| code | string | The code. | - -**Returns:** - -| Return Type | Description | -| ----------- | --------------------------------- | -| boolean | Whether the code matches the AST. | - -### AST - -**Type:** Field. - -**Description:** - -The AST type definition with name, row, column and sub nodes. - -**Signature:** - -```lua -type AST = {string, integer, integer, any} -``` - -### to_ast - -**Type:** Function. - -**Description:** - -Converts the code to the AST. - -**Signature:** - -```lua -to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): - --[[AST]] AST | nil, - --[[error]] nil | string -``` - -**Parameters:** - -| Parameter | Type | Description | -| -------------- | ------- | --------------------------------------------------------------------------------------------- | -| code | string | The code. | -| flattenLevel | integer | [Optional] The flatten level. Higher level means more flattening. Default is 0. Maximum is 2. | -| astName | string | [Optional] The AST name. Default is "File". | -| reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is false. | - -**Returns:** - -| Return Type | Description | -| ------------- | ------------------------------------------------------ | -| AST \| nil | The AST, or nil if the conversion failed. | -| string \| nil | The error message, or nil if the conversion succeeded. | - -### format - -**Type:** Function. - -**Description:** - -Formats the YueScript code. - -**Signature:** - -```lua -format: function(code: string, tabSize?: number, reserveComment?: boolean): string -``` - -**Parameters:** - -| Parameter | Type | Description | -| -------------- | ------- | --------------------------------------------------------------------- | -| code | string | The code. | -| tabSize | integer | [Optional] The tab size. Default is 4. | -| reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is true. | - -**Returns:** - -| Return Type | Description | -| ----------- | ------------------- | -| string | The formatted code. | - -### \_\_call - -**Type:** Metamethod. - -**Description:** - -Requires the YueScript module. -Rewrites the error line number to the original line number in the YueScript code when loading fails. - -**Signature:** - -```lua -metamethod __call: function(self: yue, module: string): any... -``` - -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------ | ---------------- | -| module | string | The module name. | - -**Returns:** - -| Return Type | Description | -| ----------- | ----------------- | -| any | The module value. | - -## Config - -**Description:** - -The compiler compile options. - -### lint_global - -**Type:** Field. - -**Description:** - -Whether the compiler should collect the global variables appearing in the code. - -**Signature:** - -```lua -lint_global: boolean -``` - -### implicit_return_root - -**Type:** Field. - -**Description:** - -Whether the compiler should do an implicit return for the root code block. - -**Signature:** - -```lua -implicit_return_root: boolean -``` - -### reserve_line_number - -**Type:** Field. - -**Description:** - -Whether the compiler should reserve the original line number in the compiled code. - -**Signature:** - -```lua -reserve_line_number: boolean -``` - -### reserve_comment - -**Type:** Field. - -**Description:** - -Whether the compiler should reserve the original comments in the compiled code. - -**Signature:** - -```lua -reserve_comment: boolean -``` - -### space_over_tab - -**Type:** Field. - -**Description:** - -Whether the compiler should use the space character instead of the tab character in the compiled code. - -**Signature:** - -```lua -space_over_tab: boolean -``` - -### same_module - -**Type:** Field. - -**Description:** - -Whether the compiler should treat the code to be compiled as the same currently being compiled module. For internal use only. - -**Signature:** - -```lua -same_module: boolean -``` - -### line_offset - -**Type:** Field. - -**Description:** - -Whether the compiler error message should include the line number offset. For internal use only. - -**Signature:** - -```lua -line_offset: integer -``` - -### yue.Config.LuaTarget - -**Type:** Enumeration. - -**Description:** - -The target Lua version enumeration. - -**Signature:** - -```lua -enum LuaTarget - "5.1" - "5.2" - "5.3" - "5.4" - "5.5" -end -``` - -### options - -**Type:** Field. - -**Description:** - -The extra options to be passed to the compilation function. - -**Signature:** - -```lua -options: Options -``` - -## Options - -**Description:** - -The extra compiler options definition. - -### target - -**Type:** Field. - -**Description:** - -The target Lua version for the compilation. - -**Signature:** - -```lua -target: LuaTarget -``` - -### path - -**Type:** Field. - -**Description:** - -The extra module search path. - -**Signature:** - -```lua -path: string -``` - -### dump_locals - -**Type:** Field. - -**Description:** - -Whether to dump the local variables in the traceback error message. Default is false. - -**Signature:** - -```lua -dump_locals: boolean -``` - -### simplified - -**Type:** Field. - -**Description:** - -Whether to simplify the error message. Default is true. - -**Signature:** - -```lua -simplified: boolean -``` diff --git a/doc/docs/id-id/doc/advanced/the-yuescript-library.md b/doc/docs/id-id/doc/advanced/the-yuescript-library.md new file mode 100644 index 0000000..3adfe63 --- /dev/null +++ b/doc/docs/id-id/doc/advanced/the-yuescript-library.md @@ -0,0 +1,860 @@ +# Pustaka YueScript + +Akses dengan `local yue = require("yue")` di Lua. + +## yue + +**Deskripsi:** + +Pustaka bahasa YueScript. + +### version + +**Tipe:** Field. + +**Deskripsi:** + +Versi YueScript. + +**Signature:** + +```lua +version: string +``` + +### dirsep + +**Tipe:** Field. + +**Deskripsi:** + +Pemisah file untuk platform saat ini. + +**Signature:** + +```lua +dirsep: string +``` + +### yue_compiled + +**Tipe:** Field. + +**Deskripsi:** + +Cache kode modul yang telah dikompilasi. + +**Signature:** + +```lua +yue_compiled: {string: string} +``` + +### to_lua + +**Tipe:** Function. + +**Deskripsi:** + +Fungsi kompilasi YueScript. Mengompilasi kode YueScript menjadi kode Lua. + +**Signature:** + +```lua +to_lua: function(code: string, config?: Config): + --[[codes]] string | nil, + --[[error]] string | nil, + --[[globals]] {{string, integer, integer}} | nil +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ------------------------- | +| code | string | Kode YueScript. | +| config | Config | [Opsional] Opsi kompiler. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | +| string \| nil | Kode Lua hasil kompilasi, atau nil jika kompilasi gagal. | +| string \| nil | Pesan error, atau nil jika kompilasi berhasil. | +| {{string, integer, integer}} \| nil | Variabel global yang muncul dalam kode (dengan nama, baris, dan kolom), atau nil jika opsi kompiler `lint_global` bernilai false. | + +### file_exist + +**Tipe:** Function. + +**Deskripsi:** + +Fungsi untuk memeriksa keberadaan file sumber. Dapat ditimpa untuk menyesuaikan perilaku. + +**Signature:** + +```lua +file_exist: function(filename: string): boolean +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ---------- | +| filename | string | Nama file. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | ---------------- | +| boolean | Apakah file ada. | + +### read_file + +**Tipe:** Function. + +**Deskripsi:** + +Fungsi untuk membaca file sumber. Dapat ditimpa untuk menyesuaikan perilaku. + +**Signature:** + +```lua +read_file: function(filename: string): string +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ---------- | +| filename | string | Nama file. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | --------- | +| string | Isi file. | + +### insert_loader + +**Tipe:** Function. + +**Deskripsi:** + +Menyisipkan loader YueScript ke package loaders (searchers). + +**Signature:** + +```lua +insert_loader: function(pos?: integer): boolean +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------- | ------------------------------------------------------------- | +| pos | integer | [Opsional] Posisi untuk menyisipkan loader. Default adalah 3. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | --------------------------------------------------------------------------- | +| boolean | Apakah loader berhasil disisipkan. Akan gagal jika loader sudah disisipkan. | + +### remove_loader + +**Tipe:** Function. + +**Deskripsi:** + +Menghapus loader YueScript dari package loaders (searchers). + +**Signature:** + +```lua +remove_loader: function(): boolean +``` + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | ------------------------------------------------------------------------ | +| boolean | Apakah loader berhasil dihapus. Akan gagal jika loader belum disisipkan. | + +### loadstring + +**Tipe:** Function. + +**Deskripsi:** + +Memuat kode YueScript dari string menjadi fungsi. + +**Signature:** + +```lua +loadstring: function(input: string, chunkname: string, env: table, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ------------------------- | +| input | string | Kode YueScript. | +| chunkname | string | Nama chunk kode. | +| env | table | Tabel environment. | +| config | Config | [Opsional] Opsi kompiler. | + +**Return:** + +| Tipe Return | Deskripsi | +| --------------- | ------------------------------------------------- | +| function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | +| string \| nil | Pesan error, atau nil jika pemuatan berhasil. | + +### loadstring + +**Tipe:** Function. + +**Deskripsi:** + +Memuat kode YueScript dari string menjadi fungsi. + +**Signature:** + +```lua +loadstring: function(input: string, chunkname: string, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ------------------------- | +| input | string | Kode YueScript. | +| chunkname | string | Nama chunk kode. | +| config | Config | [Opsional] Opsi kompiler. | + +**Return:** + +| Tipe Return | Deskripsi | +| --------------- | ------------------------------------------------- | +| function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | +| string \| nil | Pesan error, atau nil jika pemuatan berhasil. | + +### loadstring + +**Tipe:** Function. + +**Deskripsi:** + +Memuat kode YueScript dari string menjadi fungsi. + +**Signature:** + +```lua +loadstring: function(input: string, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ------------------------- | +| input | string | Kode YueScript. | +| config | Config | [Opsional] Opsi kompiler. | + +**Return:** + +| Tipe Return | Deskripsi | +| --------------- | ------------------------------------------------- | +| function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | +| string \| nil | Pesan error, atau nil jika pemuatan berhasil. | + +### loadfile + +**Tipe:** Function. + +**Deskripsi:** + +Memuat kode YueScript dari file menjadi fungsi. + +**Signature:** + +```lua +loadfile: function(filename: string, env: table, config?: Config): + nil | function(...: any): (any...), + string | nil +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ------------------------- | +| filename | string | Nama file. | +| env | table | Tabel environment. | +| config | Config | [Opsional] Opsi kompiler. | + +**Return:** + +| Tipe Return | Deskripsi | +| --------------- | ------------------------------------------------- | +| function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | +| string \| nil | Pesan error, atau nil jika pemuatan berhasil. | + +### loadfile + +**Tipe:** Function. + +**Deskripsi:** + +Memuat kode YueScript dari file menjadi fungsi. + +**Signature:** + +```lua +loadfile: function(filename: string, config?: Config): + nil | function(...: any): (any...), + string | nil +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ------------------------- | +| filename | string | Nama file. | +| config | Config | [Opsional] Opsi kompiler. | + +**Return:** + +| Tipe Return | Deskripsi | +| --------------- | ------------------------------------------------- | +| function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | +| string \| nil | Pesan error, atau nil jika pemuatan berhasil. | + +### dofile + +**Tipe:** Function. + +**Deskripsi:** + +Memuat kode YueScript dari file menjadi fungsi dan mengeksekusinya. + +**Signature:** + +```lua +dofile: function(filename: string, env: table, config?: Config): any... +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ------------------------- | +| filename | string | Nama file. | +| env | table | Tabel environment. | +| config | Config | [Opsional] Opsi kompiler. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | ------------------------------------- | +| any... | Nilai return dari fungsi yang dimuat. | + +### dofile + +**Tipe:** Function. + +**Deskripsi:** + +Memuat kode YueScript dari file menjadi fungsi dan mengeksekusinya. + +**Signature:** + +```lua +dofile: function(filename: string, config?: Config): any... +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ------------------------- | +| filename | string | Nama file. | +| config | Config | [Opsional] Opsi kompiler. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | ------------------------------------- | +| any... | Nilai return dari fungsi yang dimuat. | + +### find_modulepath + +**Tipe:** Function. + +**Deskripsi:** + +Menguraikan nama modul YueScript menjadi path file. + +**Signature:** + +```lua +find_modulepath: function(name: string): string +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ----------- | +| name | string | Nama modul. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | ---------- | +| string | Path file. | + +### pcall + +**Tipe:** Function. + +**Deskripsi:** + +Memanggil fungsi dalam mode terlindungi. +Menangkap error apa pun dan mengembalikan kode status beserta hasil atau objek error. +Menulis ulang nomor baris error ke nomor baris asli di kode YueScript saat error terjadi. + +**Signature:** + +```lua +pcall: function(f: function, ...: any): boolean, any... +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | -------- | ---------------------------------- | +| f | function | Fungsi yang akan dipanggil. | +| ... | any | Argumen yang diteruskan ke fungsi. | + +**Return:** + +| Tipe Return | Deskripsi | +| ------------ | ---------------------------------------------- | +| boolean, ... | Kode status dan hasil fungsi atau objek error. | + +### require + +**Tipe:** Function. + +**Deskripsi:** + +Memuat modul tertentu. Bisa berupa modul Lua atau modul YueScript. +Menulis ulang nomor baris error ke nomor baris asli di kode YueScript jika modul adalah modul YueScript dan pemuatan gagal. + +**Signature:** + +```lua +require: function(name: string): any... +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ---------------------------- | +| modname | string | Nama modul yang akan dimuat. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| any | Nilai yang disimpan di package.loaded[modname] jika modul sudah dimuat. Jika belum, mencoba mencari loader dan mengembalikan nilai akhir package.loaded[modname] serta data loader sebagai hasil kedua. | + +### p + +**Tipe:** Function. + +**Deskripsi:** + +Memeriksa struktur nilai yang diteruskan dan mencetak representasi string. + +**Signature:** + +```lua +p: function(...: any) +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ---- | -------------------------- | +| ... | any | Nilai yang akan diperiksa. | + +### options + +**Tipe:** Field. + +**Deskripsi:** + +Opsi kompiler saat ini. + +**Signature:** + +```lua +options: Config.Options +``` + +### traceback + +**Tipe:** Function. + +**Deskripsi:** + +Fungsi traceback yang menulis ulang nomor baris stack trace ke nomor baris asli di kode YueScript. + +**Signature:** + +```lua +traceback: function(message: string): string +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ---------------- | +| message | string | Pesan traceback. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | ----------------------------------------- | +| string | Pesan traceback yang telah ditulis ulang. | + +### is_ast + +**Tipe:** Function. + +**Deskripsi:** + +Memeriksa apakah kode cocok dengan AST yang ditentukan. + +**Signature:** + +```lua +is_ast: function(astName: string, code: string): boolean +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | --------- | +| astName | string | Nama AST. | +| code | string | Kode. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | ----------------------------- | +| boolean | Apakah kode cocok dengan AST. | + +### AST + +**Tipe:** Field. + +**Deskripsi:** + +Definisi tipe AST dengan nama, baris, kolom, dan sub-node. + +**Signature:** + +```lua +type AST = {string, integer, integer, any} +``` + +### to_ast + +**Tipe:** Function. + +**Deskripsi:** + +Mengonversi kode menjadi AST. + +**Signature:** + +```lua +to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): + --[[AST]] AST | nil, + --[[error]] nil | string +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| -------------- | ------- | ---------------------------------------------------------------------------------------- | +| code | string | Kode. | +| flattenLevel | integer | [Opsional] Tingkat perataan. Semakin tinggi berarti semakin rata. Default 0. Maksimum 2. | +| astName | string | [Opsional] Nama AST. Default "File". | +| reserveComment | boolean | [Opsional] Apakah akan mempertahankan komentar asli. Default false. | + +**Return:** + +| Tipe Return | Deskripsi | +| ------------- | --------------------------------------------- | +| AST \| nil | AST, atau nil jika konversi gagal. | +| string \| nil | Pesan error, atau nil jika konversi berhasil. | + +### format + +**Tipe:** Function. + +**Deskripsi:** + +Memformat kode YueScript. + +**Signature:** + +```lua +format: function(code: string, tabSize?: number, reserveComment?: boolean): string +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| -------------- | ------- | ------------------------------------------------------------- | +| code | string | Kode. | +| tabSize | integer | [Opsional] Ukuran tab. Default 4. | +| reserveComment | boolean | [Opsional] Apakah mempertahankan komentar asli. Default true. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | ------------------------- | +| string | Kode yang telah diformat. | + +### \_\_call + +**Tipe:** Metamethod. + +**Deskripsi:** + +Me-require modul YueScript. +Menulis ulang nomor baris error ke nomor baris asli di kode YueScript saat pemuatan gagal. + +**Signature:** + +```lua +metamethod __call: function(self: yue, module: string): any... +``` + +**Parameter:** + +| Parameter | Tipe | Deskripsi | +| --------- | ------ | ----------- | +| module | string | Nama modul. | + +**Return:** + +| Tipe Return | Deskripsi | +| ----------- | ------------ | +| any | Nilai modul. | + +## Config + +**Deskripsi:** + +Opsi kompilasi kompiler. + +### lint_global + +**Tipe:** Field. + +**Deskripsi:** + +Apakah kompiler harus mengumpulkan variabel global yang muncul dalam kode. + +**Signature:** + +```lua +lint_global: boolean +``` + +### implicit_return_root + +**Tipe:** Field. + +**Deskripsi:** + +Apakah kompiler harus melakukan return implisit untuk blok kode root. + +**Signature:** + +```lua +implicit_return_root: boolean +``` + +### reserve_line_number + +**Tipe:** Field. + +**Deskripsi:** + +Apakah kompiler harus mempertahankan nomor baris asli di kode hasil kompilasi. + +**Signature:** + +```lua +reserve_line_number: boolean +``` + +### reserve_comment + +**Tipe:** Field. + +**Deskripsi:** + +Apakah kompiler harus mempertahankan komentar asli di kode hasil kompilasi. + +**Signature:** + +```lua +reserve_comment: boolean +``` + +### space_over_tab + +**Tipe:** Field. + +**Deskripsi:** + +Apakah kompiler harus menggunakan karakter spasi alih-alih tab di kode hasil kompilasi. + +**Signature:** + +```lua +space_over_tab: boolean +``` + +### same_module + +**Tipe:** Field. + +**Deskripsi:** + +Apakah kompiler harus memperlakukan kode yang akan dikompilasi sebagai modul yang sama dengan modul yang sedang dikompilasi. Untuk penggunaan internal saja. + +**Signature:** + +```lua +same_module: boolean +``` + +### line_offset + +**Tipe:** Field. + +**Deskripsi:** + +Apakah pesan error kompiler harus menyertakan offset nomor baris. Untuk penggunaan internal saja. + +**Signature:** + +```lua +line_offset: integer +``` + +### yue.Config.LuaTarget + +**Tipe:** Enumeration. + +**Deskripsi:** + +Enumerasi versi Lua target. + +**Signature:** + +```lua +enum LuaTarget + "5.1" + "5.2" + "5.3" + "5.4" + "5.5" +end +``` + +### options + +**Tipe:** Field. + +**Deskripsi:** + +Opsi tambahan untuk diteruskan ke fungsi kompilasi. + +**Signature:** + +```lua +options: Options +``` + +## Options + +**Deskripsi:** + +Definisi opsi kompiler tambahan. + +### target + +**Tipe:** Field. + +**Deskripsi:** + +Versi Lua target untuk kompilasi. + +**Signature:** + +```lua +target: LuaTarget +``` + +### path + +**Tipe:** Field. + +**Deskripsi:** + +Path pencarian modul tambahan. + +**Signature:** + +```lua +path: string +``` + +### dump_locals + +**Tipe:** Field. + +**Deskripsi:** + +Apakah akan menampilkan variabel local dalam pesan error traceback. Default false. + +**Signature:** + +```lua +dump_locals: boolean +``` + +### simplified + +**Tipe:** Field. + +**Deskripsi:** + +Apakah akan menyederhanakan pesan error. Default true. + +**Signature:** + +```lua +simplified: boolean +``` diff --git a/doc/docs/id-id/doc/reference/mascot.md b/doc/docs/id-id/doc/reference/mascot.md new file mode 100644 index 0000000..1b16706 --- /dev/null +++ b/doc/docs/id-id/doc/reference/mascot.md @@ -0,0 +1,39 @@ +# Maskot – Xiaoyu + +## Tentang + +Xiaoyu si Kelinci Siber + +Xiaoyu (小玉, "giok kecil") adalah seekor kelinci siber dan maskot resmi proyek YueScript. Ia biasanya ditemukan bertengger di atas bulan sabit, mengutak-atik laptopnya – menulis YueScript, tentu saja. + +Gelar lengkapnya adalah Xiaoyu si Kelinci Siber (机兔小玉), dan ia mewujudkan segala hal yang dicita-citakan YueScript: elegan, ekspresif, dan sedikit menyenangkan. + +Xiaoyu dirancang dan diilustrasikan oleh **[Tyson Tan](https://tysontan.com)**, yang dengan murah hati menciptakannya untuk proyek ini secara gratis – sesuatu yang sangat kami syukuri. + +## Gambar + +Karya seni resolusi penuh tersedia untuk diunduh di bawah ini. Klik gambar mana saja untuk membukanya dalam ukuran penuh. + +### Karya Seni Lengkap + + + Xiaoyu — karya seni lengkap dengan latar belakang + + +

Unduh PNG ukuran penuh

+ +### Latar Belakang Transparan + + + Xiaoyu — latar belakang transparan + + +

Unduh PNG transparan

+ +### File .kra Terkompresi + +

Unduh file .kra terkompresi

+ +## Lisensi + +Xiaoyu dilisensikan ganda di bawah [Lisensi MIT](https://opensource.org/licenses/MIT) dan Creative Commons [CC‑BY‑SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). diff --git a/doc/docs/id-id/doc/reference/the-yuescript-library.md b/doc/docs/id-id/doc/reference/the-yuescript-library.md deleted file mode 100644 index 3adfe63..0000000 --- a/doc/docs/id-id/doc/reference/the-yuescript-library.md +++ /dev/null @@ -1,860 +0,0 @@ -# Pustaka YueScript - -Akses dengan `local yue = require("yue")` di Lua. - -## yue - -**Deskripsi:** - -Pustaka bahasa YueScript. - -### version - -**Tipe:** Field. - -**Deskripsi:** - -Versi YueScript. - -**Signature:** - -```lua -version: string -``` - -### dirsep - -**Tipe:** Field. - -**Deskripsi:** - -Pemisah file untuk platform saat ini. - -**Signature:** - -```lua -dirsep: string -``` - -### yue_compiled - -**Tipe:** Field. - -**Deskripsi:** - -Cache kode modul yang telah dikompilasi. - -**Signature:** - -```lua -yue_compiled: {string: string} -``` - -### to_lua - -**Tipe:** Function. - -**Deskripsi:** - -Fungsi kompilasi YueScript. Mengompilasi kode YueScript menjadi kode Lua. - -**Signature:** - -```lua -to_lua: function(code: string, config?: Config): - --[[codes]] string | nil, - --[[error]] string | nil, - --[[globals]] {{string, integer, integer}} | nil -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ------------------------- | -| code | string | Kode YueScript. | -| config | Config | [Opsional] Opsi kompiler. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | -| string \| nil | Kode Lua hasil kompilasi, atau nil jika kompilasi gagal. | -| string \| nil | Pesan error, atau nil jika kompilasi berhasil. | -| {{string, integer, integer}} \| nil | Variabel global yang muncul dalam kode (dengan nama, baris, dan kolom), atau nil jika opsi kompiler `lint_global` bernilai false. | - -### file_exist - -**Tipe:** Function. - -**Deskripsi:** - -Fungsi untuk memeriksa keberadaan file sumber. Dapat ditimpa untuk menyesuaikan perilaku. - -**Signature:** - -```lua -file_exist: function(filename: string): boolean -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ---------- | -| filename | string | Nama file. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | ---------------- | -| boolean | Apakah file ada. | - -### read_file - -**Tipe:** Function. - -**Deskripsi:** - -Fungsi untuk membaca file sumber. Dapat ditimpa untuk menyesuaikan perilaku. - -**Signature:** - -```lua -read_file: function(filename: string): string -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ---------- | -| filename | string | Nama file. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | --------- | -| string | Isi file. | - -### insert_loader - -**Tipe:** Function. - -**Deskripsi:** - -Menyisipkan loader YueScript ke package loaders (searchers). - -**Signature:** - -```lua -insert_loader: function(pos?: integer): boolean -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------- | ------------------------------------------------------------- | -| pos | integer | [Opsional] Posisi untuk menyisipkan loader. Default adalah 3. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | --------------------------------------------------------------------------- | -| boolean | Apakah loader berhasil disisipkan. Akan gagal jika loader sudah disisipkan. | - -### remove_loader - -**Tipe:** Function. - -**Deskripsi:** - -Menghapus loader YueScript dari package loaders (searchers). - -**Signature:** - -```lua -remove_loader: function(): boolean -``` - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | ------------------------------------------------------------------------ | -| boolean | Apakah loader berhasil dihapus. Akan gagal jika loader belum disisipkan. | - -### loadstring - -**Tipe:** Function. - -**Deskripsi:** - -Memuat kode YueScript dari string menjadi fungsi. - -**Signature:** - -```lua -loadstring: function(input: string, chunkname: string, env: table, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ------------------------- | -| input | string | Kode YueScript. | -| chunkname | string | Nama chunk kode. | -| env | table | Tabel environment. | -| config | Config | [Opsional] Opsi kompiler. | - -**Return:** - -| Tipe Return | Deskripsi | -| --------------- | ------------------------------------------------- | -| function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | -| string \| nil | Pesan error, atau nil jika pemuatan berhasil. | - -### loadstring - -**Tipe:** Function. - -**Deskripsi:** - -Memuat kode YueScript dari string menjadi fungsi. - -**Signature:** - -```lua -loadstring: function(input: string, chunkname: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ------------------------- | -| input | string | Kode YueScript. | -| chunkname | string | Nama chunk kode. | -| config | Config | [Opsional] Opsi kompiler. | - -**Return:** - -| Tipe Return | Deskripsi | -| --------------- | ------------------------------------------------- | -| function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | -| string \| nil | Pesan error, atau nil jika pemuatan berhasil. | - -### loadstring - -**Tipe:** Function. - -**Deskripsi:** - -Memuat kode YueScript dari string menjadi fungsi. - -**Signature:** - -```lua -loadstring: function(input: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ------------------------- | -| input | string | Kode YueScript. | -| config | Config | [Opsional] Opsi kompiler. | - -**Return:** - -| Tipe Return | Deskripsi | -| --------------- | ------------------------------------------------- | -| function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | -| string \| nil | Pesan error, atau nil jika pemuatan berhasil. | - -### loadfile - -**Tipe:** Function. - -**Deskripsi:** - -Memuat kode YueScript dari file menjadi fungsi. - -**Signature:** - -```lua -loadfile: function(filename: string, env: table, config?: Config): - nil | function(...: any): (any...), - string | nil -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ------------------------- | -| filename | string | Nama file. | -| env | table | Tabel environment. | -| config | Config | [Opsional] Opsi kompiler. | - -**Return:** - -| Tipe Return | Deskripsi | -| --------------- | ------------------------------------------------- | -| function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | -| string \| nil | Pesan error, atau nil jika pemuatan berhasil. | - -### loadfile - -**Tipe:** Function. - -**Deskripsi:** - -Memuat kode YueScript dari file menjadi fungsi. - -**Signature:** - -```lua -loadfile: function(filename: string, config?: Config): - nil | function(...: any): (any...), - string | nil -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ------------------------- | -| filename | string | Nama file. | -| config | Config | [Opsional] Opsi kompiler. | - -**Return:** - -| Tipe Return | Deskripsi | -| --------------- | ------------------------------------------------- | -| function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | -| string \| nil | Pesan error, atau nil jika pemuatan berhasil. | - -### dofile - -**Tipe:** Function. - -**Deskripsi:** - -Memuat kode YueScript dari file menjadi fungsi dan mengeksekusinya. - -**Signature:** - -```lua -dofile: function(filename: string, env: table, config?: Config): any... -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ------------------------- | -| filename | string | Nama file. | -| env | table | Tabel environment. | -| config | Config | [Opsional] Opsi kompiler. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | ------------------------------------- | -| any... | Nilai return dari fungsi yang dimuat. | - -### dofile - -**Tipe:** Function. - -**Deskripsi:** - -Memuat kode YueScript dari file menjadi fungsi dan mengeksekusinya. - -**Signature:** - -```lua -dofile: function(filename: string, config?: Config): any... -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ------------------------- | -| filename | string | Nama file. | -| config | Config | [Opsional] Opsi kompiler. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | ------------------------------------- | -| any... | Nilai return dari fungsi yang dimuat. | - -### find_modulepath - -**Tipe:** Function. - -**Deskripsi:** - -Menguraikan nama modul YueScript menjadi path file. - -**Signature:** - -```lua -find_modulepath: function(name: string): string -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ----------- | -| name | string | Nama modul. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | ---------- | -| string | Path file. | - -### pcall - -**Tipe:** Function. - -**Deskripsi:** - -Memanggil fungsi dalam mode terlindungi. -Menangkap error apa pun dan mengembalikan kode status beserta hasil atau objek error. -Menulis ulang nomor baris error ke nomor baris asli di kode YueScript saat error terjadi. - -**Signature:** - -```lua -pcall: function(f: function, ...: any): boolean, any... -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | -------- | ---------------------------------- | -| f | function | Fungsi yang akan dipanggil. | -| ... | any | Argumen yang diteruskan ke fungsi. | - -**Return:** - -| Tipe Return | Deskripsi | -| ------------ | ---------------------------------------------- | -| boolean, ... | Kode status dan hasil fungsi atau objek error. | - -### require - -**Tipe:** Function. - -**Deskripsi:** - -Memuat modul tertentu. Bisa berupa modul Lua atau modul YueScript. -Menulis ulang nomor baris error ke nomor baris asli di kode YueScript jika modul adalah modul YueScript dan pemuatan gagal. - -**Signature:** - -```lua -require: function(name: string): any... -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ---------------------------- | -| modname | string | Nama modul yang akan dimuat. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| any | Nilai yang disimpan di package.loaded[modname] jika modul sudah dimuat. Jika belum, mencoba mencari loader dan mengembalikan nilai akhir package.loaded[modname] serta data loader sebagai hasil kedua. | - -### p - -**Tipe:** Function. - -**Deskripsi:** - -Memeriksa struktur nilai yang diteruskan dan mencetak representasi string. - -**Signature:** - -```lua -p: function(...: any) -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ---- | -------------------------- | -| ... | any | Nilai yang akan diperiksa. | - -### options - -**Tipe:** Field. - -**Deskripsi:** - -Opsi kompiler saat ini. - -**Signature:** - -```lua -options: Config.Options -``` - -### traceback - -**Tipe:** Function. - -**Deskripsi:** - -Fungsi traceback yang menulis ulang nomor baris stack trace ke nomor baris asli di kode YueScript. - -**Signature:** - -```lua -traceback: function(message: string): string -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ---------------- | -| message | string | Pesan traceback. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | ----------------------------------------- | -| string | Pesan traceback yang telah ditulis ulang. | - -### is_ast - -**Tipe:** Function. - -**Deskripsi:** - -Memeriksa apakah kode cocok dengan AST yang ditentukan. - -**Signature:** - -```lua -is_ast: function(astName: string, code: string): boolean -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | --------- | -| astName | string | Nama AST. | -| code | string | Kode. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | ----------------------------- | -| boolean | Apakah kode cocok dengan AST. | - -### AST - -**Tipe:** Field. - -**Deskripsi:** - -Definisi tipe AST dengan nama, baris, kolom, dan sub-node. - -**Signature:** - -```lua -type AST = {string, integer, integer, any} -``` - -### to_ast - -**Tipe:** Function. - -**Deskripsi:** - -Mengonversi kode menjadi AST. - -**Signature:** - -```lua -to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): - --[[AST]] AST | nil, - --[[error]] nil | string -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| -------------- | ------- | ---------------------------------------------------------------------------------------- | -| code | string | Kode. | -| flattenLevel | integer | [Opsional] Tingkat perataan. Semakin tinggi berarti semakin rata. Default 0. Maksimum 2. | -| astName | string | [Opsional] Nama AST. Default "File". | -| reserveComment | boolean | [Opsional] Apakah akan mempertahankan komentar asli. Default false. | - -**Return:** - -| Tipe Return | Deskripsi | -| ------------- | --------------------------------------------- | -| AST \| nil | AST, atau nil jika konversi gagal. | -| string \| nil | Pesan error, atau nil jika konversi berhasil. | - -### format - -**Tipe:** Function. - -**Deskripsi:** - -Memformat kode YueScript. - -**Signature:** - -```lua -format: function(code: string, tabSize?: number, reserveComment?: boolean): string -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| -------------- | ------- | ------------------------------------------------------------- | -| code | string | Kode. | -| tabSize | integer | [Opsional] Ukuran tab. Default 4. | -| reserveComment | boolean | [Opsional] Apakah mempertahankan komentar asli. Default true. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | ------------------------- | -| string | Kode yang telah diformat. | - -### \_\_call - -**Tipe:** Metamethod. - -**Deskripsi:** - -Me-require modul YueScript. -Menulis ulang nomor baris error ke nomor baris asli di kode YueScript saat pemuatan gagal. - -**Signature:** - -```lua -metamethod __call: function(self: yue, module: string): any... -``` - -**Parameter:** - -| Parameter | Tipe | Deskripsi | -| --------- | ------ | ----------- | -| module | string | Nama modul. | - -**Return:** - -| Tipe Return | Deskripsi | -| ----------- | ------------ | -| any | Nilai modul. | - -## Config - -**Deskripsi:** - -Opsi kompilasi kompiler. - -### lint_global - -**Tipe:** Field. - -**Deskripsi:** - -Apakah kompiler harus mengumpulkan variabel global yang muncul dalam kode. - -**Signature:** - -```lua -lint_global: boolean -``` - -### implicit_return_root - -**Tipe:** Field. - -**Deskripsi:** - -Apakah kompiler harus melakukan return implisit untuk blok kode root. - -**Signature:** - -```lua -implicit_return_root: boolean -``` - -### reserve_line_number - -**Tipe:** Field. - -**Deskripsi:** - -Apakah kompiler harus mempertahankan nomor baris asli di kode hasil kompilasi. - -**Signature:** - -```lua -reserve_line_number: boolean -``` - -### reserve_comment - -**Tipe:** Field. - -**Deskripsi:** - -Apakah kompiler harus mempertahankan komentar asli di kode hasil kompilasi. - -**Signature:** - -```lua -reserve_comment: boolean -``` - -### space_over_tab - -**Tipe:** Field. - -**Deskripsi:** - -Apakah kompiler harus menggunakan karakter spasi alih-alih tab di kode hasil kompilasi. - -**Signature:** - -```lua -space_over_tab: boolean -``` - -### same_module - -**Tipe:** Field. - -**Deskripsi:** - -Apakah kompiler harus memperlakukan kode yang akan dikompilasi sebagai modul yang sama dengan modul yang sedang dikompilasi. Untuk penggunaan internal saja. - -**Signature:** - -```lua -same_module: boolean -``` - -### line_offset - -**Tipe:** Field. - -**Deskripsi:** - -Apakah pesan error kompiler harus menyertakan offset nomor baris. Untuk penggunaan internal saja. - -**Signature:** - -```lua -line_offset: integer -``` - -### yue.Config.LuaTarget - -**Tipe:** Enumeration. - -**Deskripsi:** - -Enumerasi versi Lua target. - -**Signature:** - -```lua -enum LuaTarget - "5.1" - "5.2" - "5.3" - "5.4" - "5.5" -end -``` - -### options - -**Tipe:** Field. - -**Deskripsi:** - -Opsi tambahan untuk diteruskan ke fungsi kompilasi. - -**Signature:** - -```lua -options: Options -``` - -## Options - -**Deskripsi:** - -Definisi opsi kompiler tambahan. - -### target - -**Tipe:** Field. - -**Deskripsi:** - -Versi Lua target untuk kompilasi. - -**Signature:** - -```lua -target: LuaTarget -``` - -### path - -**Tipe:** Field. - -**Deskripsi:** - -Path pencarian modul tambahan. - -**Signature:** - -```lua -path: string -``` - -### dump_locals - -**Tipe:** Field. - -**Deskripsi:** - -Apakah akan menampilkan variabel local dalam pesan error traceback. Default false. - -**Signature:** - -```lua -dump_locals: boolean -``` - -### simplified - -**Tipe:** Field. - -**Deskripsi:** - -Apakah akan menyederhanakan pesan error. Default true. - -**Signature:** - -```lua -simplified: boolean -``` diff --git a/doc/docs/index.md b/doc/docs/index.md index 016b688..7d34f11 100644 --- a/doc/docs/index.md +++ b/doc/docs/index.md @@ -4,7 +4,7 @@ hero: name: YueScript tagline: A language that compiles to Lua image: - src: /image/yuescript.svg + src: /image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png alt: YueScript actions: - theme: brand diff --git a/doc/docs/pt-br/doc/advanced/the-yuescript-library.md b/doc/docs/pt-br/doc/advanced/the-yuescript-library.md new file mode 100644 index 0000000..7775cd5 --- /dev/null +++ b/doc/docs/pt-br/doc/advanced/the-yuescript-library.md @@ -0,0 +1,860 @@ +# A biblioteca YueScript + +Acesse com `local yue = require("yue")` no Lua. + +## yue + +**Descrição:** + +A biblioteca da linguagem YueScript. + +### version + +**Tipo:** Campo. + +**Descrição:** + +A versão do YueScript. + +**Assinatura:** + +```lua +version: string +``` + +### dirsep + +**Tipo:** Campo. + +**Descrição:** + +O separador de arquivos da plataforma atual. + +**Assinatura:** + +```lua +dirsep: string +``` + +### yue_compiled + +**Tipo:** Campo. + +**Descrição:** + +O cache de código de módulo compilado. + +**Assinatura:** + +```lua +yue_compiled: {string: string} +``` + +### to_lua + +**Tipo:** Função. + +**Descrição:** + +A função de compilação do YueScript. Compila o código YueScript para código Lua. + +**Assinatura:** + +```lua +to_lua: function(code: string, config?: Config): + --[[codes]] string | nil, + --[[error]] string | nil, + --[[globals]] {{string, integer, integer}} | nil +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ----------------------------------- | +| code | string | O código YueScript. | +| config | Config | [Opcional] As opções do compilador. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| string \| nil | O código Lua compilado, ou nil se a compilação falhou. | +| string \| nil | A mensagem de erro, ou nil se a compilação foi bem-sucedida. | +| {{string, integer, integer}} \| nil | As variáveis globais que aparecem no código (com nome, linha e coluna), ou nil se a opção do compilador `lint_global` for false. | + +### file_exist + +**Tipo:** Função. + +**Descrição:** + +Função de verificação de existência do arquivo fonte. Pode ser sobrescrita para personalizar o comportamento. + +**Assinatura:** + +```lua +file_exist: function(filename: string): boolean +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ------------------ | +| filename | string | O nome do arquivo. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | -------------------- | +| boolean | Se o arquivo existe. | + +### read_file + +**Tipo:** Função. + +**Descrição:** + +Função de leitura do arquivo fonte. Pode ser sobrescrita para personalizar o comportamento. + +**Assinatura:** + +```lua +read_file: function(filename: string): string +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ------------------ | +| filename | string | O nome do arquivo. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | ---------------------- | +| string | O conteúdo do arquivo. | + +### insert_loader + +**Tipo:** Função. + +**Descrição:** + +Insere o carregador YueScript nos carregadores de pacote (searchers). + +**Assinatura:** + +```lua +insert_loader: function(pos?: integer): boolean +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------- | ----------------------------------------------------------- | +| pos | integer | [Opcional] A posição para inserir o carregador. Padrão é 3. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | -------------------------------------------------------------------------------------- | +| boolean | Se o carregador foi inserido com sucesso. Falhará se o carregador já estiver inserido. | + +### remove_loader + +**Tipo:** Função. + +**Descrição:** + +Remove o carregador YueScript dos carregadores de pacote (searchers). + +**Assinatura:** + +```lua +remove_loader: function(): boolean +``` + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | --------------------------------------------------------------------------------------- | +| boolean | Se o carregador foi removido com sucesso. Falhará se o carregador não estiver inserido. | + +### loadstring + +**Tipo:** Função. + +**Descrição:** + +Carrega código YueScript de uma string em uma função. + +**Assinatura:** + +```lua +loadstring: function(input: string, chunkname: string, env: table, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ----------------------------------- | +| input | string | O código YueScript. | +| chunkname | string | O nome do chunk de código. | +| env | table | A tabela de ambiente. | +| config | Config | [Opcional] As opções do compilador. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | -------------------------------------------------------------- | +| function \| nil | A função carregada, ou nil se o carregamento falhou. | +| string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | + +### loadstring + +**Tipo:** Função. + +**Descrição:** + +Carrega código YueScript de uma string em uma função. + +**Assinatura:** + +```lua +loadstring: function(input: string, chunkname: string, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ----------------------------------- | +| input | string | O código YueScript. | +| chunkname | string | O nome do chunk de código. | +| config | Config | [Opcional] As opções do compilador. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | -------------------------------------------------------------- | +| function \| nil | A função carregada, ou nil se o carregamento falhou. | +| string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | + +### loadstring + +**Tipo:** Função. + +**Descrição:** + +Carrega código YueScript de uma string em uma função. + +**Assinatura:** + +```lua +loadstring: function(input: string, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ----------------------------------- | +| input | string | O código YueScript. | +| config | Config | [Opcional] As opções do compilador. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | -------------------------------------------------------------- | +| function \| nil | A função carregada, ou nil se o carregamento falhou. | +| string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | + +### loadfile + +**Tipo:** Função. + +**Descrição:** + +Carrega código YueScript de um arquivo em uma função. + +**Assinatura:** + +```lua +loadfile: function(filename: string, env: table, config?: Config): + nil | function(...: any): (any...), + string | nil +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ----------------------------------- | +| filename | string | O nome do arquivo. | +| env | table | A tabela de ambiente. | +| config | Config | [Opcional] As opções do compilador. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | -------------------------------------------------------------- | +| function \| nil | A função carregada, ou nil se o carregamento falhou. | +| string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | + +### loadfile + +**Tipo:** Função. + +**Descrição:** + +Carrega código YueScript de um arquivo em uma função. + +**Assinatura:** + +```lua +loadfile: function(filename: string, config?: Config): + nil | function(...: any): (any...), + string | nil +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ----------------------------------- | +| filename | string | O nome do arquivo. | +| config | Config | [Opcional] As opções do compilador. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | -------------------------------------------------------------- | +| function \| nil | A função carregada, ou nil se o carregamento falhou. | +| string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | + +### dofile + +**Tipo:** Função. + +**Descrição:** + +Carrega código YueScript de um arquivo em uma função e o executa. + +**Assinatura:** + +```lua +dofile: function(filename: string, env: table, config?: Config): any... +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ----------------------------------- | +| filename | string | O nome do arquivo. | +| env | table | A tabela de ambiente. | +| config | Config | [Opcional] As opções do compilador. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | ------------------------------------------ | +| any... | Os valores de retorno da função carregada. | + +### dofile + +**Tipo:** Função. + +**Descrição:** + +Carrega código YueScript de um arquivo em uma função e o executa. + +**Assinatura:** + +```lua +dofile: function(filename: string, config?: Config): any... +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ----------------------------------- | +| filename | string | O nome do arquivo. | +| config | Config | [Opcional] As opções do compilador. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | ------------------------------------------ | +| any... | Os valores de retorno da função carregada. | + +### find_modulepath + +**Tipo:** Função. + +**Descrição:** + +Resolve o nome do módulo YueScript para o caminho do arquivo. + +**Assinatura:** + +```lua +find_modulepath: function(name: string): string +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ----------------- | +| name | string | O nome do módulo. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | --------------------- | +| string | O caminho do arquivo. | + +### pcall + +**Tipo:** Função. + +**Descrição:** + +Chama uma função em modo protegido. +Captura quaisquer erros e retorna um código de status e resultados ou objeto de erro. +Reescreve o número da linha do erro para o número da linha original no código YueScript quando ocorrem erros. + +**Assinatura:** + +```lua +pcall: function(f: function, ...: any): boolean, any... +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | -------- | ---------------------------------- | +| f | function | A função a chamar. | +| ... | any | Argumentos a passar para a função. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | ---------------------------------------------------------- | +| boolean, ... | Código de status e resultados da função ou objeto de erro. | + +### require + +**Tipo:** Função. + +**Descrição:** + +Carrega um módulo dado. Pode ser um módulo Lua ou um módulo YueScript. +Reescreve o número da linha do erro para o número da linha original no código YueScript se o módulo for um módulo YueScript e o carregamento falhar. + +**Assinatura:** + +```lua +require: function(name: string): any... +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ---------------------------- | +| modname | string | O nome do módulo a carregar. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| any | O valor armazenado em package.loaded[modname] se o módulo já estiver carregado. Caso contrário, tenta encontrar um carregador e retorna o valor final de package.loaded[modname] e os dados do carregador como segundo resultado. | + +### p + +**Tipo:** Função. + +**Descrição:** + +Inspeciona as estruturas dos valores passados e imprime representações em string. + +**Assinatura:** + +```lua +p: function(...: any) +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ---- | ------------------------- | +| ... | any | Os valores a inspecionar. | + +### options + +**Tipo:** Campo. + +**Descrição:** + +As opções atuais do compilador. + +**Assinatura:** + +```lua +options: Config.Options +``` + +### traceback + +**Tipo:** Função. + +**Descrição:** + +A função traceback que reescreve os números das linhas do stack trace para os números das linhas originais no código YueScript. + +**Assinatura:** + +```lua +traceback: function(message: string): string +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ------------------------ | +| message | string | A mensagem de traceback. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | ---------------------------------- | +| string | A mensagem de traceback reescrita. | + +### is_ast + +**Tipo:** Função. + +**Descrição:** + +Verifica se o código corresponde ao AST especificado. + +**Assinatura:** + +```lua +is_ast: function(astName: string, code: string): boolean +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | -------------- | +| astName | string | O nome do AST. | +| code | string | O código. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | ------------------------------- | +| boolean | Se o código corresponde ao AST. | + +### AST + +**Tipo:** Campo. + +**Descrição:** + +A definição do tipo AST com nome, linha, coluna e subnós. + +**Assinatura:** + +```lua +type AST = {string, integer, integer, any} +``` + +### to_ast + +**Tipo:** Função. + +**Descrição:** + +Converte o código para o AST. + +**Assinatura:** + +```lua +to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): + --[[AST]] AST | nil, + --[[error]] nil | string +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| -------------- | ------- | ------------------------------------------------------------------------------------------------------ | +| code | string | O código. | +| flattenLevel | integer | [Opcional] O nível de achatamento. Nível mais alto significa mais achatamento. Padrão é 0. Máximo é 2. | +| astName | string | [Opcional] O nome do AST. Padrão é "File". | +| reserveComment | boolean | [Opcional] Se deve preservar os comentários originais. Padrão é false. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | ----------------------------------------------------------- | +| AST \| nil | O AST, ou nil se a conversão falhou. | +| string \| nil | A mensagem de erro, ou nil se a conversão foi bem-sucedida. | + +### format + +**Tipo:** Função. + +**Descrição:** + +Formata o código YueScript. + +**Assinatura:** + +```lua +format: function(code: string, tabSize?: number, reserveComment?: boolean): string +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| -------------- | ------- | --------------------------------------------------------------------- | +| code | string | O código. | +| tabSize | integer | [Opcional] O tamanho da tabulação. Padrão é 4. | +| reserveComment | boolean | [Opcional] Se deve preservar os comentários originais. Padrão é true. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | ------------------- | +| string | O código formatado. | + +### \_\_call + +**Tipo:** Metamétodo. + +**Descrição:** + +Requer o módulo YueScript. +Reescreve o número da linha do erro para o número da linha original no código YueScript quando o carregamento falha. + +**Assinatura:** + +```lua +metamethod __call: function(self: yue, module: string): any... +``` + +**Parâmetros:** + +| Parâmetro | Tipo | Descrição | +| --------- | ------ | ----------------- | +| module | string | O nome do módulo. | + +**Retorna:** + +| Tipo de Retorno | Descrição | +| --------------- | ------------------ | +| any | O valor do módulo. | + +## Config + +**Descrição:** + +As opções de compilação do compilador. + +### lint_global + +**Tipo:** Campo. + +**Descrição:** + +Se o compilador deve coletar as variáveis globais que aparecem no código. + +**Assinatura:** + +```lua +lint_global: boolean +``` + +### implicit_return_root + +**Tipo:** Campo. + +**Descrição:** + +Se o compilador deve fazer retorno implícito para o bloco de código raiz. + +**Assinatura:** + +```lua +implicit_return_root: boolean +``` + +### reserve_line_number + +**Tipo:** Campo. + +**Descrição:** + +Se o compilador deve preservar o número da linha original no código compilado. + +**Assinatura:** + +```lua +reserve_line_number: boolean +``` + +### reserve_comment + +**Tipo:** Campo. + +**Descrição:** + +Se o compilador deve preservar os comentários originais no código compilado. + +**Assinatura:** + +```lua +reserve_comment: boolean +``` + +### space_over_tab + +**Tipo:** Campo. + +**Descrição:** + +Se o compilador deve usar o caractere de espaço em vez do caractere de tabulação no código compilado. + +**Assinatura:** + +```lua +space_over_tab: boolean +``` + +### same_module + +**Tipo:** Campo. + +**Descrição:** + +Se o compilador deve tratar o código a ser compilado como o mesmo módulo que está sendo compilado atualmente. Apenas para uso interno. + +**Assinatura:** + +```lua +same_module: boolean +``` + +### line_offset + +**Tipo:** Campo. + +**Descrição:** + +Se a mensagem de erro do compilador deve incluir o deslocamento do número da linha. Apenas para uso interno. + +**Assinatura:** + +```lua +line_offset: integer +``` + +### yue.Config.LuaTarget + +**Tipo:** Enumeração. + +**Descrição:** + +A enumeração da versão alvo do Lua. + +**Assinatura:** + +```lua +enum LuaTarget + "5.1" + "5.2" + "5.3" + "5.4" + "5.5" +end +``` + +### options + +**Tipo:** Campo. + +**Descrição:** + +As opções extras a serem passadas para a função de compilação. + +**Assinatura:** + +```lua +options: Options +``` + +## Options + +**Descrição:** + +A definição das opções extras do compilador. + +### target + +**Tipo:** Campo. + +**Descrição:** + +A versão alvo do Lua para a compilação. + +**Assinatura:** + +```lua +target: LuaTarget +``` + +### path + +**Tipo:** Campo. + +**Descrição:** + +O caminho de busca de módulo extra. + +**Assinatura:** + +```lua +path: string +``` + +### dump_locals + +**Tipo:** Campo. + +**Descrição:** + +Se deve incluir as variáveis locais na mensagem de erro do traceback. Padrão é false. + +**Assinatura:** + +```lua +dump_locals: boolean +``` + +### simplified + +**Tipo:** Campo. + +**Descrição:** + +Se deve simplificar a mensagem de erro. Padrão é true. + +**Assinatura:** + +```lua +simplified: boolean +``` diff --git a/doc/docs/pt-br/doc/reference/mascot.md b/doc/docs/pt-br/doc/reference/mascot.md new file mode 100644 index 0000000..e2ff951 --- /dev/null +++ b/doc/docs/pt-br/doc/reference/mascot.md @@ -0,0 +1,39 @@ +# Mascote – Xiaoyu + +## Sobre + +Xiaoyu, a Coelha Cibernética + +Xiaoyu (小玉, "pequeno jade") é uma coelha cibernética e a mascote oficial do projeto YueScript. Ela geralmente pode ser encontrada empoleirada em uma lua crescente, mexendo em seu laptop – escrevendo YueScript, naturalmente. + +Seu título completo é Xiaoyu, a Coelha Cibernética (机兔小玉), e ela incorpora tudo o que o YueScript aspira ser: elegante, expressivo e um pouquinho divertido. + +Xiaoyu foi projetada e ilustrada por **[Tyson Tan](https://tysontan.com)**, que generosamente a criou para o projeto de forma gratuita – algo pelo qual somos incrivelmente gratos. + +## Imagens + +Artes em resolução completa estão disponíveis para download abaixo. Clique em qualquer imagem para abri-la em tamanho real. + +### Arte Completa + + + Xiaoyu — arte completa com fundo + + +

Baixar PNG em tamanho real

+ +### Fundo Transparente + + + Xiaoyu — fundo transparente + + +

Baixar PNG transparente

+ +### Arquivo .kra Compactado + +

Baixar arquivo .kra compactado

+ +## Licença + +Xiaoyu é duplamente licenciada sob a [Licença MIT](https://opensource.org/licenses/MIT) e a Creative Commons [CC‑BY‑SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). diff --git a/doc/docs/pt-br/doc/reference/the-yuescript-library.md b/doc/docs/pt-br/doc/reference/the-yuescript-library.md deleted file mode 100644 index 7775cd5..0000000 --- a/doc/docs/pt-br/doc/reference/the-yuescript-library.md +++ /dev/null @@ -1,860 +0,0 @@ -# A biblioteca YueScript - -Acesse com `local yue = require("yue")` no Lua. - -## yue - -**Descrição:** - -A biblioteca da linguagem YueScript. - -### version - -**Tipo:** Campo. - -**Descrição:** - -A versão do YueScript. - -**Assinatura:** - -```lua -version: string -``` - -### dirsep - -**Tipo:** Campo. - -**Descrição:** - -O separador de arquivos da plataforma atual. - -**Assinatura:** - -```lua -dirsep: string -``` - -### yue_compiled - -**Tipo:** Campo. - -**Descrição:** - -O cache de código de módulo compilado. - -**Assinatura:** - -```lua -yue_compiled: {string: string} -``` - -### to_lua - -**Tipo:** Função. - -**Descrição:** - -A função de compilação do YueScript. Compila o código YueScript para código Lua. - -**Assinatura:** - -```lua -to_lua: function(code: string, config?: Config): - --[[codes]] string | nil, - --[[error]] string | nil, - --[[globals]] {{string, integer, integer}} | nil -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ----------------------------------- | -| code | string | O código YueScript. | -| config | Config | [Opcional] As opções do compilador. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -| string \| nil | O código Lua compilado, ou nil se a compilação falhou. | -| string \| nil | A mensagem de erro, ou nil se a compilação foi bem-sucedida. | -| {{string, integer, integer}} \| nil | As variáveis globais que aparecem no código (com nome, linha e coluna), ou nil se a opção do compilador `lint_global` for false. | - -### file_exist - -**Tipo:** Função. - -**Descrição:** - -Função de verificação de existência do arquivo fonte. Pode ser sobrescrita para personalizar o comportamento. - -**Assinatura:** - -```lua -file_exist: function(filename: string): boolean -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ------------------ | -| filename | string | O nome do arquivo. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | -------------------- | -| boolean | Se o arquivo existe. | - -### read_file - -**Tipo:** Função. - -**Descrição:** - -Função de leitura do arquivo fonte. Pode ser sobrescrita para personalizar o comportamento. - -**Assinatura:** - -```lua -read_file: function(filename: string): string -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ------------------ | -| filename | string | O nome do arquivo. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | ---------------------- | -| string | O conteúdo do arquivo. | - -### insert_loader - -**Tipo:** Função. - -**Descrição:** - -Insere o carregador YueScript nos carregadores de pacote (searchers). - -**Assinatura:** - -```lua -insert_loader: function(pos?: integer): boolean -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------- | ----------------------------------------------------------- | -| pos | integer | [Opcional] A posição para inserir o carregador. Padrão é 3. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | -------------------------------------------------------------------------------------- | -| boolean | Se o carregador foi inserido com sucesso. Falhará se o carregador já estiver inserido. | - -### remove_loader - -**Tipo:** Função. - -**Descrição:** - -Remove o carregador YueScript dos carregadores de pacote (searchers). - -**Assinatura:** - -```lua -remove_loader: function(): boolean -``` - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | --------------------------------------------------------------------------------------- | -| boolean | Se o carregador foi removido com sucesso. Falhará se o carregador não estiver inserido. | - -### loadstring - -**Tipo:** Função. - -**Descrição:** - -Carrega código YueScript de uma string em uma função. - -**Assinatura:** - -```lua -loadstring: function(input: string, chunkname: string, env: table, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ----------------------------------- | -| input | string | O código YueScript. | -| chunkname | string | O nome do chunk de código. | -| env | table | A tabela de ambiente. | -| config | Config | [Opcional] As opções do compilador. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | -------------------------------------------------------------- | -| function \| nil | A função carregada, ou nil se o carregamento falhou. | -| string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | - -### loadstring - -**Tipo:** Função. - -**Descrição:** - -Carrega código YueScript de uma string em uma função. - -**Assinatura:** - -```lua -loadstring: function(input: string, chunkname: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ----------------------------------- | -| input | string | O código YueScript. | -| chunkname | string | O nome do chunk de código. | -| config | Config | [Opcional] As opções do compilador. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | -------------------------------------------------------------- | -| function \| nil | A função carregada, ou nil se o carregamento falhou. | -| string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | - -### loadstring - -**Tipo:** Função. - -**Descrição:** - -Carrega código YueScript de uma string em uma função. - -**Assinatura:** - -```lua -loadstring: function(input: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ----------------------------------- | -| input | string | O código YueScript. | -| config | Config | [Opcional] As opções do compilador. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | -------------------------------------------------------------- | -| function \| nil | A função carregada, ou nil se o carregamento falhou. | -| string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | - -### loadfile - -**Tipo:** Função. - -**Descrição:** - -Carrega código YueScript de um arquivo em uma função. - -**Assinatura:** - -```lua -loadfile: function(filename: string, env: table, config?: Config): - nil | function(...: any): (any...), - string | nil -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ----------------------------------- | -| filename | string | O nome do arquivo. | -| env | table | A tabela de ambiente. | -| config | Config | [Opcional] As opções do compilador. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | -------------------------------------------------------------- | -| function \| nil | A função carregada, ou nil se o carregamento falhou. | -| string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | - -### loadfile - -**Tipo:** Função. - -**Descrição:** - -Carrega código YueScript de um arquivo em uma função. - -**Assinatura:** - -```lua -loadfile: function(filename: string, config?: Config): - nil | function(...: any): (any...), - string | nil -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ----------------------------------- | -| filename | string | O nome do arquivo. | -| config | Config | [Opcional] As opções do compilador. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | -------------------------------------------------------------- | -| function \| nil | A função carregada, ou nil se o carregamento falhou. | -| string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | - -### dofile - -**Tipo:** Função. - -**Descrição:** - -Carrega código YueScript de um arquivo em uma função e o executa. - -**Assinatura:** - -```lua -dofile: function(filename: string, env: table, config?: Config): any... -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ----------------------------------- | -| filename | string | O nome do arquivo. | -| env | table | A tabela de ambiente. | -| config | Config | [Opcional] As opções do compilador. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | ------------------------------------------ | -| any... | Os valores de retorno da função carregada. | - -### dofile - -**Tipo:** Função. - -**Descrição:** - -Carrega código YueScript de um arquivo em uma função e o executa. - -**Assinatura:** - -```lua -dofile: function(filename: string, config?: Config): any... -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ----------------------------------- | -| filename | string | O nome do arquivo. | -| config | Config | [Opcional] As opções do compilador. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | ------------------------------------------ | -| any... | Os valores de retorno da função carregada. | - -### find_modulepath - -**Tipo:** Função. - -**Descrição:** - -Resolve o nome do módulo YueScript para o caminho do arquivo. - -**Assinatura:** - -```lua -find_modulepath: function(name: string): string -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ----------------- | -| name | string | O nome do módulo. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | --------------------- | -| string | O caminho do arquivo. | - -### pcall - -**Tipo:** Função. - -**Descrição:** - -Chama uma função em modo protegido. -Captura quaisquer erros e retorna um código de status e resultados ou objeto de erro. -Reescreve o número da linha do erro para o número da linha original no código YueScript quando ocorrem erros. - -**Assinatura:** - -```lua -pcall: function(f: function, ...: any): boolean, any... -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | -------- | ---------------------------------- | -| f | function | A função a chamar. | -| ... | any | Argumentos a passar para a função. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | ---------------------------------------------------------- | -| boolean, ... | Código de status e resultados da função ou objeto de erro. | - -### require - -**Tipo:** Função. - -**Descrição:** - -Carrega um módulo dado. Pode ser um módulo Lua ou um módulo YueScript. -Reescreve o número da linha do erro para o número da linha original no código YueScript se o módulo for um módulo YueScript e o carregamento falhar. - -**Assinatura:** - -```lua -require: function(name: string): any... -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ---------------------------- | -| modname | string | O nome do módulo a carregar. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| any | O valor armazenado em package.loaded[modname] se o módulo já estiver carregado. Caso contrário, tenta encontrar um carregador e retorna o valor final de package.loaded[modname] e os dados do carregador como segundo resultado. | - -### p - -**Tipo:** Função. - -**Descrição:** - -Inspeciona as estruturas dos valores passados e imprime representações em string. - -**Assinatura:** - -```lua -p: function(...: any) -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ---- | ------------------------- | -| ... | any | Os valores a inspecionar. | - -### options - -**Tipo:** Campo. - -**Descrição:** - -As opções atuais do compilador. - -**Assinatura:** - -```lua -options: Config.Options -``` - -### traceback - -**Tipo:** Função. - -**Descrição:** - -A função traceback que reescreve os números das linhas do stack trace para os números das linhas originais no código YueScript. - -**Assinatura:** - -```lua -traceback: function(message: string): string -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ------------------------ | -| message | string | A mensagem de traceback. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | ---------------------------------- | -| string | A mensagem de traceback reescrita. | - -### is_ast - -**Tipo:** Função. - -**Descrição:** - -Verifica se o código corresponde ao AST especificado. - -**Assinatura:** - -```lua -is_ast: function(astName: string, code: string): boolean -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | -------------- | -| astName | string | O nome do AST. | -| code | string | O código. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | ------------------------------- | -| boolean | Se o código corresponde ao AST. | - -### AST - -**Tipo:** Campo. - -**Descrição:** - -A definição do tipo AST com nome, linha, coluna e subnós. - -**Assinatura:** - -```lua -type AST = {string, integer, integer, any} -``` - -### to_ast - -**Tipo:** Função. - -**Descrição:** - -Converte o código para o AST. - -**Assinatura:** - -```lua -to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): - --[[AST]] AST | nil, - --[[error]] nil | string -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| -------------- | ------- | ------------------------------------------------------------------------------------------------------ | -| code | string | O código. | -| flattenLevel | integer | [Opcional] O nível de achatamento. Nível mais alto significa mais achatamento. Padrão é 0. Máximo é 2. | -| astName | string | [Opcional] O nome do AST. Padrão é "File". | -| reserveComment | boolean | [Opcional] Se deve preservar os comentários originais. Padrão é false. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | ----------------------------------------------------------- | -| AST \| nil | O AST, ou nil se a conversão falhou. | -| string \| nil | A mensagem de erro, ou nil se a conversão foi bem-sucedida. | - -### format - -**Tipo:** Função. - -**Descrição:** - -Formata o código YueScript. - -**Assinatura:** - -```lua -format: function(code: string, tabSize?: number, reserveComment?: boolean): string -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| -------------- | ------- | --------------------------------------------------------------------- | -| code | string | O código. | -| tabSize | integer | [Opcional] O tamanho da tabulação. Padrão é 4. | -| reserveComment | boolean | [Opcional] Se deve preservar os comentários originais. Padrão é true. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | ------------------- | -| string | O código formatado. | - -### \_\_call - -**Tipo:** Metamétodo. - -**Descrição:** - -Requer o módulo YueScript. -Reescreve o número da linha do erro para o número da linha original no código YueScript quando o carregamento falha. - -**Assinatura:** - -```lua -metamethod __call: function(self: yue, module: string): any... -``` - -**Parâmetros:** - -| Parâmetro | Tipo | Descrição | -| --------- | ------ | ----------------- | -| module | string | O nome do módulo. | - -**Retorna:** - -| Tipo de Retorno | Descrição | -| --------------- | ------------------ | -| any | O valor do módulo. | - -## Config - -**Descrição:** - -As opções de compilação do compilador. - -### lint_global - -**Tipo:** Campo. - -**Descrição:** - -Se o compilador deve coletar as variáveis globais que aparecem no código. - -**Assinatura:** - -```lua -lint_global: boolean -``` - -### implicit_return_root - -**Tipo:** Campo. - -**Descrição:** - -Se o compilador deve fazer retorno implícito para o bloco de código raiz. - -**Assinatura:** - -```lua -implicit_return_root: boolean -``` - -### reserve_line_number - -**Tipo:** Campo. - -**Descrição:** - -Se o compilador deve preservar o número da linha original no código compilado. - -**Assinatura:** - -```lua -reserve_line_number: boolean -``` - -### reserve_comment - -**Tipo:** Campo. - -**Descrição:** - -Se o compilador deve preservar os comentários originais no código compilado. - -**Assinatura:** - -```lua -reserve_comment: boolean -``` - -### space_over_tab - -**Tipo:** Campo. - -**Descrição:** - -Se o compilador deve usar o caractere de espaço em vez do caractere de tabulação no código compilado. - -**Assinatura:** - -```lua -space_over_tab: boolean -``` - -### same_module - -**Tipo:** Campo. - -**Descrição:** - -Se o compilador deve tratar o código a ser compilado como o mesmo módulo que está sendo compilado atualmente. Apenas para uso interno. - -**Assinatura:** - -```lua -same_module: boolean -``` - -### line_offset - -**Tipo:** Campo. - -**Descrição:** - -Se a mensagem de erro do compilador deve incluir o deslocamento do número da linha. Apenas para uso interno. - -**Assinatura:** - -```lua -line_offset: integer -``` - -### yue.Config.LuaTarget - -**Tipo:** Enumeração. - -**Descrição:** - -A enumeração da versão alvo do Lua. - -**Assinatura:** - -```lua -enum LuaTarget - "5.1" - "5.2" - "5.3" - "5.4" - "5.5" -end -``` - -### options - -**Tipo:** Campo. - -**Descrição:** - -As opções extras a serem passadas para a função de compilação. - -**Assinatura:** - -```lua -options: Options -``` - -## Options - -**Descrição:** - -A definição das opções extras do compilador. - -### target - -**Tipo:** Campo. - -**Descrição:** - -A versão alvo do Lua para a compilação. - -**Assinatura:** - -```lua -target: LuaTarget -``` - -### path - -**Tipo:** Campo. - -**Descrição:** - -O caminho de busca de módulo extra. - -**Assinatura:** - -```lua -path: string -``` - -### dump_locals - -**Tipo:** Campo. - -**Descrição:** - -Se deve incluir as variáveis locais na mensagem de erro do traceback. Padrão é false. - -**Assinatura:** - -```lua -dump_locals: boolean -``` - -### simplified - -**Tipo:** Campo. - -**Descrição:** - -Se deve simplificar a mensagem de erro. Padrão é true. - -**Assinatura:** - -```lua -simplified: boolean -``` diff --git a/doc/docs/zh/doc/advanced/the-yuescript-library.md b/doc/docs/zh/doc/advanced/the-yuescript-library.md new file mode 100644 index 0000000..9565b01 --- /dev/null +++ b/doc/docs/zh/doc/advanced/the-yuescript-library.md @@ -0,0 +1,860 @@ +# 月之脚本语言库 + +在 Lua 中使用 `local yue = require("yue")` 来访问。 + +## yue + +**描述:** + +月之脚本语言库。 + +### version + +**类型:** 成员变量。 + +**描述:** + +月之脚本版本。 + +**签名:** + +```lua +version: string +``` + +### dirsep + +**类型:** 成员变量。 + +**描述:** + +当前平台的文件分隔符。 + +**签名:** + +```lua +dirsep: string +``` + +### yue_compiled + +**类型:** 成员变量。 + +**描述:** + +编译模块代码缓存。 + +**签名:** + +```lua +yue_compiled: {string: string} +``` + +### to_lua + +**类型:** 函数。 + +**描述:** + +月之脚本的编译函数。它将 YueScript 代码编译为 Lua 代码。 + +**签名:** + +```lua +to_lua: function(code: string, config?: Config): + --[[codes]] string | nil, + --[[error]] string | nil, + --[[globals]] {{string, integer, integer}} | nil +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| ------ | ------ | ------------------- | +| code | string | YueScript 代码。 | +| config | Config | [可选] 编译器选项。 | + +**返回值:** + +| 返回类型 | 描述 | +| ----------------------------------- | ------------------------------------------------------------------------------------------ | +| string \| nil | 编译后的 Lua 代码,如果编译失败则为 nil。 | +| string \| nil | 错误消息,如果编译成功则为 nil。 | +| {{string, integer, integer}} \| nil | 代码中出现的全局变量(带有名称、行和列),如果编译器选项 `lint_global` 为 false 则为 nil。 | + +### file_exist + +**类型:** 函数。 + +**描述:** + +检查源文件是否存在的函数。可以覆盖该函数以自定义行为。 + +**签名:** + +```lua +file_exist: function(filename: string): boolean +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| -------- | ------ | -------- | +| filename | string | 文件名。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | -------------- | +| boolean | 文件是否存在。 | + +### read_file + +**类型:** 函数。 + +**描述:** + +读取源文件的函数。可以覆盖该函数以自定义行为。 + +**签名:** + +```lua +read_file: function(filename: string): string +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| -------- | ------ | -------- | +| filename | string | 文件名。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | ---------- | +| string | 文件内容。 | + +### insert_loader + +**类型:** 函数。 + +**描述:** + +将 YueScript 加载器插入到 Lua 包加载器(搜索器)中。 + +**签名:** + +```lua +insert_loader: function(pos?: integer): boolean +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| ------ | ------- | ------------------------------------- | +| pos | integer | [可选] 要插入加载器的位置。默认为 3。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | ---------------------------------------------------- | +| boolean | 是否成功插入加载器。如果加载器已经插入,则返回失败。 | + +### remove_loader + +**类型:** 函数。 + +**描述:** + +从 Lua 包加载器(搜索器)中移除 YueScript 加载器。 + +**签名:** + +```lua +remove_loader: function(): boolean +``` + +**返回值:** + +| 返回类型 | 描述 | +| -------- | -------------------------------------------------- | +| boolean | 是否成功移除加载器。如果加载器未插入,则返回失败。 | + +### loadstring + +**类型:** 函数。 + +**描述:** + +将 YueScript 代码字符串加载为一个函数。 + +**签名:** + +```lua +loadstring: function(input: string, chunkname: string, env: table, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| --------- | ------ | ------------------- | +| input | string | YueScript 代码。 | +| chunkname | string | 代码块的名称。 | +| env | table | 环境表。 | +| config | Config | [可选] 编译器选项。 | + +**返回值:** + +| 返回类型 | 描述 | +| --------------- | ---------------------------------- | +| function \| nil | 加载的函数,如果加载失败则为 nil。 | +| string \| nil | 错误消息,如果加载成功则为 nil。 | + +### loadstring + +**类型:** 函数。 + +**描述:** + +将 YueScript 代码字符串加载为一个函数。 + +**签名:** + +```lua +loadstring: function(input: string, chunkname: string, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| --------- | ------ | ------------------- | +| input | string | YueScript 代码。 | +| chunkname | string | 代码块的名称。 | +| config | Config | [可选] 编译器选项。 | + +**返回值:** + +| 返回类型 | 描述 | +| --------------- | ---------------------------------- | +| function \| nil | 加载的函数,如果加载失败则为 nil。 | +| string \| nil | 错误消息,如果加载成功则为 nil。 | + +### loadstring + +**类型:** 函数。 + +**描述:** + +将 YueScript 代码字符串加载为一个函数。 + +**签名:** + +```lua +loadstring: function(input: string, config?: Config): + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| ------ | ------ | ------------------- | +| input | string | YueScript 代码。 | +| config | Config | [可选] 编译器选项。 | + +**返回值:** + +| 返回类型 | 描述 | +| --------------- | ---------------------------------- | +| function \| nil | 加载的函数,如果加载失败则为 nil。 | +| string \| nil | 错误消息,如果加载成功则为 nil。 | + +### loadfile + +**类型:** 函数。 + +**描述:** + +将 YueScript 代码文件加载为一个函数。 + +**签名:** + +```lua +loadfile: function(filename: string, env: table, config?: Config): + nil | function(...: any): (any...), + string | nil +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| -------- | ------ | ------------------- | +| filename | string | 文件名。 | +| env | table | 环境表。 | +| config | Config | [可选] 编译器选项。 | + +**返回值:** + +| 返回类型 | 描述 | +| --------------- | ---------------------------------- | +| function \| nil | 加载的函数,如果加载失败则为 nil。 | +| string \| nil | 错误消息,如果加载成功则为 nil。 | + +### loadfile + +**类型:** 函数。 + +**描述:** + +将 YueScript 代码文件加载为一个函数。 + +**签名:** + +```lua +loadfile: function(filename: string, config?: Config): + nil | function(...: any): (any...), + string | nil +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| -------- | ------ | ------------------- | +| filename | string | 文件名。 | +| config | Config | [可选] 编译器选项。 | + +**返回值:** + +| 返回类型 | 描述 | +| --------------- | ---------------------------------- | +| function \| nil | 加载的函数,如果加载失败则为 nil。 | +| string \| nil | 错误消息,如果加载成功则为 nil。 | + +### dofile + +**类型:** 函数。 + +**描述:** + +将 YueScript 代码文件加载为一个函数并执行。 + +**签名:** + +```lua +dofile: function(filename: string, env: table, config?: Config): any... +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| -------- | ------ | ------------------- | +| filename | string | 文件名。 | +| env | table | 环境表。 | +| config | Config | [可选] 编译器选项。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | -------------------------- | +| any... | 加载的函数执行后的返回值。 | + +### dofile + +**类型:** 函数。 + +**描述:** + +将 YueScript 代码文件加载为一个函数并执行。 + +**签名:** + +```lua +dofile: function(filename: string, config?: Config): any... +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| -------- | ------ | ------------------- | +| filename | string | 文件名。 | +| config | Config | [可选] 编译器选项。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | -------------------------- | +| any... | 加载的函数执行后的返回值。 | + +### find_modulepath + +**类型:** 函数。 + +**描述:** + +将 YueScript 模块名解析为文件路径。 + +**签名:** + +```lua +find_modulepath: function(name: string): string +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| ------ | ------ | -------- | +| name | string | 模块名。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | ---------- | +| string | 文件路径。 | + +### pcall + +**类型:** 函数。 + +**描述:** + +在保护模式下调用一个函数。 +会捕获任何错误,执行成功则返回成功状态和结果,否则为失败状态和错误信息。 +当发生错误时,将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 + +**签名:** + +```lua +pcall: function(f: function, ...: any): boolean, any... +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| ------ | -------- | -------------------- | +| f | function | 要调用的函数。 | +| ... | any | 要传递给函数的参数。 | + +**返回值:** + +| 返回类型 | 描述 | +| ------------ | ---------------------------- | +| boolean, ... | 状态码和函数结果或错误信息。 | + +### require + +**类型:** 函数。 + +**描述:** + +加载给定的模块。可以是 Lua 模块或 YueScript 模块。 +如果模块是 YueScript 模块且加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 + +**签名:** + +```lua +require: function(name: string): any... +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| ------- | ------ | ---------------- | +| modname | string | 要加载的模块名。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | +| any | 如果模块已经加载,则返回 package.loaded[modname] 中存储的值。否则,尝试查找加载器并返回 package.loaded[modname] 的最终值和加载器数据作为第二个结果。 | + +### p + +**类型:** 函数。 + +**描述:** + +检查传递的值的内部结构,并打印值出它的字符串表示。 + +**签名:** + +```lua +p: function(...: any) +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| ------ | ---- | ------------ | +| ... | any | 要检查的值。 | + +### options + +**类型:** 成员变量。 + +**描述:** + +当前编译器选项。 + +**签名:** + +```lua +options: Config.Options +``` + +### traceback + +**类型:** 函数。 + +**描述:** + +重写堆栈跟踪中的行号为 YueScript 代码中的原始行号的 traceback 函数。 + +**签名:** + +```lua +traceback: function(message: string): string +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| ------- | ------ | -------------- | +| message | string | 堆栈跟踪消息。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | ---------------------- | +| string | 重写后的堆栈跟踪消息。 | + +### is_ast + +**类型:** 函数。 + +**描述:** + +检查代码是否匹配指定的 AST。 + +**签名:** + +```lua +is_ast: function(astName: string, code: string): boolean +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| ------- | ------ | ---------- | +| astName | string | AST 名称。 | +| code | string | 代码。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | ------------------ | +| boolean | 代码是否匹配 AST。 | + +### AST + +**类型:** 成员变量。 + +**描述:** + +AST 类型定义,带有名称、行、列和子节点。 + +**签名:** + +```lua +type AST = {string, integer, integer, any} +``` + +### to_ast + +**类型:** 函数。 + +**描述:** + +将代码转换为 AST。 + +**签名:** + +```lua +to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): + --[[AST]] AST | nil, + --[[error]] nil | string +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| -------------- | ------- | ------------------------------------------------------------------------------ | +| code | string | 代码。 | +| flattenLevel | integer | [可选] 扁平化级别。级别越高,会消除更多的 AST 结构的嵌套。默认为 0。最大为 2。 | +| astName | string | [可选] AST 名称。默认为 "File"。 | +| reserveComment | boolean | [可选] 是否保留原始注释。默认为 false。 | + +**返回值:** + +| 返回类型 | 描述 | +| ------------- | -------------------------------- | +| AST \| nil | AST,如果转换失败则为 nil。 | +| string \| nil | 错误消息,如果转换成功则为 nil。 | + +### format + +**类型:** 函数。 + +**描述:** + +格式化 YueScript 代码。 + +**签名:** + +```lua +format: function(code: string, tabSize?: number, reserveComment?: boolean): string +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| -------------- | ------- | -------------------------------------- | +| code | string | 代码。 | +| tabSize | integer | [可选] 制表符大小。默认为 4。 | +| reserveComment | boolean | [可选] 是否保留原始注释。默认为 true。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | ---------------- | +| string | 格式化后的代码。 | + +### \_\_call + +**类型:** 元方法。 + +**描述:** + +导入 YueScript 模块。 +如果发生加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 + +**签名:** + +```lua +metamethod __call: function(self: yue, module: string): any... +``` + +**参数:** + +| 参数名 | 类型 | 描述 | +| ------ | ------ | -------- | +| module | string | 模块名。 | + +**返回值:** + +| 返回类型 | 描述 | +| -------- | -------- | +| any | 模块值。 | + +## Config + +**描述:** + +编译器编译选项。 + +### lint_global + +**类型:** 成员变量。 + +**描述:** + +编译器是否应该收集代码中出现的全局变量。 + +**签名:** + +```lua +lint_global: boolean +``` + +### implicit_return_root + +**类型:** 成员变量。 + +**描述:** + +编译器是否应该对根层级的代码块进行隐式的表达式返回。 + +**签名:** + +```lua +implicit_return_root: boolean +``` + +### reserve_line_number + +**类型:** 成员变量。 + +**描述:** + +编译器是否应该在编译后的代码中保留原始行号。 + +**签名:** + +```lua +reserve_line_number: boolean +``` + +### reserve_comment + +**类型:** 成员变量。 + +**描述:** + +编译器是否应该在编译后的代码中保留原始注释。 + +**签名:** + +```lua +reserve_comment: boolean +``` + +### space_over_tab + +**类型:** 成员变量。 + +**描述:** + +编译器是否应该在编译后的代码中使用空格字符而不是制表符字符。 + +**签名:** + +```lua +space_over_tab: boolean +``` + +### same_module + +**类型:** 成员变量。 + +**描述:** + +编译器是否应该将要编译的代码视为当前正在编译的模块。仅供编译器内部使用。 + +**签名:** + +```lua +same_module: boolean +``` + +### line_offset + +**类型:** 成员变量。 + +**描述:** + +编译器错误消息是否应该包含行号偏移量。仅供编译器内部使用。 + +**签名:** + +```lua +line_offset: integer +``` + +### yue.Config.LuaTarget + +**类型:** 枚举。 + +**描述:** + +目标 Lua 版本枚举。 + +**签名:** + +```lua +enum LuaTarget + "5.1" + "5.2" + "5.3" + "5.4" + "5.5" +end +``` + +### options + +**类型:** 成员变量。 + +**描述:** + +要传递给编译函数的额外选项。 + +**签名:** + +```lua +options: Options +``` + +## Options + +**描述:** + +额外编译器选项定义。 + +### target + +**类型:** 成员变量。 + +**描述:** + +编译目标 Lua 版本。 + +**签名:** + +```lua +target: LuaTarget +``` + +### path + +**类型:** 成员变量。 + +**描述:** + +额外模块搜索路径。 + +**签名:** + +```lua +path: string +``` + +### dump_locals + +**类型:** 成员变量。 + +**描述:** + +是否在回溯错误消息中输出代码块的局部变量。默认为 false。 + +**签名:** + +```lua +dump_locals: boolean +``` + +### simplified + +**类型:** 成员变量。 + +**描述:** + +是否简化输出的错误消息。默认为 true。 + +**签名:** + +```lua +simplified: boolean +``` diff --git a/doc/docs/zh/doc/reference/mascot.md b/doc/docs/zh/doc/reference/mascot.md new file mode 100644 index 0000000..cc6c80e --- /dev/null +++ b/doc/docs/zh/doc/reference/mascot.md @@ -0,0 +1,39 @@ +# 吉祥物 – 小玉 + +## 简介 + +机兔小玉 + +小玉(Xiaoyu,意为"小小的玉")是一只赛博兔,也是 YueScript 项目的官方吉祥物。她通常栖息在一弯新月之上,在笔记本电脑上忙碌着——当然是在写 YueScript。 + +她的全称是机兔小玉,体现了 YueScript 所追求的一切:优雅、富有表现力,还带着一点俏皮。 + +小玉由 **[Tyson Tan](https://tysontan.com)** 设计和绘制,他慷慨地免费为本项目创作了她——我们对此深表感激。 + +## 图片 + +以下提供全分辨率画作供下载。点击任意图片可查看原始尺寸。 + +### 完整画作 + + + 小玉 — 含背景的完整画作 + + +

下载完整 PNG

+ +### 透明背景 + + + 小玉 — 透明背景 + + +

下载透明背景 PNG

+ +### .kra 压缩文件 + +

下载 .kra 压缩文件

+ +## 许可证 + +小玉采用 [MIT 许可证](https://opensource.org/licenses/MIT) 和知识共享 [CC‑BY‑SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) 双重许可。 diff --git a/doc/docs/zh/doc/reference/the-yuescript-library.md b/doc/docs/zh/doc/reference/the-yuescript-library.md deleted file mode 100644 index 9565b01..0000000 --- a/doc/docs/zh/doc/reference/the-yuescript-library.md +++ /dev/null @@ -1,860 +0,0 @@ -# 月之脚本语言库 - -在 Lua 中使用 `local yue = require("yue")` 来访问。 - -## yue - -**描述:** - -月之脚本语言库。 - -### version - -**类型:** 成员变量。 - -**描述:** - -月之脚本版本。 - -**签名:** - -```lua -version: string -``` - -### dirsep - -**类型:** 成员变量。 - -**描述:** - -当前平台的文件分隔符。 - -**签名:** - -```lua -dirsep: string -``` - -### yue_compiled - -**类型:** 成员变量。 - -**描述:** - -编译模块代码缓存。 - -**签名:** - -```lua -yue_compiled: {string: string} -``` - -### to_lua - -**类型:** 函数。 - -**描述:** - -月之脚本的编译函数。它将 YueScript 代码编译为 Lua 代码。 - -**签名:** - -```lua -to_lua: function(code: string, config?: Config): - --[[codes]] string | nil, - --[[error]] string | nil, - --[[globals]] {{string, integer, integer}} | nil -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| ------ | ------ | ------------------- | -| code | string | YueScript 代码。 | -| config | Config | [可选] 编译器选项。 | - -**返回值:** - -| 返回类型 | 描述 | -| ----------------------------------- | ------------------------------------------------------------------------------------------ | -| string \| nil | 编译后的 Lua 代码,如果编译失败则为 nil。 | -| string \| nil | 错误消息,如果编译成功则为 nil。 | -| {{string, integer, integer}} \| nil | 代码中出现的全局变量(带有名称、行和列),如果编译器选项 `lint_global` 为 false 则为 nil。 | - -### file_exist - -**类型:** 函数。 - -**描述:** - -检查源文件是否存在的函数。可以覆盖该函数以自定义行为。 - -**签名:** - -```lua -file_exist: function(filename: string): boolean -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| -------- | ------ | -------- | -| filename | string | 文件名。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | -------------- | -| boolean | 文件是否存在。 | - -### read_file - -**类型:** 函数。 - -**描述:** - -读取源文件的函数。可以覆盖该函数以自定义行为。 - -**签名:** - -```lua -read_file: function(filename: string): string -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| -------- | ------ | -------- | -| filename | string | 文件名。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | ---------- | -| string | 文件内容。 | - -### insert_loader - -**类型:** 函数。 - -**描述:** - -将 YueScript 加载器插入到 Lua 包加载器(搜索器)中。 - -**签名:** - -```lua -insert_loader: function(pos?: integer): boolean -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| ------ | ------- | ------------------------------------- | -| pos | integer | [可选] 要插入加载器的位置。默认为 3。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | ---------------------------------------------------- | -| boolean | 是否成功插入加载器。如果加载器已经插入,则返回失败。 | - -### remove_loader - -**类型:** 函数。 - -**描述:** - -从 Lua 包加载器(搜索器)中移除 YueScript 加载器。 - -**签名:** - -```lua -remove_loader: function(): boolean -``` - -**返回值:** - -| 返回类型 | 描述 | -| -------- | -------------------------------------------------- | -| boolean | 是否成功移除加载器。如果加载器未插入,则返回失败。 | - -### loadstring - -**类型:** 函数。 - -**描述:** - -将 YueScript 代码字符串加载为一个函数。 - -**签名:** - -```lua -loadstring: function(input: string, chunkname: string, env: table, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| --------- | ------ | ------------------- | -| input | string | YueScript 代码。 | -| chunkname | string | 代码块的名称。 | -| env | table | 环境表。 | -| config | Config | [可选] 编译器选项。 | - -**返回值:** - -| 返回类型 | 描述 | -| --------------- | ---------------------------------- | -| function \| nil | 加载的函数,如果加载失败则为 nil。 | -| string \| nil | 错误消息,如果加载成功则为 nil。 | - -### loadstring - -**类型:** 函数。 - -**描述:** - -将 YueScript 代码字符串加载为一个函数。 - -**签名:** - -```lua -loadstring: function(input: string, chunkname: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| --------- | ------ | ------------------- | -| input | string | YueScript 代码。 | -| chunkname | string | 代码块的名称。 | -| config | Config | [可选] 编译器选项。 | - -**返回值:** - -| 返回类型 | 描述 | -| --------------- | ---------------------------------- | -| function \| nil | 加载的函数,如果加载失败则为 nil。 | -| string \| nil | 错误消息,如果加载成功则为 nil。 | - -### loadstring - -**类型:** 函数。 - -**描述:** - -将 YueScript 代码字符串加载为一个函数。 - -**签名:** - -```lua -loadstring: function(input: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| ------ | ------ | ------------------- | -| input | string | YueScript 代码。 | -| config | Config | [可选] 编译器选项。 | - -**返回值:** - -| 返回类型 | 描述 | -| --------------- | ---------------------------------- | -| function \| nil | 加载的函数,如果加载失败则为 nil。 | -| string \| nil | 错误消息,如果加载成功则为 nil。 | - -### loadfile - -**类型:** 函数。 - -**描述:** - -将 YueScript 代码文件加载为一个函数。 - -**签名:** - -```lua -loadfile: function(filename: string, env: table, config?: Config): - nil | function(...: any): (any...), - string | nil -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| -------- | ------ | ------------------- | -| filename | string | 文件名。 | -| env | table | 环境表。 | -| config | Config | [可选] 编译器选项。 | - -**返回值:** - -| 返回类型 | 描述 | -| --------------- | ---------------------------------- | -| function \| nil | 加载的函数,如果加载失败则为 nil。 | -| string \| nil | 错误消息,如果加载成功则为 nil。 | - -### loadfile - -**类型:** 函数。 - -**描述:** - -将 YueScript 代码文件加载为一个函数。 - -**签名:** - -```lua -loadfile: function(filename: string, config?: Config): - nil | function(...: any): (any...), - string | nil -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| -------- | ------ | ------------------- | -| filename | string | 文件名。 | -| config | Config | [可选] 编译器选项。 | - -**返回值:** - -| 返回类型 | 描述 | -| --------------- | ---------------------------------- | -| function \| nil | 加载的函数,如果加载失败则为 nil。 | -| string \| nil | 错误消息,如果加载成功则为 nil。 | - -### dofile - -**类型:** 函数。 - -**描述:** - -将 YueScript 代码文件加载为一个函数并执行。 - -**签名:** - -```lua -dofile: function(filename: string, env: table, config?: Config): any... -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| -------- | ------ | ------------------- | -| filename | string | 文件名。 | -| env | table | 环境表。 | -| config | Config | [可选] 编译器选项。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | -------------------------- | -| any... | 加载的函数执行后的返回值。 | - -### dofile - -**类型:** 函数。 - -**描述:** - -将 YueScript 代码文件加载为一个函数并执行。 - -**签名:** - -```lua -dofile: function(filename: string, config?: Config): any... -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| -------- | ------ | ------------------- | -| filename | string | 文件名。 | -| config | Config | [可选] 编译器选项。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | -------------------------- | -| any... | 加载的函数执行后的返回值。 | - -### find_modulepath - -**类型:** 函数。 - -**描述:** - -将 YueScript 模块名解析为文件路径。 - -**签名:** - -```lua -find_modulepath: function(name: string): string -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| ------ | ------ | -------- | -| name | string | 模块名。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | ---------- | -| string | 文件路径。 | - -### pcall - -**类型:** 函数。 - -**描述:** - -在保护模式下调用一个函数。 -会捕获任何错误,执行成功则返回成功状态和结果,否则为失败状态和错误信息。 -当发生错误时,将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 - -**签名:** - -```lua -pcall: function(f: function, ...: any): boolean, any... -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| ------ | -------- | -------------------- | -| f | function | 要调用的函数。 | -| ... | any | 要传递给函数的参数。 | - -**返回值:** - -| 返回类型 | 描述 | -| ------------ | ---------------------------- | -| boolean, ... | 状态码和函数结果或错误信息。 | - -### require - -**类型:** 函数。 - -**描述:** - -加载给定的模块。可以是 Lua 模块或 YueScript 模块。 -如果模块是 YueScript 模块且加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 - -**签名:** - -```lua -require: function(name: string): any... -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| ------- | ------ | ---------------- | -| modname | string | 要加载的模块名。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -| any | 如果模块已经加载,则返回 package.loaded[modname] 中存储的值。否则,尝试查找加载器并返回 package.loaded[modname] 的最终值和加载器数据作为第二个结果。 | - -### p - -**类型:** 函数。 - -**描述:** - -检查传递的值的内部结构,并打印值出它的字符串表示。 - -**签名:** - -```lua -p: function(...: any) -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| ------ | ---- | ------------ | -| ... | any | 要检查的值。 | - -### options - -**类型:** 成员变量。 - -**描述:** - -当前编译器选项。 - -**签名:** - -```lua -options: Config.Options -``` - -### traceback - -**类型:** 函数。 - -**描述:** - -重写堆栈跟踪中的行号为 YueScript 代码中的原始行号的 traceback 函数。 - -**签名:** - -```lua -traceback: function(message: string): string -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| ------- | ------ | -------------- | -| message | string | 堆栈跟踪消息。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | ---------------------- | -| string | 重写后的堆栈跟踪消息。 | - -### is_ast - -**类型:** 函数。 - -**描述:** - -检查代码是否匹配指定的 AST。 - -**签名:** - -```lua -is_ast: function(astName: string, code: string): boolean -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| ------- | ------ | ---------- | -| astName | string | AST 名称。 | -| code | string | 代码。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | ------------------ | -| boolean | 代码是否匹配 AST。 | - -### AST - -**类型:** 成员变量。 - -**描述:** - -AST 类型定义,带有名称、行、列和子节点。 - -**签名:** - -```lua -type AST = {string, integer, integer, any} -``` - -### to_ast - -**类型:** 函数。 - -**描述:** - -将代码转换为 AST。 - -**签名:** - -```lua -to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): - --[[AST]] AST | nil, - --[[error]] nil | string -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| -------------- | ------- | ------------------------------------------------------------------------------ | -| code | string | 代码。 | -| flattenLevel | integer | [可选] 扁平化级别。级别越高,会消除更多的 AST 结构的嵌套。默认为 0。最大为 2。 | -| astName | string | [可选] AST 名称。默认为 "File"。 | -| reserveComment | boolean | [可选] 是否保留原始注释。默认为 false。 | - -**返回值:** - -| 返回类型 | 描述 | -| ------------- | -------------------------------- | -| AST \| nil | AST,如果转换失败则为 nil。 | -| string \| nil | 错误消息,如果转换成功则为 nil。 | - -### format - -**类型:** 函数。 - -**描述:** - -格式化 YueScript 代码。 - -**签名:** - -```lua -format: function(code: string, tabSize?: number, reserveComment?: boolean): string -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| -------------- | ------- | -------------------------------------- | -| code | string | 代码。 | -| tabSize | integer | [可选] 制表符大小。默认为 4。 | -| reserveComment | boolean | [可选] 是否保留原始注释。默认为 true。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | ---------------- | -| string | 格式化后的代码。 | - -### \_\_call - -**类型:** 元方法。 - -**描述:** - -导入 YueScript 模块。 -如果发生加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 - -**签名:** - -```lua -metamethod __call: function(self: yue, module: string): any... -``` - -**参数:** - -| 参数名 | 类型 | 描述 | -| ------ | ------ | -------- | -| module | string | 模块名。 | - -**返回值:** - -| 返回类型 | 描述 | -| -------- | -------- | -| any | 模块值。 | - -## Config - -**描述:** - -编译器编译选项。 - -### lint_global - -**类型:** 成员变量。 - -**描述:** - -编译器是否应该收集代码中出现的全局变量。 - -**签名:** - -```lua -lint_global: boolean -``` - -### implicit_return_root - -**类型:** 成员变量。 - -**描述:** - -编译器是否应该对根层级的代码块进行隐式的表达式返回。 - -**签名:** - -```lua -implicit_return_root: boolean -``` - -### reserve_line_number - -**类型:** 成员变量。 - -**描述:** - -编译器是否应该在编译后的代码中保留原始行号。 - -**签名:** - -```lua -reserve_line_number: boolean -``` - -### reserve_comment - -**类型:** 成员变量。 - -**描述:** - -编译器是否应该在编译后的代码中保留原始注释。 - -**签名:** - -```lua -reserve_comment: boolean -``` - -### space_over_tab - -**类型:** 成员变量。 - -**描述:** - -编译器是否应该在编译后的代码中使用空格字符而不是制表符字符。 - -**签名:** - -```lua -space_over_tab: boolean -``` - -### same_module - -**类型:** 成员变量。 - -**描述:** - -编译器是否应该将要编译的代码视为当前正在编译的模块。仅供编译器内部使用。 - -**签名:** - -```lua -same_module: boolean -``` - -### line_offset - -**类型:** 成员变量。 - -**描述:** - -编译器错误消息是否应该包含行号偏移量。仅供编译器内部使用。 - -**签名:** - -```lua -line_offset: integer -``` - -### yue.Config.LuaTarget - -**类型:** 枚举。 - -**描述:** - -目标 Lua 版本枚举。 - -**签名:** - -```lua -enum LuaTarget - "5.1" - "5.2" - "5.3" - "5.4" - "5.5" -end -``` - -### options - -**类型:** 成员变量。 - -**描述:** - -要传递给编译函数的额外选项。 - -**签名:** - -```lua -options: Options -``` - -## Options - -**描述:** - -额外编译器选项定义。 - -### target - -**类型:** 成员变量。 - -**描述:** - -编译目标 Lua 版本。 - -**签名:** - -```lua -target: LuaTarget -``` - -### path - -**类型:** 成员变量。 - -**描述:** - -额外模块搜索路径。 - -**签名:** - -```lua -path: string -``` - -### dump_locals - -**类型:** 成员变量。 - -**描述:** - -是否在回溯错误消息中输出代码块的局部变量。默认为 false。 - -**签名:** - -```lua -dump_locals: boolean -``` - -### simplified - -**类型:** 成员变量。 - -**描述:** - -是否简化输出的错误消息。默认为 true。 - -**签名:** - -```lua -simplified: boolean -``` -- cgit v1.2.3-55-g6feb