diff options
| author | Dania Rifki <atomicnumberphi@gmail.com> | 2026-02-07 18:40:56 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-07 18:48:17 +0800 |
| commit | 8a5e2639d349402ad66d838ed45a124b53c35b7e (patch) | |
| tree | a33227e21ee599e22990e0beb258a536e0b72319 /doc | |
| parent | 85436c1272be0f48a22e1d22badd1cc32d9f09cb (diff) | |
| download | yuescript-8a5e2639d349402ad66d838ed45a124b53c35b7e.tar.gz yuescript-8a5e2639d349402ad66d838ed45a124b53c35b7e.tar.bz2 yuescript-8a5e2639d349402ad66d838ed45a124b53c35b7e.zip | |
Format docs with prettier
Also adjust custom.css a little
Diffstat (limited to 'doc')
164 files changed, 3767 insertions, 2403 deletions
diff --git a/doc/docs/.vitepress/config.mts b/doc/docs/.vitepress/config.mts index 9491a8d..cae1d89 100644 --- a/doc/docs/.vitepress/config.mts +++ b/doc/docs/.vitepress/config.mts | |||
| @@ -1,338 +1,388 @@ | |||
| 1 | import { readFileSync } from 'fs'; | 1 | import { readFileSync } from "fs"; |
| 2 | import { | 2 | import { dirname, resolve } from "path"; |
| 3 | dirname, | 3 | import { fileURLToPath } from "url"; |
| 4 | resolve, | 4 | import { defineConfig } from "vitepress"; |
| 5 | } from 'path'; | ||
| 6 | import { fileURLToPath } from 'url'; | ||
| 7 | import { defineConfig } from 'vitepress'; | ||
| 8 | 5 | ||
| 9 | import darkPlus from '@shikijs/themes/dark-plus'; | 6 | import darkPlus from "@shikijs/themes/dark-plus"; |
| 10 | import lightPlus from '@shikijs/themes/light-plus'; | 7 | import lightPlus from "@shikijs/themes/light-plus"; |
| 11 | 8 | ||
| 12 | const __dirname = dirname(fileURLToPath(import.meta.url)) | 9 | const __dirname = dirname(fileURLToPath(import.meta.url)); |
| 13 | const yuescriptGrammarPath = resolve(__dirname, 'grammars/yuescript.tmLanguage.json') | 10 | const yuescriptGrammarPath = resolve( |
| 14 | const yuescriptGrammar = JSON.parse(readFileSync(yuescriptGrammarPath, 'utf-8')) | 11 | __dirname, |
| 12 | "grammars/yuescript.tmLanguage.json", | ||
| 13 | ); | ||
| 14 | const yuescriptGrammar = JSON.parse( | ||
| 15 | readFileSync(yuescriptGrammarPath, "utf-8"), | ||
| 16 | ); | ||
| 15 | const yuescriptLanguage = { | 17 | const yuescriptLanguage = { |
| 16 | ...yuescriptGrammar, | 18 | ...yuescriptGrammar, |
| 17 | name: 'yuescript', | 19 | name: "yuescript", |
| 18 | scopeName: 'source.yuescript', | 20 | scopeName: "source.yuescript", |
| 19 | aliases: ['yue'], | 21 | aliases: ["yue"], |
| 20 | } | 22 | }; |
| 21 | 23 | ||
| 22 | const sidebarText = { | 24 | const sidebarText = { |
| 23 | de: { | 25 | de: { |
| 24 | introduction: 'Einführung', | 26 | introduction: "Einführung", |
| 25 | installation: 'Installation', | 27 | installation: "Installation", |
| 26 | usage: 'Verwendung', | 28 | usage: "Verwendung", |
| 27 | macro: 'Makro', | 29 | macro: "Makro", |
| 28 | operator: 'Operatoren', | 30 | operator: "Operatoren", |
| 29 | module: 'Modul', | 31 | module: "Modul", |
| 30 | assignment: 'Zuweisung', | 32 | assignment: "Zuweisung", |
| 31 | destructuringAssignment: 'Destrukturierende Zuweisung', | 33 | destructuringAssignment: "Destrukturierende Zuweisung", |
| 32 | ifAssignment: 'If-Zuweisung', | 34 | ifAssignment: "If-Zuweisung", |
| 33 | varargsAssignment: 'Varargs-Zuweisung', | 35 | varargsAssignment: "Varargs-Zuweisung", |
| 34 | whitespace: 'Leerraum', | 36 | whitespace: "Leerraum", |
| 35 | comment: 'Kommentare', | 37 | comment: "Kommentare", |
| 36 | try: 'Try/Catch', | 38 | try: "Try/Catch", |
| 37 | attributes: 'Attribute', | 39 | attributes: "Attribute", |
| 38 | literals: 'Literale', | 40 | literals: "Literale", |
| 39 | functionLiterals: 'Funktionsliterale', | 41 | functionLiterals: "Funktionsliterale", |
| 40 | backcalls: 'Backcalls', | 42 | backcalls: "Backcalls", |
| 41 | tableLiterals: 'Tabellenliterale', | 43 | tableLiterals: "Tabellenliterale", |
| 42 | comprehensions: 'Comprehensions', | 44 | comprehensions: "Comprehensions", |
| 43 | forLoop: 'For-Schleife', | 45 | forLoop: "For-Schleife", |
| 44 | whileLoop: 'While-Schleife', | 46 | whileLoop: "While-Schleife", |
| 45 | continueStatement: 'Continue-Anweisung', | 47 | continueStatement: "Continue-Anweisung", |
| 46 | conditionals: 'Bedingungen', | 48 | conditionals: "Bedingungen", |
| 47 | lineDecorators: 'Zeilen-Dekoratoren', | 49 | lineDecorators: "Zeilen-Dekoratoren", |
| 48 | switch: 'Switch', | 50 | switch: "Switch", |
| 49 | objectOrientedProgramming: 'Objektorientierte Programmierung', | 51 | objectOrientedProgramming: "Objektorientierte Programmierung", |
| 50 | withStatement: 'With-Anweisung', | 52 | withStatement: "With-Anweisung", |
| 51 | do: 'Do', | 53 | do: "Do", |
| 52 | functionStubs: 'Funktions-Stubs', | 54 | functionStubs: "Funktions-Stubs", |
| 53 | usingClause: 'Die Using-Klausel; Kontrolle destruktiver Zuweisung', | 55 | usingClause: "Die Using-Klausel; Kontrolle destruktiver Zuweisung", |
| 54 | yuescriptLibrary: 'Die YueScript-Bibliothek', | 56 | yuescriptLibrary: "Die YueScript-Bibliothek", |
| 55 | licenseMit: 'Lizenz: MIT', | 57 | licenseMit: "Lizenz: MIT", |
| 56 | }, | 58 | }, |
| 57 | en: { | 59 | en: { |
| 58 | introduction: 'Introduction', | 60 | introduction: "Introduction", |
| 59 | installation: 'Installation', | 61 | installation: "Installation", |
| 60 | usage: 'Usage', | 62 | usage: "Usage", |
| 61 | macro: 'Macro', | 63 | macro: "Macro", |
| 62 | operator: 'Operator', | 64 | operator: "Operator", |
| 63 | module: 'Module', | 65 | module: "Module", |
| 64 | assignment: 'Assignment', | 66 | assignment: "Assignment", |
| 65 | destructuringAssignment: 'Destructuring Assignment', | 67 | destructuringAssignment: "Destructuring Assignment", |
| 66 | ifAssignment: 'If Assignment', | 68 | ifAssignment: "If Assignment", |
| 67 | varargsAssignment: 'Varargs Assignment', | 69 | varargsAssignment: "Varargs Assignment", |
| 68 | whitespace: 'Whitespace', | 70 | whitespace: "Whitespace", |
| 69 | comment: 'Comment', | 71 | comment: "Comment", |
| 70 | try: 'Try', | 72 | try: "Try", |
| 71 | attributes: 'Attributes', | 73 | attributes: "Attributes", |
| 72 | literals: 'Literals', | 74 | literals: "Literals", |
| 73 | functionLiterals: 'Function Literals', | 75 | functionLiterals: "Function Literals", |
| 74 | backcalls: 'Backcalls', | 76 | backcalls: "Backcalls", |
| 75 | tableLiterals: 'Table Literals', | 77 | tableLiterals: "Table Literals", |
| 76 | comprehensions: 'Comprehensions', | 78 | comprehensions: "Comprehensions", |
| 77 | forLoop: 'For Loop', | 79 | forLoop: "For Loop", |
| 78 | whileLoop: 'While Loop', | 80 | whileLoop: "While Loop", |
| 79 | continueStatement: 'Continue Statement', | 81 | continueStatement: "Continue Statement", |
| 80 | conditionals: 'Conditionals', | 82 | conditionals: "Conditionals", |
| 81 | lineDecorators: 'Line Decorators', | 83 | lineDecorators: "Line Decorators", |
| 82 | switch: 'Switch', | 84 | switch: "Switch", |
| 83 | objectOrientedProgramming: 'Object Oriented Programming', | 85 | objectOrientedProgramming: "Object Oriented Programming", |
| 84 | withStatement: 'With Statement', | 86 | withStatement: "With Statement", |
| 85 | do: 'Do', | 87 | do: "Do", |
| 86 | functionStubs: 'Function Stubs', | 88 | functionStubs: "Function Stubs", |
| 87 | usingClause: 'The Using Clause; Controlling Destructive Assignment', | 89 | usingClause: "The Using Clause; Controlling Destructive Assignment", |
| 88 | yuescriptLibrary: 'The YueScript Library', | 90 | yuescriptLibrary: "The YueScript Library", |
| 89 | licenseMit: 'License: MIT', | 91 | licenseMit: "License: MIT", |
| 90 | }, | 92 | }, |
| 91 | idId: { | 93 | idId: { |
| 92 | introduction: 'Pendahuluan', | 94 | introduction: "Pendahuluan", |
| 93 | installation: 'Instalasi', | 95 | installation: "Instalasi", |
| 94 | usage: 'Penggunaan', | 96 | usage: "Penggunaan", |
| 95 | macro: 'Makro', | 97 | macro: "Makro", |
| 96 | operator: 'Operator', | 98 | operator: "Operator", |
| 97 | module: 'Modul', | 99 | module: "Modul", |
| 98 | assignment: 'Penugasan', | 100 | assignment: "Penugasan", |
| 99 | destructuringAssignment: 'Penugasan Destrukturisasi', | 101 | destructuringAssignment: "Penugasan Destrukturisasi", |
| 100 | ifAssignment: 'Penugasan If', | 102 | ifAssignment: "Penugasan If", |
| 101 | varargsAssignment: 'Penugasan Varargs', | 103 | varargsAssignment: "Penugasan Varargs", |
| 102 | whitespace: 'Spasi Kosong', | 104 | whitespace: "Spasi Kosong", |
| 103 | comment: 'Komentar', | 105 | comment: "Komentar", |
| 104 | try: 'Coba', | 106 | try: "Coba", |
| 105 | attributes: 'Atribut', | 107 | attributes: "Atribut", |
| 106 | literals: 'Literal', | 108 | literals: "Literal", |
| 107 | functionLiterals: 'Literal Fungsi', | 109 | functionLiterals: "Literal Fungsi", |
| 108 | backcalls: 'Pemanggilan Mundur', | 110 | backcalls: "Pemanggilan Mundur", |
| 109 | tableLiterals: 'Literal Tabel', | 111 | tableLiterals: "Literal Tabel", |
| 110 | comprehensions: 'Kompresi', | 112 | comprehensions: "Kompresi", |
| 111 | forLoop: 'Perulangan For', | 113 | forLoop: "Perulangan For", |
| 112 | whileLoop: 'Perulangan While', | 114 | whileLoop: "Perulangan While", |
| 113 | continueStatement: 'Pernyataan Lanjutkan', | 115 | continueStatement: "Pernyataan Lanjutkan", |
| 114 | conditionals: 'Percabangan', | 116 | conditionals: "Percabangan", |
| 115 | lineDecorators: 'Dekorator Baris', | 117 | lineDecorators: "Dekorator Baris", |
| 116 | switch: 'Switch', | 118 | switch: "Switch", |
| 117 | objectOrientedProgramming: 'Pemrograman Berorientasi Objek', | 119 | objectOrientedProgramming: "Pemrograman Berorientasi Objek", |
| 118 | withStatement: 'Pernyataan With', | 120 | withStatement: "Pernyataan With", |
| 119 | do: 'Do', | 121 | do: "Do", |
| 120 | functionStubs: 'Fungsi Sementara', | 122 | functionStubs: "Fungsi Sementara", |
| 121 | usingClause: 'Klausa Using; Mengontrol Penugasan Destruktif', | 123 | usingClause: "Klausa Using; Mengontrol Penugasan Destruktif", |
| 122 | yuescriptLibrary: 'Pustaka YueScript', | 124 | yuescriptLibrary: "Pustaka YueScript", |
| 123 | licenseMit: 'Lisensi: MIT', | 125 | licenseMit: "Lisensi: MIT", |
| 124 | }, | 126 | }, |
| 125 | ptBr: { | 127 | ptBr: { |
| 126 | introduction: 'Introdução', | 128 | introduction: "Introdução", |
| 127 | installation: 'Instalação', | 129 | installation: "Instalação", |
| 128 | usage: 'Uso', | 130 | usage: "Uso", |
| 129 | macro: 'Macro', | 131 | macro: "Macro", |
| 130 | operator: 'Operadores', | 132 | operator: "Operadores", |
| 131 | module: 'Módulo', | 133 | module: "Módulo", |
| 132 | assignment: 'Atribuição', | 134 | assignment: "Atribuição", |
| 133 | destructuringAssignment: 'Atribuição com desestruturação', | 135 | destructuringAssignment: "Atribuição com desestruturação", |
| 134 | ifAssignment: 'Atribuição com if', | 136 | ifAssignment: "Atribuição com if", |
| 135 | varargsAssignment: 'Atribuição de varargs', | 137 | varargsAssignment: "Atribuição de varargs", |
| 136 | whitespace: 'Espaços em branco', | 138 | whitespace: "Espaços em branco", |
| 137 | comment: 'Comentários', | 139 | comment: "Comentários", |
| 138 | try: 'Try/Catch', | 140 | try: "Try/Catch", |
| 139 | attributes: 'Atributos', | 141 | attributes: "Atributos", |
| 140 | literals: 'Literais', | 142 | literals: "Literais", |
| 141 | functionLiterals: 'Literais de função', | 143 | functionLiterals: "Literais de função", |
| 142 | backcalls: 'Backcalls', | 144 | backcalls: "Backcalls", |
| 143 | tableLiterals: 'Literais de tabela', | 145 | tableLiterals: "Literais de tabela", |
| 144 | comprehensions: 'Compreensões', | 146 | comprehensions: "Compreensões", |
| 145 | forLoop: 'Laço for', | 147 | forLoop: "Laço for", |
| 146 | whileLoop: 'Laço while', | 148 | whileLoop: "Laço while", |
| 147 | continueStatement: 'Instrução continue', | 149 | continueStatement: "Instrução continue", |
| 148 | conditionals: 'Condicionais', | 150 | conditionals: "Condicionais", |
| 149 | lineDecorators: 'Decoradores de linha', | 151 | lineDecorators: "Decoradores de linha", |
| 150 | switch: 'Switch', | 152 | switch: "Switch", |
| 151 | objectOrientedProgramming: 'Programação orientada a objetos', | 153 | objectOrientedProgramming: "Programação orientada a objetos", |
| 152 | withStatement: 'Instrução with', | 154 | withStatement: "Instrução with", |
| 153 | do: 'Do', | 155 | do: "Do", |
| 154 | functionStubs: 'Stubs de função', | 156 | functionStubs: "Stubs de função", |
| 155 | usingClause: 'Cláusula using; controlando atribuição destrutiva', | 157 | usingClause: "Cláusula using; controlando atribuição destrutiva", |
| 156 | yuescriptLibrary: 'A biblioteca do YueScript', | 158 | yuescriptLibrary: "A biblioteca do YueScript", |
| 157 | licenseMit: 'Licença: MIT', | 159 | licenseMit: "Licença: MIT", |
| 158 | }, | 160 | }, |
| 159 | zh: { | 161 | zh: { |
| 160 | introduction: '介绍', | 162 | introduction: "介绍", |
| 161 | installation: '安装', | 163 | installation: "安装", |
| 162 | usage: '使用方法', | 164 | usage: "使用方法", |
| 163 | macro: '宏', | 165 | macro: "宏", |
| 164 | operator: '操作符', | 166 | operator: "操作符", |
| 165 | module: '模块', | 167 | module: "模块", |
| 166 | assignment: '赋值', | 168 | assignment: "赋值", |
| 167 | destructuringAssignment: '解构赋值', | 169 | destructuringAssignment: "解构赋值", |
| 168 | ifAssignment: 'if 赋值', | 170 | ifAssignment: "if 赋值", |
| 169 | varargsAssignment: '可变参数赋值', | 171 | varargsAssignment: "可变参数赋值", |
| 170 | whitespace: '空白', | 172 | whitespace: "空白", |
| 171 | comment: '注释', | 173 | comment: "注释", |
| 172 | try: '错误处理', | 174 | try: "错误处理", |
| 173 | attributes: '属性', | 175 | attributes: "属性", |
| 174 | literals: '字面量', | 176 | literals: "字面量", |
| 175 | functionLiterals: '函数字面量', | 177 | functionLiterals: "函数字面量", |
| 176 | backcalls: '反向回调', | 178 | backcalls: "反向回调", |
| 177 | tableLiterals: '表格字面量', | 179 | tableLiterals: "表格字面量", |
| 178 | comprehensions: '推导式', | 180 | comprehensions: "推导式", |
| 179 | forLoop: 'for 循环', | 181 | forLoop: "for 循环", |
| 180 | whileLoop: 'while 循环', | 182 | whileLoop: "while 循环", |
| 181 | continueStatement: 'continue 语句', | 183 | continueStatement: "continue 语句", |
| 182 | conditionals: '条件语句', | 184 | conditionals: "条件语句", |
| 183 | lineDecorators: '代码行修饰符', | 185 | lineDecorators: "代码行修饰符", |
| 184 | switch: 'switch 语句', | 186 | switch: "switch 语句", |
| 185 | objectOrientedProgramming: '面向对象编程', | 187 | objectOrientedProgramming: "面向对象编程", |
| 186 | withStatement: 'with 语句', | 188 | withStatement: "with 语句", |
| 187 | do: 'do 语句', | 189 | do: "do 语句", |
| 188 | functionStubs: '函数存根', | 190 | functionStubs: "函数存根", |
| 189 | usingClause: '使用 using 语句:防止破坏性赋值', | 191 | usingClause: "使用 using 语句:防止破坏性赋值", |
| 190 | yuescriptLibrary: '月之脚本语言库', | 192 | yuescriptLibrary: "月之脚本语言库", |
| 191 | licenseMit: 'MIT 许可证', | 193 | licenseMit: "MIT 许可证", |
| 192 | }, | 194 | }, |
| 193 | } as const | 195 | } as const; |
| 194 | 196 | ||
| 195 | type SidebarLocale = keyof typeof sidebarText | 197 | type SidebarLocale = keyof typeof sidebarText; |
| 196 | 198 | ||
| 197 | type SidebarGroupText = { | 199 | type SidebarGroupText = { |
| 198 | gettingStarted: string | 200 | gettingStarted: string; |
| 199 | languageBasics: string | 201 | languageBasics: string; |
| 200 | assignment: string | 202 | assignment: string; |
| 201 | functions: string | 203 | functions: string; |
| 202 | controlFlow: string | 204 | controlFlow: string; |
| 203 | dataStructures: string | 205 | dataStructures: string; |
| 204 | objects: string | 206 | objects: string; |
| 205 | advancedFeatures: string | 207 | advancedFeatures: string; |
| 206 | reference: string | 208 | reference: string; |
| 207 | } | 209 | }; |
| 208 | 210 | ||
| 209 | const sidebarGroups: Record<SidebarLocale, SidebarGroupText> = { | 211 | const sidebarGroups: Record<SidebarLocale, SidebarGroupText> = { |
| 210 | de: { | 212 | de: { |
| 211 | gettingStarted: 'Erste Schritte', | 213 | gettingStarted: "Erste Schritte", |
| 212 | languageBasics: 'Sprachgrundlagen', | 214 | languageBasics: "Sprachgrundlagen", |
| 213 | assignment: 'Zuweisung', | 215 | assignment: "Zuweisung", |
| 214 | functions: 'Funktionen', | 216 | functions: "Funktionen", |
| 215 | controlFlow: 'Kontrollfluss', | 217 | controlFlow: "Kontrollfluss", |
| 216 | dataStructures: 'Datenstrukturen', | 218 | dataStructures: "Datenstrukturen", |
| 217 | objects: 'Objekte', | 219 | objects: "Objekte", |
| 218 | advancedFeatures: 'Erweiterte Funktionen', | 220 | advancedFeatures: "Erweiterte Funktionen", |
| 219 | reference: 'Referenz', | 221 | reference: "Referenz", |
| 220 | }, | 222 | }, |
| 221 | en: { | 223 | en: { |
| 222 | gettingStarted: 'Getting Started', | 224 | gettingStarted: "Getting Started", |
| 223 | languageBasics: 'Language Basics', | 225 | languageBasics: "Language Basics", |
| 224 | assignment: 'Assignment', | 226 | assignment: "Assignment", |
| 225 | functions: 'Functions', | 227 | functions: "Functions", |
| 226 | controlFlow: 'Control Flow', | 228 | controlFlow: "Control Flow", |
| 227 | dataStructures: 'Data Structures', | 229 | dataStructures: "Data Structures", |
| 228 | objects: 'Objects', | 230 | objects: "Objects", |
| 229 | advancedFeatures: 'Advanced Features', | 231 | advancedFeatures: "Advanced Features", |
| 230 | reference: 'Reference', | 232 | reference: "Reference", |
| 231 | }, | 233 | }, |
| 232 | idId: { | 234 | idId: { |
| 233 | gettingStarted: 'Memulai', | 235 | gettingStarted: "Memulai", |
| 234 | languageBasics: 'Dasar-dasar Bahasa', | 236 | languageBasics: "Dasar-dasar Bahasa", |
| 235 | assignment: 'Penugasan', | 237 | assignment: "Penugasan", |
| 236 | functions: 'Fungsi', | 238 | functions: "Fungsi", |
| 237 | controlFlow: 'Alur Kontrol', | 239 | controlFlow: "Alur Kontrol", |
| 238 | dataStructures: 'Struktur Data', | 240 | dataStructures: "Struktur Data", |
| 239 | objects: 'Objek', | 241 | objects: "Objek", |
| 240 | advancedFeatures: 'Fitur Lanjutan', | 242 | advancedFeatures: "Fitur Lanjutan", |
| 241 | reference: 'Referensi', | 243 | reference: "Referensi", |
| 242 | }, | 244 | }, |
| 243 | ptBr: { | 245 | ptBr: { |
| 244 | gettingStarted: 'Primeiros passos', | 246 | gettingStarted: "Primeiros passos", |
| 245 | languageBasics: 'Fundamentos da linguagem', | 247 | languageBasics: "Fundamentos da linguagem", |
| 246 | assignment: 'Atribuição', | 248 | assignment: "Atribuição", |
| 247 | functions: 'Funções', | 249 | functions: "Funções", |
| 248 | controlFlow: 'Controle de fluxo', | 250 | controlFlow: "Controle de fluxo", |
| 249 | dataStructures: 'Estruturas de dados', | 251 | dataStructures: "Estruturas de dados", |
| 250 | objects: 'Objetos', | 252 | objects: "Objetos", |
| 251 | advancedFeatures: 'Recursos avançados', | 253 | advancedFeatures: "Recursos avançados", |
| 252 | reference: 'Referência', | 254 | reference: "Referência", |
| 253 | }, | 255 | }, |
| 254 | zh: { | 256 | zh: { |
| 255 | gettingStarted: '起步', | 257 | gettingStarted: "起步", |
| 256 | languageBasics: '语言基础', | 258 | languageBasics: "语言基础", |
| 257 | assignment: '赋值', | 259 | assignment: "赋值", |
| 258 | functions: '函数', | 260 | functions: "函数", |
| 259 | controlFlow: '控制流', | 261 | controlFlow: "控制流", |
| 260 | dataStructures: '数据结构', | 262 | dataStructures: "数据结构", |
| 261 | objects: '面向对象', | 263 | objects: "面向对象", |
| 262 | advancedFeatures: '高级特性', | 264 | advancedFeatures: "高级特性", |
| 263 | reference: '参考', | 265 | reference: "参考", |
| 264 | }, | 266 | }, |
| 265 | } | 267 | }; |
| 266 | 268 | ||
| 267 | function createSidebar(basePath: string, locale: SidebarLocale) { | 269 | function createSidebar(basePath: string, locale: SidebarLocale) { |
| 268 | const text = sidebarText[locale] | 270 | const text = sidebarText[locale]; |
| 269 | const group = sidebarGroups[locale] | 271 | const group = sidebarGroups[locale]; |
| 270 | return [ | 272 | return [ |
| 271 | { | 273 | { |
| 272 | text: group.gettingStarted, | 274 | text: group.gettingStarted, |
| 273 | items: [ | 275 | items: [ |
| 274 | { text: text.introduction, link: `${basePath}/getting-started/introduction` }, | 276 | { |
| 275 | { text: text.installation, link: `${basePath}/getting-started/installation` }, | 277 | text: text.introduction, |
| 278 | link: `${basePath}/getting-started/introduction`, | ||
| 279 | }, | ||
| 280 | { | ||
| 281 | text: text.installation, | ||
| 282 | link: `${basePath}/getting-started/installation`, | ||
| 283 | }, | ||
| 276 | { text: text.usage, link: `${basePath}/getting-started/usage` }, | 284 | { text: text.usage, link: `${basePath}/getting-started/usage` }, |
| 277 | ] | 285 | ], |
| 278 | }, | 286 | }, |
| 279 | { | 287 | { |
| 280 | text: group.languageBasics, | 288 | text: group.languageBasics, |
| 281 | collapsed: true, | 289 | collapsed: true, |
| 282 | items: [ | 290 | items: [ |
| 283 | { text: text.whitespace, link: `${basePath}/language-basics/whitespace` }, | 291 | { |
| 292 | text: text.whitespace, | ||
| 293 | link: `${basePath}/language-basics/whitespace`, | ||
| 294 | }, | ||
| 284 | { text: text.comment, link: `${basePath}/language-basics/comment` }, | 295 | { text: text.comment, link: `${basePath}/language-basics/comment` }, |
| 285 | { text: text.literals, link: `${basePath}/language-basics/literals` }, | 296 | { text: text.literals, link: `${basePath}/language-basics/literals` }, |
| 286 | { text: text.operator, link: `${basePath}/language-basics/operator` }, | 297 | { text: text.operator, link: `${basePath}/language-basics/operator` }, |
| 287 | { text: text.attributes, link: `${basePath}/language-basics/attributes` }, | 298 | { |
| 288 | ] | 299 | text: text.attributes, |
| 300 | link: `${basePath}/language-basics/attributes`, | ||
| 301 | }, | ||
| 302 | ], | ||
| 289 | }, | 303 | }, |
| 290 | { | 304 | { |
| 291 | text: group.assignment, | 305 | text: group.assignment, |
| 292 | collapsed: true, | 306 | collapsed: true, |
| 293 | items: [ | 307 | items: [ |
| 294 | { text: text.assignment, link: `${basePath}/assignment/assignment` }, | 308 | { text: text.assignment, link: `${basePath}/assignment/assignment` }, |
| 295 | { text: text.destructuringAssignment, link: `${basePath}/assignment/destructuring-assignment` }, | 309 | { |
| 296 | { text: text.ifAssignment, link: `${basePath}/assignment/if-assignment` }, | 310 | text: text.destructuringAssignment, |
| 297 | { text: text.varargsAssignment, link: `${basePath}/assignment/varargs-assignment` }, | 311 | link: `${basePath}/assignment/destructuring-assignment`, |
| 298 | { text: text.usingClause, link: `${basePath}/assignment/the-using-clause-controlling-destructive-assignment` }, | 312 | }, |
| 299 | ] | 313 | { |
| 314 | text: text.ifAssignment, | ||
| 315 | link: `${basePath}/assignment/if-assignment`, | ||
| 316 | }, | ||
| 317 | { | ||
| 318 | text: text.varargsAssignment, | ||
| 319 | link: `${basePath}/assignment/varargs-assignment`, | ||
| 320 | }, | ||
| 321 | { | ||
| 322 | text: text.usingClause, | ||
| 323 | link: `${basePath}/assignment/the-using-clause-controlling-destructive-assignment`, | ||
| 324 | }, | ||
| 325 | ], | ||
| 300 | }, | 326 | }, |
| 301 | { | 327 | { |
| 302 | text: group.functions, | 328 | text: group.functions, |
| 303 | collapsed: true, | 329 | collapsed: true, |
| 304 | items: [ | 330 | items: [ |
| 305 | { text: text.functionLiterals, link: `${basePath}/functions/function-literals` }, | 331 | { |
| 332 | text: text.functionLiterals, | ||
| 333 | link: `${basePath}/functions/function-literals`, | ||
| 334 | }, | ||
| 306 | { text: text.backcalls, link: `${basePath}/functions/backcalls` }, | 335 | { text: text.backcalls, link: `${basePath}/functions/backcalls` }, |
| 307 | { text: text.functionStubs, link: `${basePath}/functions/function-stubs` }, | 336 | { |
| 308 | ] | 337 | text: text.functionStubs, |
| 338 | link: `${basePath}/functions/function-stubs`, | ||
| 339 | }, | ||
| 340 | ], | ||
| 309 | }, | 341 | }, |
| 310 | { | 342 | { |
| 311 | text: group.controlFlow, | 343 | text: group.controlFlow, |
| 312 | collapsed: true, | 344 | collapsed: true, |
| 313 | items: [ | 345 | items: [ |
| 314 | { text: text.conditionals, link: `${basePath}/control-flow/conditionals` }, | 346 | { |
| 347 | text: text.conditionals, | ||
| 348 | link: `${basePath}/control-flow/conditionals`, | ||
| 349 | }, | ||
| 315 | { text: text.forLoop, link: `${basePath}/control-flow/for-loop` }, | 350 | { text: text.forLoop, link: `${basePath}/control-flow/for-loop` }, |
| 316 | { text: text.whileLoop, link: `${basePath}/control-flow/while-loop` }, | 351 | { text: text.whileLoop, link: `${basePath}/control-flow/while-loop` }, |
| 317 | { text: text.continueStatement, link: `${basePath}/control-flow/continue` }, | 352 | { |
| 353 | text: text.continueStatement, | ||
| 354 | link: `${basePath}/control-flow/continue`, | ||
| 355 | }, | ||
| 318 | { text: text.switch, link: `${basePath}/control-flow/switch` }, | 356 | { text: text.switch, link: `${basePath}/control-flow/switch` }, |
| 319 | ] | 357 | ], |
| 320 | }, | 358 | }, |
| 321 | { | 359 | { |
| 322 | text: group.dataStructures, | 360 | text: group.dataStructures, |
| 323 | collapsed: true, | 361 | collapsed: true, |
| 324 | items: [ | 362 | items: [ |
| 325 | { text: text.tableLiterals, link: `${basePath}/data-structures/table-literals` }, | 363 | { |
| 326 | { text: text.comprehensions, link: `${basePath}/data-structures/comprehensions` }, | 364 | text: text.tableLiterals, |
| 327 | ] | 365 | link: `${basePath}/data-structures/table-literals`, |
| 366 | }, | ||
| 367 | { | ||
| 368 | text: text.comprehensions, | ||
| 369 | link: `${basePath}/data-structures/comprehensions`, | ||
| 370 | }, | ||
| 371 | ], | ||
| 328 | }, | 372 | }, |
| 329 | { | 373 | { |
| 330 | text: group.objects, | 374 | text: group.objects, |
| 331 | collapsed: true, | 375 | collapsed: true, |
| 332 | items: [ | 376 | items: [ |
| 333 | { text: text.objectOrientedProgramming, link: `${basePath}/objects/object-oriented-programming` }, | 377 | { |
| 334 | { text: text.withStatement, link: `${basePath}/objects/with-statement` }, | 378 | text: text.objectOrientedProgramming, |
| 335 | ] | 379 | link: `${basePath}/objects/object-oriented-programming`, |
| 380 | }, | ||
| 381 | { | ||
| 382 | text: text.withStatement, | ||
| 383 | link: `${basePath}/objects/with-statement`, | ||
| 384 | }, | ||
| 385 | ], | ||
| 336 | }, | 386 | }, |
| 337 | { | 387 | { |
| 338 | text: group.advancedFeatures, | 388 | text: group.advancedFeatures, |
| @@ -340,46 +390,104 @@ function createSidebar(basePath: string, locale: SidebarLocale) { | |||
| 340 | items: [ | 390 | items: [ |
| 341 | { text: text.macro, link: `${basePath}/advanced/macro` }, | 391 | { text: text.macro, link: `${basePath}/advanced/macro` }, |
| 342 | { text: text.module, link: `${basePath}/advanced/module` }, | 392 | { text: text.module, link: `${basePath}/advanced/module` }, |
| 343 | { text: text.lineDecorators, link: `${basePath}/advanced/line-decorators` }, | 393 | { |
| 394 | text: text.lineDecorators, | ||
| 395 | link: `${basePath}/advanced/line-decorators`, | ||
| 396 | }, | ||
| 344 | { text: text.do, link: `${basePath}/advanced/do` }, | 397 | { text: text.do, link: `${basePath}/advanced/do` }, |
| 345 | { text: text.try, link: `${basePath}/advanced/try` }, | 398 | { text: text.try, link: `${basePath}/advanced/try` }, |
| 346 | ] | 399 | ], |
| 347 | }, | 400 | }, |
| 348 | { | 401 | { |
| 349 | text: group.reference, | 402 | text: group.reference, |
| 350 | collapsed: true, | 403 | collapsed: true, |
| 351 | items: [ | 404 | items: [ |
| 352 | { text: text.yuescriptLibrary, link: `${basePath}/reference/the-yuescript-library` }, | 405 | { |
| 406 | text: text.yuescriptLibrary, | ||
| 407 | link: `${basePath}/reference/the-yuescript-library`, | ||
| 408 | }, | ||
| 353 | { text: text.licenseMit, link: `${basePath}/reference/license-mit` }, | 409 | { text: text.licenseMit, link: `${basePath}/reference/license-mit` }, |
| 354 | ] | 410 | ], |
| 355 | }, | 411 | }, |
| 356 | ] | 412 | ]; |
| 357 | } | 413 | } |
| 358 | 414 | ||
| 359 | export default defineConfig({ | 415 | export default defineConfig({ |
| 360 | title: 'YueScript', | 416 | title: "YueScript", |
| 361 | description: 'A language that compiles to Lua', | 417 | description: "A language that compiles to Lua", |
| 362 | base: '/', | 418 | base: "/", |
| 363 | head: [ | 419 | head: [ |
| 364 | ['meta', { name: 'theme-color', content: '#b4ac8f' }], | 420 | ["meta", { name: "theme-color", content: "#b4ac8f" }], |
| 365 | ['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }], | 421 | ["meta", { name: "apple-mobile-web-app-capable", content: "yes" }], |
| 366 | ['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }], | 422 | [ |
| 367 | ['meta', { property: 'og:title', content: 'YueScript' }], | 423 | "meta", |
| 368 | ['meta', { property: 'og:description', content: 'A language that compiles to Lua' }], | 424 | { name: "apple-mobile-web-app-status-bar-style", content: "black" }, |
| 369 | ['meta', { property: 'og:type', content: 'website' }], | 425 | ], |
| 370 | ['meta', { property: 'og:image', content: '/image/yuescript.png' }], | 426 | ["meta", { property: "og:title", content: "YueScript" }], |
| 371 | ['meta', { property: 'og:image:secure_url', content: '/image/yuescript.png' }], | 427 | [ |
| 372 | ['meta', { property: 'og:image:type', content: 'image/png' }], | 428 | "meta", |
| 373 | ['meta', { property: 'og:image:width', content: '1200' }], | 429 | { |
| 374 | ['meta', { property: 'og:image:height', content: '1200' }], | 430 | property: "og:description", |
| 375 | ['link', { rel: 'icon', href: '/image/favicon/favicon-16x16.png', sizes: '16x16', type: 'image/png' }], | 431 | content: "A language that compiles to Lua", |
| 376 | ['link', { rel: 'icon', href: '/image/favicon/favicon-32x32.png', sizes: '32x32', type: 'image/png' }], | 432 | }, |
| 377 | ['link', { rel: 'apple-touch-icon', href: '/image/favicon/apple-touch-icon.png', sizes: '180x180', type: 'image/png' }], | 433 | ], |
| 378 | ['link', { rel: 'android-chrome', href: '/image/favicon/android-chrome-192x192.png', sizes: '192x192', type: 'image/png' }], | 434 | ["meta", { property: "og:type", content: "website" }], |
| 379 | ['link', { rel: 'android-chrome', href: '/image/favicon/android-chrome-512x512.png', sizes: '512x512', type: 'image/png' }], | 435 | ["meta", { property: "og:image", content: "/image/yuescript.png" }], |
| 380 | ['script', {}, 'window.global = window;'], | 436 | [ |
| 437 | "meta", | ||
| 438 | { property: "og:image:secure_url", content: "/image/yuescript.png" }, | ||
| 439 | ], | ||
| 440 | ["meta", { property: "og:image:type", content: "image/png" }], | ||
| 441 | ["meta", { property: "og:image:width", content: "1200" }], | ||
| 442 | ["meta", { property: "og:image:height", content: "1200" }], | ||
| 443 | [ | ||
| 444 | "link", | ||
| 445 | { | ||
| 446 | rel: "icon", | ||
| 447 | href: "/image/favicon/favicon-16x16.png", | ||
| 448 | sizes: "16x16", | ||
| 449 | type: "image/png", | ||
| 450 | }, | ||
| 451 | ], | ||
| 381 | [ | 452 | [ |
| 382 | 'script', | 453 | "link", |
| 454 | { | ||
| 455 | rel: "icon", | ||
| 456 | href: "/image/favicon/favicon-32x32.png", | ||
| 457 | sizes: "32x32", | ||
| 458 | type: "image/png", | ||
| 459 | }, | ||
| 460 | ], | ||
| 461 | [ | ||
| 462 | "link", | ||
| 463 | { | ||
| 464 | rel: "apple-touch-icon", | ||
| 465 | href: "/image/favicon/apple-touch-icon.png", | ||
| 466 | sizes: "180x180", | ||
| 467 | type: "image/png", | ||
| 468 | }, | ||
| 469 | ], | ||
| 470 | [ | ||
| 471 | "link", | ||
| 472 | { | ||
| 473 | rel: "android-chrome", | ||
| 474 | href: "/image/favicon/android-chrome-192x192.png", | ||
| 475 | sizes: "192x192", | ||
| 476 | type: "image/png", | ||
| 477 | }, | ||
| 478 | ], | ||
| 479 | [ | ||
| 480 | "link", | ||
| 481 | { | ||
| 482 | rel: "android-chrome", | ||
| 483 | href: "/image/favicon/android-chrome-512x512.png", | ||
| 484 | sizes: "512x512", | ||
| 485 | type: "image/png", | ||
| 486 | }, | ||
| 487 | ], | ||
| 488 | ["script", {}, "window.global = window;"], | ||
| 489 | [ | ||
| 490 | "script", | ||
| 383 | {}, | 491 | {}, |
| 384 | `var Module = { | 492 | `var Module = { |
| 385 | onRuntimeInitialized: function() { | 493 | onRuntimeInitialized: function() { |
| @@ -400,16 +508,14 @@ export default defineConfig({ | |||
| 400 | s.src = '/js/yuescript.js'; | 508 | s.src = '/js/yuescript.js'; |
| 401 | s.async = true; | 509 | s.async = true; |
| 402 | document.head.appendChild(s); | 510 | document.head.appendChild(s); |
| 403 | })();` | 511 | })();`, |
| 404 | ] | 512 | ], |
| 405 | ], | 513 | ], |
| 406 | vite: { | 514 | vite: { |
| 407 | publicDir: resolve(__dirname, 'public'), | 515 | publicDir: resolve(__dirname, "public"), |
| 408 | }, | 516 | }, |
| 409 | markdown: { | 517 | markdown: { |
| 410 | languages: [ | 518 | languages: [yuescriptLanguage], |
| 411 | yuescriptLanguage, | ||
| 412 | ], | ||
| 413 | theme: { | 519 | theme: { |
| 414 | light: lightPlus, | 520 | light: lightPlus, |
| 415 | dark: darkPlus, | 521 | dark: darkPlus, |
| @@ -417,74 +523,74 @@ export default defineConfig({ | |||
| 417 | }, | 523 | }, |
| 418 | locales: { | 524 | locales: { |
| 419 | root: { | 525 | root: { |
| 420 | label: 'English', | 526 | label: "English", |
| 421 | lang: 'en-US', | 527 | lang: "en-US", |
| 422 | description: 'A language that compiles to Lua', | 528 | description: "A language that compiles to Lua", |
| 423 | themeConfig: { | 529 | themeConfig: { |
| 424 | nav: [ | 530 | nav: [ |
| 425 | { text: 'Documentation', link: '/doc/' }, | 531 | { text: "Documentation", link: "/doc/" }, |
| 426 | { text: 'Try yue!', link: '/try/' }, | 532 | { text: "Try yue!", link: "/try/" }, |
| 427 | { text: 'GitHub', link: 'https://github.com/IppClub/Yuescript' } | 533 | { text: "GitHub", link: "https://github.com/IppClub/Yuescript" }, |
| 428 | ], | 534 | ], |
| 429 | sidebar: createSidebar('/doc', 'en'), | 535 | sidebar: createSidebar("/doc", "en"), |
| 430 | } | 536 | }, |
| 431 | }, | 537 | }, |
| 432 | 'id-id': { | 538 | "id-id": { |
| 433 | label: 'Bahasa Indonesia', | 539 | label: "Bahasa Indonesia", |
| 434 | lang: 'id-ID', | 540 | lang: "id-ID", |
| 435 | description: 'Bahasa yang dikompilasi ke Lua', | 541 | description: "Bahasa yang dikompilasi ke Lua", |
| 436 | themeConfig: { | 542 | themeConfig: { |
| 437 | nav: [ | 543 | nav: [ |
| 438 | { text: 'Dokumentasi', link: '/id-id/doc/' }, | 544 | { text: "Dokumentasi", link: "/id-id/doc/" }, |
| 439 | { text: 'Coba Yue!', link: '/id-id/try/' }, | 545 | { text: "Coba Yue!", link: "/id-id/try/" }, |
| 440 | { text: 'GitHub', link: 'https://github.com/IppClub/Yuescript' } | 546 | { text: "GitHub", link: "https://github.com/IppClub/Yuescript" }, |
| 441 | ], | 547 | ], |
| 442 | sidebar: createSidebar('/id-id/doc', 'idId'), | 548 | sidebar: createSidebar("/id-id/doc", "idId"), |
| 443 | } | 549 | }, |
| 444 | }, | 550 | }, |
| 445 | de: { | 551 | de: { |
| 446 | label: 'Deutsch', | 552 | label: "Deutsch", |
| 447 | lang: 'de-DE', | 553 | lang: "de-DE", |
| 448 | description: 'Eine Sprache, die zu Lua kompiliert', | 554 | description: "Eine Sprache, die zu Lua kompiliert", |
| 449 | themeConfig: { | 555 | themeConfig: { |
| 450 | nav: [ | 556 | nav: [ |
| 451 | { text: 'Dokumentation', link: '/de/doc/' }, | 557 | { text: "Dokumentation", link: "/de/doc/" }, |
| 452 | { text: 'Yue ausprobieren!', link: '/de/try/' }, | 558 | { text: "Yue ausprobieren!", link: "/de/try/" }, |
| 453 | { text: 'GitHub', link: 'https://github.com/IppClub/Yuescript' } | 559 | { text: "GitHub", link: "https://github.com/IppClub/Yuescript" }, |
| 454 | ], | 560 | ], |
| 455 | sidebar: createSidebar('/de/doc', 'de'), | 561 | sidebar: createSidebar("/de/doc", "de"), |
| 456 | } | 562 | }, |
| 457 | }, | 563 | }, |
| 458 | 'pt-br': { | 564 | "pt-br": { |
| 459 | label: 'Português (Brasil)', | 565 | label: "Português (Brasil)", |
| 460 | lang: 'pt-BR', | 566 | lang: "pt-BR", |
| 461 | description: 'Uma linguagem que compila para Lua', | 567 | description: "Uma linguagem que compila para Lua", |
| 462 | themeConfig: { | 568 | themeConfig: { |
| 463 | nav: [ | 569 | nav: [ |
| 464 | { text: 'Documentação', link: '/pt-br/doc/' }, | 570 | { text: "Documentação", link: "/pt-br/doc/" }, |
| 465 | { text: 'Experimente Yue!', link: '/pt-br/try/' }, | 571 | { text: "Experimente Yue!", link: "/pt-br/try/" }, |
| 466 | { text: 'GitHub', link: 'https://github.com/IppClub/Yuescript' } | 572 | { text: "GitHub", link: "https://github.com/IppClub/Yuescript" }, |
| 467 | ], | 573 | ], |
| 468 | sidebar: createSidebar('/pt-br/doc', 'ptBr'), | 574 | sidebar: createSidebar("/pt-br/doc", "ptBr"), |
| 469 | } | 575 | }, |
| 470 | }, | 576 | }, |
| 471 | zh: { | 577 | zh: { |
| 472 | label: '简体中文', | 578 | label: "简体中文", |
| 473 | lang: 'zh-CN', | 579 | lang: "zh-CN", |
| 474 | description: '一门编译到 Lua 的语言', | 580 | description: "一门编译到 Lua 的语言", |
| 475 | themeConfig: { | 581 | themeConfig: { |
| 476 | nav: [ | 582 | nav: [ |
| 477 | { text: '文档', link: '/zh/doc/' }, | 583 | { text: "文档", link: "/zh/doc/" }, |
| 478 | { text: '试一试!', link: '/zh/try/' }, | 584 | { text: "试一试!", link: "/zh/try/" }, |
| 479 | { text: 'GitHub', link: 'https://github.com/IppClub/Yuescript' } | 585 | { text: "GitHub", link: "https://github.com/IppClub/Yuescript" }, |
| 480 | ], | 586 | ], |
| 481 | sidebar: createSidebar('/zh/doc', 'zh'), | 587 | sidebar: createSidebar("/zh/doc", "zh"), |
| 482 | } | 588 | }, |
| 483 | }, | 589 | }, |
| 484 | }, | 590 | }, |
| 485 | themeConfig: { | 591 | themeConfig: { |
| 486 | search: { | 592 | search: { |
| 487 | provider: 'local' | 593 | provider: "local", |
| 488 | } | 594 | }, |
| 489 | } | 595 | }, |
| 490 | }) | 596 | }); |
diff --git a/doc/docs/.vitepress/env.d.ts b/doc/docs/.vitepress/env.d.ts index 0f28852..f01ea51 100644 --- a/doc/docs/.vitepress/env.d.ts +++ b/doc/docs/.vitepress/env.d.ts | |||
| @@ -1,19 +1,19 @@ | |||
| 1 | /// <reference types="vitepress/client" /> | 1 | /// <reference types="vitepress/client" /> |
| 2 | 2 | ||
| 3 | declare module '*.vue' { | 3 | declare module "*.vue" { |
| 4 | import type { DefineComponent } from 'vue' | 4 | import type { DefineComponent } from "vue"; |
| 5 | const component: DefineComponent<{}, {}, any> | 5 | const component: DefineComponent<{}, {}, any>; |
| 6 | export default component | 6 | export default component; |
| 7 | } | 7 | } |
| 8 | 8 | ||
| 9 | declare global { | 9 | declare global { |
| 10 | interface Window { | 10 | interface Window { |
| 11 | yue?: { | 11 | yue?: { |
| 12 | version: () => string | 12 | version: () => string; |
| 13 | tolua: (code: string, ...args: unknown[]) => [string, string] | 13 | tolua: (code: string, ...args: unknown[]) => [string, string]; |
| 14 | exec: (code: string) => string | 14 | exec: (code: string) => string; |
| 15 | } | 15 | }; |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | export {} | 19 | export {}; |
diff --git a/doc/docs/.vitepress/grammars/yuescript.tmLanguage.json b/doc/docs/.vitepress/grammars/yuescript.tmLanguage.json index 62ac5fb..3a57344 100644 --- a/doc/docs/.vitepress/grammars/yuescript.tmLanguage.json +++ b/doc/docs/.vitepress/grammars/yuescript.tmLanguage.json | |||
| @@ -1,689 +1,687 @@ | |||
| 1 | { | 1 | { |
| 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", | 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", |
| 3 | "scopeName": "source.yue", | 3 | "scopeName": "source.yue", |
| 4 | "name": "YueScript", | 4 | "name": "YueScript", |
| 5 | "fileTypes": [ | 5 | "fileTypes": ["yue"], |
| 6 | "yue" | 6 | "patterns": [ |
| 7 | ], | 7 | { |
| 8 | "patterns": [ | 8 | "match": "\\A(#!).*$\\n?", |
| 9 | { | 9 | "name": "comment.line.shebang.yue", |
| 10 | "match": "\\A(#!).*$\\n?", | 10 | "captures": { |
| 11 | "name": "comment.line.shebang.yue", | 11 | "1": { |
| 12 | "captures": { | 12 | "name": "punctuation.definition.comment.yue" |
| 13 | "1": { | 13 | } |
| 14 | "name": "punctuation.definition.comment.yue" | 14 | } |
| 15 | } | 15 | }, |
| 16 | } | 16 | { |
| 17 | }, | 17 | "match": "(\\(.*?\\))?\\s*([=-]>)", |
| 18 | { | 18 | "name": "meta.inline.function.yue", |
| 19 | "match": "(\\(.*?\\))?\\s*([=-]>)", | 19 | "captures": { |
| 20 | "name": "meta.inline.function.yue", | 20 | "1": { |
| 21 | "captures": { | 21 | "name": "variable.parameter.function.yue" |
| 22 | "1": { | 22 | }, |
| 23 | "name": "variable.parameter.function.yue" | 23 | "2": { |
| 24 | }, | 24 | "name": "storage.type.function.yue" |
| 25 | "2": { | 25 | } |
| 26 | "name": "storage.type.function.yue" | 26 | } |
| 27 | } | 27 | }, |
| 28 | } | 28 | { |
| 29 | }, | 29 | "match": "(?<=^|\\bdo\\b|[=-]>)\\s*(\\(.*?\\))?\\s*(<[=-]\\s*(?=[a-zA-Z_]))", |
| 30 | { | 30 | "name": "meta.inline.function.yue", |
| 31 | "match": "(?<=^|\\bdo\\b|[=-]>)\\s*(\\(.*?\\))?\\s*(<[=-]\\s*(?=[a-zA-Z_]))", | 31 | "captures": { |
| 32 | "name": "meta.inline.function.yue", | 32 | "1": { |
| 33 | "captures": { | 33 | "name": "variable.parameter.function.yue" |
| 34 | "1": { | 34 | }, |
| 35 | "name": "variable.parameter.function.yue" | 35 | "2": { |
| 36 | }, | 36 | "name": "storage.type.function.yue" |
| 37 | "2": { | 37 | } |
| 38 | "name": "storage.type.function.yue" | 38 | } |
| 39 | } | 39 | }, |
| 40 | } | 40 | { |
| 41 | }, | 41 | "match": "(\\b[A-Z]\\w*)\\s*", |
| 42 | { | 42 | "name": "entity.name.type.class.yue", |
| 43 | "match": "(\\b[A-Z]\\w*)\\s*", | 43 | "captures": { |
| 44 | "name": "entity.name.type.class.yue", | 44 | "1": { |
| 45 | "captures": { | 45 | "name": "entity.name.type.class" |
| 46 | "1": { | 46 | } |
| 47 | "name": "entity.name.type.class" | 47 | } |
| 48 | } | 48 | }, |
| 49 | } | 49 | { |
| 50 | }, | 50 | "begin": "\\[(=*)\\[", |
| 51 | { | 51 | "beginCaptures": { |
| 52 | "begin": "\\[(=*)\\[", | 52 | "0": { |
| 53 | "beginCaptures": { | 53 | "name": "punctuation.definition.string.begin.yue" |
| 54 | "0": { | 54 | } |
| 55 | "name": "punctuation.definition.string.begin.yue" | 55 | }, |
| 56 | } | 56 | "end": "\\]\\1\\]", |
| 57 | }, | 57 | "endCaptures": { |
| 58 | "end": "\\]\\1\\]", | 58 | "0": { |
| 59 | "endCaptures": { | 59 | "name": "punctuation.definition.string.end.yue" |
| 60 | "0": { | 60 | } |
| 61 | "name": "punctuation.definition.string.end.yue" | 61 | }, |
| 62 | } | 62 | "name": "string.quoted.other.multiline.yue" |
| 63 | }, | 63 | }, |
| 64 | "name": "string.quoted.other.multiline.yue" | 64 | { |
| 65 | }, | 65 | "begin": "(?<!-)--\\[\\[", |
| 66 | { | 66 | "captures": { |
| 67 | "begin": "(?<!-)--\\[\\[", | 67 | "0": { |
| 68 | "captures": { | 68 | "name": "punctuation.definition.comment.yue" |
| 69 | "0": { | 69 | } |
| 70 | "name": "punctuation.definition.comment.yue" | 70 | }, |
| 71 | } | 71 | "end": "\\]\\]", |
| 72 | }, | 72 | "name": "comment.block.yue", |
| 73 | "end": "\\]\\]", | 73 | "patterns": [ |
| 74 | "name": "comment.block.yue", | 74 | { |
| 75 | "patterns": [ | 75 | "match": "@\\w*", |
| 76 | { | 76 | "name": "storage.type.annotation.yue" |
| 77 | "match": "@\\w*", | 77 | } |
| 78 | "name": "storage.type.annotation.yue" | 78 | ] |
| 79 | } | 79 | }, |
| 80 | ] | 80 | { |
| 81 | }, | 81 | "begin": "(?<!-)--", |
| 82 | { | 82 | "end": "(?:[ \\t]*\\n)", |
| 83 | "begin": "(?<!-)--", | 83 | "name": "comment.line.yue", |
| 84 | "end": "(?:[ \\t]*\\n)", | 84 | "patterns": [ |
| 85 | "name": "comment.line.yue", | 85 | { |
| 86 | "patterns": [ | 86 | "match": "@\\w*", |
| 87 | { | 87 | "name": "storage.type.annotation.yuescript" |
| 88 | "match": "@\\w*", | 88 | } |
| 89 | "name": "storage.type.annotation.yuescript" | 89 | ], |
| 90 | } | 90 | "captures": { |
| 91 | ], | 91 | "0": { |
| 92 | "captures": { | 92 | "name": "punctuation.definition.comment.yue" |
| 93 | "0": { | 93 | } |
| 94 | "name": "punctuation.definition.comment.yue" | 94 | } |
| 95 | } | 95 | }, |
| 96 | } | 96 | { |
| 97 | }, | 97 | "match": "(::)\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*(::)", |
| 98 | { | 98 | "name": "string.tag.lua", |
| 99 | "match": "(::)\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*(::)", | 99 | "captures": { |
| 100 | "name": "string.tag.lua", | 100 | "1": { |
| 101 | "captures": { | 101 | "name": "punctuation.section.embedded.begin.yue" |
| 102 | "1": { | 102 | }, |
| 103 | "name": "punctuation.section.embedded.begin.yue" | 103 | "2": { |
| 104 | }, | 104 | "name": "punctuation.section.embedded.end.yue" |
| 105 | "2": { | 105 | } |
| 106 | "name": "punctuation.section.embedded.end.yue" | 106 | } |
| 107 | } | 107 | }, |
| 108 | } | 108 | { |
| 109 | }, | 109 | "patterns": [ |
| 110 | { | 110 | { |
| 111 | "patterns": [ | 111 | "match": "<\\b(?:mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\\b>", |
| 112 | { | 112 | "name": "constant.language.yue" |
| 113 | "match": "<\\b(?:mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\\b>", | 113 | }, |
| 114 | "name": "constant.language.yue" | 114 | { |
| 115 | }, | 115 | "match": "<>", |
| 116 | { | 116 | "name": "constant.language.yue" |
| 117 | "match": "<>", | 117 | }, |
| 118 | "name": "constant.language.yue" | 118 | { |
| 119 | }, | 119 | "match": "<(\"(?:\\\\\"|[^\"])*\")>", |
| 120 | { | 120 | "name": "constant.language.yue", |
| 121 | "match": "<(\"(?:\\\\\"|[^\"])*\")>", | 121 | "captures": { |
| 122 | "name": "constant.language.yue", | 122 | "1": { |
| 123 | "captures": { | 123 | "name": "string.quoted.double.yue" |
| 124 | "1": { | 124 | } |
| 125 | "name": "string.quoted.double.yue" | 125 | } |
| 126 | } | 126 | }, |
| 127 | } | 127 | { |
| 128 | }, | 128 | "match": "<('(?:\\\\'|[^'])*')>", |
| 129 | { | 129 | "name": "constant.language.yue", |
| 130 | "match": "<('(?:\\\\'|[^'])*')>", | 130 | "captures": { |
| 131 | "name": "constant.language.yue", | 131 | "1": { |
| 132 | "captures": { | 132 | "name": "string.quoted.single.yue" |
| 133 | "1": { | 133 | } |
| 134 | "name": "string.quoted.single.yue" | 134 | } |
| 135 | } | 135 | }, |
| 136 | } | 136 | { |
| 137 | }, | 137 | "match": "<\\w+>", |
| 138 | { | 138 | "name": "invalid.illegal.yue" |
| 139 | "match": "<\\w+>", | 139 | } |
| 140 | "name": "invalid.illegal.yue" | 140 | ] |
| 141 | } | 141 | }, |
| 142 | ] | 142 | { |
| 143 | }, | 143 | "match": "(\\+|\\-|\\*|/|%|\\^|//|\\||\\&|>>|<<|(?<!\\?)\\?{2}(?!\\?)|(?<!\\.)\\.{2}(?!\\.)|\\band|\\bor)=?", |
| 144 | { | 144 | "name": "keyword.operator.yue" |
| 145 | "match": "(\\+|\\-|\\*|/|%|\\^|//|\\||\\&|>>|<<|(?<!\\?)\\?{2}(?!\\?)|(?<!\\.)\\.{2}(?!\\.)|\\band|\\bor)=?", | 145 | }, |
| 146 | "name": "keyword.operator.yue" | 146 | { |
| 147 | }, | 147 | "match": "\\[\\]\\s*=", |
| 148 | { | 148 | "name": "keyword.operator.yue" |
| 149 | "match": "\\[\\]\\s*=", | 149 | }, |
| 150 | "name": "keyword.operator.yue" | 150 | { |
| 151 | }, | 151 | "match": "==|~=|\\!=|>|>=|<|<=", |
| 152 | { | 152 | "name": "keyword.operator.yue" |
| 153 | "match": "==|~=|\\!=|>|>=|<|<=", | 153 | }, |
| 154 | "name": "keyword.operator.yue" | 154 | { |
| 155 | }, | 155 | "match": "#|\\-|~|\\?|!", |
| 156 | { | 156 | "name": "keyword.operator.yue" |
| 157 | "match": "#|\\-|~|\\?|!", | 157 | }, |
| 158 | "name": "keyword.operator.yue" | 158 | { |
| 159 | }, | 159 | "match": "\\|>|=|:=|(?<!:):(?!:)|,|\\b_\\b", |
| 160 | { | 160 | "name": "keyword.operator.yue" |
| 161 | "match": "\\|>|=|:=|(?<!:):(?!:)|,|\\b_\\b", | 161 | }, |
| 162 | "name": "keyword.operator.yue" | 162 | { |
| 163 | }, | 163 | "match": "(?<!\\.)\\.{3}(?!\\.)(?!\\w+)", |
| 164 | { | 164 | "name": "constant.language.yue" |
| 165 | "match": "(?<!\\.)\\.{3}(?!\\.)(?!\\w+)", | 165 | }, |
| 166 | "name": "constant.language.yue" | 166 | { |
| 167 | }, | 167 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using)\\b(?!:)", |
| 168 | { | 168 | "name": "keyword.yue" |
| 169 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using)\\b(?!:)", | 169 | }, |
| 170 | "name": "keyword.yue" | 170 | { |
| 171 | }, | 171 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto)\\b(?!:)", |
| 172 | { | 172 | "name": "keyword.control.yue" |
| 173 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto)\\b(?!:)", | 173 | }, |
| 174 | "name": "keyword.control.yue" | 174 | { |
| 175 | }, | 175 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:or|and|in|not)\\b(?!:)", |
| 176 | { | 176 | "name": "keyword.control.yue" |
| 177 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:or|and|in|not)\\b(?!:)", | 177 | }, |
| 178 | "name": "keyword.control.yue" | 178 | { |
| 179 | }, | 179 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:true|false|nil)\\b(?!:)", |
| 180 | { | 180 | "name": "constant.language.boolean.yue" |
| 181 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:true|false|nil)\\b(?!:)", | 181 | }, |
| 182 | "name": "constant.language.boolean.yue" | 182 | { |
| 183 | }, | 183 | "match": "\\b(?<![\\.|:|::|\\\\|\\$])(function|end)(?!:)\\b", |
| 184 | { | 184 | "name": "invalid.illegal.yue" |
| 185 | "match": "\\b(?<![\\.|:|::|\\\\|\\$])(function|end)(?!:)\\b", | 185 | }, |
| 186 | "name": "invalid.illegal.yue" | 186 | { |
| 187 | }, | 187 | "match": "((?<!\\.)\\.{4,}(?!\\.))", |
| 188 | { | 188 | "name": "invalid.illegal.yue" |
| 189 | "match": "((?<!\\.)\\.{4,}(?!\\.))", | 189 | }, |
| 190 | "name": "invalid.illegal.yue" | 190 | { |
| 191 | }, | 191 | "begin": "(?<=\\s|^)(\\{)(?=.+?\\}\\s+[:=])", |
| 192 | { | 192 | "beginCaptures": { |
| 193 | "begin": "(?<=\\s|^)(\\{)(?=.+?\\}\\s+[:=])", | 193 | "0": { |
| 194 | "beginCaptures": { | 194 | "name": "keyword.control.yue" |
| 195 | "0": { | 195 | } |
| 196 | "name": "keyword.control.yue" | 196 | }, |
| 197 | } | 197 | "end": "(\\}\\s*[:=])", |
| 198 | }, | 198 | "endCaptures": { |
| 199 | "end": "(\\}\\s*[:=])", | 199 | "0": { |
| 200 | "endCaptures": { | 200 | "name": "keyword.control.yue" |
| 201 | "0": { | 201 | } |
| 202 | "name": "keyword.control.yue" | 202 | }, |
| 203 | } | 203 | "name": "meta.variable.assignment.destructured.object.yue", |
| 204 | }, | 204 | "patterns": [ |
| 205 | "name": "meta.variable.assignment.destructured.object.yue", | 205 | { |
| 206 | "patterns": [ | 206 | "include": "#expression" |
| 207 | { | 207 | } |
| 208 | "include": "#expression" | 208 | ] |
| 209 | } | 209 | }, |
| 210 | ] | 210 | { |
| 211 | }, | 211 | "match": "(?<=[ \t]*)\\b(?:new)\\b(?=:(?:\\s*\\(.*\\))?\\s*=>)", |
| 212 | { | 212 | "name": "variable.language.yue" |
| 213 | "match": "(?<=[ \t]*)\\b(?:new)\\b(?=:(?:\\s*\\(.*\\))?\\s*=>)", | 213 | }, |
| 214 | "name": "variable.language.yue" | 214 | { |
| 215 | }, | 215 | "match": "(?x)\n\t\t\t\t(?<=^|\\s)\n\t\t\t\t(?=@?[a-zA-Z\\$_]\\??)\n\t\t\t\t(\n\t\t\t\t\t@?[a-zA-Z\\$_]\\??(\\w|\\$|:|\\.)*\\s*\n\t\t\t\t\t(?=[:=](\\s*\\(.*\\))?\\s*([=-]>))\n\t\t\t\t)\n\t\t\t", |
| 216 | { | 216 | "name": "meta.function.yue", |
| 217 | "match": "(?x)\n\t\t\t\t(?<=^|\\s)\n\t\t\t\t(?=@?[a-zA-Z\\$_]\\??)\n\t\t\t\t(\n\t\t\t\t\t@?[a-zA-Z\\$_]\\??(\\w|\\$|:|\\.)*\\s*\n\t\t\t\t\t(?=[:=](\\s*\\(.*\\))?\\s*([=-]>))\n\t\t\t\t)\n\t\t\t", | 217 | "captures": { |
| 218 | "name": "meta.function.yue", | 218 | "1": { |
| 219 | "captures": { | 219 | "name": "entity.name.function.yue" |
| 220 | "1": { | 220 | }, |
| 221 | "name": "entity.name.function.yue" | 221 | "2": { |
| 222 | }, | 222 | "name": "entity.name.function.yue" |
| 223 | "2": { | 223 | }, |
| 224 | "name": "entity.name.function.yue" | 224 | "3": { |
| 225 | }, | 225 | "name": "variable.parameter.function.yue" |
| 226 | "3": { | 226 | }, |
| 227 | "name": "variable.parameter.function.yue" | 227 | "4": { |
| 228 | }, | 228 | "name": "storage.type.function.yue" |
| 229 | "4": { | 229 | } |
| 230 | "name": "storage.type.function.yue" | 230 | } |
| 231 | } | 231 | }, |
| 232 | } | 232 | { |
| 233 | }, | 233 | "match": "\\b__(class|base|init|inherited|mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\\b", |
| 234 | { | 234 | "name": "entity.name.function.yue" |
| 235 | "match": "\\b__(class|base|init|inherited|mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\\b", | 235 | }, |
| 236 | "name": "entity.name.function.yue" | 236 | { |
| 237 | }, | 237 | "match": "(?:\\bclass\\b)\\s+(@?[a-zA-Z\\$_][\\w\\.]*)?(?:\\s+(?:\\bextends\\b)\\s+(@?[a-zA-Z\\$\\._][\\w\\.]*))?", |
| 238 | { | 238 | "name": "meta.class.yue", |
| 239 | "match": "(?:\\bclass\\b)\\s+(@?[a-zA-Z\\$_][\\w\\.]*)?(?:\\s+(?:\\bextends\\b)\\s+(@?[a-zA-Z\\$\\._][\\w\\.]*))?", | 239 | "captures": { |
| 240 | "name": "meta.class.yue", | 240 | "1": { |
| 241 | "captures": { | 241 | "name": "storage.type.class.yue" |
| 242 | "1": { | 242 | }, |
| 243 | "name": "storage.type.class.yue" | 243 | "2": { |
| 244 | }, | 244 | "name": "entity.name.type.class.yue" |
| 245 | "2": { | 245 | }, |
| 246 | "name": "entity.name.type.class.yue" | 246 | "3": { |
| 247 | }, | 247 | "name": "keyword.control.inheritance.yue" |
| 248 | "3": { | 248 | }, |
| 249 | "name": "keyword.control.inheritance.yue" | 249 | "4": { |
| 250 | }, | 250 | "name": "entity.other.inherited-class.yue" |
| 251 | "4": { | 251 | } |
| 252 | "name": "entity.other.inherited-class.yue" | 252 | } |
| 253 | } | 253 | }, |
| 254 | } | 254 | { |
| 255 | }, | 255 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:_ENV|_G|_VERSION|arg)\\b(?!(?:\\s*(?:(?:\\+|\\-|\\*|/|%|\\^|//|\\||\\&|>>|<<|(?<!\\?)\\?{2}(?!\\?)|(?<!\\.)\\.{2}(?!\\.)|\\band|\\bor)?=|:=)\\s*|:))", |
| 256 | { | 256 | "name": "constant.language.yue" |
| 257 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:_ENV|_G|_VERSION|arg)\\b(?!(?:\\s*(?:(?:\\+|\\-|\\*|/|%|\\^|//|\\||\\&|>>|<<|(?<!\\?)\\?{2}(?!\\?)|(?<!\\.)\\.{2}(?!\\.)|\\band|\\bor)?=|:=)\\s*|:))", | 257 | }, |
| 258 | "name": "constant.language.yue" | 258 | { |
| 259 | }, | 259 | "include": "#expression" |
| 260 | { | 260 | }, |
| 261 | "include": "#expression" | 261 | { |
| 262 | }, | 262 | "match": ",[ \\t]*", |
| 263 | { | 263 | "name": "meta.delimiter.object.comma.yue" |
| 264 | "match": ",[ \\t]*", | 264 | }, |
| 265 | "name": "meta.delimiter.object.comma.yue" | 265 | { |
| 266 | }, | 266 | "match": "\\.|::|\\\\", |
| 267 | { | 267 | "name": "meta.delimiter.method.yue" |
| 268 | "match": "\\.|::|\\\\", | 268 | }, |
| 269 | "name": "meta.delimiter.method.yue" | 269 | { |
| 270 | }, | 270 | "match": "\\{|\\}", |
| 271 | { | 271 | "name": "meta.brace.curly.yue" |
| 272 | "match": "\\{|\\}", | 272 | }, |
| 273 | "name": "meta.brace.curly.yue" | 273 | { |
| 274 | }, | 274 | "match": "\\(|\\)", |
| 275 | { | 275 | "name": "meta.brace.round.yue" |
| 276 | "match": "\\(|\\)", | 276 | }, |
| 277 | "name": "meta.brace.round.yue" | 277 | { |
| 278 | }, | 278 | "match": "\\[|\\]", |
| 279 | { | 279 | "name": "meta.brace.square.yue" |
| 280 | "match": "\\[|\\]", | 280 | } |
| 281 | "name": "meta.brace.square.yue" | 281 | ], |
| 282 | } | 282 | "repository": { |
| 283 | ], | 283 | "expression": { |
| 284 | "repository": { | 284 | "patterns": [ |
| 285 | "expression": { | 285 | { |
| 286 | "patterns": [ | 286 | "include": "#string" |
| 287 | { | 287 | }, |
| 288 | "include": "#string" | 288 | { |
| 289 | }, | 289 | "include": "#numeric" |
| 290 | { | 290 | }, |
| 291 | "include": "#numeric" | 291 | { |
| 292 | }, | 292 | "include": "#builtins" |
| 293 | { | 293 | }, |
| 294 | "include": "#builtins" | 294 | { |
| 295 | }, | 295 | "include": "#variable_name" |
| 296 | { | 296 | } |
| 297 | "include": "#variable_name" | 297 | ] |
| 298 | } | 298 | }, |
| 299 | ] | 299 | "keyword": { |
| 300 | }, | 300 | "patterns": [ |
| 301 | "keyword": { | 301 | { |
| 302 | "patterns": [ | 302 | "match": "\\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using)\\b", |
| 303 | { | 303 | "name": "keyword.yue" |
| 304 | "match": "\\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using)\\b", | 304 | }, |
| 305 | "name": "keyword.yue" | 305 | { |
| 306 | }, | 306 | "match": "\\b(?:if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto)\\b", |
| 307 | { | 307 | "name": "keyword.control.yue" |
| 308 | "match": "\\b(?:if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto)\\b", | 308 | }, |
| 309 | "name": "keyword.control.yue" | 309 | { |
| 310 | }, | 310 | "match": "\\b(?:or|and|in|not)\\b", |
| 311 | { | 311 | "name": "keyword.operator.yue" |
| 312 | "match": "\\b(?:or|and|in|not)\\b", | 312 | } |
| 313 | "name": "keyword.operator.yue" | 313 | ] |
| 314 | } | 314 | }, |
| 315 | ] | 315 | "string": { |
| 316 | }, | 316 | "patterns": [ |
| 317 | "string": { | 317 | { |
| 318 | "patterns": [ | 318 | "include": "#single_quoted_string" |
| 319 | { | 319 | }, |
| 320 | "include": "#single_quoted_string" | 320 | { |
| 321 | }, | 321 | "include": "#double_quoted_string" |
| 322 | { | 322 | } |
| 323 | "include": "#double_quoted_string" | 323 | ] |
| 324 | } | 324 | }, |
| 325 | ] | 325 | "string_format_code": { |
| 326 | }, | 326 | "patterns": [ |
| 327 | "string_format_code": { | 327 | { |
| 328 | "patterns": [ | 328 | "match": "%(%|a|A|c|d|e|E|f|g|G|i|o|p|q|s|u|x|X)", |
| 329 | { | 329 | "name": "constant.character.yue" |
| 330 | "match": "%(%|a|A|c|d|e|E|f|g|G|i|o|p|q|s|u|x|X)", | 330 | } |
| 331 | "name": "constant.character.yue" | 331 | ] |
| 332 | } | 332 | }, |
| 333 | ] | 333 | "string_escape_sequence": { |
| 334 | }, | 334 | "patterns": [ |
| 335 | "string_escape_sequence": { | 335 | { |
| 336 | "patterns": [ | 336 | "match": "\\\\([abfnrtvz\\'\"\\\\]|\\d{1,3}|x\\h{2}|u\\{\\h+\\})", |
| 337 | { | 337 | "name": "constant.character.yue" |
| 338 | "match": "\\\\([abfnrtvz\\'\"\\\\]|\\d{1,3}|x\\h{2}|u\\{\\h+\\})", | 338 | }, |
| 339 | "name": "constant.character.yue" | 339 | { |
| 340 | }, | 340 | "match": "\\\\.", |
| 341 | { | 341 | "name": "invalid.illegal.yue" |
| 342 | "match": "\\\\.", | 342 | } |
| 343 | "name": "invalid.illegal.yue" | 343 | ] |
| 344 | } | 344 | }, |
| 345 | ] | 345 | "double_quoted_string": { |
| 346 | }, | 346 | "patterns": [ |
| 347 | "double_quoted_string": { | 347 | { |
| 348 | "patterns": [ | 348 | "begin": "\"", |
| 349 | { | 349 | "beginCaptures": { |
| 350 | "begin": "\"", | 350 | "0": { |
| 351 | "beginCaptures": { | 351 | "name": "punctuation.definition.string.begin.yue" |
| 352 | "0": { | 352 | } |
| 353 | "name": "punctuation.definition.string.begin.yue" | 353 | }, |
| 354 | } | 354 | "end": "\"", |
| 355 | }, | 355 | "endCaptures": { |
| 356 | "end": "\"", | 356 | "0": { |
| 357 | "endCaptures": { | 357 | "name": "punctuation.definition.string.end.yue" |
| 358 | "0": { | 358 | } |
| 359 | "name": "punctuation.definition.string.end.yue" | 359 | }, |
| 360 | } | 360 | "name": "string.quoted.double.yue", |
| 361 | }, | 361 | "patterns": [ |
| 362 | "name": "string.quoted.double.yue", | 362 | { |
| 363 | "patterns": [ | 363 | "include": "#string_escape_sequence" |
| 364 | { | 364 | }, |
| 365 | "include": "#string_escape_sequence" | 365 | { |
| 366 | }, | 366 | "include": "#interpolated_yue" |
| 367 | { | 367 | }, |
| 368 | "include": "#interpolated_yue" | 368 | { |
| 369 | }, | 369 | "include": "#string_format_code" |
| 370 | { | 370 | } |
| 371 | "include": "#string_format_code" | 371 | ] |
| 372 | } | 372 | } |
| 373 | ] | 373 | ] |
| 374 | } | 374 | }, |
| 375 | ] | 375 | "single_quoted_string": { |
| 376 | }, | 376 | "patterns": [ |
| 377 | "single_quoted_string": { | 377 | { |
| 378 | "patterns": [ | 378 | "begin": "'", |
| 379 | { | 379 | "beginCaptures": { |
| 380 | "begin": "'", | 380 | "0": { |
| 381 | "beginCaptures": { | 381 | "name": "punctuation.definition.string.begin.yue" |
| 382 | "0": { | 382 | } |
| 383 | "name": "punctuation.definition.string.begin.yue" | 383 | }, |
| 384 | } | 384 | "end": "'", |
| 385 | }, | 385 | "endCaptures": { |
| 386 | "end": "'", | 386 | "0": { |
| 387 | "endCaptures": { | 387 | "name": "punctuation.definition.string.end.yue" |
| 388 | "0": { | 388 | } |
| 389 | "name": "punctuation.definition.string.end.yue" | 389 | }, |
| 390 | } | 390 | "name": "string.quoted.single.yue", |
| 391 | }, | 391 | "patterns": [ |
| 392 | "name": "string.quoted.single.yue", | 392 | { |
| 393 | "patterns": [ | 393 | "include": "#string_escape_sequence" |
| 394 | { | 394 | }, |
| 395 | "include": "#string_escape_sequence" | 395 | { |
| 396 | }, | 396 | "include": "#string_format_code" |
| 397 | { | 397 | } |
| 398 | "include": "#string_format_code" | 398 | ] |
| 399 | } | 399 | } |
| 400 | ] | 400 | ] |
| 401 | } | 401 | }, |
| 402 | ] | 402 | "interpolated_yue": { |
| 403 | }, | 403 | "patterns": [ |
| 404 | "interpolated_yue": { | 404 | { |
| 405 | "patterns": [ | 405 | "begin": "\\#\\{", |
| 406 | { | 406 | "captures": { |
| 407 | "begin": "\\#\\{", | 407 | "0": { |
| 408 | "captures": { | 408 | "name": "punctuation.section.embedded.yue" |
| 409 | "0": { | 409 | } |
| 410 | "name": "punctuation.section.embedded.yue" | 410 | }, |
| 411 | } | 411 | "end": "\\}", |
| 412 | }, | 412 | "name": "source.yue.embedded.source", |
| 413 | "end": "\\}", | 413 | "patterns": [ |
| 414 | "name": "source.yue.embedded.source", | 414 | { |
| 415 | "patterns": [ | 415 | "include": "$self" |
| 416 | { | 416 | } |
| 417 | "include": "$self" | 417 | ] |
| 418 | } | 418 | } |
| 419 | ] | 419 | ] |
| 420 | } | 420 | }, |
| 421 | ] | 421 | "variable_name": { |
| 422 | }, | 422 | "patterns": [ |
| 423 | "variable_name": { | 423 | { |
| 424 | "patterns": [ | 424 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)(\\b(?:self)\\b)(?!:)\\b", |
| 425 | { | 425 | "name": "invalid.deprecated.yue" |
| 426 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)(\\b(?:self)\\b)(?!:)\\b", | 426 | }, |
| 427 | "name": "invalid.deprecated.yue" | 427 | { |
| 428 | }, | 428 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:super)\\b(?!(?:\\s*(?:(?:\\+|\\-|\\*|/|%|\\^|//|\\||\\&|>>|<<|(?<!\\?)\\?{2}(?!\\?)|(?<!\\.)\\.{2}(?!\\.)|\\band|\\bor)?=|:=)\\s*|:))", |
| 429 | { | 429 | "name": "variable.language.yue" |
| 430 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:super)\\b(?!(?:\\s*(?:(?:\\+|\\-|\\*|/|%|\\^|//|\\||\\&|>>|<<|(?<!\\?)\\?{2}(?!\\?)|(?<!\\.)\\.{2}(?!\\.)|\\band|\\bor)?=|:=)\\s*|:))", | 430 | }, |
| 431 | "name": "variable.language.yue" | 431 | { |
| 432 | }, | 432 | "match": "(?:\\${2,}|@{3,})(?:(?:\\b[a-zA-Z_]\\w*)?((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*)*\\b)?", |
| 433 | { | 433 | "name": "invalid.illegal.yue" |
| 434 | "match": "(?:\\${2,}|@{3,})(?:(?:\\b[a-zA-Z_]\\w*)?((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*)*\\b)?", | 434 | }, |
| 435 | "name": "invalid.illegal.yue" | 435 | { |
| 436 | }, | 436 | "match": "(?<!\\$)\\$\\b[a-zA-Z_]\\w*\\b", |
| 437 | { | 437 | "name": "entity.name.function.preprocessor.yue" |
| 438 | "match": "(?<!\\$)\\$\\b[a-zA-Z_]\\w*\\b", | 438 | }, |
| 439 | "name": "entity.name.function.preprocessor.yue" | 439 | { |
| 440 | }, | 440 | "match": "(?<!\\$)\\$(?!\\$)", |
| 441 | { | 441 | "name": "invalid.illegal.yue" |
| 442 | "match": "(?<!\\$)\\$(?!\\$)", | 442 | }, |
| 443 | "name": "invalid.illegal.yue" | 443 | { |
| 444 | }, | 444 | "match": "(?<![\\$@])@@(?:(?:\\b[a-zA-Z_]\\w*)?((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*)*\\b)?", |
| 445 | { | 445 | "name": "variable.other.static.yue" |
| 446 | "match": "(?<![\\$@])@@(?:(?:\\b[a-zA-Z_]\\w*)?((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*)*\\b)?", | 446 | }, |
| 447 | "name": "variable.other.static.yue" | 447 | { |
| 448 | }, | 448 | "match": "(?<![\\$@])@(?:(?:\\b[a-zA-Z_]\\w*)?((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*)*\\b)?", |
| 449 | { | 449 | "name": "variable.other.member.yue" |
| 450 | "match": "(?<![\\$@])@(?:(?:\\b[a-zA-Z_]\\w*)?((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*)*\\b)?", | 450 | }, |
| 451 | "name": "variable.other.member.yue" | 451 | { |
| 452 | }, | 452 | "match": "(?<![\\$@])\\b[a-zA-Z_]\\w*((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*\\b)*", |
| 453 | { | 453 | "name": "variable.assignment.yue" |
| 454 | "match": "(?<![\\$@])\\b[a-zA-Z_]\\w*((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*\\b)*", | 454 | }, |
| 455 | "name": "variable.assignment.yue" | 455 | { |
| 456 | }, | 456 | "match": "(?<![\\$@])\\b([a-zA-Z\\$_]\\w*(\\.\\w+)*)\\b", |
| 457 | { | 457 | "name": "variable.assignment.yue", |
| 458 | "match": "(?<![\\$@])\\b([a-zA-Z\\$_]\\w*(\\.\\w+)*)\\b", | 458 | "captures": { |
| 459 | "name": "variable.assignment.yue", | 459 | "1": { |
| 460 | "captures": { | 460 | "name": "variable.assignment.yue" |
| 461 | "1": { | 461 | } |
| 462 | "name": "variable.assignment.yue" | 462 | } |
| 463 | } | 463 | } |
| 464 | } | 464 | ] |
| 465 | } | 465 | }, |
| 466 | ] | 466 | "numeric": { |
| 467 | }, | 467 | "patterns": [ |
| 468 | "numeric": { | 468 | { |
| 469 | "patterns": [ | 469 | "match": "\\b([\\d_]+(\\.[\\d_]+)?|\\.[\\d_]+)(e[+\\-]?[\\d_]+)?\\b", |
| 470 | { | 470 | "name": "constant.numeric.yue" |
| 471 | "match": "\\b([\\d_]+(\\.[\\d_]+)?|\\.[\\d_]+)(e[+\\-]?[\\d_]+)?\\b", | 471 | }, |
| 472 | "name": "constant.numeric.yue" | 472 | { |
| 473 | }, | 473 | "match": "\\b0x(((?:\\h|\\h[\\h_]*\\h)(\\.(?:\\h|\\h[\\h_]*\\h))?)|\\.(?:\\h|\\h[\\h_]*\\h))\\b", |
| 474 | { | 474 | "name": "constant.numeric.yue" |
| 475 | "match": "\\b0x(((?:\\h|\\h[\\h_]*\\h)(\\.(?:\\h|\\h[\\h_]*\\h))?)|\\.(?:\\h|\\h[\\h_]*\\h))\\b", | 475 | }, |
| 476 | "name": "constant.numeric.yue" | 476 | { |
| 477 | }, | 477 | "match": "\\b\\d(?:\\w|\\.|:|::|\\\\)+\\b", |
| 478 | { | 478 | "name": "invalid.illegal.yue" |
| 479 | "match": "\\b\\d(?:\\w|\\.|:|::|\\\\)+\\b", | 479 | } |
| 480 | "name": "invalid.illegal.yue" | 480 | ] |
| 481 | } | 481 | }, |
| 482 | ] | 482 | "builtins": { |
| 483 | }, | 483 | "patterns": [ |
| 484 | "builtins": { | 484 | { |
| 485 | "patterns": [ | 485 | "name": "support.function.library.yue", |
| 486 | { | 486 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*(?:lpeg|lpeglabel)(?:(?:\\.|::|\\\\)(?:B|C|Carg|Cb|Cc|Cf|Cg|Cmt|Cp|Cs|Ct|P|R|S|T|V|locale|match|pcode|ptree|setmaxstack|type|utfR|version))?\\b" |
| 487 | "name": "support.function.library.yue", | 487 | }, |
| 488 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*(?:lpeg|lpeglabel)(?:(?:\\.|::|\\\\)(?:B|C|Carg|Cb|Cc|Cf|Cg|Cmt|Cp|Cs|Ct|P|R|S|T|V|locale|match|pcode|ptree|setmaxstack|type|utfR|version))?\\b" | 488 | { |
| 489 | }, | 489 | "name": "support.function.library.yue", |
| 490 | { | 490 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*(?:re|relabel)(?:(?:\\.|::|\\\\)(?:calcline|compile|find|gsub|match|updatelocale))?\\b" |
| 491 | "name": "support.function.library.yue", | 491 | }, |
| 492 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*(?:re|relabel)(?:(?:\\.|::|\\\\)(?:calcline|compile|find|gsub|match|updatelocale))?\\b" | 492 | { |
| 493 | }, | 493 | "name": "support.function.library.yue", |
| 494 | { | 494 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*coroutine(?:(?:\\.|::|\\\\)(?:close|create|isyieldable|resume|running|status|wrap|yield))?\\b" |
| 495 | "name": "support.function.library.yue", | 495 | }, |
| 496 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*coroutine(?:(?:\\.|::|\\\\)(?:close|create|isyieldable|resume|running|status|wrap|yield))?\\b" | 496 | { |
| 497 | }, | 497 | "name": "support.function.library.yue", |
| 498 | { | 498 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*debug(?:(?:\\.|::|\\\\)(?:debug|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|getuservalue|setcstacklimit|sethook|setlocal|setmetatable|setupvalue|setuservalue|traceback|upvalueid|upvaluejoin))?\\b" |
| 499 | "name": "support.function.library.yue", | 499 | }, |
| 500 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*debug(?:(?:\\.|::|\\\\)(?:debug|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|getuservalue|setcstacklimit|sethook|setlocal|setmetatable|setupvalue|setuservalue|traceback|upvalueid|upvaluejoin))?\\b" | 500 | { |
| 501 | }, | 501 | "name": "support.function.library.yue", |
| 502 | { | 502 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*io(?:(?:\\.|::|\\\\)(?:close|flush|input|lines|open|output|popen|read|stderr|stdin|stdout|tmpfile|type|write))?\\b" |
| 503 | "name": "support.function.library.yue", | 503 | }, |
| 504 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*io(?:(?:\\.|::|\\\\)(?:close|flush|input|lines|open|output|popen|read|stderr|stdin|stdout|tmpfile|type|write))?\\b" | 504 | { |
| 505 | }, | 505 | "name": "support.function.library.yue", |
| 506 | { | 506 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*math(?:(?:\\.|::|\\\\)(?:abs|acos|asin|atan|atan2|ceil|cos|cosh|deg|exp|floor|fmod|frexp|huge|ldexp|log|log10|max|maxinteger|min|mininteger|modf|pi|pow|rad|random|randomseed|sin|sinh|sqrt|tan|tanh|tointeger|type|ult))?\\b" |
| 507 | "name": "support.function.library.yue", | 507 | }, |
| 508 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*math(?:(?:\\.|::|\\\\)(?:abs|acos|asin|atan|atan2|ceil|cos|cosh|deg|exp|floor|fmod|frexp|huge|ldexp|log|log10|max|maxinteger|min|mininteger|modf|pi|pow|rad|random|randomseed|sin|sinh|sqrt|tan|tanh|tointeger|type|ult))?\\b" | 508 | { |
| 509 | }, | 509 | "name": "support.function.library.yue", |
| 510 | { | 510 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*os(?:(?:\\.|::|\\\\)(?:clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname))?\\b" |
| 511 | "name": "support.function.library.yue", | 511 | }, |
| 512 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*os(?:(?:\\.|::|\\\\)(?:clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname))?\\b" | 512 | { |
| 513 | }, | 513 | "name": "support.function.library.yue", |
| 514 | { | 514 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*package(?:(?:\\.|::|\\\\)(?:config|cpath|loaded|loadlib|path|preload|searchers|searchpath))?\\b" |
| 515 | "name": "support.function.library.yue", | 515 | }, |
| 516 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*package(?:(?:\\.|::|\\\\)(?:config|cpath|loaded|loadlib|path|preload|searchers|searchpath))?\\b" | 516 | { |
| 517 | }, | 517 | "name": "support.function.library.yue", |
| 518 | { | 518 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.Date(?:(?:\\.|::|\\\\)(?:Format|Interval|_class|_init|add|cast|catch|class_of|day|diff|hour|is_a|is_weekend|last_day|min|month|month_name|sec|set|toLocal|toUTC|tzone|weekday_name|yday|year))?\\b" |
| 519 | "name": "support.function.library.yue", | 519 | }, |
| 520 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.Date(?:(?:\\.|::|\\\\)(?:Format|Interval|_class|_init|add|cast|catch|class_of|day|diff|hour|is_a|is_weekend|last_day|min|month|month_name|sec|set|toLocal|toUTC|tzone|weekday_name|yday|year))?\\b" | 520 | { |
| 521 | }, | 521 | "name": "support.function.library.yue", |
| 522 | { | 522 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.List(?:(?:\\.|::|\\\\)(?:_class|_create|_init|_name|append|cast|catch|chop|class_of|clear|clone|concat|contains|count|default_map|default_map_with|extend|filter|foreach|foreachm|get|index|insert|is_a|iter|iterate|join|len|map|map2|mapm|minmax|new|partition|pop|push|put|range|reduce|remove|remove_value|reverse|slice|slice_assign|sort|sorted|splice|split|transform))?\\b" |
| 523 | "name": "support.function.library.yue", | 523 | }, |
| 524 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.List(?:(?:\\.|::|\\\\)(?:_class|_create|_init|_name|append|cast|catch|chop|class_of|clear|clone|concat|contains|count|default_map|default_map_with|extend|filter|foreach|foreachm|get|index|insert|is_a|iter|iterate|join|len|map|map2|mapm|minmax|new|partition|pop|push|put|range|reduce|remove|remove_value|reverse|slice|slice_assign|sort|sorted|splice|split|transform))?\\b" | 524 | { |
| 525 | }, | 525 | "name": "support.function.library.yue", |
| 526 | { | 526 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.Map(?:(?:\\.|::|\\\\)(?:_class|_init|_name|cast|catch|class_of|get|getvalues|is_a|items|iter|keys|len|set|setdefault|update|values))?\\b" |
| 527 | "name": "support.function.library.yue", | 527 | }, |
| 528 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.Map(?:(?:\\.|::|\\\\)(?:_class|_init|_name|cast|catch|class_of|get|getvalues|is_a|items|iter|keys|len|set|setdefault|update|values))?\\b" | 528 | { |
| 529 | }, | 529 | "name": "support.function.library.yue", |
| 530 | { | 530 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.MultiMap(?:(?:\\.|::|\\\\)(?:_base|_class|_init|_name|_parent_with_init|cast|catch|class_of|get|getvalues|is_a|items|iter|keys|len|set|setdefault|update|values))?\\b" |
| 531 | "name": "support.function.library.yue", | 531 | }, |
| 532 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.MultiMap(?:(?:\\.|::|\\\\)(?:_base|_class|_init|_name|_parent_with_init|cast|catch|class_of|get|getvalues|is_a|items|iter|keys|len|set|setdefault|update|values))?\\b" | 532 | { |
| 533 | }, | 533 | "name": "support.function.library.yue", |
| 534 | { | 534 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.OrderedMap(?:(?:\\.|::|\\\\)(?:_base|_class|_init|_name|_parent_with_init|cast|catch|class_of|get|getvalues|insert|is_a|items|iter|keys|len|set|setdefault|sort|update|values))?\\b" |
| 535 | "name": "support.function.library.yue", | 535 | }, |
| 536 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.OrderedMap(?:(?:\\.|::|\\\\)(?:_base|_class|_init|_name|_parent_with_init|cast|catch|class_of|get|getvalues|insert|is_a|items|iter|keys|len|set|setdefault|sort|update|values))?\\b" | 536 | { |
| 537 | }, | 537 | "name": "support.function.library.yue", |
| 538 | { | 538 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.Set(?:(?:\\.|::|\\\\)(?:_base|_class|_init|_name|_parent_with_init|cast|catch|class_of|difference|get|getvalues|intersection|is_a|isdisjoint|isempty|issubset|items|iter|keys|len|map|set|setdefault|symmetric_difference|union|update|values))?\\b" |
| 539 | "name": "support.function.library.yue", | 539 | }, |
| 540 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.Set(?:(?:\\.|::|\\\\)(?:_base|_class|_init|_name|_parent_with_init|cast|catch|class_of|difference|get|getvalues|intersection|is_a|isdisjoint|isempty|issubset|items|iter|keys|len|map|set|setdefault|symmetric_difference|union|update|values))?\\b" | 540 | { |
| 541 | }, | 541 | "name": "support.function.library.yue", |
| 542 | { | 542 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.app(?:(?:\\.|::|\\\\)(?:appfile|lua|parse_args|platform|require_here|script_name))?\\b" |
| 543 | "name": "support.function.library.yue", | 543 | }, |
| 544 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.app(?:(?:\\.|::|\\\\)(?:appfile|lua|parse_args|platform|require_here|script_name))?\\b" | 544 | { |
| 545 | }, | 545 | "name": "support.function.library.yue", |
| 546 | { | 546 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.array2d(?:(?:\\.|::|\\\\)(?:column|columns|default_range|extract_cols|extract_rows|flatten|forall|iter|map|map2|move|new|parse_range|product|range|reduce2|reduce_cols|reduce_rows|remove_col|remove_row|reshape|row|rows|set|size|slice|swap_cols|swap_rows|transpose|write))?\\b" |
| 547 | "name": "support.function.library.yue", | 547 | }, |
| 548 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.array2d(?:(?:\\.|::|\\\\)(?:column|columns|default_range|extract_cols|extract_rows|flatten|forall|iter|map|map2|move|new|parse_range|product|range|reduce2|reduce_cols|reduce_rows|remove_col|remove_row|reshape|row|rows|set|size|slice|swap_cols|swap_rows|transpose|write))?\\b" | 548 | { |
| 549 | }, | 549 | "name": "support.function.library.yue", |
| 550 | { | 550 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.class(?:(?:\\.|::|\\\\)(?:properties))?\\b" |
| 551 | "name": "support.function.library.yue", | 551 | }, |
| 552 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.class(?:(?:\\.|::|\\\\)(?:properties))?\\b" | 552 | { |
| 553 | }, | 553 | "name": "support.function.library.yue", |
| 554 | { | 554 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.compat(?:(?:\\.|::|\\\\)(?:dir_separator|execute|getfenv|is_windows|jit|load|lua51|setfenv))?\\b" |
| 555 | "name": "support.function.library.yue", | 555 | }, |
| 556 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.compat(?:(?:\\.|::|\\\\)(?:dir_separator|execute|getfenv|is_windows|jit|load|lua51|setfenv))?\\b" | 556 | { |
| 557 | }, | 557 | "name": "support.function.library.yue", |
| 558 | { | 558 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.comprehension(?:(?:\\.|::|\\\\)(?:new))?\\b" |
| 559 | "name": "support.function.library.yue", | 559 | }, |
| 560 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.comprehension(?:(?:\\.|::|\\\\)(?:new))?\\b" | 560 | { |
| 561 | }, | 561 | "name": "support.function.library.yue", |
| 562 | { | 562 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.config(?:(?:\\.|::|\\\\)(?:lines|read))?\\b" |
| 563 | "name": "support.function.library.yue", | 563 | }, |
| 564 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.config(?:(?:\\.|::|\\\\)(?:lines|read))?\\b" | 564 | { |
| 565 | }, | 565 | "name": "support.function.library.yue", |
| 566 | { | 566 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.data(?:(?:\\.|::|\\\\)(?:filter|new|query|read|write))?\\b" |
| 567 | "name": "support.function.library.yue", | 567 | }, |
| 568 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.data(?:(?:\\.|::|\\\\)(?:filter|new|query|read|write))?\\b" | 568 | { |
| 569 | }, | 569 | "name": "support.function.library.yue", |
| 570 | { | 570 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.dir(?:(?:\\.|::|\\\\)(?:clonetree|copyfile|dirtree|filter|fnmatch|getallfiles|getdirectories|getfiles|makepath|movefile|rmtree|walk))?\\b" |
| 571 | "name": "support.function.library.yue", | 571 | }, |
| 572 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.dir(?:(?:\\.|::|\\\\)(?:clonetree|copyfile|dirtree|filter|fnmatch|getallfiles|getdirectories|getfiles|makepath|movefile|rmtree|walk))?\\b" | 572 | { |
| 573 | }, | 573 | "name": "support.function.library.yue", |
| 574 | { | 574 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.file(?:(?:\\.|::|\\\\)(?:access_time|copy|creation_time|delete|modified_time|move|read|write))?\\b" |
| 575 | "name": "support.function.library.yue", | 575 | }, |
| 576 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.file(?:(?:\\.|::|\\\\)(?:access_time|copy|creation_time|delete|modified_time|move|read|write))?\\b" | 576 | { |
| 577 | }, | 577 | "name": "support.function.library.yue", |
| 578 | { | 578 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.func(?:(?:\\.|::|\\\\)(?:And|Args|Eq|Ge|Gt|I|Le|Len|Lt|Nil|Not|Or|PE|Var|_|_0|_1|_2|_3|_4|_5|bind|bind1|collect_values|compose|curry|import|instantiate|isPE|lookup_imported_name|register|repr|tail))?\\b" |
| 579 | "name": "support.function.library.yue", | 579 | }, |
| 580 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.func(?:(?:\\.|::|\\\\)(?:And|Args|Eq|Ge|Gt|I|Le|Len|Lt|Nil|Not|Or|PE|Var|_|_0|_1|_2|_3|_4|_5|bind|bind1|collect_values|compose|curry|import|instantiate|isPE|lookup_imported_name|register|repr|tail))?\\b" | 580 | { |
| 581 | }, | 581 | "name": "support.function.library.yue", |
| 582 | { | 582 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.input(?:(?:\\.|::|\\\\)(?:alltokens|create_getter|fields|numbers|words))?\\b" |
| 583 | "name": "support.function.library.yue", | 583 | }, |
| 584 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.input(?:(?:\\.|::|\\\\)(?:alltokens|create_getter|fields|numbers|words))?\\b" | 584 | { |
| 585 | }, | 585 | "name": "support.function.library.yue", |
| 586 | { | 586 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.lapp(?:(?:\\.|::|\\\\)(?:add_type|assert|callback|error|open|process_options_string|quit|show_usage_error))?\\b" |
| 587 | "name": "support.function.library.yue", | 587 | }, |
| 588 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.lapp(?:(?:\\.|::|\\\\)(?:add_type|assert|callback|error|open|process_options_string|quit|show_usage_error))?\\b" | 588 | { |
| 589 | }, | 589 | "name": "support.function.library.yue", |
| 590 | { | 590 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.lexer(?:(?:\\.|::|\\\\)(?:cpp|expecting|get_keywords|get_separated_list|getline|getrest|insert|lineno|lua|scan|skipws))?\\b" |
| 591 | "name": "support.function.library.yue", | 591 | }, |
| 592 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.lexer(?:(?:\\.|::|\\\\)(?:cpp|expecting|get_keywords|get_separated_list|getline|getrest|insert|lineno|lua|scan|skipws))?\\b" | 592 | { |
| 593 | }, | 593 | "name": "support.function.library.yue", |
| 594 | { | 594 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.luabalanced(?:(?:\\.|::|\\\\)(?:gsub|match_bracketed|match_explist|match_expression|match_namelist|match_string))?\\b" |
| 595 | "name": "support.function.library.yue", | 595 | }, |
| 596 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.luabalanced(?:(?:\\.|::|\\\\)(?:gsub|match_bracketed|match_explist|match_expression|match_namelist|match_string))?\\b" | 596 | { |
| 597 | }, | 597 | "name": "support.function.library.yue", |
| 598 | { | 598 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.operator(?:(?:\\.|::|\\\\)(?:add|call|concat|div|eq|ge|gt|index|land|le|len|lnot|lor|lt|match|mod|mul|neq|nop|optable|pow|sub|table|unm))?\\b" |
| 599 | "name": "support.function.library.yue", | 599 | }, |
| 600 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.operator(?:(?:\\.|::|\\\\)(?:add|call|concat|div|eq|ge|gt|index|land|le|len|lnot|lor|lt|match|mod|mul|neq|nop|optable|pow|sub|table|unm))?\\b" | 600 | { |
| 601 | }, | 601 | "name": "support.function.library.yue", |
| 602 | { | 602 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.path(?:(?:\\.|::|\\\\)(?:abspath|attrib|basename|chdir|common_prefix|currentdir|dir|dirname|dirsep|exists|expanduser|extension|getatime|getctime|getmtime|getsize|is_windows|isabs|isdir|isfile|islink|join|link_attrib|mkdir|normcase|normpath|package_path|relpath|rmdir|sep|splitext|splitpath|tmpname))?\\b" |
| 603 | "name": "support.function.library.yue", | 603 | }, |
| 604 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.path(?:(?:\\.|::|\\\\)(?:abspath|attrib|basename|chdir|common_prefix|currentdir|dir|dirname|dirsep|exists|expanduser|extension|getatime|getctime|getmtime|getsize|is_windows|isabs|isdir|isfile|islink|join|link_attrib|mkdir|normcase|normpath|package_path|relpath|rmdir|sep|splitext|splitpath|tmpname))?\\b" | 604 | { |
| 605 | }, | 605 | "name": "support.function.library.yue", |
| 606 | { | 606 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.permute(?:(?:\\.|::|\\\\)(?:iter|list_iter|list_table|order_iter|order_table|table))?\\b" |
| 607 | "name": "support.function.library.yue", | 607 | }, |
| 608 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.permute(?:(?:\\.|::|\\\\)(?:iter|list_iter|list_table|order_iter|order_table|table))?\\b" | 608 | { |
| 609 | }, | 609 | "name": "support.function.library.yue", |
| 610 | { | 610 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.pretty(?:(?:\\.|::|\\\\)(?:debug|dump|load|number|read|write))?\\b" |
| 611 | "name": "support.function.library.yue", | 611 | }, |
| 612 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.pretty(?:(?:\\.|::|\\\\)(?:debug|dump|load|number|read|write))?\\b" | 612 | { |
| 613 | }, | 613 | "name": "support.function.library.yue", |
| 614 | { | 614 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.seq(?:(?:\\.|::|\\\\)(?:copy|copy2|copy_tuples|count|count_map|enum|equal_to|filter|foreach|greater_than|import|iter|keys|last|less_than|lines|list|map|mapmethod|matching|minmax|printall|random|range|reduce|skip|sort|splice|sum|take|unique|zip))?\\b" |
| 615 | "name": "support.function.library.yue", | 615 | }, |
| 616 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.seq(?:(?:\\.|::|\\\\)(?:copy|copy2|copy_tuples|count|count_map|enum|equal_to|filter|foreach|greater_than|import|iter|keys|last|less_than|lines|list|map|mapmethod|matching|minmax|printall|random|range|reduce|skip|sort|splice|sum|take|unique|zip))?\\b" | 616 | { |
| 617 | }, | 617 | "name": "support.function.library.yue", |
| 618 | { | 618 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.sip(?:(?:\\.|::|\\\\)(?:compile|create_pattern|create_spec_fun|custom_pattern|fields|match|match_at_start|pattern|read))?\\b" |
| 619 | "name": "support.function.library.yue", | 619 | }, |
| 620 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.sip(?:(?:\\.|::|\\\\)(?:compile|create_pattern|create_spec_fun|custom_pattern|fields|match|match_at_start|pattern|read))?\\b" | 620 | { |
| 621 | }, | 621 | "name": "support.function.library.yue", |
| 622 | { | 622 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.strict(?:(?:\\.|::|\\\\)(?:closed_module|make_all_strict|module))?\\b" |
| 623 | "name": "support.function.library.yue", | 623 | }, |
| 624 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.strict(?:(?:\\.|::|\\\\)(?:closed_module|make_all_strict|module))?\\b" | 624 | { |
| 625 | }, | 625 | "name": "support.function.library.yue", |
| 626 | { | 626 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.stringio(?:(?:\\.|::|\\\\)(?:create|lines|open))?\\b" |
| 627 | "name": "support.function.library.yue", | 627 | }, |
| 628 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.stringio(?:(?:\\.|::|\\\\)(?:create|lines|open))?\\b" | 628 | { |
| 629 | }, | 629 | "name": "support.function.library.yue", |
| 630 | { | 630 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.stringx(?:(?:\\.|::|\\\\)(?:Template|at|capitalize|center|count|dedent|endswith|expandtabs|fill|format_operator|import|indent|isalnum|isalpha|isdigit|islower|isspace|isupper|join|lfind|lines|ljust|lstrip|partition|quote_string|replace|rfind|rjust|rpartition|rstrip|shorten|split|splitlines|splitv|startswith|strip|title|wrap))?\\b" |
| 631 | "name": "support.function.library.yue", | 631 | }, |
| 632 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.stringx(?:(?:\\.|::|\\\\)(?:Template|at|capitalize|center|count|dedent|endswith|expandtabs|fill|format_operator|import|indent|isalnum|isalpha|isdigit|islower|isspace|isupper|join|lfind|lines|ljust|lstrip|partition|quote_string|replace|rfind|rjust|rpartition|rstrip|shorten|split|splitlines|splitv|startswith|strip|title|wrap))?\\b" | 632 | { |
| 633 | }, | 633 | "name": "support.function.library.yue", |
| 634 | { | 634 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.tablex(?:(?:\\.|::|\\\\)(?:_normalize_slice|clear|compare|compare_no_order|copy|count_map|deepcompare|deepcopy|difference|filter|find|find_if|foreach|foreachi|icopy|imap|imap2|index_by|index_map|insertvalues|intersection|keys|makeset|map|map2|map_named_method|mapn|merge|move|new|pairmap|range|readonly|reduce|removevalues|rfind|search|set|size|sort|sortv|sub|transform|union|update|values|zip))?\\b" |
| 635 | "name": "support.function.library.yue", | 635 | }, |
| 636 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.tablex(?:(?:\\.|::|\\\\)(?:_normalize_slice|clear|compare|compare_no_order|copy|count_map|deepcompare|deepcopy|difference|filter|find|find_if|foreach|foreachi|icopy|imap|imap2|index_by|index_map|insertvalues|intersection|keys|makeset|map|map2|map_named_method|mapn|merge|move|new|pairmap|range|readonly|reduce|removevalues|rfind|search|set|size|sort|sortv|sub|transform|union|update|values|zip))?\\b" | 636 | { |
| 637 | }, | 637 | "name": "support.function.library.yue", |
| 638 | { | 638 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.template(?:(?:\\.|::|\\\\)(?:compile|substitute))?\\b" |
| 639 | "name": "support.function.library.yue", | 639 | }, |
| 640 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.template(?:(?:\\.|::|\\\\)(?:compile|substitute))?\\b" | 640 | { |
| 641 | }, | 641 | "name": "support.function.library.yue", |
| 642 | { | 642 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.test(?:(?:\\.|::|\\\\)(?:asserteq|asserteq2|assertmatch|assertraise|complain|error_handler|timer|tuple))?\\b" |
| 643 | "name": "support.function.library.yue", | 643 | }, |
| 644 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.test(?:(?:\\.|::|\\\\)(?:asserteq|asserteq2|assertmatch|assertraise|complain|error_handler|timer|tuple))?\\b" | 644 | { |
| 645 | }, | 645 | "name": "support.function.library.yue", |
| 646 | { | 646 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.text(?:(?:\\.|::|\\\\)(?:Template|at|capitalize|center|count|dedent|endswith|expandtabs|fill|format_operator|import|indent|isalnum|isalpha|isdigit|islower|isspace|isupper|join|lfind|lines|ljust|lstrip|partition|quote_string|replace|rfind|rjust|rpartition|rstrip|shorten|split|splitlines|splitv|startswith|strip|title|wrap))?\\b" |
| 647 | "name": "support.function.library.yue", | 647 | }, |
| 648 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.text(?:(?:\\.|::|\\\\)(?:Template|at|capitalize|center|count|dedent|endswith|expandtabs|fill|format_operator|import|indent|isalnum|isalpha|isdigit|islower|isspace|isupper|join|lfind|lines|ljust|lstrip|partition|quote_string|replace|rfind|rjust|rpartition|rstrip|shorten|split|splitlines|splitv|startswith|strip|title|wrap))?\\b" | 648 | { |
| 649 | }, | 649 | "name": "support.function.library.yue", |
| 650 | { | 650 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.types(?:(?:\\.|::|\\\\)(?:is_callable|is_empty|is_indexable|is_integer|is_iterable|is_type|is_writeable|to_bool|type))?\\b" |
| 651 | "name": "support.function.library.yue", | 651 | }, |
| 652 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.types(?:(?:\\.|::|\\\\)(?:is_callable|is_empty|is_indexable|is_integer|is_iterable|is_type|is_writeable|to_bool|type))?\\b" | 652 | { |
| 653 | }, | 653 | "name": "support.function.library.yue", |
| 654 | { | 654 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.url(?:(?:\\.|::|\\\\)(?:quote|unquote))?\\b" |
| 655 | "name": "support.function.library.yue", | 655 | }, |
| 656 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.url(?:(?:\\.|::|\\\\)(?:quote|unquote))?\\b" | 656 | { |
| 657 | }, | 657 | "name": "support.function.library.yue", |
| 658 | { | 658 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.utils(?:(?:\\.|::|\\\\)(?:_VERSION|add_function_factory|array_tostring|assert_arg|assert_string|bind1|bind2|choose|dir_separator|enum|escape|execute|executeex|fprintf|function_arg|getfenv|import|is_type|is_windows|jit|kpairs|load|lua51|memoize|npairs|on_error|pack|patterns|printf|quit|quote_arg|raise|raise_deprecation|readfile|readlines|set_deprecation_func|setfenv|split|splitv|stdmt|string_lambda|unpack|writefile))?\\b" |
| 659 | "name": "support.function.library.yue", | 659 | }, |
| 660 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.utils(?:(?:\\.|::|\\\\)(?:_VERSION|add_function_factory|array_tostring|assert_arg|assert_string|bind1|bind2|choose|dir_separator|enum|escape|execute|executeex|fprintf|function_arg|getfenv|import|is_type|is_windows|jit|kpairs|load|lua51|memoize|npairs|on_error|pack|patterns|printf|quit|quote_arg|raise|raise_deprecation|readfile|readlines|set_deprecation_func|setfenv|split|splitv|stdmt|string_lambda|unpack|writefile))?\\b" | 660 | { |
| 661 | }, | 661 | "name": "support.function.library.yue", |
| 662 | { | 662 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.xml(?:(?:\\.|::|\\\\)(?:basic_parse|clone|compare|elem|is_tag|new|parse|parsehtml|tags|tostring|walk|xml_escape|xml_unescape))?\\b" |
| 663 | "name": "support.function.library.yue", | 663 | }, |
| 664 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.xml(?:(?:\\.|::|\\\\)(?:basic_parse|clone|compare|elem|is_tag|new|parse|parsehtml|tags|tostring|walk|xml_escape|xml_unescape))?\\b" | 664 | { |
| 665 | }, | 665 | "name": "support.function.library.yue", |
| 666 | { | 666 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*string(?:(?:\\.|::|\\\\)(?:byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper))?\\b" |
| 667 | "name": "support.function.library.yue", | 667 | }, |
| 668 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*string(?:(?:\\.|::|\\\\)(?:byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper))?\\b" | 668 | { |
| 669 | }, | 669 | "name": "support.function.library.yue", |
| 670 | { | 670 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*table(?:(?:\\.|::|\\\\)(?:concat|insert|move|pack|remove|sort|unpack))?\\b" |
| 671 | "name": "support.function.library.yue", | 671 | }, |
| 672 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*table(?:(?:\\.|::|\\\\)(?:concat|insert|move|pack|remove|sort|unpack))?\\b" | 672 | { |
| 673 | }, | 673 | "name": "support.function.library.yue", |
| 674 | { | 674 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*utf8(?:(?:\\.|::|\\\\)(?:char|charpattern|codepoint|codes|len|offset))?\\b" |
| 675 | "name": "support.function.library.yue", | 675 | }, |
| 676 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*utf8(?:(?:\\.|::|\\\\)(?:char|charpattern|codepoint|codes|len|offset))?\\b" | 676 | { |
| 677 | }, | 677 | "name": "support.function.library.yue", |
| 678 | { | 678 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*yue(?:(?:\\.|::|\\\\)(?:check|dofile|file_exist|find_modulepath|format|insert_loader|is_ast|loadfile|loadstring|macro_env|options|p|pcall|read_file|to_ast|to_lua|traceback|version|yue_compiled))?\\b" |
| 679 | "name": "support.function.library.yue", | 679 | }, |
| 680 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*yue(?:(?:\\.|::|\\\\)(?:check|dofile|file_exist|find_modulepath|format|insert_loader|is_ast|loadfile|loadstring|macro_env|options|p|pcall|read_file|to_ast|to_lua|traceback|version|yue_compiled))?\\b" | 680 | { |
| 681 | }, | 681 | "name": "support.function.library.yue", |
| 682 | { | 682 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*(?:_G|_VERSION|arg|assert|collectgarbage|coroutine|debug|dofile|error|getmetatable|io|ipairs|lfs|load|loadfile|math|next|os|package|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setmetatable|string|table|tonumber|tostring|type|utf8|warn|xpcall)\\b" |
| 683 | "name": "support.function.library.yue", | 683 | } |
| 684 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*(?:_G|_VERSION|arg|assert|collectgarbage|coroutine|debug|dofile|error|getmetatable|io|ipairs|lfs|load|loadfile|math|next|os|package|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setmetatable|string|table|tonumber|tostring|type|utf8|warn|xpcall)\\b" | 684 | ] |
| 685 | } | 685 | } |
| 686 | ] | 686 | } |
| 687 | } | 687 | } |
| 688 | } | ||
| 689 | } \ No newline at end of file | ||
diff --git a/doc/docs/.vitepress/theme/components/CompilerModal.vue b/doc/docs/.vitepress/theme/components/CompilerModal.vue index c00443e..19d5830 100755 --- a/doc/docs/.vitepress/theme/components/CompilerModal.vue +++ b/doc/docs/.vitepress/theme/components/CompilerModal.vue | |||
| @@ -7,41 +7,41 @@ | |||
| 7 | </template> | 7 | </template> |
| 8 | 8 | ||
| 9 | <script> | 9 | <script> |
| 10 | import YueCompiler from './YueCompiler.vue' | 10 | import YueCompiler from "./YueCompiler.vue"; |
| 11 | 11 | ||
| 12 | export default { | 12 | export default { |
| 13 | components: { | 13 | components: { |
| 14 | YueCompiler | 14 | YueCompiler, |
| 15 | }, | 15 | }, |
| 16 | data() { | 16 | data() { |
| 17 | return { | 17 | return { |
| 18 | isOpen: false, | 18 | isOpen: false, |
| 19 | content: '' | 19 | content: "", |
| 20 | } | 20 | }; |
| 21 | }, | 21 | }, |
| 22 | mounted() { | 22 | mounted() { |
| 23 | this.handleOpen = (event) => { | 23 | this.handleOpen = (event) => { |
| 24 | this.content = event?.detail || '' | 24 | this.content = event?.detail || ""; |
| 25 | this.isOpen = true | 25 | this.isOpen = true; |
| 26 | } | 26 | }; |
| 27 | this.handleKeydown = (event) => { | 27 | this.handleKeydown = (event) => { |
| 28 | if (event.key === 'Escape' && this.isOpen) { | 28 | if (event.key === "Escape" && this.isOpen) { |
| 29 | this.close() | 29 | this.close(); |
| 30 | } | 30 | } |
| 31 | } | 31 | }; |
| 32 | window.addEventListener('yue:open-compiler', this.handleOpen) | 32 | window.addEventListener("yue:open-compiler", this.handleOpen); |
| 33 | window.addEventListener('keydown', this.handleKeydown) | 33 | window.addEventListener("keydown", this.handleKeydown); |
| 34 | }, | 34 | }, |
| 35 | beforeUnmount() { | 35 | beforeUnmount() { |
| 36 | window.removeEventListener('yue:open-compiler', this.handleOpen) | 36 | window.removeEventListener("yue:open-compiler", this.handleOpen); |
| 37 | window.removeEventListener('keydown', this.handleKeydown) | 37 | window.removeEventListener("keydown", this.handleKeydown); |
| 38 | }, | 38 | }, |
| 39 | methods: { | 39 | methods: { |
| 40 | close() { | 40 | close() { |
| 41 | this.isOpen = false | 41 | this.isOpen = false; |
| 42 | } | 42 | }, |
| 43 | } | 43 | }, |
| 44 | } | 44 | }; |
| 45 | </script> | 45 | </script> |
| 46 | 46 | ||
| 47 | <style scoped> | 47 | <style scoped> |
| @@ -63,5 +63,4 @@ export default { | |||
| 63 | background: #ffffff; | 63 | background: #ffffff; |
| 64 | box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2); | 64 | box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2); |
| 65 | } | 65 | } |
| 66 | |||
| 67 | </style> | 66 | </style> |
diff --git a/doc/docs/.vitepress/theme/components/HomeFooter.vue b/doc/docs/.vitepress/theme/components/HomeFooter.vue index 5ee116c..640b4a7 100644 --- a/doc/docs/.vitepress/theme/components/HomeFooter.vue +++ b/doc/docs/.vitepress/theme/components/HomeFooter.vue | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | import { useData } from 'vitepress' | 2 | import { useData } from "vitepress"; |
| 3 | 3 | ||
| 4 | const { frontmatter } = useData() | 4 | const { frontmatter } = useData(); |
| 5 | </script> | 5 | </script> |
| 6 | 6 | ||
| 7 | <template> | 7 | <template> |
diff --git a/doc/docs/.vitepress/theme/components/YueCompiler.vue b/doc/docs/.vitepress/theme/components/YueCompiler.vue index a49692b..d9a3702 100755 --- a/doc/docs/.vitepress/theme/components/YueCompiler.vue +++ b/doc/docs/.vitepress/theme/components/YueCompiler.vue | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <template> | 1 | <template> |
| 2 | <div style="width: 100%; height: auto;"> | 2 | <div style="width: 100%; height: auto"> |
| 3 | <div class="parent"> | 3 | <div class="parent"> |
| 4 | <div class="editor-section"> | 4 | <div class="editor-section"> |
| 5 | <div class="childTitle">YueScript {{ info }}</div> | 5 | <div class="childTitle">YueScript {{ info }}</div> |
| @@ -10,7 +10,9 @@ | |||
| 10 | <div class="editor-section"> | 10 | <div class="editor-section"> |
| 11 | <div class="childTitle">Lua</div> | 11 | <div class="childTitle">Lua</div> |
| 12 | <div class="editor-container"> | 12 | <div class="editor-container"> |
| 13 | <pre class="code-output language-lua"><code v-html="highlightedLua"></code></pre> | 13 | <pre |
| 14 | class="code-output language-lua" | ||
| 15 | ><code v-html="highlightedLua"></code></pre> | ||
| 14 | </div> | 16 | </div> |
| 15 | </div> | 17 | </div> |
| 16 | </div> | 18 | </div> |
| @@ -22,447 +24,555 @@ | |||
| 22 | </template> | 24 | </template> |
| 23 | 25 | ||
| 24 | <script> | 26 | <script> |
| 25 | import pkg from 'prismjs/components/prism-core.js' | 27 | import pkg from "prismjs/components/prism-core.js"; |
| 26 | const { highlight, languages } = pkg | 28 | const { highlight, languages } = pkg; |
| 27 | import 'prismjs/components/prism-moonscript' | 29 | import "prismjs/components/prism-moonscript"; |
| 28 | import 'prismjs/components/prism-lua' | 30 | import "prismjs/components/prism-lua"; |
| 29 | import { EditorState, Compartment } from '@codemirror/state' | 31 | import { EditorState, Compartment } from "@codemirror/state"; |
| 30 | import { EditorView, keymap, lineNumbers } from '@codemirror/view' | 32 | import { EditorView, keymap, lineNumbers } from "@codemirror/view"; |
| 31 | import { | 33 | import { |
| 32 | indentUnit, | 34 | indentUnit, |
| 33 | StreamLanguage, | 35 | StreamLanguage, |
| 34 | syntaxHighlighting, | 36 | syntaxHighlighting, |
| 35 | HighlightStyle | 37 | HighlightStyle, |
| 36 | } from '@codemirror/language' | 38 | } from "@codemirror/language"; |
| 37 | import { tags } from '@lezer/highlight' | 39 | import { tags } from "@lezer/highlight"; |
| 38 | import { history, indentWithTab } from '@codemirror/commands' | 40 | import { history, indentWithTab } from "@codemirror/commands"; |
| 39 | import { defaultKeymap, historyKeymap } from '@codemirror/commands' | 41 | import { defaultKeymap, historyKeymap } from "@codemirror/commands"; |
| 40 | import { simpleMode } from '@codemirror/legacy-modes/mode/simple-mode' | 42 | import { simpleMode } from "@codemirror/legacy-modes/mode/simple-mode"; |
| 41 | 43 | ||
| 42 | /* shikijs/themes/light-plus: editor.background #FFFFFF, editor.foreground #000000 */ | 44 | /* shikijs/themes/light-plus: editor.background #FFFFFF, editor.foreground #000000 */ |
| 43 | const lightPlusTheme = EditorView.theme( | 45 | const lightPlusTheme = EditorView.theme( |
| 44 | { | 46 | { |
| 45 | '&': { | 47 | "&": { |
| 46 | height: '100%', | 48 | height: "100%", |
| 47 | backgroundColor: '#FFFFFF', | 49 | backgroundColor: "#FFFFFF", |
| 48 | color: '#000000', | 50 | color: "#000000", |
| 49 | fontSize: '14px' | 51 | fontSize: "14px", |
| 50 | }, | 52 | }, |
| 51 | '&.cm-focused': { | 53 | "&.cm-focused": { |
| 52 | outline: 'none' | 54 | outline: "none", |
| 53 | }, | 55 | }, |
| 54 | '.cm-content': { | 56 | ".cm-content": { |
| 55 | fontFamily: | 57 | fontFamily: |
| 56 | "ui-monospace, 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace", | 58 | "ui-monospace, 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace", |
| 57 | lineHeight: '1.375' | 59 | lineHeight: "1.375", |
| 58 | }, | 60 | }, |
| 59 | '.cm-gutters': { | 61 | ".cm-gutters": { |
| 60 | backgroundColor: '#FFFFFF', | 62 | backgroundColor: "#FFFFFF", |
| 61 | color: '#6e6e6e', | 63 | color: "#6e6e6e", |
| 62 | borderRight: 'none' | 64 | borderRight: "none", |
| 63 | }, | 65 | }, |
| 64 | '.cm-activeLine': { | 66 | ".cm-activeLine": { |
| 65 | backgroundColor: 'transparent' | 67 | backgroundColor: "transparent", |
| 66 | }, | 68 | }, |
| 67 | '.cm-activeLineGutter': { | 69 | ".cm-activeLineGutter": { |
| 68 | backgroundColor: 'transparent' | 70 | backgroundColor: "transparent", |
| 69 | }, | 71 | }, |
| 70 | '.cm-selectionBackground': { | 72 | ".cm-selectionBackground": { |
| 71 | backgroundColor: '#add6ff' | 73 | backgroundColor: "#add6ff", |
| 72 | }, | 74 | }, |
| 73 | '&.cm-focused .cm-selectionBackground': { | 75 | "&.cm-focused .cm-selectionBackground": { |
| 74 | backgroundColor: '#add6ff' | 76 | backgroundColor: "#add6ff", |
| 75 | }, | 77 | }, |
| 76 | '.cm-cursor': { | 78 | ".cm-cursor": { |
| 77 | borderLeftColor: '#000000' | 79 | borderLeftColor: "#000000", |
| 80 | }, | ||
| 81 | ".cm-matchingBracket": { | ||
| 82 | backgroundColor: "#c9def5", | ||
| 78 | }, | 83 | }, |
| 79 | '.cm-matchingBracket': { | ||
| 80 | backgroundColor: '#c9def5' | ||
| 81 | } | ||
| 82 | }, | 84 | }, |
| 83 | { dark: false } | 85 | { dark: false }, |
| 84 | ) | 86 | ); |
| 85 | 87 | ||
| 86 | /* shikijs/themes/dark-plus: editor.background #1E1E1E, editor.foreground #D4D4D4 */ | 88 | /* shikijs/themes/dark-plus: editor.background #1E1E1E, editor.foreground #D4D4D4 */ |
| 87 | const darkPlusTheme = EditorView.theme( | 89 | const darkPlusTheme = EditorView.theme( |
| 88 | { | 90 | { |
| 89 | '&': { | 91 | "&": { |
| 90 | height: '100%', | 92 | height: "100%", |
| 91 | backgroundColor: '#1E1E1E', | 93 | backgroundColor: "#1E1E1E", |
| 92 | color: '#D4D4D4', | 94 | color: "#D4D4D4", |
| 93 | fontSize: '14px' | 95 | fontSize: "14px", |
| 94 | }, | 96 | }, |
| 95 | '&.cm-focused': { | 97 | "&.cm-focused": { |
| 96 | outline: 'none' | 98 | outline: "none", |
| 97 | }, | 99 | }, |
| 98 | '.cm-content': { | 100 | ".cm-content": { |
| 99 | fontFamily: | 101 | fontFamily: |
| 100 | "ui-monospace, 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace", | 102 | "ui-monospace, 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace", |
| 101 | lineHeight: '1.375' | 103 | lineHeight: "1.375", |
| 102 | }, | 104 | }, |
| 103 | '.cm-gutters': { | 105 | ".cm-gutters": { |
| 104 | backgroundColor: '#1E1E1E', | 106 | backgroundColor: "#1E1E1E", |
| 105 | color: '#858585', | 107 | color: "#858585", |
| 106 | borderRight: 'none' | 108 | borderRight: "none", |
| 107 | }, | 109 | }, |
| 108 | '.cm-activeLine': { | 110 | ".cm-activeLine": { |
| 109 | backgroundColor: 'transparent' | 111 | backgroundColor: "transparent", |
| 110 | }, | 112 | }, |
| 111 | '.cm-activeLineGutter': { | 113 | ".cm-activeLineGutter": { |
| 112 | backgroundColor: 'transparent' | 114 | backgroundColor: "transparent", |
| 113 | }, | 115 | }, |
| 114 | '.cm-selectionBackground': { | 116 | ".cm-selectionBackground": { |
| 115 | backgroundColor: '#264f78' | 117 | backgroundColor: "#264f78", |
| 116 | }, | 118 | }, |
| 117 | '&.cm-focused .cm-selectionBackground': { | 119 | "&.cm-focused .cm-selectionBackground": { |
| 118 | backgroundColor: '#264f78' | 120 | backgroundColor: "#264f78", |
| 119 | }, | 121 | }, |
| 120 | '.cm-cursor': { | 122 | ".cm-cursor": { |
| 121 | borderLeftColor: '#aeafad' | 123 | borderLeftColor: "#aeafad", |
| 124 | }, | ||
| 125 | ".cm-matchingBracket": { | ||
| 126 | backgroundColor: "#3a3d41", | ||
| 122 | }, | 127 | }, |
| 123 | '.cm-matchingBracket': { | ||
| 124 | backgroundColor: '#3a3d41' | ||
| 125 | } | ||
| 126 | }, | 128 | }, |
| 127 | { dark: true } | 129 | { dark: true }, |
| 128 | ) | 130 | ); |
| 129 | 131 | ||
| 130 | /* shikijs/themes/light-plus tokenColors */ | 132 | /* shikijs/themes/light-plus tokenColors */ |
| 131 | const lightPlusHighlightStyle = HighlightStyle.define([ | 133 | const lightPlusHighlightStyle = HighlightStyle.define( |
| 132 | { tag: tags.comment, color: '#008000' }, | 134 | [ |
| 133 | { tag: tags.keyword, color: '#AF00DB' }, | 135 | { tag: tags.comment, color: "#008000" }, |
| 134 | { tag: [tags.operator, tags.punctuation], color: '#000000' }, | 136 | { tag: tags.keyword, color: "#AF00DB" }, |
| 135 | { tag: [tags.string, tags.special(tags.string)], color: '#a31515' }, | 137 | { tag: [tags.operator, tags.punctuation], color: "#000000" }, |
| 136 | { tag: tags.regexp, color: '#811f3f' }, | 138 | { tag: [tags.string, tags.special(tags.string)], color: "#a31515" }, |
| 137 | { tag: [tags.number, tags.bool, tags.null], color: '#098658' }, | 139 | { tag: tags.regexp, color: "#811f3f" }, |
| 138 | { tag: tags.function(tags.variableName), color: '#795e26' }, | 140 | { tag: [tags.number, tags.bool, tags.null], color: "#098658" }, |
| 139 | { tag: tags.typeName, color: '#267f99' }, | 141 | { tag: tags.function(tags.variableName), color: "#795e26" }, |
| 140 | { tag: tags.className, color: '#267f99' }, | 142 | { tag: tags.typeName, color: "#267f99" }, |
| 141 | { tag: tags.propertyName, color: '#001080' }, | 143 | { tag: tags.className, color: "#267f99" }, |
| 142 | { tag: tags.tagName, color: '#800000' }, | 144 | { tag: tags.propertyName, color: "#001080" }, |
| 143 | { tag: tags.attributeName, color: '#e50000' }, | 145 | { tag: tags.tagName, color: "#800000" }, |
| 144 | { tag: tags.meta, color: '#666666' }, | 146 | { tag: tags.attributeName, color: "#e50000" }, |
| 145 | { tag: tags.invalid, color: '#cd3131' }, | 147 | { tag: tags.meta, color: "#666666" }, |
| 146 | // Additional tags for YueScript - ensure all token types have styles | 148 | { tag: tags.invalid, color: "#cd3131" }, |
| 147 | { tag: tags.variableName, color: '#001080' }, | 149 | // Additional tags for YueScript - ensure all token types have styles |
| 148 | { tag: tags.constant(tags.name), color: '#098658' }, | 150 | { tag: tags.variableName, color: "#001080" }, |
| 149 | { tag: tags.constant(tags.variableName), color: '#098658' }, | 151 | { tag: tags.constant(tags.name), color: "#098658" }, |
| 150 | { tag: tags.constant, color: '#098658' }, | 152 | { tag: tags.constant(tags.variableName), color: "#098658" }, |
| 151 | { tag: tags.definition(tags.variableName), color: '#001080' }, | 153 | { tag: tags.constant, color: "#098658" }, |
| 152 | { tag: tags.modifier, color: '#AF00DB' }, | 154 | { tag: tags.definition(tags.variableName), color: "#001080" }, |
| 153 | { tag: tags.namespace, color: '#267f99' }, | 155 | { tag: tags.modifier, color: "#AF00DB" }, |
| 154 | { tag: tags.labelName, color: '#795e26' }, | 156 | { tag: tags.namespace, color: "#267f99" }, |
| 155 | { tag: tags.character, color: '#098658' }, | 157 | { tag: tags.labelName, color: "#795e26" }, |
| 156 | { tag: tags.literal, color: '#098658' }, | 158 | { tag: tags.character, color: "#098658" }, |
| 157 | { tag: tags.bracket, color: '#000000' }, | 159 | { tag: tags.literal, color: "#098658" }, |
| 158 | { tag: tags.squareBracket, color: '#000000' }, | 160 | { tag: tags.bracket, color: "#000000" }, |
| 159 | { tag: tags.paren, color: '#000000' }, | 161 | { tag: tags.squareBracket, color: "#000000" }, |
| 160 | { tag: tags.brace, color: '#000000' } | 162 | { tag: tags.paren, color: "#000000" }, |
| 161 | ], { fallback: true }) | 163 | { tag: tags.brace, color: "#000000" }, |
| 164 | ], | ||
| 165 | { fallback: true }, | ||
| 166 | ); | ||
| 162 | 167 | ||
| 163 | /* shikijs/themes/dark-plus tokenColors */ | 168 | /* shikijs/themes/dark-plus tokenColors */ |
| 164 | const darkPlusHighlightStyle = HighlightStyle.define([ | 169 | const darkPlusHighlightStyle = HighlightStyle.define( |
| 165 | { tag: tags.comment, color: '#6a9955' }, | 170 | [ |
| 166 | { tag: tags.keyword, color: '#C586C0' }, | 171 | { tag: tags.comment, color: "#6a9955" }, |
| 167 | { tag: [tags.operator, tags.punctuation], color: '#d4d4d4' }, | 172 | { tag: tags.keyword, color: "#C586C0" }, |
| 168 | { tag: [tags.string, tags.special(tags.string)], color: '#ce9178' }, | 173 | { tag: [tags.operator, tags.punctuation], color: "#d4d4d4" }, |
| 169 | { tag: tags.regexp, color: '#d16969' }, | 174 | { tag: [tags.string, tags.special(tags.string)], color: "#ce9178" }, |
| 170 | { tag: [tags.number, tags.bool, tags.null], color: '#b5cea8' }, | 175 | { tag: tags.regexp, color: "#d16969" }, |
| 171 | { tag: tags.function(tags.variableName), color: '#dcdcaa' }, | 176 | { tag: [tags.number, tags.bool, tags.null], color: "#b5cea8" }, |
| 172 | { tag: tags.typeName, color: '#4ec9b0' }, | 177 | { tag: tags.function(tags.variableName), color: "#dcdcaa" }, |
| 173 | { tag: tags.className, color: '#4ec9b0' }, | 178 | { tag: tags.typeName, color: "#4ec9b0" }, |
| 174 | { tag: tags.propertyName, color: '#9cdcfe' }, | 179 | { tag: tags.className, color: "#4ec9b0" }, |
| 175 | { tag: tags.tagName, color: '#569cd6' }, | 180 | { tag: tags.propertyName, color: "#9cdcfe" }, |
| 176 | { tag: tags.attributeName, color: '#9cdcfe' }, | 181 | { tag: tags.tagName, color: "#569cd6" }, |
| 177 | { tag: tags.meta, color: '#d4d4d4' }, | 182 | { tag: tags.attributeName, color: "#9cdcfe" }, |
| 178 | { tag: tags.invalid, color: '#f44747' }, | 183 | { tag: tags.meta, color: "#d4d4d4" }, |
| 179 | // Additional tags for YueScript - ensure all token types have styles | 184 | { tag: tags.invalid, color: "#f44747" }, |
| 180 | { tag: tags.variableName, color: '#9cdcfe' }, | 185 | // Additional tags for YueScript - ensure all token types have styles |
| 181 | { tag: tags.constant(tags.name), color: '#b5cea8' }, | 186 | { tag: tags.variableName, color: "#9cdcfe" }, |
| 182 | { tag: tags.constant(tags.variableName), color: '#b5cea8' }, | 187 | { tag: tags.constant(tags.name), color: "#b5cea8" }, |
| 183 | { tag: tags.constant, color: '#b5cea8' }, | 188 | { tag: tags.constant(tags.variableName), color: "#b5cea8" }, |
| 184 | { tag: tags.definition(tags.variableName), color: '#9cdcfe' }, | 189 | { tag: tags.constant, color: "#b5cea8" }, |
| 185 | { tag: tags.modifier, color: '#C586C0' }, | 190 | { tag: tags.definition(tags.variableName), color: "#9cdcfe" }, |
| 186 | { tag: tags.namespace, color: '#4ec9b0' }, | 191 | { tag: tags.modifier, color: "#C586C0" }, |
| 187 | { tag: tags.labelName, color: '#dcdcaa' }, | 192 | { tag: tags.namespace, color: "#4ec9b0" }, |
| 188 | { tag: tags.character, color: '#b5cea8' }, | 193 | { tag: tags.labelName, color: "#dcdcaa" }, |
| 189 | { tag: tags.literal, color: '#b5cea8' }, | 194 | { tag: tags.character, color: "#b5cea8" }, |
| 190 | { tag: tags.bracket, color: '#d4d4d4' }, | 195 | { tag: tags.literal, color: "#b5cea8" }, |
| 191 | { tag: tags.squareBracket, color: '#d4d4d4' }, | 196 | { tag: tags.bracket, color: "#d4d4d4" }, |
| 192 | { tag: tags.paren, color: '#d4d4d4' }, | 197 | { tag: tags.squareBracket, color: "#d4d4d4" }, |
| 193 | { tag: tags.brace, color: '#d4d4d4' } | 198 | { tag: tags.paren, color: "#d4d4d4" }, |
| 194 | ], { fallback: true }) | 199 | { tag: tags.brace, color: "#d4d4d4" }, |
| 200 | ], | ||
| 201 | { fallback: true }, | ||
| 202 | ); | ||
| 195 | 203 | ||
| 196 | export default { | 204 | export default { |
| 197 | props: { | 205 | props: { |
| 198 | compileronly: { | 206 | compileronly: { |
| 199 | type: Boolean, | 207 | type: Boolean, |
| 200 | default: false | 208 | default: false, |
| 201 | }, | 209 | }, |
| 202 | displayonly: { | 210 | displayonly: { |
| 203 | type: Boolean, | 211 | type: Boolean, |
| 204 | default: false | 212 | default: false, |
| 205 | }, | 213 | }, |
| 206 | text: { | 214 | text: { |
| 207 | type: String, | 215 | type: String, |
| 208 | default: '' | 216 | default: "", |
| 209 | } | 217 | }, |
| 210 | }, | 218 | }, |
| 211 | data() { | 219 | data() { |
| 212 | return { | 220 | return { |
| 213 | info: 'Loading', | 221 | info: "Loading", |
| 214 | readonly: true, | 222 | readonly: true, |
| 215 | code: '', | 223 | code: "", |
| 216 | compiled: '', | 224 | compiled: "", |
| 217 | result: '', | 225 | result: "", |
| 218 | windowWidth: 0, | 226 | windowWidth: 0, |
| 219 | editorView: null, | 227 | editorView: null, |
| 220 | readOnlyCompartment: null, | 228 | readOnlyCompartment: null, |
| 221 | themeCompartment: null, | 229 | themeCompartment: null, |
| 222 | highlightCompartment: null, | 230 | highlightCompartment: null, |
| 223 | themeObserver: null | 231 | themeObserver: null, |
| 224 | } | 232 | }; |
| 225 | }, | 233 | }, |
| 226 | computed: { | 234 | computed: { |
| 227 | isMobileLayout() { | 235 | isMobileLayout() { |
| 228 | return this.windowWidth <= 768 | 236 | return this.windowWidth <= 768; |
| 229 | }, | 237 | }, |
| 230 | highlightedLua() { | 238 | highlightedLua() { |
| 231 | return highlight(this.compiled || '', languages.lua) | 239 | return highlight(this.compiled || "", languages.lua); |
| 232 | } | 240 | }, |
| 233 | }, | 241 | }, |
| 234 | mounted() { | 242 | mounted() { |
| 235 | this.windowWidth = window.innerWidth | 243 | this.windowWidth = window.innerWidth; |
| 236 | window.addEventListener('resize', this.handleResize) | 244 | window.addEventListener("resize", this.handleResize); |
| 237 | this.observeTheme() | 245 | this.observeTheme(); |
| 238 | 246 | ||
| 239 | const initialCode = this.text !== '' ? this.text : '' | 247 | const initialCode = this.text !== "" ? this.text : ""; |
| 240 | this.code = initialCode | 248 | this.code = initialCode; |
| 241 | this.codeChanged(initialCode) | 249 | this.codeChanged(initialCode); |
| 242 | this.initEditor(initialCode) | 250 | this.initEditor(initialCode); |
| 243 | this.$nextTick(() => { | 251 | this.$nextTick(() => { |
| 244 | this.focusEditorToEnd() | 252 | this.focusEditorToEnd(); |
| 245 | }) | 253 | }); |
| 246 | 254 | ||
| 247 | const check = ((self) => { | 255 | const check = ((self) => { |
| 248 | return () => { | 256 | return () => { |
| 249 | if (window.yue) { | 257 | if (window.yue) { |
| 250 | self.info = window.yue.version() | 258 | self.info = window.yue.version(); |
| 251 | self.readonly = false | 259 | self.readonly = false; |
| 252 | this.refreshEditorReadOnly() | 260 | this.refreshEditorReadOnly(); |
| 253 | } else { | 261 | } else { |
| 254 | setTimeout(check, 100) | 262 | setTimeout(check, 100); |
| 255 | } | 263 | } |
| 256 | } | 264 | }; |
| 257 | })(this) | 265 | })(this); |
| 258 | check() | 266 | check(); |
| 259 | }, | 267 | }, |
| 260 | beforeUnmount() { | 268 | beforeUnmount() { |
| 261 | window.removeEventListener('resize', this.handleResize) | 269 | window.removeEventListener("resize", this.handleResize); |
| 262 | if (this.editorView) { | 270 | if (this.editorView) { |
| 263 | this.editorView.destroy() | 271 | this.editorView.destroy(); |
| 264 | this.editorView = null | 272 | this.editorView = null; |
| 265 | } | 273 | } |
| 266 | if (this.themeObserver) { | 274 | if (this.themeObserver) { |
| 267 | this.themeObserver.disconnect() | 275 | this.themeObserver.disconnect(); |
| 268 | this.themeObserver = null | 276 | this.themeObserver = null; |
| 269 | } | 277 | } |
| 270 | }, | 278 | }, |
| 271 | methods: { | 279 | methods: { |
| 272 | focusEditorToEnd() { | 280 | focusEditorToEnd() { |
| 273 | if (!this.editorView) { | 281 | if (!this.editorView) { |
| 274 | return | 282 | return; |
| 275 | } | 283 | } |
| 276 | const docLength = this.editorView.state.doc.length | 284 | const docLength = this.editorView.state.doc.length; |
| 277 | this.editorView.dispatch({ | 285 | this.editorView.dispatch({ |
| 278 | selection: { anchor: docLength }, | 286 | selection: { anchor: docLength }, |
| 279 | scrollIntoView: true | 287 | scrollIntoView: true, |
| 280 | }) | 288 | }); |
| 281 | this.editorView.focus() | 289 | this.editorView.focus(); |
| 282 | }, | 290 | }, |
| 283 | handleResize() { | 291 | handleResize() { |
| 284 | this.windowWidth = window.innerWidth | 292 | this.windowWidth = window.innerWidth; |
| 285 | }, | 293 | }, |
| 286 | isDarkTheme() { | 294 | isDarkTheme() { |
| 287 | return document.documentElement.classList.contains('dark') | 295 | return document.documentElement.classList.contains("dark"); |
| 288 | }, | 296 | }, |
| 289 | observeTheme() { | 297 | observeTheme() { |
| 290 | if (this.themeObserver) { | 298 | if (this.themeObserver) { |
| 291 | return | 299 | return; |
| 292 | } | 300 | } |
| 293 | this.themeObserver = new MutationObserver(() => { | 301 | this.themeObserver = new MutationObserver(() => { |
| 294 | this.refreshEditorTheme() | 302 | this.refreshEditorTheme(); |
| 295 | }) | 303 | }); |
| 296 | this.themeObserver.observe(document.documentElement, { | 304 | this.themeObserver.observe(document.documentElement, { |
| 297 | attributes: true, | 305 | attributes: true, |
| 298 | attributeFilter: ['class'] | 306 | attributeFilter: ["class"], |
| 299 | }) | 307 | }); |
| 300 | }, | 308 | }, |
| 301 | initEditor(initialCode) { | 309 | initEditor(initialCode) { |
| 302 | if (!this.$refs.codeEditor) { | 310 | if (!this.$refs.codeEditor) { |
| 303 | return | 311 | return; |
| 304 | } | 312 | } |
| 305 | 313 | ||
| 306 | const yuescriptMode = simpleMode({ | 314 | const yuescriptMode = simpleMode({ |
| 307 | start: [ | 315 | start: [ |
| 308 | // Shebang | 316 | // Shebang |
| 309 | { regex: /^#!.*/, token: 'comment' }, | 317 | { regex: /^#!.*/, token: "comment" }, |
| 310 | // Multiline string: [=[...]=] with any number of = | 318 | // Multiline string: [=[...]=] with any number of = |
| 311 | { regex: /\[(=*)\[/, token: 'string', push: 'luaString' }, | 319 | { regex: /\[(=*)\[/, token: "string", push: "luaString" }, |
| 312 | // Block comment: --[[...]] (but not ---) | 320 | // Block comment: --[[...]] (but not ---) |
| 313 | { regex: /--\[\[/, token: 'comment', push: 'commentBlock' }, | 321 | { regex: /--\[\[/, token: "comment", push: "commentBlock" }, |
| 314 | // Line comment: -- (but not ---) | 322 | // Line comment: -- (but not ---) |
| 315 | { regex: /--(?!-).*/, token: 'comment' }, | 323 | { regex: /--(?!-).*/, token: "comment" }, |
| 316 | // Double quoted string with interpolation #{...} | 324 | // Double quoted string with interpolation #{...} |
| 317 | { regex: /"/, token: 'string', push: 'doubleString' }, | 325 | { regex: /"/, token: "string", push: "doubleString" }, |
| 318 | // Single quoted string | 326 | // Single quoted string |
| 319 | { regex: /'/, token: 'string', push: 'singleString' }, | 327 | { regex: /'/, token: "string", push: "singleString" }, |
| 320 | // Tag: ::name:: | 328 | // Tag: ::name:: |
| 321 | { regex: /(::)\s*[a-zA-Z_][a-zA-Z0-9_]*\s*(::)/, token: 'tagName' }, | 329 | { regex: /(::)\s*[a-zA-Z_][a-zA-Z0-9_]*\s*(::)/, token: "tagName" }, |
| 322 | // Class definition: class Name extends Base | 330 | // Class definition: class Name extends Base |
| 323 | { regex: /\bclass\b\s+(@?[a-zA-Z$_][\w.]*)?(?:\s+\bextends\b\s+(@?[a-zA-Z$._][\w.]*))?/, token: 'keyword' }, | 331 | { |
| 332 | regex: | ||
| 333 | /\bclass\b\s+(@?[a-zA-Z$_][\w.]*)?(?:\s+\bextends\b\s+(@?[a-zA-Z$._][\w.]*))?/, | ||
| 334 | token: "keyword", | ||
| 335 | }, | ||
| 324 | // Function definition: name: => or name := => or name(params): => | 336 | // Function definition: name: => or name := => or name(params): => |
| 325 | { regex: /(@?[a-zA-Z$_]\??[\w$:.]*\s*[:=]\s*(?:\([^)]*\))?\s*[=-]>)/, token: 'function' }, | 337 | { |
| 338 | regex: /(@?[a-zA-Z$_]\??[\w$:.]*\s*[:=]\s*(?:\([^)]*\))?\s*[=-]>)/, | ||
| 339 | token: "function", | ||
| 340 | }, | ||
| 326 | // Destructured assignment: { ... } := or { ... } = | 341 | // Destructured assignment: { ... } := or { ... } = |
| 327 | { regex: /\{\s*[^}]*\}\s*[:=]/, token: 'keyword' }, | 342 | { regex: /\{\s*[^}]*\}\s*[:=]/, token: "keyword" }, |
| 328 | // Keywords (must come before operators to catch 'and', 'or', 'in', 'not') | 343 | // Keywords (must come before operators to catch 'and', 'or', 'in', 'not') |
| 329 | { regex: /\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using)\b(?![:\w])/, token: 'keyword' }, | 344 | { |
| 345 | regex: | ||
| 346 | /\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using)\b(?![:\w])/, | ||
| 347 | token: "keyword", | ||
| 348 | }, | ||
| 330 | // Control keywords | 349 | // Control keywords |
| 331 | { regex: /\b(?:if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto)\b(?![:\w])/, token: 'keyword' }, | 350 | { |
| 332 | { regex: /\b(?:or|and|in|not)\b(?![:\w])/, token: 'keyword' }, | 351 | regex: |
| 352 | /\b(?:if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto)\b(?![:\w])/, | ||
| 353 | token: "keyword", | ||
| 354 | }, | ||
| 355 | { regex: /\b(?:or|and|in|not)\b(?![:\w])/, token: "keyword" }, | ||
| 333 | // Boolean and nil | 356 | // Boolean and nil |
| 334 | { regex: /\b(?:true|false|nil)\b(?![:\w])/, token: 'number' }, | 357 | { regex: /\b(?:true|false|nil)\b(?![:\w])/, token: "number" }, |
| 335 | // Invalid: function/end | 358 | // Invalid: function/end |
| 336 | { regex: /\b(?:function|end)\b(?![:\w])/, token: 'invalid' }, | 359 | { regex: /\b(?:function|end)\b(?![:\w])/, token: "invalid" }, |
| 337 | // Invalid: self (deprecated) | 360 | // Invalid: self (deprecated) |
| 338 | { regex: /\bself\b(?![:\w])/, token: 'invalid' }, | 361 | { regex: /\bself\b(?![:\w])/, token: "invalid" }, |
| 339 | // super keyword | 362 | // super keyword |
| 340 | { regex: /\bsuper\b(?![:\w])/, token: 'variable' }, | 363 | { regex: /\bsuper\b(?![:\w])/, token: "variable" }, |
| 341 | // Invalid variables: $$, $@, @@@, standalone $ | 364 | // Invalid variables: $$, $@, @@@, standalone $ |
| 342 | { regex: /\$\$+/, token: 'invalid' }, | 365 | { regex: /\$\$+/, token: "invalid" }, |
| 343 | { regex: /@@@+/, token: 'invalid' }, | 366 | { regex: /@@@+/, token: "invalid" }, |
| 344 | { regex: /\$(?!\w)/, token: 'invalid' }, | 367 | { regex: /\$(?!\w)/, token: "invalid" }, |
| 345 | // Special operators: <mode>, <>, <"string">, <'string'>, <word> (invalid) | 368 | // Special operators: <mode>, <>, <"string">, <'string'>, <word> (invalid) |
| 346 | { regex: /<\b(?:mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\b>/, token: 'constant' }, | 369 | { |
| 347 | { regex: /<>/, token: 'constant' }, | 370 | regex: |
| 348 | { regex: /<"[^"]*">/, token: 'constant' }, | 371 | /<\b(?:mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\b>/, |
| 349 | { regex: /<'[^']*'>/, token: 'constant' }, | 372 | token: "constant", |
| 350 | { regex: /<\w+>/, token: 'invalid' }, | 373 | }, |
| 374 | { regex: /<>/, token: "constant" }, | ||
| 375 | { regex: /<"[^"]*">/, token: "constant" }, | ||
| 376 | { regex: /<'[^']*'>/, token: "constant" }, | ||
| 377 | { regex: /<\w+>/, token: "invalid" }, | ||
| 351 | // Operators (and/or removed since they're keywords, ?? must not match ???) | 378 | // Operators (and/or removed since they're keywords, ?? must not match ???) |
| 352 | { regex: /(\+|\-|\*|\/|%|\^|\/\/|\||\&|>>|<<|\.\.)=?/, token: 'operator' }, | 379 | { |
| 353 | { regex: /\?\?(?!\?)/, token: 'operator' }, | 380 | regex: /(\+|\-|\*|\/|%|\^|\/\/|\||\&|>>|<<|\.\.)=?/, |
| 354 | { regex: /\[\]\s*=/, token: 'operator' }, | 381 | token: "operator", |
| 355 | { regex: /==|~=|!=|>|>=|<|<=/, token: 'operator' }, | 382 | }, |
| 356 | { regex: /#|~|\?|!/, token: 'operator' }, | 383 | { regex: /\?\?(?!\?)/, token: "operator" }, |
| 357 | { regex: /\|>|=|:=|:(?!:)|,|\b_\b/, token: 'operator' }, | 384 | { regex: /\[\]\s*=/, token: "operator" }, |
| 358 | { regex: /\.\.\.(?!\.)/, token: 'constant' }, | 385 | { regex: /==|~=|!=|>|>=|<|<=/, token: "operator" }, |
| 386 | { regex: /#|~|\?|!/, token: "operator" }, | ||
| 387 | { regex: /\|>|=|:=|:(?!:)|,|\b_\b/, token: "operator" }, | ||
| 388 | { regex: /\.\.\.(?!\.)/, token: "constant" }, | ||
| 359 | // Invalid: 4+ dots | 389 | // Invalid: 4+ dots |
| 360 | { regex: /\.{4,}/, token: 'invalid' }, | 390 | { regex: /\.{4,}/, token: "invalid" }, |
| 361 | // Class name (capitalized) - must come after keywords | 391 | // Class name (capitalized) - must come after keywords |
| 362 | { regex: /\b[A-Z]\w*\b/, token: 'typeName' }, | 392 | { regex: /\b[A-Z]\w*\b/, token: "typeName" }, |
| 363 | // Special variables: $variable (preprocessor), @variable (member), @@variable (static) | 393 | // Special variables: $variable (preprocessor), @variable (member), @@variable (static) |
| 364 | { regex: /\$\b[a-zA-Z_]\w*\b/, token: 'variable-2' }, | 394 | { regex: /\$\b[a-zA-Z_]\w*\b/, token: "variable-2" }, |
| 365 | { regex: /@@(?:(?:\b[a-zA-Z_]\w*)?((?:\.|::|\\)\b[a-zA-Z_]\w*\b)*)?/, token: 'variable-2' }, | 395 | { |
| 366 | { regex: /@(?:(?:\b[a-zA-Z_]\w*)?((?:\.|::|\\)\b[a-zA-Z_]\w*\b)*)?/, token: 'variable-2' }, | 396 | regex: /@@(?:(?:\b[a-zA-Z_]\w*)?((?:\.|::|\\)\b[a-zA-Z_]\w*\b)*)?/, |
| 397 | token: "variable-2", | ||
| 398 | }, | ||
| 399 | { | ||
| 400 | regex: /@(?:(?:\b[a-zA-Z_]\w*)?((?:\.|::|\\)\b[a-zA-Z_]\w*\b)*)?/, | ||
| 401 | token: "variable-2", | ||
| 402 | }, | ||
| 367 | // Magic methods: __class, __base, etc. | 403 | // Magic methods: __class, __base, etc. |
| 368 | { regex: /\b__(?:class|base|init|inherited|mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\b/, token: 'function' }, | 404 | { |
| 405 | regex: | ||
| 406 | /\b__(?:class|base|init|inherited|mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\b/, | ||
| 407 | token: "function", | ||
| 408 | }, | ||
| 369 | // Numbers: decimal, hex, with underscores | 409 | // Numbers: decimal, hex, with underscores |
| 370 | { regex: /\b([\d_]+(\.[\d_]+)?|\.[\d_]+)(e[+\-]?[\d_]+)?\b/i, token: 'number' }, | 410 | { |
| 371 | { regex: /\b0x([0-9a-fA-F]([0-9a-fA-F_]*[0-9a-fA-F])?(\.[0-9a-fA-F]([0-9a-fA-F_]*[0-9a-fA-F])?)?|\.[0-9a-fA-F]([0-9a-fA-F_]*[0-9a-fA-F])?)\b/i, token: 'number' }, | 411 | regex: /\b([\d_]+(\.[\d_]+)?|\.[\d_]+)(e[+\-]?[\d_]+)?\b/i, |
| 412 | token: "number", | ||
| 413 | }, | ||
| 414 | { | ||
| 415 | regex: | ||
| 416 | /\b0x([0-9a-fA-F]([0-9a-fA-F_]*[0-9a-fA-F])?(\.[0-9a-fA-F]([0-9a-fA-F_]*[0-9a-fA-F])?)?|\.[0-9a-fA-F]([0-9a-fA-F_]*[0-9a-fA-F])?)\b/i, | ||
| 417 | token: "number", | ||
| 418 | }, | ||
| 372 | // Invalid number | 419 | // Invalid number |
| 373 | { regex: /\b\d(?:\w|\.|:|::|\\)+\b/, token: 'invalid' }, | 420 | { regex: /\b\d(?:\w|\.|:|::|\\)+\b/, token: "invalid" }, |
| 374 | // Built-in constants | 421 | // Built-in constants |
| 375 | { regex: /\b(?:_ENV|_G|_VERSION|arg)\b(?![:\w])/, token: 'constant' }, | 422 | { regex: /\b(?:_ENV|_G|_VERSION|arg)\b(?![:\w])/, token: "constant" }, |
| 376 | // Built-in functions - comprehensive list | 423 | // Built-in functions - comprehensive list |
| 377 | { regex: /\b(?:_G(?:\\.|:|::|\\))*(?:lpeg|lpeglabel)(?:(?:\\.|::|\\)(?:B|C|Carg|Cb|Cc|Cf|Cg|Cmt|Cp|Cs|Ct|P|R|S|T|V|locale|match|pcode|ptree|setmaxstack|type|utfR|version))?\b/, token: 'function' }, | 424 | { |
| 378 | { regex: /\b(?:_G(?:\\.|:|::|\\))*(?:re|relabel)(?:(?:\\.|::|\\)(?:calcline|compile|find|gsub|match|updatelocale))?\b/, token: 'function' }, | 425 | regex: |
| 379 | { regex: /\b(?:_G(?:\\.|:|::|\\))*coroutine(?:(?:\\.|::|\\)(?:close|create|isyieldable|resume|running|status|wrap|yield))?\b/, token: 'function' }, | 426 | /\b(?:_G(?:\\.|:|::|\\))*(?:lpeg|lpeglabel)(?:(?:\\.|::|\\)(?:B|C|Carg|Cb|Cc|Cf|Cg|Cmt|Cp|Cs|Ct|P|R|S|T|V|locale|match|pcode|ptree|setmaxstack|type|utfR|version))?\b/, |
| 380 | { regex: /\b(?:_G(?:\\.|:|::|\\))*debug(?:(?:\\.|::|\\)(?:debug|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|getuservalue|setcstacklimit|sethook|setlocal|setmetatable|setupvalue|setuservalue|traceback|upvalueid|upvaluejoin))?\b/, token: 'function' }, | 427 | token: "function", |
| 381 | { regex: /\b(?:_G(?:\\.|:|::|\\))*io(?:(?:\\.|::|\\)(?:close|flush|input|lines|open|output|popen|read|stderr|stdin|stdout|tmpfile|type|write))?\b/, token: 'function' }, | 428 | }, |
| 382 | { regex: /\b(?:_G(?:\\.|:|::|\\))*math(?:(?:\\.|::|\\)(?:abs|acos|asin|atan|atan2|ceil|cos|cosh|deg|exp|floor|fmod|frexp|huge|ldexp|log|log10|max|maxinteger|min|mininteger|modf|pi|pow|rad|random|randomseed|sin|sinh|sqrt|tan|tanh|tointeger|type|ult))?\b/, token: 'function' }, | 429 | { |
| 383 | { regex: /\b(?:_G(?:\\.|:|::|\\))*os(?:(?:\\.|::|\\)(?:clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname))?\b/, token: 'function' }, | 430 | regex: |
| 384 | { regex: /\b(?:_G(?:\\.|:|::|\\))*package(?:(?:\\.|::|\\)(?:config|cpath|loaded|loadlib|path|preload|searchers|searchpath))?\b/, token: 'function' }, | 431 | /\b(?:_G(?:\\.|:|::|\\))*(?:re|relabel)(?:(?:\\.|::|\\)(?:calcline|compile|find|gsub|match|updatelocale))?\b/, |
| 385 | { regex: /\b(?:_G(?:\\.|:|::|\\))*string(?:(?:\\.|::|\\)(?:byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper))?\b/, token: 'function' }, | 432 | token: "function", |
| 386 | { regex: /\b(?:_G(?:\\.|:|::|\\))*table(?:(?:\\.|::|\\)(?:concat|insert|move|pack|remove|sort|unpack))?\b/, token: 'function' }, | 433 | }, |
| 387 | { regex: /\b(?:_G(?:\\.|:|::|\\))*utf8(?:(?:\\.|::|\\)(?:char|charpattern|codepoint|codes|len|offset))?\b/, token: 'function' }, | 434 | { |
| 388 | { regex: /\b(?:_G(?:\\.|:|::|\\))*yue(?:(?:\\.|::|\\)(?:check|dofile|file_exist|find_modulepath|format|insert_loader|is_ast|loadfile|loadstring|macro_env|options|p|pcall|read_file|to_ast|to_lua|traceback|version|yue_compiled))?\b/, token: 'function' }, | 435 | regex: |
| 389 | { regex: /\b(?:_G(?:\\.|:|::|\\))*(?:assert|collectgarbage|dofile|error|getmetatable|ipairs|lfs|load|loadfile|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setmetatable|tonumber|tostring|type|warn|xpcall)\b/, token: 'function' }, | 436 | /\b(?:_G(?:\\.|:|::|\\))*coroutine(?:(?:\\.|::|\\)(?:close|create|isyieldable|resume|running|status|wrap|yield))?\b/, |
| 437 | token: "function", | ||
| 438 | }, | ||
| 439 | { | ||
| 440 | regex: | ||
| 441 | /\b(?:_G(?:\\.|:|::|\\))*debug(?:(?:\\.|::|\\)(?:debug|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|getuservalue|setcstacklimit|sethook|setlocal|setmetatable|setupvalue|setuservalue|traceback|upvalueid|upvaluejoin))?\b/, | ||
| 442 | token: "function", | ||
| 443 | }, | ||
| 444 | { | ||
| 445 | regex: | ||
| 446 | /\b(?:_G(?:\\.|:|::|\\))*io(?:(?:\\.|::|\\)(?:close|flush|input|lines|open|output|popen|read|stderr|stdin|stdout|tmpfile|type|write))?\b/, | ||
| 447 | token: "function", | ||
| 448 | }, | ||
| 449 | { | ||
| 450 | regex: | ||
| 451 | /\b(?:_G(?:\\.|:|::|\\))*math(?:(?:\\.|::|\\)(?:abs|acos|asin|atan|atan2|ceil|cos|cosh|deg|exp|floor|fmod|frexp|huge|ldexp|log|log10|max|maxinteger|min|mininteger|modf|pi|pow|rad|random|randomseed|sin|sinh|sqrt|tan|tanh|tointeger|type|ult))?\b/, | ||
| 452 | token: "function", | ||
| 453 | }, | ||
| 454 | { | ||
| 455 | regex: | ||
| 456 | /\b(?:_G(?:\\.|:|::|\\))*os(?:(?:\\.|::|\\)(?:clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname))?\b/, | ||
| 457 | token: "function", | ||
| 458 | }, | ||
| 459 | { | ||
| 460 | regex: | ||
| 461 | /\b(?:_G(?:\\.|:|::|\\))*package(?:(?:\\.|::|\\)(?:config|cpath|loaded|loadlib|path|preload|searchers|searchpath))?\b/, | ||
| 462 | token: "function", | ||
| 463 | }, | ||
| 464 | { | ||
| 465 | regex: | ||
| 466 | /\b(?:_G(?:\\.|:|::|\\))*string(?:(?:\\.|::|\\)(?:byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper))?\b/, | ||
| 467 | token: "function", | ||
| 468 | }, | ||
| 469 | { | ||
| 470 | regex: | ||
| 471 | /\b(?:_G(?:\\.|:|::|\\))*table(?:(?:\\.|::|\\)(?:concat|insert|move|pack|remove|sort|unpack))?\b/, | ||
| 472 | token: "function", | ||
| 473 | }, | ||
| 474 | { | ||
| 475 | regex: | ||
| 476 | /\b(?:_G(?:\\.|:|::|\\))*utf8(?:(?:\\.|::|\\)(?:char|charpattern|codepoint|codes|len|offset))?\b/, | ||
| 477 | token: "function", | ||
| 478 | }, | ||
| 479 | { | ||
| 480 | regex: | ||
| 481 | /\b(?:_G(?:\\.|:|::|\\))*yue(?:(?:\\.|::|\\)(?:check|dofile|file_exist|find_modulepath|format|insert_loader|is_ast|loadfile|loadstring|macro_env|options|p|pcall|read_file|to_ast|to_lua|traceback|version|yue_compiled))?\b/, | ||
| 482 | token: "function", | ||
| 483 | }, | ||
| 484 | { | ||
| 485 | regex: | ||
| 486 | /\b(?:_G(?:\\.|:|::|\\))*(?:assert|collectgarbage|dofile|error|getmetatable|ipairs|lfs|load|loadfile|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setmetatable|tonumber|tostring|type|warn|xpcall)\b/, | ||
| 487 | token: "function", | ||
| 488 | }, | ||
| 390 | // pl.* library functions (penlight) | 489 | // pl.* library functions (penlight) |
| 391 | { regex: /\b(?:_G(?:\\.|:|::|\\))*pl\.(?:Date|List|Map|MultiMap|OrderedMap|Set|app|array2d|class|compat|comprehension|config|data|dir|file|func|input|lapp|lexer|luabalanced|operator|path|permute|pretty|seq|sip|strict|stringio|stringx|tablex|template|test|text|types|url|utils|xml)(?:(?:\\.|::|\\)\w+)?\b/, token: 'function' }, | 490 | { |
| 491 | regex: | ||
| 492 | /\b(?:_G(?:\\.|:|::|\\))*pl\.(?:Date|List|Map|MultiMap|OrderedMap|Set|app|array2d|class|compat|comprehension|config|data|dir|file|func|input|lapp|lexer|luabalanced|operator|path|permute|pretty|seq|sip|strict|stringio|stringx|tablex|template|test|text|types|url|utils|xml)(?:(?:\\.|::|\\)\w+)?\b/, | ||
| 493 | token: "function", | ||
| 494 | }, | ||
| 392 | // Arrow functions: (params) => or <= name | 495 | // Arrow functions: (params) => or <= name |
| 393 | { regex: /\([^)]*\)\s*[=-]>/, token: 'operator' }, | 496 | { regex: /\([^)]*\)\s*[=-]>/, token: "operator" }, |
| 394 | { regex: /\([^)]*\)?\s*<[=-]\s*(?=[a-zA-Z_])/, token: 'operator' }, | 497 | { regex: /\([^)]*\)?\s*<[=-]\s*(?=[a-zA-Z_])/, token: "operator" }, |
| 395 | // new keyword before arrow function | 498 | // new keyword before arrow function |
| 396 | { regex: /\bnew\b(?=:\s*\([^)]*\)?\s*[=-]>)/, token: 'variable' }, | 499 | { regex: /\bnew\b(?=:\s*\([^)]*\)?\s*[=-]>)/, token: "variable" }, |
| 397 | // Brackets and delimiters | 500 | // Brackets and delimiters |
| 398 | { regex: /[()\[\]{}]/, token: 'bracket' }, | 501 | { regex: /[()\[\]{}]/, token: "bracket" }, |
| 399 | { regex: /\.|::|\\/, token: 'operator' }, | 502 | { regex: /\.|::|\\/, token: "operator" }, |
| 400 | // Variable names (with dot notation support) | 503 | // Variable names (with dot notation support) |
| 401 | { regex: /[a-zA-Z_$][\w$]*(?:(?:\.|::|\\)[a-zA-Z_$][\w$]*)*/, token: 'variable' } | 504 | { |
| 505 | regex: /[a-zA-Z_$][\w$]*(?:(?:\.|::|\\)[a-zA-Z_$][\w$]*)*/, | ||
| 506 | token: "variable", | ||
| 507 | }, | ||
| 402 | ], | 508 | ], |
| 403 | commentBlock: [ | 509 | commentBlock: [ |
| 404 | { regex: /.*?\]\]/, token: 'comment', pop: true }, | 510 | { regex: /.*?\]\]/, token: "comment", pop: true }, |
| 405 | { regex: /@\w*/, token: 'typeName' }, | 511 | { regex: /@\w*/, token: "typeName" }, |
| 406 | { regex: /.*/, token: 'comment' } | 512 | { regex: /.*/, token: "comment" }, |
| 407 | ], | 513 | ], |
| 408 | luaString: [ | 514 | luaString: [ |
| 409 | // Match closing ]=] where number of = matches opening | 515 | // Match closing ]=] where number of = matches opening |
| 410 | // This is a simplified version - matches ]=] with 0 or more = | 516 | // This is a simplified version - matches ]=] with 0 or more = |
| 411 | { regex: /\](=*)\]/, token: 'string', pop: true }, | 517 | { regex: /\](=*)\]/, token: "string", pop: true }, |
| 412 | { regex: /.*/, token: 'string' } | 518 | { regex: /.*/, token: "string" }, |
| 413 | ], | 519 | ], |
| 414 | doubleString: [ | 520 | doubleString: [ |
| 415 | { regex: /"/, token: 'string', pop: true }, | 521 | { regex: /"/, token: "string", pop: true }, |
| 416 | { regex: /\\[abfnrtvz\\'"]/, token: 'constant' }, | 522 | { regex: /\\[abfnrtvz\\'"]/, token: "constant" }, |
| 417 | { regex: /\\\d{1,3}/, token: 'constant' }, | 523 | { regex: /\\\d{1,3}/, token: "constant" }, |
| 418 | { regex: /\\x[0-9a-fA-F]{2}/, token: 'constant' }, | 524 | { regex: /\\x[0-9a-fA-F]{2}/, token: "constant" }, |
| 419 | { regex: /\\u\{[0-9a-fA-F]+\}/, token: 'constant' }, | 525 | { regex: /\\u\{[0-9a-fA-F]+\}/, token: "constant" }, |
| 420 | { regex: /\\\./, token: 'invalid' }, | 526 | { regex: /\\\./, token: "invalid" }, |
| 421 | { regex: /#\{/, token: 'operator', push: 'interpolation' }, | 527 | { regex: /#\{/, token: "operator", push: "interpolation" }, |
| 422 | { regex: /%[%aAcdeEfgiopsuxX]/, token: 'constant' }, | 528 | { regex: /%[%aAcdeEfgiopsuxX]/, token: "constant" }, |
| 423 | { regex: /[^"\\#%]+/, token: 'string' } | 529 | { regex: /[^"\\#%]+/, token: "string" }, |
| 424 | ], | 530 | ], |
| 425 | singleString: [ | 531 | singleString: [ |
| 426 | { regex: /'/, token: 'string', pop: true }, | 532 | { regex: /'/, token: "string", pop: true }, |
| 427 | { regex: /\\[abfnrtvz\\']/, token: 'string' }, | 533 | { regex: /\\[abfnrtvz\\']/, token: "string" }, |
| 428 | { regex: /\\\d{1,3}/, token: 'string' }, | 534 | { regex: /\\\d{1,3}/, token: "string" }, |
| 429 | { regex: /\\x[0-9a-fA-F]{2}/, token: 'string' }, | 535 | { regex: /\\x[0-9a-fA-F]{2}/, token: "string" }, |
| 430 | { regex: /\\u\{[0-9a-fA-F]+\}/, token: 'string' }, | 536 | { regex: /\\u\{[0-9a-fA-F]+\}/, token: "string" }, |
| 431 | { regex: /\\\./, token: 'invalid' }, | 537 | { regex: /\\\./, token: "invalid" }, |
| 432 | { regex: /%[%aAcdeEfgiopsuxX]/, token: 'constant' }, | 538 | { regex: /%[%aAcdeEfgiopsuxX]/, token: "constant" }, |
| 433 | { regex: /[^'\\%]+/, token: 'string' } | 539 | { regex: /[^'\\%]+/, token: "string" }, |
| 434 | ], | 540 | ], |
| 435 | interpolation: [ | 541 | interpolation: [ |
| 436 | { regex: /\}/, token: 'operator', pop: true }, | 542 | { regex: /\}/, token: "operator", pop: true }, |
| 437 | { regex: /\{/, token: 'operator', push: 'interpolation' }, | 543 | { regex: /\{/, token: "operator", push: "interpolation" }, |
| 438 | { regex: /"(?:[^\\"]|\\.)*"?/, token: 'string' }, | 544 | { regex: /"(?:[^\\"]|\\.)*"?/, token: "string" }, |
| 439 | { regex: /'(?:[^\\']|\\.)*'?/, token: 'string' }, | 545 | { regex: /'(?:[^\\']|\\.)*'?/, token: "string" }, |
| 440 | { regex: /\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using|if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto|or|and|in|not|true|false|nil)\b/, token: 'keyword' }, | 546 | { |
| 441 | { regex: /\b[A-Z]\w*\b/, token: 'typeName' }, | 547 | regex: |
| 442 | { regex: /[a-zA-Z_$][\w$]*/, token: 'variable' }, | 548 | /\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using|if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto|or|and|in|not|true|false|nil)\b/, |
| 443 | { regex: /(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/i, token: 'number' }, | 549 | token: "keyword", |
| 444 | { regex: /[+\-/*=<>!]=?|[~^|&%]/, token: 'operator' }, | 550 | }, |
| 445 | { regex: /[()\[\]{}]/, token: 'bracket' }, | 551 | { regex: /\b[A-Z]\w*\b/, token: "typeName" }, |
| 446 | { regex: /[^}]/, token: 'variable' } | 552 | { regex: /[a-zA-Z_$][\w$]*/, token: "variable" }, |
| 553 | { regex: /(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/i, token: "number" }, | ||
| 554 | { regex: /[+\-/*=<>!]=?|[~^|&%]/, token: "operator" }, | ||
| 555 | { regex: /[()\[\]{}]/, token: "bracket" }, | ||
| 556 | { regex: /[^}]/, token: "variable" }, | ||
| 447 | ], | 557 | ], |
| 448 | languageData: { | 558 | languageData: { |
| 449 | name: 'yuescript' | 559 | name: "yuescript", |
| 450 | } | 560 | }, |
| 451 | }) | 561 | }); |
| 452 | 562 | ||
| 453 | this.readOnlyCompartment = new Compartment() | 563 | this.readOnlyCompartment = new Compartment(); |
| 454 | this.themeCompartment = new Compartment() | 564 | this.themeCompartment = new Compartment(); |
| 455 | this.highlightCompartment = new Compartment() | 565 | this.highlightCompartment = new Compartment(); |
| 456 | const updateListener = EditorView.updateListener.of((update) => { | 566 | const updateListener = EditorView.updateListener.of((update) => { |
| 457 | if (!update.docChanged) { | 567 | if (!update.docChanged) { |
| 458 | return | 568 | return; |
| 459 | } | 569 | } |
| 460 | const nextCode = update.state.doc.toString() | 570 | const nextCode = update.state.doc.toString(); |
| 461 | this.code = nextCode | 571 | this.code = nextCode; |
| 462 | this.codeChanged(nextCode) | 572 | this.codeChanged(nextCode); |
| 463 | }) | 573 | }); |
| 464 | 574 | ||
| 465 | const isDark = this.isDarkTheme() | 575 | const isDark = this.isDarkTheme(); |
| 466 | 576 | ||
| 467 | const state = EditorState.create({ | 577 | const state = EditorState.create({ |
| 468 | doc: initialCode, | 578 | doc: initialCode, |
| @@ -471,84 +581,88 @@ export default { | |||
| 471 | history(), | 581 | history(), |
| 472 | keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]), | 582 | keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]), |
| 473 | StreamLanguage.define(yuescriptMode), | 583 | StreamLanguage.define(yuescriptMode), |
| 474 | indentUnit.of(' '), | 584 | indentUnit.of(" "), |
| 475 | this.readOnlyCompartment.of(EditorState.readOnly.of(this.readonly)), | 585 | this.readOnlyCompartment.of(EditorState.readOnly.of(this.readonly)), |
| 476 | this.highlightCompartment.of( | 586 | this.highlightCompartment.of( |
| 477 | syntaxHighlighting( | 587 | syntaxHighlighting( |
| 478 | isDark ? darkPlusHighlightStyle : lightPlusHighlightStyle, | 588 | isDark ? darkPlusHighlightStyle : lightPlusHighlightStyle, |
| 479 | { fallback: true } | 589 | { fallback: true }, |
| 480 | ) | 590 | ), |
| 481 | ), | 591 | ), |
| 482 | updateListener, | 592 | updateListener, |
| 483 | this.themeCompartment.of(isDark ? darkPlusTheme : lightPlusTheme) | 593 | this.themeCompartment.of(isDark ? darkPlusTheme : lightPlusTheme), |
| 484 | ] | 594 | ], |
| 485 | }) | 595 | }); |
| 486 | 596 | ||
| 487 | this.editorView = new EditorView({ | 597 | this.editorView = new EditorView({ |
| 488 | state, | 598 | state, |
| 489 | parent: this.$refs.codeEditor | 599 | parent: this.$refs.codeEditor, |
| 490 | }) | 600 | }); |
| 491 | }, | 601 | }, |
| 492 | refreshEditorTheme() { | 602 | refreshEditorTheme() { |
| 493 | if (!this.editorView || !this.themeCompartment || !this.highlightCompartment) { | 603 | if ( |
| 494 | return | 604 | !this.editorView || |
| 605 | !this.themeCompartment || | ||
| 606 | !this.highlightCompartment | ||
| 607 | ) { | ||
| 608 | return; | ||
| 495 | } | 609 | } |
| 496 | const isDark = this.isDarkTheme() | 610 | const isDark = this.isDarkTheme(); |
| 497 | this.editorView.dispatch({ | 611 | this.editorView.dispatch({ |
| 498 | effects: [ | 612 | effects: [ |
| 499 | this.themeCompartment.reconfigure( | 613 | this.themeCompartment.reconfigure( |
| 500 | isDark ? darkPlusTheme : lightPlusTheme | 614 | isDark ? darkPlusTheme : lightPlusTheme, |
| 501 | ), | 615 | ), |
| 502 | this.highlightCompartment.reconfigure( | 616 | this.highlightCompartment.reconfigure( |
| 503 | syntaxHighlighting( | 617 | syntaxHighlighting( |
| 504 | isDark ? darkPlusHighlightStyle : lightPlusHighlightStyle, | 618 | isDark ? darkPlusHighlightStyle : lightPlusHighlightStyle, |
| 505 | { fallback: true } | 619 | { fallback: true }, |
| 506 | ) | 620 | ), |
| 507 | ) | 621 | ), |
| 508 | ] | 622 | ], |
| 509 | }) | 623 | }); |
| 510 | }, | 624 | }, |
| 511 | refreshEditorReadOnly() { | 625 | refreshEditorReadOnly() { |
| 512 | if (!this.editorView || !this.readOnlyCompartment) { | 626 | if (!this.editorView || !this.readOnlyCompartment) { |
| 513 | return | 627 | return; |
| 514 | } | 628 | } |
| 515 | this.editorView.dispatch({ | 629 | this.editorView.dispatch({ |
| 516 | effects: this.readOnlyCompartment.reconfigure( | 630 | effects: this.readOnlyCompartment.reconfigure( |
| 517 | EditorState.readOnly.of(this.readonly) | 631 | EditorState.readOnly.of(this.readonly), |
| 518 | ) | 632 | ), |
| 519 | }) | 633 | }); |
| 520 | }, | 634 | }, |
| 521 | runCode() { | 635 | runCode() { |
| 522 | if (window.yue && this.compiled !== '') { | 636 | if (window.yue && this.compiled !== "") { |
| 523 | let res = '' | 637 | let res = ""; |
| 524 | try { | 638 | try { |
| 525 | res = window.yue.exec(this.code) | 639 | res = window.yue.exec(this.code); |
| 526 | } catch (err) { | 640 | } catch (err) { |
| 527 | res = err | 641 | res = err; |
| 528 | } | 642 | } |
| 529 | this.result = res | 643 | this.result = res; |
| 530 | } | 644 | } |
| 531 | }, | 645 | }, |
| 532 | codeChanged(text) { | 646 | codeChanged(text) { |
| 533 | if (window.yue) { | 647 | if (window.yue) { |
| 534 | let res = [ | 648 | let res = [ |
| 535 | '', | 649 | "", |
| 536 | 'compiler error, and please help opening an issue for this. Thanks a lot!' | 650 | "compiler error, and please help opening an issue for this. Thanks a lot!", |
| 537 | ] | 651 | ]; |
| 538 | try { | 652 | try { |
| 539 | res = window.yue.tolua(text, true, !this.displayonly, true) | 653 | res = window.yue.tolua(text, true, !this.displayonly, true); |
| 540 | if (res[0] !== '') { | 654 | if (res[0] !== "") { |
| 541 | this.compiled = res[0] | 655 | this.compiled = res[0]; |
| 542 | } else { | 656 | } else { |
| 543 | this.compiled = res[1] | 657 | this.compiled = res[1]; |
| 544 | } | 658 | } |
| 545 | } catch (error) { | 659 | } catch (error) { |
| 546 | this.compiled = res[1] | 660 | this.compiled = res[1]; |
| 547 | } | 661 | } |
| 548 | } | 662 | } |
| 549 | } | 663 | }, |
| 550 | } | 664 | }, |
| 551 | } | 665 | }; |
| 552 | </script> | 666 | </script> |
| 553 | 667 | ||
| 554 | <style scoped> | 668 | <style scoped> |
diff --git a/doc/docs/.vitepress/theme/components/YueDisplay.vue b/doc/docs/.vitepress/theme/components/YueDisplay.vue index 507ace0..b270f21 100755 --- a/doc/docs/.vitepress/theme/components/YueDisplay.vue +++ b/doc/docs/.vitepress/theme/components/YueDisplay.vue | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | <template> | 1 | <template> |
| 2 | <div> | 2 | <div> |
| 3 | <button class="button" @click="compile()">Compile</button> | 3 | <button class="button" @click="compile()">Compile</button> |
| 4 | <div style="display: none;"> | 4 | <div style="display: none"> |
| 5 | <slot></slot> | 5 | <slot></slot> |
| 6 | </div> | 6 | </div> |
| 7 | </div> | 7 | </div> |
| @@ -11,14 +11,16 @@ | |||
| 11 | export default { | 11 | export default { |
| 12 | methods: { | 12 | methods: { |
| 13 | compile() { | 13 | compile() { |
| 14 | const node = this.$el.children[1] | 14 | const node = this.$el.children[1]; |
| 15 | const pre = node.querySelector('pre') | 15 | const pre = node.querySelector("pre"); |
| 16 | const codeNode = pre?.querySelector('code') || pre || node | 16 | const codeNode = pre?.querySelector("code") || pre || node; |
| 17 | const code = (codeNode?.textContent || '').replace(/\r\n?/g, '\n') | 17 | const code = (codeNode?.textContent || "").replace(/\r\n?/g, "\n"); |
| 18 | window.dispatchEvent(new CustomEvent('yue:open-compiler', { detail: code })) | 18 | window.dispatchEvent( |
| 19 | } | 19 | new CustomEvent("yue:open-compiler", { detail: code }), |
| 20 | } | 20 | ); |
| 21 | } | 21 | }, |
| 22 | }, | ||
| 23 | }; | ||
| 22 | </script> | 24 | </script> |
| 23 | 25 | ||
| 24 | <style scoped> | 26 | <style scoped> |
diff --git a/doc/docs/.vitepress/theme/custom.css b/doc/docs/.vitepress/theme/custom.css index 3cf51d7..493069e 100644 --- a/doc/docs/.vitepress/theme/custom.css +++ b/doc/docs/.vitepress/theme/custom.css | |||
| @@ -1,19 +1,21 @@ | |||
| 1 | @import '@fontsource/merriweather/400.css'; | 1 | @import "@fontsource/merriweather/400.css"; |
| 2 | @import '@fontsource/merriweather/700.css'; | 2 | @import "@fontsource/merriweather/700.css"; |
| 3 | @import '@fontsource/merriweather/900.css'; | 3 | @import "@fontsource/merriweather/900.css"; |
| 4 | @import '@fontsource/merriweather/400-italic.css'; | 4 | @import "@fontsource/merriweather/400-italic.css"; |
| 5 | @import '@fontsource/merriweather/700-italic.css'; | 5 | @import "@fontsource/merriweather/700-italic.css"; |
| 6 | @import '@fontsource/merriweather/900-italic.css'; | 6 | @import "@fontsource/merriweather/900-italic.css"; |
| 7 | 7 | ||
| 8 | @import '@fontsource/noto-serif-sc/400.css'; | 8 | @import "@fontsource/noto-serif-sc/400.css"; |
| 9 | @import '@fontsource/noto-serif-sc/700.css'; | 9 | @import "@fontsource/noto-serif-sc/700.css"; |
| 10 | @import '@fontsource/noto-serif-sc/900.css'; | 10 | @import "@fontsource/noto-serif-sc/900.css"; |
| 11 | 11 | ||
| 12 | :root { | 12 | :root { |
| 13 | /* --- TYPOGRAPHY --- */ | 13 | /* --- TYPOGRAPHY --- */ |
| 14 | /* Keep standard sans-serif for body text for readability */ | 14 | /* Keep standard sans-serif for body text for readability */ |
| 15 | --vp-font-family-base: system-ui, sans-serif; | 15 | --vp-font-family-base: system-ui, sans-serif; |
| 16 | --vp-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; | 16 | --vp-font-family-mono: |
| 17 | ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", | ||
| 18 | "Courier New", monospace; | ||
| 17 | 19 | ||
| 18 | /* --- BRAND COLORS (Original Moon Gold) --- */ | 20 | /* --- BRAND COLORS (Original Moon Gold) --- */ |
| 19 | --vp-c-brand-1: #b4ac8f; | 21 | --vp-c-brand-1: #b4ac8f; |
| @@ -27,11 +29,11 @@ | |||
| 27 | 29 | ||
| 28 | /* --- LIGHT MODE THEME --- */ | 30 | /* --- LIGHT MODE THEME --- */ |
| 29 | /* A warmer, "creamy" paper feel instead of harsh white */ | 31 | /* A warmer, "creamy" paper feel instead of harsh white */ |
| 30 | --vp-c-bg: #FDFBF7; | 32 | --vp-c-bg: #fdfbf7; |
| 31 | --vp-c-bg-soft: #F7F5F0; | 33 | --vp-c-bg-soft: #f7f5f0; |
| 34 | |||
| 32 | /* Slightly darker for sidebars */ | 35 | /* Slightly darker for sidebars */ |
| 33 | --vp-c-bg-alt: #F0EDE5; | 36 | --vp-c-bg-alt: #f0ede5; |
| 34 | /* For code blocks/inputs */ | ||
| 35 | 37 | ||
| 36 | /* Text Colors: Deep Navy instead of pure black for softer contrast */ | 38 | /* Text Colors: Deep Navy instead of pure black for softer contrast */ |
| 37 | --vp-c-text-1: #1a202c; | 39 | --vp-c-text-1: #1a202c; |
| @@ -44,6 +46,7 @@ | |||
| 44 | width: 450px !important; | 46 | width: 450px !important; |
| 45 | } | 47 | } |
| 46 | } | 48 | } |
| 49 | |||
| 47 | .VPHero :deep(.image-src) { | 50 | .VPHero :deep(.image-src) { |
| 48 | max-width: 450px; | 51 | max-width: 450px; |
| 49 | max-height: 450px; | 52 | max-height: 450px; |
| @@ -52,20 +55,20 @@ | |||
| 52 | /* --- DARK MODE THEME (Midnight Blue) --- */ | 55 | /* --- DARK MODE THEME (Midnight Blue) --- */ |
| 53 | .dark { | 56 | .dark { |
| 54 | /* Deep Midnight Blue background (replaces standard grey) */ | 57 | /* Deep Midnight Blue background (replaces standard grey) */ |
| 55 | --vp-c-bg: #0B0E14; | 58 | --vp-c-bg: #0b0e14; |
| 56 | --vp-c-bg-soft: #131722; | 59 | --vp-c-bg-soft: #131722; |
| 60 | |||
| 57 | /* Sidebar/Nav */ | 61 | /* Sidebar/Nav */ |
| 58 | --vp-c-bg-alt: #1A1F2E; | 62 | --vp-c-bg-alt: #1a1f2e; |
| 59 | /* Code blocks/inputs */ | ||
| 60 | 63 | ||
| 61 | /* Text Colors: Moonlight Silver */ | 64 | /* Text Colors: Moonlight Silver */ |
| 62 | --vp-c-text-1: #E2E8F0; | 65 | --vp-c-text-1: #e2e8f0; |
| 63 | --vp-c-text-2: #94A3B8; | 66 | --vp-c-text-2: #94a3b8; |
| 64 | 67 | ||
| 65 | /* Adjust border colors to blend with blue, not grey */ | 68 | /* Adjust border colors to blend with blue, not grey */ |
| 66 | --vp-c-border: #1E293B; | 69 | --vp-c-border: #1e293b; |
| 67 | --vp-c-divider: #1E293B; | 70 | --vp-c-divider: #1e293b; |
| 68 | --vp-c-gutter: #1E293B; | 71 | --vp-c-gutter: #1e293b; |
| 69 | } | 72 | } |
| 70 | 73 | ||
| 71 | /* --- HEADINGS: Apply the Serif Font --- */ | 74 | /* --- HEADINGS: Apply the Serif Font --- */ |
| @@ -78,16 +81,19 @@ h6, | |||
| 78 | .VPFeature .title, | 81 | .VPFeature .title, |
| 79 | .VPHero .name, | 82 | .VPHero .name, |
| 80 | .VPNavBarTitle .title { | 83 | .VPNavBarTitle .title { |
| 81 | font-family: 'Merriweather', 'Noto Serif SC', serif !important; | 84 | font-family: "Merriweather", "Noto Serif SC", serif !important; |
| 82 | letter-spacing: -0.02em; | 85 | letter-spacing: -0.02em; |
| 83 | /* Tighter tracking looks more professional on serifs */ | 86 | /* Tighter tracking looks more professional on serifs */ |
| 84 | } | 87 | } |
| 85 | 88 | ||
| 89 | .VPNavBarTitle .title { | ||
| 90 | font-size: 1.125rem; | ||
| 91 | } | ||
| 92 | |||
| 86 | /* Make the Hero Title (YueScript) feel more "Editorial" */ | 93 | /* Make the Hero Title (YueScript) feel more "Editorial" */ |
| 87 | .VPHero .name { | 94 | .VPHero .name { |
| 88 | font-weight: 900 !important; | 95 | font-weight: 900 !important; |
| 89 | color: var(--vp-c-brand-1); | 96 | color: var(--vp-c-brand-1); |
| 90 | /* Optional: Adds a subtle glow in dark mode */ | ||
| 91 | text-shadow: 0 0 20px rgba(180, 172, 143, 0.2); | 97 | text-shadow: 0 0 20px rgba(180, 172, 143, 0.2); |
| 92 | } | 98 | } |
| 93 | 99 | ||
| @@ -103,7 +109,6 @@ h6, | |||
| 103 | background-color: var(--vp-c-brand-1) !important; | 109 | background-color: var(--vp-c-brand-1) !important; |
| 104 | } | 110 | } |
| 105 | 111 | ||
| 106 | |||
| 107 | /* Prism theme for YueCompiler output (shikijs/themes light-plus & dark-plus) */ | 112 | /* Prism theme for YueCompiler output (shikijs/themes light-plus & dark-plus) */ |
| 108 | .code-output, | 113 | .code-output, |
| 109 | .code-output code { | 114 | .code-output code { |
| @@ -124,7 +129,7 @@ h6, | |||
| 124 | } | 129 | } |
| 125 | 130 | ||
| 126 | .code-output .token.keyword { | 131 | .code-output .token.keyword { |
| 127 | color: #AF00DB; | 132 | color: #af00db; |
| 128 | } | 133 | } |
| 129 | 134 | ||
| 130 | .code-output .token.operator, | 135 | .code-output .token.operator, |
| @@ -171,7 +176,7 @@ h6, | |||
| 171 | } | 176 | } |
| 172 | 177 | ||
| 173 | .dark .code-output .token.keyword { | 178 | .dark .code-output .token.keyword { |
| 174 | color: #C586C0; | 179 | color: #c586c0; |
| 175 | } | 180 | } |
| 176 | 181 | ||
| 177 | .dark .code-output .token.operator, | 182 | .dark .code-output .token.operator, |
| @@ -215,5 +220,5 @@ h6, | |||
| 215 | /* --- CODE BLOCKS --- */ | 220 | /* --- CODE BLOCKS --- */ |
| 216 | /* Slight adjustment to code block background to fit the midnight theme */ | 221 | /* Slight adjustment to code block background to fit the midnight theme */ |
| 217 | .dark .vp-code-group .tabs label { | 222 | .dark .vp-code-group .tabs label { |
| 218 | background-color: #1A1F2E; | 223 | background-color: #1a1f2e; |
| 219 | } \ No newline at end of file | 224 | } |
diff --git a/doc/docs/.vitepress/theme/index.ts b/doc/docs/.vitepress/theme/index.ts index 0ee45fe..70145d5 100644 --- a/doc/docs/.vitepress/theme/index.ts +++ b/doc/docs/.vitepress/theme/index.ts | |||
| @@ -1,28 +1,28 @@ | |||
| 1 | import DefaultTheme from 'vitepress/theme' | 1 | import DefaultTheme from "vitepress/theme"; |
| 2 | import type { Theme } from 'vitepress' | 2 | import type { Theme } from "vitepress"; |
| 3 | import { h } from 'vue' | 3 | import { h } from "vue"; |
| 4 | import './custom.css' | 4 | import "./custom.css"; |
| 5 | 5 | ||
| 6 | // @ts-ignore | 6 | // @ts-ignore |
| 7 | import CompilerModal from './components/CompilerModal.vue' | 7 | import CompilerModal from "./components/CompilerModal.vue"; |
| 8 | // @ts-ignore | 8 | // @ts-ignore |
| 9 | import HomeFooter from './components/HomeFooter.vue' | 9 | import HomeFooter from "./components/HomeFooter.vue"; |
| 10 | // @ts-ignore | 10 | // @ts-ignore |
| 11 | import YueCompiler from './components/YueCompiler.vue' | 11 | import YueCompiler from "./components/YueCompiler.vue"; |
| 12 | // @ts-ignore | 12 | // @ts-ignore |
| 13 | import YueDisplay from './components/YueDisplay.vue' | 13 | import YueDisplay from "./components/YueDisplay.vue"; |
| 14 | 14 | ||
| 15 | const theme: Theme = { | 15 | const theme: Theme = { |
| 16 | extends: DefaultTheme, | 16 | extends: DefaultTheme, |
| 17 | Layout: () => | 17 | Layout: () => |
| 18 | h(DefaultTheme.Layout, null, { | 18 | h(DefaultTheme.Layout, null, { |
| 19 | 'layout-bottom': () => [h(HomeFooter), h(CompilerModal)] | 19 | "layout-bottom": () => [h(HomeFooter), h(CompilerModal)], |
| 20 | }), | 20 | }), |
| 21 | enhanceApp({ app }) { | 21 | enhanceApp({ app }) { |
| 22 | app.component('CompilerModal', CompilerModal) | 22 | app.component("CompilerModal", CompilerModal); |
| 23 | app.component('YueCompiler', YueCompiler) | 23 | app.component("YueCompiler", YueCompiler); |
| 24 | app.component('YueDisplay', YueDisplay) | 24 | app.component("YueDisplay", YueDisplay); |
| 25 | } | 25 | }, |
| 26 | } | 26 | }; |
| 27 | 27 | ||
| 28 | export default theme | 28 | export default theme; |
diff --git a/doc/docs/de/doc/advanced/do.md b/doc/docs/de/doc/advanced/do.md index 6f81f9d..265a5ba 100644 --- a/doc/docs/de/doc/advanced/do.md +++ b/doc/docs/de/doc/advanced/do.md | |||
| @@ -8,6 +8,7 @@ do | |||
| 8 | print var | 8 | print var |
| 9 | print var -- nil hier | 9 | print var -- nil hier |
| 10 | ``` | 10 | ``` |
| 11 | |||
| 11 | <YueDisplay> | 12 | <YueDisplay> |
| 12 | 13 | ||
| 13 | ```yue | 14 | ```yue |
| @@ -31,6 +32,7 @@ counter = do | |||
| 31 | print counter! | 32 | print counter! |
| 32 | print counter! | 33 | print counter! |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -53,6 +55,7 @@ tbl = { | |||
| 53 | 1234 | 55 | 1234 |
| 54 | } | 56 | } |
| 55 | ``` | 57 | ``` |
| 58 | |||
| 56 | <YueDisplay> | 59 | <YueDisplay> |
| 57 | 60 | ||
| 58 | ```yue | 61 | ```yue |
diff --git a/doc/docs/de/doc/advanced/line-decorators.md b/doc/docs/de/doc/advanced/line-decorators.md index dd26925..dbeaeb5 100644 --- a/doc/docs/de/doc/advanced/line-decorators.md +++ b/doc/docs/de/doc/advanced/line-decorators.md | |||
| @@ -5,6 +5,7 @@ Zur Vereinfachung können `for`-Schleifen und `if`-Anweisungen auf einzelne Anwe | |||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | print "Hallo Welt" if name == "Rob" | 6 | print "Hallo Welt" if name == "Rob" |
| 7 | ``` | 7 | ``` |
| 8 | |||
| 8 | <YueDisplay> | 9 | <YueDisplay> |
| 9 | 10 | ||
| 10 | ```yue | 11 | ```yue |
| @@ -18,6 +19,7 @@ Und mit einfachen Schleifen: | |||
| 18 | ```yuescript | 19 | ```yuescript |
| 19 | print "Element: ", item for item in *items | 20 | print "Element: ", item for item in *items |
| 20 | ``` | 21 | ``` |
| 22 | |||
| 21 | <YueDisplay> | 23 | <YueDisplay> |
| 22 | 24 | ||
| 23 | ```yue | 25 | ```yue |
| @@ -33,6 +35,7 @@ game\update! while game\isRunning! | |||
| 33 | 35 | ||
| 34 | reader\parse_line! until reader\eof! | 36 | reader\parse_line! until reader\eof! |
| 35 | ``` | 37 | ``` |
| 38 | |||
| 36 | <YueDisplay> | 39 | <YueDisplay> |
| 37 | 40 | ||
| 38 | ```yue | 41 | ```yue |
diff --git a/doc/docs/de/doc/advanced/macro.md b/doc/docs/de/doc/advanced/macro.md index a3e155a..a030aea 100644 --- a/doc/docs/de/doc/advanced/macro.md +++ b/doc/docs/de/doc/advanced/macro.md | |||
| @@ -32,6 +32,7 @@ macro and = (...) -> "#{ table.concat {...}, ' and ' }" | |||
| 32 | if $and f1!, f2!, f3! | 32 | if $and f1!, f2!, f3! |
| 33 | print "OK" | 33 | print "OK" |
| 34 | ``` | 34 | ``` |
| 35 | |||
| 35 | <YueDisplay> | 36 | <YueDisplay> |
| 36 | 37 | ||
| 37 | ```yue | 38 | ```yue |
| @@ -94,6 +95,7 @@ if cond then | |||
| 94 | end | 95 | end |
| 95 | ]==] | 96 | ]==] |
| 96 | ``` | 97 | ``` |
| 98 | |||
| 97 | <YueDisplay> | 99 | <YueDisplay> |
| 98 | 100 | ||
| 99 | ```yue | 101 | ```yue |
| @@ -142,6 +144,7 @@ import "utils" as { | |||
| 142 | } | 144 | } |
| 143 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ | 145 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ |
| 144 | ``` | 146 | ``` |
| 147 | |||
| 145 | <YueDisplay> | 148 | <YueDisplay> |
| 146 | 149 | ||
| 147 | ```yue | 150 | ```yue |
| @@ -172,6 +175,7 @@ Es gibt einige eingebaute Makros, aber du kannst sie überschreiben, indem du Ma | |||
| 172 | print $FILE -- String des aktuellen Modulnamens | 175 | print $FILE -- String des aktuellen Modulnamens |
| 173 | print $LINE -- gibt 2 aus | 176 | print $LINE -- gibt 2 aus |
| 174 | ``` | 177 | ``` |
| 178 | |||
| 175 | <YueDisplay> | 179 | <YueDisplay> |
| 176 | 180 | ||
| 177 | ```yue | 181 | ```yue |
| @@ -238,6 +242,7 @@ macro printNumAndStr = (num `Num, str `String) -> | | |||
| 238 | 242 | ||
| 239 | $printNumAndStr 123, "hallo" | 243 | $printNumAndStr 123, "hallo" |
| 240 | ``` | 244 | ``` |
| 245 | |||
| 241 | <YueDisplay> | 246 | <YueDisplay> |
| 242 | 247 | ||
| 243 | ```yue | 248 | ```yue |
| @@ -262,6 +267,7 @@ macro printNumAndStr = (num, str) -> | |||
| 262 | 267 | ||
| 263 | $printNumAndStr 123, "hallo" | 268 | $printNumAndStr 123, "hallo" |
| 264 | ``` | 269 | ``` |
| 270 | |||
| 265 | <YueDisplay> | 271 | <YueDisplay> |
| 266 | 272 | ||
| 267 | ```yue | 273 | ```yue |
diff --git a/doc/docs/de/doc/advanced/module.md b/doc/docs/de/doc/advanced/module.md index bdc5d86..f20deec 100644 --- a/doc/docs/de/doc/advanced/module.md +++ b/doc/docs/de/doc/advanced/module.md | |||
| @@ -28,6 +28,7 @@ do | |||
| 28 | import "lpeg" as :C, :Ct, :Cmt | 28 | import "lpeg" as :C, :Ct, :Cmt |
| 29 | import "export" as {one, two, Something:{umm:{ch}}} | 29 | import "export" as {one, two, Something:{umm:{ch}}} |
| 30 | ``` | 30 | ``` |
| 31 | |||
| 31 | <YueDisplay> | 32 | <YueDisplay> |
| 32 | 33 | ||
| 33 | ```yue | 34 | ```yue |
| @@ -67,6 +68,7 @@ do | |||
| 67 | import table.concat | 68 | import table.concat |
| 68 | print concat ["a", tostring 1] | 69 | print concat ["a", tostring 1] |
| 69 | ``` | 70 | ``` |
| 71 | |||
| 70 | <YueDisplay> | 72 | <YueDisplay> |
| 71 | 73 | ||
| 72 | ```yue | 74 | ```yue |
| @@ -98,6 +100,7 @@ do | |||
| 98 | print FLAG | 100 | print FLAG |
| 99 | FLAG = 123 | 101 | FLAG = 123 |
| 100 | ``` | 102 | ``` |
| 103 | |||
| 101 | <YueDisplay> | 104 | <YueDisplay> |
| 102 | 105 | ||
| 103 | ```yue | 106 | ```yue |
| @@ -140,6 +143,7 @@ export y = -> | |||
| 140 | export class Something | 143 | export class Something |
| 141 | umm: "cool" | 144 | umm: "cool" |
| 142 | ``` | 145 | ``` |
| 146 | |||
| 143 | <YueDisplay> | 147 | <YueDisplay> |
| 144 | 148 | ||
| 145 | ```yue | 149 | ```yue |
| @@ -166,6 +170,7 @@ Benannter Export mit Destructuring. | |||
| 166 | export :loadstring, to_lua: tolua = yue | 170 | export :loadstring, to_lua: tolua = yue |
| 167 | export {itemA: {:fieldA = 'default'}} = tb | 171 | export {itemA: {:fieldA = 'default'}} = tb |
| 168 | ``` | 172 | ``` |
| 173 | |||
| 169 | <YueDisplay> | 174 | <YueDisplay> |
| 170 | 175 | ||
| 171 | ```yue | 176 | ```yue |
| @@ -182,6 +187,7 @@ export.itemA = tb | |||
| 182 | export.<index> = items | 187 | export.<index> = items |
| 183 | export["a-b-c"] = 123 | 188 | export["a-b-c"] = 123 |
| 184 | ``` | 189 | ``` |
| 190 | |||
| 185 | <YueDisplay> | 191 | <YueDisplay> |
| 186 | 192 | ||
| 187 | ```yue | 193 | ```yue |
| @@ -208,6 +214,7 @@ else | |||
| 208 | export with tmp | 214 | export with tmp |
| 209 | j = 2000 | 215 | j = 2000 |
| 210 | ``` | 216 | ``` |
| 217 | |||
| 211 | <YueDisplay> | 218 | <YueDisplay> |
| 212 | 219 | ||
| 213 | ```yue | 220 | ```yue |
| @@ -234,6 +241,7 @@ export default -> | |||
| 234 | print "hallo" | 241 | print "hallo" |
| 235 | 123 | 242 | 123 |
| 236 | ``` | 243 | ``` |
| 244 | |||
| 237 | <YueDisplay> | 245 | <YueDisplay> |
| 238 | 246 | ||
| 239 | ```yue | 247 | ```yue |
diff --git a/doc/docs/de/doc/advanced/try.md b/doc/docs/de/doc/advanced/try.md index 4550e92..2505967 100644 --- a/doc/docs/de/doc/advanced/try.md +++ b/doc/docs/de/doc/advanced/try.md | |||
| @@ -29,6 +29,7 @@ catch err | |||
| 29 | print yue.traceback err | 29 | print yue.traceback err |
| 30 | print result | 30 | print result |
| 31 | ``` | 31 | ``` |
| 32 | |||
| 32 | <YueDisplay> | 33 | <YueDisplay> |
| 33 | 34 | ||
| 34 | ```yue | 35 | ```yue |
| @@ -82,6 +83,7 @@ catch e | |||
| 82 | print e | 83 | print e |
| 83 | e | 84 | e |
| 84 | ``` | 85 | ``` |
| 86 | |||
| 85 | <YueDisplay> | 87 | <YueDisplay> |
| 86 | 88 | ||
| 87 | ```yue | 89 | ```yue |
diff --git a/doc/docs/de/doc/assignment/assignment.md b/doc/docs/de/doc/assignment/assignment.md index b74501f..ed56e46 100644 --- a/doc/docs/de/doc/assignment/assignment.md +++ b/doc/docs/de/doc/assignment/assignment.md | |||
| @@ -7,6 +7,7 @@ hello = "world" | |||
| 7 | a, b, c = 1, 2, 3 | 7 | a, b, c = 1, 2, 3 |
| 8 | hello = 123 -- nutzt die bestehende Variable | 8 | hello = 123 -- nutzt die bestehende Variable |
| 9 | ``` | 9 | ``` |
| 10 | |||
| 10 | <YueDisplay> | 11 | <YueDisplay> |
| 11 | 12 | ||
| 12 | ```yue | 13 | ```yue |
| @@ -31,6 +32,7 @@ x %= 10 | |||
| 31 | s ..= "world" -- legt eine neue lokale Variable an, wenn sie nicht existiert | 32 | s ..= "world" -- legt eine neue lokale Variable an, wenn sie nicht existiert |
| 32 | arg or= "default value" | 33 | arg or= "default value" |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -54,6 +56,7 @@ Mit verketteten Zuweisungen kannst du mehrere Variablen auf denselben Wert setze | |||
| 54 | a = b = c = d = e = 0 | 56 | a = b = c = d = e = 0 |
| 55 | x = y = z = f! | 57 | x = y = z = f! |
| 56 | ``` | 58 | ``` |
| 59 | |||
| 57 | <YueDisplay> | 60 | <YueDisplay> |
| 58 | 61 | ||
| 59 | ```yue | 62 | ```yue |
| @@ -81,6 +84,7 @@ do | |||
| 81 | a = 1 | 84 | a = 1 |
| 82 | B = 2 | 85 | B = 2 |
| 83 | ``` | 86 | ``` |
| 87 | |||
| 84 | <YueDisplay> | 88 | <YueDisplay> |
| 85 | 89 | ||
| 86 | ```yue | 90 | ```yue |
| @@ -120,6 +124,7 @@ do | |||
| 120 | B = 2 | 124 | B = 2 |
| 121 | local Temp = "a local value" | 125 | local Temp = "a local value" |
| 122 | ``` | 126 | ``` |
| 127 | |||
| 123 | <YueDisplay> | 128 | <YueDisplay> |
| 124 | 129 | ||
| 125 | ```yue | 130 | ```yue |
diff --git a/doc/docs/de/doc/assignment/destructuring-assignment.md b/doc/docs/de/doc/assignment/destructuring-assignment.md index 0a08e22..5582468 100644 --- a/doc/docs/de/doc/assignment/destructuring-assignment.md +++ b/doc/docs/de/doc/assignment/destructuring-assignment.md | |||
| @@ -12,6 +12,7 @@ thing = [1, 2] | |||
| 12 | [a, b] = thing | 12 | [a, b] = thing |
| 13 | print a, b | 13 | print a, b |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -37,6 +38,7 @@ print hello, the_day | |||
| 37 | 38 | ||
| 38 | :day = obj -- einfache Destructuring-Zuweisung ohne Klammern ist ok | 39 | :day = obj -- einfache Destructuring-Zuweisung ohne Klammern ist ok |
| 39 | ``` | 40 | ``` |
| 41 | |||
| 40 | <YueDisplay> | 42 | <YueDisplay> |
| 41 | 43 | ||
| 42 | ```yue | 44 | ```yue |
| @@ -68,6 +70,7 @@ obj2 = { | |||
| 68 | {numbers: [first, second], properties: {color: color}} = obj2 | 70 | {numbers: [first, second], properties: {color: color}} = obj2 |
| 69 | print first, second, color | 71 | print first, second, color |
| 70 | ``` | 72 | ``` |
| 73 | |||
| 71 | <YueDisplay> | 74 | <YueDisplay> |
| 72 | 75 | ||
| 73 | ```yue | 76 | ```yue |
| @@ -95,6 +98,7 @@ Wenn die Destructuring-Anweisung kompliziert ist, kannst du sie gerne auf mehrer | |||
| 95 | } | 98 | } |
| 96 | } = obj2 | 99 | } = obj2 |
| 97 | ``` | 100 | ``` |
| 101 | |||
| 98 | <YueDisplay> | 102 | <YueDisplay> |
| 99 | 103 | ||
| 100 | ```yue | 104 | ```yue |
| @@ -113,6 +117,7 @@ Es ist üblich, Werte aus einer Tabelle zu extrahieren und ihnen lokale Variable | |||
| 113 | ```yuescript | 117 | ```yuescript |
| 114 | {:concat, :insert} = table | 118 | {:concat, :insert} = table |
| 115 | ``` | 119 | ``` |
| 120 | |||
| 116 | <YueDisplay> | 121 | <YueDisplay> |
| 117 | 122 | ||
| 118 | ```yue | 123 | ```yue |
| @@ -126,6 +131,7 @@ Das ist effektiv dasselbe wie `import`, aber du kannst Felder umbenennen, indem | |||
| 126 | ```yuescript | 131 | ```yuescript |
| 127 | {:mix, :max, random: rand} = math | 132 | {:mix, :max, random: rand} = math |
| 128 | ``` | 133 | ``` |
| 134 | |||
| 129 | <YueDisplay> | 135 | <YueDisplay> |
| 130 | 136 | ||
| 131 | ```yue | 137 | ```yue |
| @@ -139,6 +145,7 @@ Du kannst Standardwerte beim Destructuring angeben, z. B.: | |||
| 139 | ```yuescript | 145 | ```yuescript |
| 140 | {:name = "namenlos", :job = "arbeitlos"} = person | 146 | {:name = "namenlos", :job = "arbeitlos"} = person |
| 141 | ``` | 147 | ``` |
| 148 | |||
| 142 | <YueDisplay> | 149 | <YueDisplay> |
| 143 | 150 | ||
| 144 | ```yue | 151 | ```yue |
| @@ -152,6 +159,7 @@ Du kannst `_` als Platzhalter verwenden, wenn du eine Listen-Destructuring-Zuwei | |||
| 152 | ```yuescript | 159 | ```yuescript |
| 153 | [_, two, _, four] = items | 160 | [_, two, _, four] = items |
| 154 | ``` | 161 | ``` |
| 162 | |||
| 155 | <YueDisplay> | 163 | <YueDisplay> |
| 156 | 164 | ||
| 157 | ```yue | 165 | ```yue |
| @@ -171,6 +179,7 @@ print first -- gibt aus: erster | |||
| 171 | print bulk -- gibt aus: {"zweiter", "dritter", "vierter"} | 179 | print bulk -- gibt aus: {"zweiter", "dritter", "vierter"} |
| 172 | print last -- gibt aus: letzter | 180 | print last -- gibt aus: letzter |
| 173 | ``` | 181 | ``` |
| 182 | |||
| 174 | <YueDisplay> | 183 | <YueDisplay> |
| 175 | 184 | ||
| 176 | ```yue | 185 | ```yue |
| @@ -195,6 +204,7 @@ Der Spread-Operator kann an unterschiedlichen Positionen verwendet werden, um un | |||
| 195 | -- Alles außer den mittleren Elementen erfassen | 204 | -- Alles außer den mittleren Elementen erfassen |
| 196 | [first, ..._, last] = orders | 205 | [first, ..._, last] = orders |
| 197 | ``` | 206 | ``` |
| 207 | |||
| 198 | <YueDisplay> | 208 | <YueDisplay> |
| 199 | 209 | ||
| 200 | ```yue | 210 | ```yue |
| @@ -223,6 +233,7 @@ tuples = [ | |||
| 223 | for [left, right] in *tuples | 233 | for [left, right] in *tuples |
| 224 | print left, right | 234 | print left, right |
| 225 | ``` | 235 | ``` |
| 236 | |||
| 226 | <YueDisplay> | 237 | <YueDisplay> |
| 227 | 238 | ||
| 228 | ```yue | 239 | ```yue |
diff --git a/doc/docs/de/doc/assignment/if-assignment.md b/doc/docs/de/doc/assignment/if-assignment.md index 884a8d2..21bc8be 100644 --- a/doc/docs/de/doc/assignment/if-assignment.md +++ b/doc/docs/de/doc/assignment/if-assignment.md | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | if user := database.find_user "moon" | 6 | if user := database.find_user "moon" |
| 7 | print user.name | 7 | print user.name |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -23,6 +24,7 @@ elseif world := os.getenv "world" | |||
| 23 | else | 24 | else |
| 24 | print "nichts :(" | 25 | print "nichts :(" |
| 25 | ``` | 26 | ``` |
| 27 | |||
| 26 | <YueDisplay> | 28 | <YueDisplay> |
| 27 | 29 | ||
| 28 | ```yue | 30 | ```yue |
| @@ -43,6 +45,7 @@ if success, result := pcall -> "Ergebnis ohne Probleme erhalten" | |||
| 43 | print result -- Variable result ist im Scope | 45 | print result -- Variable result ist im Scope |
| 44 | print "OK" | 46 | print "OK" |
| 45 | ``` | 47 | ``` |
| 48 | |||
| 46 | <YueDisplay> | 49 | <YueDisplay> |
| 47 | 50 | ||
| 48 | ```yue | 51 | ```yue |
| @@ -62,6 +65,7 @@ while byte := stream\read_one! | |||
| 62 | -- mit dem Byte etwas anfangen | 65 | -- mit dem Byte etwas anfangen |
| 63 | print byte | 66 | print byte |
| 64 | ``` | 67 | ``` |
| 68 | |||
| 65 | <YueDisplay> | 69 | <YueDisplay> |
| 66 | 70 | ||
| 67 | ```yue | 71 | ```yue |
diff --git a/doc/docs/de/doc/assignment/the-using-clause-controlling-destructive-assignment.md b/doc/docs/de/doc/assignment/the-using-clause-controlling-destructive-assignment.md index 63bf016..ce8a45c 100644 --- a/doc/docs/de/doc/assignment/the-using-clause-controlling-destructive-assignment.md +++ b/doc/docs/de/doc/assignment/the-using-clause-controlling-destructive-assignment.md | |||
| @@ -17,6 +17,7 @@ my_func! | |||
| 17 | 17 | ||
| 18 | print i -- wird 0 ausgeben | 18 | print i -- wird 0 ausgeben |
| 19 | ``` | 19 | ``` |
| 20 | |||
| 20 | <YueDisplay> | 21 | <YueDisplay> |
| 21 | 22 | ||
| 22 | ```yue | 23 | ```yue |
| @@ -52,6 +53,7 @@ my_func = (using nil) -> | |||
| 52 | my_func! | 53 | my_func! |
| 53 | print i -- gibt 100 aus, i bleibt unverändert | 54 | print i -- gibt 100 aus, i bleibt unverändert |
| 54 | ``` | 55 | ``` |
| 56 | |||
| 55 | <YueDisplay> | 57 | <YueDisplay> |
| 56 | 58 | ||
| 57 | ```yue | 59 | ```yue |
| @@ -80,6 +82,7 @@ my_func = (add using k, i) -> | |||
| 80 | my_func(22) | 82 | my_func(22) |
| 81 | print i, k -- diese wurden aktualisiert | 83 | print i, k -- diese wurden aktualisiert |
| 82 | ``` | 84 | ``` |
| 85 | |||
| 83 | <YueDisplay> | 86 | <YueDisplay> |
| 84 | 87 | ||
| 85 | ```yue | 88 | ```yue |
diff --git a/doc/docs/de/doc/assignment/varargs-assignment.md b/doc/docs/de/doc/assignment/varargs-assignment.md index b211a8a..96927fa 100644 --- a/doc/docs/de/doc/assignment/varargs-assignment.md +++ b/doc/docs/de/doc/assignment/varargs-assignment.md | |||
| @@ -10,6 +10,7 @@ count = select '#', ... | |||
| 10 | first = select 1, ... | 10 | first = select 1, ... |
| 11 | print ok, count, first | 11 | print ok, count, first |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
diff --git a/doc/docs/de/doc/control-flow/conditionals.md b/doc/docs/de/doc/control-flow/conditionals.md index d20e6e3..56663d1 100644 --- a/doc/docs/de/doc/control-flow/conditionals.md +++ b/doc/docs/de/doc/control-flow/conditionals.md | |||
| @@ -7,6 +7,7 @@ if have_coins | |||
| 7 | else | 7 | else |
| 8 | print "Keine Münzen" | 8 | print "Keine Münzen" |
| 9 | ``` | 9 | ``` |
| 10 | |||
| 10 | <YueDisplay> | 11 | <YueDisplay> |
| 11 | 12 | ||
| 12 | ```yue | 13 | ```yue |
| @@ -25,6 +26,7 @@ Eine Kurzsyntax für einzelne Anweisungen kann ebenfalls verwendet werden: | |||
| 25 | have_coins = false | 26 | have_coins = false |
| 26 | if have_coins then print "Münzen erhalten" else print "Keine Münzen" | 27 | if have_coins then print "Münzen erhalten" else print "Keine Münzen" |
| 27 | ``` | 28 | ``` |
| 29 | |||
| 28 | <YueDisplay> | 30 | <YueDisplay> |
| 29 | 31 | ||
| 30 | ```yue | 32 | ```yue |
| @@ -40,6 +42,7 @@ Da `if`-Anweisungen als Ausdrücke verwendet werden können, kann man das auch s | |||
| 40 | have_coins = false | 42 | have_coins = false |
| 41 | print if have_coins then "Münzen erhalten" else "Keine Münzen" | 43 | print if have_coins then "Münzen erhalten" else "Keine Münzen" |
| 42 | ``` | 44 | ``` |
| 45 | |||
| 43 | <YueDisplay> | 46 | <YueDisplay> |
| 44 | 47 | ||
| 45 | ```yue | 48 | ```yue |
| @@ -65,6 +68,7 @@ else | |||
| 65 | 68 | ||
| 66 | print message -- gibt aus: Ich bin sehr groß | 69 | print message -- gibt aus: Ich bin sehr groß |
| 67 | ``` | 70 | ``` |
| 71 | |||
| 68 | <YueDisplay> | 72 | <YueDisplay> |
| 69 | 73 | ||
| 70 | ```yue | 74 | ```yue |
| @@ -90,6 +94,7 @@ Das Gegenteil von `if` ist `unless`: | |||
| 90 | unless os.date("%A") == "Monday" | 94 | unless os.date("%A") == "Monday" |
| 91 | print "Es ist nicht Montag!" | 95 | print "Es ist nicht Montag!" |
| 92 | ``` | 96 | ``` |
| 97 | |||
| 93 | <YueDisplay> | 98 | <YueDisplay> |
| 94 | 99 | ||
| 95 | ```yue | 100 | ```yue |
| @@ -102,6 +107,7 @@ unless os.date("%A") == "Monday" | |||
| 102 | ```yuescript | 107 | ```yuescript |
| 103 | print "You're lucky!" unless math.random! > 0.1 | 108 | print "You're lucky!" unless math.random! > 0.1 |
| 104 | ``` | 109 | ``` |
| 110 | |||
| 105 | <YueDisplay> | 111 | <YueDisplay> |
| 106 | 112 | ||
| 107 | ```yue | 113 | ```yue |
| @@ -123,6 +129,7 @@ if a in [1, 3, 5, 7] | |||
| 123 | if a in list | 129 | if a in list |
| 124 | print "Prüfen, ob `a` in einer Liste ist" | 130 | print "Prüfen, ob `a` in einer Liste ist" |
| 125 | ``` | 131 | ``` |
| 132 | |||
| 126 | <YueDisplay> | 133 | <YueDisplay> |
| 127 | 134 | ||
| 128 | ```yue | 135 | ```yue |
diff --git a/doc/docs/de/doc/control-flow/continue.md b/doc/docs/de/doc/control-flow/continue.md index a6210d4..4b5ccdc 100644 --- a/doc/docs/de/doc/control-flow/continue.md +++ b/doc/docs/de/doc/control-flow/continue.md | |||
| @@ -9,6 +9,7 @@ while i < 10 | |||
| 9 | continue if i % 2 == 0 | 9 | continue if i % 2 == 0 |
| 10 | print i | 10 | print i |
| 11 | ``` | 11 | ``` |
| 12 | |||
| 12 | <YueDisplay> | 13 | <YueDisplay> |
| 13 | 14 | ||
| 14 | ```yue | 15 | ```yue |
| @@ -29,6 +30,7 @@ odds = for x in *my_numbers | |||
| 29 | continue if x % 2 == 1 | 30 | continue if x % 2 == 1 |
| 30 | x | 31 | x |
| 31 | ``` | 32 | ``` |
| 33 | |||
| 32 | <YueDisplay> | 34 | <YueDisplay> |
| 33 | 35 | ||
| 34 | ```yue | 36 | ```yue |
diff --git a/doc/docs/de/doc/control-flow/for-loop.md b/doc/docs/de/doc/control-flow/for-loop.md index 3bf63d4..827d983 100644 --- a/doc/docs/de/doc/control-flow/for-loop.md +++ b/doc/docs/de/doc/control-flow/for-loop.md | |||
| @@ -12,6 +12,7 @@ for k = 1, 15, 2 -- ein optionaler Schritt | |||
| 12 | for key, value in pairs object | 12 | for key, value in pairs object |
| 13 | print key, value | 13 | print key, value |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -33,6 +34,7 @@ Die Slicing- und **\***-Operatoren können verwendet werden, genau wie bei Compr | |||
| 33 | for item in *items[2, 4] | 34 | for item in *items[2, 4] |
| 34 | print item | 35 | print item |
| 35 | ``` | 36 | ``` |
| 37 | |||
| 36 | <YueDisplay> | 38 | <YueDisplay> |
| 37 | 39 | ||
| 38 | ```yue | 40 | ```yue |
| @@ -49,6 +51,7 @@ for item in *items do print item | |||
| 49 | 51 | ||
| 50 | for j = 1, 10, 3 do print j | 52 | for j = 1, 10, 3 do print j |
| 51 | ``` | 53 | ``` |
| 54 | |||
| 52 | <YueDisplay> | 55 | <YueDisplay> |
| 53 | 56 | ||
| 54 | ```yue | 57 | ```yue |
| @@ -70,6 +73,7 @@ doubled_evens = for i = 1, 20 | |||
| 70 | else | 73 | else |
| 71 | i | 74 | i |
| 72 | ``` | 75 | ``` |
| 76 | |||
| 73 | <YueDisplay> | 77 | <YueDisplay> |
| 74 | 78 | ||
| 75 | ```yue | 79 | ```yue |
| @@ -90,6 +94,7 @@ Beispiel: die erste Zahl größer als 10 finden: | |||
| 90 | first_large = for n in *numbers | 94 | first_large = for n in *numbers |
| 91 | break n if n > 10 | 95 | break n if n > 10 |
| 92 | ``` | 96 | ``` |
| 97 | |||
| 93 | <YueDisplay> | 98 | <YueDisplay> |
| 94 | 99 | ||
| 95 | ```yue | 100 | ```yue |
| @@ -112,6 +117,7 @@ func_b = -> return for i = 1, 10 do i | |||
| 112 | print func_a! -- gibt nil aus | 117 | print func_a! -- gibt nil aus |
| 113 | print func_b! -- gibt Tabellenobjekt aus | 118 | print func_b! -- gibt Tabellenobjekt aus |
| 114 | ``` | 119 | ``` |
| 120 | |||
| 115 | <YueDisplay> | 121 | <YueDisplay> |
| 116 | 122 | ||
| 117 | ```yue | 123 | ```yue |
diff --git a/doc/docs/de/doc/control-flow/switch.md b/doc/docs/de/doc/control-flow/switch.md index 81e08bd..5e5107b 100644 --- a/doc/docs/de/doc/control-flow/switch.md +++ b/doc/docs/de/doc/control-flow/switch.md | |||
| @@ -11,6 +11,7 @@ switch name := "Dan" | |||
| 11 | else | 11 | else |
| 12 | print "Ich kenne dich nicht mit dem Namen #{name}" | 12 | print "Ich kenne dich nicht mit dem Namen #{name}" |
| 13 | ``` | 13 | ``` |
| 14 | |||
| 14 | <YueDisplay> | 15 | <YueDisplay> |
| 15 | 16 | ||
| 16 | ```yue | 17 | ```yue |
| @@ -39,6 +40,7 @@ next_number = switch b | |||
| 39 | else | 40 | else |
| 40 | error "so hoch kann ich nicht zählen!" | 41 | error "so hoch kann ich nicht zählen!" |
| 41 | ``` | 42 | ``` |
| 43 | |||
| 42 | <YueDisplay> | 44 | <YueDisplay> |
| 43 | 45 | ||
| 44 | ```yue | 46 | ```yue |
| @@ -62,6 +64,7 @@ msg = switch math.random(1, 5) | |||
| 62 | when 2 then "Du hast fast Glück" | 64 | when 2 then "Du hast fast Glück" |
| 63 | else "nicht so viel Glück" | 65 | else "nicht so viel Glück" |
| 64 | ``` | 66 | ``` |
| 67 | |||
| 65 | <YueDisplay> | 68 | <YueDisplay> |
| 66 | 69 | ||
| 67 | ```yue | 70 | ```yue |
| @@ -87,6 +90,7 @@ switch math.random(1, 5) when 1 | |||
| 87 | else | 90 | else |
| 88 | print "nicht so viel Glück" | 91 | print "nicht so viel Glück" |
| 89 | ``` | 92 | ``` |
| 93 | |||
| 90 | <YueDisplay> | 94 | <YueDisplay> |
| 91 | 95 | ||
| 92 | ```yue | 96 | ```yue |
| @@ -124,6 +128,7 @@ for item in *items | |||
| 124 | when :width, :height | 128 | when :width, :height |
| 125 | print "Größe #{width}, #{height}" | 129 | print "Größe #{width}, #{height}" |
| 126 | ``` | 130 | ``` |
| 131 | |||
| 127 | <YueDisplay> | 132 | <YueDisplay> |
| 128 | 133 | ||
| 129 | ```yue | 134 | ```yue |
| @@ -154,6 +159,7 @@ switch item | |||
| 154 | when {pos: {:x = 50, :y = 200}} | 159 | when {pos: {:x = 50, :y = 200}} |
| 155 | print "Vec2 #{x}, #{y}" -- Tabellen-Destrukturierung greift trotzdem | 160 | print "Vec2 #{x}, #{y}" -- Tabellen-Destrukturierung greift trotzdem |
| 156 | ``` | 161 | ``` |
| 162 | |||
| 157 | <YueDisplay> | 163 | <YueDisplay> |
| 158 | 164 | ||
| 159 | ```yue | 165 | ```yue |
| @@ -181,6 +187,7 @@ switch tb | |||
| 181 | when [1, 2, b = 3] -- b hat einen Standardwert | 187 | when [1, 2, b = 3] -- b hat einen Standardwert |
| 182 | print "1, 2, #{b}" | 188 | print "1, 2, #{b}" |
| 183 | ``` | 189 | ``` |
| 190 | |||
| 184 | <YueDisplay> | 191 | <YueDisplay> |
| 185 | 192 | ||
| 186 | ```yue | 193 | ```yue |
| @@ -206,6 +213,7 @@ switch tb | |||
| 206 | else | 213 | else |
| 207 | print "ungültig" | 214 | print "ungültig" |
| 208 | ``` | 215 | ``` |
| 216 | |||
| 209 | <YueDisplay> | 217 | <YueDisplay> |
| 210 | 218 | ||
| 211 | ```yue | 219 | ```yue |
| @@ -231,6 +239,7 @@ switch tb | |||
| 231 | else | 239 | else |
| 232 | print "ungültig" | 240 | print "ungültig" |
| 233 | ``` | 241 | ``` |
| 242 | |||
| 234 | <YueDisplay> | 243 | <YueDisplay> |
| 235 | 244 | ||
| 236 | ```yue | 245 | ```yue |
| @@ -257,6 +266,7 @@ switch tb | |||
| 257 | ] | 266 | ] |
| 258 | print "getroffen", fourth | 267 | print "getroffen", fourth |
| 259 | ``` | 268 | ``` |
| 269 | |||
| 260 | <YueDisplay> | 270 | <YueDisplay> |
| 261 | 271 | ||
| 262 | ```yue | 272 | ```yue |
| @@ -282,6 +292,7 @@ switch segments | |||
| 282 | print "Ressource:", resource -- gibt aus: "logs" | 292 | print "Ressource:", resource -- gibt aus: "logs" |
| 283 | print "Aktion:", action -- gibt aus: "view" | 293 | print "Aktion:", action -- gibt aus: "view" |
| 284 | ``` | 294 | ``` |
| 295 | |||
| 285 | <YueDisplay> | 296 | <YueDisplay> |
| 286 | 297 | ||
| 287 | ```yue | 298 | ```yue |
diff --git a/doc/docs/de/doc/control-flow/while-loop.md b/doc/docs/de/doc/control-flow/while-loop.md index a875bf9..6d9f089 100644 --- a/doc/docs/de/doc/control-flow/while-loop.md +++ b/doc/docs/de/doc/control-flow/while-loop.md | |||
| @@ -10,6 +10,7 @@ while i > 0 | |||
| 10 | 10 | ||
| 11 | while running == true do my_function! | 11 | while running == true do my_function! |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
| @@ -31,6 +32,7 @@ until i == 0 | |||
| 31 | 32 | ||
| 32 | until running == false do my_function! | 33 | until running == false do my_function! |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -56,6 +58,7 @@ repeat | |||
| 56 | i -= 1 | 58 | i -= 1 |
| 57 | until i == 0 | 59 | until i == 0 |
| 58 | ``` | 60 | ``` |
| 61 | |||
| 59 | <YueDisplay> | 62 | <YueDisplay> |
| 60 | 63 | ||
| 61 | ```yue | 64 | ```yue |
diff --git a/doc/docs/de/doc/data-structures/comprehensions.md b/doc/docs/de/doc/data-structures/comprehensions.md index 7e00c57..4d74e06 100644 --- a/doc/docs/de/doc/data-structures/comprehensions.md +++ b/doc/docs/de/doc/data-structures/comprehensions.md | |||
| @@ -10,6 +10,7 @@ Das folgende Beispiel erstellt eine Kopie der `items`-Tabelle, aber mit verdoppe | |||
| 10 | items = [ 1, 2, 3, 4 ] | 10 | items = [ 1, 2, 3, 4 ] |
| 11 | doubled = [item * 2 for i, item in ipairs items] | 11 | doubled = [item * 2 for i, item in ipairs items] |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
| @@ -24,6 +25,7 @@ Die Elemente in der neuen Tabelle können mit einer `when`-Klausel eingeschränk | |||
| 24 | ```yuescript | 25 | ```yuescript |
| 25 | slice = [item for i, item in ipairs items when i > 1 and i < 3] | 26 | slice = [item for i, item in ipairs items when i > 1 and i < 3] |
| 26 | ``` | 27 | ``` |
| 28 | |||
| 27 | <YueDisplay> | 29 | <YueDisplay> |
| 28 | 30 | ||
| 29 | ```yue | 31 | ```yue |
| @@ -37,6 +39,7 @@ Da es üblich ist, über die Werte einer numerisch indizierten Tabelle zu iterie | |||
| 37 | ```yuescript | 39 | ```yuescript |
| 38 | doubled = [item * 2 for item in *items] | 40 | doubled = [item * 2 for item in *items] |
| 39 | ``` | 41 | ``` |
| 42 | |||
| 40 | <YueDisplay> | 43 | <YueDisplay> |
| 41 | 44 | ||
| 42 | ```yue | 45 | ```yue |
| @@ -55,6 +58,7 @@ data = | |||
| 55 | flat = [...v for k,v in pairs data] | 58 | flat = [...v for k,v in pairs data] |
| 56 | -- flat ist jetzt [1, 2, 3, 4, 5, 6] | 59 | -- flat ist jetzt [1, 2, 3, 4, 5, 6] |
| 57 | ``` | 60 | ``` |
| 61 | |||
| 58 | <YueDisplay> | 62 | <YueDisplay> |
| 59 | 63 | ||
| 60 | ```yue | 64 | ```yue |
| @@ -79,6 +83,7 @@ y_coords = [9, 2, 3] | |||
| 79 | points = [ [x, y] for x in *x_coords \ | 83 | points = [ [x, y] for x in *x_coords \ |
| 80 | for y in *y_coords] | 84 | for y in *y_coords] |
| 81 | ``` | 85 | ``` |
| 86 | |||
| 82 | <YueDisplay> | 87 | <YueDisplay> |
| 83 | 88 | ||
| 84 | ```yue | 89 | ```yue |
| @@ -96,6 +101,7 @@ Numerische `for`-Schleifen können ebenfalls in Comprehensions verwendet werden: | |||
| 96 | ```yuescript | 101 | ```yuescript |
| 97 | evens = [i for i = 1, 100 when i % 2 == 0] | 102 | evens = [i for i = 1, 100 when i % 2 == 0] |
| 98 | ``` | 103 | ``` |
| 104 | |||
| 99 | <YueDisplay> | 105 | <YueDisplay> |
| 100 | 106 | ||
| 101 | ```yue | 107 | ```yue |
| @@ -119,6 +125,7 @@ thing = { | |||
| 119 | 125 | ||
| 120 | thing_copy = {k, v for k, v in pairs thing} | 126 | thing_copy = {k, v for k, v in pairs thing} |
| 121 | ``` | 127 | ``` |
| 128 | |||
| 122 | <YueDisplay> | 129 | <YueDisplay> |
| 123 | 130 | ||
| 124 | ```yue | 131 | ```yue |
| @@ -136,6 +143,7 @@ thing_copy = {k, v for k, v in pairs thing} | |||
| 136 | ```yuescript | 143 | ```yuescript |
| 137 | no_color = {k, v for k, v in pairs thing when k != "color"} | 144 | no_color = {k, v for k, v in pairs thing when k != "color"} |
| 138 | ``` | 145 | ``` |
| 146 | |||
| 139 | <YueDisplay> | 147 | <YueDisplay> |
| 140 | 148 | ||
| 141 | ```yue | 149 | ```yue |
| @@ -150,6 +158,7 @@ Der **\***-Operator wird ebenfalls unterstützt. Hier erstellen wir eine Nachsch | |||
| 150 | numbers = [1, 2, 3, 4] | 158 | numbers = [1, 2, 3, 4] |
| 151 | sqrts = {i, math.sqrt i for i in *numbers} | 159 | sqrts = {i, math.sqrt i for i in *numbers} |
| 152 | ``` | 160 | ``` |
| 161 | |||
| 153 | <YueDisplay> | 162 | <YueDisplay> |
| 154 | 163 | ||
| 155 | ```yue | 164 | ```yue |
| @@ -167,6 +176,7 @@ In diesem Beispiel konvertieren wir ein Array von Paaren in eine Tabelle, wobei | |||
| 167 | tuples = [ ["hallo", "Welt"], ["foo", "bar"]] | 176 | tuples = [ ["hallo", "Welt"], ["foo", "bar"]] |
| 168 | tbl = {unpack tuple for tuple in *tuples} | 177 | tbl = {unpack tuple for tuple in *tuples} |
| 169 | ``` | 178 | ``` |
| 179 | |||
| 170 | <YueDisplay> | 180 | <YueDisplay> |
| 171 | 181 | ||
| 172 | ```yue | 182 | ```yue |
| @@ -185,6 +195,7 @@ Hier setzen wir die minimalen und maximalen Grenzen und nehmen alle Elemente mit | |||
| 185 | ```yuescript | 195 | ```yuescript |
| 186 | slice = [item for item in *items[1, 5]] | 196 | slice = [item for item in *items[1, 5]] |
| 187 | ``` | 197 | ``` |
| 198 | |||
| 188 | <YueDisplay> | 199 | <YueDisplay> |
| 189 | 200 | ||
| 190 | ```yue | 201 | ```yue |
| @@ -198,6 +209,7 @@ Jedes der Slice-Argumente kann weggelassen werden, um einen sinnvollen Standard | |||
| 198 | ```yuescript | 209 | ```yuescript |
| 199 | slice = [item for item in *items[2,]] | 210 | slice = [item for item in *items[2,]] |
| 200 | ``` | 211 | ``` |
| 212 | |||
| 201 | <YueDisplay> | 213 | <YueDisplay> |
| 202 | 214 | ||
| 203 | ```yue | 215 | ```yue |
| @@ -211,6 +223,7 @@ Wenn die Mindestgrenze weggelassen wird, ist sie standardmäßig 1. Hier geben w | |||
| 211 | ```yuescript | 223 | ```yuescript |
| 212 | slice = [item for item in *items[,,2]] | 224 | slice = [item for item in *items[,,2]] |
| 213 | ``` | 225 | ``` |
| 226 | |||
| 214 | <YueDisplay> | 227 | <YueDisplay> |
| 215 | 228 | ||
| 216 | ```yue | 229 | ```yue |
| @@ -225,6 +238,7 @@ Sowohl die Mindest- als auch die Maximalgrenze können negativ sein; dann werden | |||
| 225 | -- die letzten 4 Elemente nehmen | 238 | -- die letzten 4 Elemente nehmen |
| 226 | slice = [item for item in *items[-4,-1]] | 239 | slice = [item for item in *items[-4,-1]] |
| 227 | ``` | 240 | ``` |
| 241 | |||
| 228 | <YueDisplay> | 242 | <YueDisplay> |
| 229 | 243 | ||
| 230 | ```yue | 244 | ```yue |
| @@ -239,6 +253,7 @@ Die Schrittweite kann ebenfalls negativ sein, wodurch die Elemente in umgekehrte | |||
| 239 | ```yuescript | 253 | ```yuescript |
| 240 | reverse_slice = [item for item in *items[-1,1,-1]] | 254 | reverse_slice = [item for item in *items[-1,1,-1]] |
| 241 | ``` | 255 | ``` |
| 256 | |||
| 242 | <YueDisplay> | 257 | <YueDisplay> |
| 243 | 258 | ||
| 244 | ```yue | 259 | ```yue |
| @@ -258,6 +273,7 @@ sub_list = items[2, 4] | |||
| 258 | -- die letzten 4 Elemente nehmen | 273 | -- die letzten 4 Elemente nehmen |
| 259 | last_four_items = items[-4, -1] | 274 | last_four_items = items[-4, -1] |
| 260 | ``` | 275 | ``` |
| 276 | |||
| 261 | <YueDisplay> | 277 | <YueDisplay> |
| 262 | 278 | ||
| 263 | ```yue | 279 | ```yue |
diff --git a/doc/docs/de/doc/data-structures/table-literals.md b/doc/docs/de/doc/data-structures/table-literals.md index 46181d7..4b127d8 100644 --- a/doc/docs/de/doc/data-structures/table-literals.md +++ b/doc/docs/de/doc/data-structures/table-literals.md | |||
| @@ -5,6 +5,7 @@ Wie in Lua werden Tabellen mit geschweiften Klammern definiert. | |||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | some_values = [1, 2, 3, 4] | 6 | some_values = [1, 2, 3, 4] |
| 7 | ``` | 7 | ``` |
| 8 | |||
| 8 | <YueDisplay> | 9 | <YueDisplay> |
| 9 | 10 | ||
| 10 | ```yue | 11 | ```yue |
| @@ -22,6 +23,7 @@ some_values = { | |||
| 22 | ["Lieblingsessen"]: "Reis" | 23 | ["Lieblingsessen"]: "Reis" |
| 23 | } | 24 | } |
| 24 | ``` | 25 | ``` |
| 26 | |||
| 25 | <YueDisplay> | 27 | <YueDisplay> |
| 26 | 28 | ||
| 27 | ```yue | 29 | ```yue |
| @@ -42,6 +44,7 @@ profile = | |||
| 42 | shoe_size: 13, | 44 | shoe_size: 13, |
| 43 | favorite_foods: ["Eis", "Donuts"] | 45 | favorite_foods: ["Eis", "Donuts"] |
| 44 | ``` | 46 | ``` |
| 47 | |||
| 45 | <YueDisplay> | 48 | <YueDisplay> |
| 46 | 49 | ||
| 47 | ```yue | 50 | ```yue |
| @@ -63,6 +66,7 @@ values = { | |||
| 63 | occupation: "Verbrechensbekämpfung" | 66 | occupation: "Verbrechensbekämpfung" |
| 64 | } | 67 | } |
| 65 | ``` | 68 | ``` |
| 69 | |||
| 66 | <YueDisplay> | 70 | <YueDisplay> |
| 67 | 71 | ||
| 68 | ```yue | 72 | ```yue |
| @@ -83,6 +87,7 @@ my_function dance: "Tango", partner: "keiner" | |||
| 83 | 87 | ||
| 84 | y = type: "Hund", legs: 4, tails: 1 | 88 | y = type: "Hund", legs: 4, tails: 1 |
| 85 | ``` | 89 | ``` |
| 90 | |||
| 86 | <YueDisplay> | 91 | <YueDisplay> |
| 87 | 92 | ||
| 88 | ```yue | 93 | ```yue |
| @@ -101,6 +106,7 @@ tbl = { | |||
| 101 | end: "Hunger" | 106 | end: "Hunger" |
| 102 | } | 107 | } |
| 103 | ``` | 108 | ``` |
| 109 | |||
| 104 | <YueDisplay> | 110 | <YueDisplay> |
| 105 | 111 | ||
| 106 | ```yue | 112 | ```yue |
| @@ -121,6 +127,7 @@ person = { :hair, :height, shoe_size: 40 } | |||
| 121 | 127 | ||
| 122 | print_table :hair, :height | 128 | print_table :hair, :height |
| 123 | ``` | 129 | ``` |
| 130 | |||
| 124 | <YueDisplay> | 131 | <YueDisplay> |
| 125 | 132 | ||
| 126 | ```yue | 133 | ```yue |
| @@ -141,6 +148,7 @@ t = { | |||
| 141 | "Hallo Welt": true | 148 | "Hallo Welt": true |
| 142 | } | 149 | } |
| 143 | ``` | 150 | ``` |
| 151 | |||
| 144 | <YueDisplay> | 152 | <YueDisplay> |
| 145 | 153 | ||
| 146 | ```yue | 154 | ```yue |
| @@ -158,6 +166,7 @@ Lua-Tabellen haben einen Array-Teil und einen Hash-Teil, aber manchmal möchte m | |||
| 158 | some_values = [1, 2, 3, 4] | 166 | some_values = [1, 2, 3, 4] |
| 159 | list_with_one_element = [1, ] | 167 | list_with_one_element = [1, ] |
| 160 | ``` | 168 | ``` |
| 169 | |||
| 161 | <YueDisplay> | 170 | <YueDisplay> |
| 162 | 171 | ||
| 163 | ```yue | 172 | ```yue |
diff --git a/doc/docs/de/doc/functions/backcalls.md b/doc/docs/de/doc/functions/backcalls.md index dbac86b..08b012d 100644 --- a/doc/docs/de/doc/functions/backcalls.md +++ b/doc/docs/de/doc/functions/backcalls.md | |||
| @@ -6,6 +6,7 @@ Backcalls werden verwendet, um Callbacks zu entkoppeln (unnesting). Sie werden m | |||
| 6 | x <- f | 6 | x <- f |
| 7 | print "hallo" .. x | 7 | print "hallo" .. x |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -21,6 +22,7 @@ Fat-Arrow-Funktionen sind ebenfalls verfügbar. | |||
| 21 | <= f | 22 | <= f |
| 22 | print @value | 23 | print @value |
| 23 | ``` | 24 | ``` |
| 25 | |||
| 24 | <YueDisplay> | 26 | <YueDisplay> |
| 25 | 27 | ||
| 26 | ```yue | 28 | ```yue |
| @@ -36,6 +38,7 @@ Du kannst einen Platzhalter angeben, an welcher Stelle die Backcall-Funktion als | |||
| 36 | (x) <- map _, [1, 2, 3] | 38 | (x) <- map _, [1, 2, 3] |
| 37 | x * 2 | 39 | x * 2 |
| 38 | ``` | 40 | ``` |
| 41 | |||
| 39 | <YueDisplay> | 42 | <YueDisplay> |
| 40 | 43 | ||
| 41 | ```yue | 44 | ```yue |
| @@ -55,6 +58,7 @@ result, msg = do | |||
| 55 | check info | 58 | check info |
| 56 | print result, msg | 59 | print result, msg |
| 57 | ``` | 60 | ``` |
| 61 | |||
| 58 | <YueDisplay> | 62 | <YueDisplay> |
| 59 | 63 | ||
| 60 | ```yue | 64 | ```yue |
diff --git a/doc/docs/de/doc/functions/function-literals.md b/doc/docs/de/doc/functions/function-literals.md index d3bfb11..1c9b00f 100644 --- a/doc/docs/de/doc/functions/function-literals.md +++ b/doc/docs/de/doc/functions/function-literals.md | |||
| @@ -6,6 +6,7 @@ Alle Funktionen werden mit einem Funktionsausdruck erstellt. Eine einfache Funkt | |||
| 6 | my_function = -> | 6 | my_function = -> |
| 7 | my_function() -- leere Funktion aufrufen | 7 | my_function() -- leere Funktion aufrufen |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -24,6 +25,7 @@ func_b = -> | |||
| 24 | value = 100 | 25 | value = 100 |
| 25 | print "Der Wert:", value | 26 | print "Der Wert:", value |
| 26 | ``` | 27 | ``` |
| 28 | |||
| 27 | <YueDisplay> | 29 | <YueDisplay> |
| 28 | 30 | ||
| 29 | ```yue | 31 | ```yue |
| @@ -42,6 +44,7 @@ Wenn eine Funktion keine Argumente hat, kann sie mit dem `!`-Operator statt leer | |||
| 42 | func_a! | 44 | func_a! |
| 43 | func_b() | 45 | func_b() |
| 44 | ``` | 46 | ``` |
| 47 | |||
| 45 | <YueDisplay> | 48 | <YueDisplay> |
| 46 | 49 | ||
| 47 | ```yue | 50 | ```yue |
| @@ -56,6 +59,7 @@ Funktionen mit Argumenten werden erstellt, indem der Pfeil von einer Argumentlis | |||
| 56 | ```yuescript | 59 | ```yuescript |
| 57 | sum = (x, y) -> print "Summe", x + y | 60 | sum = (x, y) -> print "Summe", x + y |
| 58 | ``` | 61 | ``` |
| 62 | |||
| 59 | <YueDisplay> | 63 | <YueDisplay> |
| 60 | 64 | ||
| 61 | ```yue | 65 | ```yue |
| @@ -72,6 +76,7 @@ print sum 10, 20 | |||
| 72 | 76 | ||
| 73 | a b c "a", "b", "c" | 77 | a b c "a", "b", "c" |
| 74 | ``` | 78 | ``` |
| 79 | |||
| 75 | <YueDisplay> | 80 | <YueDisplay> |
| 76 | 81 | ||
| 77 | ```yue | 82 | ```yue |
| @@ -88,6 +93,7 @@ Um Mehrdeutigkeiten beim Aufruf zu vermeiden, können die Argumente auch in Klam | |||
| 88 | ```yuescript | 93 | ```yuescript |
| 89 | print "x:", sum(10, 20), "y:", sum(30, 40) | 94 | print "x:", sum(10, 20), "y:", sum(30, 40) |
| 90 | ``` | 95 | ``` |
| 96 | |||
| 91 | <YueDisplay> | 97 | <YueDisplay> |
| 92 | 98 | ||
| 93 | ```yue | 99 | ```yue |
| @@ -104,6 +110,7 @@ Funktionen wandeln die letzte Anweisung im Funktionskörper in ein `return` um. | |||
| 104 | sum = (x, y) -> x + y | 110 | sum = (x, y) -> x + y |
| 105 | print "Die Summe ist ", sum 10, 20 | 111 | print "Die Summe ist ", sum 10, 20 |
| 106 | ``` | 112 | ``` |
| 113 | |||
| 107 | <YueDisplay> | 114 | <YueDisplay> |
| 108 | 115 | ||
| 109 | ```yue | 116 | ```yue |
| @@ -118,6 +125,7 @@ Wenn du explizit zurückgeben willst, verwende `return`: | |||
| 118 | ```yuescript | 125 | ```yuescript |
| 119 | sum = (x, y) -> return x + y | 126 | sum = (x, y) -> return x + y |
| 120 | ``` | 127 | ``` |
| 128 | |||
| 121 | <YueDisplay> | 129 | <YueDisplay> |
| 122 | 130 | ||
| 123 | ```yue | 131 | ```yue |
| @@ -132,6 +140,7 @@ Wie in Lua können Funktionen mehrere Werte zurückgeben. Die letzte Anweisung m | |||
| 132 | mystery = (x, y) -> x + y, x - y | 140 | mystery = (x, y) -> x + y, x - y |
| 133 | a, b = mystery 10, 20 | 141 | a, b = mystery 10, 20 |
| 134 | ``` | 142 | ``` |
| 143 | |||
| 135 | <YueDisplay> | 144 | <YueDisplay> |
| 136 | 145 | ||
| 137 | ```yue | 146 | ```yue |
| @@ -148,6 +157,7 @@ Da es in Lua üblich ist, beim Methodenaufruf ein Objekt als erstes Argument zu | |||
| 148 | ```yuescript | 157 | ```yuescript |
| 149 | func = (num) => @value + num | 158 | func = (num) => @value + num |
| 150 | ``` | 159 | ``` |
| 160 | |||
| 151 | <YueDisplay> | 161 | <YueDisplay> |
| 152 | 162 | ||
| 153 | ```yue | 163 | ```yue |
| @@ -165,6 +175,7 @@ my_function = (name = "etwas", height = 100) -> | |||
| 165 | print "Hallo, ich bin", name | 175 | print "Hallo, ich bin", name |
| 166 | print "Meine Größe ist", height | 176 | print "Meine Größe ist", height |
| 167 | ``` | 177 | ``` |
| 178 | |||
| 168 | <YueDisplay> | 179 | <YueDisplay> |
| 169 | 180 | ||
| 170 | ```yue | 181 | ```yue |
| @@ -181,6 +192,7 @@ Der Ausdruck für den Standardwert wird im Funktionskörper in der Reihenfolge d | |||
| 181 | some_args = (x = 100, y = x + 1000) -> | 192 | some_args = (x = 100, y = x + 1000) -> |
| 182 | print x + y | 193 | print x + y |
| 183 | ``` | 194 | ``` |
| 195 | |||
| 184 | <YueDisplay> | 196 | <YueDisplay> |
| 185 | 197 | ||
| 186 | ```yue | 198 | ```yue |
| @@ -202,6 +214,7 @@ b = x-10 | |||
| 202 | c = x -y | 214 | c = x -y |
| 203 | d = x- z | 215 | d = x- z |
| 204 | ``` | 216 | ``` |
| 217 | |||
| 205 | <YueDisplay> | 218 | <YueDisplay> |
| 206 | 219 | ||
| 207 | ```yue | 220 | ```yue |
| @@ -223,6 +236,7 @@ Steht ein Leerzeichen zwischen Variable und String-Literal, verhält sich der Au | |||
| 223 | x = func"hallo" + 100 | 236 | x = func"hallo" + 100 |
| 224 | y = func "hallo" + 100 | 237 | y = func "hallo" + 100 |
| 225 | ``` | 238 | ``` |
| 239 | |||
| 226 | <YueDisplay> | 240 | <YueDisplay> |
| 227 | 241 | ||
| 228 | ```yue | 242 | ```yue |
| @@ -247,6 +261,7 @@ cool_func 1, 2, | |||
| 247 | 5, 6, | 261 | 5, 6, |
| 248 | 7, 8 | 262 | 7, 8 |
| 249 | ``` | 263 | ``` |
| 264 | |||
| 250 | <YueDisplay> | 265 | <YueDisplay> |
| 251 | 266 | ||
| 252 | ```yue | 267 | ```yue |
| @@ -269,6 +284,7 @@ my_func 5, 6, 7, | |||
| 269 | 9, 1, 2, | 284 | 9, 1, 2, |
| 270 | 5, 4 | 285 | 5, 4 |
| 271 | ``` | 286 | ``` |
| 287 | |||
| 272 | <YueDisplay> | 288 | <YueDisplay> |
| 273 | 289 | ||
| 274 | ```yue | 290 | ```yue |
| @@ -289,6 +305,7 @@ x = [ | |||
| 289 | 8, 9, 10 | 305 | 8, 9, 10 |
| 290 | ] | 306 | ] |
| 291 | ``` | 307 | ``` |
| 308 | |||
| 292 | <YueDisplay> | 309 | <YueDisplay> |
| 293 | 310 | ||
| 294 | ```yue | 311 | ```yue |
| @@ -309,6 +326,7 @@ y = [ my_func 1, 2, 3, | |||
| 309 | 5, 6, 7 | 326 | 5, 6, 7 |
| 310 | ] | 327 | ] |
| 311 | ``` | 328 | ``` |
| 329 | |||
| 312 | <YueDisplay> | 330 | <YueDisplay> |
| 313 | 331 | ||
| 314 | ```yue | 332 | ```yue |
| @@ -335,6 +353,7 @@ if func 1, 2, 3, | |||
| 335 | print "hallo" | 353 | print "hallo" |
| 336 | print "Ich bin innerhalb der if-Bedingung" | 354 | print "Ich bin innerhalb der if-Bedingung" |
| 337 | ``` | 355 | ``` |
| 356 | |||
| 338 | <YueDisplay> | 357 | <YueDisplay> |
| 339 | 358 | ||
| 340 | ```yue | 359 | ```yue |
| @@ -357,8 +376,8 @@ if func 1, 2, 3, | |||
| 357 | 376 | ||
| 358 | YueScript unterstützt jetzt Destructuring von Funktionsparametern, wenn das Argument ein Objekt ist. Es gibt zwei Formen von Destructuring-Tabellenliteralen: | 377 | YueScript unterstützt jetzt Destructuring von Funktionsparametern, wenn das Argument ein Objekt ist. Es gibt zwei Formen von Destructuring-Tabellenliteralen: |
| 359 | 378 | ||
| 360 | * **Geschweifte Klammern/Objektparameter**, die optionale Standardwerte erlauben, wenn Felder fehlen (z. B. `{:a, :b}`, `{a: a1 = 123}`). | 379 | - **Geschweifte Klammern/Objektparameter**, die optionale Standardwerte erlauben, wenn Felder fehlen (z. B. `{:a, :b}`, `{a: a1 = 123}`). |
| 361 | * **Unverpackte einfache Tabellensyntax**, die mit einer Sequenz aus Key-Value- oder Shorthand-Bindings beginnt und so lange läuft, bis ein anderer Ausdruck sie beendet (z. B. `:a, b: b1, :c`). Diese Form extrahiert mehrere Felder aus demselben Objekt. | 380 | - **Unverpackte einfache Tabellensyntax**, die mit einer Sequenz aus Key-Value- oder Shorthand-Bindings beginnt und so lange läuft, bis ein anderer Ausdruck sie beendet (z. B. `:a, b: b1, :c`). Diese Form extrahiert mehrere Felder aus demselben Objekt. |
| 362 | 381 | ||
| 363 | ```yuescript | 382 | ```yuescript |
| 364 | f1 = (:a, :b, :c) -> | 383 | f1 = (:a, :b, :c) -> |
| @@ -372,6 +391,7 @@ f2 = ({a: a1 = 123, :b = 'abc'}, c = {}) -> | |||
| 372 | arg1 = {a: 0} | 391 | arg1 = {a: 0} |
| 373 | f2 arg1, arg2 | 392 | f2 arg1, arg2 |
| 374 | ``` | 393 | ``` |
| 394 | |||
| 375 | <YueDisplay> | 395 | <YueDisplay> |
| 376 | 396 | ||
| 377 | ```yue | 397 | ```yue |
| @@ -401,6 +421,7 @@ findFirstEven = (list): nil -> | |||
| 401 | if sub % 2 == 0 | 421 | if sub % 2 == 0 |
| 402 | return sub | 422 | return sub |
| 403 | ``` | 423 | ``` |
| 424 | |||
| 404 | <YueDisplay> | 425 | <YueDisplay> |
| 405 | 426 | ||
| 406 | ```yue | 427 | ```yue |
| @@ -425,6 +446,7 @@ findFirstEven = (list) -> | |||
| 425 | return sub | 446 | return sub |
| 426 | nil | 447 | nil |
| 427 | ``` | 448 | ``` |
| 449 | |||
| 428 | <YueDisplay> | 450 | <YueDisplay> |
| 429 | 451 | ||
| 430 | ```yue | 452 | ```yue |
| @@ -466,6 +488,7 @@ process = (...args) -> | |||
| 466 | 488 | ||
| 467 | process 1, nil, 3, nil, 5 | 489 | process 1, nil, 3, nil, 5 |
| 468 | ``` | 490 | ``` |
| 491 | |||
| 469 | <YueDisplay> | 492 | <YueDisplay> |
| 470 | 493 | ||
| 471 | ```yue | 494 | ```yue |
diff --git a/doc/docs/de/doc/functions/function-stubs.md b/doc/docs/de/doc/functions/function-stubs.md index 66b3ddb..cd4382a 100644 --- a/doc/docs/de/doc/functions/function-stubs.md +++ b/doc/docs/de/doc/functions/function-stubs.md | |||
| @@ -24,6 +24,7 @@ run_callback my_object.write | |||
| 24 | -- bindet das Objekt in eine neue Funktion ein | 24 | -- bindet das Objekt in eine neue Funktion ein |
| 25 | run_callback my_object\write | 25 | run_callback my_object\write |
| 26 | ``` | 26 | ``` |
| 27 | |||
| 27 | <YueDisplay> | 28 | <YueDisplay> |
| 28 | 29 | ||
| 29 | ```yue | 30 | ```yue |
diff --git a/doc/docs/de/doc/getting-started/usage.md b/doc/docs/de/doc/getting-started/usage.md index f3c9333..2c10406 100644 --- a/doc/docs/de/doc/getting-started/usage.md +++ b/doc/docs/de/doc/getting-started/usage.md | |||
| @@ -4,49 +4,51 @@ | |||
| 4 | 4 | ||
| 5 | YueScript-Modul in Lua verwenden: | 5 | YueScript-Modul in Lua verwenden: |
| 6 | 6 | ||
| 7 | * **Fall 1** | 7 | - **Fall 1** |
| 8 | 8 | ||
| 9 | "your_yuescript_entry.yue" in Lua require'n. | 9 | "your_yuescript_entry.yue" in Lua require'n. |
| 10 | ```Lua | 10 | |
| 11 | require("yue")("your_yuescript_entry") | 11 | ```Lua |
| 12 | ``` | 12 | require("yue")("your_yuescript_entry") |
| 13 | Dieser Code funktioniert weiterhin, wenn du "your_yuescript_entry.yue" im gleichen Pfad zu "your_yuescript_entry.lua" kompilierst. In den restlichen YueScript-Dateien verwendest du einfach normales **require** oder **import**. Die Zeilennummern in Fehlermeldungen werden korrekt behandelt. | 13 | ``` |
| 14 | 14 | ||
| 15 | * **Fall 2** | 15 | Dieser Code funktioniert weiterhin, wenn du "your_yuescript_entry.yue" im gleichen Pfad zu "your_yuescript_entry.lua" kompilierst. In den restlichen YueScript-Dateien verwendest du einfach normales **require** oder **import**. Die Zeilennummern in Fehlermeldungen werden korrekt behandelt. |
| 16 | 16 | ||
| 17 | YueScript-Modul require'n und das Fehlermapping manuell umschreiben. | 17 | - **Fall 2** |
| 18 | 18 | ||
| 19 | ```lua | 19 | YueScript-Modul require'n und das Fehlermapping manuell umschreiben. |
| 20 | local yue = require("yue") | 20 | |
| 21 | yue.insert_loader() | 21 | ```lua |
| 22 | local success, result = xpcall(function() | 22 | local yue = require("yue") |
| 23 | return require("yuescript_module_name") | 23 | yue.insert_loader() |
| 24 | end, function(err) | 24 | local success, result = xpcall(function() |
| 25 | return yue.traceback(err) | 25 | return require("yuescript_module_name") |
| 26 | end) | 26 | end, function(err) |
| 27 | ``` | 27 | return yue.traceback(err) |
| 28 | 28 | end) | |
| 29 | * **Fall 3** | 29 | ``` |
| 30 | 30 | ||
| 31 | Die YueScript-Compilerfunktion in Lua verwenden. | 31 | - **Fall 3** |
| 32 | 32 | ||
| 33 | ```lua | 33 | Die YueScript-Compilerfunktion in Lua verwenden. |
| 34 | local yue = require("yue") | 34 | |
| 35 | local codes, err, globals = yue.to_lua([[ | 35 | ```lua |
| 36 | f = -> | 36 | local yue = require("yue") |
| 37 | print "Hallo Welt" | 37 | local codes, err, globals = yue.to_lua([[ |
| 38 | f! | 38 | f = -> |
| 39 | ]],{ | 39 | print "Hallo Welt" |
| 40 | implicit_return_root = true, | 40 | f! |
| 41 | reserve_line_number = true, | 41 | ]],{ |
| 42 | lint_global = true, | 42 | implicit_return_root = true, |
| 43 | space_over_tab = false, | 43 | reserve_line_number = true, |
| 44 | options = { | 44 | lint_global = true, |
| 45 | target = "5.4", | 45 | space_over_tab = false, |
| 46 | path = "/script" | 46 | options = { |
| 47 | } | 47 | target = "5.4", |
| 48 | }) | 48 | path = "/script" |
| 49 | ``` | 49 | } |
| 50 | }) | ||
| 51 | ``` | ||
| 50 | 52 | ||
| 51 | ## YueScript-Tool | 53 | ## YueScript-Tool |
| 52 | 54 | ||
diff --git a/doc/docs/de/doc/language-basics/attributes.md b/doc/docs/de/doc/language-basics/attributes.md index 0fa3654..8c37d82 100644 --- a/doc/docs/de/doc/language-basics/attributes.md +++ b/doc/docs/de/doc/language-basics/attributes.md | |||
| @@ -6,6 +6,7 @@ Syntax-Unterstützung für Lua-5.4-Attribute. Du kannst weiterhin die Deklaratio | |||
| 6 | const a = 123 | 6 | const a = 123 |
| 7 | close _ = <close>: -> print "Außerhalb des Gültigkeitsbereichs." | 7 | close _ = <close>: -> print "Außerhalb des Gültigkeitsbereichs." |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -21,6 +22,7 @@ Du kannst Destructuring mit als konstant markierten Variablen verwenden. | |||
| 21 | const {:a, :b, c, d} = tb | 22 | const {:a, :b, c, d} = tb |
| 22 | -- a = 1 | 23 | -- a = 1 |
| 23 | ``` | 24 | ``` |
| 25 | |||
| 24 | <YueDisplay> | 26 | <YueDisplay> |
| 25 | 27 | ||
| 26 | ```yue | 28 | ```yue |
| @@ -36,6 +38,7 @@ Du kannst auch eine globale Variable als `const` deklarieren. | |||
| 36 | global const Constant = 123 | 38 | global const Constant = 123 |
| 37 | -- Constant = 1 | 39 | -- Constant = 1 |
| 38 | ``` | 40 | ``` |
| 41 | |||
| 39 | <YueDisplay> | 42 | <YueDisplay> |
| 40 | 43 | ||
| 41 | ```yue | 44 | ```yue |
diff --git a/doc/docs/de/doc/language-basics/comment.md b/doc/docs/de/doc/language-basics/comment.md index dec9bb0..0216162 100644 --- a/doc/docs/de/doc/language-basics/comment.md +++ b/doc/docs/de/doc/language-basics/comment.md | |||
| @@ -12,6 +12,7 @@ Alles okay. | |||
| 12 | 12 | ||
| 13 | func --[[Port]] 3000, --[[IP]] "192.168.1.1" | 13 | func --[[Port]] 3000, --[[IP]] "192.168.1.1" |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
diff --git a/doc/docs/de/doc/language-basics/literals.md b/doc/docs/de/doc/language-basics/literals.md index 55a5aaa..23e8582 100644 --- a/doc/docs/de/doc/language-basics/literals.md +++ b/doc/docs/de/doc/language-basics/literals.md | |||
| @@ -12,6 +12,7 @@ some_string = "Hier ist ein String | |||
| 12 | -- String-Interpolation gibt es nur in doppelt angeführten Strings. | 12 | -- String-Interpolation gibt es nur in doppelt angeführten Strings. |
| 13 | print "Ich bin mir zu #{math.random! * 100}% sicher." | 13 | print "Ich bin mir zu #{math.random! * 100}% sicher." |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -34,6 +35,7 @@ integer = 1_000_000 | |||
| 34 | hex = 0xEF_BB_BF | 35 | hex = 0xEF_BB_BF |
| 35 | binary = 0B10011 | 36 | binary = 0B10011 |
| 36 | ``` | 37 | ``` |
| 38 | |||
| 37 | <YueDisplay> | 39 | <YueDisplay> |
| 38 | 40 | ||
| 39 | ```yue | 41 | ```yue |
| @@ -55,6 +57,7 @@ str = | | |||
| 55 | - item1 | 57 | - item1 |
| 56 | - #{expr} | 58 | - #{expr} |
| 57 | ``` | 59 | ``` |
| 60 | |||
| 58 | <YueDisplay> | 61 | <YueDisplay> |
| 59 | 62 | ||
| 60 | ```yue | 63 | ```yue |
| @@ -78,6 +81,7 @@ fn = -> | |||
| 78 | bar: baz | 81 | bar: baz |
| 79 | return str | 82 | return str |
| 80 | ``` | 83 | ``` |
| 84 | |||
| 81 | <YueDisplay> | 85 | <YueDisplay> |
| 82 | 86 | ||
| 83 | ```yue | 87 | ```yue |
| @@ -99,6 +103,7 @@ str = | | |||
| 99 | path: "C:\Program Files\App" | 103 | path: "C:\Program Files\App" |
| 100 | note: 'He said: "#{Hello}!"' | 104 | note: 'He said: "#{Hello}!"' |
| 101 | ``` | 105 | ``` |
| 106 | |||
| 102 | <YueDisplay> | 107 | <YueDisplay> |
| 103 | 108 | ||
| 104 | ```yue | 109 | ```yue |
diff --git a/doc/docs/de/doc/language-basics/operator.md b/doc/docs/de/doc/language-basics/operator.md index a7b8c5c..12143d5 100644 --- a/doc/docs/de/doc/language-basics/operator.md +++ b/doc/docs/de/doc/language-basics/operator.md | |||
| @@ -1,11 +1,12 @@ | |||
| 1 | # Operatoren | 1 | # Operatoren |
| 2 | 2 | ||
| 3 | Alle binären und unären Operatoren von Lua sind verfügbar. Zusätzlich ist **!=** ein Alias für **~=**, und entweder **\** oder **::** kann für verkettete Funktionsaufrufe wie `tb\func!` oder `tb::func!` verwendet werden. Außerdem bietet YueScript einige spezielle Operatoren für ausdrucksstärkeren Code. | 3 | Alle binären und unären Operatoren von Lua sind verfügbar. Zusätzlich ist **!=** ein Alias für **~=**, und entweder **\*\* oder **::\*\* kann für verkettete Funktionsaufrufe wie `tb\func!` oder `tb::func!` verwendet werden. Außerdem bietet YueScript einige spezielle Operatoren für ausdrucksstärkeren Code. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | tb\func! if tb ~= nil | 6 | tb\func! if tb ~= nil |
| 7 | tb::func! if tb != nil | 7 | tb::func! if tb != nil |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -27,6 +28,7 @@ a = 5 | |||
| 27 | print 1 <= a <= 10 | 28 | print 1 <= a <= 10 |
| 28 | -- Ausgabe: true | 29 | -- Ausgabe: true |
| 29 | ``` | 30 | ``` |
| 31 | |||
| 30 | <YueDisplay> | 32 | <YueDisplay> |
| 31 | 33 | ||
| 32 | ```yue | 34 | ```yue |
| @@ -64,6 +66,7 @@ print v(1) > v(2) <= v(3) | |||
| 64 | false | 66 | false |
| 65 | ]] | 67 | ]] |
| 66 | ``` | 68 | ``` |
| 69 | |||
| 67 | <YueDisplay> | 70 | <YueDisplay> |
| 68 | 71 | ||
| 69 | ```yue | 72 | ```yue |
| @@ -101,6 +104,7 @@ Der Operator **[] =** wird verwendet, um Werte an Tabellen anzuhängen. | |||
| 101 | tab = [] | 104 | tab = [] |
| 102 | tab[] = "Wert" | 105 | tab[] = "Wert" |
| 103 | ``` | 106 | ``` |
| 107 | |||
| 104 | <YueDisplay> | 108 | <YueDisplay> |
| 105 | 109 | ||
| 106 | ```yue | 110 | ```yue |
| @@ -118,6 +122,7 @@ tbB = [4, 5, 6] | |||
| 118 | tbA[] = ...tbB | 122 | tbA[] = ...tbB |
| 119 | -- tbA ist jetzt [1, 2, 3, 4, 5, 6] | 123 | -- tbA ist jetzt [1, 2, 3, 4, 5, 6] |
| 120 | ``` | 124 | ``` |
| 125 | |||
| 121 | <YueDisplay> | 126 | <YueDisplay> |
| 122 | 127 | ||
| 123 | ```yue | 128 | ```yue |
| @@ -149,6 +154,7 @@ a = {1, 2, 3, x: 1} | |||
| 149 | b = {4, 5, y: 1} | 154 | b = {4, 5, y: 1} |
| 150 | merge = {...a, ...b} | 155 | merge = {...a, ...b} |
| 151 | ``` | 156 | ``` |
| 157 | |||
| 152 | <YueDisplay> | 158 | <YueDisplay> |
| 153 | 159 | ||
| 154 | ```yue | 160 | ```yue |
| @@ -179,6 +185,7 @@ last = data.items[#] | |||
| 179 | second_last = data.items[#-1] | 185 | second_last = data.items[#-1] |
| 180 | data.items[#] = 1 | 186 | data.items[#] = 1 |
| 181 | ``` | 187 | ``` |
| 188 | |||
| 182 | <YueDisplay> | 189 | <YueDisplay> |
| 183 | 190 | ||
| 184 | ```yue | 191 | ```yue |
| @@ -212,6 +219,7 @@ print d.value | |||
| 212 | 219 | ||
| 213 | close _ = <close>: -> print "Außerhalb des Gültigkeitsbereichs" | 220 | close _ = <close>: -> print "Außerhalb des Gültigkeitsbereichs" |
| 214 | ``` | 221 | ``` |
| 222 | |||
| 215 | <YueDisplay> | 223 | <YueDisplay> |
| 216 | 224 | ||
| 217 | ```yue | 225 | ```yue |
| @@ -245,6 +253,7 @@ print tb.value | |||
| 245 | tb.<> = __index: {item: "hallo"} | 253 | tb.<> = __index: {item: "hallo"} |
| 246 | print tb.item | 254 | print tb.item |
| 247 | ``` | 255 | ``` |
| 256 | |||
| 248 | <YueDisplay> | 257 | <YueDisplay> |
| 249 | 258 | ||
| 250 | ```yue | 259 | ```yue |
| @@ -266,6 +275,7 @@ Destrukturiere Metatable mit Metamethoden-Schlüssel, der von **<>** umschlossen | |||
| 266 | {item, :new, :<close>, <index>: getter} = tb | 275 | {item, :new, :<close>, <index>: getter} = tb |
| 267 | print item, new, close, getter | 276 | print item, new, close, getter |
| 268 | ``` | 277 | ``` |
| 278 | |||
| 269 | <YueDisplay> | 279 | <YueDisplay> |
| 270 | 280 | ||
| 271 | ```yue | 281 | ```yue |
| @@ -293,6 +303,7 @@ with? io.open "test.txt", "w" | |||
| 293 | \write "hello" | 303 | \write "hello" |
| 294 | \close! | 304 | \close! |
| 295 | ``` | 305 | ``` |
| 306 | |||
| 296 | <YueDisplay> | 307 | <YueDisplay> |
| 297 | 308 | ||
| 298 | ```yue | 309 | ```yue |
| @@ -329,6 +340,7 @@ readFile "example.txt" | |||
| 329 | |> render | 340 | |> render |
| 330 | 341 | ||
| 331 | ``` | 342 | ``` |
| 343 | |||
| 332 | <YueDisplay> | 344 | <YueDisplay> |
| 333 | 345 | ||
| 334 | ```yue | 346 | ```yue |
| @@ -357,6 +369,7 @@ func a ?? {} | |||
| 357 | 369 | ||
| 358 | a ??= false | 370 | a ??= false |
| 359 | ``` | 371 | ``` |
| 372 | |||
| 360 | <YueDisplay> | 373 | <YueDisplay> |
| 361 | 374 | ||
| 362 | ```yue | 375 | ```yue |
| @@ -414,6 +427,7 @@ tb = | |||
| 414 | tb: { } | 427 | tb: { } |
| 415 | 428 | ||
| 416 | ``` | 429 | ``` |
| 430 | |||
| 417 | <YueDisplay> | 431 | <YueDisplay> |
| 418 | 432 | ||
| 419 | ```yue | 433 | ```yue |
diff --git a/doc/docs/de/doc/language-basics/whitespace.md b/doc/docs/de/doc/language-basics/whitespace.md index 9d5889d..0915692 100644 --- a/doc/docs/de/doc/language-basics/whitespace.md +++ b/doc/docs/de/doc/language-basics/whitespace.md | |||
| @@ -9,6 +9,7 @@ Eine Anweisung endet normalerweise an einem Zeilenumbruch. Du kannst auch ein Se | |||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | a = 1; b = 2; print a + b | 10 | a = 1; b = 2; print a + b |
| 11 | ``` | 11 | ``` |
| 12 | |||
| 12 | <YueDisplay> | 13 | <YueDisplay> |
| 13 | 14 | ||
| 14 | ```yue | 15 | ```yue |
| @@ -29,6 +30,7 @@ Rx.Observable | |||
| 29 | \map (value) -> value .. '!' | 30 | \map (value) -> value .. '!' |
| 30 | \subscribe print | 31 | \subscribe print |
| 31 | ``` | 32 | ``` |
| 33 | |||
| 32 | <YueDisplay> | 34 | <YueDisplay> |
| 33 | 35 | ||
| 34 | ```yue | 36 | ```yue |
diff --git a/doc/docs/de/doc/objects/object-oriented-programming.md b/doc/docs/de/doc/objects/object-oriented-programming.md index 1c116a3..706cfda 100644 --- a/doc/docs/de/doc/objects/object-oriented-programming.md +++ b/doc/docs/de/doc/objects/object-oriented-programming.md | |||
| @@ -15,6 +15,7 @@ class Inventory | |||
| 15 | else | 15 | else |
| 16 | @items[name] = 1 | 16 | @items[name] = 1 |
| 17 | ``` | 17 | ``` |
| 18 | |||
| 18 | <YueDisplay> | 19 | <YueDisplay> |
| 19 | 20 | ||
| 20 | ```yue | 21 | ```yue |
| @@ -46,6 +47,7 @@ inv = Inventory! | |||
| 46 | inv\add_item "T-Shirt" | 47 | inv\add_item "T-Shirt" |
| 47 | inv\add_item "Hose" | 48 | inv\add_item "Hose" |
| 48 | ``` | 49 | ``` |
| 50 | |||
| 49 | <YueDisplay> | 51 | <YueDisplay> |
| 50 | 52 | ||
| 51 | ```yue | 53 | ```yue |
| @@ -77,6 +79,7 @@ b\give_item "Hemd" | |||
| 77 | -- gibt sowohl Hose als auch Hemd aus | 79 | -- gibt sowohl Hose als auch Hemd aus |
| 78 | print item for item in *a.clothes | 80 | print item for item in *a.clothes |
| 79 | ``` | 81 | ``` |
| 82 | |||
| 80 | <YueDisplay> | 83 | <YueDisplay> |
| 81 | 84 | ||
| 82 | ```yue | 85 | ```yue |
| @@ -104,6 +107,7 @@ class Person | |||
| 104 | new: => | 107 | new: => |
| 105 | @clothes = [] | 108 | @clothes = [] |
| 106 | ``` | 109 | ``` |
| 110 | |||
| 107 | <YueDisplay> | 111 | <YueDisplay> |
| 108 | 112 | ||
| 109 | ```yue | 113 | ```yue |
| @@ -125,6 +129,7 @@ class BackPack extends Inventory | |||
| 125 | if #@items > size then error "Rucksack ist voll" | 129 | if #@items > size then error "Rucksack ist voll" |
| 126 | super name | 130 | super name |
| 127 | ``` | 131 | ``` |
| 132 | |||
| 128 | <YueDisplay> | 133 | <YueDisplay> |
| 129 | 134 | ||
| 130 | ```yue | 135 | ```yue |
| @@ -151,6 +156,7 @@ class Shelf | |||
| 151 | -- gibt aus: Shelf wurde von Cupboard geerbt | 156 | -- gibt aus: Shelf wurde von Cupboard geerbt |
| 152 | class Cupboard extends Shelf | 157 | class Cupboard extends Shelf |
| 153 | ``` | 158 | ``` |
| 159 | |||
| 154 | <YueDisplay> | 160 | <YueDisplay> |
| 155 | 161 | ||
| 156 | ```yue | 162 | ```yue |
| @@ -189,6 +195,7 @@ class MyClass extends ParentClass | |||
| 189 | -- super als Wert entspricht der Elternklasse: | 195 | -- super als Wert entspricht der Elternklasse: |
| 190 | assert super == ParentClass | 196 | assert super == ParentClass |
| 191 | ``` | 197 | ``` |
| 198 | |||
| 192 | <YueDisplay> | 199 | <YueDisplay> |
| 193 | 200 | ||
| 194 | ```yue | 201 | ```yue |
| @@ -217,6 +224,7 @@ assert b.__class == BackPack | |||
| 217 | 224 | ||
| 218 | print BackPack.size -- gibt 10 aus | 225 | print BackPack.size -- gibt 10 aus |
| 219 | ``` | 226 | ``` |
| 227 | |||
| 220 | <YueDisplay> | 228 | <YueDisplay> |
| 221 | 229 | ||
| 222 | ```yue | 230 | ```yue |
| @@ -247,6 +255,7 @@ Der Name der Klasse, wie sie deklariert wurde, wird im Feld `__name` gespeichert | |||
| 247 | ```yuescript | 255 | ```yuescript |
| 248 | print BackPack.__name -- gibt Backpack aus | 256 | print BackPack.__name -- gibt Backpack aus |
| 249 | ``` | 257 | ``` |
| 258 | |||
| 250 | <YueDisplay> | 259 | <YueDisplay> |
| 251 | 260 | ||
| 252 | ```yue | 261 | ```yue |
| @@ -272,6 +281,7 @@ Things\some_func! | |||
| 272 | -- Klassenvariablen in Instanzen nicht sichtbar | 281 | -- Klassenvariablen in Instanzen nicht sichtbar |
| 273 | assert Things().some_func == nil | 282 | assert Things().some_func == nil |
| 274 | ``` | 283 | ``` |
| 284 | |||
| 275 | <YueDisplay> | 285 | <YueDisplay> |
| 276 | 286 | ||
| 277 | ```yue | 287 | ```yue |
| @@ -300,6 +310,7 @@ Counter! | |||
| 300 | 310 | ||
| 301 | print Counter.count -- gibt 2 aus | 311 | print Counter.count -- gibt 2 aus |
| 302 | ``` | 312 | ``` |
| 313 | |||
| 303 | <YueDisplay> | 314 | <YueDisplay> |
| 304 | 315 | ||
| 305 | ```yue | 316 | ```yue |
| @@ -322,6 +333,7 @@ Die Aufrufsemantik von `@@` ist ähnlich wie bei `@`. Wenn du einen `@@`-Namen a | |||
| 322 | ```yuescript | 333 | ```yuescript |
| 323 | @@hello 1,2,3,4 | 334 | @@hello 1,2,3,4 |
| 324 | ``` | 335 | ``` |
| 336 | |||
| 325 | <YueDisplay> | 337 | <YueDisplay> |
| 326 | 338 | ||
| 327 | ```yue | 339 | ```yue |
| @@ -340,6 +352,7 @@ Hier ist eine alternative Möglichkeit, eine Klassenvariable zu erstellen: | |||
| 340 | class Things | 352 | class Things |
| 341 | @class_var = "Hallo Welt" | 353 | @class_var = "Hallo Welt" |
| 342 | ``` | 354 | ``` |
| 355 | |||
| 343 | <YueDisplay> | 356 | <YueDisplay> |
| 344 | 357 | ||
| 345 | ```yue | 358 | ```yue |
| @@ -361,6 +374,7 @@ class MoreThings | |||
| 361 | some_method: => | 374 | some_method: => |
| 362 | log "Hallo Welt: " .. secret | 375 | log "Hallo Welt: " .. secret |
| 363 | ``` | 376 | ``` |
| 377 | |||
| 364 | <YueDisplay> | 378 | <YueDisplay> |
| 365 | 379 | ||
| 366 | ```yue | 380 | ```yue |
| @@ -384,6 +398,7 @@ Wenn sie alleine verwendet werden, sind sie Aliase für `self` und `self.__class | |||
| 384 | assert @ == self | 398 | assert @ == self |
| 385 | assert @@ == self.__class | 399 | assert @@ == self.__class |
| 386 | ``` | 400 | ``` |
| 401 | |||
| 387 | <YueDisplay> | 402 | <YueDisplay> |
| 388 | 403 | ||
| 389 | ```yue | 404 | ```yue |
| @@ -398,6 +413,7 @@ Zum Beispiel kannst du mit `@@` in einer Instanzmethode schnell eine neue Instan | |||
| 398 | ```yuescript | 413 | ```yuescript |
| 399 | some_instance_method = (...) => @@ ... | 414 | some_instance_method = (...) => @@ ... |
| 400 | ``` | 415 | ``` |
| 416 | |||
| 401 | <YueDisplay> | 417 | <YueDisplay> |
| 402 | 418 | ||
| 403 | ```yue | 419 | ```yue |
| @@ -423,6 +439,7 @@ class Something | |||
| 423 | @@biz = biz | 439 | @@biz = biz |
| 424 | @@baz = baz | 440 | @@baz = baz |
| 425 | ``` | 441 | ``` |
| 442 | |||
| 426 | <YueDisplay> | 443 | <YueDisplay> |
| 427 | 444 | ||
| 428 | ```yue | 445 | ```yue |
| @@ -448,6 +465,7 @@ new = (@fieldA, @fieldB) => @ | |||
| 448 | obj = new {}, 123, "abc" | 465 | obj = new {}, 123, "abc" |
| 449 | print obj | 466 | print obj |
| 450 | ``` | 467 | ``` |
| 468 | |||
| 451 | <YueDisplay> | 469 | <YueDisplay> |
| 452 | 470 | ||
| 453 | ```yue | 471 | ```yue |
| @@ -467,6 +485,7 @@ x = class Bucket | |||
| 467 | drops: 0 | 485 | drops: 0 |
| 468 | add_drop: => @drops += 1 | 486 | add_drop: => @drops += 1 |
| 469 | ``` | 487 | ``` |
| 488 | |||
| 470 | <YueDisplay> | 489 | <YueDisplay> |
| 471 | 490 | ||
| 472 | ```yue | 491 | ```yue |
| @@ -487,6 +506,7 @@ BigBucket = class extends Bucket | |||
| 487 | 506 | ||
| 488 | assert Bucket.__name == "BigBucket" | 507 | assert Bucket.__name == "BigBucket" |
| 489 | ``` | 508 | ``` |
| 509 | |||
| 490 | <YueDisplay> | 510 | <YueDisplay> |
| 491 | 511 | ||
| 492 | ```yue | 512 | ```yue |
| @@ -503,6 +523,7 @@ Du kannst sogar den Körper weglassen und eine leere anonyme Klasse schreiben: | |||
| 503 | ```yuescript | 523 | ```yuescript |
| 504 | x = class | 524 | x = class |
| 505 | ``` | 525 | ``` |
| 526 | |||
| 506 | <YueDisplay> | 527 | <YueDisplay> |
| 507 | 528 | ||
| 508 | ```yue | 529 | ```yue |
| @@ -532,6 +553,7 @@ y\func! | |||
| 532 | 553 | ||
| 533 | assert y.__class.__parent ~= X -- X ist nicht die Elternklasse von Y | 554 | assert y.__class.__parent ~= X -- X ist nicht die Elternklasse von Y |
| 534 | ``` | 555 | ``` |
| 556 | |||
| 535 | <YueDisplay> | 557 | <YueDisplay> |
| 536 | 558 | ||
| 537 | ```yue | 559 | ```yue |
diff --git a/doc/docs/de/doc/objects/with-statement.md b/doc/docs/de/doc/objects/with-statement.md index 446f837..adeeda6 100644 --- a/doc/docs/de/doc/objects/with-statement.md +++ b/doc/docs/de/doc/objects/with-statement.md | |||
| @@ -15,6 +15,7 @@ with Person! | |||
| 15 | \save! | 15 | \save! |
| 16 | print .name | 16 | print .name |
| 17 | ``` | 17 | ``` |
| 18 | |||
| 18 | <YueDisplay> | 19 | <YueDisplay> |
| 19 | 20 | ||
| 20 | ```yue | 21 | ```yue |
| @@ -33,6 +34,7 @@ Das `with`-Statement kann auch als Ausdruck verwendet werden und gibt den Wert z | |||
| 33 | file = with File "Lieblingsessen.txt" | 34 | file = with File "Lieblingsessen.txt" |
| 34 | \set_encoding "utf8" | 35 | \set_encoding "utf8" |
| 35 | ``` | 36 | ``` |
| 37 | |||
| 36 | <YueDisplay> | 38 | <YueDisplay> |
| 37 | 39 | ||
| 38 | ```yue | 40 | ```yue |
| @@ -52,6 +54,7 @@ create_person = (name, relatives) -> | |||
| 52 | 54 | ||
| 53 | me = create_person "Leaf", [dad, mother, sister] | 55 | me = create_person "Leaf", [dad, mother, sister] |
| 54 | ``` | 56 | ``` |
| 57 | |||
| 55 | <YueDisplay> | 58 | <YueDisplay> |
| 56 | 59 | ||
| 57 | ```yue | 60 | ```yue |
| @@ -74,6 +77,7 @@ with str := "Hallo" | |||
| 74 | print "Original:", str | 77 | print "Original:", str |
| 75 | print "Großbuchstaben:", \upper! | 78 | print "Großbuchstaben:", \upper! |
| 76 | ``` | 79 | ``` |
| 80 | |||
| 77 | <YueDisplay> | 81 | <YueDisplay> |
| 78 | 82 | ||
| 79 | ```yue | 83 | ```yue |
| @@ -95,6 +99,7 @@ with tb | |||
| 95 | ["key-name"] = value | 99 | ["key-name"] = value |
| 96 | [] = "abc" -- an "tb" anhängen | 100 | [] = "abc" -- an "tb" anhängen |
| 97 | ``` | 101 | ``` |
| 102 | |||
| 98 | <YueDisplay> | 103 | <YueDisplay> |
| 99 | 104 | ||
| 100 | ```yue | 105 | ```yue |
| @@ -115,6 +120,7 @@ with tb | |||
| 115 | with? obj | 120 | with? obj |
| 116 | print obj.name | 121 | print obj.name |
| 117 | ``` | 122 | ``` |
| 123 | |||
| 118 | <YueDisplay> | 124 | <YueDisplay> |
| 119 | 125 | ||
| 120 | ```yue | 126 | ```yue |
diff --git a/doc/docs/de/doc/reference/the-yuescript-library.md b/doc/docs/de/doc/reference/the-yuescript-library.md index 1838ced..0c371bf 100644 --- a/doc/docs/de/doc/reference/the-yuescript-library.md +++ b/doc/docs/de/doc/reference/the-yuescript-library.md | |||
| @@ -17,6 +17,7 @@ Die YueScript-Sprachbibliothek. | |||
| 17 | Die YueScript-Version. | 17 | Die YueScript-Version. |
| 18 | 18 | ||
| 19 | **Signatur:** | 19 | **Signatur:** |
| 20 | |||
| 20 | ```lua | 21 | ```lua |
| 21 | version: string | 22 | version: string |
| 22 | ``` | 23 | ``` |
| @@ -30,6 +31,7 @@ version: string | |||
| 30 | Der Dateitrennzeichen-String der aktuellen Plattform. | 31 | Der Dateitrennzeichen-String der aktuellen Plattform. |
| 31 | 32 | ||
| 32 | **Signatur:** | 33 | **Signatur:** |
| 34 | |||
| 33 | ```lua | 35 | ```lua |
| 34 | dirsep: string | 36 | dirsep: string |
| 35 | ``` | 37 | ``` |
| @@ -43,6 +45,7 @@ dirsep: string | |||
| 43 | Der Cache für kompilierten Modulcode. | 45 | Der Cache für kompilierten Modulcode. |
| 44 | 46 | ||
| 45 | **Signatur:** | 47 | **Signatur:** |
| 48 | |||
| 46 | ```lua | 49 | ```lua |
| 47 | yue_compiled: {string: string} | 50 | yue_compiled: {string: string} |
| 48 | ``` | 51 | ``` |
| @@ -56,6 +59,7 @@ yue_compiled: {string: string} | |||
| 56 | Die YueScript-Compilerfunktion. Sie kompiliert YueScript-Code zu Lua-Code. | 59 | Die YueScript-Compilerfunktion. Sie kompiliert YueScript-Code zu Lua-Code. |
| 57 | 60 | ||
| 58 | **Signatur:** | 61 | **Signatur:** |
| 62 | |||
| 59 | ```lua | 63 | ```lua |
| 60 | to_lua: function(code: string, config?: Config): | 64 | to_lua: function(code: string, config?: Config): |
| 61 | --[[codes]] string | nil, | 65 | --[[codes]] string | nil, |
| @@ -65,17 +69,17 @@ to_lua: function(code: string, config?: Config): | |||
| 65 | 69 | ||
| 66 | **Parameter:** | 70 | **Parameter:** |
| 67 | 71 | ||
| 68 | | Parameter | Typ | Beschreibung | | 72 | | Parameter | Typ | Beschreibung | |
| 69 | | --- | --- | --- | | 73 | | --------- | ------ | --------------------------------- | |
| 70 | | code | string | Der YueScript-Code. | | 74 | | code | string | Der YueScript-Code. | |
| 71 | | config | Config | [Optional] Die Compiler-Optionen. | | 75 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 72 | 76 | ||
| 73 | **Rückgabe:** | 77 | **Rückgabe:** |
| 74 | 78 | ||
| 75 | | Rückgabetyp | Beschreibung | | 79 | | Rückgabetyp | Beschreibung | |
| 76 | | --- | --- | | 80 | | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | |
| 77 | | string \| nil | Der kompilierte Lua-Code oder `nil`, falls die Kompilierung fehlgeschlagen ist. | | 81 | | string \| nil | Der kompilierte Lua-Code oder `nil`, falls die Kompilierung fehlgeschlagen ist. | |
| 78 | | string \| nil | Die Fehlermeldung oder `nil`, falls die Kompilierung erfolgreich war. | | 82 | | string \| nil | Die Fehlermeldung oder `nil`, falls die Kompilierung erfolgreich war. | |
| 79 | | {{string, integer, integer}} \| nil | Die globalen Variablen im Code (mit Name, Zeile und Spalte) oder `nil`, wenn die Compiler-Option `lint_global` false ist. | | 83 | | {{string, integer, integer}} \| nil | Die globalen Variablen im Code (mit Name, Zeile und Spalte) oder `nil`, wenn die Compiler-Option `lint_global` false ist. | |
| 80 | 84 | ||
| 81 | ### file_exist | 85 | ### file_exist |
| @@ -87,21 +91,22 @@ to_lua: function(code: string, config?: Config): | |||
| 87 | Prüft, ob eine Quelldatei existiert. Kann überschrieben werden, um das Verhalten anzupassen. | 91 | Prüft, ob eine Quelldatei existiert. Kann überschrieben werden, um das Verhalten anzupassen. |
| 88 | 92 | ||
| 89 | **Signatur:** | 93 | **Signatur:** |
| 94 | |||
| 90 | ```lua | 95 | ```lua |
| 91 | file_exist: function(filename: string): boolean | 96 | file_exist: function(filename: string): boolean |
| 92 | ``` | 97 | ``` |
| 93 | 98 | ||
| 94 | **Parameter:** | 99 | **Parameter:** |
| 95 | 100 | ||
| 96 | | Parameter | Typ | Beschreibung | | 101 | | Parameter | Typ | Beschreibung | |
| 97 | | --- | --- | --- | | 102 | | --------- | ------ | -------------- | |
| 98 | | filename | string | Der Dateiname. | | 103 | | filename | string | Der Dateiname. | |
| 99 | 104 | ||
| 100 | **Rückgabe:** | 105 | **Rückgabe:** |
| 101 | 106 | ||
| 102 | | Rückgabetyp | Beschreibung | | 107 | | Rückgabetyp | Beschreibung | |
| 103 | | --- | --- | | 108 | | ----------- | ----------------------- | |
| 104 | | boolean | Ob die Datei existiert. | | 109 | | boolean | Ob die Datei existiert. | |
| 105 | 110 | ||
| 106 | ### read_file | 111 | ### read_file |
| 107 | 112 | ||
| @@ -112,21 +117,22 @@ file_exist: function(filename: string): boolean | |||
| 112 | Liest eine Quelldatei. Kann überschrieben werden, um das Verhalten anzupassen. | 117 | Liest eine Quelldatei. Kann überschrieben werden, um das Verhalten anzupassen. |
| 113 | 118 | ||
| 114 | **Signatur:** | 119 | **Signatur:** |
| 120 | |||
| 115 | ```lua | 121 | ```lua |
| 116 | read_file: function(filename: string): string | 122 | read_file: function(filename: string): string |
| 117 | ``` | 123 | ``` |
| 118 | 124 | ||
| 119 | **Parameter:** | 125 | **Parameter:** |
| 120 | 126 | ||
| 121 | | Parameter | Typ | Beschreibung | | 127 | | Parameter | Typ | Beschreibung | |
| 122 | | --- | --- | --- | | 128 | | --------- | ------ | -------------- | |
| 123 | | filename | string | Der Dateiname. | | 129 | | filename | string | Der Dateiname. | |
| 124 | 130 | ||
| 125 | **Rückgabe:** | 131 | **Rückgabe:** |
| 126 | 132 | ||
| 127 | | Rückgabetyp | Beschreibung | | 133 | | Rückgabetyp | Beschreibung | |
| 128 | | --- | --- | | 134 | | ----------- | ---------------- | |
| 129 | | string | Der Dateiinhalt. | | 135 | | string | Der Dateiinhalt. | |
| 130 | 136 | ||
| 131 | ### insert_loader | 137 | ### insert_loader |
| 132 | 138 | ||
| @@ -137,21 +143,22 @@ read_file: function(filename: string): string | |||
| 137 | Fügt den YueScript-Loader in die Package-Loader (Searcher) ein. | 143 | Fügt den YueScript-Loader in die Package-Loader (Searcher) ein. |
| 138 | 144 | ||
| 139 | **Signatur:** | 145 | **Signatur:** |
| 146 | |||
| 140 | ```lua | 147 | ```lua |
| 141 | insert_loader: function(pos?: integer): boolean | 148 | insert_loader: function(pos?: integer): boolean |
| 142 | ``` | 149 | ``` |
| 143 | 150 | ||
| 144 | **Parameter:** | 151 | **Parameter:** |
| 145 | 152 | ||
| 146 | | Parameter | Typ | Beschreibung | | 153 | | Parameter | Typ | Beschreibung | |
| 147 | | --- | --- | --- | | 154 | | --------- | ------- | ---------------------------------------------------------------------- | |
| 148 | | pos | integer | [Optional] Position, an der der Loader eingefügt wird. Standard ist 3. | | 155 | | pos | integer | [Optional] Position, an der der Loader eingefügt wird. Standard ist 3. | |
| 149 | 156 | ||
| 150 | **Rückgabe:** | 157 | **Rückgabe:** |
| 151 | 158 | ||
| 152 | | Rückgabetyp | Beschreibung | | 159 | | Rückgabetyp | Beschreibung | |
| 153 | | --- | --- | | 160 | | ----------- | ------------------------------------------------------------------------------------ | |
| 154 | | boolean | Ob der Loader erfolgreich eingefügt wurde. Scheitert, wenn er bereits eingefügt ist. | | 161 | | boolean | Ob der Loader erfolgreich eingefügt wurde. Scheitert, wenn er bereits eingefügt ist. | |
| 155 | 162 | ||
| 156 | ### remove_loader | 163 | ### remove_loader |
| 157 | 164 | ||
| @@ -162,15 +169,16 @@ insert_loader: function(pos?: integer): boolean | |||
| 162 | Entfernt den YueScript-Loader aus den Package-Loadern (Searchern). | 169 | Entfernt den YueScript-Loader aus den Package-Loadern (Searchern). |
| 163 | 170 | ||
| 164 | **Signatur:** | 171 | **Signatur:** |
| 172 | |||
| 165 | ```lua | 173 | ```lua |
| 166 | remove_loader: function(): boolean | 174 | remove_loader: function(): boolean |
| 167 | ``` | 175 | ``` |
| 168 | 176 | ||
| 169 | **Rückgabe:** | 177 | **Rückgabe:** |
| 170 | 178 | ||
| 171 | | Rückgabetyp | Beschreibung | | 179 | | Rückgabetyp | Beschreibung | |
| 172 | | --- | --- | | 180 | | ----------- | --------------------------------------------------------------------------------- | |
| 173 | | boolean | Ob der Loader erfolgreich entfernt wurde. Scheitert, wenn er nicht eingefügt ist. | | 181 | | boolean | Ob der Loader erfolgreich entfernt wurde. Scheitert, wenn er nicht eingefügt ist. | |
| 174 | 182 | ||
| 175 | ### loadstring | 183 | ### loadstring |
| 176 | 184 | ||
| @@ -181,6 +189,7 @@ remove_loader: function(): boolean | |||
| 181 | Lädt YueScript-Code aus einem String in eine Funktion. | 189 | Lädt YueScript-Code aus einem String in eine Funktion. |
| 182 | 190 | ||
| 183 | **Signatur:** | 191 | **Signatur:** |
| 192 | |||
| 184 | ```lua | 193 | ```lua |
| 185 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): | 194 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): |
| 186 | --[[loaded function]] nil | function(...: any): (any...), | 195 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -189,19 +198,19 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 189 | 198 | ||
| 190 | **Parameter:** | 199 | **Parameter:** |
| 191 | 200 | ||
| 192 | | Parameter | Typ | Beschreibung | | 201 | | Parameter | Typ | Beschreibung | |
| 193 | | --- | --- | --- | | 202 | | --------- | ------ | --------------------------------- | |
| 194 | | input | string | Der YueScript-Code. | | 203 | | input | string | Der YueScript-Code. | |
| 195 | | chunkname | string | Der Name des Code-Chunks. | | 204 | | chunkname | string | Der Name des Code-Chunks. | |
| 196 | | env | table | Die Environment-Tabelle. | | 205 | | env | table | Die Environment-Tabelle. | |
| 197 | | config | Config | [Optional] Die Compiler-Optionen. | | 206 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 198 | 207 | ||
| 199 | **Rückgabe:** | 208 | **Rückgabe:** |
| 200 | 209 | ||
| 201 | | Rückgabetyp | Beschreibung | | 210 | | Rückgabetyp | Beschreibung | |
| 202 | | --- | --- | | 211 | | --------------- | --------------------------------------------------------------------- | |
| 203 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | | 212 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | |
| 204 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | | 213 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | |
| 205 | 214 | ||
| 206 | ### loadstring | 215 | ### loadstring |
| 207 | 216 | ||
| @@ -212,6 +221,7 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 212 | Lädt YueScript-Code aus einem String in eine Funktion. | 221 | Lädt YueScript-Code aus einem String in eine Funktion. |
| 213 | 222 | ||
| 214 | **Signatur:** | 223 | **Signatur:** |
| 224 | |||
| 215 | ```lua | 225 | ```lua |
| 216 | loadstring: function(input: string, chunkname: string, config?: Config): | 226 | loadstring: function(input: string, chunkname: string, config?: Config): |
| 217 | --[[loaded function]] nil | function(...: any): (any...), | 227 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -220,18 +230,18 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 220 | 230 | ||
| 221 | **Parameter:** | 231 | **Parameter:** |
| 222 | 232 | ||
| 223 | | Parameter | Typ | Beschreibung | | 233 | | Parameter | Typ | Beschreibung | |
| 224 | | --- | --- | --- | | 234 | | --------- | ------ | --------------------------------- | |
| 225 | | input | string | Der YueScript-Code. | | 235 | | input | string | Der YueScript-Code. | |
| 226 | | chunkname | string | Der Name des Code-Chunks. | | 236 | | chunkname | string | Der Name des Code-Chunks. | |
| 227 | | config | Config | [Optional] Die Compiler-Optionen. | | 237 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 228 | 238 | ||
| 229 | **Rückgabe:** | 239 | **Rückgabe:** |
| 230 | 240 | ||
| 231 | | Rückgabetyp | Beschreibung | | 241 | | Rückgabetyp | Beschreibung | |
| 232 | | --- | --- | | 242 | | --------------- | --------------------------------------------------------------------- | |
| 233 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | | 243 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | |
| 234 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | | 244 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | |
| 235 | 245 | ||
| 236 | ### loadstring | 246 | ### loadstring |
| 237 | 247 | ||
| @@ -242,6 +252,7 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 242 | Lädt YueScript-Code aus einem String in eine Funktion. | 252 | Lädt YueScript-Code aus einem String in eine Funktion. |
| 243 | 253 | ||
| 244 | **Signatur:** | 254 | **Signatur:** |
| 255 | |||
| 245 | ```lua | 256 | ```lua |
| 246 | loadstring: function(input: string, config?: Config): | 257 | loadstring: function(input: string, config?: Config): |
| 247 | --[[loaded function]] nil | function(...: any): (any...), | 258 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -250,17 +261,17 @@ loadstring: function(input: string, config?: Config): | |||
| 250 | 261 | ||
| 251 | **Parameter:** | 262 | **Parameter:** |
| 252 | 263 | ||
| 253 | | Parameter | Typ | Beschreibung | | 264 | | Parameter | Typ | Beschreibung | |
| 254 | | --- | --- | --- | | 265 | | --------- | ------ | --------------------------------- | |
| 255 | | input | string | Der YueScript-Code. | | 266 | | input | string | Der YueScript-Code. | |
| 256 | | config | Config | [Optional] Die Compiler-Optionen. | | 267 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 257 | 268 | ||
| 258 | **Rückgabe:** | 269 | **Rückgabe:** |
| 259 | 270 | ||
| 260 | | Rückgabetyp | Beschreibung | | 271 | | Rückgabetyp | Beschreibung | |
| 261 | | --- | --- | | 272 | | --------------- | --------------------------------------------------------------------- | |
| 262 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | | 273 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | |
| 263 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | | 274 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | |
| 264 | 275 | ||
| 265 | ### loadfile | 276 | ### loadfile |
| 266 | 277 | ||
| @@ -271,6 +282,7 @@ loadstring: function(input: string, config?: Config): | |||
| 271 | Lädt YueScript-Code aus einer Datei in eine Funktion. | 282 | Lädt YueScript-Code aus einer Datei in eine Funktion. |
| 272 | 283 | ||
| 273 | **Signatur:** | 284 | **Signatur:** |
| 285 | |||
| 274 | ```lua | 286 | ```lua |
| 275 | loadfile: function(filename: string, env: table, config?: Config): | 287 | loadfile: function(filename: string, env: table, config?: Config): |
| 276 | nil | function(...: any): (any...), | 288 | nil | function(...: any): (any...), |
| @@ -279,18 +291,18 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 279 | 291 | ||
| 280 | **Parameter:** | 292 | **Parameter:** |
| 281 | 293 | ||
| 282 | | Parameter | Typ | Beschreibung | | 294 | | Parameter | Typ | Beschreibung | |
| 283 | | --- | --- | --- | | 295 | | --------- | ------ | --------------------------------- | |
| 284 | | filename | string | Der Dateiname. | | 296 | | filename | string | Der Dateiname. | |
| 285 | | env | table | Die Environment-Tabelle. | | 297 | | env | table | Die Environment-Tabelle. | |
| 286 | | config | Config | [Optional] Die Compiler-Optionen. | | 298 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 287 | 299 | ||
| 288 | **Rückgabe:** | 300 | **Rückgabe:** |
| 289 | 301 | ||
| 290 | | Rückgabetyp | Beschreibung | | 302 | | Rückgabetyp | Beschreibung | |
| 291 | | --- | --- | | 303 | | --------------- | --------------------------------------------------------------------- | |
| 292 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | | 304 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | |
| 293 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | | 305 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | |
| 294 | 306 | ||
| 295 | ### loadfile | 307 | ### loadfile |
| 296 | 308 | ||
| @@ -301,6 +313,7 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 301 | Lädt YueScript-Code aus einer Datei in eine Funktion. | 313 | Lädt YueScript-Code aus einer Datei in eine Funktion. |
| 302 | 314 | ||
| 303 | **Signatur:** | 315 | **Signatur:** |
| 316 | |||
| 304 | ```lua | 317 | ```lua |
| 305 | loadfile: function(filename: string, config?: Config): | 318 | loadfile: function(filename: string, config?: Config): |
| 306 | nil | function(...: any): (any...), | 319 | nil | function(...: any): (any...), |
| @@ -309,17 +322,17 @@ loadfile: function(filename: string, config?: Config): | |||
| 309 | 322 | ||
| 310 | **Parameter:** | 323 | **Parameter:** |
| 311 | 324 | ||
| 312 | | Parameter | Typ | Beschreibung | | 325 | | Parameter | Typ | Beschreibung | |
| 313 | | --- | --- | --- | | 326 | | --------- | ------ | --------------------------------- | |
| 314 | | filename | string | Der Dateiname. | | 327 | | filename | string | Der Dateiname. | |
| 315 | | config | Config | [Optional] Die Compiler-Optionen. | | 328 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 316 | 329 | ||
| 317 | **Rückgabe:** | 330 | **Rückgabe:** |
| 318 | 331 | ||
| 319 | | Rückgabetyp | Beschreibung | | 332 | | Rückgabetyp | Beschreibung | |
| 320 | | --- | --- | | 333 | | --------------- | --------------------------------------------------------------------- | |
| 321 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | | 334 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | |
| 322 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | | 335 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | |
| 323 | 336 | ||
| 324 | ### dofile | 337 | ### dofile |
| 325 | 338 | ||
| @@ -330,23 +343,24 @@ loadfile: function(filename: string, config?: Config): | |||
| 330 | Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. | 343 | Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. |
| 331 | 344 | ||
| 332 | **Signatur:** | 345 | **Signatur:** |
| 346 | |||
| 333 | ```lua | 347 | ```lua |
| 334 | dofile: function(filename: string, env: table, config?: Config): any... | 348 | dofile: function(filename: string, env: table, config?: Config): any... |
| 335 | ``` | 349 | ``` |
| 336 | 350 | ||
| 337 | **Parameter:** | 351 | **Parameter:** |
| 338 | 352 | ||
| 339 | | Parameter | Typ | Beschreibung | | 353 | | Parameter | Typ | Beschreibung | |
| 340 | | --- | --- | --- | | 354 | | --------- | ------ | --------------------------------- | |
| 341 | | filename | string | Der Dateiname. | | 355 | | filename | string | Der Dateiname. | |
| 342 | | env | table | Die Environment-Tabelle. | | 356 | | env | table | Die Environment-Tabelle. | |
| 343 | | config | Config | [Optional] Die Compiler-Optionen. | | 357 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 344 | 358 | ||
| 345 | **Rückgabe:** | 359 | **Rückgabe:** |
| 346 | 360 | ||
| 347 | | Rückgabetyp | Beschreibung | | 361 | | Rückgabetyp | Beschreibung | |
| 348 | | --- | --- | | 362 | | ----------- | ----------------------------------------- | |
| 349 | | any... | Die Rückgabewerte der geladenen Funktion. | | 363 | | any... | Die Rückgabewerte der geladenen Funktion. | |
| 350 | 364 | ||
| 351 | ### dofile | 365 | ### dofile |
| 352 | 366 | ||
| @@ -357,22 +371,23 @@ dofile: function(filename: string, env: table, config?: Config): any... | |||
| 357 | Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. | 371 | Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. |
| 358 | 372 | ||
| 359 | **Signatur:** | 373 | **Signatur:** |
| 374 | |||
| 360 | ```lua | 375 | ```lua |
| 361 | dofile: function(filename: string, config?: Config): any... | 376 | dofile: function(filename: string, config?: Config): any... |
| 362 | ``` | 377 | ``` |
| 363 | 378 | ||
| 364 | **Parameter:** | 379 | **Parameter:** |
| 365 | 380 | ||
| 366 | | Parameter | Typ | Beschreibung | | 381 | | Parameter | Typ | Beschreibung | |
| 367 | | --- | --- | --- | | 382 | | --------- | ------ | --------------------------------- | |
| 368 | | filename | string | Der Dateiname. | | 383 | | filename | string | Der Dateiname. | |
| 369 | | config | Config | [Optional] Die Compiler-Optionen. | | 384 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 370 | 385 | ||
| 371 | **Rückgabe:** | 386 | **Rückgabe:** |
| 372 | 387 | ||
| 373 | | Rückgabetyp | Beschreibung | | 388 | | Rückgabetyp | Beschreibung | |
| 374 | | --- | --- | | 389 | | ----------- | ----------------------------------------- | |
| 375 | | any... | Die Rückgabewerte der geladenen Funktion. | | 390 | | any... | Die Rückgabewerte der geladenen Funktion. | |
| 376 | 391 | ||
| 377 | ### find_modulepath | 392 | ### find_modulepath |
| 378 | 393 | ||
| @@ -383,21 +398,22 @@ dofile: function(filename: string, config?: Config): any... | |||
| 383 | Löst den YueScript-Modulnamen in einen Dateipfad auf. | 398 | Löst den YueScript-Modulnamen in einen Dateipfad auf. |
| 384 | 399 | ||
| 385 | **Signatur:** | 400 | **Signatur:** |
| 401 | |||
| 386 | ```lua | 402 | ```lua |
| 387 | find_modulepath: function(name: string): string | 403 | find_modulepath: function(name: string): string |
| 388 | ``` | 404 | ``` |
| 389 | 405 | ||
| 390 | **Parameter:** | 406 | **Parameter:** |
| 391 | 407 | ||
| 392 | | Parameter | Typ | Beschreibung | | 408 | | Parameter | Typ | Beschreibung | |
| 393 | | --- | --- | --- | | 409 | | --------- | ------ | -------------- | |
| 394 | | name | string | Der Modulname. | | 410 | | name | string | Der Modulname. | |
| 395 | 411 | ||
| 396 | **Rückgabe:** | 412 | **Rückgabe:** |
| 397 | 413 | ||
| 398 | | Rückgabetyp | Beschreibung | | 414 | | Rückgabetyp | Beschreibung | |
| 399 | | --- | --- | | 415 | | ----------- | -------------- | |
| 400 | | string | Der Dateipfad. | | 416 | | string | Der Dateipfad. | |
| 401 | 417 | ||
| 402 | ### pcall | 418 | ### pcall |
| 403 | 419 | ||
| @@ -410,21 +426,22 @@ Fängt Fehler ab und gibt einen Statuscode sowie Ergebnisse oder ein Fehlerobjek | |||
| 410 | Schreibt die Fehlerzeilennummer bei Fehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. | 426 | Schreibt die Fehlerzeilennummer bei Fehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. |
| 411 | 427 | ||
| 412 | **Signatur:** | 428 | **Signatur:** |
| 429 | |||
| 413 | ```lua | 430 | ```lua |
| 414 | pcall: function(f: function, ...: any): boolean, any... | 431 | pcall: function(f: function, ...: any): boolean, any... |
| 415 | ``` | 432 | ``` |
| 416 | 433 | ||
| 417 | **Parameter:** | 434 | **Parameter:** |
| 418 | 435 | ||
| 419 | | Parameter | Typ | Beschreibung | | 436 | | Parameter | Typ | Beschreibung | |
| 420 | | --- | --- | --- | | 437 | | --------- | -------- | --------------------------- | |
| 421 | | f | function | Die aufzurufende Funktion. | | 438 | | f | function | Die aufzurufende Funktion. | |
| 422 | | ... | any | Argumente für die Funktion. | | 439 | | ... | any | Argumente für die Funktion. | |
| 423 | 440 | ||
| 424 | **Rückgabe:** | 441 | **Rückgabe:** |
| 425 | 442 | ||
| 426 | | Rückgabetyp | Beschreibung | | 443 | | Rückgabetyp | Beschreibung | |
| 427 | | --- | --- | | 444 | | ------------ | ---------------------------------------------------- | |
| 428 | | boolean, ... | Statuscode und Funktionsresultate oder Fehlerobjekt. | | 445 | | boolean, ... | Statuscode und Funktionsresultate oder Fehlerobjekt. | |
| 429 | 446 | ||
| 430 | ### require | 447 | ### require |
| @@ -437,21 +454,22 @@ Lädt ein Modul (Lua oder YueScript). | |||
| 437 | Schreibt die Fehlerzeilennummer auf die ursprüngliche Zeilennummer im YueScript-Code um, wenn das Modul ein YueScript-Modul ist und das Laden fehlschlägt. | 454 | Schreibt die Fehlerzeilennummer auf die ursprüngliche Zeilennummer im YueScript-Code um, wenn das Modul ein YueScript-Modul ist und das Laden fehlschlägt. |
| 438 | 455 | ||
| 439 | **Signatur:** | 456 | **Signatur:** |
| 457 | |||
| 440 | ```lua | 458 | ```lua |
| 441 | require: function(name: string): any... | 459 | require: function(name: string): any... |
| 442 | ``` | 460 | ``` |
| 443 | 461 | ||
| 444 | **Parameter:** | 462 | **Parameter:** |
| 445 | 463 | ||
| 446 | | Parameter | Typ | Beschreibung | | 464 | | Parameter | Typ | Beschreibung | |
| 447 | | --- | --- | --- | | 465 | | --------- | ------ | -------------------------------- | |
| 448 | | modname | string | Der Name des zu ladenden Moduls. | | 466 | | modname | string | Der Name des zu ladenden Moduls. | |
| 449 | 467 | ||
| 450 | **Rückgabe:** | 468 | **Rückgabe:** |
| 451 | 469 | ||
| 452 | | Rückgabetyp | Beschreibung | | 470 | | Rückgabetyp | Beschreibung | |
| 453 | | --- | --- | | 471 | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
| 454 | | 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. | | 472 | | 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. | |
| 455 | 473 | ||
| 456 | ### p | 474 | ### p |
| 457 | 475 | ||
| @@ -462,15 +480,16 @@ require: function(name: string): any... | |||
| 462 | Inspiziert die Struktur der übergebenen Werte und gibt String-Repräsentationen aus. | 480 | Inspiziert die Struktur der übergebenen Werte und gibt String-Repräsentationen aus. |
| 463 | 481 | ||
| 464 | **Signatur:** | 482 | **Signatur:** |
| 483 | |||
| 465 | ```lua | 484 | ```lua |
| 466 | p: function(...: any) | 485 | p: function(...: any) |
| 467 | ``` | 486 | ``` |
| 468 | 487 | ||
| 469 | **Parameter:** | 488 | **Parameter:** |
| 470 | 489 | ||
| 471 | | Parameter | Typ | Beschreibung | | 490 | | Parameter | Typ | Beschreibung | |
| 472 | | --- | --- | --- | | 491 | | --------- | --- | ---------------------------- | |
| 473 | | ... | any | Die zu inspizierenden Werte. | | 492 | | ... | any | Die zu inspizierenden Werte. | |
| 474 | 493 | ||
| 475 | ### options | 494 | ### options |
| 476 | 495 | ||
| @@ -481,6 +500,7 @@ p: function(...: any) | |||
| 481 | Die aktuellen Compiler-Optionen. | 500 | Die aktuellen Compiler-Optionen. |
| 482 | 501 | ||
| 483 | **Signatur:** | 502 | **Signatur:** |
| 503 | |||
| 484 | ```lua | 504 | ```lua |
| 485 | options: Config.Options | 505 | options: Config.Options |
| 486 | ``` | 506 | ``` |
| @@ -494,21 +514,22 @@ options: Config.Options | |||
| 494 | Die Traceback-Funktion, die Stacktrace-Zeilennummern auf die ursprünglichen Zeilennummern im YueScript-Code umschreibt. | 514 | Die Traceback-Funktion, die Stacktrace-Zeilennummern auf die ursprünglichen Zeilennummern im YueScript-Code umschreibt. |
| 495 | 515 | ||
| 496 | **Signatur:** | 516 | **Signatur:** |
| 517 | |||
| 497 | ```lua | 518 | ```lua |
| 498 | traceback: function(message: string): string | 519 | traceback: function(message: string): string |
| 499 | ``` | 520 | ``` |
| 500 | 521 | ||
| 501 | **Parameter:** | 522 | **Parameter:** |
| 502 | 523 | ||
| 503 | | Parameter | Typ | Beschreibung | | 524 | | Parameter | Typ | Beschreibung | |
| 504 | | --- | --- | --- | | 525 | | --------- | ------ | ------------------------ | |
| 505 | | message | string | Die Traceback-Nachricht. | | 526 | | message | string | Die Traceback-Nachricht. | |
| 506 | 527 | ||
| 507 | **Rückgabe:** | 528 | **Rückgabe:** |
| 508 | 529 | ||
| 509 | | Rückgabetyp | Beschreibung | | 530 | | Rückgabetyp | Beschreibung | |
| 510 | | --- | --- | | 531 | | ----------- | --------------------------------------- | |
| 511 | | string | Die umgeschriebene Traceback-Nachricht. | | 532 | | string | Die umgeschriebene Traceback-Nachricht. | |
| 512 | 533 | ||
| 513 | ### is_ast | 534 | ### is_ast |
| 514 | 535 | ||
| @@ -519,22 +540,23 @@ traceback: function(message: string): string | |||
| 519 | Prüft, ob der Code dem angegebenen AST entspricht. | 540 | Prüft, ob der Code dem angegebenen AST entspricht. |
| 520 | 541 | ||
| 521 | **Signatur:** | 542 | **Signatur:** |
| 543 | |||
| 522 | ```lua | 544 | ```lua |
| 523 | is_ast: function(astName: string, code: string): boolean | 545 | is_ast: function(astName: string, code: string): boolean |
| 524 | ``` | 546 | ``` |
| 525 | 547 | ||
| 526 | **Parameter:** | 548 | **Parameter:** |
| 527 | 549 | ||
| 528 | | Parameter | Typ | Beschreibung | | 550 | | Parameter | Typ | Beschreibung | |
| 529 | | --- | --- | --- | | 551 | | --------- | ------ | ------------- | |
| 530 | | astName | string | Der AST-Name. | | 552 | | astName | string | Der AST-Name. | |
| 531 | | code | string | Der Code. | | 553 | | code | string | Der Code. | |
| 532 | 554 | ||
| 533 | **Rückgabe:** | 555 | **Rückgabe:** |
| 534 | 556 | ||
| 535 | | Rückgabetyp | Beschreibung | | 557 | | Rückgabetyp | Beschreibung | |
| 536 | | --- | --- | | 558 | | ----------- | ------------------------------- | |
| 537 | | boolean | Ob der Code dem AST entspricht. | | 559 | | boolean | Ob der Code dem AST entspricht. | |
| 538 | 560 | ||
| 539 | ### AST | 561 | ### AST |
| 540 | 562 | ||
| @@ -545,6 +567,7 @@ is_ast: function(astName: string, code: string): boolean | |||
| 545 | Die AST-Typdefinition mit Name, Zeile, Spalte und Unterknoten. | 567 | Die AST-Typdefinition mit Name, Zeile, Spalte und Unterknoten. |
| 546 | 568 | ||
| 547 | **Signatur:** | 569 | **Signatur:** |
| 570 | |||
| 548 | ```lua | 571 | ```lua |
| 549 | type AST = {string, integer, integer, any} | 572 | type AST = {string, integer, integer, any} |
| 550 | ``` | 573 | ``` |
| @@ -558,6 +581,7 @@ type AST = {string, integer, integer, any} | |||
| 558 | Konvertiert Code in AST. | 581 | Konvertiert Code in AST. |
| 559 | 582 | ||
| 560 | **Signatur:** | 583 | **Signatur:** |
| 584 | |||
| 561 | ```lua | 585 | ```lua |
| 562 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): | 586 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): |
| 563 | --[[AST]] AST | nil, | 587 | --[[AST]] AST | nil, |
| @@ -566,18 +590,18 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 566 | 590 | ||
| 567 | **Parameter:** | 591 | **Parameter:** |
| 568 | 592 | ||
| 569 | | Parameter | Typ | Beschreibung | | 593 | | Parameter | Typ | Beschreibung | |
| 570 | | --- | --- | --- | | 594 | | -------------- | ------- | -------------------------------------------------------------------------------------------- | |
| 571 | | code | string | Der Code. | | 595 | | code | string | Der Code. | |
| 572 | | flattenLevel | integer | [Optional] Der Flatten-Level. Höher bedeutet mehr Flattening. Standard ist 0. Maximum ist 2. | | 596 | | flattenLevel | integer | [Optional] Der Flatten-Level. Höher bedeutet mehr Flattening. Standard ist 0. Maximum ist 2. | |
| 573 | | astName | string | [Optional] Der AST-Name. Standard ist "File". | | 597 | | astName | string | [Optional] Der AST-Name. Standard ist "File". | |
| 574 | | reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist false. | | 598 | | reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist false. | |
| 575 | 599 | ||
| 576 | **Rückgabe:** | 600 | **Rückgabe:** |
| 577 | 601 | ||
| 578 | | Rückgabetyp | Beschreibung | | 602 | | Rückgabetyp | Beschreibung | |
| 579 | | --- | --- | | 603 | | ------------- | ---------------------------------------------------------------------- | |
| 580 | | AST \| nil | Der AST oder `nil`, falls die Konvertierung fehlgeschlagen ist. | | 604 | | AST \| nil | Der AST oder `nil`, falls die Konvertierung fehlgeschlagen ist. | |
| 581 | | string \| nil | Die Fehlermeldung oder `nil`, falls die Konvertierung erfolgreich war. | | 605 | | string \| nil | Die Fehlermeldung oder `nil`, falls die Konvertierung erfolgreich war. | |
| 582 | 606 | ||
| 583 | ### format | 607 | ### format |
| @@ -589,25 +613,26 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 589 | Formatiert den YueScript-Code. | 613 | Formatiert den YueScript-Code. |
| 590 | 614 | ||
| 591 | **Signatur:** | 615 | **Signatur:** |
| 616 | |||
| 592 | ```lua | 617 | ```lua |
| 593 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string | 618 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string |
| 594 | ``` | 619 | ``` |
| 595 | 620 | ||
| 596 | **Parameter:** | 621 | **Parameter:** |
| 597 | 622 | ||
| 598 | | Parameter | Typ | Beschreibung | | 623 | | Parameter | Typ | Beschreibung | |
| 599 | | --- | --- | --- | | 624 | | -------------- | ------- | ---------------------------------------------------------------------------------- | |
| 600 | | code | string | Der Code. | | 625 | | code | string | Der Code. | |
| 601 | | tabSize | integer | [Optional] Die Tab-Größe. Standard ist 4. | | 626 | | tabSize | integer | [Optional] Die Tab-Größe. Standard ist 4. | |
| 602 | | reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist true. | | 627 | | reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist true. | |
| 603 | 628 | ||
| 604 | **Rückgabe:** | 629 | **Rückgabe:** |
| 605 | 630 | ||
| 606 | | Rückgabetyp | Beschreibung | | 631 | | Rückgabetyp | Beschreibung | |
| 607 | | --- | --- | | 632 | | ----------- | --------------------- | |
| 608 | | string | Der formatierte Code. | | 633 | | string | Der formatierte Code. | |
| 609 | 634 | ||
| 610 | ### __call | 635 | ### \_\_call |
| 611 | 636 | ||
| 612 | **Typ:** Metamethod. | 637 | **Typ:** Metamethod. |
| 613 | 638 | ||
| @@ -617,21 +642,22 @@ Required das YueScript-Modul. | |||
| 617 | Schreibt die Fehlerzeilennummer bei Ladefehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. | 642 | Schreibt die Fehlerzeilennummer bei Ladefehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. |
| 618 | 643 | ||
| 619 | **Signatur:** | 644 | **Signatur:** |
| 645 | |||
| 620 | ```lua | 646 | ```lua |
| 621 | metamethod __call: function(self: yue, module: string): any... | 647 | metamethod __call: function(self: yue, module: string): any... |
| 622 | ``` | 648 | ``` |
| 623 | 649 | ||
| 624 | **Parameter:** | 650 | **Parameter:** |
| 625 | 651 | ||
| 626 | | Parameter | Typ | Beschreibung | | 652 | | Parameter | Typ | Beschreibung | |
| 627 | | --- | --- | --- | | 653 | | --------- | ------ | -------------- | |
| 628 | | module | string | Der Modulname. | | 654 | | module | string | Der Modulname. | |
| 629 | 655 | ||
| 630 | **Rückgabe:** | 656 | **Rückgabe:** |
| 631 | 657 | ||
| 632 | | Rückgabetyp | Beschreibung | | 658 | | Rückgabetyp | Beschreibung | |
| 633 | | --- | --- | | 659 | | ----------- | -------------- | |
| 634 | | any | Der Modulwert. | | 660 | | any | Der Modulwert. | |
| 635 | 661 | ||
| 636 | ## Config | 662 | ## Config |
| 637 | 663 | ||
| @@ -648,6 +674,7 @@ Die Compiler-Optionen. | |||
| 648 | Ob der Compiler die globalen Variablen im Code sammeln soll. | 674 | Ob der Compiler die globalen Variablen im Code sammeln soll. |
| 649 | 675 | ||
| 650 | **Signatur:** | 676 | **Signatur:** |
| 677 | |||
| 651 | ```lua | 678 | ```lua |
| 652 | lint_global: boolean | 679 | lint_global: boolean |
| 653 | ``` | 680 | ``` |
| @@ -661,6 +688,7 @@ lint_global: boolean | |||
| 661 | Ob der Compiler für den Root-Codeblock ein implizites Return verwenden soll. | 688 | Ob der Compiler für den Root-Codeblock ein implizites Return verwenden soll. |
| 662 | 689 | ||
| 663 | **Signatur:** | 690 | **Signatur:** |
| 691 | |||
| 664 | ```lua | 692 | ```lua |
| 665 | implicit_return_root: boolean | 693 | implicit_return_root: boolean |
| 666 | ``` | 694 | ``` |
| @@ -674,6 +702,7 @@ implicit_return_root: boolean | |||
| 674 | Ob der Compiler die ursprüngliche Zeilennummer im kompilierten Code beibehalten soll. | 702 | Ob der Compiler die ursprüngliche Zeilennummer im kompilierten Code beibehalten soll. |
| 675 | 703 | ||
| 676 | **Signatur:** | 704 | **Signatur:** |
| 705 | |||
| 677 | ```lua | 706 | ```lua |
| 678 | reserve_line_number: boolean | 707 | reserve_line_number: boolean |
| 679 | ``` | 708 | ``` |
| @@ -687,6 +716,7 @@ reserve_line_number: boolean | |||
| 687 | Ob der Compiler die ursprünglichen Kommentare im kompilierten Code beibehalten soll. | 716 | Ob der Compiler die ursprünglichen Kommentare im kompilierten Code beibehalten soll. |
| 688 | 717 | ||
| 689 | **Signatur:** | 718 | **Signatur:** |
| 719 | |||
| 690 | ```lua | 720 | ```lua |
| 691 | reserve_comment: boolean | 721 | reserve_comment: boolean |
| 692 | ``` | 722 | ``` |
| @@ -700,6 +730,7 @@ reserve_comment: boolean | |||
| 700 | Ob der Compiler statt Tabzeichen Leerzeichen verwenden soll. | 730 | Ob der Compiler statt Tabzeichen Leerzeichen verwenden soll. |
| 701 | 731 | ||
| 702 | **Signatur:** | 732 | **Signatur:** |
| 733 | |||
| 703 | ```lua | 734 | ```lua |
| 704 | space_over_tab: boolean | 735 | space_over_tab: boolean |
| 705 | ``` | 736 | ``` |
| @@ -713,6 +744,7 @@ space_over_tab: boolean | |||
| 713 | Ob der Compiler den zu kompilierenden Code als dasselbe aktuell kompilierte Modul behandeln soll. Nur für internen Gebrauch. | 744 | Ob der Compiler den zu kompilierenden Code als dasselbe aktuell kompilierte Modul behandeln soll. Nur für internen Gebrauch. |
| 714 | 745 | ||
| 715 | **Signatur:** | 746 | **Signatur:** |
| 747 | |||
| 716 | ```lua | 748 | ```lua |
| 717 | same_module: boolean | 749 | same_module: boolean |
| 718 | ``` | 750 | ``` |
| @@ -726,6 +758,7 @@ same_module: boolean | |||
| 726 | Ob die Compiler-Fehlermeldung einen Zeilennummern-Offset enthalten soll. Nur für internen Gebrauch. | 758 | Ob die Compiler-Fehlermeldung einen Zeilennummern-Offset enthalten soll. Nur für internen Gebrauch. |
| 727 | 759 | ||
| 728 | **Signatur:** | 760 | **Signatur:** |
| 761 | |||
| 729 | ```lua | 762 | ```lua |
| 730 | line_offset: integer | 763 | line_offset: integer |
| 731 | ``` | 764 | ``` |
| @@ -739,6 +772,7 @@ line_offset: integer | |||
| 739 | Die Ziel-Lua-Version. | 772 | Die Ziel-Lua-Version. |
| 740 | 773 | ||
| 741 | **Signatur:** | 774 | **Signatur:** |
| 775 | |||
| 742 | ```lua | 776 | ```lua |
| 743 | enum LuaTarget | 777 | enum LuaTarget |
| 744 | "5.1" | 778 | "5.1" |
| @@ -758,6 +792,7 @@ end | |||
| 758 | Zusätzliche Optionen für die Kompilierung. | 792 | Zusätzliche Optionen für die Kompilierung. |
| 759 | 793 | ||
| 760 | **Signatur:** | 794 | **Signatur:** |
| 795 | |||
| 761 | ```lua | 796 | ```lua |
| 762 | options: Options | 797 | options: Options |
| 763 | ``` | 798 | ``` |
| @@ -777,6 +812,7 @@ Zusätzliche Compiler-Optionen. | |||
| 777 | Die Ziel-Lua-Version für die Kompilierung. | 812 | Die Ziel-Lua-Version für die Kompilierung. |
| 778 | 813 | ||
| 779 | **Signatur:** | 814 | **Signatur:** |
| 815 | |||
| 780 | ```lua | 816 | ```lua |
| 781 | target: LuaTarget | 817 | target: LuaTarget |
| 782 | ``` | 818 | ``` |
| @@ -790,6 +826,7 @@ target: LuaTarget | |||
| 790 | Zusätzlicher Modul-Suchpfad. | 826 | Zusätzlicher Modul-Suchpfad. |
| 791 | 827 | ||
| 792 | **Signatur:** | 828 | **Signatur:** |
| 829 | |||
| 793 | ```lua | 830 | ```lua |
| 794 | path: string | 831 | path: string |
| 795 | ``` | 832 | ``` |
| @@ -803,6 +840,7 @@ path: string | |||
| 803 | Ob lokale Variablen in Traceback-Fehlermeldungen ausgegeben werden sollen. Standard ist false. | 840 | Ob lokale Variablen in Traceback-Fehlermeldungen ausgegeben werden sollen. Standard ist false. |
| 804 | 841 | ||
| 805 | **Signatur:** | 842 | **Signatur:** |
| 843 | |||
| 806 | ```lua | 844 | ```lua |
| 807 | dump_locals: boolean | 845 | dump_locals: boolean |
| 808 | ``` | 846 | ``` |
| @@ -816,6 +854,7 @@ dump_locals: boolean | |||
| 816 | Ob Fehlermeldungen vereinfacht werden sollen. Standard ist true. | 854 | Ob Fehlermeldungen vereinfacht werden sollen. Standard ist true. |
| 817 | 855 | ||
| 818 | **Signatur:** | 856 | **Signatur:** |
| 857 | |||
| 819 | ```lua | 858 | ```lua |
| 820 | simplified: boolean | 859 | simplified: boolean |
| 821 | ``` | 860 | ``` |
diff --git a/doc/docs/de/index.md b/doc/docs/de/index.md index 1a923b2..94bd00f 100644 --- a/doc/docs/de/index.md +++ b/doc/docs/de/index.md | |||
| @@ -21,4 +21,5 @@ footer: | |||
| 21 | message: MIT-Lizenz. | 21 | message: MIT-Lizenz. |
| 22 | copyright: Copyright © 2017-2026 Li Jin. Alle Rechte vorbehalten. | 22 | copyright: Copyright © 2017-2026 Li Jin. Alle Rechte vorbehalten. |
| 23 | --- | 23 | --- |
| 24 | |||
| 24 | --- | 25 | --- |
diff --git a/doc/docs/de/try/index.md b/doc/docs/de/try/index.md index f8c3193..4c17c6c 100755 --- a/doc/docs/de/try/index.md +++ b/doc/docs/de/try/index.md | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | # YueScript Online-Compiler | 1 | # YueScript Online-Compiler |
| 2 | |||
| 2 | --- | 3 | --- |
| 3 | 4 | ||
| 4 | Probiere YueScript im Browser mit WASM aus. | 5 | Probiere YueScript im Browser mit WASM aus. |
diff --git a/doc/docs/doc/advanced/do.md b/doc/docs/doc/advanced/do.md index 4990d6f..c4b3e30 100644 --- a/doc/docs/doc/advanced/do.md +++ b/doc/docs/doc/advanced/do.md | |||
| @@ -8,6 +8,7 @@ do | |||
| 8 | print var | 8 | print var |
| 9 | print var -- nil here | 9 | print var -- nil here |
| 10 | ``` | 10 | ``` |
| 11 | |||
| 11 | <YueDisplay> | 12 | <YueDisplay> |
| 12 | 13 | ||
| 13 | ```yue | 14 | ```yue |
| @@ -31,6 +32,7 @@ counter = do | |||
| 31 | print counter! | 32 | print counter! |
| 32 | print counter! | 33 | print counter! |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -53,6 +55,7 @@ tbl = { | |||
| 53 | 1234 | 55 | 1234 |
| 54 | } | 56 | } |
| 55 | ``` | 57 | ``` |
| 58 | |||
| 56 | <YueDisplay> | 59 | <YueDisplay> |
| 57 | 60 | ||
| 58 | ```yue | 61 | ```yue |
diff --git a/doc/docs/doc/advanced/line-decorators.md b/doc/docs/doc/advanced/line-decorators.md index 292bc77..16b447c 100644 --- a/doc/docs/doc/advanced/line-decorators.md +++ b/doc/docs/doc/advanced/line-decorators.md | |||
| @@ -5,6 +5,7 @@ For convenience, the for loop and if statement can be applied to single statemen | |||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | print "hello world" if name == "Rob" | 6 | print "hello world" if name == "Rob" |
| 7 | ``` | 7 | ``` |
| 8 | |||
| 8 | <YueDisplay> | 9 | <YueDisplay> |
| 9 | 10 | ||
| 10 | ```yue | 11 | ```yue |
| @@ -18,6 +19,7 @@ And with basic loops: | |||
| 18 | ```yuescript | 19 | ```yuescript |
| 19 | print "item: ", item for item in *items | 20 | print "item: ", item for item in *items |
| 20 | ``` | 21 | ``` |
| 22 | |||
| 21 | <YueDisplay> | 23 | <YueDisplay> |
| 22 | 24 | ||
| 23 | ```yue | 25 | ```yue |
| @@ -33,6 +35,7 @@ game\update! while game\isRunning! | |||
| 33 | 35 | ||
| 34 | reader\parse_line! until reader\eof! | 36 | reader\parse_line! until reader\eof! |
| 35 | ``` | 37 | ``` |
| 38 | |||
| 36 | <YueDisplay> | 39 | <YueDisplay> |
| 37 | 40 | ||
| 38 | ```yue | 41 | ```yue |
diff --git a/doc/docs/doc/advanced/macro.md b/doc/docs/doc/advanced/macro.md index 6d194c3..c057f40 100644 --- a/doc/docs/doc/advanced/macro.md +++ b/doc/docs/doc/advanced/macro.md | |||
| @@ -32,6 +32,7 @@ macro and = (...) -> "#{ table.concat {...}, ' and ' }" | |||
| 32 | if $and f1!, f2!, f3! | 32 | if $and f1!, f2!, f3! |
| 33 | print "OK" | 33 | print "OK" |
| 34 | ``` | 34 | ``` |
| 35 | |||
| 35 | <YueDisplay> | 36 | <YueDisplay> |
| 36 | 37 | ||
| 37 | ```yue | 38 | ```yue |
| @@ -68,6 +69,7 @@ if $and f1!, f2!, f3! | |||
| 68 | ## Insert Raw Codes | 69 | ## Insert Raw Codes |
| 69 | 70 | ||
| 70 | A macro function can either return a YueScript string or a config table containing Lua codes. | 71 | A macro function can either return a YueScript string or a config table containing Lua codes. |
| 72 | |||
| 71 | ```yuescript | 73 | ```yuescript |
| 72 | macro yueFunc = (var) -> "local #{var} = ->" | 74 | macro yueFunc = (var) -> "local #{var} = ->" |
| 73 | $yueFunc funcA | 75 | $yueFunc funcA |
| @@ -93,6 +95,7 @@ if cond then | |||
| 93 | end | 95 | end |
| 94 | ]==] | 96 | ]==] |
| 95 | ``` | 97 | ``` |
| 98 | |||
| 96 | <YueDisplay> | 99 | <YueDisplay> |
| 97 | 100 | ||
| 98 | ```yue | 101 | ```yue |
| @@ -126,6 +129,7 @@ end | |||
| 126 | ## Export Macro | 129 | ## Export Macro |
| 127 | 130 | ||
| 128 | Macro functions can be exported from a module and get imported in another module. You have to put export macro functions in a single file to be used, and only macro definition, macro importing and macro expansion in place can be put into the macro exporting module. | 131 | Macro functions can be exported from a module and get imported in another module. You have to put export macro functions in a single file to be used, and only macro definition, macro importing and macro expansion in place can be put into the macro exporting module. |
| 132 | |||
| 129 | ```yuescript | 133 | ```yuescript |
| 130 | -- file: utils.yue | 134 | -- file: utils.yue |
| 131 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" | 135 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" |
| @@ -140,6 +144,7 @@ import "utils" as { | |||
| 140 | } | 144 | } |
| 141 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ | 145 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ |
| 142 | ``` | 146 | ``` |
| 147 | |||
| 143 | <YueDisplay> | 148 | <YueDisplay> |
| 144 | 149 | ||
| 145 | ```yue | 150 | ```yue |
| @@ -165,10 +170,12 @@ import "utils" as { | |||
| 165 | ## Builtin Macro | 170 | ## Builtin Macro |
| 166 | 171 | ||
| 167 | There are some builtin macros but you can override them by declaring macros with the same names. | 172 | There are some builtin macros but you can override them by declaring macros with the same names. |
| 173 | |||
| 168 | ```yuescript | 174 | ```yuescript |
| 169 | print $FILE -- get string of current module name | 175 | print $FILE -- get string of current module name |
| 170 | print $LINE -- get number 2 | 176 | print $LINE -- get number 2 |
| 171 | ``` | 177 | ``` |
| 178 | |||
| 172 | <YueDisplay> | 179 | <YueDisplay> |
| 173 | 180 | ||
| 174 | ```yue | 181 | ```yue |
| @@ -235,6 +242,7 @@ macro printNumAndStr = (num `Num, str `String) -> | | |||
| 235 | 242 | ||
| 236 | $printNumAndStr 123, "hello" | 243 | $printNumAndStr 123, "hello" |
| 237 | ``` | 244 | ``` |
| 245 | |||
| 238 | <YueDisplay> | 246 | <YueDisplay> |
| 239 | 247 | ||
| 240 | ```yue | 248 | ```yue |
| @@ -259,6 +267,7 @@ macro printNumAndStr = (num, str) -> | |||
| 259 | 267 | ||
| 260 | $printNumAndStr 123, "hello" | 268 | $printNumAndStr 123, "hello" |
| 261 | ``` | 269 | ``` |
| 270 | |||
| 262 | <YueDisplay> | 271 | <YueDisplay> |
| 263 | 272 | ||
| 264 | ```yue | 273 | ```yue |
diff --git a/doc/docs/doc/advanced/module.md b/doc/docs/doc/advanced/module.md index c955092..0ba2d90 100644 --- a/doc/docs/doc/advanced/module.md +++ b/doc/docs/doc/advanced/module.md | |||
| @@ -28,6 +28,7 @@ do | |||
| 28 | import "lpeg" as :C, :Ct, :Cmt | 28 | import "lpeg" as :C, :Ct, :Cmt |
| 29 | import "export" as {one, two, Something:{umm:{ch}}} | 29 | import "export" as {one, two, Something:{umm:{ch}}} |
| 30 | ``` | 30 | ``` |
| 31 | |||
| 31 | <YueDisplay> | 32 | <YueDisplay> |
| 32 | 33 | ||
| 33 | ```yue | 34 | ```yue |
| @@ -67,6 +68,7 @@ do | |||
| 67 | import table.concat | 68 | import table.concat |
| 68 | print concat ["a", tostring 1] | 69 | print concat ["a", tostring 1] |
| 69 | ``` | 70 | ``` |
| 71 | |||
| 70 | <YueDisplay> | 72 | <YueDisplay> |
| 71 | 73 | ||
| 72 | ```yue | 74 | ```yue |
| @@ -98,6 +100,7 @@ do | |||
| 98 | print FLAG | 100 | print FLAG |
| 99 | FLAG = 123 | 101 | FLAG = 123 |
| 100 | ``` | 102 | ``` |
| 103 | |||
| 101 | <YueDisplay> | 104 | <YueDisplay> |
| 102 | 105 | ||
| 103 | ```yue | 106 | ```yue |
| @@ -140,6 +143,7 @@ export y = -> | |||
| 140 | export class Something | 143 | export class Something |
| 141 | umm: "cool" | 144 | umm: "cool" |
| 142 | ``` | 145 | ``` |
| 146 | |||
| 143 | <YueDisplay> | 147 | <YueDisplay> |
| 144 | 148 | ||
| 145 | ```yue | 149 | ```yue |
| @@ -166,6 +170,7 @@ Doing named export with destructuring. | |||
| 166 | export :loadstring, to_lua: tolua = yue | 170 | export :loadstring, to_lua: tolua = yue |
| 167 | export {itemA: {:fieldA = 'default'}} = tb | 171 | export {itemA: {:fieldA = 'default'}} = tb |
| 168 | ``` | 172 | ``` |
| 173 | |||
| 169 | <YueDisplay> | 174 | <YueDisplay> |
| 170 | 175 | ||
| 171 | ```yue | 176 | ```yue |
| @@ -182,6 +187,7 @@ export.itemA = tb | |||
| 182 | export.<index> = items | 187 | export.<index> = items |
| 183 | export["a-b-c"] = 123 | 188 | export["a-b-c"] = 123 |
| 184 | ``` | 189 | ``` |
| 190 | |||
| 185 | <YueDisplay> | 191 | <YueDisplay> |
| 186 | 192 | ||
| 187 | ```yue | 193 | ```yue |
| @@ -208,6 +214,7 @@ else | |||
| 208 | export with tmp | 214 | export with tmp |
| 209 | j = 2000 | 215 | j = 2000 |
| 210 | ``` | 216 | ``` |
| 217 | |||
| 211 | <YueDisplay> | 218 | <YueDisplay> |
| 212 | 219 | ||
| 213 | ```yue | 220 | ```yue |
| @@ -234,6 +241,7 @@ export default -> | |||
| 234 | print "hello" | 241 | print "hello" |
| 235 | 123 | 242 | 123 |
| 236 | ``` | 243 | ``` |
| 244 | |||
| 237 | <YueDisplay> | 245 | <YueDisplay> |
| 238 | 246 | ||
| 239 | ```yue | 247 | ```yue |
diff --git a/doc/docs/doc/advanced/try.md b/doc/docs/doc/advanced/try.md index 23c7877..c890f09 100644 --- a/doc/docs/doc/advanced/try.md +++ b/doc/docs/doc/advanced/try.md | |||
| @@ -29,6 +29,7 @@ catch err | |||
| 29 | print yue.traceback err | 29 | print yue.traceback err |
| 30 | print result | 30 | print result |
| 31 | ``` | 31 | ``` |
| 32 | |||
| 32 | <YueDisplay> | 33 | <YueDisplay> |
| 33 | 34 | ||
| 34 | ```yue | 35 | ```yue |
| @@ -82,6 +83,7 @@ catch e | |||
| 82 | print e | 83 | print e |
| 83 | e | 84 | e |
| 84 | ``` | 85 | ``` |
| 86 | |||
| 85 | <YueDisplay> | 87 | <YueDisplay> |
| 86 | 88 | ||
| 87 | ```yue | 89 | ```yue |
diff --git a/doc/docs/doc/assignment/assignment.md b/doc/docs/doc/assignment/assignment.md index 4dac6f4..cabbc45 100644 --- a/doc/docs/doc/assignment/assignment.md +++ b/doc/docs/doc/assignment/assignment.md | |||
| @@ -7,6 +7,7 @@ hello = "world" | |||
| 7 | a, b, c = 1, 2, 3 | 7 | a, b, c = 1, 2, 3 |
| 8 | hello = 123 -- uses the existing variable | 8 | hello = 123 -- uses the existing variable |
| 9 | ``` | 9 | ``` |
| 10 | |||
| 10 | <YueDisplay> | 11 | <YueDisplay> |
| 11 | 12 | ||
| 12 | ```yue | 13 | ```yue |
| @@ -20,6 +21,7 @@ hello = 123 -- uses the existing variable | |||
| 20 | ## Perform Update | 21 | ## Perform Update |
| 21 | 22 | ||
| 22 | You can perform update assignment with many binary operators. | 23 | You can perform update assignment with many binary operators. |
| 24 | |||
| 23 | ```yuescript | 25 | ```yuescript |
| 24 | x = 1 | 26 | x = 1 |
| 25 | x += 1 | 27 | x += 1 |
| @@ -30,6 +32,7 @@ x %= 10 | |||
| 30 | s ..= "world" -- will add a new local if local variable is not exist | 32 | s ..= "world" -- will add a new local if local variable is not exist |
| 31 | arg or= "default value" | 33 | arg or= "default value" |
| 32 | ``` | 34 | ``` |
| 35 | |||
| 33 | <YueDisplay> | 36 | <YueDisplay> |
| 34 | 37 | ||
| 35 | ```yue | 38 | ```yue |
| @@ -48,10 +51,12 @@ arg or= "default value" | |||
| 48 | ## Chaining Assignment | 51 | ## Chaining Assignment |
| 49 | 52 | ||
| 50 | You can do chaining assignment to assign multiple items to hold the same value. | 53 | You can do chaining assignment to assign multiple items to hold the same value. |
| 54 | |||
| 51 | ```yuescript | 55 | ```yuescript |
| 52 | a = b = c = d = e = 0 | 56 | a = b = c = d = e = 0 |
| 53 | x = y = z = f! | 57 | x = y = z = f! |
| 54 | ``` | 58 | ``` |
| 59 | |||
| 55 | <YueDisplay> | 60 | <YueDisplay> |
| 56 | 61 | ||
| 57 | ```yue | 62 | ```yue |
| @@ -62,6 +67,7 @@ x = y = z = f! | |||
| 62 | </YueDisplay> | 67 | </YueDisplay> |
| 63 | 68 | ||
| 64 | ## Explicit Locals | 69 | ## Explicit Locals |
| 70 | |||
| 65 | ```yuescript | 71 | ```yuescript |
| 66 | do | 72 | do |
| 67 | local a = 1 | 73 | local a = 1 |
| @@ -78,6 +84,7 @@ do | |||
| 78 | a = 1 | 84 | a = 1 |
| 79 | B = 2 | 85 | B = 2 |
| 80 | ``` | 86 | ``` |
| 87 | |||
| 81 | <YueDisplay> | 88 | <YueDisplay> |
| 82 | 89 | ||
| 83 | ```yue | 90 | ```yue |
| @@ -100,6 +107,7 @@ do | |||
| 100 | </YueDisplay> | 107 | </YueDisplay> |
| 101 | 108 | ||
| 102 | ## Explicit Globals | 109 | ## Explicit Globals |
| 110 | |||
| 103 | ```yuescript | 111 | ```yuescript |
| 104 | do | 112 | do |
| 105 | global a = 1 | 113 | global a = 1 |
| @@ -116,6 +124,7 @@ do | |||
| 116 | B = 2 | 124 | B = 2 |
| 117 | local Temp = "a local value" | 125 | local Temp = "a local value" |
| 118 | ``` | 126 | ``` |
| 127 | |||
| 119 | <YueDisplay> | 128 | <YueDisplay> |
| 120 | 129 | ||
| 121 | ```yue | 130 | ```yue |
diff --git a/doc/docs/doc/assignment/destructuring-assignment.md b/doc/docs/doc/assignment/destructuring-assignment.md index e7b8046..750f09e 100644 --- a/doc/docs/doc/assignment/destructuring-assignment.md +++ b/doc/docs/doc/assignment/destructuring-assignment.md | |||
| @@ -12,6 +12,7 @@ thing = [1, 2] | |||
| 12 | [a, b] = thing | 12 | [a, b] = thing |
| 13 | print a, b | 13 | print a, b |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -37,6 +38,7 @@ print hello, the_day | |||
| 37 | 38 | ||
| 38 | :day = obj -- OK to do simple destructuring without braces | 39 | :day = obj -- OK to do simple destructuring without braces |
| 39 | ``` | 40 | ``` |
| 41 | |||
| 40 | <YueDisplay> | 42 | <YueDisplay> |
| 41 | 43 | ||
| 42 | ```yue | 44 | ```yue |
| @@ -68,6 +70,7 @@ obj2 = { | |||
| 68 | {numbers: [first, second], properties: {color: color}} = obj2 | 70 | {numbers: [first, second], properties: {color: color}} = obj2 |
| 69 | print first, second, color | 71 | print first, second, color |
| 70 | ``` | 72 | ``` |
| 73 | |||
| 71 | <YueDisplay> | 74 | <YueDisplay> |
| 72 | 75 | ||
| 73 | ```yue | 76 | ```yue |
| @@ -95,6 +98,7 @@ If the destructuring statement is complicated, feel free to spread it out over a | |||
| 95 | } | 98 | } |
| 96 | } = obj2 | 99 | } = obj2 |
| 97 | ``` | 100 | ``` |
| 101 | |||
| 98 | <YueDisplay> | 102 | <YueDisplay> |
| 99 | 103 | ||
| 100 | ```yue | 104 | ```yue |
| @@ -113,6 +117,7 @@ It's common to extract values from at table and assign them the local variables | |||
| 113 | ```yuescript | 117 | ```yuescript |
| 114 | {:concat, :insert} = table | 118 | {:concat, :insert} = table |
| 115 | ``` | 119 | ``` |
| 120 | |||
| 116 | <YueDisplay> | 121 | <YueDisplay> |
| 117 | 122 | ||
| 118 | ```yue | 123 | ```yue |
| @@ -126,6 +131,7 @@ This is effectively the same as import, but we can rename fields we want to extr | |||
| 126 | ```yuescript | 131 | ```yuescript |
| 127 | {:mix, :max, random: rand} = math | 132 | {:mix, :max, random: rand} = math |
| 128 | ``` | 133 | ``` |
| 134 | |||
| 129 | <YueDisplay> | 135 | <YueDisplay> |
| 130 | 136 | ||
| 131 | ```yue | 137 | ```yue |
| @@ -139,6 +145,7 @@ You can write default values while doing destructuring like: | |||
| 139 | ```yuescript | 145 | ```yuescript |
| 140 | {:name = "nameless", :job = "jobless"} = person | 146 | {:name = "nameless", :job = "jobless"} = person |
| 141 | ``` | 147 | ``` |
| 148 | |||
| 142 | <YueDisplay> | 149 | <YueDisplay> |
| 143 | 150 | ||
| 144 | ```yue | 151 | ```yue |
| @@ -152,6 +159,7 @@ You can use `_` as placeholder when doing a list destructuring: | |||
| 152 | ```yuescript | 159 | ```yuescript |
| 153 | [_, two, _, four] = items | 160 | [_, two, _, four] = items |
| 154 | ``` | 161 | ``` |
| 162 | |||
| 155 | <YueDisplay> | 163 | <YueDisplay> |
| 156 | 164 | ||
| 157 | ```yue | 165 | ```yue |
| @@ -171,6 +179,7 @@ print first -- prints: first | |||
| 171 | print bulk -- prints: {"second", "third", "fourth"} | 179 | print bulk -- prints: {"second", "third", "fourth"} |
| 172 | print last -- prints: last | 180 | print last -- prints: last |
| 173 | ``` | 181 | ``` |
| 182 | |||
| 174 | <YueDisplay> | 183 | <YueDisplay> |
| 175 | 184 | ||
| 176 | ```yue | 185 | ```yue |
| @@ -195,6 +204,7 @@ The spread operator can be used in different positions to capture different rang | |||
| 195 | -- Capture things except the middle elements | 204 | -- Capture things except the middle elements |
| 196 | [first, ..._, last] = orders | 205 | [first, ..._, last] = orders |
| 197 | ``` | 206 | ``` |
| 207 | |||
| 198 | <YueDisplay> | 208 | <YueDisplay> |
| 199 | 209 | ||
| 200 | ```yue | 210 | ```yue |
| @@ -223,6 +233,7 @@ tuples = [ | |||
| 223 | for [left, right] in *tuples | 233 | for [left, right] in *tuples |
| 224 | print left, right | 234 | print left, right |
| 225 | ``` | 235 | ``` |
| 236 | |||
| 226 | <YueDisplay> | 237 | <YueDisplay> |
| 227 | 238 | ||
| 228 | ```yue | 239 | ```yue |
diff --git a/doc/docs/doc/assignment/if-assignment.md b/doc/docs/doc/assignment/if-assignment.md index 02984e8..99f94b4 100644 --- a/doc/docs/doc/assignment/if-assignment.md +++ b/doc/docs/doc/assignment/if-assignment.md | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | if user := database.find_user "moon" | 6 | if user := database.find_user "moon" |
| 7 | print user.name | 7 | print user.name |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -23,6 +24,7 @@ elseif world := os.getenv "world" | |||
| 23 | else | 24 | else |
| 24 | print "nothing :(" | 25 | print "nothing :(" |
| 25 | ``` | 26 | ``` |
| 27 | |||
| 26 | <YueDisplay> | 28 | <YueDisplay> |
| 27 | 29 | ||
| 28 | ```yue | 30 | ```yue |
| @@ -37,11 +39,13 @@ else | |||
| 37 | </YueDisplay> | 39 | </YueDisplay> |
| 38 | 40 | ||
| 39 | If assignment with multiple return values. Only the first value is getting checked, other values are scoped. | 41 | If assignment with multiple return values. Only the first value is getting checked, other values are scoped. |
| 42 | |||
| 40 | ```yuescript | 43 | ```yuescript |
| 41 | if success, result := pcall -> "get result without problems" | 44 | if success, result := pcall -> "get result without problems" |
| 42 | print result -- variable result is scoped | 45 | print result -- variable result is scoped |
| 43 | print "OK" | 46 | print "OK" |
| 44 | ``` | 47 | ``` |
| 48 | |||
| 45 | <YueDisplay> | 49 | <YueDisplay> |
| 46 | 50 | ||
| 47 | ```yue | 51 | ```yue |
| @@ -61,6 +65,7 @@ while byte := stream\read_one! | |||
| 61 | -- do something with the byte | 65 | -- do something with the byte |
| 62 | print byte | 66 | print byte |
| 63 | ``` | 67 | ``` |
| 68 | |||
| 64 | <YueDisplay> | 69 | <YueDisplay> |
| 65 | 70 | ||
| 66 | ```yue | 71 | ```yue |
diff --git a/doc/docs/doc/assignment/the-using-clause-controlling-destructive-assignment.md b/doc/docs/doc/assignment/the-using-clause-controlling-destructive-assignment.md index fb9b740..20ba236 100644 --- a/doc/docs/doc/assignment/the-using-clause-controlling-destructive-assignment.md +++ b/doc/docs/doc/assignment/the-using-clause-controlling-destructive-assignment.md | |||
| @@ -17,6 +17,7 @@ my_func! | |||
| 17 | 17 | ||
| 18 | print i -- will print 0 | 18 | print i -- will print 0 |
| 19 | ``` | 19 | ``` |
| 20 | |||
| 20 | <YueDisplay> | 21 | <YueDisplay> |
| 21 | 22 | ||
| 22 | ```yue | 23 | ```yue |
| @@ -52,6 +53,7 @@ my_func = (using nil) -> | |||
| 52 | my_func! | 53 | my_func! |
| 53 | print i -- prints 100, i is unaffected | 54 | print i -- prints 100, i is unaffected |
| 54 | ``` | 55 | ``` |
| 56 | |||
| 55 | <YueDisplay> | 57 | <YueDisplay> |
| 56 | 58 | ||
| 57 | ```yue | 59 | ```yue |
| @@ -80,6 +82,7 @@ my_func = (add using k, i) -> | |||
| 80 | my_func(22) | 82 | my_func(22) |
| 81 | print i, k -- these have been updated | 83 | print i, k -- these have been updated |
| 82 | ``` | 84 | ``` |
| 85 | |||
| 83 | <YueDisplay> | 86 | <YueDisplay> |
| 84 | 87 | ||
| 85 | ```yue | 88 | ```yue |
diff --git a/doc/docs/doc/assignment/varargs-assignment.md b/doc/docs/doc/assignment/varargs-assignment.md index 1d66680..145274c 100644 --- a/doc/docs/doc/assignment/varargs-assignment.md +++ b/doc/docs/doc/assignment/varargs-assignment.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Varargs Assignment | 1 | # Varargs Assignment |
| 2 | 2 | ||
| 3 | You can assign the results returned from a function to a varargs symbol `...`. And then access its content using the Lua way. | 3 | You can assign the results returned from a function to a varargs symbol `...`. And then access its content using the Lua way. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | list = [1, 2, 3, 4, 5] | 6 | list = [1, 2, 3, 4, 5] |
| @@ -10,6 +10,7 @@ count = select '#', ... | |||
| 10 | first = select 1, ... | 10 | first = select 1, ... |
| 11 | print ok, count, first | 11 | print ok, count, first |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
diff --git a/doc/docs/doc/control-flow/conditionals.md b/doc/docs/doc/control-flow/conditionals.md index 1bda514..1bcc838 100644 --- a/doc/docs/doc/control-flow/conditionals.md +++ b/doc/docs/doc/control-flow/conditionals.md | |||
| @@ -7,6 +7,7 @@ if have_coins | |||
| 7 | else | 7 | else |
| 8 | print "No coins" | 8 | print "No coins" |
| 9 | ``` | 9 | ``` |
| 10 | |||
| 10 | <YueDisplay> | 11 | <YueDisplay> |
| 11 | 12 | ||
| 12 | ```yue | 13 | ```yue |
| @@ -25,6 +26,7 @@ A short syntax for single statements can also be used: | |||
| 25 | have_coins = false | 26 | have_coins = false |
| 26 | if have_coins then print "Got coins" else print "No coins" | 27 | if have_coins then print "Got coins" else print "No coins" |
| 27 | ``` | 28 | ``` |
| 29 | |||
| 28 | <YueDisplay> | 30 | <YueDisplay> |
| 29 | 31 | ||
| 30 | ```yue | 32 | ```yue |
| @@ -40,6 +42,7 @@ Because if statements can be used as expressions, this can also be written as: | |||
| 40 | have_coins = false | 42 | have_coins = false |
| 41 | print if have_coins then "Got coins" else "No coins" | 43 | print if have_coins then "Got coins" else "No coins" |
| 42 | ``` | 44 | ``` |
| 45 | |||
| 43 | <YueDisplay> | 46 | <YueDisplay> |
| 44 | 47 | ||
| 45 | ```yue | 48 | ```yue |
| @@ -65,6 +68,7 @@ else | |||
| 65 | 68 | ||
| 66 | print message -- prints: I am very tall | 69 | print message -- prints: I am very tall |
| 67 | ``` | 70 | ``` |
| 71 | |||
| 68 | <YueDisplay> | 72 | <YueDisplay> |
| 69 | 73 | ||
| 70 | ```yue | 74 | ```yue |
| @@ -90,6 +94,7 @@ The opposite of if is unless: | |||
| 90 | unless os.date("%A") == "Monday" | 94 | unless os.date("%A") == "Monday" |
| 91 | print "it is not Monday!" | 95 | print "it is not Monday!" |
| 92 | ``` | 96 | ``` |
| 97 | |||
| 93 | <YueDisplay> | 98 | <YueDisplay> |
| 94 | 99 | ||
| 95 | ```yue | 100 | ```yue |
| @@ -102,6 +107,7 @@ unless os.date("%A") == "Monday" | |||
| 102 | ```yuescript | 107 | ```yuescript |
| 103 | print "You're lucky!" unless math.random! > 0.1 | 108 | print "You're lucky!" unless math.random! > 0.1 |
| 104 | ``` | 109 | ``` |
| 110 | |||
| 105 | <YueDisplay> | 111 | <YueDisplay> |
| 106 | 112 | ||
| 107 | ```yue | 113 | ```yue |
| @@ -123,6 +129,7 @@ if a in [1, 3, 5, 7] | |||
| 123 | if a in list | 129 | if a in list |
| 124 | print "checking if `a` is in a list" | 130 | print "checking if `a` is in a list" |
| 125 | ``` | 131 | ``` |
| 132 | |||
| 126 | <YueDisplay> | 133 | <YueDisplay> |
| 127 | 134 | ||
| 128 | ```yue | 135 | ```yue |
diff --git a/doc/docs/doc/control-flow/continue.md b/doc/docs/doc/control-flow/continue.md index b000765..8708b5a 100644 --- a/doc/docs/doc/control-flow/continue.md +++ b/doc/docs/doc/control-flow/continue.md | |||
| @@ -9,6 +9,7 @@ while i < 10 | |||
| 9 | continue if i % 2 == 0 | 9 | continue if i % 2 == 0 |
| 10 | print i | 10 | print i |
| 11 | ``` | 11 | ``` |
| 12 | |||
| 12 | <YueDisplay> | 13 | <YueDisplay> |
| 13 | 14 | ||
| 14 | ```yue | 15 | ```yue |
| @@ -29,6 +30,7 @@ odds = for x in *my_numbers | |||
| 29 | continue if x % 2 == 1 | 30 | continue if x % 2 == 1 |
| 30 | x | 31 | x |
| 31 | ``` | 32 | ``` |
| 33 | |||
| 32 | <YueDisplay> | 34 | <YueDisplay> |
| 33 | 35 | ||
| 34 | ```yue | 36 | ```yue |
diff --git a/doc/docs/doc/control-flow/for-loop.md b/doc/docs/doc/control-flow/for-loop.md index cabcde5..b92e94e 100644 --- a/doc/docs/doc/control-flow/for-loop.md +++ b/doc/docs/doc/control-flow/for-loop.md | |||
| @@ -12,6 +12,7 @@ for k = 1, 15, 2 -- an optional step provided | |||
| 12 | for key, value in pairs object | 12 | for key, value in pairs object |
| 13 | print key, value | 13 | print key, value |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -33,6 +34,7 @@ The slicing and **\*** operators can be used, just like with comprehensions: | |||
| 33 | for item in *items[2, 4] | 34 | for item in *items[2, 4] |
| 34 | print item | 35 | print item |
| 35 | ``` | 36 | ``` |
| 37 | |||
| 36 | <YueDisplay> | 38 | <YueDisplay> |
| 37 | 39 | ||
| 38 | ```yue | 40 | ```yue |
| @@ -49,6 +51,7 @@ for item in *items do print item | |||
| 49 | 51 | ||
| 50 | for j = 1, 10, 3 do print j | 52 | for j = 1, 10, 3 do print j |
| 51 | ``` | 53 | ``` |
| 54 | |||
| 52 | <YueDisplay> | 55 | <YueDisplay> |
| 53 | 56 | ||
| 54 | ```yue | 57 | ```yue |
| @@ -70,6 +73,7 @@ doubled_evens = for i = 1, 20 | |||
| 70 | else | 73 | else |
| 71 | i | 74 | i |
| 72 | ``` | 75 | ``` |
| 76 | |||
| 73 | <YueDisplay> | 77 | <YueDisplay> |
| 74 | 78 | ||
| 75 | ```yue | 79 | ```yue |
| @@ -90,6 +94,7 @@ For example, to find the first number greater than 10: | |||
| 90 | first_large = for n in *numbers | 94 | first_large = for n in *numbers |
| 91 | break n if n > 10 | 95 | break n if n > 10 |
| 92 | ``` | 96 | ``` |
| 97 | |||
| 93 | <YueDisplay> | 98 | <YueDisplay> |
| 94 | 99 | ||
| 95 | ```yue | 100 | ```yue |
| @@ -112,6 +117,7 @@ func_b = -> return for i = 1, 10 do i | |||
| 112 | print func_a! -- prints nil | 117 | print func_a! -- prints nil |
| 113 | print func_b! -- prints table object | 118 | print func_b! -- prints table object |
| 114 | ``` | 119 | ``` |
| 120 | |||
| 115 | <YueDisplay> | 121 | <YueDisplay> |
| 116 | 122 | ||
| 117 | ```yue | 123 | ```yue |
diff --git a/doc/docs/doc/control-flow/switch.md b/doc/docs/doc/control-flow/switch.md index f503a80..7787b64 100644 --- a/doc/docs/doc/control-flow/switch.md +++ b/doc/docs/doc/control-flow/switch.md | |||
| @@ -11,6 +11,7 @@ switch name := "Dan" | |||
| 11 | else | 11 | else |
| 12 | print "I don't know about you with name #{name}" | 12 | print "I don't know about you with name #{name}" |
| 13 | ``` | 13 | ``` |
| 14 | |||
| 14 | <YueDisplay> | 15 | <YueDisplay> |
| 15 | 16 | ||
| 16 | ```yue | 17 | ```yue |
| @@ -39,6 +40,7 @@ next_number = switch b | |||
| 39 | else | 40 | else |
| 40 | error "can't count that high!" | 41 | error "can't count that high!" |
| 41 | ``` | 42 | ``` |
| 43 | |||
| 42 | <YueDisplay> | 44 | <YueDisplay> |
| 43 | 45 | ||
| 44 | ```yue | 46 | ```yue |
| @@ -62,6 +64,7 @@ msg = switch math.random(1, 5) | |||
| 62 | when 2 then "you are almost lucky" | 64 | when 2 then "you are almost lucky" |
| 63 | else "not so lucky" | 65 | else "not so lucky" |
| 64 | ``` | 66 | ``` |
| 67 | |||
| 65 | <YueDisplay> | 68 | <YueDisplay> |
| 66 | 69 | ||
| 67 | ```yue | 70 | ```yue |
| @@ -87,6 +90,7 @@ switch math.random(1, 5) when 1 | |||
| 87 | else | 90 | else |
| 88 | print "not so lucky" | 91 | print "not so lucky" |
| 89 | ``` | 92 | ``` |
| 93 | |||
| 90 | <YueDisplay> | 94 | <YueDisplay> |
| 91 | 95 | ||
| 92 | ```yue | 96 | ```yue |
| @@ -124,6 +128,7 @@ for item in *items | |||
| 124 | when :width, :height | 128 | when :width, :height |
| 125 | print "size #{width}, #{height}" | 129 | print "size #{width}, #{height}" |
| 126 | ``` | 130 | ``` |
| 131 | |||
| 127 | <YueDisplay> | 132 | <YueDisplay> |
| 128 | 133 | ||
| 129 | ```yue | 134 | ```yue |
| @@ -154,6 +159,7 @@ switch item | |||
| 154 | when {pos: {:x = 50, :y = 200}} | 159 | when {pos: {:x = 50, :y = 200}} |
| 155 | print "Vec2 #{x}, #{y}" -- table destructuring will still pass | 160 | print "Vec2 #{x}, #{y}" -- table destructuring will still pass |
| 156 | ``` | 161 | ``` |
| 162 | |||
| 157 | <YueDisplay> | 163 | <YueDisplay> |
| 158 | 164 | ||
| 159 | ```yue | 165 | ```yue |
| @@ -181,6 +187,7 @@ switch tb | |||
| 181 | when [1, 2, b = 3] -- b has a default value | 187 | when [1, 2, b = 3] -- b has a default value |
| 182 | print "1, 2, #{b}" | 188 | print "1, 2, #{b}" |
| 183 | ``` | 189 | ``` |
| 190 | |||
| 184 | <YueDisplay> | 191 | <YueDisplay> |
| 185 | 192 | ||
| 186 | ```yue | 193 | ```yue |
| @@ -206,6 +213,7 @@ switch tb | |||
| 206 | else | 213 | else |
| 207 | print "invalid" | 214 | print "invalid" |
| 208 | ``` | 215 | ``` |
| 216 | |||
| 209 | <YueDisplay> | 217 | <YueDisplay> |
| 210 | 218 | ||
| 211 | ```yue | 219 | ```yue |
| @@ -231,6 +239,7 @@ switch tb | |||
| 231 | else | 239 | else |
| 232 | print "invalid" | 240 | print "invalid" |
| 233 | ``` | 241 | ``` |
| 242 | |||
| 234 | <YueDisplay> | 243 | <YueDisplay> |
| 235 | 244 | ||
| 236 | ```yue | 245 | ```yue |
| @@ -257,6 +266,7 @@ switch tb | |||
| 257 | ] | 266 | ] |
| 258 | print "matched", fourth | 267 | print "matched", fourth |
| 259 | ``` | 268 | ``` |
| 269 | |||
| 260 | <YueDisplay> | 270 | <YueDisplay> |
| 261 | 271 | ||
| 262 | ```yue | 272 | ```yue |
| @@ -282,6 +292,7 @@ switch segments | |||
| 282 | print "Resource:", resource -- prints: "logs" | 292 | print "Resource:", resource -- prints: "logs" |
| 283 | print "Action:", action -- prints: "view" | 293 | print "Action:", action -- prints: "view" |
| 284 | ``` | 294 | ``` |
| 295 | |||
| 285 | <YueDisplay> | 296 | <YueDisplay> |
| 286 | 297 | ||
| 287 | ```yue | 298 | ```yue |
diff --git a/doc/docs/doc/control-flow/while-loop.md b/doc/docs/doc/control-flow/while-loop.md index 502935e..02e82d6 100644 --- a/doc/docs/doc/control-flow/while-loop.md +++ b/doc/docs/doc/control-flow/while-loop.md | |||
| @@ -10,6 +10,7 @@ while i > 0 | |||
| 10 | 10 | ||
| 11 | while running == true do my_function! | 11 | while running == true do my_function! |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
| @@ -31,6 +32,7 @@ until i == 0 | |||
| 31 | 32 | ||
| 32 | until running == false do my_function! | 33 | until running == false do my_function! |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -56,6 +58,7 @@ repeat | |||
| 56 | i -= 1 | 58 | i -= 1 |
| 57 | until i == 0 | 59 | until i == 0 |
| 58 | ``` | 60 | ``` |
| 61 | |||
| 59 | <YueDisplay> | 62 | <YueDisplay> |
| 60 | 63 | ||
| 61 | ```yue | 64 | ```yue |
diff --git a/doc/docs/doc/data-structures/comprehensions.md b/doc/docs/doc/data-structures/comprehensions.md index 3a92167..94fbf38 100644 --- a/doc/docs/doc/data-structures/comprehensions.md +++ b/doc/docs/doc/data-structures/comprehensions.md | |||
| @@ -10,6 +10,7 @@ The following creates a copy of the items table but with all the values doubled. | |||
| 10 | items = [ 1, 2, 3, 4 ] | 10 | items = [ 1, 2, 3, 4 ] |
| 11 | doubled = [item * 2 for i, item in ipairs items] | 11 | doubled = [item * 2 for i, item in ipairs items] |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
| @@ -24,6 +25,7 @@ The items included in the new table can be restricted with a when clause: | |||
| 24 | ```yuescript | 25 | ```yuescript |
| 25 | slice = [item for i, item in ipairs items when i > 1 and i < 3] | 26 | slice = [item for i, item in ipairs items when i > 1 and i < 3] |
| 26 | ``` | 27 | ``` |
| 28 | |||
| 27 | <YueDisplay> | 29 | <YueDisplay> |
| 28 | 30 | ||
| 29 | ```yue | 31 | ```yue |
| @@ -37,6 +39,7 @@ Because it is common to iterate over the values of a numerically indexed table, | |||
| 37 | ```yuescript | 39 | ```yuescript |
| 38 | doubled = [item * 2 for item in *items] | 40 | doubled = [item * 2 for item in *items] |
| 39 | ``` | 41 | ``` |
| 42 | |||
| 40 | <YueDisplay> | 43 | <YueDisplay> |
| 41 | 44 | ||
| 42 | ```yue | 45 | ```yue |
| @@ -55,6 +58,7 @@ data = | |||
| 55 | flat = [...v for k,v in pairs data] | 58 | flat = [...v for k,v in pairs data] |
| 56 | -- flat is now [1, 2, 3, 4, 5, 6] | 59 | -- flat is now [1, 2, 3, 4, 5, 6] |
| 57 | ``` | 60 | ``` |
| 61 | |||
| 58 | <YueDisplay> | 62 | <YueDisplay> |
| 59 | 63 | ||
| 60 | ```yue | 64 | ```yue |
| @@ -79,6 +83,7 @@ y_coords = [9, 2, 3] | |||
| 79 | points = [ [x, y] for x in *x_coords \ | 83 | points = [ [x, y] for x in *x_coords \ |
| 80 | for y in *y_coords] | 84 | for y in *y_coords] |
| 81 | ``` | 85 | ``` |
| 86 | |||
| 82 | <YueDisplay> | 87 | <YueDisplay> |
| 83 | 88 | ||
| 84 | ```yue | 89 | ```yue |
| @@ -96,6 +101,7 @@ Numeric for loops can also be used in comprehensions: | |||
| 96 | ```yuescript | 101 | ```yuescript |
| 97 | evens = [i for i = 1, 100 when i % 2 == 0] | 102 | evens = [i for i = 1, 100 when i % 2 == 0] |
| 98 | ``` | 103 | ``` |
| 104 | |||
| 99 | <YueDisplay> | 105 | <YueDisplay> |
| 100 | 106 | ||
| 101 | ```yue | 107 | ```yue |
| @@ -119,6 +125,7 @@ thing = { | |||
| 119 | 125 | ||
| 120 | thing_copy = {k, v for k, v in pairs thing} | 126 | thing_copy = {k, v for k, v in pairs thing} |
| 121 | ``` | 127 | ``` |
| 128 | |||
| 122 | <YueDisplay> | 129 | <YueDisplay> |
| 123 | 130 | ||
| 124 | ```yue | 131 | ```yue |
| @@ -136,6 +143,7 @@ thing_copy = {k, v for k, v in pairs thing} | |||
| 136 | ```yuescript | 143 | ```yuescript |
| 137 | no_color = {k, v for k, v in pairs thing when k != "color"} | 144 | no_color = {k, v for k, v in pairs thing when k != "color"} |
| 138 | ``` | 145 | ``` |
| 146 | |||
| 139 | <YueDisplay> | 147 | <YueDisplay> |
| 140 | 148 | ||
| 141 | ```yue | 149 | ```yue |
| @@ -150,6 +158,7 @@ The **\*** operator is also supported. Here we create a square root look up tabl | |||
| 150 | numbers = [1, 2, 3, 4] | 158 | numbers = [1, 2, 3, 4] |
| 151 | sqrts = {i, math.sqrt i for i in *numbers} | 159 | sqrts = {i, math.sqrt i for i in *numbers} |
| 152 | ``` | 160 | ``` |
| 161 | |||
| 153 | <YueDisplay> | 162 | <YueDisplay> |
| 154 | 163 | ||
| 155 | ```yue | 164 | ```yue |
| @@ -167,6 +176,7 @@ In this example we convert an array of pairs to a table where the first item in | |||
| 167 | tuples = [ ["hello", "world"], ["foo", "bar"]] | 176 | tuples = [ ["hello", "world"], ["foo", "bar"]] |
| 168 | tbl = {unpack tuple for tuple in *tuples} | 177 | tbl = {unpack tuple for tuple in *tuples} |
| 169 | ``` | 178 | ``` |
| 179 | |||
| 170 | <YueDisplay> | 180 | <YueDisplay> |
| 171 | 181 | ||
| 172 | ```yue | 182 | ```yue |
| @@ -185,6 +195,7 @@ Here we can set the minimum and maximum bounds, taking all items with indexes be | |||
| 185 | ```yuescript | 195 | ```yuescript |
| 186 | slice = [item for item in *items[1, 5]] | 196 | slice = [item for item in *items[1, 5]] |
| 187 | ``` | 197 | ``` |
| 198 | |||
| 188 | <YueDisplay> | 199 | <YueDisplay> |
| 189 | 200 | ||
| 190 | ```yue | 201 | ```yue |
| @@ -198,6 +209,7 @@ Any of the slice arguments can be left off to use a sensible default. In this ex | |||
| 198 | ```yuescript | 209 | ```yuescript |
| 199 | slice = [item for item in *items[2,]] | 210 | slice = [item for item in *items[2,]] |
| 200 | ``` | 211 | ``` |
| 212 | |||
| 201 | <YueDisplay> | 213 | <YueDisplay> |
| 202 | 214 | ||
| 203 | ```yue | 215 | ```yue |
| @@ -211,6 +223,7 @@ If the minimum bound is left out, it defaults to 1. Here we only provide a step | |||
| 211 | ```yuescript | 223 | ```yuescript |
| 212 | slice = [item for item in *items[,,2]] | 224 | slice = [item for item in *items[,,2]] |
| 213 | ``` | 225 | ``` |
| 226 | |||
| 214 | <YueDisplay> | 227 | <YueDisplay> |
| 215 | 228 | ||
| 216 | ```yue | 229 | ```yue |
| @@ -225,6 +238,7 @@ Both the minimum and maximum bounds can be negative, which means that the bounds | |||
| 225 | -- take the last 4 items | 238 | -- take the last 4 items |
| 226 | slice = [item for item in *items[-4,-1]] | 239 | slice = [item for item in *items[-4,-1]] |
| 227 | ``` | 240 | ``` |
| 241 | |||
| 228 | <YueDisplay> | 242 | <YueDisplay> |
| 229 | 243 | ||
| 230 | ```yue | 244 | ```yue |
| @@ -239,6 +253,7 @@ The step size can also be negative, which means that the items are taken in reve | |||
| 239 | ```yuescript | 253 | ```yuescript |
| 240 | reverse_slice = [item for item in *items[-1,1,-1]] | 254 | reverse_slice = [item for item in *items[-1,1,-1]] |
| 241 | ``` | 255 | ``` |
| 256 | |||
| 242 | <YueDisplay> | 257 | <YueDisplay> |
| 243 | 258 | ||
| 244 | ```yue | 259 | ```yue |
| @@ -258,6 +273,7 @@ sub_list = items[2, 4] | |||
| 258 | -- take the last 4 items | 273 | -- take the last 4 items |
| 259 | last_four_items = items[-4, -1] | 274 | last_four_items = items[-4, -1] |
| 260 | ``` | 275 | ``` |
| 276 | |||
| 261 | <YueDisplay> | 277 | <YueDisplay> |
| 262 | 278 | ||
| 263 | ```yue | 279 | ```yue |
diff --git a/doc/docs/doc/data-structures/table-literals.md b/doc/docs/doc/data-structures/table-literals.md index c1adcab..23f9fc5 100644 --- a/doc/docs/doc/data-structures/table-literals.md +++ b/doc/docs/doc/data-structures/table-literals.md | |||
| @@ -5,6 +5,7 @@ Like in Lua, tables are delimited in curly braces. | |||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | some_values = [1, 2, 3, 4] | 6 | some_values = [1, 2, 3, 4] |
| 7 | ``` | 7 | ``` |
| 8 | |||
| 8 | <YueDisplay> | 9 | <YueDisplay> |
| 9 | 10 | ||
| 10 | ```yue | 11 | ```yue |
| @@ -22,6 +23,7 @@ some_values = { | |||
| 22 | ["favorite food"]: "rice" | 23 | ["favorite food"]: "rice" |
| 23 | } | 24 | } |
| 24 | ``` | 25 | ``` |
| 26 | |||
| 25 | <YueDisplay> | 27 | <YueDisplay> |
| 26 | 28 | ||
| 27 | ```yue | 29 | ```yue |
| @@ -42,6 +44,7 @@ profile = | |||
| 42 | shoe_size: 13, | 44 | shoe_size: 13, |
| 43 | favorite_foods: ["ice cream", "donuts"] | 45 | favorite_foods: ["ice cream", "donuts"] |
| 44 | ``` | 46 | ``` |
| 47 | |||
| 45 | <YueDisplay> | 48 | <YueDisplay> |
| 46 | 49 | ||
| 47 | ```yue | 50 | ```yue |
| @@ -63,6 +66,7 @@ values = { | |||
| 63 | occupation: "crime fighting" | 66 | occupation: "crime fighting" |
| 64 | } | 67 | } |
| 65 | ``` | 68 | ``` |
| 69 | |||
| 66 | <YueDisplay> | 70 | <YueDisplay> |
| 67 | 71 | ||
| 68 | ```yue | 72 | ```yue |
| @@ -83,6 +87,7 @@ my_function dance: "Tango", partner: "none" | |||
| 83 | 87 | ||
| 84 | y = type: "dog", legs: 4, tails: 1 | 88 | y = type: "dog", legs: 4, tails: 1 |
| 85 | ``` | 89 | ``` |
| 90 | |||
| 86 | <YueDisplay> | 91 | <YueDisplay> |
| 87 | 92 | ||
| 88 | ```yue | 93 | ```yue |
| @@ -101,6 +106,7 @@ tbl = { | |||
| 101 | end: "hunger" | 106 | end: "hunger" |
| 102 | } | 107 | } |
| 103 | ``` | 108 | ``` |
| 109 | |||
| 104 | <YueDisplay> | 110 | <YueDisplay> |
| 105 | 111 | ||
| 106 | ```yue | 112 | ```yue |
| @@ -121,6 +127,7 @@ person = { :hair, :height, shoe_size: 40 } | |||
| 121 | 127 | ||
| 122 | print_table :hair, :height | 128 | print_table :hair, :height |
| 123 | ``` | 129 | ``` |
| 130 | |||
| 124 | <YueDisplay> | 131 | <YueDisplay> |
| 125 | 132 | ||
| 126 | ```yue | 133 | ```yue |
| @@ -141,6 +148,7 @@ t = { | |||
| 141 | "hello world": true | 148 | "hello world": true |
| 142 | } | 149 | } |
| 143 | ``` | 150 | ``` |
| 151 | |||
| 144 | <YueDisplay> | 152 | <YueDisplay> |
| 145 | 153 | ||
| 146 | ```yue | 154 | ```yue |
| @@ -158,6 +166,7 @@ Lua tables have both an array part and a hash part, but sometimes you want to ma | |||
| 158 | some_values = [1, 2, 3, 4] | 166 | some_values = [1, 2, 3, 4] |
| 159 | list_with_one_element = [1, ] | 167 | list_with_one_element = [1, ] |
| 160 | ``` | 168 | ``` |
| 169 | |||
| 161 | <YueDisplay> | 170 | <YueDisplay> |
| 162 | 171 | ||
| 163 | ```yue | 172 | ```yue |
diff --git a/doc/docs/doc/functions/backcalls.md b/doc/docs/doc/functions/backcalls.md index e34331e..a1d9f39 100644 --- a/doc/docs/doc/functions/backcalls.md +++ b/doc/docs/doc/functions/backcalls.md | |||
| @@ -6,6 +6,7 @@ Backcalls are used for unnesting callbacks. They are defined using arrows pointe | |||
| 6 | x <- f | 6 | x <- f |
| 7 | print "hello" .. x | 7 | print "hello" .. x |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -21,6 +22,7 @@ Fat arrow functions are also available. | |||
| 21 | <= f | 22 | <= f |
| 22 | print @value | 23 | print @value |
| 23 | ``` | 24 | ``` |
| 25 | |||
| 24 | <YueDisplay> | 26 | <YueDisplay> |
| 25 | 27 | ||
| 26 | ```yue | 28 | ```yue |
| @@ -36,6 +38,7 @@ You can specify a placeholder for where you want the backcall function to go as | |||
| 36 | (x) <- map _, [1, 2, 3] | 38 | (x) <- map _, [1, 2, 3] |
| 37 | x * 2 | 39 | x * 2 |
| 38 | ``` | 40 | ``` |
| 41 | |||
| 39 | <YueDisplay> | 42 | <YueDisplay> |
| 40 | 43 | ||
| 41 | ```yue | 44 | ```yue |
| @@ -55,6 +58,7 @@ result, msg = do | |||
| 55 | check info | 58 | check info |
| 56 | print result, msg | 59 | print result, msg |
| 57 | ``` | 60 | ``` |
| 61 | |||
| 58 | <YueDisplay> | 62 | <YueDisplay> |
| 59 | 63 | ||
| 60 | ```yue | 64 | ```yue |
diff --git a/doc/docs/doc/functions/function-literals.md b/doc/docs/doc/functions/function-literals.md index 316e07c..ed37e52 100644 --- a/doc/docs/doc/functions/function-literals.md +++ b/doc/docs/doc/functions/function-literals.md | |||
| @@ -6,6 +6,7 @@ All functions are created using a function expression. A simple function is deno | |||
| 6 | my_function = -> | 6 | my_function = -> |
| 7 | my_function() -- call the empty function | 7 | my_function() -- call the empty function |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -24,6 +25,7 @@ func_b = -> | |||
| 24 | value = 100 | 25 | value = 100 |
| 25 | print "The value:", value | 26 | print "The value:", value |
| 26 | ``` | 27 | ``` |
| 28 | |||
| 27 | <YueDisplay> | 29 | <YueDisplay> |
| 28 | 30 | ||
| 29 | ```yue | 31 | ```yue |
| @@ -42,6 +44,7 @@ If a function has no arguments, it can be called using the ! operator, instead o | |||
| 42 | func_a! | 44 | func_a! |
| 43 | func_b() | 45 | func_b() |
| 44 | ``` | 46 | ``` |
| 47 | |||
| 45 | <YueDisplay> | 48 | <YueDisplay> |
| 46 | 49 | ||
| 47 | ```yue | 50 | ```yue |
| @@ -56,6 +59,7 @@ Functions with arguments can be created by preceding the arrow with a list of ar | |||
| 56 | ```yuescript | 59 | ```yuescript |
| 57 | sum = (x, y) -> print "sum", x + y | 60 | sum = (x, y) -> print "sum", x + y |
| 58 | ``` | 61 | ``` |
| 62 | |||
| 59 | <YueDisplay> | 63 | <YueDisplay> |
| 60 | 64 | ||
| 61 | ```yue | 65 | ```yue |
| @@ -72,6 +76,7 @@ print sum 10, 20 | |||
| 72 | 76 | ||
| 73 | a b c "a", "b", "c" | 77 | a b c "a", "b", "c" |
| 74 | ``` | 78 | ``` |
| 79 | |||
| 75 | <YueDisplay> | 80 | <YueDisplay> |
| 76 | 81 | ||
| 77 | ```yue | 82 | ```yue |
| @@ -88,6 +93,7 @@ In order to avoid ambiguity in when calling functions, parentheses can also be u | |||
| 88 | ```yuescript | 93 | ```yuescript |
| 89 | print "x:", sum(10, 20), "y:", sum(30, 40) | 94 | print "x:", sum(10, 20), "y:", sum(30, 40) |
| 90 | ``` | 95 | ``` |
| 96 | |||
| 91 | <YueDisplay> | 97 | <YueDisplay> |
| 92 | 98 | ||
| 93 | ```yue | 99 | ```yue |
| @@ -104,6 +110,7 @@ Functions will coerce the last statement in their body into a return statement, | |||
| 104 | sum = (x, y) -> x + y | 110 | sum = (x, y) -> x + y |
| 105 | print "The sum is ", sum 10, 20 | 111 | print "The sum is ", sum 10, 20 |
| 106 | ``` | 112 | ``` |
| 113 | |||
| 107 | <YueDisplay> | 114 | <YueDisplay> |
| 108 | 115 | ||
| 109 | ```yue | 116 | ```yue |
| @@ -118,6 +125,7 @@ And if you need to explicitly return, you can use the return keyword: | |||
| 118 | ```yuescript | 125 | ```yuescript |
| 119 | sum = (x, y) -> return x + y | 126 | sum = (x, y) -> return x + y |
| 120 | ``` | 127 | ``` |
| 128 | |||
| 121 | <YueDisplay> | 129 | <YueDisplay> |
| 122 | 130 | ||
| 123 | ```yue | 131 | ```yue |
| @@ -132,6 +140,7 @@ Just like in Lua, functions can return multiple values. The last statement must | |||
| 132 | mystery = (x, y) -> x + y, x - y | 140 | mystery = (x, y) -> x + y, x - y |
| 133 | a, b = mystery 10, 20 | 141 | a, b = mystery 10, 20 |
| 134 | ``` | 142 | ``` |
| 143 | |||
| 135 | <YueDisplay> | 144 | <YueDisplay> |
| 136 | 145 | ||
| 137 | ```yue | 146 | ```yue |
| @@ -148,6 +157,7 @@ Because it is an idiom in Lua to send an object as the first argument when calli | |||
| 148 | ```yuescript | 157 | ```yuescript |
| 149 | func = (num) => @value + num | 158 | func = (num) => @value + num |
| 150 | ``` | 159 | ``` |
| 160 | |||
| 151 | <YueDisplay> | 161 | <YueDisplay> |
| 152 | 162 | ||
| 153 | ```yue | 163 | ```yue |
| @@ -165,6 +175,7 @@ my_function = (name = "something", height = 100) -> | |||
| 165 | print "Hello I am", name | 175 | print "Hello I am", name |
| 166 | print "My height is", height | 176 | print "My height is", height |
| 167 | ``` | 177 | ``` |
| 178 | |||
| 168 | <YueDisplay> | 179 | <YueDisplay> |
| 169 | 180 | ||
| 170 | ```yue | 181 | ```yue |
| @@ -181,6 +192,7 @@ An argument default value expression is evaluated in the body of the function in | |||
| 181 | some_args = (x = 100, y = x + 1000) -> | 192 | some_args = (x = 100, y = x + 1000) -> |
| 182 | print x + y | 193 | print x + y |
| 183 | ``` | 194 | ``` |
| 195 | |||
| 184 | <YueDisplay> | 196 | <YueDisplay> |
| 185 | 197 | ||
| 186 | ```yue | 198 | ```yue |
| @@ -202,6 +214,7 @@ b = x-10 | |||
| 202 | c = x -y | 214 | c = x -y |
| 203 | d = x- z | 215 | d = x- z |
| 204 | ``` | 216 | ``` |
| 217 | |||
| 205 | <YueDisplay> | 218 | <YueDisplay> |
| 206 | 219 | ||
| 207 | ```yue | 220 | ```yue |
| @@ -223,6 +236,7 @@ Where there is a space following a variable and a string literal, the function c | |||
| 223 | x = func"hello" + 100 | 236 | x = func"hello" + 100 |
| 224 | y = func "hello" + 100 | 237 | y = func "hello" + 100 |
| 225 | ``` | 238 | ``` |
| 239 | |||
| 226 | <YueDisplay> | 240 | <YueDisplay> |
| 227 | 241 | ||
| 228 | ```yue | 242 | ```yue |
| @@ -247,6 +261,7 @@ cool_func 1, 2, | |||
| 247 | 5, 6, | 261 | 5, 6, |
| 248 | 7, 8 | 262 | 7, 8 |
| 249 | ``` | 263 | ``` |
| 264 | |||
| 250 | <YueDisplay> | 265 | <YueDisplay> |
| 251 | 266 | ||
| 252 | ```yue | 267 | ```yue |
| @@ -269,6 +284,7 @@ my_func 5, 6, 7, | |||
| 269 | 9, 1, 2, | 284 | 9, 1, 2, |
| 270 | 5, 4 | 285 | 5, 4 |
| 271 | ``` | 286 | ``` |
| 287 | |||
| 272 | <YueDisplay> | 288 | <YueDisplay> |
| 273 | 289 | ||
| 274 | ```yue | 290 | ```yue |
| @@ -289,6 +305,7 @@ x = [ | |||
| 289 | 8, 9, 10 | 305 | 8, 9, 10 |
| 290 | ] | 306 | ] |
| 291 | ``` | 307 | ``` |
| 308 | |||
| 292 | <YueDisplay> | 309 | <YueDisplay> |
| 293 | 310 | ||
| 294 | ```yue | 311 | ```yue |
| @@ -309,6 +326,7 @@ y = [ my_func 1, 2, 3, | |||
| 309 | 5, 6, 7 | 326 | 5, 6, 7 |
| 310 | ] | 327 | ] |
| 311 | ``` | 328 | ``` |
| 329 | |||
| 312 | <YueDisplay> | 330 | <YueDisplay> |
| 313 | 331 | ||
| 314 | ```yue | 332 | ```yue |
| @@ -335,6 +353,7 @@ if func 1, 2, 3, | |||
| 335 | print "hello" | 353 | print "hello" |
| 336 | print "I am inside if" | 354 | print "I am inside if" |
| 337 | ``` | 355 | ``` |
| 356 | |||
| 338 | <YueDisplay> | 357 | <YueDisplay> |
| 339 | 358 | ||
| 340 | ```yue | 359 | ```yue |
| @@ -357,9 +376,9 @@ if func 1, 2, 3, | |||
| 357 | 376 | ||
| 358 | YueScript now supports destructuring function parameters when the argument is an object. Two forms of destructuring table literals are available: | 377 | YueScript now supports destructuring function parameters when the argument is an object. Two forms of destructuring table literals are available: |
| 359 | 378 | ||
| 360 | * **Curly-brace wrapped literals/object parameters**, allowing optional default values when fields are missing (e.g., `{:a, :b}`, `{a: a1 = 123}`). | 379 | - **Curly-brace wrapped literals/object parameters**, allowing optional default values when fields are missing (e.g., `{:a, :b}`, `{a: a1 = 123}`). |
| 361 | 380 | ||
| 362 | * **Unwrapped simple table syntax**, starting with a sequence of key-value or shorthand bindings and continuing until another expression terminates it (e.g., `:a, b: b1, :c`). This form extracts multiple fields from the same object. | 381 | - **Unwrapped simple table syntax**, starting with a sequence of key-value or shorthand bindings and continuing until another expression terminates it (e.g., `:a, b: b1, :c`). This form extracts multiple fields from the same object. |
| 363 | 382 | ||
| 364 | ```yuescript | 383 | ```yuescript |
| 365 | f1 = (:a, :b, :c) -> | 384 | f1 = (:a, :b, :c) -> |
| @@ -373,6 +392,7 @@ f2 = ({a: a1 = 123, :b = 'abc'}, c = {}) -> | |||
| 373 | arg1 = {a: 0} | 392 | arg1 = {a: 0} |
| 374 | f2 arg1, arg2 | 393 | f2 arg1, arg2 |
| 375 | ``` | 394 | ``` |
| 395 | |||
| 376 | <YueDisplay> | 396 | <YueDisplay> |
| 377 | 397 | ||
| 378 | ```yue | 398 | ```yue |
| @@ -402,6 +422,7 @@ findFirstEven = (list): nil -> | |||
| 402 | if sub % 2 == 0 | 422 | if sub % 2 == 0 |
| 403 | return sub | 423 | return sub |
| 404 | ``` | 424 | ``` |
| 425 | |||
| 405 | <YueDisplay> | 426 | <YueDisplay> |
| 406 | 427 | ||
| 407 | ```yue | 428 | ```yue |
| @@ -426,6 +447,7 @@ findFirstEven = (list) -> | |||
| 426 | return sub | 447 | return sub |
| 427 | nil | 448 | nil |
| 428 | ``` | 449 | ``` |
| 450 | |||
| 429 | <YueDisplay> | 451 | <YueDisplay> |
| 430 | 452 | ||
| 431 | ```yue | 453 | ```yue |
| @@ -467,6 +489,7 @@ process = (...args) -> | |||
| 467 | 489 | ||
| 468 | process 1, nil, 3, nil, 5 | 490 | process 1, nil, 3, nil, 5 |
| 469 | ``` | 491 | ``` |
| 492 | |||
| 470 | <YueDisplay> | 493 | <YueDisplay> |
| 471 | 494 | ||
| 472 | ```yue | 495 | ```yue |
diff --git a/doc/docs/doc/functions/function-stubs.md b/doc/docs/doc/functions/function-stubs.md index 57a8b0c..59ce00c 100644 --- a/doc/docs/doc/functions/function-stubs.md +++ b/doc/docs/doc/functions/function-stubs.md | |||
| @@ -24,6 +24,7 @@ run_callback my_object.write | |||
| 24 | -- lets us bundle the object into a new function | 24 | -- lets us bundle the object into a new function |
| 25 | run_callback my_object\write | 25 | run_callback my_object\write |
| 26 | ``` | 26 | ``` |
| 27 | |||
| 27 | <YueDisplay> | 28 | <YueDisplay> |
| 28 | 29 | ||
| 29 | ```yue | 30 | ```yue |
diff --git a/doc/docs/doc/getting-started/introduction.md b/doc/docs/doc/getting-started/introduction.md index 9a76b23..0b2beed 100644 --- a/doc/docs/doc/getting-started/introduction.md +++ b/doc/docs/doc/getting-started/introduction.md | |||
| @@ -102,4 +102,4 @@ export 🌛 = "Script of Moon" | |||
| 102 | 102 | ||
| 103 | ## About Dora SSR | 103 | ## About Dora SSR |
| 104 | 104 | ||
| 105 | YueScript is being developed and maintained alongside the open-source game engine [Dora SSR](https://github.com/Dora-SSR/Dora-SSR). It has been used to create engine tools, game demos and prototypes, validating its capabilities in real-world scenarios while enhancing the Dora SSR development experience. \ No newline at end of file | 105 | YueScript is being developed and maintained alongside the open-source game engine [Dora SSR](https://github.com/Dora-SSR/Dora-SSR). It has been used to create engine tools, game demos and prototypes, validating its capabilities in real-world scenarios while enhancing the Dora SSR development experience. |
diff --git a/doc/docs/doc/getting-started/usage.md b/doc/docs/doc/getting-started/usage.md index 45161c6..8818dd0 100644 --- a/doc/docs/doc/getting-started/usage.md +++ b/doc/docs/doc/getting-started/usage.md | |||
| @@ -4,49 +4,51 @@ | |||
| 4 | 4 | ||
| 5 | Use YueScript module in Lua: | 5 | Use YueScript module in Lua: |
| 6 | 6 | ||
| 7 | * **Case 1** | 7 | - **Case 1** |
| 8 | 8 | ||
| 9 | Require "your_yuescript_entry.yue" in Lua. | 9 | Require "your_yuescript_entry.yue" in Lua. |
| 10 | ```Lua | 10 | |
| 11 | require("yue")("your_yuescript_entry") | 11 | ```Lua |
| 12 | ``` | 12 | require("yue")("your_yuescript_entry") |
| 13 | And this code still works when you compile "your_yuescript_entry.yue" to "your_yuescript_entry.lua" in the same path. In the rest YueScript files just use the normal **require** or **import**. The code line numbers in error messages will also be handled correctly. | 13 | ``` |
| 14 | 14 | ||
| 15 | * **Case 2** | 15 | And this code still works when you compile "your_yuescript_entry.yue" to "your_yuescript_entry.lua" in the same path. In the rest YueScript files just use the normal **require** or **import**. The code line numbers in error messages will also be handled correctly. |
| 16 | 16 | ||
| 17 | Require YueScript module and rewite message by hand. | 17 | - **Case 2** |
| 18 | 18 | ||
| 19 | ```lua | 19 | Require YueScript module and rewite message by hand. |
| 20 | local yue = require("yue") | 20 | |
| 21 | yue.insert_loader() | 21 | ```lua |
| 22 | local success, result = xpcall(function() | 22 | local yue = require("yue") |
| 23 | return require("yuescript_module_name") | 23 | yue.insert_loader() |
| 24 | end, function(err) | 24 | local success, result = xpcall(function() |
| 25 | return yue.traceback(err) | 25 | return require("yuescript_module_name") |
| 26 | end) | 26 | end, function(err) |
| 27 | ``` | 27 | return yue.traceback(err) |
| 28 | 28 | end) | |
| 29 | * **Case 3** | 29 | ``` |
| 30 | 30 | ||
| 31 | Use the YueScript compiler function in Lua. | 31 | - **Case 3** |
| 32 | 32 | ||
| 33 | ```lua | 33 | Use the YueScript compiler function in Lua. |
| 34 | local yue = require("yue") | 34 | |
| 35 | local codes, err, globals = yue.to_lua([[ | 35 | ```lua |
| 36 | f = -> | 36 | local yue = require("yue") |
| 37 | print "hello world" | 37 | local codes, err, globals = yue.to_lua([[ |
| 38 | f! | 38 | f = -> |
| 39 | ]],{ | 39 | print "hello world" |
| 40 | implicit_return_root = true, | 40 | f! |
| 41 | reserve_line_number = true, | 41 | ]],{ |
| 42 | lint_global = true, | 42 | implicit_return_root = true, |
| 43 | space_over_tab = false, | 43 | reserve_line_number = true, |
| 44 | options = { | 44 | lint_global = true, |
| 45 | target = "5.4", | 45 | space_over_tab = false, |
| 46 | path = "/script" | 46 | options = { |
| 47 | } | 47 | target = "5.4", |
| 48 | }) | 48 | path = "/script" |
| 49 | ``` | 49 | } |
| 50 | }) | ||
| 51 | ``` | ||
| 50 | 52 | ||
| 51 | ## YueScript Tool | 53 | ## YueScript Tool |
| 52 | 54 | ||
| @@ -96,16 +98,17 @@ Options: | |||
| 96 | Execute without options to enter REPL, type symbol '$' | 98 | Execute without options to enter REPL, type symbol '$' |
| 97 | in a single line to start/stop multi-line mode | 99 | in a single line to start/stop multi-line mode |
| 98 | ``` | 100 | ``` |
| 101 | |||
| 99 | Use cases: | 102 | Use cases: |
| 100 | 103 | ||
| 101 | Recursively compile every YueScript file with extension **.yue** under current path: **yue .** | 104 | Recursively compile every YueScript file with extension **.yue** under current path: **yue .** |
| 102 | 105 | ||
| 103 | Compile and save results to a target path: **yue -t /target/path/ .** | 106 | Compile and save results to a target path: **yue -t /target/path/ .** |
| 104 | 107 | ||
| 105 | Compile and reserve debug info: **yue -l .** | 108 | Compile and reserve debug info: **yue -l .** |
| 106 | 109 | ||
| 107 | Compile and generate minified codes: **yue -m .** | 110 | Compile and generate minified codes: **yue -m .** |
| 108 | 111 | ||
| 109 | Execute raw codes: **yue -e 'print 123'** | 112 | Execute raw codes: **yue -e 'print 123'** |
| 110 | 113 | ||
| 111 | Execute a YueScript file: **yue -e main.yue** | 114 | Execute a YueScript file: **yue -e main.yue** |
diff --git a/doc/docs/doc/language-basics/attributes.md b/doc/docs/doc/language-basics/attributes.md index e6fd5a7..068a56a 100644 --- a/doc/docs/doc/language-basics/attributes.md +++ b/doc/docs/doc/language-basics/attributes.md | |||
| @@ -6,6 +6,7 @@ Syntax support for Lua 5.4 attributes. And you can still use both the `const` an | |||
| 6 | const a = 123 | 6 | const a = 123 |
| 7 | close _ = <close>: -> print "Out of scope." | 7 | close _ = <close>: -> print "Out of scope." |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -21,6 +22,7 @@ You can do desctructuring with variables attributed as constant. | |||
| 21 | const {:a, :b, c, d} = tb | 22 | const {:a, :b, c, d} = tb |
| 22 | -- a = 1 | 23 | -- a = 1 |
| 23 | ``` | 24 | ``` |
| 25 | |||
| 24 | <YueDisplay> | 26 | <YueDisplay> |
| 25 | 27 | ||
| 26 | ```yue | 28 | ```yue |
| @@ -36,6 +38,7 @@ You can also declare a global variable to be `const`. | |||
| 36 | global const Constant = 123 | 38 | global const Constant = 123 |
| 37 | -- Constant = 1 | 39 | -- Constant = 1 |
| 38 | ``` | 40 | ``` |
| 41 | |||
| 39 | <YueDisplay> | 42 | <YueDisplay> |
| 40 | 43 | ||
| 41 | ```yue | 44 | ```yue |
diff --git a/doc/docs/doc/language-basics/comment.md b/doc/docs/doc/language-basics/comment.md index b67c97d..ee637dd 100644 --- a/doc/docs/doc/language-basics/comment.md +++ b/doc/docs/doc/language-basics/comment.md | |||
| @@ -12,6 +12,7 @@ It's OK. | |||
| 12 | 12 | ||
| 13 | func --[[port]] 3000, --[[ip]] "192.168.1.1" | 13 | func --[[port]] 3000, --[[ip]] "192.168.1.1" |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
diff --git a/doc/docs/doc/language-basics/literals.md b/doc/docs/doc/language-basics/literals.md index e097c62..17b823f 100644 --- a/doc/docs/doc/language-basics/literals.md +++ b/doc/docs/doc/language-basics/literals.md | |||
| @@ -12,6 +12,7 @@ some_string = "Here is a string | |||
| 12 | -- String interpolation is only available in double quoted strings. | 12 | -- String interpolation is only available in double quoted strings. |
| 13 | print "I am #{math.random! * 100}% sure." | 13 | print "I am #{math.random! * 100}% sure." |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -34,6 +35,7 @@ integer = 1_000_000 | |||
| 34 | hex = 0xEF_BB_BF | 35 | hex = 0xEF_BB_BF |
| 35 | binary = 0B10011 | 36 | binary = 0B10011 |
| 36 | ``` | 37 | ``` |
| 38 | |||
| 37 | <YueDisplay> | 39 | <YueDisplay> |
| 38 | 40 | ||
| 39 | ```yue | 41 | ```yue |
| @@ -55,6 +57,7 @@ str = | | |||
| 55 | - item1 | 57 | - item1 |
| 56 | - #{expr} | 58 | - #{expr} |
| 57 | ``` | 59 | ``` |
| 60 | |||
| 58 | <YueDisplay> | 61 | <YueDisplay> |
| 59 | 62 | ||
| 60 | ```yue | 63 | ```yue |
| @@ -78,6 +81,7 @@ fn = -> | |||
| 78 | bar: baz | 81 | bar: baz |
| 79 | return str | 82 | return str |
| 80 | ``` | 83 | ``` |
| 84 | |||
| 81 | <YueDisplay> | 85 | <YueDisplay> |
| 82 | 86 | ||
| 83 | ```yue | 87 | ```yue |
| @@ -99,6 +103,7 @@ str = | | |||
| 99 | path: "C:\Program Files\App" | 103 | path: "C:\Program Files\App" |
| 100 | note: 'He said: "#{Hello}!"' | 104 | note: 'He said: "#{Hello}!"' |
| 101 | ``` | 105 | ``` |
| 106 | |||
| 102 | <YueDisplay> | 107 | <YueDisplay> |
| 103 | 108 | ||
| 104 | ```yue | 109 | ```yue |
diff --git a/doc/docs/doc/language-basics/operator.md b/doc/docs/doc/language-basics/operator.md index 9a2e89b..6de5c17 100644 --- a/doc/docs/doc/language-basics/operator.md +++ b/doc/docs/doc/language-basics/operator.md | |||
| @@ -6,6 +6,7 @@ All of Lua's binary and unary operators are available. Additionally **!=** is as | |||
| 6 | tb\func! if tb ~= nil | 6 | tb\func! if tb ~= nil |
| 7 | tb::func! if tb != nil | 7 | tb::func! if tb != nil |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -27,6 +28,7 @@ a = 5 | |||
| 27 | print 1 <= a <= 10 | 28 | print 1 <= a <= 10 |
| 28 | -- output: true | 29 | -- output: true |
| 29 | ``` | 30 | ``` |
| 31 | |||
| 30 | <YueDisplay> | 32 | <YueDisplay> |
| 31 | 33 | ||
| 32 | ```yue | 34 | ```yue |
| @@ -64,6 +66,7 @@ print v(1) > v(2) <= v(3) | |||
| 64 | false | 66 | false |
| 65 | ]] | 67 | ]] |
| 66 | ``` | 68 | ``` |
| 69 | |||
| 67 | <YueDisplay> | 70 | <YueDisplay> |
| 68 | 71 | ||
| 69 | ```yue | 72 | ```yue |
| @@ -101,6 +104,7 @@ The **[] =** operator is used to append values to tables. | |||
| 101 | tab = [] | 104 | tab = [] |
| 102 | tab[] = "Value" | 105 | tab[] = "Value" |
| 103 | ``` | 106 | ``` |
| 107 | |||
| 104 | <YueDisplay> | 108 | <YueDisplay> |
| 105 | 109 | ||
| 106 | ```yue | 110 | ```yue |
| @@ -118,6 +122,7 @@ tbB = [4, 5, 6] | |||
| 118 | tbA[] = ...tbB | 122 | tbA[] = ...tbB |
| 119 | -- tbA is now [1, 2, 3, 4, 5, 6] | 123 | -- tbA is now [1, 2, 3, 4, 5, 6] |
| 120 | ``` | 124 | ``` |
| 125 | |||
| 121 | <YueDisplay> | 126 | <YueDisplay> |
| 122 | 127 | ||
| 123 | ```yue | 128 | ```yue |
| @@ -149,6 +154,7 @@ a = {1, 2, 3, x: 1} | |||
| 149 | b = {4, 5, y: 1} | 154 | b = {4, 5, y: 1} |
| 150 | merge = {...a, ...b} | 155 | merge = {...a, ...b} |
| 151 | ``` | 156 | ``` |
| 157 | |||
| 152 | <YueDisplay> | 158 | <YueDisplay> |
| 153 | 159 | ||
| 154 | ```yue | 160 | ```yue |
| @@ -179,6 +185,7 @@ last = data.items[#] | |||
| 179 | second_last = data.items[#-1] | 185 | second_last = data.items[#-1] |
| 180 | data.items[#] = 1 | 186 | data.items[#] = 1 |
| 181 | ``` | 187 | ``` |
| 188 | |||
| 182 | <YueDisplay> | 189 | <YueDisplay> |
| 183 | 190 | ||
| 184 | ```yue | 191 | ```yue |
| @@ -212,6 +219,7 @@ print d.value | |||
| 212 | 219 | ||
| 213 | close _ = <close>: -> print "out of scope" | 220 | close _ = <close>: -> print "out of scope" |
| 214 | ``` | 221 | ``` |
| 222 | |||
| 215 | <YueDisplay> | 223 | <YueDisplay> |
| 216 | 224 | ||
| 217 | ```yue | 225 | ```yue |
| @@ -245,6 +253,7 @@ print tb.value | |||
| 245 | tb.<> = __index: {item: "hello"} | 253 | tb.<> = __index: {item: "hello"} |
| 246 | print tb.item | 254 | print tb.item |
| 247 | ``` | 255 | ``` |
| 256 | |||
| 248 | <YueDisplay> | 257 | <YueDisplay> |
| 249 | 258 | ||
| 250 | ```yue | 259 | ```yue |
| @@ -266,6 +275,7 @@ Destruct metatable with metamethod key surrounded by **<>**. | |||
| 266 | {item, :new, :<close>, <index>: getter} = tb | 275 | {item, :new, :<close>, <index>: getter} = tb |
| 267 | print item, new, close, getter | 276 | print item, new, close, getter |
| 268 | ``` | 277 | ``` |
| 278 | |||
| 269 | <YueDisplay> | 279 | <YueDisplay> |
| 270 | 280 | ||
| 271 | ```yue | 281 | ```yue |
| @@ -293,6 +303,7 @@ with? io.open "test.txt", "w" | |||
| 293 | \write "hello" | 303 | \write "hello" |
| 294 | \close! | 304 | \close! |
| 295 | ``` | 305 | ``` |
| 306 | |||
| 296 | <YueDisplay> | 307 | <YueDisplay> |
| 297 | 308 | ||
| 298 | ```yue | 309 | ```yue |
| @@ -329,6 +340,7 @@ readFile "example.txt" | |||
| 329 | |> render | 340 | |> render |
| 330 | 341 | ||
| 331 | ``` | 342 | ``` |
| 343 | |||
| 332 | <YueDisplay> | 344 | <YueDisplay> |
| 333 | 345 | ||
| 334 | ```yue | 346 | ```yue |
| @@ -349,6 +361,7 @@ readFile "example.txt" | |||
| 349 | ## Nil Coalescing | 361 | ## Nil Coalescing |
| 350 | 362 | ||
| 351 | The nil-coalescing operator **??** returns the value of its left-hand operand if it isn't **nil**; otherwise, it evaluates the right-hand operand and returns its result. The **??** operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-nil. | 363 | The nil-coalescing operator **??** returns the value of its left-hand operand if it isn't **nil**; otherwise, it evaluates the right-hand operand and returns its result. The **??** operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-nil. |
| 364 | |||
| 352 | ```yuescript | 365 | ```yuescript |
| 353 | local a, b, c, d | 366 | local a, b, c, d |
| 354 | a = b ?? c ?? d | 367 | a = b ?? c ?? d |
| @@ -356,6 +369,7 @@ func a ?? {} | |||
| 356 | 369 | ||
| 357 | a ??= false | 370 | a ??= false |
| 358 | ``` | 371 | ``` |
| 372 | |||
| 359 | <YueDisplay> | 373 | <YueDisplay> |
| 360 | 374 | ||
| 361 | ```yue | 375 | ```yue |
| @@ -413,6 +427,7 @@ tb = | |||
| 413 | tb: { } | 427 | tb: { } |
| 414 | 428 | ||
| 415 | ``` | 429 | ``` |
| 430 | |||
| 416 | <YueDisplay> | 431 | <YueDisplay> |
| 417 | 432 | ||
| 418 | ```yue | 433 | ```yue |
diff --git a/doc/docs/doc/language-basics/whitespace.md b/doc/docs/doc/language-basics/whitespace.md index d742a2b..3b67e48 100644 --- a/doc/docs/doc/language-basics/whitespace.md +++ b/doc/docs/doc/language-basics/whitespace.md | |||
| @@ -9,6 +9,7 @@ A statement normally ends at a line break. You can also use a semicolon `;` to e | |||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | a = 1; b = 2; print a + b | 10 | a = 1; b = 2; print a + b |
| 11 | ``` | 11 | ``` |
| 12 | |||
| 12 | <YueDisplay> | 13 | <YueDisplay> |
| 13 | 14 | ||
| 14 | ```yue | 15 | ```yue |
| @@ -29,6 +30,7 @@ Rx.Observable | |||
| 29 | \map (value) -> value .. '!' | 30 | \map (value) -> value .. '!' |
| 30 | \subscribe print | 31 | \subscribe print |
| 31 | ``` | 32 | ``` |
| 33 | |||
| 32 | <YueDisplay> | 34 | <YueDisplay> |
| 33 | 35 | ||
| 34 | ```yue | 36 | ```yue |
diff --git a/doc/docs/doc/objects/object-oriented-programming.md b/doc/docs/doc/objects/object-oriented-programming.md index 6a8559e..781ab65 100644 --- a/doc/docs/doc/objects/object-oriented-programming.md +++ b/doc/docs/doc/objects/object-oriented-programming.md | |||
| @@ -15,6 +15,7 @@ class Inventory | |||
| 15 | else | 15 | else |
| 16 | @items[name] = 1 | 16 | @items[name] = 1 |
| 17 | ``` | 17 | ``` |
| 18 | |||
| 18 | <YueDisplay> | 19 | <YueDisplay> |
| 19 | 20 | ||
| 20 | ```yue | 21 | ```yue |
| @@ -46,6 +47,7 @@ inv = Inventory! | |||
| 46 | inv\add_item "t-shirt" | 47 | inv\add_item "t-shirt" |
| 47 | inv\add_item "pants" | 48 | inv\add_item "pants" |
| 48 | ``` | 49 | ``` |
| 50 | |||
| 49 | <YueDisplay> | 51 | <YueDisplay> |
| 50 | 52 | ||
| 51 | ```yue | 53 | ```yue |
| @@ -77,6 +79,7 @@ b\give_item "shirt" | |||
| 77 | -- will print both pants and shirt | 79 | -- will print both pants and shirt |
| 78 | print item for item in *a.clothes | 80 | print item for item in *a.clothes |
| 79 | ``` | 81 | ``` |
| 82 | |||
| 80 | <YueDisplay> | 83 | <YueDisplay> |
| 81 | 84 | ||
| 82 | ```yue | 85 | ```yue |
| @@ -104,6 +107,7 @@ class Person | |||
| 104 | new: => | 107 | new: => |
| 105 | @clothes = [] | 108 | @clothes = [] |
| 106 | ``` | 109 | ``` |
| 110 | |||
| 107 | <YueDisplay> | 111 | <YueDisplay> |
| 108 | 112 | ||
| 109 | ```yue | 113 | ```yue |
| @@ -125,6 +129,7 @@ class BackPack extends Inventory | |||
| 125 | if #@items > size then error "backpack is full" | 129 | if #@items > size then error "backpack is full" |
| 126 | super name | 130 | super name |
| 127 | ``` | 131 | ``` |
| 132 | |||
| 128 | <YueDisplay> | 133 | <YueDisplay> |
| 129 | 134 | ||
| 130 | ```yue | 135 | ```yue |
| @@ -141,7 +146,7 @@ Here we extend our Inventory class, and limit the amount of items it can carry. | |||
| 141 | 146 | ||
| 142 | In this example, we don't define a constructor on the subclass, so the parent class' constructor is called when we make a new instance. If we did define a constructor then we can use the super method to call the parent constructor. | 147 | In this example, we don't define a constructor on the subclass, so the parent class' constructor is called when we make a new instance. If we did define a constructor then we can use the super method to call the parent constructor. |
| 143 | 148 | ||
| 144 | Whenever a class inherits from another, it sends a message to the parent class by calling the method __inherited on the parent class if it exists. The function receives two arguments, the class that is being inherited and the child class. | 149 | Whenever a class inherits from another, it sends a message to the parent class by calling the method \_\_inherited on the parent class if it exists. The function receives two arguments, the class that is being inherited and the child class. |
| 145 | 150 | ||
| 146 | ```yuescript | 151 | ```yuescript |
| 147 | class Shelf | 152 | class Shelf |
| @@ -151,6 +156,7 @@ class Shelf | |||
| 151 | -- will print: Shelf was inherited by Cupboard | 156 | -- will print: Shelf was inherited by Cupboard |
| 152 | class Cupboard extends Shelf | 157 | class Cupboard extends Shelf |
| 153 | ``` | 158 | ``` |
| 159 | |||
| 154 | <YueDisplay> | 160 | <YueDisplay> |
| 155 | 161 | ||
| 156 | ```yue | 162 | ```yue |
| @@ -189,6 +195,7 @@ class MyClass extends ParentClass | |||
| 189 | -- super as a value is equal to the parent class: | 195 | -- super as a value is equal to the parent class: |
| 190 | assert super == ParentClass | 196 | assert super == ParentClass |
| 191 | ``` | 197 | ``` |
| 198 | |||
| 192 | <YueDisplay> | 199 | <YueDisplay> |
| 193 | 200 | ||
| 194 | ```yue | 201 | ```yue |
| @@ -209,7 +216,7 @@ class MyClass extends ParentClass | |||
| 209 | 216 | ||
| 210 | ## Types | 217 | ## Types |
| 211 | 218 | ||
| 212 | Every instance of a class carries its type with it. This is stored in the special __class property. This property holds the class object. The class object is what we call to build a new instance. We can also index the class object to retrieve class methods and properties. | 219 | Every instance of a class carries its type with it. This is stored in the special \_\_class property. This property holds the class object. The class object is what we call to build a new instance. We can also index the class object to retrieve class methods and properties. |
| 213 | 220 | ||
| 214 | ```yuescript | 221 | ```yuescript |
| 215 | b = BackPack! | 222 | b = BackPack! |
| @@ -217,6 +224,7 @@ assert b.__class == BackPack | |||
| 217 | 224 | ||
| 218 | print BackPack.size -- prints 10 | 225 | print BackPack.size -- prints 10 |
| 219 | ``` | 226 | ``` |
| 227 | |||
| 220 | <YueDisplay> | 228 | <YueDisplay> |
| 221 | 229 | ||
| 222 | ```yue | 230 | ```yue |
| @@ -238,15 +246,16 @@ A class is made up of two tables. The class table itself, and the base table. Th | |||
| 238 | 246 | ||
| 239 | The class object's metatable reads properties from the base if they don't exist in the class object. This means we can access functions and properties directly from the class. | 247 | The class object's metatable reads properties from the base if they don't exist in the class object. This means we can access functions and properties directly from the class. |
| 240 | 248 | ||
| 241 | It is important to note that assigning to the class object does not assign into the base, so it's not a valid way to add new methods to instances. Instead the base must explicitly be changed. See the __base field below. | 249 | It is important to note that assigning to the class object does not assign into the base, so it's not a valid way to add new methods to instances. Instead the base must explicitly be changed. See the \_\_base field below. |
| 242 | 250 | ||
| 243 | The class object has a couple special properties: | 251 | The class object has a couple special properties: |
| 244 | 252 | ||
| 245 | The name of the class as when it was declared is stored as a string in the __name field of the class object. | 253 | The name of the class as when it was declared is stored as a string in the \_\_name field of the class object. |
| 246 | 254 | ||
| 247 | ```yuescript | 255 | ```yuescript |
| 248 | print BackPack.__name -- prints Backpack | 256 | print BackPack.__name -- prints Backpack |
| 249 | ``` | 257 | ``` |
| 258 | |||
| 250 | <YueDisplay> | 259 | <YueDisplay> |
| 251 | 260 | ||
| 252 | ```yue | 261 | ```yue |
| @@ -255,9 +264,9 @@ print BackPack.__name -- prints Backpack | |||
| 255 | 264 | ||
| 256 | </YueDisplay> | 265 | </YueDisplay> |
| 257 | 266 | ||
| 258 | The base object is stored in __base. We can modify this table to add functionality to instances that have already been created and ones that are yet to be created. | 267 | The base object is stored in \_\_base. We can modify this table to add functionality to instances that have already been created and ones that are yet to be created. |
| 259 | 268 | ||
| 260 | If the class extends from anything, the parent class object is stored in __parent. | 269 | If the class extends from anything, the parent class object is stored in \_\_parent. |
| 261 | 270 | ||
| 262 | ## Class Variables | 271 | ## Class Variables |
| 263 | 272 | ||
| @@ -272,6 +281,7 @@ Things\some_func! | |||
| 272 | -- class variables not visible in instances | 281 | -- class variables not visible in instances |
| 273 | assert Things().some_func == nil | 282 | assert Things().some_func == nil |
| 274 | ``` | 283 | ``` |
| 284 | |||
| 275 | <YueDisplay> | 285 | <YueDisplay> |
| 276 | 286 | ||
| 277 | ```yue | 287 | ```yue |
| @@ -286,7 +296,7 @@ assert Things().some_func == nil | |||
| 286 | 296 | ||
| 287 | </YueDisplay> | 297 | </YueDisplay> |
| 288 | 298 | ||
| 289 | In expressions, we can use @@ to access a value that is stored in the __class of self. Thus, @@hello is shorthand for self.__class.hello. | 299 | In expressions, we can use @@ to access a value that is stored in the **class of self. Thus, @@hello is shorthand for self.**class.hello. |
| 290 | 300 | ||
| 291 | ```yuescript | 301 | ```yuescript |
| 292 | class Counter | 302 | class Counter |
| @@ -300,6 +310,7 @@ Counter! | |||
| 300 | 310 | ||
| 301 | print Counter.count -- prints 2 | 311 | print Counter.count -- prints 2 |
| 302 | ``` | 312 | ``` |
| 313 | |||
| 303 | <YueDisplay> | 314 | <YueDisplay> |
| 304 | 315 | ||
| 305 | ```yue | 316 | ```yue |
| @@ -322,6 +333,7 @@ The calling semantics of @@ are similar to @. Calling a @@ name will pass the cl | |||
| 322 | ```yuescript | 333 | ```yuescript |
| 323 | @@hello 1,2,3,4 | 334 | @@hello 1,2,3,4 |
| 324 | ``` | 335 | ``` |
| 336 | |||
| 325 | <YueDisplay> | 337 | <YueDisplay> |
| 326 | 338 | ||
| 327 | ```yue | 339 | ```yue |
| @@ -340,6 +352,7 @@ Here is an alternative way to create a class variable compared to what's describ | |||
| 340 | class Things | 352 | class Things |
| 341 | @class_var = "hello world" | 353 | @class_var = "hello world" |
| 342 | ``` | 354 | ``` |
| 355 | |||
| 343 | <YueDisplay> | 356 | <YueDisplay> |
| 344 | 357 | ||
| 345 | ```yue | 358 | ```yue |
| @@ -361,6 +374,7 @@ class MoreThings | |||
| 361 | some_method: => | 374 | some_method: => |
| 362 | log "hello world: " .. secret | 375 | log "hello world: " .. secret |
| 363 | ``` | 376 | ``` |
| 377 | |||
| 364 | <YueDisplay> | 378 | <YueDisplay> |
| 365 | 379 | ||
| 366 | ```yue | 380 | ```yue |
| @@ -376,14 +390,15 @@ class MoreThings | |||
| 376 | 390 | ||
| 377 | ## @ and @@ Values | 391 | ## @ and @@ Values |
| 378 | 392 | ||
| 379 | When @ and @@ are prefixed in front of a name they represent, respectively, that name accessed in self and self.__class. | 393 | When @ and @@ are prefixed in front of a name they represent, respectively, that name accessed in self and self.\_\_class. |
| 380 | 394 | ||
| 381 | If they are used all by themselves, they are aliases for self and self.__class. | 395 | If they are used all by themselves, they are aliases for self and self.\_\_class. |
| 382 | 396 | ||
| 383 | ```yuescript | 397 | ```yuescript |
| 384 | assert @ == self | 398 | assert @ == self |
| 385 | assert @@ == self.__class | 399 | assert @@ == self.__class |
| 386 | ``` | 400 | ``` |
| 401 | |||
| 387 | <YueDisplay> | 402 | <YueDisplay> |
| 388 | 403 | ||
| 389 | ```yue | 404 | ```yue |
| @@ -398,6 +413,7 @@ For example, a quick way to create a new instance of the same class from an inst | |||
| 398 | ```yuescript | 413 | ```yuescript |
| 399 | some_instance_method = (...) => @@ ... | 414 | some_instance_method = (...) => @@ ... |
| 400 | ``` | 415 | ``` |
| 416 | |||
| 401 | <YueDisplay> | 417 | <YueDisplay> |
| 402 | 418 | ||
| 403 | ```yue | 419 | ```yue |
| @@ -423,6 +439,7 @@ class Something | |||
| 423 | @@biz = biz | 439 | @@biz = biz |
| 424 | @@baz = baz | 440 | @@baz = baz |
| 425 | ``` | 441 | ``` |
| 442 | |||
| 426 | <YueDisplay> | 443 | <YueDisplay> |
| 427 | 444 | ||
| 428 | ```yue | 445 | ```yue |
| @@ -448,6 +465,7 @@ new = (@fieldA, @fieldB) => @ | |||
| 448 | obj = new {}, 123, "abc" | 465 | obj = new {}, 123, "abc" |
| 449 | print obj | 466 | print obj |
| 450 | ``` | 467 | ``` |
| 468 | |||
| 451 | <YueDisplay> | 469 | <YueDisplay> |
| 452 | 470 | ||
| 453 | ```yue | 471 | ```yue |
| @@ -467,6 +485,7 @@ x = class Bucket | |||
| 467 | drops: 0 | 485 | drops: 0 |
| 468 | add_drop: => @drops += 1 | 486 | add_drop: => @drops += 1 |
| 469 | ``` | 487 | ``` |
| 488 | |||
| 470 | <YueDisplay> | 489 | <YueDisplay> |
| 471 | 490 | ||
| 472 | ```yue | 491 | ```yue |
| @@ -479,7 +498,7 @@ x = class Bucket | |||
| 479 | 498 | ||
| 480 | ## Anonymous classes | 499 | ## Anonymous classes |
| 481 | 500 | ||
| 482 | The name can be left out when declaring a class. The __name attribute will be nil, unless the class expression is in an assignment. The name on the left hand side of the assignment is used instead of nil. | 501 | The name can be left out when declaring a class. The \_\_name attribute will be nil, unless the class expression is in an assignment. The name on the left hand side of the assignment is used instead of nil. |
| 483 | 502 | ||
| 484 | ```yuescript | 503 | ```yuescript |
| 485 | BigBucket = class extends Bucket | 504 | BigBucket = class extends Bucket |
| @@ -487,6 +506,7 @@ BigBucket = class extends Bucket | |||
| 487 | 506 | ||
| 488 | assert Bucket.__name == "BigBucket" | 507 | assert Bucket.__name == "BigBucket" |
| 489 | ``` | 508 | ``` |
| 509 | |||
| 490 | <YueDisplay> | 510 | <YueDisplay> |
| 491 | 511 | ||
| 492 | ```yue | 512 | ```yue |
| @@ -503,6 +523,7 @@ You can even leave off the body, meaning you can write a blank anonymous class l | |||
| 503 | ```yuescript | 523 | ```yuescript |
| 504 | x = class | 524 | x = class |
| 505 | ``` | 525 | ``` |
| 526 | |||
| 506 | <YueDisplay> | 527 | <YueDisplay> |
| 507 | 528 | ||
| 508 | ```yue | 529 | ```yue |
| @@ -532,6 +553,7 @@ y\func! | |||
| 532 | 553 | ||
| 533 | assert y.__class.__parent ~= X -- X is not parent of Y | 554 | assert y.__class.__parent ~= X -- X is not parent of Y |
| 534 | ``` | 555 | ``` |
| 556 | |||
| 535 | <YueDisplay> | 557 | <YueDisplay> |
| 536 | 558 | ||
| 537 | ```yue | 559 | ```yue |
diff --git a/doc/docs/doc/objects/with-statement.md b/doc/docs/doc/objects/with-statement.md index 7786803..5d7fea3 100644 --- a/doc/docs/doc/objects/with-statement.md +++ b/doc/docs/doc/objects/with-statement.md | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | # With Statement | 1 | # With Statement |
| 2 | 2 | ||
| 3 | |||
| 4 | A common pattern involving the creation of an object is calling a series of functions and setting a series of properties immediately after creating it. | 3 | A common pattern involving the creation of an object is calling a series of functions and setting a series of properties immediately after creating it. |
| 5 | 4 | ||
| 6 | This results in repeating the name of the object multiple times in code, adding unnecessary noise. A common solution to this is to pass a table in as an argument which contains a collection of keys and values to overwrite. The downside to this is that the constructor of this object must support this form. | 5 | This results in repeating the name of the object multiple times in code, adding unnecessary noise. A common solution to this is to pass a table in as an argument which contains a collection of keys and values to overwrite. The downside to this is that the constructor of this object must support this form. |
| @@ -16,6 +15,7 @@ with Person! | |||
| 16 | \save! | 15 | \save! |
| 17 | print .name | 16 | print .name |
| 18 | ``` | 17 | ``` |
| 18 | |||
| 19 | <YueDisplay> | 19 | <YueDisplay> |
| 20 | 20 | ||
| 21 | ```yue | 21 | ```yue |
| @@ -34,6 +34,7 @@ The with statement can also be used as an expression which returns the value it | |||
| 34 | file = with File "favorite_foods.txt" | 34 | file = with File "favorite_foods.txt" |
| 35 | \set_encoding "utf8" | 35 | \set_encoding "utf8" |
| 36 | ``` | 36 | ``` |
| 37 | |||
| 37 | <YueDisplay> | 38 | <YueDisplay> |
| 38 | 39 | ||
| 39 | ```yue | 40 | ```yue |
| @@ -53,6 +54,7 @@ create_person = (name, relatives) -> | |||
| 53 | 54 | ||
| 54 | me = create_person "Leaf", [dad, mother, sister] | 55 | me = create_person "Leaf", [dad, mother, sister] |
| 55 | ``` | 56 | ``` |
| 57 | |||
| 56 | <YueDisplay> | 58 | <YueDisplay> |
| 57 | 59 | ||
| 58 | ```yue | 60 | ```yue |
| @@ -75,6 +77,7 @@ with str := "Hello" | |||
| 75 | print "original:", str | 77 | print "original:", str |
| 76 | print "upper:", \upper! | 78 | print "upper:", \upper! |
| 77 | ``` | 79 | ``` |
| 80 | |||
| 78 | <YueDisplay> | 81 | <YueDisplay> |
| 79 | 82 | ||
| 80 | ```yue | 83 | ```yue |
| @@ -96,6 +99,7 @@ with tb | |||
| 96 | ["key-name"] = value | 99 | ["key-name"] = value |
| 97 | [] = "abc" -- appending to "tb" | 100 | [] = "abc" -- appending to "tb" |
| 98 | ``` | 101 | ``` |
| 102 | |||
| 99 | <YueDisplay> | 103 | <YueDisplay> |
| 100 | 104 | ||
| 101 | ```yue | 105 | ```yue |
| @@ -116,6 +120,7 @@ with tb | |||
| 116 | with? obj | 120 | with? obj |
| 117 | print obj.name | 121 | print obj.name |
| 118 | ``` | 122 | ``` |
| 123 | |||
| 119 | <YueDisplay> | 124 | <YueDisplay> |
| 120 | 125 | ||
| 121 | ```yue | 126 | ```yue |
diff --git a/doc/docs/doc/reference/the-yuescript-library.md b/doc/docs/doc/reference/the-yuescript-library.md index 3761755..817bfab 100644 --- a/doc/docs/doc/reference/the-yuescript-library.md +++ b/doc/docs/doc/reference/the-yuescript-library.md | |||
| @@ -17,6 +17,7 @@ The YueScript language library. | |||
| 17 | The YueScript version. | 17 | The YueScript version. |
| 18 | 18 | ||
| 19 | **Signature:** | 19 | **Signature:** |
| 20 | |||
| 20 | ```lua | 21 | ```lua |
| 21 | version: string | 22 | version: string |
| 22 | ``` | 23 | ``` |
| @@ -30,6 +31,7 @@ version: string | |||
| 30 | The file separator for the current platform. | 31 | The file separator for the current platform. |
| 31 | 32 | ||
| 32 | **Signature:** | 33 | **Signature:** |
| 34 | |||
| 33 | ```lua | 35 | ```lua |
| 34 | dirsep: string | 36 | dirsep: string |
| 35 | ``` | 37 | ``` |
| @@ -43,6 +45,7 @@ dirsep: string | |||
| 43 | The compiled module code cache. | 45 | The compiled module code cache. |
| 44 | 46 | ||
| 45 | **Signature:** | 47 | **Signature:** |
| 48 | |||
| 46 | ```lua | 49 | ```lua |
| 47 | yue_compiled: {string: string} | 50 | yue_compiled: {string: string} |
| 48 | ``` | 51 | ``` |
| @@ -56,6 +59,7 @@ yue_compiled: {string: string} | |||
| 56 | The YueScript compiling function. It compiles the YueScript code to Lua code. | 59 | The YueScript compiling function. It compiles the YueScript code to Lua code. |
| 57 | 60 | ||
| 58 | **Signature:** | 61 | **Signature:** |
| 62 | |||
| 59 | ```lua | 63 | ```lua |
| 60 | to_lua: function(code: string, config?: Config): | 64 | to_lua: function(code: string, config?: Config): |
| 61 | --[[codes]] string | nil, | 65 | --[[codes]] string | nil, |
| @@ -65,17 +69,17 @@ to_lua: function(code: string, config?: Config): | |||
| 65 | 69 | ||
| 66 | **Parameters:** | 70 | **Parameters:** |
| 67 | 71 | ||
| 68 | | Parameter | Type | Description | | 72 | | Parameter | Type | Description | |
| 69 | | --- | --- | --- | | 73 | | --------- | ------ | -------------------------------- | |
| 70 | | code | string | The YueScript code. | | 74 | | code | string | The YueScript code. | |
| 71 | | config | Config | [Optional] The compiler options. | | 75 | | config | Config | [Optional] The compiler options. | |
| 72 | 76 | ||
| 73 | **Returns:** | 77 | **Returns:** |
| 74 | 78 | ||
| 75 | | Return Type | Description | | 79 | | Return Type | Description | |
| 76 | | --- | --- | | 80 | | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | |
| 77 | | string \| nil | The compiled Lua code, or nil if the compilation failed. | | 81 | | string \| nil | The compiled Lua code, or nil if the compilation failed. | |
| 78 | | string \| nil | The error message, or nil if the compilation succeeded. | | 82 | | string \| nil | The error message, or nil if the compilation succeeded. | |
| 79 | | {{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. | | 83 | | {{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. | |
| 80 | 84 | ||
| 81 | ### file_exist | 85 | ### file_exist |
| @@ -87,21 +91,22 @@ to_lua: function(code: string, config?: Config): | |||
| 87 | The source file existence checking function. Can be overridden to customize the behavior. | 91 | The source file existence checking function. Can be overridden to customize the behavior. |
| 88 | 92 | ||
| 89 | **Signature:** | 93 | **Signature:** |
| 94 | |||
| 90 | ```lua | 95 | ```lua |
| 91 | file_exist: function(filename: string): boolean | 96 | file_exist: function(filename: string): boolean |
| 92 | ``` | 97 | ``` |
| 93 | 98 | ||
| 94 | **Parameters:** | 99 | **Parameters:** |
| 95 | 100 | ||
| 96 | | Parameter | Type | Description | | 101 | | Parameter | Type | Description | |
| 97 | | --- | --- | --- | | 102 | | --------- | ------ | -------------- | |
| 98 | | filename | string | The file name. | | 103 | | filename | string | The file name. | |
| 99 | 104 | ||
| 100 | **Returns:** | 105 | **Returns:** |
| 101 | 106 | ||
| 102 | | Return Type | Description | | 107 | | Return Type | Description | |
| 103 | | --- | --- | | 108 | | ----------- | ------------------------ | |
| 104 | | boolean | Whether the file exists. | | 109 | | boolean | Whether the file exists. | |
| 105 | 110 | ||
| 106 | ### read_file | 111 | ### read_file |
| 107 | 112 | ||
| @@ -112,21 +117,22 @@ file_exist: function(filename: string): boolean | |||
| 112 | The source file reading function. Can be overridden to customize the behavior. | 117 | The source file reading function. Can be overridden to customize the behavior. |
| 113 | 118 | ||
| 114 | **Signature:** | 119 | **Signature:** |
| 120 | |||
| 115 | ```lua | 121 | ```lua |
| 116 | read_file: function(filename: string): string | 122 | read_file: function(filename: string): string |
| 117 | ``` | 123 | ``` |
| 118 | 124 | ||
| 119 | **Parameters:** | 125 | **Parameters:** |
| 120 | 126 | ||
| 121 | | Parameter | Type | Description | | 127 | | Parameter | Type | Description | |
| 122 | | --- | --- | --- | | 128 | | --------- | ------ | -------------- | |
| 123 | | filename | string | The file name. | | 129 | | filename | string | The file name. | |
| 124 | 130 | ||
| 125 | **Returns:** | 131 | **Returns:** |
| 126 | 132 | ||
| 127 | | Return Type | Description | | 133 | | Return Type | Description | |
| 128 | | --- | --- | | 134 | | ----------- | ----------------- | |
| 129 | | string | The file content. | | 135 | | string | The file content. | |
| 130 | 136 | ||
| 131 | ### insert_loader | 137 | ### insert_loader |
| 132 | 138 | ||
| @@ -137,21 +143,22 @@ read_file: function(filename: string): string | |||
| 137 | Insert the YueScript loader to the package loaders (searchers). | 143 | Insert the YueScript loader to the package loaders (searchers). |
| 138 | 144 | ||
| 139 | **Signature:** | 145 | **Signature:** |
| 146 | |||
| 140 | ```lua | 147 | ```lua |
| 141 | insert_loader: function(pos?: integer): boolean | 148 | insert_loader: function(pos?: integer): boolean |
| 142 | ``` | 149 | ``` |
| 143 | 150 | ||
| 144 | **Parameters:** | 151 | **Parameters:** |
| 145 | 152 | ||
| 146 | | Parameter | Type | Description | | 153 | | Parameter | Type | Description | |
| 147 | | --- | --- | --- | | 154 | | --------- | ------- | ----------------------------------------------------------- | |
| 148 | | pos | integer | [Optional] The position to insert the loader. Default is 3. | | 155 | | pos | integer | [Optional] The position to insert the loader. Default is 3. | |
| 149 | 156 | ||
| 150 | **Returns:** | 157 | **Returns:** |
| 151 | 158 | ||
| 152 | | Return Type | Description | | 159 | | Return Type | Description | |
| 153 | | --- | --- | | 160 | | ----------- | -------------------------------------------------------------------------------------------- | |
| 154 | | boolean | Whether the loader is inserted successfully. It will fail if the loader is already inserted. | | 161 | | boolean | Whether the loader is inserted successfully. It will fail if the loader is already inserted. | |
| 155 | 162 | ||
| 156 | ### remove_loader | 163 | ### remove_loader |
| 157 | 164 | ||
| @@ -162,15 +169,16 @@ insert_loader: function(pos?: integer): boolean | |||
| 162 | Remove the YueScript loader from the package loaders (searchers). | 169 | Remove the YueScript loader from the package loaders (searchers). |
| 163 | 170 | ||
| 164 | **Signature:** | 171 | **Signature:** |
| 172 | |||
| 165 | ```lua | 173 | ```lua |
| 166 | remove_loader: function(): boolean | 174 | remove_loader: function(): boolean |
| 167 | ``` | 175 | ``` |
| 168 | 176 | ||
| 169 | **Returns:** | 177 | **Returns:** |
| 170 | 178 | ||
| 171 | | Return Type | Description | | 179 | | Return Type | Description | |
| 172 | | --- | --- | | 180 | | ----------- | --------------------------------------------------------------------------------------- | |
| 173 | | boolean | Whether the loader is removed successfully. It will fail if the loader is not inserted. | | 181 | | boolean | Whether the loader is removed successfully. It will fail if the loader is not inserted. | |
| 174 | 182 | ||
| 175 | ### loadstring | 183 | ### loadstring |
| 176 | 184 | ||
| @@ -181,6 +189,7 @@ remove_loader: function(): boolean | |||
| 181 | Loads YueScript code from a string into a function. | 189 | Loads YueScript code from a string into a function. |
| 182 | 190 | ||
| 183 | **Signature:** | 191 | **Signature:** |
| 192 | |||
| 184 | ```lua | 193 | ```lua |
| 185 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): | 194 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): |
| 186 | --[[loaded function]] nil | function(...: any): (any...), | 195 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -189,19 +198,19 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 189 | 198 | ||
| 190 | **Parameters:** | 199 | **Parameters:** |
| 191 | 200 | ||
| 192 | | Parameter | Type | Description | | 201 | | Parameter | Type | Description | |
| 193 | | --- | --- | --- | | 202 | | --------- | ------ | -------------------------------- | |
| 194 | | input | string | The YueScript code. | | 203 | | input | string | The YueScript code. | |
| 195 | | chunkname | string | The name of the code chunk. | | 204 | | chunkname | string | The name of the code chunk. | |
| 196 | | env | table | The environment table. | | 205 | | env | table | The environment table. | |
| 197 | | config | Config | [Optional] The compiler options. | | 206 | | config | Config | [Optional] The compiler options. | |
| 198 | 207 | ||
| 199 | **Returns:** | 208 | **Returns:** |
| 200 | 209 | ||
| 201 | | Return Type | Description | | 210 | | Return Type | Description | |
| 202 | | --- | --- | | 211 | | --------------- | --------------------------------------------------- | |
| 203 | | function \| nil | The loaded function, or nil if the loading failed. | | 212 | | function \| nil | The loaded function, or nil if the loading failed. | |
| 204 | | string \| nil | The error message, or nil if the loading succeeded. | | 213 | | string \| nil | The error message, or nil if the loading succeeded. | |
| 205 | 214 | ||
| 206 | ### loadstring | 215 | ### loadstring |
| 207 | 216 | ||
| @@ -212,6 +221,7 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 212 | Loads YueScript code from a string into a function. | 221 | Loads YueScript code from a string into a function. |
| 213 | 222 | ||
| 214 | **Signature:** | 223 | **Signature:** |
| 224 | |||
| 215 | ```lua | 225 | ```lua |
| 216 | loadstring: function(input: string, chunkname: string, config?: Config): | 226 | loadstring: function(input: string, chunkname: string, config?: Config): |
| 217 | --[[loaded function]] nil | function(...: any): (any...), | 227 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -220,18 +230,18 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 220 | 230 | ||
| 221 | **Parameters:** | 231 | **Parameters:** |
| 222 | 232 | ||
| 223 | | Parameter | Type | Description | | 233 | | Parameter | Type | Description | |
| 224 | | --- | --- | --- | | 234 | | --------- | ------ | -------------------------------- | |
| 225 | | input | string | The YueScript code. | | 235 | | input | string | The YueScript code. | |
| 226 | | chunkname | string | The name of the code chunk. | | 236 | | chunkname | string | The name of the code chunk. | |
| 227 | | config | Config | [Optional] The compiler options. | | 237 | | config | Config | [Optional] The compiler options. | |
| 228 | 238 | ||
| 229 | **Returns:** | 239 | **Returns:** |
| 230 | 240 | ||
| 231 | | Return Type | Description | | 241 | | Return Type | Description | |
| 232 | | --- | --- | | 242 | | --------------- | --------------------------------------------------- | |
| 233 | | function \| nil | The loaded function, or nil if the loading failed. | | 243 | | function \| nil | The loaded function, or nil if the loading failed. | |
| 234 | | string \| nil | The error message, or nil if the loading succeeded. | | 244 | | string \| nil | The error message, or nil if the loading succeeded. | |
| 235 | 245 | ||
| 236 | ### loadstring | 246 | ### loadstring |
| 237 | 247 | ||
| @@ -242,6 +252,7 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 242 | Loads YueScript code from a string into a function. | 252 | Loads YueScript code from a string into a function. |
| 243 | 253 | ||
| 244 | **Signature:** | 254 | **Signature:** |
| 255 | |||
| 245 | ```lua | 256 | ```lua |
| 246 | loadstring: function(input: string, config?: Config): | 257 | loadstring: function(input: string, config?: Config): |
| 247 | --[[loaded function]] nil | function(...: any): (any...), | 258 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -250,17 +261,17 @@ loadstring: function(input: string, config?: Config): | |||
| 250 | 261 | ||
| 251 | **Parameters:** | 262 | **Parameters:** |
| 252 | 263 | ||
| 253 | | Parameter | Type | Description | | 264 | | Parameter | Type | Description | |
| 254 | | --- | --- | --- | | 265 | | --------- | ------ | -------------------------------- | |
| 255 | | input | string | The YueScript code. | | 266 | | input | string | The YueScript code. | |
| 256 | | config | Config | [Optional] The compiler options. | | 267 | | config | Config | [Optional] The compiler options. | |
| 257 | 268 | ||
| 258 | **Returns:** | 269 | **Returns:** |
| 259 | 270 | ||
| 260 | | Return Type | Description | | 271 | | Return Type | Description | |
| 261 | | --- | --- | | 272 | | --------------- | --------------------------------------------------- | |
| 262 | | function \| nil | The loaded function, or nil if the loading failed. | | 273 | | function \| nil | The loaded function, or nil if the loading failed. | |
| 263 | | string \| nil | The error message, or nil if the loading succeeded. | | 274 | | string \| nil | The error message, or nil if the loading succeeded. | |
| 264 | 275 | ||
| 265 | ### loadfile | 276 | ### loadfile |
| 266 | 277 | ||
| @@ -271,6 +282,7 @@ loadstring: function(input: string, config?: Config): | |||
| 271 | Loads YueScript code from a file into a function. | 282 | Loads YueScript code from a file into a function. |
| 272 | 283 | ||
| 273 | **Signature:** | 284 | **Signature:** |
| 285 | |||
| 274 | ```lua | 286 | ```lua |
| 275 | loadfile: function(filename: string, env: table, config?: Config): | 287 | loadfile: function(filename: string, env: table, config?: Config): |
| 276 | nil | function(...: any): (any...), | 288 | nil | function(...: any): (any...), |
| @@ -279,18 +291,18 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 279 | 291 | ||
| 280 | **Parameters:** | 292 | **Parameters:** |
| 281 | 293 | ||
| 282 | | Parameter | Type | Description | | 294 | | Parameter | Type | Description | |
| 283 | | --- | --- | --- | | 295 | | --------- | ------ | -------------------------------- | |
| 284 | | filename | string | The file name. | | 296 | | filename | string | The file name. | |
| 285 | | env | table | The environment table. | | 297 | | env | table | The environment table. | |
| 286 | | config | Config | [Optional] The compiler options. | | 298 | | config | Config | [Optional] The compiler options. | |
| 287 | 299 | ||
| 288 | **Returns:** | 300 | **Returns:** |
| 289 | 301 | ||
| 290 | | Return Type | Description | | 302 | | Return Type | Description | |
| 291 | | --- | --- | | 303 | | --------------- | --------------------------------------------------- | |
| 292 | | function \| nil | The loaded function, or nil if the loading failed. | | 304 | | function \| nil | The loaded function, or nil if the loading failed. | |
| 293 | | string \| nil | The error message, or nil if the loading succeeded. | | 305 | | string \| nil | The error message, or nil if the loading succeeded. | |
| 294 | 306 | ||
| 295 | ### loadfile | 307 | ### loadfile |
| 296 | 308 | ||
| @@ -301,6 +313,7 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 301 | Loads YueScript code from a file into a function. | 313 | Loads YueScript code from a file into a function. |
| 302 | 314 | ||
| 303 | **Signature:** | 315 | **Signature:** |
| 316 | |||
| 304 | ```lua | 317 | ```lua |
| 305 | loadfile: function(filename: string, config?: Config): | 318 | loadfile: function(filename: string, config?: Config): |
| 306 | nil | function(...: any): (any...), | 319 | nil | function(...: any): (any...), |
| @@ -309,17 +322,17 @@ loadfile: function(filename: string, config?: Config): | |||
| 309 | 322 | ||
| 310 | **Parameters:** | 323 | **Parameters:** |
| 311 | 324 | ||
| 312 | | Parameter | Type | Description | | 325 | | Parameter | Type | Description | |
| 313 | | --- | --- | --- | | 326 | | --------- | ------ | -------------------------------- | |
| 314 | | filename | string | The file name. | | 327 | | filename | string | The file name. | |
| 315 | | config | Config | [Optional] The compiler options. | | 328 | | config | Config | [Optional] The compiler options. | |
| 316 | 329 | ||
| 317 | **Returns:** | 330 | **Returns:** |
| 318 | 331 | ||
| 319 | | Return Type | Description | | 332 | | Return Type | Description | |
| 320 | | --- | --- | | 333 | | --------------- | --------------------------------------------------- | |
| 321 | | function \| nil | The loaded function, or nil if the loading failed. | | 334 | | function \| nil | The loaded function, or nil if the loading failed. | |
| 322 | | string \| nil | The error message, or nil if the loading succeeded. | | 335 | | string \| nil | The error message, or nil if the loading succeeded. | |
| 323 | 336 | ||
| 324 | ### dofile | 337 | ### dofile |
| 325 | 338 | ||
| @@ -330,23 +343,24 @@ loadfile: function(filename: string, config?: Config): | |||
| 330 | Loads YueScript code from a file into a function and executes it. | 343 | Loads YueScript code from a file into a function and executes it. |
| 331 | 344 | ||
| 332 | **Signature:** | 345 | **Signature:** |
| 346 | |||
| 333 | ```lua | 347 | ```lua |
| 334 | dofile: function(filename: string, env: table, config?: Config): any... | 348 | dofile: function(filename: string, env: table, config?: Config): any... |
| 335 | ``` | 349 | ``` |
| 336 | 350 | ||
| 337 | **Parameters:** | 351 | **Parameters:** |
| 338 | 352 | ||
| 339 | | Parameter | Type | Description | | 353 | | Parameter | Type | Description | |
| 340 | | --- | --- | --- | | 354 | | --------- | ------ | -------------------------------- | |
| 341 | | filename | string | The file name. | | 355 | | filename | string | The file name. | |
| 342 | | env | table | The environment table. | | 356 | | env | table | The environment table. | |
| 343 | | config | Config | [Optional] The compiler options. | | 357 | | config | Config | [Optional] The compiler options. | |
| 344 | 358 | ||
| 345 | **Returns:** | 359 | **Returns:** |
| 346 | 360 | ||
| 347 | | Return Type | Description | | 361 | | Return Type | Description | |
| 348 | | --- | --- | | 362 | | ----------- | ----------------------------------------- | |
| 349 | | any... | The return values of the loaded function. | | 363 | | any... | The return values of the loaded function. | |
| 350 | 364 | ||
| 351 | ### dofile | 365 | ### dofile |
| 352 | 366 | ||
| @@ -357,22 +371,23 @@ dofile: function(filename: string, env: table, config?: Config): any... | |||
| 357 | Loads YueScript code from a file into a function and executes it. | 371 | Loads YueScript code from a file into a function and executes it. |
| 358 | 372 | ||
| 359 | **Signature:** | 373 | **Signature:** |
| 374 | |||
| 360 | ```lua | 375 | ```lua |
| 361 | dofile: function(filename: string, config?: Config): any... | 376 | dofile: function(filename: string, config?: Config): any... |
| 362 | ``` | 377 | ``` |
| 363 | 378 | ||
| 364 | **Parameters:** | 379 | **Parameters:** |
| 365 | 380 | ||
| 366 | | Parameter | Type | Description | | 381 | | Parameter | Type | Description | |
| 367 | | --- | --- | --- | | 382 | | --------- | ------ | -------------------------------- | |
| 368 | | filename | string | The file name. | | 383 | | filename | string | The file name. | |
| 369 | | config | Config | [Optional] The compiler options. | | 384 | | config | Config | [Optional] The compiler options. | |
| 370 | 385 | ||
| 371 | **Returns:** | 386 | **Returns:** |
| 372 | 387 | ||
| 373 | | Return Type | Description | | 388 | | Return Type | Description | |
| 374 | | --- | --- | | 389 | | ----------- | ----------------------------------------- | |
| 375 | | any... | The return values of the loaded function. | | 390 | | any... | The return values of the loaded function. | |
| 376 | 391 | ||
| 377 | ### find_modulepath | 392 | ### find_modulepath |
| 378 | 393 | ||
| @@ -383,21 +398,22 @@ dofile: function(filename: string, config?: Config): any... | |||
| 383 | Resolves the YueScript module name to the file path. | 398 | Resolves the YueScript module name to the file path. |
| 384 | 399 | ||
| 385 | **Signature:** | 400 | **Signature:** |
| 401 | |||
| 386 | ```lua | 402 | ```lua |
| 387 | find_modulepath: function(name: string): string | 403 | find_modulepath: function(name: string): string |
| 388 | ``` | 404 | ``` |
| 389 | 405 | ||
| 390 | **Parameters:** | 406 | **Parameters:** |
| 391 | 407 | ||
| 392 | | Parameter | Type | Description | | 408 | | Parameter | Type | Description | |
| 393 | | --- | --- | --- | | 409 | | --------- | ------ | ---------------- | |
| 394 | | name | string | The module name. | | 410 | | name | string | The module name. | |
| 395 | 411 | ||
| 396 | **Returns:** | 412 | **Returns:** |
| 397 | 413 | ||
| 398 | | Return Type | Description | | 414 | | Return Type | Description | |
| 399 | | --- | --- | | 415 | | ----------- | -------------- | |
| 400 | | string | The file path. | | 416 | | string | The file path. | |
| 401 | 417 | ||
| 402 | ### pcall | 418 | ### pcall |
| 403 | 419 | ||
| @@ -410,21 +426,22 @@ Catches any errors and returns a status code and results or error object. | |||
| 410 | Rewrites the error line number to the original line number in the YueScript code when errors occur. | 426 | Rewrites the error line number to the original line number in the YueScript code when errors occur. |
| 411 | 427 | ||
| 412 | **Signature:** | 428 | **Signature:** |
| 429 | |||
| 413 | ```lua | 430 | ```lua |
| 414 | pcall: function(f: function, ...: any): boolean, any... | 431 | pcall: function(f: function, ...: any): boolean, any... |
| 415 | ``` | 432 | ``` |
| 416 | 433 | ||
| 417 | **Parameters:** | 434 | **Parameters:** |
| 418 | 435 | ||
| 419 | | Parameter | Type | Description | | 436 | | Parameter | Type | Description | |
| 420 | | --- | --- | --- | | 437 | | --------- | -------- | ---------------------------------- | |
| 421 | | f | function | The function to call. | | 438 | | f | function | The function to call. | |
| 422 | | ... | any | Arguments to pass to the function. | | 439 | | ... | any | Arguments to pass to the function. | |
| 423 | 440 | ||
| 424 | **Returns:** | 441 | **Returns:** |
| 425 | 442 | ||
| 426 | | Return Type | Description | | 443 | | Return Type | Description | |
| 427 | | --- | --- | | 444 | | ------------ | ------------------------------------------------- | |
| 428 | | boolean, ... | Status code and function results or error object. | | 445 | | boolean, ... | Status code and function results or error object. | |
| 429 | 446 | ||
| 430 | ### require | 447 | ### require |
| @@ -437,21 +454,22 @@ Loads a given module. Can be either a Lua module or a YueScript module. | |||
| 437 | Rewrites the error line number to the original line number in the YueScript code if the module is a YueScript module and loading fails. | 454 | Rewrites the error line number to the original line number in the YueScript code if the module is a YueScript module and loading fails. |
| 438 | 455 | ||
| 439 | **Signature:** | 456 | **Signature:** |
| 457 | |||
| 440 | ```lua | 458 | ```lua |
| 441 | require: function(name: string): any... | 459 | require: function(name: string): any... |
| 442 | ``` | 460 | ``` |
| 443 | 461 | ||
| 444 | **Parameters:** | 462 | **Parameters:** |
| 445 | 463 | ||
| 446 | | Parameter | Type | Description | | 464 | | Parameter | Type | Description | |
| 447 | | --- | --- | --- | | 465 | | --------- | ------ | ------------------------------- | |
| 448 | | modname | string | The name of the module to load. | | 466 | | modname | string | The name of the module to load. | |
| 449 | 467 | ||
| 450 | **Returns:** | 468 | **Returns:** |
| 451 | 469 | ||
| 452 | | Return Type | Description | | 470 | | Return Type | Description | |
| 453 | | --- | --- | | 471 | | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 454 | | 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. | | 472 | | 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. | |
| 455 | 473 | ||
| 456 | ### p | 474 | ### p |
| 457 | 475 | ||
| @@ -462,15 +480,16 @@ require: function(name: string): any... | |||
| 462 | Inspects the structures of the passed values and prints string representations. | 480 | Inspects the structures of the passed values and prints string representations. |
| 463 | 481 | ||
| 464 | **Signature:** | 482 | **Signature:** |
| 483 | |||
| 465 | ```lua | 484 | ```lua |
| 466 | p: function(...: any) | 485 | p: function(...: any) |
| 467 | ``` | 486 | ``` |
| 468 | 487 | ||
| 469 | **Parameters:** | 488 | **Parameters:** |
| 470 | 489 | ||
| 471 | | Parameter | Type | Description | | 490 | | Parameter | Type | Description | |
| 472 | | --- | --- | --- | | 491 | | --------- | ---- | ---------------------- | |
| 473 | | ... | any | The values to inspect. | | 492 | | ... | any | The values to inspect. | |
| 474 | 493 | ||
| 475 | ### options | 494 | ### options |
| 476 | 495 | ||
| @@ -481,6 +500,7 @@ p: function(...: any) | |||
| 481 | The current compiler options. | 500 | The current compiler options. |
| 482 | 501 | ||
| 483 | **Signature:** | 502 | **Signature:** |
| 503 | |||
| 484 | ```lua | 504 | ```lua |
| 485 | options: Config.Options | 505 | options: Config.Options |
| 486 | ``` | 506 | ``` |
| @@ -494,21 +514,22 @@ options: Config.Options | |||
| 494 | The traceback function that rewrites the stack trace line numbers to the original line numbers in the YueScript code. | 514 | The traceback function that rewrites the stack trace line numbers to the original line numbers in the YueScript code. |
| 495 | 515 | ||
| 496 | **Signature:** | 516 | **Signature:** |
| 517 | |||
| 497 | ```lua | 518 | ```lua |
| 498 | traceback: function(message: string): string | 519 | traceback: function(message: string): string |
| 499 | ``` | 520 | ``` |
| 500 | 521 | ||
| 501 | **Parameters:** | 522 | **Parameters:** |
| 502 | 523 | ||
| 503 | | Parameter | Type | Description | | 524 | | Parameter | Type | Description | |
| 504 | | --- | --- | --- | | 525 | | --------- | ------ | ---------------------- | |
| 505 | | message | string | The traceback message. | | 526 | | message | string | The traceback message. | |
| 506 | 527 | ||
| 507 | **Returns:** | 528 | **Returns:** |
| 508 | 529 | ||
| 509 | | Return Type | Description | | 530 | | Return Type | Description | |
| 510 | | --- | --- | | 531 | | ----------- | -------------------------------- | |
| 511 | | string | The rewritten traceback message. | | 532 | | string | The rewritten traceback message. | |
| 512 | 533 | ||
| 513 | ### is_ast | 534 | ### is_ast |
| 514 | 535 | ||
| @@ -519,22 +540,23 @@ traceback: function(message: string): string | |||
| 519 | Checks whether the code matches the specified AST. | 540 | Checks whether the code matches the specified AST. |
| 520 | 541 | ||
| 521 | **Signature:** | 542 | **Signature:** |
| 543 | |||
| 522 | ```lua | 544 | ```lua |
| 523 | is_ast: function(astName: string, code: string): boolean | 545 | is_ast: function(astName: string, code: string): boolean |
| 524 | ``` | 546 | ``` |
| 525 | 547 | ||
| 526 | **Parameters:** | 548 | **Parameters:** |
| 527 | 549 | ||
| 528 | | Parameter | Type | Description | | 550 | | Parameter | Type | Description | |
| 529 | | --- | --- | --- | | 551 | | --------- | ------ | ------------- | |
| 530 | | astName | string | The AST name. | | 552 | | astName | string | The AST name. | |
| 531 | | code | string | The code. | | 553 | | code | string | The code. | |
| 532 | 554 | ||
| 533 | **Returns:** | 555 | **Returns:** |
| 534 | 556 | ||
| 535 | | Return Type | Description | | 557 | | Return Type | Description | |
| 536 | | --- | --- | | 558 | | ----------- | --------------------------------- | |
| 537 | | boolean | Whether the code matches the AST. | | 559 | | boolean | Whether the code matches the AST. | |
| 538 | 560 | ||
| 539 | ### AST | 561 | ### AST |
| 540 | 562 | ||
| @@ -545,6 +567,7 @@ is_ast: function(astName: string, code: string): boolean | |||
| 545 | The AST type definition with name, row, column and sub nodes. | 567 | The AST type definition with name, row, column and sub nodes. |
| 546 | 568 | ||
| 547 | **Signature:** | 569 | **Signature:** |
| 570 | |||
| 548 | ```lua | 571 | ```lua |
| 549 | type AST = {string, integer, integer, any} | 572 | type AST = {string, integer, integer, any} |
| 550 | ``` | 573 | ``` |
| @@ -558,6 +581,7 @@ type AST = {string, integer, integer, any} | |||
| 558 | Converts the code to the AST. | 581 | Converts the code to the AST. |
| 559 | 582 | ||
| 560 | **Signature:** | 583 | **Signature:** |
| 584 | |||
| 561 | ```lua | 585 | ```lua |
| 562 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): | 586 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): |
| 563 | --[[AST]] AST | nil, | 587 | --[[AST]] AST | nil, |
| @@ -566,18 +590,18 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 566 | 590 | ||
| 567 | **Parameters:** | 591 | **Parameters:** |
| 568 | 592 | ||
| 569 | | Parameter | Type | Description | | 593 | | Parameter | Type | Description | |
| 570 | | --- | --- | --- | | 594 | | -------------- | ------- | --------------------------------------------------------------------------------------------- | |
| 571 | | code | string | The code. | | 595 | | code | string | The code. | |
| 572 | | flattenLevel | integer | [Optional] The flatten level. Higher level means more flattening. Default is 0. Maximum is 2. | | 596 | | flattenLevel | integer | [Optional] The flatten level. Higher level means more flattening. Default is 0. Maximum is 2. | |
| 573 | | astName | string | [Optional] The AST name. Default is "File". | | 597 | | astName | string | [Optional] The AST name. Default is "File". | |
| 574 | | reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is false. | | 598 | | reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is false. | |
| 575 | 599 | ||
| 576 | **Returns:** | 600 | **Returns:** |
| 577 | 601 | ||
| 578 | | Return Type | Description | | 602 | | Return Type | Description | |
| 579 | | --- | --- | | 603 | | ------------- | ------------------------------------------------------ | |
| 580 | | AST \| nil | The AST, or nil if the conversion failed. | | 604 | | AST \| nil | The AST, or nil if the conversion failed. | |
| 581 | | string \| nil | The error message, or nil if the conversion succeeded. | | 605 | | string \| nil | The error message, or nil if the conversion succeeded. | |
| 582 | 606 | ||
| 583 | ### format | 607 | ### format |
| @@ -589,25 +613,26 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 589 | Formats the YueScript code. | 613 | Formats the YueScript code. |
| 590 | 614 | ||
| 591 | **Signature:** | 615 | **Signature:** |
| 616 | |||
| 592 | ```lua | 617 | ```lua |
| 593 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string | 618 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string |
| 594 | ``` | 619 | ``` |
| 595 | 620 | ||
| 596 | **Parameters:** | 621 | **Parameters:** |
| 597 | 622 | ||
| 598 | | Parameter | Type | Description | | 623 | | Parameter | Type | Description | |
| 599 | | --- | --- | --- | | 624 | | -------------- | ------- | --------------------------------------------------------------------- | |
| 600 | | code | string | The code. | | 625 | | code | string | The code. | |
| 601 | | tabSize | integer | [Optional] The tab size. Default is 4. | | 626 | | tabSize | integer | [Optional] The tab size. Default is 4. | |
| 602 | | reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is true. | | 627 | | reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is true. | |
| 603 | 628 | ||
| 604 | **Returns:** | 629 | **Returns:** |
| 605 | 630 | ||
| 606 | | Return Type | Description | | 631 | | Return Type | Description | |
| 607 | | --- | --- | | 632 | | ----------- | ------------------- | |
| 608 | | string | The formatted code. | | 633 | | string | The formatted code. | |
| 609 | 634 | ||
| 610 | ### __call | 635 | ### \_\_call |
| 611 | 636 | ||
| 612 | **Type:** Metamethod. | 637 | **Type:** Metamethod. |
| 613 | 638 | ||
| @@ -617,21 +642,22 @@ Requires the YueScript module. | |||
| 617 | Rewrites the error line number to the original line number in the YueScript code when loading fails. | 642 | Rewrites the error line number to the original line number in the YueScript code when loading fails. |
| 618 | 643 | ||
| 619 | **Signature:** | 644 | **Signature:** |
| 645 | |||
| 620 | ```lua | 646 | ```lua |
| 621 | metamethod __call: function(self: yue, module: string): any... | 647 | metamethod __call: function(self: yue, module: string): any... |
| 622 | ``` | 648 | ``` |
| 623 | 649 | ||
| 624 | **Parameters:** | 650 | **Parameters:** |
| 625 | 651 | ||
| 626 | | Parameter | Type | Description | | 652 | | Parameter | Type | Description | |
| 627 | | --- | --- | --- | | 653 | | --------- | ------ | ---------------- | |
| 628 | | module | string | The module name. | | 654 | | module | string | The module name. | |
| 629 | 655 | ||
| 630 | **Returns:** | 656 | **Returns:** |
| 631 | 657 | ||
| 632 | | Return Type | Description | | 658 | | Return Type | Description | |
| 633 | | --- | --- | | 659 | | ----------- | ----------------- | |
| 634 | | any | The module value. | | 660 | | any | The module value. | |
| 635 | 661 | ||
| 636 | ## Config | 662 | ## Config |
| 637 | 663 | ||
| @@ -648,6 +674,7 @@ The compiler compile options. | |||
| 648 | Whether the compiler should collect the global variables appearing in the code. | 674 | Whether the compiler should collect the global variables appearing in the code. |
| 649 | 675 | ||
| 650 | **Signature:** | 676 | **Signature:** |
| 677 | |||
| 651 | ```lua | 678 | ```lua |
| 652 | lint_global: boolean | 679 | lint_global: boolean |
| 653 | ``` | 680 | ``` |
| @@ -661,6 +688,7 @@ lint_global: boolean | |||
| 661 | Whether the compiler should do an implicit return for the root code block. | 688 | Whether the compiler should do an implicit return for the root code block. |
| 662 | 689 | ||
| 663 | **Signature:** | 690 | **Signature:** |
| 691 | |||
| 664 | ```lua | 692 | ```lua |
| 665 | implicit_return_root: boolean | 693 | implicit_return_root: boolean |
| 666 | ``` | 694 | ``` |
| @@ -674,6 +702,7 @@ implicit_return_root: boolean | |||
| 674 | Whether the compiler should reserve the original line number in the compiled code. | 702 | Whether the compiler should reserve the original line number in the compiled code. |
| 675 | 703 | ||
| 676 | **Signature:** | 704 | **Signature:** |
| 705 | |||
| 677 | ```lua | 706 | ```lua |
| 678 | reserve_line_number: boolean | 707 | reserve_line_number: boolean |
| 679 | ``` | 708 | ``` |
| @@ -687,6 +716,7 @@ reserve_line_number: boolean | |||
| 687 | Whether the compiler should reserve the original comments in the compiled code. | 716 | Whether the compiler should reserve the original comments in the compiled code. |
| 688 | 717 | ||
| 689 | **Signature:** | 718 | **Signature:** |
| 719 | |||
| 690 | ```lua | 720 | ```lua |
| 691 | reserve_comment: boolean | 721 | reserve_comment: boolean |
| 692 | ``` | 722 | ``` |
| @@ -700,6 +730,7 @@ reserve_comment: boolean | |||
| 700 | Whether the compiler should use the space character instead of the tab character in the compiled code. | 730 | Whether the compiler should use the space character instead of the tab character in the compiled code. |
| 701 | 731 | ||
| 702 | **Signature:** | 732 | **Signature:** |
| 733 | |||
| 703 | ```lua | 734 | ```lua |
| 704 | space_over_tab: boolean | 735 | space_over_tab: boolean |
| 705 | ``` | 736 | ``` |
| @@ -713,6 +744,7 @@ space_over_tab: boolean | |||
| 713 | Whether the compiler should treat the code to be compiled as the same currently being compiled module. For internal use only. | 744 | Whether the compiler should treat the code to be compiled as the same currently being compiled module. For internal use only. |
| 714 | 745 | ||
| 715 | **Signature:** | 746 | **Signature:** |
| 747 | |||
| 716 | ```lua | 748 | ```lua |
| 717 | same_module: boolean | 749 | same_module: boolean |
| 718 | ``` | 750 | ``` |
| @@ -726,6 +758,7 @@ same_module: boolean | |||
| 726 | Whether the compiler error message should include the line number offset. For internal use only. | 758 | Whether the compiler error message should include the line number offset. For internal use only. |
| 727 | 759 | ||
| 728 | **Signature:** | 760 | **Signature:** |
| 761 | |||
| 729 | ```lua | 762 | ```lua |
| 730 | line_offset: integer | 763 | line_offset: integer |
| 731 | ``` | 764 | ``` |
| @@ -739,6 +772,7 @@ line_offset: integer | |||
| 739 | The target Lua version enumeration. | 772 | The target Lua version enumeration. |
| 740 | 773 | ||
| 741 | **Signature:** | 774 | **Signature:** |
| 775 | |||
| 742 | ```lua | 776 | ```lua |
| 743 | enum LuaTarget | 777 | enum LuaTarget |
| 744 | "5.1" | 778 | "5.1" |
| @@ -758,6 +792,7 @@ end | |||
| 758 | The extra options to be passed to the compilation function. | 792 | The extra options to be passed to the compilation function. |
| 759 | 793 | ||
| 760 | **Signature:** | 794 | **Signature:** |
| 795 | |||
| 761 | ```lua | 796 | ```lua |
| 762 | options: Options | 797 | options: Options |
| 763 | ``` | 798 | ``` |
| @@ -777,6 +812,7 @@ The extra compiler options definition. | |||
| 777 | The target Lua version for the compilation. | 812 | The target Lua version for the compilation. |
| 778 | 813 | ||
| 779 | **Signature:** | 814 | **Signature:** |
| 815 | |||
| 780 | ```lua | 816 | ```lua |
| 781 | target: LuaTarget | 817 | target: LuaTarget |
| 782 | ``` | 818 | ``` |
| @@ -790,6 +826,7 @@ target: LuaTarget | |||
| 790 | The extra module search path. | 826 | The extra module search path. |
| 791 | 827 | ||
| 792 | **Signature:** | 828 | **Signature:** |
| 829 | |||
| 793 | ```lua | 830 | ```lua |
| 794 | path: string | 831 | path: string |
| 795 | ``` | 832 | ``` |
| @@ -803,6 +840,7 @@ path: string | |||
| 803 | Whether to dump the local variables in the traceback error message. Default is false. | 840 | Whether to dump the local variables in the traceback error message. Default is false. |
| 804 | 841 | ||
| 805 | **Signature:** | 842 | **Signature:** |
| 843 | |||
| 806 | ```lua | 844 | ```lua |
| 807 | dump_locals: boolean | 845 | dump_locals: boolean |
| 808 | ``` | 846 | ``` |
| @@ -816,6 +854,7 @@ dump_locals: boolean | |||
| 816 | Whether to simplify the error message. Default is true. | 854 | Whether to simplify the error message. Default is true. |
| 817 | 855 | ||
| 818 | **Signature:** | 856 | **Signature:** |
| 857 | |||
| 819 | ```lua | 858 | ```lua |
| 820 | simplified: boolean | 859 | simplified: boolean |
| 821 | ``` | 860 | ``` |
diff --git a/doc/docs/id-id/doc/advanced/do.md b/doc/docs/id-id/doc/advanced/do.md index ebbd2e2..ac75531 100644 --- a/doc/docs/id-id/doc/advanced/do.md +++ b/doc/docs/id-id/doc/advanced/do.md | |||
| @@ -8,6 +8,7 @@ do | |||
| 8 | print var | 8 | print var |
| 9 | print var -- nil di sini | 9 | print var -- nil di sini |
| 10 | ``` | 10 | ``` |
| 11 | |||
| 11 | <YueDisplay> | 12 | <YueDisplay> |
| 12 | 13 | ||
| 13 | ```yue | 14 | ```yue |
| @@ -31,6 +32,7 @@ counter = do | |||
| 31 | print counter! | 32 | print counter! |
| 32 | print counter! | 33 | print counter! |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -53,6 +55,7 @@ tbl = { | |||
| 53 | 1234 | 55 | 1234 |
| 54 | } | 56 | } |
| 55 | ``` | 57 | ``` |
| 58 | |||
| 56 | <YueDisplay> | 59 | <YueDisplay> |
| 57 | 60 | ||
| 58 | ```yue | 61 | ```yue |
diff --git a/doc/docs/id-id/doc/advanced/line-decorators.md b/doc/docs/id-id/doc/advanced/line-decorators.md index e90e205..d968b1f 100644 --- a/doc/docs/id-id/doc/advanced/line-decorators.md +++ b/doc/docs/id-id/doc/advanced/line-decorators.md | |||
| @@ -5,6 +5,7 @@ Untuk kemudahan, loop for dan pernyataan if dapat diterapkan pada pernyataan tun | |||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | print "hello world" if name == "Rob" | 6 | print "hello world" if name == "Rob" |
| 7 | ``` | 7 | ``` |
| 8 | |||
| 8 | <YueDisplay> | 9 | <YueDisplay> |
| 9 | 10 | ||
| 10 | ```yue | 11 | ```yue |
| @@ -18,6 +19,7 @@ Dan dengan loop dasar: | |||
| 18 | ```yuescript | 19 | ```yuescript |
| 19 | print "item: ", item for item in *items | 20 | print "item: ", item for item in *items |
| 20 | ``` | 21 | ``` |
| 22 | |||
| 21 | <YueDisplay> | 23 | <YueDisplay> |
| 22 | 24 | ||
| 23 | ```yue | 25 | ```yue |
| @@ -33,6 +35,7 @@ game\update! while game\isRunning! | |||
| 33 | 35 | ||
| 34 | reader\parse_line! until reader\eof! | 36 | reader\parse_line! until reader\eof! |
| 35 | ``` | 37 | ``` |
| 38 | |||
| 36 | <YueDisplay> | 39 | <YueDisplay> |
| 37 | 40 | ||
| 38 | ```yue | 41 | ```yue |
diff --git a/doc/docs/id-id/doc/advanced/macro.md b/doc/docs/id-id/doc/advanced/macro.md index ce0bafa..d33ec5b 100644 --- a/doc/docs/id-id/doc/advanced/macro.md +++ b/doc/docs/id-id/doc/advanced/macro.md | |||
| @@ -32,6 +32,7 @@ macro and = (...) -> "#{ table.concat {...}, ' and ' }" | |||
| 32 | if $and f1!, f2!, f3! | 32 | if $and f1!, f2!, f3! |
| 33 | print "OK" | 33 | print "OK" |
| 34 | ``` | 34 | ``` |
| 35 | |||
| 35 | <YueDisplay> | 36 | <YueDisplay> |
| 36 | 37 | ||
| 37 | ```yue | 38 | ```yue |
| @@ -68,6 +69,7 @@ if $and f1!, f2!, f3! | |||
| 68 | ## Menyisipkan Kode Mentah | 69 | ## Menyisipkan Kode Mentah |
| 69 | 70 | ||
| 70 | Fungsi macro bisa mengembalikan string YueScript atau tabel konfigurasi yang berisi kode Lua. | 71 | Fungsi macro bisa mengembalikan string YueScript atau tabel konfigurasi yang berisi kode Lua. |
| 72 | |||
| 71 | ```yuescript | 73 | ```yuescript |
| 72 | macro yueFunc = (var) -> "local #{var} = ->" | 74 | macro yueFunc = (var) -> "local #{var} = ->" |
| 73 | $yueFunc funcA | 75 | $yueFunc funcA |
| @@ -93,6 +95,7 @@ if cond then | |||
| 93 | end | 95 | end |
| 94 | ]==] | 96 | ]==] |
| 95 | ``` | 97 | ``` |
| 98 | |||
| 96 | <YueDisplay> | 99 | <YueDisplay> |
| 97 | 100 | ||
| 98 | ```yue | 101 | ```yue |
| @@ -126,6 +129,7 @@ end | |||
| 126 | ## Export Macro | 129 | ## Export Macro |
| 127 | 130 | ||
| 128 | Fungsi macro dapat diekspor dari modul dan diimpor di modul lain. Anda harus menaruh fungsi macro export dalam satu file agar dapat digunakan, dan hanya definisi macro, impor macro, dan ekspansi macro yang boleh ada di modul export macro. | 131 | Fungsi macro dapat diekspor dari modul dan diimpor di modul lain. Anda harus menaruh fungsi macro export dalam satu file agar dapat digunakan, dan hanya definisi macro, impor macro, dan ekspansi macro yang boleh ada di modul export macro. |
| 132 | |||
| 129 | ```yuescript | 133 | ```yuescript |
| 130 | -- file: utils.yue | 134 | -- file: utils.yue |
| 131 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" | 135 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" |
| @@ -140,6 +144,7 @@ import "utils" as { | |||
| 140 | } | 144 | } |
| 141 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ | 145 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ |
| 142 | ``` | 146 | ``` |
| 147 | |||
| 143 | <YueDisplay> | 148 | <YueDisplay> |
| 144 | 149 | ||
| 145 | ```yue | 150 | ```yue |
| @@ -165,10 +170,12 @@ import "utils" as { | |||
| 165 | ## Macro Bawaan | 170 | ## Macro Bawaan |
| 166 | 171 | ||
| 167 | Ada beberapa macro bawaan tetapi Anda bisa menimpanya dengan mendeklarasikan macro dengan nama yang sama. | 172 | Ada beberapa macro bawaan tetapi Anda bisa menimpanya dengan mendeklarasikan macro dengan nama yang sama. |
| 173 | |||
| 168 | ```yuescript | 174 | ```yuescript |
| 169 | print $FILE -- mendapatkan string nama modul saat ini | 175 | print $FILE -- mendapatkan string nama modul saat ini |
| 170 | print $LINE -- mendapatkan angka 2 | 176 | print $LINE -- mendapatkan angka 2 |
| 171 | ``` | 177 | ``` |
| 178 | |||
| 172 | <YueDisplay> | 179 | <YueDisplay> |
| 173 | 180 | ||
| 174 | ```yue | 181 | ```yue |
| @@ -235,6 +242,7 @@ macro printNumAndStr = (num `Num, str `String) -> | | |||
| 235 | 242 | ||
| 236 | $printNumAndStr 123, "hello" | 243 | $printNumAndStr 123, "hello" |
| 237 | ``` | 244 | ``` |
| 245 | |||
| 238 | <YueDisplay> | 246 | <YueDisplay> |
| 239 | 247 | ||
| 240 | ```yue | 248 | ```yue |
| @@ -259,6 +267,7 @@ macro printNumAndStr = (num, str) -> | |||
| 259 | 267 | ||
| 260 | $printNumAndStr 123, "hello" | 268 | $printNumAndStr 123, "hello" |
| 261 | ``` | 269 | ``` |
| 270 | |||
| 262 | <YueDisplay> | 271 | <YueDisplay> |
| 263 | 272 | ||
| 264 | ```yue | 273 | ```yue |
diff --git a/doc/docs/id-id/doc/advanced/module.md b/doc/docs/id-id/doc/advanced/module.md index dd97a32..103e3f6 100644 --- a/doc/docs/id-id/doc/advanced/module.md +++ b/doc/docs/id-id/doc/advanced/module.md | |||
| @@ -28,6 +28,7 @@ do | |||
| 28 | import "lpeg" as :C, :Ct, :Cmt | 28 | import "lpeg" as :C, :Ct, :Cmt |
| 29 | import "export" as {one, two, Something:{umm:{ch}}} | 29 | import "export" as {one, two, Something:{umm:{ch}}} |
| 30 | ``` | 30 | ``` |
| 31 | |||
| 31 | <YueDisplay> | 32 | <YueDisplay> |
| 32 | 33 | ||
| 33 | ```yue | 34 | ```yue |
| @@ -67,6 +68,7 @@ do | |||
| 67 | import table.concat | 68 | import table.concat |
| 68 | print concat ["a", tostring 1] | 69 | print concat ["a", tostring 1] |
| 69 | ``` | 70 | ``` |
| 71 | |||
| 70 | <YueDisplay> | 72 | <YueDisplay> |
| 71 | 73 | ||
| 72 | ```yue | 74 | ```yue |
| @@ -98,6 +100,7 @@ do | |||
| 98 | print FLAG | 100 | print FLAG |
| 99 | FLAG = 123 | 101 | FLAG = 123 |
| 100 | ``` | 102 | ``` |
| 103 | |||
| 101 | <YueDisplay> | 104 | <YueDisplay> |
| 102 | 105 | ||
| 103 | ```yue | 106 | ```yue |
| @@ -140,6 +143,7 @@ export y = -> | |||
| 140 | export class Something | 143 | export class Something |
| 141 | umm: "cool" | 144 | umm: "cool" |
| 142 | ``` | 145 | ``` |
| 146 | |||
| 143 | <YueDisplay> | 147 | <YueDisplay> |
| 144 | 148 | ||
| 145 | ```yue | 149 | ```yue |
| @@ -166,6 +170,7 @@ Melakukan export bernama dengan destrukturisasi. | |||
| 166 | export :loadstring, to_lua: tolua = yue | 170 | export :loadstring, to_lua: tolua = yue |
| 167 | export {itemA: {:fieldA = 'default'}} = tb | 171 | export {itemA: {:fieldA = 'default'}} = tb |
| 168 | ``` | 172 | ``` |
| 173 | |||
| 169 | <YueDisplay> | 174 | <YueDisplay> |
| 170 | 175 | ||
| 171 | ```yue | 176 | ```yue |
| @@ -182,6 +187,7 @@ export.itemA = tb | |||
| 182 | export.<index> = items | 187 | export.<index> = items |
| 183 | export["a-b-c"] = 123 | 188 | export["a-b-c"] = 123 |
| 184 | ``` | 189 | ``` |
| 190 | |||
| 185 | <YueDisplay> | 191 | <YueDisplay> |
| 186 | 192 | ||
| 187 | ```yue | 193 | ```yue |
| @@ -208,6 +214,7 @@ else | |||
| 208 | export with tmp | 214 | export with tmp |
| 209 | j = 2000 | 215 | j = 2000 |
| 210 | ``` | 216 | ``` |
| 217 | |||
| 211 | <YueDisplay> | 218 | <YueDisplay> |
| 212 | 219 | ||
| 213 | ```yue | 220 | ```yue |
| @@ -234,6 +241,7 @@ export default -> | |||
| 234 | print "hello" | 241 | print "hello" |
| 235 | 123 | 242 | 123 |
| 236 | ``` | 243 | ``` |
| 244 | |||
| 237 | <YueDisplay> | 245 | <YueDisplay> |
| 238 | 246 | ||
| 239 | ```yue | 247 | ```yue |
diff --git a/doc/docs/id-id/doc/advanced/try.md b/doc/docs/id-id/doc/advanced/try.md index 6607451..4e63004 100644 --- a/doc/docs/id-id/doc/advanced/try.md +++ b/doc/docs/id-id/doc/advanced/try.md | |||
| @@ -29,6 +29,7 @@ catch err | |||
| 29 | print yue.traceback err | 29 | print yue.traceback err |
| 30 | print result | 30 | print result |
| 31 | ``` | 31 | ``` |
| 32 | |||
| 32 | <YueDisplay> | 33 | <YueDisplay> |
| 33 | 34 | ||
| 34 | ```yue | 35 | ```yue |
| @@ -82,6 +83,7 @@ catch e | |||
| 82 | print e | 83 | print e |
| 83 | e | 84 | e |
| 84 | ``` | 85 | ``` |
| 86 | |||
| 85 | <YueDisplay> | 87 | <YueDisplay> |
| 86 | 88 | ||
| 87 | ```yue | 89 | ```yue |
diff --git a/doc/docs/id-id/doc/assignment/assignment.md b/doc/docs/id-id/doc/assignment/assignment.md index d9fd45d..34e18fd 100644 --- a/doc/docs/id-id/doc/assignment/assignment.md +++ b/doc/docs/id-id/doc/assignment/assignment.md | |||
| @@ -7,6 +7,7 @@ hello = "world" | |||
| 7 | a, b, c = 1, 2, 3 | 7 | a, b, c = 1, 2, 3 |
| 8 | hello = 123 -- menggunakan variabel yang sudah ada | 8 | hello = 123 -- menggunakan variabel yang sudah ada |
| 9 | ``` | 9 | ``` |
| 10 | |||
| 10 | <YueDisplay> | 11 | <YueDisplay> |
| 11 | 12 | ||
| 12 | ```yue | 13 | ```yue |
| @@ -20,6 +21,7 @@ hello = 123 -- menggunakan variabel yang sudah ada | |||
| 20 | ## Pembaruan Nilai | 21 | ## Pembaruan Nilai |
| 21 | 22 | ||
| 22 | Anda dapat melakukan assignment pembaruan dengan banyak operator biner. | 23 | Anda dapat melakukan assignment pembaruan dengan banyak operator biner. |
| 24 | |||
| 23 | ```yuescript | 25 | ```yuescript |
| 24 | x = 1 | 26 | x = 1 |
| 25 | x += 1 | 27 | x += 1 |
| @@ -30,6 +32,7 @@ x %= 10 | |||
| 30 | s ..= "world" -- akan menambah local baru jika variabel local belum ada | 32 | s ..= "world" -- akan menambah local baru jika variabel local belum ada |
| 31 | arg or= "default value" | 33 | arg or= "default value" |
| 32 | ``` | 34 | ``` |
| 35 | |||
| 33 | <YueDisplay> | 36 | <YueDisplay> |
| 34 | 37 | ||
| 35 | ```yue | 38 | ```yue |
| @@ -48,10 +51,12 @@ arg or= "default value" | |||
| 48 | ## Assignment Berantai | 51 | ## Assignment Berantai |
| 49 | 52 | ||
| 50 | Anda bisa melakukan assignment berantai untuk menetapkan beberapa item ke nilai yang sama. | 53 | Anda bisa melakukan assignment berantai untuk menetapkan beberapa item ke nilai yang sama. |
| 54 | |||
| 51 | ```yuescript | 55 | ```yuescript |
| 52 | a = b = c = d = e = 0 | 56 | a = b = c = d = e = 0 |
| 53 | x = y = z = f! | 57 | x = y = z = f! |
| 54 | ``` | 58 | ``` |
| 59 | |||
| 55 | <YueDisplay> | 60 | <YueDisplay> |
| 56 | 61 | ||
| 57 | ```yue | 62 | ```yue |
| @@ -62,6 +67,7 @@ x = y = z = f! | |||
| 62 | </YueDisplay> | 67 | </YueDisplay> |
| 63 | 68 | ||
| 64 | ## Local Eksplisit | 69 | ## Local Eksplisit |
| 70 | |||
| 65 | ```yuescript | 71 | ```yuescript |
| 66 | do | 72 | do |
| 67 | local a = 1 | 73 | local a = 1 |
| @@ -78,6 +84,7 @@ do | |||
| 78 | a = 1 | 84 | a = 1 |
| 79 | B = 2 | 85 | B = 2 |
| 80 | ``` | 86 | ``` |
| 87 | |||
| 81 | <YueDisplay> | 88 | <YueDisplay> |
| 82 | 89 | ||
| 83 | ```yue | 90 | ```yue |
| @@ -100,6 +107,7 @@ do | |||
| 100 | </YueDisplay> | 107 | </YueDisplay> |
| 101 | 108 | ||
| 102 | ## Global Eksplisit | 109 | ## Global Eksplisit |
| 110 | |||
| 103 | ```yuescript | 111 | ```yuescript |
| 104 | do | 112 | do |
| 105 | global a = 1 | 113 | global a = 1 |
| @@ -116,6 +124,7 @@ do | |||
| 116 | B = 2 | 124 | B = 2 |
| 117 | local Temp = "a local value" | 125 | local Temp = "a local value" |
| 118 | ``` | 126 | ``` |
| 127 | |||
| 119 | <YueDisplay> | 128 | <YueDisplay> |
| 120 | 129 | ||
| 121 | ```yue | 130 | ```yue |
diff --git a/doc/docs/id-id/doc/assignment/destructuring-assignment.md b/doc/docs/id-id/doc/assignment/destructuring-assignment.md index ba591fd..b9956a8 100644 --- a/doc/docs/id-id/doc/assignment/destructuring-assignment.md +++ b/doc/docs/id-id/doc/assignment/destructuring-assignment.md | |||
| @@ -12,6 +12,7 @@ thing = [1, 2] | |||
| 12 | [a, b] = thing | 12 | [a, b] = thing |
| 13 | print a, b | 13 | print a, b |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -37,6 +38,7 @@ print hello, the_day | |||
| 37 | 38 | ||
| 38 | :day = obj -- OK untuk destrukturisasi sederhana tanpa kurung | 39 | :day = obj -- OK untuk destrukturisasi sederhana tanpa kurung |
| 39 | ``` | 40 | ``` |
| 41 | |||
| 40 | <YueDisplay> | 42 | <YueDisplay> |
| 41 | 43 | ||
| 42 | ```yue | 44 | ```yue |
| @@ -68,6 +70,7 @@ obj2 = { | |||
| 68 | {numbers: [first, second], properties: {color: color}} = obj2 | 70 | {numbers: [first, second], properties: {color: color}} = obj2 |
| 69 | print first, second, color | 71 | print first, second, color |
| 70 | ``` | 72 | ``` |
| 73 | |||
| 71 | <YueDisplay> | 74 | <YueDisplay> |
| 72 | 75 | ||
| 73 | ```yue | 76 | ```yue |
| @@ -95,6 +98,7 @@ Jika pernyataan destrukturisasi kompleks, Anda bisa memecahnya ke beberapa baris | |||
| 95 | } | 98 | } |
| 96 | } = obj2 | 99 | } = obj2 |
| 97 | ``` | 100 | ``` |
| 101 | |||
| 98 | <YueDisplay> | 102 | <YueDisplay> |
| 99 | 103 | ||
| 100 | ```yue | 104 | ```yue |
| @@ -113,6 +117,7 @@ Umumnya mengekstrak nilai dari tabel lalu menugaskannya ke variabel local dengan | |||
| 113 | ```yuescript | 117 | ```yuescript |
| 114 | {:concat, :insert} = table | 118 | {:concat, :insert} = table |
| 115 | ``` | 119 | ``` |
| 120 | |||
| 116 | <YueDisplay> | 121 | <YueDisplay> |
| 117 | 122 | ||
| 118 | ```yue | 123 | ```yue |
| @@ -126,6 +131,7 @@ Ini secara efektif sama seperti import, tetapi kita dapat mengganti nama field y | |||
| 126 | ```yuescript | 131 | ```yuescript |
| 127 | {:mix, :max, random: rand} = math | 132 | {:mix, :max, random: rand} = math |
| 128 | ``` | 133 | ``` |
| 134 | |||
| 129 | <YueDisplay> | 135 | <YueDisplay> |
| 130 | 136 | ||
| 131 | ```yue | 137 | ```yue |
| @@ -139,6 +145,7 @@ Anda bisa menulis nilai default saat destrukturisasi seperti: | |||
| 139 | ```yuescript | 145 | ```yuescript |
| 140 | {:name = "nameless", :job = "jobless"} = person | 146 | {:name = "nameless", :job = "jobless"} = person |
| 141 | ``` | 147 | ``` |
| 148 | |||
| 142 | <YueDisplay> | 149 | <YueDisplay> |
| 143 | 150 | ||
| 144 | ```yue | 151 | ```yue |
| @@ -152,6 +159,7 @@ Anda dapat menggunakan `_` sebagai placeholder saat destrukturisasi list: | |||
| 152 | ```yuescript | 159 | ```yuescript |
| 153 | [_, two, _, four] = items | 160 | [_, two, _, four] = items |
| 154 | ``` | 161 | ``` |
| 162 | |||
| 155 | <YueDisplay> | 163 | <YueDisplay> |
| 156 | 164 | ||
| 157 | ```yue | 165 | ```yue |
| @@ -171,6 +179,7 @@ print first -- prints: first | |||
| 171 | print bulk -- prints: {"second", "third", "fourth"} | 179 | print bulk -- prints: {"second", "third", "fourth"} |
| 172 | print last -- prints: last | 180 | print last -- prints: last |
| 173 | ``` | 181 | ``` |
| 182 | |||
| 174 | <YueDisplay> | 183 | <YueDisplay> |
| 175 | 184 | ||
| 176 | ```yue | 185 | ```yue |
| @@ -195,6 +204,7 @@ Operator spread dapat digunakan pada posisi berbeda untuk menangkap rentang yang | |||
| 195 | -- Tangkap semuanya kecuali elemen tengah | 204 | -- Tangkap semuanya kecuali elemen tengah |
| 196 | [first, ..._, last] = orders | 205 | [first, ..._, last] = orders |
| 197 | ``` | 206 | ``` |
| 207 | |||
| 198 | <YueDisplay> | 208 | <YueDisplay> |
| 199 | 209 | ||
| 200 | ```yue | 210 | ```yue |
| @@ -223,6 +233,7 @@ tuples = [ | |||
| 223 | for [left, right] in *tuples | 233 | for [left, right] in *tuples |
| 224 | print left, right | 234 | print left, right |
| 225 | ``` | 235 | ``` |
| 236 | |||
| 226 | <YueDisplay> | 237 | <YueDisplay> |
| 227 | 238 | ||
| 228 | ```yue | 239 | ```yue |
diff --git a/doc/docs/id-id/doc/assignment/if-assignment.md b/doc/docs/id-id/doc/assignment/if-assignment.md index b30d0d9..e212859 100644 --- a/doc/docs/id-id/doc/assignment/if-assignment.md +++ b/doc/docs/id-id/doc/assignment/if-assignment.md | |||
| @@ -6,6 +6,7 @@ Blok `if` dan `elseif` dapat menerima assignment sebagai ganti ekspresi kondisio | |||
| 6 | if user := database.find_user "moon" | 6 | if user := database.find_user "moon" |
| 7 | print user.name | 7 | print user.name |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -23,6 +24,7 @@ elseif world := os.getenv "world" | |||
| 23 | else | 24 | else |
| 24 | print "nothing :(" | 25 | print "nothing :(" |
| 25 | ``` | 26 | ``` |
| 27 | |||
| 26 | <YueDisplay> | 28 | <YueDisplay> |
| 27 | 29 | ||
| 28 | ```yue | 30 | ```yue |
| @@ -37,11 +39,13 @@ else | |||
| 37 | </YueDisplay> | 39 | </YueDisplay> |
| 38 | 40 | ||
| 39 | Assignment if dengan beberapa nilai return. Hanya nilai pertama yang dicek, nilai lainnya tetap berada dalam scope. | 41 | Assignment if dengan beberapa nilai return. Hanya nilai pertama yang dicek, nilai lainnya tetap berada dalam scope. |
| 42 | |||
| 40 | ```yuescript | 43 | ```yuescript |
| 41 | if success, result := pcall -> "get result without problems" | 44 | if success, result := pcall -> "get result without problems" |
| 42 | print result -- variabel result berada dalam scope | 45 | print result -- variabel result berada dalam scope |
| 43 | print "OK" | 46 | print "OK" |
| 44 | ``` | 47 | ``` |
| 48 | |||
| 45 | <YueDisplay> | 49 | <YueDisplay> |
| 46 | 50 | ||
| 47 | ```yue | 51 | ```yue |
| @@ -61,6 +65,7 @@ while byte := stream\read_one! | |||
| 61 | -- lakukan sesuatu dengan byte | 65 | -- lakukan sesuatu dengan byte |
| 62 | print byte | 66 | print byte |
| 63 | ``` | 67 | ``` |
| 68 | |||
| 64 | <YueDisplay> | 69 | <YueDisplay> |
| 65 | 70 | ||
| 66 | ```yue | 71 | ```yue |
diff --git a/doc/docs/id-id/doc/assignment/the-using-clause-controlling-destructive-assignment.md b/doc/docs/id-id/doc/assignment/the-using-clause-controlling-destructive-assignment.md index 6953138..6e47f0c 100644 --- a/doc/docs/id-id/doc/assignment/the-using-clause-controlling-destructive-assignment.md +++ b/doc/docs/id-id/doc/assignment/the-using-clause-controlling-destructive-assignment.md | |||
| @@ -17,6 +17,7 @@ my_func! | |||
| 17 | 17 | ||
| 18 | print i -- akan mencetak 0 | 18 | print i -- akan mencetak 0 |
| 19 | ``` | 19 | ``` |
| 20 | |||
| 20 | <YueDisplay> | 21 | <YueDisplay> |
| 21 | 22 | ||
| 22 | ```yue | 23 | ```yue |
| @@ -52,6 +53,7 @@ my_func = (using nil) -> | |||
| 52 | my_func! | 53 | my_func! |
| 53 | print i -- mencetak 100, i tidak terpengaruh | 54 | print i -- mencetak 100, i tidak terpengaruh |
| 54 | ``` | 55 | ``` |
| 56 | |||
| 55 | <YueDisplay> | 57 | <YueDisplay> |
| 56 | 58 | ||
| 57 | ```yue | 59 | ```yue |
| @@ -80,6 +82,7 @@ my_func = (add using k, i) -> | |||
| 80 | my_func(22) | 82 | my_func(22) |
| 81 | print i, k -- ini telah diperbarui | 83 | print i, k -- ini telah diperbarui |
| 82 | ``` | 84 | ``` |
| 85 | |||
| 83 | <YueDisplay> | 86 | <YueDisplay> |
| 84 | 87 | ||
| 85 | ```yue | 88 | ```yue |
diff --git a/doc/docs/id-id/doc/assignment/varargs-assignment.md b/doc/docs/id-id/doc/assignment/varargs-assignment.md index f24652f..9c5c8a3 100644 --- a/doc/docs/id-id/doc/assignment/varargs-assignment.md +++ b/doc/docs/id-id/doc/assignment/varargs-assignment.md | |||
| @@ -10,6 +10,7 @@ count = select '#', ... | |||
| 10 | first = select 1, ... | 10 | first = select 1, ... |
| 11 | print ok, count, first | 11 | print ok, count, first |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
diff --git a/doc/docs/id-id/doc/control-flow/conditionals.md b/doc/docs/id-id/doc/control-flow/conditionals.md index 4f08b16..861eae6 100644 --- a/doc/docs/id-id/doc/control-flow/conditionals.md +++ b/doc/docs/id-id/doc/control-flow/conditionals.md | |||
| @@ -7,6 +7,7 @@ if have_coins | |||
| 7 | else | 7 | else |
| 8 | print "Tidak ada koin" | 8 | print "Tidak ada koin" |
| 9 | ``` | 9 | ``` |
| 10 | |||
| 10 | <YueDisplay> | 11 | <YueDisplay> |
| 11 | 12 | ||
| 12 | ```yue | 13 | ```yue |
| @@ -25,6 +26,7 @@ Sintaks pendek untuk pernyataan tunggal juga bisa digunakan: | |||
| 25 | have_coins = false | 26 | have_coins = false |
| 26 | if have_coins then print "Dapat koin" else print "Tidak ada koin" | 27 | if have_coins then print "Dapat koin" else print "Tidak ada koin" |
| 27 | ``` | 28 | ``` |
| 29 | |||
| 28 | <YueDisplay> | 30 | <YueDisplay> |
| 29 | 31 | ||
| 30 | ```yue | 32 | ```yue |
| @@ -40,6 +42,7 @@ Karena pernyataan if dapat digunakan sebagai ekspresi, ini juga bisa ditulis seb | |||
| 40 | have_coins = false | 42 | have_coins = false |
| 41 | print if have_coins then "Dapat koin" else "Tidak ada koin" | 43 | print if have_coins then "Dapat koin" else "Tidak ada koin" |
| 42 | ``` | 44 | ``` |
| 45 | |||
| 43 | <YueDisplay> | 46 | <YueDisplay> |
| 44 | 47 | ||
| 45 | ```yue | 48 | ```yue |
| @@ -65,6 +68,7 @@ else | |||
| 65 | 68 | ||
| 66 | print message -- prints: Saya sangat tinggi | 69 | print message -- prints: Saya sangat tinggi |
| 67 | ``` | 70 | ``` |
| 71 | |||
| 68 | <YueDisplay> | 72 | <YueDisplay> |
| 69 | 73 | ||
| 70 | ```yue | 74 | ```yue |
| @@ -90,6 +94,7 @@ Kebalikan dari if adalah unless: | |||
| 90 | unless os.date("%A") == "Monday" | 94 | unless os.date("%A") == "Monday" |
| 91 | print "hari ini bukan Senin!" | 95 | print "hari ini bukan Senin!" |
| 92 | ``` | 96 | ``` |
| 97 | |||
| 93 | <YueDisplay> | 98 | <YueDisplay> |
| 94 | 99 | ||
| 95 | ```yue | 100 | ```yue |
| @@ -102,6 +107,7 @@ unless os.date("%A") == "Monday" | |||
| 102 | ```yuescript | 107 | ```yuescript |
| 103 | print "Kamu beruntung!" unless math.random! > 0.1 | 108 | print "Kamu beruntung!" unless math.random! > 0.1 |
| 104 | ``` | 109 | ``` |
| 110 | |||
| 105 | <YueDisplay> | 111 | <YueDisplay> |
| 106 | 112 | ||
| 107 | ```yue | 113 | ```yue |
| @@ -123,6 +129,7 @@ if a in [1, 3, 5, 7] | |||
| 123 | if a in list | 129 | if a in list |
| 124 | print "memeriksa apakah `a` ada di dalam daftar" | 130 | print "memeriksa apakah `a` ada di dalam daftar" |
| 125 | ``` | 131 | ``` |
| 132 | |||
| 126 | <YueDisplay> | 133 | <YueDisplay> |
| 127 | 134 | ||
| 128 | ```yue | 135 | ```yue |
diff --git a/doc/docs/id-id/doc/control-flow/continue.md b/doc/docs/id-id/doc/control-flow/continue.md index 3d7a68c..798a44b 100644 --- a/doc/docs/id-id/doc/control-flow/continue.md +++ b/doc/docs/id-id/doc/control-flow/continue.md | |||
| @@ -9,6 +9,7 @@ while i < 10 | |||
| 9 | continue if i % 2 == 0 | 9 | continue if i % 2 == 0 |
| 10 | print i | 10 | print i |
| 11 | ``` | 11 | ``` |
| 12 | |||
| 12 | <YueDisplay> | 13 | <YueDisplay> |
| 13 | 14 | ||
| 14 | ```yue | 15 | ```yue |
| @@ -29,6 +30,7 @@ odds = for x in *my_numbers | |||
| 29 | continue if x % 2 == 1 | 30 | continue if x % 2 == 1 |
| 30 | x | 31 | x |
| 31 | ``` | 32 | ``` |
| 33 | |||
| 32 | <YueDisplay> | 34 | <YueDisplay> |
| 33 | 35 | ||
| 34 | ```yue | 36 | ```yue |
diff --git a/doc/docs/id-id/doc/control-flow/for-loop.md b/doc/docs/id-id/doc/control-flow/for-loop.md index 91ba22e..65386f7 100644 --- a/doc/docs/id-id/doc/control-flow/for-loop.md +++ b/doc/docs/id-id/doc/control-flow/for-loop.md | |||
| @@ -12,6 +12,7 @@ for k = 1, 15, 2 -- an optional step provided | |||
| 12 | for key, value in pairs object | 12 | for key, value in pairs object |
| 13 | print key, value | 13 | print key, value |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -33,6 +34,7 @@ Operator slicing dan **\*** dapat digunakan, seperti pada comprehension: | |||
| 33 | for item in *items[2, 4] | 34 | for item in *items[2, 4] |
| 34 | print item | 35 | print item |
| 35 | ``` | 36 | ``` |
| 37 | |||
| 36 | <YueDisplay> | 38 | <YueDisplay> |
| 37 | 39 | ||
| 38 | ```yue | 40 | ```yue |
| @@ -49,6 +51,7 @@ for item in *items do print item | |||
| 49 | 51 | ||
| 50 | for j = 1, 10, 3 do print j | 52 | for j = 1, 10, 3 do print j |
| 51 | ``` | 53 | ``` |
| 54 | |||
| 52 | <YueDisplay> | 55 | <YueDisplay> |
| 53 | 56 | ||
| 54 | ```yue | 57 | ```yue |
| @@ -70,6 +73,7 @@ doubled_evens = for i = 1, 20 | |||
| 70 | else | 73 | else |
| 71 | i | 74 | i |
| 72 | ``` | 75 | ``` |
| 76 | |||
| 73 | <YueDisplay> | 77 | <YueDisplay> |
| 74 | 78 | ||
| 75 | ```yue | 79 | ```yue |
| @@ -90,6 +94,7 @@ Contohnya, untuk menemukan angka pertama yang lebih besar dari 10: | |||
| 90 | first_large = for n in *numbers | 94 | first_large = for n in *numbers |
| 91 | break n if n > 10 | 95 | break n if n > 10 |
| 92 | ``` | 96 | ``` |
| 97 | |||
| 93 | <YueDisplay> | 98 | <YueDisplay> |
| 94 | 99 | ||
| 95 | ```yue | 100 | ```yue |
| @@ -112,6 +117,7 @@ func_b = -> return for i = 1, 10 do i | |||
| 112 | print func_a! -- prints nil | 117 | print func_a! -- prints nil |
| 113 | print func_b! -- prints table object | 118 | print func_b! -- prints table object |
| 114 | ``` | 119 | ``` |
| 120 | |||
| 115 | <YueDisplay> | 121 | <YueDisplay> |
| 116 | 122 | ||
| 117 | ```yue | 123 | ```yue |
diff --git a/doc/docs/id-id/doc/control-flow/switch.md b/doc/docs/id-id/doc/control-flow/switch.md index ced4748..1b7b86e 100644 --- a/doc/docs/id-id/doc/control-flow/switch.md +++ b/doc/docs/id-id/doc/control-flow/switch.md | |||
| @@ -11,6 +11,7 @@ switch name := "Dan" | |||
| 11 | else | 11 | else |
| 12 | print "I don't know about you with name #{name}" | 12 | print "I don't know about you with name #{name}" |
| 13 | ``` | 13 | ``` |
| 14 | |||
| 14 | <YueDisplay> | 15 | <YueDisplay> |
| 15 | 16 | ||
| 16 | ```yue | 17 | ```yue |
| @@ -39,6 +40,7 @@ next_number = switch b | |||
| 39 | else | 40 | else |
| 40 | error "can't count that high!" | 41 | error "can't count that high!" |
| 41 | ``` | 42 | ``` |
| 43 | |||
| 42 | <YueDisplay> | 44 | <YueDisplay> |
| 43 | 45 | ||
| 44 | ```yue | 46 | ```yue |
| @@ -62,6 +64,7 @@ msg = switch math.random(1, 5) | |||
| 62 | when 2 then "you are almost lucky" | 64 | when 2 then "you are almost lucky" |
| 63 | else "not so lucky" | 65 | else "not so lucky" |
| 64 | ``` | 66 | ``` |
| 67 | |||
| 65 | <YueDisplay> | 68 | <YueDisplay> |
| 66 | 69 | ||
| 67 | ```yue | 70 | ```yue |
| @@ -87,6 +90,7 @@ switch math.random(1, 5) when 1 | |||
| 87 | else | 90 | else |
| 88 | print "not so lucky" | 91 | print "not so lucky" |
| 89 | ``` | 92 | ``` |
| 93 | |||
| 90 | <YueDisplay> | 94 | <YueDisplay> |
| 91 | 95 | ||
| 92 | ```yue | 96 | ```yue |
| @@ -124,6 +128,7 @@ for item in *items | |||
| 124 | when :width, :height | 128 | when :width, :height |
| 125 | print "size #{width}, #{height}" | 129 | print "size #{width}, #{height}" |
| 126 | ``` | 130 | ``` |
| 131 | |||
| 127 | <YueDisplay> | 132 | <YueDisplay> |
| 128 | 133 | ||
| 129 | ```yue | 134 | ```yue |
| @@ -154,6 +159,7 @@ switch item | |||
| 154 | when {pos: {:x = 50, :y = 200}} | 159 | when {pos: {:x = 50, :y = 200}} |
| 155 | print "Vec2 #{x}, #{y}" -- table destructuring will still pass | 160 | print "Vec2 #{x}, #{y}" -- table destructuring will still pass |
| 156 | ``` | 161 | ``` |
| 162 | |||
| 157 | <YueDisplay> | 163 | <YueDisplay> |
| 158 | 164 | ||
| 159 | ```yue | 165 | ```yue |
| @@ -181,6 +187,7 @@ switch tb | |||
| 181 | when [1, 2, b = 3] -- b has a default value | 187 | when [1, 2, b = 3] -- b has a default value |
| 182 | print "1, 2, #{b}" | 188 | print "1, 2, #{b}" |
| 183 | ``` | 189 | ``` |
| 190 | |||
| 184 | <YueDisplay> | 191 | <YueDisplay> |
| 185 | 192 | ||
| 186 | ```yue | 193 | ```yue |
| @@ -206,6 +213,7 @@ switch tb | |||
| 206 | else | 213 | else |
| 207 | print "invalid" | 214 | print "invalid" |
| 208 | ``` | 215 | ``` |
| 216 | |||
| 209 | <YueDisplay> | 217 | <YueDisplay> |
| 210 | 218 | ||
| 211 | ```yue | 219 | ```yue |
| @@ -231,6 +239,7 @@ switch tb | |||
| 231 | else | 239 | else |
| 232 | print "invalid" | 240 | print "invalid" |
| 233 | ``` | 241 | ``` |
| 242 | |||
| 234 | <YueDisplay> | 243 | <YueDisplay> |
| 235 | 244 | ||
| 236 | ```yue | 245 | ```yue |
| @@ -257,6 +266,7 @@ switch tb | |||
| 257 | ] | 266 | ] |
| 258 | print "matched", fourth | 267 | print "matched", fourth |
| 259 | ``` | 268 | ``` |
| 269 | |||
| 260 | <YueDisplay> | 270 | <YueDisplay> |
| 261 | 271 | ||
| 262 | ```yue | 272 | ```yue |
| @@ -282,6 +292,7 @@ switch segments | |||
| 282 | print "Resource:", resource -- prints: "logs" | 292 | print "Resource:", resource -- prints: "logs" |
| 283 | print "Action:", action -- prints: "view" | 293 | print "Action:", action -- prints: "view" |
| 284 | ``` | 294 | ``` |
| 295 | |||
| 285 | <YueDisplay> | 296 | <YueDisplay> |
| 286 | 297 | ||
| 287 | ```yue | 298 | ```yue |
diff --git a/doc/docs/id-id/doc/control-flow/while-loop.md b/doc/docs/id-id/doc/control-flow/while-loop.md index cd93c91..3e302cc 100644 --- a/doc/docs/id-id/doc/control-flow/while-loop.md +++ b/doc/docs/id-id/doc/control-flow/while-loop.md | |||
| @@ -10,6 +10,7 @@ while i > 0 | |||
| 10 | 10 | ||
| 11 | while running == true do my_function! | 11 | while running == true do my_function! |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
| @@ -31,6 +32,7 @@ until i == 0 | |||
| 31 | 32 | ||
| 32 | until running == false do my_function! | 33 | until running == false do my_function! |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -56,6 +58,7 @@ repeat | |||
| 56 | i -= 1 | 58 | i -= 1 |
| 57 | until i == 0 | 59 | until i == 0 |
| 58 | ``` | 60 | ``` |
| 61 | |||
| 59 | <YueDisplay> | 62 | <YueDisplay> |
| 60 | 63 | ||
| 61 | ```yue | 64 | ```yue |
diff --git a/doc/docs/id-id/doc/data-structures/comprehensions.md b/doc/docs/id-id/doc/data-structures/comprehensions.md index 3a2a9ff..c5a8f7b 100644 --- a/doc/docs/id-id/doc/data-structures/comprehensions.md +++ b/doc/docs/id-id/doc/data-structures/comprehensions.md | |||
| @@ -10,6 +10,7 @@ Berikut membuat salinan tabel `items` tetapi semua nilainya digandakan. | |||
| 10 | items = [ 1, 2, 3, 4 ] | 10 | items = [ 1, 2, 3, 4 ] |
| 11 | doubled = [item * 2 for i, item in ipairs items] | 11 | doubled = [item * 2 for i, item in ipairs items] |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
| @@ -24,6 +25,7 @@ Item yang disertakan dalam tabel baru bisa dibatasi dengan klausa `when`: | |||
| 24 | ```yuescript | 25 | ```yuescript |
| 25 | slice = [item for i, item in ipairs items when i > 1 and i < 3] | 26 | slice = [item for i, item in ipairs items when i > 1 and i < 3] |
| 26 | ``` | 27 | ``` |
| 28 | |||
| 27 | <YueDisplay> | 29 | <YueDisplay> |
| 28 | 30 | ||
| 29 | ```yue | 31 | ```yue |
| @@ -37,6 +39,7 @@ Karena umum untuk mengiterasi nilai dari tabel berindeks numerik, operator **\** | |||
| 37 | ```yuescript | 39 | ```yuescript |
| 38 | doubled = [item * 2 for item in *items] | 40 | doubled = [item * 2 for item in *items] |
| 39 | ``` | 41 | ``` |
| 42 | |||
| 40 | <YueDisplay> | 43 | <YueDisplay> |
| 41 | 44 | ||
| 42 | ```yue | 45 | ```yue |
| @@ -55,6 +58,7 @@ data = | |||
| 55 | flat = [...v for k,v in pairs data] | 58 | flat = [...v for k,v in pairs data] |
| 56 | -- flat sekarang [1, 2, 3, 4, 5, 6] | 59 | -- flat sekarang [1, 2, 3, 4, 5, 6] |
| 57 | ``` | 60 | ``` |
| 61 | |||
| 58 | <YueDisplay> | 62 | <YueDisplay> |
| 59 | 63 | ||
| 60 | ```yue | 64 | ```yue |
| @@ -79,6 +83,7 @@ y_coords = [9, 2, 3] | |||
| 79 | points = [ [x, y] for x in *x_coords \ | 83 | points = [ [x, y] for x in *x_coords \ |
| 80 | for y in *y_coords] | 84 | for y in *y_coords] |
| 81 | ``` | 85 | ``` |
| 86 | |||
| 82 | <YueDisplay> | 87 | <YueDisplay> |
| 83 | 88 | ||
| 84 | ```yue | 89 | ```yue |
| @@ -96,6 +101,7 @@ Perulangan for numerik juga bisa digunakan dalam komprehensi: | |||
| 96 | ```yuescript | 101 | ```yuescript |
| 97 | evens = [i for i = 1, 100 when i % 2 == 0] | 102 | evens = [i for i = 1, 100 when i % 2 == 0] |
| 98 | ``` | 103 | ``` |
| 104 | |||
| 99 | <YueDisplay> | 105 | <YueDisplay> |
| 100 | 106 | ||
| 101 | ```yue | 107 | ```yue |
| @@ -119,6 +125,7 @@ thing = { | |||
| 119 | 125 | ||
| 120 | thing_copy = {k, v for k, v in pairs thing} | 126 | thing_copy = {k, v for k, v in pairs thing} |
| 121 | ``` | 127 | ``` |
| 128 | |||
| 122 | <YueDisplay> | 129 | <YueDisplay> |
| 123 | 130 | ||
| 124 | ```yue | 131 | ```yue |
| @@ -136,6 +143,7 @@ thing_copy = {k, v for k, v in pairs thing} | |||
| 136 | ```yuescript | 143 | ```yuescript |
| 137 | no_color = {k, v for k, v in pairs thing when k != "color"} | 144 | no_color = {k, v for k, v in pairs thing when k != "color"} |
| 138 | ``` | 145 | ``` |
| 146 | |||
| 139 | <YueDisplay> | 147 | <YueDisplay> |
| 140 | 148 | ||
| 141 | ```yue | 149 | ```yue |
| @@ -150,6 +158,7 @@ Operator **\*** juga didukung. Di sini kita membuat tabel lookup akar kuadrat un | |||
| 150 | numbers = [1, 2, 3, 4] | 158 | numbers = [1, 2, 3, 4] |
| 151 | sqrts = {i, math.sqrt i for i in *numbers} | 159 | sqrts = {i, math.sqrt i for i in *numbers} |
| 152 | ``` | 160 | ``` |
| 161 | |||
| 153 | <YueDisplay> | 162 | <YueDisplay> |
| 154 | 163 | ||
| 155 | ```yue | 164 | ```yue |
| @@ -167,6 +176,7 @@ Dalam contoh ini kita mengonversi array pasangan menjadi tabel di mana item pert | |||
| 167 | tuples = [ ["hello", "world"], ["foo", "bar"]] | 176 | tuples = [ ["hello", "world"], ["foo", "bar"]] |
| 168 | tbl = {unpack tuple for tuple in *tuples} | 177 | tbl = {unpack tuple for tuple in *tuples} |
| 169 | ``` | 178 | ``` |
| 179 | |||
| 170 | <YueDisplay> | 180 | <YueDisplay> |
| 171 | 181 | ||
| 172 | ```yue | 182 | ```yue |
| @@ -185,6 +195,7 @@ Di sini kita bisa menetapkan batas minimum dan maksimum, mengambil semua item de | |||
| 185 | ```yuescript | 195 | ```yuescript |
| 186 | slice = [item for item in *items[1, 5]] | 196 | slice = [item for item in *items[1, 5]] |
| 187 | ``` | 197 | ``` |
| 198 | |||
| 188 | <YueDisplay> | 199 | <YueDisplay> |
| 189 | 200 | ||
| 190 | ```yue | 201 | ```yue |
| @@ -198,6 +209,7 @@ Salah satu argumen slice boleh dikosongkan untuk menggunakan default yang masuk | |||
| 198 | ```yuescript | 209 | ```yuescript |
| 199 | slice = [item for item in *items[2,]] | 210 | slice = [item for item in *items[2,]] |
| 200 | ``` | 211 | ``` |
| 212 | |||
| 201 | <YueDisplay> | 213 | <YueDisplay> |
| 202 | 214 | ||
| 203 | ```yue | 215 | ```yue |
| @@ -211,6 +223,7 @@ Jika batas minimum dikosongkan, defaultnya adalah 1. Di sini kita hanya memberik | |||
| 211 | ```yuescript | 223 | ```yuescript |
| 212 | slice = [item for item in *items[,,2]] | 224 | slice = [item for item in *items[,,2]] |
| 213 | ``` | 225 | ``` |
| 226 | |||
| 214 | <YueDisplay> | 227 | <YueDisplay> |
| 215 | 228 | ||
| 216 | ```yue | 229 | ```yue |
| @@ -225,6 +238,7 @@ Batas minimum dan maksimum bisa bernilai negatif, yang berarti batas dihitung da | |||
| 225 | -- ambil 4 item terakhir | 238 | -- ambil 4 item terakhir |
| 226 | slice = [item for item in *items[-4,-1]] | 239 | slice = [item for item in *items[-4,-1]] |
| 227 | ``` | 240 | ``` |
| 241 | |||
| 228 | <YueDisplay> | 242 | <YueDisplay> |
| 229 | 243 | ||
| 230 | ```yue | 244 | ```yue |
| @@ -239,6 +253,7 @@ Ukuran langkah juga bisa negatif, yang berarti item diambil dalam urutan terbali | |||
| 239 | ```yuescript | 253 | ```yuescript |
| 240 | reverse_slice = [item for item in *items[-1,1,-1]] | 254 | reverse_slice = [item for item in *items[-1,1,-1]] |
| 241 | ``` | 255 | ``` |
| 256 | |||
| 242 | <YueDisplay> | 257 | <YueDisplay> |
| 243 | 258 | ||
| 244 | ```yue | 259 | ```yue |
| @@ -258,6 +273,7 @@ sub_list = items[2, 4] | |||
| 258 | -- ambil 4 item terakhir | 273 | -- ambil 4 item terakhir |
| 259 | last_four_items = items[-4, -1] | 274 | last_four_items = items[-4, -1] |
| 260 | ``` | 275 | ``` |
| 276 | |||
| 261 | <YueDisplay> | 277 | <YueDisplay> |
| 262 | 278 | ||
| 263 | ```yue | 279 | ```yue |
diff --git a/doc/docs/id-id/doc/data-structures/table-literals.md b/doc/docs/id-id/doc/data-structures/table-literals.md index df32f1c..c190f00 100644 --- a/doc/docs/id-id/doc/data-structures/table-literals.md +++ b/doc/docs/id-id/doc/data-structures/table-literals.md | |||
| @@ -5,6 +5,7 @@ Seperti di Lua, tabel dibatasi dengan kurung kurawal. | |||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | some_values = [1, 2, 3, 4] | 6 | some_values = [1, 2, 3, 4] |
| 7 | ``` | 7 | ``` |
| 8 | |||
| 8 | <YueDisplay> | 9 | <YueDisplay> |
| 9 | 10 | ||
| 10 | ```yue | 11 | ```yue |
| @@ -22,6 +23,7 @@ some_values = { | |||
| 22 | ["favorite food"]: "rice" | 23 | ["favorite food"]: "rice" |
| 23 | } | 24 | } |
| 24 | ``` | 25 | ``` |
| 26 | |||
| 25 | <YueDisplay> | 27 | <YueDisplay> |
| 26 | 28 | ||
| 27 | ```yue | 29 | ```yue |
| @@ -42,6 +44,7 @@ profile = | |||
| 42 | shoe_size: 13, | 44 | shoe_size: 13, |
| 43 | favorite_foods: ["ice cream", "donuts"] | 45 | favorite_foods: ["ice cream", "donuts"] |
| 44 | ``` | 46 | ``` |
| 47 | |||
| 45 | <YueDisplay> | 48 | <YueDisplay> |
| 46 | 49 | ||
| 47 | ```yue | 50 | ```yue |
| @@ -63,6 +66,7 @@ values = { | |||
| 63 | occupation: "crime fighting" | 66 | occupation: "crime fighting" |
| 64 | } | 67 | } |
| 65 | ``` | 68 | ``` |
| 69 | |||
| 66 | <YueDisplay> | 70 | <YueDisplay> |
| 67 | 71 | ||
| 68 | ```yue | 72 | ```yue |
| @@ -83,6 +87,7 @@ my_function dance: "Tango", partner: "none" | |||
| 83 | 87 | ||
| 84 | y = type: "dog", legs: 4, tails: 1 | 88 | y = type: "dog", legs: 4, tails: 1 |
| 85 | ``` | 89 | ``` |
| 90 | |||
| 86 | <YueDisplay> | 91 | <YueDisplay> |
| 87 | 92 | ||
| 88 | ```yue | 93 | ```yue |
| @@ -101,6 +106,7 @@ tbl = { | |||
| 101 | end: "hunger" | 106 | end: "hunger" |
| 102 | } | 107 | } |
| 103 | ``` | 108 | ``` |
| 109 | |||
| 104 | <YueDisplay> | 110 | <YueDisplay> |
| 105 | 111 | ||
| 106 | ```yue | 112 | ```yue |
| @@ -121,6 +127,7 @@ person = { :hair, :height, shoe_size: 40 } | |||
| 121 | 127 | ||
| 122 | print_table :hair, :height | 128 | print_table :hair, :height |
| 123 | ``` | 129 | ``` |
| 130 | |||
| 124 | <YueDisplay> | 131 | <YueDisplay> |
| 125 | 132 | ||
| 126 | ```yue | 133 | ```yue |
| @@ -141,6 +148,7 @@ t = { | |||
| 141 | "hello world": true | 148 | "hello world": true |
| 142 | } | 149 | } |
| 143 | ``` | 150 | ``` |
| 151 | |||
| 144 | <YueDisplay> | 152 | <YueDisplay> |
| 145 | 153 | ||
| 146 | ```yue | 154 | ```yue |
| @@ -158,6 +166,7 @@ Tabel Lua memiliki bagian array dan bagian hash, tetapi terkadang Anda ingin mem | |||
| 158 | some_values = [1, 2, 3, 4] | 166 | some_values = [1, 2, 3, 4] |
| 159 | list_with_one_element = [1, ] | 167 | list_with_one_element = [1, ] |
| 160 | ``` | 168 | ``` |
| 169 | |||
| 161 | <YueDisplay> | 170 | <YueDisplay> |
| 162 | 171 | ||
| 163 | ```yue | 172 | ```yue |
diff --git a/doc/docs/id-id/doc/functions/backcalls.md b/doc/docs/id-id/doc/functions/backcalls.md index 8d542ee..9de64c3 100644 --- a/doc/docs/id-id/doc/functions/backcalls.md +++ b/doc/docs/id-id/doc/functions/backcalls.md | |||
| @@ -6,6 +6,7 @@ Backcall digunakan untuk meratakan callback yang bersarang. Backcall didefinisik | |||
| 6 | x <- f | 6 | x <- f |
| 7 | print "hello" .. x | 7 | print "hello" .. x |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -21,6 +22,7 @@ Fungsi panah tebal juga tersedia. | |||
| 21 | <= f | 22 | <= f |
| 22 | print @value | 23 | print @value |
| 23 | ``` | 24 | ``` |
| 25 | |||
| 24 | <YueDisplay> | 26 | <YueDisplay> |
| 25 | 27 | ||
| 26 | ```yue | 28 | ```yue |
| @@ -36,6 +38,7 @@ Anda dapat menentukan placeholder untuk posisi fungsi backcall sebagai parameter | |||
| 36 | (x) <- map _, [1, 2, 3] | 38 | (x) <- map _, [1, 2, 3] |
| 37 | x * 2 | 39 | x * 2 |
| 38 | ``` | 40 | ``` |
| 41 | |||
| 39 | <YueDisplay> | 42 | <YueDisplay> |
| 40 | 43 | ||
| 41 | ```yue | 44 | ```yue |
| @@ -55,6 +58,7 @@ result, msg = do | |||
| 55 | check info | 58 | check info |
| 56 | print result, msg | 59 | print result, msg |
| 57 | ``` | 60 | ``` |
| 61 | |||
| 58 | <YueDisplay> | 62 | <YueDisplay> |
| 59 | 63 | ||
| 60 | ```yue | 64 | ```yue |
diff --git a/doc/docs/id-id/doc/functions/function-literals.md b/doc/docs/id-id/doc/functions/function-literals.md index 589a26d..67ae158 100644 --- a/doc/docs/id-id/doc/functions/function-literals.md +++ b/doc/docs/id-id/doc/functions/function-literals.md | |||
| @@ -6,6 +6,7 @@ Semua fungsi dibuat menggunakan ekspresi fungsi. Fungsi sederhana ditandai denga | |||
| 6 | my_function = -> | 6 | my_function = -> |
| 7 | my_function() -- memanggil fungsi kosong | 7 | my_function() -- memanggil fungsi kosong |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -24,6 +25,7 @@ func_b = -> | |||
| 24 | value = 100 | 25 | value = 100 |
| 25 | print "The value:", value | 26 | print "The value:", value |
| 26 | ``` | 27 | ``` |
| 28 | |||
| 27 | <YueDisplay> | 29 | <YueDisplay> |
| 28 | 30 | ||
| 29 | ```yue | 31 | ```yue |
| @@ -42,6 +44,7 @@ Jika fungsi tidak memiliki argumen, ia dapat dipanggil menggunakan operator `!`, | |||
| 42 | func_a! | 44 | func_a! |
| 43 | func_b() | 45 | func_b() |
| 44 | ``` | 46 | ``` |
| 47 | |||
| 45 | <YueDisplay> | 48 | <YueDisplay> |
| 46 | 49 | ||
| 47 | ```yue | 50 | ```yue |
| @@ -56,6 +59,7 @@ Fungsi dengan argumen dapat dibuat dengan menaruh daftar nama argumen dalam tand | |||
| 56 | ```yuescript | 59 | ```yuescript |
| 57 | sum = (x, y) -> print "sum", x + y | 60 | sum = (x, y) -> print "sum", x + y |
| 58 | ``` | 61 | ``` |
| 62 | |||
| 59 | <YueDisplay> | 63 | <YueDisplay> |
| 60 | 64 | ||
| 61 | ```yue | 65 | ```yue |
| @@ -72,6 +76,7 @@ print sum 10, 20 | |||
| 72 | 76 | ||
| 73 | a b c "a", "b", "c" | 77 | a b c "a", "b", "c" |
| 74 | ``` | 78 | ``` |
| 79 | |||
| 75 | <YueDisplay> | 80 | <YueDisplay> |
| 76 | 81 | ||
| 77 | ```yue | 82 | ```yue |
| @@ -88,6 +93,7 @@ Untuk menghindari ambiguitas saat memanggil fungsi, tanda kurung juga bisa digun | |||
| 88 | ```yuescript | 93 | ```yuescript |
| 89 | print "x:", sum(10, 20), "y:", sum(30, 40) | 94 | print "x:", sum(10, 20), "y:", sum(30, 40) |
| 90 | ``` | 95 | ``` |
| 96 | |||
| 91 | <YueDisplay> | 97 | <YueDisplay> |
| 92 | 98 | ||
| 93 | ```yue | 99 | ```yue |
| @@ -104,6 +110,7 @@ Fungsi akan memaksa pernyataan terakhir di badannya menjadi pernyataan return, i | |||
| 104 | sum = (x, y) -> x + y | 110 | sum = (x, y) -> x + y |
| 105 | print "The sum is ", sum 10, 20 | 111 | print "The sum is ", sum 10, 20 |
| 106 | ``` | 112 | ``` |
| 113 | |||
| 107 | <YueDisplay> | 114 | <YueDisplay> |
| 108 | 115 | ||
| 109 | ```yue | 116 | ```yue |
| @@ -118,6 +125,7 @@ Dan jika Anda perlu return secara eksplisit, Anda bisa menggunakan kata kunci `r | |||
| 118 | ```yuescript | 125 | ```yuescript |
| 119 | sum = (x, y) -> return x + y | 126 | sum = (x, y) -> return x + y |
| 120 | ``` | 127 | ``` |
| 128 | |||
| 121 | <YueDisplay> | 129 | <YueDisplay> |
| 122 | 130 | ||
| 123 | ```yue | 131 | ```yue |
| @@ -132,6 +140,7 @@ Seperti di Lua, fungsi dapat mengembalikan beberapa nilai. Pernyataan terakhir h | |||
| 132 | mystery = (x, y) -> x + y, x - y | 140 | mystery = (x, y) -> x + y, x - y |
| 133 | a, b = mystery 10, 20 | 141 | a, b = mystery 10, 20 |
| 134 | ``` | 142 | ``` |
| 143 | |||
| 135 | <YueDisplay> | 144 | <YueDisplay> |
| 136 | 145 | ||
| 137 | ```yue | 146 | ```yue |
| @@ -148,6 +157,7 @@ Karena sudah menjadi idiom di Lua untuk mengirim objek sebagai argumen pertama s | |||
| 148 | ```yuescript | 157 | ```yuescript |
| 149 | func = (num) => @value + num | 158 | func = (num) => @value + num |
| 150 | ``` | 159 | ``` |
| 160 | |||
| 151 | <YueDisplay> | 161 | <YueDisplay> |
| 152 | 162 | ||
| 153 | ```yue | 163 | ```yue |
| @@ -165,6 +175,7 @@ my_function = (name = "something", height = 100) -> | |||
| 165 | print "Hello I am", name | 175 | print "Hello I am", name |
| 166 | print "My height is", height | 176 | print "My height is", height |
| 167 | ``` | 177 | ``` |
| 178 | |||
| 168 | <YueDisplay> | 179 | <YueDisplay> |
| 169 | 180 | ||
| 170 | ```yue | 181 | ```yue |
| @@ -181,6 +192,7 @@ Ekspresi nilai default argumen dievaluasi di dalam badan fungsi sesuai urutan de | |||
| 181 | some_args = (x = 100, y = x + 1000) -> | 192 | some_args = (x = 100, y = x + 1000) -> |
| 182 | print x + y | 193 | print x + y |
| 183 | ``` | 194 | ``` |
| 195 | |||
| 184 | <YueDisplay> | 196 | <YueDisplay> |
| 185 | 197 | ||
| 186 | ```yue | 198 | ```yue |
| @@ -202,6 +214,7 @@ b = x-10 | |||
| 202 | c = x -y | 214 | c = x -y |
| 203 | d = x- z | 215 | d = x- z |
| 204 | ``` | 216 | ``` |
| 217 | |||
| 205 | <YueDisplay> | 218 | <YueDisplay> |
| 206 | 219 | ||
| 207 | ```yue | 220 | ```yue |
| @@ -223,6 +236,7 @@ Ketika ada spasi setelah variabel dan literal string, pemanggilan fungsi bertind | |||
| 223 | x = func"hello" + 100 | 236 | x = func"hello" + 100 |
| 224 | y = func "hello" + 100 | 237 | y = func "hello" + 100 |
| 225 | ``` | 238 | ``` |
| 239 | |||
| 226 | <YueDisplay> | 240 | <YueDisplay> |
| 227 | 241 | ||
| 228 | ```yue | 242 | ```yue |
| @@ -247,6 +261,7 @@ cool_func 1, 2, | |||
| 247 | 5, 6, | 261 | 5, 6, |
| 248 | 7, 8 | 262 | 7, 8 |
| 249 | ``` | 263 | ``` |
| 264 | |||
| 250 | <YueDisplay> | 265 | <YueDisplay> |
| 251 | 266 | ||
| 252 | ```yue | 267 | ```yue |
| @@ -269,6 +284,7 @@ my_func 5, 6, 7, | |||
| 269 | 9, 1, 2, | 284 | 9, 1, 2, |
| 270 | 5, 4 | 285 | 5, 4 |
| 271 | ``` | 286 | ``` |
| 287 | |||
| 272 | <YueDisplay> | 288 | <YueDisplay> |
| 273 | 289 | ||
| 274 | ```yue | 290 | ```yue |
| @@ -289,6 +305,7 @@ x = [ | |||
| 289 | 8, 9, 10 | 305 | 8, 9, 10 |
| 290 | ] | 306 | ] |
| 291 | ``` | 307 | ``` |
| 308 | |||
| 292 | <YueDisplay> | 309 | <YueDisplay> |
| 293 | 310 | ||
| 294 | ```yue | 311 | ```yue |
| @@ -309,6 +326,7 @@ y = [ my_func 1, 2, 3, | |||
| 309 | 5, 6, 7 | 326 | 5, 6, 7 |
| 310 | ] | 327 | ] |
| 311 | ``` | 328 | ``` |
| 329 | |||
| 312 | <YueDisplay> | 330 | <YueDisplay> |
| 313 | 331 | ||
| 314 | ```yue | 332 | ```yue |
| @@ -335,6 +353,7 @@ if func 1, 2, 3, | |||
| 335 | print "hello" | 353 | print "hello" |
| 336 | print "I am inside if" | 354 | print "I am inside if" |
| 337 | ``` | 355 | ``` |
| 356 | |||
| 338 | <YueDisplay> | 357 | <YueDisplay> |
| 339 | 358 | ||
| 340 | ```yue | 359 | ```yue |
| @@ -357,9 +376,9 @@ if func 1, 2, 3, | |||
| 357 | 376 | ||
| 358 | YueScript kini mendukung destrukturisasi parameter fungsi ketika argumen berupa objek. Dua bentuk destrukturisasi literal tabel tersedia: | 377 | YueScript kini mendukung destrukturisasi parameter fungsi ketika argumen berupa objek. Dua bentuk destrukturisasi literal tabel tersedia: |
| 359 | 378 | ||
| 360 | * **Literal berkurung kurawal/parameter objek**, memungkinkan nilai default opsional ketika field hilang (misalnya, `{:a, :b}`, `{a: a1 = 123}`). | 379 | - **Literal berkurung kurawal/parameter objek**, memungkinkan nilai default opsional ketika field hilang (misalnya, `{:a, :b}`, `{a: a1 = 123}`). |
| 361 | 380 | ||
| 362 | * **Sintaks tabel sederhana tanpa pembungkus**, dimulai dengan urutan key-value atau binding singkat dan berlanjut sampai ekspresi lain menghentikannya (misalnya, `:a, b: b1, :c`). Bentuk ini mengekstrak beberapa field dari objek yang sama. | 381 | - **Sintaks tabel sederhana tanpa pembungkus**, dimulai dengan urutan key-value atau binding singkat dan berlanjut sampai ekspresi lain menghentikannya (misalnya, `:a, b: b1, :c`). Bentuk ini mengekstrak beberapa field dari objek yang sama. |
| 363 | 382 | ||
| 364 | ```yuescript | 383 | ```yuescript |
| 365 | f1 = (:a, :b, :c) -> | 384 | f1 = (:a, :b, :c) -> |
| @@ -373,6 +392,7 @@ f2 = ({a: a1 = 123, :b = 'abc'}, c = {}) -> | |||
| 373 | arg1 = {a: 0} | 392 | arg1 = {a: 0} |
| 374 | f2 arg1, arg2 | 393 | f2 arg1, arg2 |
| 375 | ``` | 394 | ``` |
| 395 | |||
| 376 | <YueDisplay> | 396 | <YueDisplay> |
| 377 | 397 | ||
| 378 | ```yue | 398 | ```yue |
| @@ -402,6 +422,7 @@ findFirstEven = (list): nil -> | |||
| 402 | if sub % 2 == 0 | 422 | if sub % 2 == 0 |
| 403 | return sub | 423 | return sub |
| 404 | ``` | 424 | ``` |
| 425 | |||
| 405 | <YueDisplay> | 426 | <YueDisplay> |
| 406 | 427 | ||
| 407 | ```yue | 428 | ```yue |
| @@ -426,6 +447,7 @@ findFirstEven = (list) -> | |||
| 426 | return sub | 447 | return sub |
| 427 | nil | 448 | nil |
| 428 | ``` | 449 | ``` |
| 450 | |||
| 429 | <YueDisplay> | 451 | <YueDisplay> |
| 430 | 452 | ||
| 431 | ```yue | 453 | ```yue |
| @@ -467,6 +489,7 @@ process = (...args) -> | |||
| 467 | 489 | ||
| 468 | process 1, nil, 3, nil, 5 | 490 | process 1, nil, 3, nil, 5 |
| 469 | ``` | 491 | ``` |
| 492 | |||
| 470 | <YueDisplay> | 493 | <YueDisplay> |
| 471 | 494 | ||
| 472 | ```yue | 495 | ```yue |
diff --git a/doc/docs/id-id/doc/functions/function-stubs.md b/doc/docs/id-id/doc/functions/function-stubs.md index 57ed5c1..87dfd73 100644 --- a/doc/docs/id-id/doc/functions/function-stubs.md +++ b/doc/docs/id-id/doc/functions/function-stubs.md | |||
| @@ -24,6 +24,7 @@ run_callback my_object.write | |||
| 24 | -- memungkinkan kita membundel objek ke fungsi baru | 24 | -- memungkinkan kita membundel objek ke fungsi baru |
| 25 | run_callback my_object\write | 25 | run_callback my_object\write |
| 26 | ``` | 26 | ``` |
| 27 | |||
| 27 | <YueDisplay> | 28 | <YueDisplay> |
| 28 | 29 | ||
| 29 | ```yue | 30 | ```yue |
diff --git a/doc/docs/id-id/doc/getting-started/usage.md b/doc/docs/id-id/doc/getting-started/usage.md index 85cad07..a9523f7 100644 --- a/doc/docs/id-id/doc/getting-started/usage.md +++ b/doc/docs/id-id/doc/getting-started/usage.md | |||
| @@ -4,49 +4,51 @@ | |||
| 4 | 4 | ||
| 5 | Gunakan modul YueScript di Lua: | 5 | Gunakan modul YueScript di Lua: |
| 6 | 6 | ||
| 7 | * **Kasus 1** | 7 | - **Kasus 1** |
| 8 | 8 | ||
| 9 | Require "your_yuescript_entry.yue" di Lua. | 9 | Require "your_yuescript_entry.yue" di Lua. |
| 10 | ```Lua | 10 | |
| 11 | require("yue")("your_yuescript_entry") | 11 | ```Lua |
| 12 | ``` | 12 | require("yue")("your_yuescript_entry") |
| 13 | Dan kode ini tetap bekerja ketika Anda mengompilasi "your_yuescript_entry.yue" menjadi "your_yuescript_entry.lua" di path yang sama. Pada file YueScript lainnya cukup gunakan **require** atau **import** biasa. Nomor baris pada pesan error juga akan ditangani dengan benar. | 13 | ``` |
| 14 | 14 | ||
| 15 | * **Kasus 2** | 15 | Dan kode ini tetap bekerja ketika Anda mengompilasi "your_yuescript_entry.yue" menjadi "your_yuescript_entry.lua" di path yang sama. Pada file YueScript lainnya cukup gunakan **require** atau **import** biasa. Nomor baris pada pesan error juga akan ditangani dengan benar. |
| 16 | 16 | ||
| 17 | Require modul YueScript dan tulis ulang pesan secara manual. | 17 | - **Kasus 2** |
| 18 | 18 | ||
| 19 | ```lua | 19 | Require modul YueScript dan tulis ulang pesan secara manual. |
| 20 | local yue = require("yue") | 20 | |
| 21 | yue.insert_loader() | 21 | ```lua |
| 22 | local success, result = xpcall(function() | 22 | local yue = require("yue") |
| 23 | return require("yuescript_module_name") | 23 | yue.insert_loader() |
| 24 | end, function(err) | 24 | local success, result = xpcall(function() |
| 25 | return yue.traceback(err) | 25 | return require("yuescript_module_name") |
| 26 | end) | 26 | end, function(err) |
| 27 | ``` | 27 | return yue.traceback(err) |
| 28 | 28 | end) | |
| 29 | * **Kasus 3** | 29 | ``` |
| 30 | 30 | ||
| 31 | Gunakan fungsi kompiler YueScript di Lua. | 31 | - **Kasus 3** |
| 32 | 32 | ||
| 33 | ```lua | 33 | Gunakan fungsi kompiler YueScript di Lua. |
| 34 | local yue = require("yue") | 34 | |
| 35 | local codes, err, globals = yue.to_lua([[ | 35 | ```lua |
| 36 | f = -> | 36 | local yue = require("yue") |
| 37 | print "hello world" | 37 | local codes, err, globals = yue.to_lua([[ |
| 38 | f! | 38 | f = -> |
| 39 | ]],{ | 39 | print "hello world" |
| 40 | implicit_return_root = true, | 40 | f! |
| 41 | reserve_line_number = true, | 41 | ]],{ |
| 42 | lint_global = true, | 42 | implicit_return_root = true, |
| 43 | space_over_tab = false, | 43 | reserve_line_number = true, |
| 44 | options = { | 44 | lint_global = true, |
| 45 | target = "5.4", | 45 | space_over_tab = false, |
| 46 | path = "/script" | 46 | options = { |
| 47 | } | 47 | target = "5.4", |
| 48 | }) | 48 | path = "/script" |
| 49 | ``` | 49 | } |
| 50 | }) | ||
| 51 | ``` | ||
| 50 | 52 | ||
| 51 | ## Tool YueScript | 53 | ## Tool YueScript |
| 52 | 54 | ||
| @@ -99,14 +101,14 @@ Opsi: | |||
| 99 | 101 | ||
| 100 | Gunakan kasus: | 102 | Gunakan kasus: |
| 101 | 103 | ||
| 102 | Kompilasi semua file YueScript dengan ekstensi **.yue** secara rekursif di bawah path saat ini: **yue .** | 104 | Kompilasi semua file YueScript dengan ekstensi **.yue** secara rekursif di bawah path saat ini: **yue .** |
| 103 | 105 | ||
| 104 | Kompilasi dan simpan hasil ke path target: **yue -t /target/path/ .** | 106 | Kompilasi dan simpan hasil ke path target: **yue -t /target/path/ .** |
| 105 | 107 | ||
| 106 | Kompilasi dan pertahankan info debug: **yue -l .** | 108 | Kompilasi dan pertahankan info debug: **yue -l .** |
| 107 | 109 | ||
| 108 | Kompilasi dan hasilkan kode yang diminisasi: **yue -m .** | 110 | Kompilasi dan hasilkan kode yang diminisasi: **yue -m .** |
| 109 | 111 | ||
| 110 | Eksekusi kode mentah: **yue -e 'print 123'** | 112 | Eksekusi kode mentah: **yue -e 'print 123'** |
| 111 | 113 | ||
| 112 | Eksekusi file YueScript: **yue -e main.yue** | 114 | Eksekusi file YueScript: **yue -e main.yue** |
diff --git a/doc/docs/id-id/doc/language-basics/attributes.md b/doc/docs/id-id/doc/language-basics/attributes.md index 5b92947..20b7c9c 100644 --- a/doc/docs/id-id/doc/language-basics/attributes.md +++ b/doc/docs/id-id/doc/language-basics/attributes.md | |||
| @@ -6,6 +6,7 @@ Dukungan sintaks untuk atribut Lua 5.4. Anda juga masih bisa menggunakan deklara | |||
| 6 | const a = 123 | 6 | const a = 123 |
| 7 | close _ = <close>: -> print "Out of scope." | 7 | close _ = <close>: -> print "Out of scope." |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -21,6 +22,7 @@ Anda dapat melakukan destrukturisasi dengan variabel yang diberi atribut sebagai | |||
| 21 | const {:a, :b, c, d} = tb | 22 | const {:a, :b, c, d} = tb |
| 22 | -- a = 1 | 23 | -- a = 1 |
| 23 | ``` | 24 | ``` |
| 25 | |||
| 24 | <YueDisplay> | 26 | <YueDisplay> |
| 25 | 27 | ||
| 26 | ```yue | 28 | ```yue |
| @@ -36,6 +38,7 @@ Anda juga bisa mendeklarasikan variabel global sebagai `const`. | |||
| 36 | global const Constant = 123 | 38 | global const Constant = 123 |
| 37 | -- Constant = 1 | 39 | -- Constant = 1 |
| 38 | ``` | 40 | ``` |
| 41 | |||
| 39 | <YueDisplay> | 42 | <YueDisplay> |
| 40 | 43 | ||
| 41 | ```yue | 44 | ```yue |
diff --git a/doc/docs/id-id/doc/language-basics/comment.md b/doc/docs/id-id/doc/language-basics/comment.md index 99f7b51..058c66b 100644 --- a/doc/docs/id-id/doc/language-basics/comment.md +++ b/doc/docs/id-id/doc/language-basics/comment.md | |||
| @@ -12,6 +12,7 @@ Tidak masalah. | |||
| 12 | 12 | ||
| 13 | func --[[port]] 3000, --[[ip]] "192.168.1.1" | 13 | func --[[port]] 3000, --[[ip]] "192.168.1.1" |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
diff --git a/doc/docs/id-id/doc/language-basics/literals.md b/doc/docs/id-id/doc/language-basics/literals.md index c17c310..93a547b 100644 --- a/doc/docs/id-id/doc/language-basics/literals.md +++ b/doc/docs/id-id/doc/language-basics/literals.md | |||
| @@ -12,6 +12,7 @@ some_string = "Here is a string | |||
| 12 | -- Interpolasi string hanya tersedia pada string dengan tanda kutip ganda. | 12 | -- Interpolasi string hanya tersedia pada string dengan tanda kutip ganda. |
| 13 | print "I am #{math.random! * 100}% sure." | 13 | print "I am #{math.random! * 100}% sure." |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -34,6 +35,7 @@ integer = 1_000_000 | |||
| 34 | hex = 0xEF_BB_BF | 35 | hex = 0xEF_BB_BF |
| 35 | binary = 0B10011 | 36 | binary = 0B10011 |
| 36 | ``` | 37 | ``` |
| 38 | |||
| 37 | <YueDisplay> | 39 | <YueDisplay> |
| 38 | 40 | ||
| 39 | ```yue | 41 | ```yue |
| @@ -55,6 +57,7 @@ str = | | |||
| 55 | - item1 | 57 | - item1 |
| 56 | - #{expr} | 58 | - #{expr} |
| 57 | ``` | 59 | ``` |
| 60 | |||
| 58 | <YueDisplay> | 61 | <YueDisplay> |
| 59 | 62 | ||
| 60 | ```yue | 63 | ```yue |
| @@ -78,6 +81,7 @@ fn = -> | |||
| 78 | bar: baz | 81 | bar: baz |
| 79 | return str | 82 | return str |
| 80 | ``` | 83 | ``` |
| 84 | |||
| 81 | <YueDisplay> | 85 | <YueDisplay> |
| 82 | 86 | ||
| 83 | ```yue | 87 | ```yue |
| @@ -99,6 +103,7 @@ str = | | |||
| 99 | path: "C:\Program Files\App" | 103 | path: "C:\Program Files\App" |
| 100 | note: 'He said: "#{Hello}!"' | 104 | note: 'He said: "#{Hello}!"' |
| 101 | ``` | 105 | ``` |
| 106 | |||
| 102 | <YueDisplay> | 107 | <YueDisplay> |
| 103 | 108 | ||
| 104 | ```yue | 109 | ```yue |
diff --git a/doc/docs/id-id/doc/language-basics/operator.md b/doc/docs/id-id/doc/language-basics/operator.md index f3fe092..6e0030a 100644 --- a/doc/docs/id-id/doc/language-basics/operator.md +++ b/doc/docs/id-id/doc/language-basics/operator.md | |||
| @@ -6,6 +6,7 @@ Semua operator biner dan unari Lua tersedia. Selain itu **!=** adalah alias untu | |||
| 6 | tb\func! if tb ~= nil | 6 | tb\func! if tb ~= nil |
| 7 | tb::func! if tb != nil | 7 | tb::func! if tb != nil |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -27,6 +28,7 @@ a = 5 | |||
| 27 | print 1 <= a <= 10 | 28 | print 1 <= a <= 10 |
| 28 | -- output: true | 29 | -- output: true |
| 29 | ``` | 30 | ``` |
| 31 | |||
| 30 | <YueDisplay> | 32 | <YueDisplay> |
| 31 | 33 | ||
| 32 | ```yue | 34 | ```yue |
| @@ -64,6 +66,7 @@ print v(1) > v(2) <= v(3) | |||
| 64 | false | 66 | false |
| 65 | ]] | 67 | ]] |
| 66 | ``` | 68 | ``` |
| 69 | |||
| 67 | <YueDisplay> | 70 | <YueDisplay> |
| 68 | 71 | ||
| 69 | ```yue | 72 | ```yue |
| @@ -101,6 +104,7 @@ Operator **[] =** digunakan untuk menambahkan nilai ke tabel. | |||
| 101 | tab = [] | 104 | tab = [] |
| 102 | tab[] = "Value" | 105 | tab[] = "Value" |
| 103 | ``` | 106 | ``` |
| 107 | |||
| 104 | <YueDisplay> | 108 | <YueDisplay> |
| 105 | 109 | ||
| 106 | ```yue | 110 | ```yue |
| @@ -118,6 +122,7 @@ tbB = [4, 5, 6] | |||
| 118 | tbA[] = ...tbB | 122 | tbA[] = ...tbB |
| 119 | -- tbA sekarang [1, 2, 3, 4, 5, 6] | 123 | -- tbA sekarang [1, 2, 3, 4, 5, 6] |
| 120 | ``` | 124 | ``` |
| 125 | |||
| 121 | <YueDisplay> | 126 | <YueDisplay> |
| 122 | 127 | ||
| 123 | ```yue | 128 | ```yue |
| @@ -149,6 +154,7 @@ a = {1, 2, 3, x: 1} | |||
| 149 | b = {4, 5, y: 1} | 154 | b = {4, 5, y: 1} |
| 150 | merge = {...a, ...b} | 155 | merge = {...a, ...b} |
| 151 | ``` | 156 | ``` |
| 157 | |||
| 152 | <YueDisplay> | 158 | <YueDisplay> |
| 153 | 159 | ||
| 154 | ```yue | 160 | ```yue |
| @@ -179,6 +185,7 @@ last = data.items[#] | |||
| 179 | second_last = data.items[#-1] | 185 | second_last = data.items[#-1] |
| 180 | data.items[#] = 1 | 186 | data.items[#] = 1 |
| 181 | ``` | 187 | ``` |
| 188 | |||
| 182 | <YueDisplay> | 189 | <YueDisplay> |
| 183 | 190 | ||
| 184 | ```yue | 191 | ```yue |
| @@ -212,6 +219,7 @@ print d.value | |||
| 212 | 219 | ||
| 213 | close _ = <close>: -> print "out of scope" | 220 | close _ = <close>: -> print "out of scope" |
| 214 | ``` | 221 | ``` |
| 222 | |||
| 215 | <YueDisplay> | 223 | <YueDisplay> |
| 216 | 224 | ||
| 217 | ```yue | 225 | ```yue |
| @@ -245,6 +253,7 @@ print tb.value | |||
| 245 | tb.<> = __index: {item: "hello"} | 253 | tb.<> = __index: {item: "hello"} |
| 246 | print tb.item | 254 | print tb.item |
| 247 | ``` | 255 | ``` |
| 256 | |||
| 248 | <YueDisplay> | 257 | <YueDisplay> |
| 249 | 258 | ||
| 250 | ```yue | 259 | ```yue |
| @@ -266,6 +275,7 @@ Destrukturisasi metatable dengan kunci metamethod yang dikelilingi **<>**. | |||
| 266 | {item, :new, :<close>, <index>: getter} = tb | 275 | {item, :new, :<close>, <index>: getter} = tb |
| 267 | print item, new, close, getter | 276 | print item, new, close, getter |
| 268 | ``` | 277 | ``` |
| 278 | |||
| 269 | <YueDisplay> | 279 | <YueDisplay> |
| 270 | 280 | ||
| 271 | ```yue | 281 | ```yue |
| @@ -293,6 +303,7 @@ with? io.open "test.txt", "w" | |||
| 293 | \write "hello" | 303 | \write "hello" |
| 294 | \close! | 304 | \close! |
| 295 | ``` | 305 | ``` |
| 306 | |||
| 296 | <YueDisplay> | 307 | <YueDisplay> |
| 297 | 308 | ||
| 298 | ```yue | 309 | ```yue |
| @@ -329,6 +340,7 @@ readFile "example.txt" | |||
| 329 | |> render | 340 | |> render |
| 330 | 341 | ||
| 331 | ``` | 342 | ``` |
| 343 | |||
| 332 | <YueDisplay> | 344 | <YueDisplay> |
| 333 | 345 | ||
| 334 | ```yue | 346 | ```yue |
| @@ -349,6 +361,7 @@ readFile "example.txt" | |||
| 349 | ## Nil Coalescing | 361 | ## Nil Coalescing |
| 350 | 362 | ||
| 351 | Operator nil-coalescing **??** mengembalikan nilai dari operan kiri jika bukan **nil**; jika tidak, operator mengevaluasi operan kanan dan mengembalikan hasilnya. Operator **??** tidak mengevaluasi operan kanan jika operan kiri bernilai non-nil. | 363 | Operator nil-coalescing **??** mengembalikan nilai dari operan kiri jika bukan **nil**; jika tidak, operator mengevaluasi operan kanan dan mengembalikan hasilnya. Operator **??** tidak mengevaluasi operan kanan jika operan kiri bernilai non-nil. |
| 364 | |||
| 352 | ```yuescript | 365 | ```yuescript |
| 353 | local a, b, c, d | 366 | local a, b, c, d |
| 354 | a = b ?? c ?? d | 367 | a = b ?? c ?? d |
| @@ -356,6 +369,7 @@ func a ?? {} | |||
| 356 | 369 | ||
| 357 | a ??= false | 370 | a ??= false |
| 358 | ``` | 371 | ``` |
| 372 | |||
| 359 | <YueDisplay> | 373 | <YueDisplay> |
| 360 | 374 | ||
| 361 | ```yue | 375 | ```yue |
| @@ -413,6 +427,7 @@ tb = | |||
| 413 | tb: { } | 427 | tb: { } |
| 414 | 428 | ||
| 415 | ``` | 429 | ``` |
| 430 | |||
| 416 | <YueDisplay> | 431 | <YueDisplay> |
| 417 | 432 | ||
| 418 | ```yue | 433 | ```yue |
diff --git a/doc/docs/id-id/doc/language-basics/whitespace.md b/doc/docs/id-id/doc/language-basics/whitespace.md index bdc124e..486bcaa 100644 --- a/doc/docs/id-id/doc/language-basics/whitespace.md +++ b/doc/docs/id-id/doc/language-basics/whitespace.md | |||
| @@ -9,6 +9,7 @@ Sebuah pernyataan biasanya berakhir pada pergantian baris. Anda juga bisa memaka | |||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | a = 1; b = 2; print a + b | 10 | a = 1; b = 2; print a + b |
| 11 | ``` | 11 | ``` |
| 12 | |||
| 12 | <YueDisplay> | 13 | <YueDisplay> |
| 13 | 14 | ||
| 14 | ```yue | 15 | ```yue |
| @@ -29,6 +30,7 @@ Rx.Observable | |||
| 29 | \map (value) -> value .. '!' | 30 | \map (value) -> value .. '!' |
| 30 | \subscribe print | 31 | \subscribe print |
| 31 | ``` | 32 | ``` |
| 33 | |||
| 32 | <YueDisplay> | 34 | <YueDisplay> |
| 33 | 35 | ||
| 34 | ```yue | 36 | ```yue |
diff --git a/doc/docs/id-id/doc/objects/object-oriented-programming.md b/doc/docs/id-id/doc/objects/object-oriented-programming.md index 96c19d7..7d5d420 100644 --- a/doc/docs/id-id/doc/objects/object-oriented-programming.md +++ b/doc/docs/id-id/doc/objects/object-oriented-programming.md | |||
| @@ -15,6 +15,7 @@ class Inventory | |||
| 15 | else | 15 | else |
| 16 | @items[name] = 1 | 16 | @items[name] = 1 |
| 17 | ``` | 17 | ``` |
| 18 | |||
| 18 | <YueDisplay> | 19 | <YueDisplay> |
| 19 | 20 | ||
| 20 | ```yue | 21 | ```yue |
| @@ -46,6 +47,7 @@ inv = Inventory! | |||
| 46 | inv\add_item "t-shirt" | 47 | inv\add_item "t-shirt" |
| 47 | inv\add_item "pants" | 48 | inv\add_item "pants" |
| 48 | ``` | 49 | ``` |
| 50 | |||
| 49 | <YueDisplay> | 51 | <YueDisplay> |
| 50 | 52 | ||
| 51 | ```yue | 53 | ```yue |
| @@ -77,6 +79,7 @@ b\give_item "shirt" | |||
| 77 | -- akan mencetak pants dan shirt | 79 | -- akan mencetak pants dan shirt |
| 78 | print item for item in *a.clothes | 80 | print item for item in *a.clothes |
| 79 | ``` | 81 | ``` |
| 82 | |||
| 80 | <YueDisplay> | 83 | <YueDisplay> |
| 81 | 84 | ||
| 82 | ```yue | 85 | ```yue |
| @@ -104,6 +107,7 @@ class Person | |||
| 104 | new: => | 107 | new: => |
| 105 | @clothes = [] | 108 | @clothes = [] |
| 106 | ``` | 109 | ``` |
| 110 | |||
| 107 | <YueDisplay> | 111 | <YueDisplay> |
| 108 | 112 | ||
| 109 | ```yue | 113 | ```yue |
| @@ -125,6 +129,7 @@ class BackPack extends Inventory | |||
| 125 | if #@items > size then error "backpack is full" | 129 | if #@items > size then error "backpack is full" |
| 126 | super name | 130 | super name |
| 127 | ``` | 131 | ``` |
| 132 | |||
| 128 | <YueDisplay> | 133 | <YueDisplay> |
| 129 | 134 | ||
| 130 | ```yue | 135 | ```yue |
| @@ -151,6 +156,7 @@ class Shelf | |||
| 151 | -- akan mencetak: Shelf was inherited by Cupboard | 156 | -- akan mencetak: Shelf was inherited by Cupboard |
| 152 | class Cupboard extends Shelf | 157 | class Cupboard extends Shelf |
| 153 | ``` | 158 | ``` |
| 159 | |||
| 154 | <YueDisplay> | 160 | <YueDisplay> |
| 155 | 161 | ||
| 156 | ```yue | 162 | ```yue |
| @@ -189,6 +195,7 @@ class MyClass extends ParentClass | |||
| 189 | -- super sebagai nilai sama dengan kelas induk: | 195 | -- super sebagai nilai sama dengan kelas induk: |
| 190 | assert super == ParentClass | 196 | assert super == ParentClass |
| 191 | ``` | 197 | ``` |
| 198 | |||
| 192 | <YueDisplay> | 199 | <YueDisplay> |
| 193 | 200 | ||
| 194 | ```yue | 201 | ```yue |
| @@ -217,6 +224,7 @@ assert b.__class == BackPack | |||
| 217 | 224 | ||
| 218 | print BackPack.size -- mencetak 10 | 225 | print BackPack.size -- mencetak 10 |
| 219 | ``` | 226 | ``` |
| 227 | |||
| 220 | <YueDisplay> | 228 | <YueDisplay> |
| 221 | 229 | ||
| 222 | ```yue | 230 | ```yue |
| @@ -247,6 +255,7 @@ Nama kelas saat dideklarasikan disimpan sebagai string di field `__name` pada ob | |||
| 247 | ```yuescript | 255 | ```yuescript |
| 248 | print BackPack.__name -- mencetak Backpack | 256 | print BackPack.__name -- mencetak Backpack |
| 249 | ``` | 257 | ``` |
| 258 | |||
| 250 | <YueDisplay> | 259 | <YueDisplay> |
| 251 | 260 | ||
| 252 | ```yue | 261 | ```yue |
| @@ -272,6 +281,7 @@ Things\some_func! | |||
| 272 | -- variabel kelas tidak terlihat pada instance | 281 | -- variabel kelas tidak terlihat pada instance |
| 273 | assert Things().some_func == nil | 282 | assert Things().some_func == nil |
| 274 | ``` | 283 | ``` |
| 284 | |||
| 275 | <YueDisplay> | 285 | <YueDisplay> |
| 276 | 286 | ||
| 277 | ```yue | 287 | ```yue |
| @@ -300,6 +310,7 @@ Counter! | |||
| 300 | 310 | ||
| 301 | print Counter.count -- mencetak 2 | 311 | print Counter.count -- mencetak 2 |
| 302 | ``` | 312 | ``` |
| 313 | |||
| 303 | <YueDisplay> | 314 | <YueDisplay> |
| 304 | 315 | ||
| 305 | ```yue | 316 | ```yue |
| @@ -322,6 +333,7 @@ Semantik pemanggilan `@@` mirip dengan `@`. Memanggil nama `@@` akan meneruskan | |||
| 322 | ```yuescript | 333 | ```yuescript |
| 323 | @@hello 1,2,3,4 | 334 | @@hello 1,2,3,4 |
| 324 | ``` | 335 | ``` |
| 336 | |||
| 325 | <YueDisplay> | 337 | <YueDisplay> |
| 326 | 338 | ||
| 327 | ```yue | 339 | ```yue |
| @@ -340,6 +352,7 @@ Berikut cara alternatif untuk membuat variabel kelas dibandingkan yang dijelaska | |||
| 340 | class Things | 352 | class Things |
| 341 | @class_var = "hello world" | 353 | @class_var = "hello world" |
| 342 | ``` | 354 | ``` |
| 355 | |||
| 343 | <YueDisplay> | 356 | <YueDisplay> |
| 344 | 357 | ||
| 345 | ```yue | 358 | ```yue |
| @@ -361,6 +374,7 @@ class MoreThings | |||
| 361 | some_method: => | 374 | some_method: => |
| 362 | log "hello world: " .. secret | 375 | log "hello world: " .. secret |
| 363 | ``` | 376 | ``` |
| 377 | |||
| 364 | <YueDisplay> | 378 | <YueDisplay> |
| 365 | 379 | ||
| 366 | ```yue | 380 | ```yue |
| @@ -384,6 +398,7 @@ Jika digunakan sendirian, keduanya adalah alias untuk `self` dan `self.__class`. | |||
| 384 | assert @ == self | 398 | assert @ == self |
| 385 | assert @@ == self.__class | 399 | assert @@ == self.__class |
| 386 | ``` | 400 | ``` |
| 401 | |||
| 387 | <YueDisplay> | 402 | <YueDisplay> |
| 388 | 403 | ||
| 389 | ```yue | 404 | ```yue |
| @@ -398,6 +413,7 @@ Contohnya, cara cepat untuk membuat instance baru dari kelas yang sama dari meth | |||
| 398 | ```yuescript | 413 | ```yuescript |
| 399 | some_instance_method = (...) => @@ ... | 414 | some_instance_method = (...) => @@ ... |
| 400 | ``` | 415 | ``` |
| 416 | |||
| 401 | <YueDisplay> | 417 | <YueDisplay> |
| 402 | 418 | ||
| 403 | ```yue | 419 | ```yue |
| @@ -423,6 +439,7 @@ class Something | |||
| 423 | @@biz = biz | 439 | @@biz = biz |
| 424 | @@baz = baz | 440 | @@baz = baz |
| 425 | ``` | 441 | ``` |
| 442 | |||
| 426 | <YueDisplay> | 443 | <YueDisplay> |
| 427 | 444 | ||
| 428 | ```yue | 445 | ```yue |
| @@ -448,6 +465,7 @@ new = (@fieldA, @fieldB) => @ | |||
| 448 | obj = new {}, 123, "abc" | 465 | obj = new {}, 123, "abc" |
| 449 | print obj | 466 | print obj |
| 450 | ``` | 467 | ``` |
| 468 | |||
| 451 | <YueDisplay> | 469 | <YueDisplay> |
| 452 | 470 | ||
| 453 | ```yue | 471 | ```yue |
| @@ -467,6 +485,7 @@ x = class Bucket | |||
| 467 | drops: 0 | 485 | drops: 0 |
| 468 | add_drop: => @drops += 1 | 486 | add_drop: => @drops += 1 |
| 469 | ``` | 487 | ``` |
| 488 | |||
| 470 | <YueDisplay> | 489 | <YueDisplay> |
| 471 | 490 | ||
| 472 | ```yue | 491 | ```yue |
| @@ -487,6 +506,7 @@ BigBucket = class extends Bucket | |||
| 487 | 506 | ||
| 488 | assert Bucket.__name == "BigBucket" | 507 | assert Bucket.__name == "BigBucket" |
| 489 | ``` | 508 | ``` |
| 509 | |||
| 490 | <YueDisplay> | 510 | <YueDisplay> |
| 491 | 511 | ||
| 492 | ```yue | 512 | ```yue |
| @@ -503,6 +523,7 @@ Anda bahkan bisa menghilangkan badan kelas, artinya Anda bisa menulis kelas anon | |||
| 503 | ```yuescript | 523 | ```yuescript |
| 504 | x = class | 524 | x = class |
| 505 | ``` | 525 | ``` |
| 526 | |||
| 506 | <YueDisplay> | 527 | <YueDisplay> |
| 507 | 528 | ||
| 508 | ```yue | 529 | ```yue |
| @@ -532,6 +553,7 @@ y\func! | |||
| 532 | 553 | ||
| 533 | assert y.__class.__parent ~= X -- X bukan parent dari Y | 554 | assert y.__class.__parent ~= X -- X bukan parent dari Y |
| 534 | ``` | 555 | ``` |
| 556 | |||
| 535 | <YueDisplay> | 557 | <YueDisplay> |
| 536 | 558 | ||
| 537 | ```yue | 559 | ```yue |
diff --git a/doc/docs/id-id/doc/objects/with-statement.md b/doc/docs/id-id/doc/objects/with-statement.md index 3c0a8a5..96a3efd 100644 --- a/doc/docs/id-id/doc/objects/with-statement.md +++ b/doc/docs/id-id/doc/objects/with-statement.md | |||
| @@ -15,6 +15,7 @@ with Person! | |||
| 15 | \save! | 15 | \save! |
| 16 | print .name | 16 | print .name |
| 17 | ``` | 17 | ``` |
| 18 | |||
| 18 | <YueDisplay> | 19 | <YueDisplay> |
| 19 | 20 | ||
| 20 | ```yue | 21 | ```yue |
| @@ -33,6 +34,7 @@ Pernyataan `with` juga bisa digunakan sebagai ekspresi yang mengembalikan nilai | |||
| 33 | file = with File "favorite_foods.txt" | 34 | file = with File "favorite_foods.txt" |
| 34 | \set_encoding "utf8" | 35 | \set_encoding "utf8" |
| 35 | ``` | 36 | ``` |
| 37 | |||
| 36 | <YueDisplay> | 38 | <YueDisplay> |
| 37 | 39 | ||
| 38 | ```yue | 40 | ```yue |
| @@ -52,6 +54,7 @@ create_person = (name, relatives) -> | |||
| 52 | 54 | ||
| 53 | me = create_person "Leaf", [dad, mother, sister] | 55 | me = create_person "Leaf", [dad, mother, sister] |
| 54 | ``` | 56 | ``` |
| 57 | |||
| 55 | <YueDisplay> | 58 | <YueDisplay> |
| 56 | 59 | ||
| 57 | ```yue | 60 | ```yue |
| @@ -74,6 +77,7 @@ with str := "Hello" | |||
| 74 | print "original:", str | 77 | print "original:", str |
| 75 | print "upper:", \upper! | 78 | print "upper:", \upper! |
| 76 | ``` | 79 | ``` |
| 80 | |||
| 77 | <YueDisplay> | 81 | <YueDisplay> |
| 78 | 82 | ||
| 79 | ```yue | 83 | ```yue |
| @@ -95,6 +99,7 @@ with tb | |||
| 95 | ["key-name"] = value | 99 | ["key-name"] = value |
| 96 | [] = "abc" -- menambahkan ke "tb" | 100 | [] = "abc" -- menambahkan ke "tb" |
| 97 | ``` | 101 | ``` |
| 102 | |||
| 98 | <YueDisplay> | 103 | <YueDisplay> |
| 99 | 104 | ||
| 100 | ```yue | 105 | ```yue |
| @@ -115,6 +120,7 @@ with tb | |||
| 115 | with? obj | 120 | with? obj |
| 116 | print obj.name | 121 | print obj.name |
| 117 | ``` | 122 | ``` |
| 123 | |||
| 118 | <YueDisplay> | 124 | <YueDisplay> |
| 119 | 125 | ||
| 120 | ```yue | 126 | ```yue |
diff --git a/doc/docs/id-id/doc/reference/the-yuescript-library.md b/doc/docs/id-id/doc/reference/the-yuescript-library.md index 0a398a5..3adfe63 100644 --- a/doc/docs/id-id/doc/reference/the-yuescript-library.md +++ b/doc/docs/id-id/doc/reference/the-yuescript-library.md | |||
| @@ -17,6 +17,7 @@ Pustaka bahasa YueScript. | |||
| 17 | Versi YueScript. | 17 | Versi YueScript. |
| 18 | 18 | ||
| 19 | **Signature:** | 19 | **Signature:** |
| 20 | |||
| 20 | ```lua | 21 | ```lua |
| 21 | version: string | 22 | version: string |
| 22 | ``` | 23 | ``` |
| @@ -30,6 +31,7 @@ version: string | |||
| 30 | Pemisah file untuk platform saat ini. | 31 | Pemisah file untuk platform saat ini. |
| 31 | 32 | ||
| 32 | **Signature:** | 33 | **Signature:** |
| 34 | |||
| 33 | ```lua | 35 | ```lua |
| 34 | dirsep: string | 36 | dirsep: string |
| 35 | ``` | 37 | ``` |
| @@ -43,6 +45,7 @@ dirsep: string | |||
| 43 | Cache kode modul yang telah dikompilasi. | 45 | Cache kode modul yang telah dikompilasi. |
| 44 | 46 | ||
| 45 | **Signature:** | 47 | **Signature:** |
| 48 | |||
| 46 | ```lua | 49 | ```lua |
| 47 | yue_compiled: {string: string} | 50 | yue_compiled: {string: string} |
| 48 | ``` | 51 | ``` |
| @@ -56,6 +59,7 @@ yue_compiled: {string: string} | |||
| 56 | Fungsi kompilasi YueScript. Mengompilasi kode YueScript menjadi kode Lua. | 59 | Fungsi kompilasi YueScript. Mengompilasi kode YueScript menjadi kode Lua. |
| 57 | 60 | ||
| 58 | **Signature:** | 61 | **Signature:** |
| 62 | |||
| 59 | ```lua | 63 | ```lua |
| 60 | to_lua: function(code: string, config?: Config): | 64 | to_lua: function(code: string, config?: Config): |
| 61 | --[[codes]] string | nil, | 65 | --[[codes]] string | nil, |
| @@ -65,17 +69,17 @@ to_lua: function(code: string, config?: Config): | |||
| 65 | 69 | ||
| 66 | **Parameter:** | 70 | **Parameter:** |
| 67 | 71 | ||
| 68 | | Parameter | Tipe | Deskripsi | | 72 | | Parameter | Tipe | Deskripsi | |
| 69 | | --- | --- | --- | | 73 | | --------- | ------ | ------------------------- | |
| 70 | | code | string | Kode YueScript. | | 74 | | code | string | Kode YueScript. | |
| 71 | | config | Config | [Opsional] Opsi kompiler. | | 75 | | config | Config | [Opsional] Opsi kompiler. | |
| 72 | 76 | ||
| 73 | **Return:** | 77 | **Return:** |
| 74 | 78 | ||
| 75 | | Tipe Return | Deskripsi | | 79 | | Tipe Return | Deskripsi | |
| 76 | | --- | --- | | 80 | | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | |
| 77 | | string \| nil | Kode Lua hasil kompilasi, atau nil jika kompilasi gagal. | | 81 | | string \| nil | Kode Lua hasil kompilasi, atau nil jika kompilasi gagal. | |
| 78 | | string \| nil | Pesan error, atau nil jika kompilasi berhasil. | | 82 | | string \| nil | Pesan error, atau nil jika kompilasi berhasil. | |
| 79 | | {{string, integer, integer}} \| nil | Variabel global yang muncul dalam kode (dengan nama, baris, dan kolom), atau nil jika opsi kompiler `lint_global` bernilai false. | | 83 | | {{string, integer, integer}} \| nil | Variabel global yang muncul dalam kode (dengan nama, baris, dan kolom), atau nil jika opsi kompiler `lint_global` bernilai false. | |
| 80 | 84 | ||
| 81 | ### file_exist | 85 | ### file_exist |
| @@ -87,21 +91,22 @@ to_lua: function(code: string, config?: Config): | |||
| 87 | Fungsi untuk memeriksa keberadaan file sumber. Dapat ditimpa untuk menyesuaikan perilaku. | 91 | Fungsi untuk memeriksa keberadaan file sumber. Dapat ditimpa untuk menyesuaikan perilaku. |
| 88 | 92 | ||
| 89 | **Signature:** | 93 | **Signature:** |
| 94 | |||
| 90 | ```lua | 95 | ```lua |
| 91 | file_exist: function(filename: string): boolean | 96 | file_exist: function(filename: string): boolean |
| 92 | ``` | 97 | ``` |
| 93 | 98 | ||
| 94 | **Parameter:** | 99 | **Parameter:** |
| 95 | 100 | ||
| 96 | | Parameter | Tipe | Deskripsi | | 101 | | Parameter | Tipe | Deskripsi | |
| 97 | | --- | --- | --- | | 102 | | --------- | ------ | ---------- | |
| 98 | | filename | string | Nama file. | | 103 | | filename | string | Nama file. | |
| 99 | 104 | ||
| 100 | **Return:** | 105 | **Return:** |
| 101 | 106 | ||
| 102 | | Tipe Return | Deskripsi | | 107 | | Tipe Return | Deskripsi | |
| 103 | | --- | --- | | 108 | | ----------- | ---------------- | |
| 104 | | boolean | Apakah file ada. | | 109 | | boolean | Apakah file ada. | |
| 105 | 110 | ||
| 106 | ### read_file | 111 | ### read_file |
| 107 | 112 | ||
| @@ -112,21 +117,22 @@ file_exist: function(filename: string): boolean | |||
| 112 | Fungsi untuk membaca file sumber. Dapat ditimpa untuk menyesuaikan perilaku. | 117 | Fungsi untuk membaca file sumber. Dapat ditimpa untuk menyesuaikan perilaku. |
| 113 | 118 | ||
| 114 | **Signature:** | 119 | **Signature:** |
| 120 | |||
| 115 | ```lua | 121 | ```lua |
| 116 | read_file: function(filename: string): string | 122 | read_file: function(filename: string): string |
| 117 | ``` | 123 | ``` |
| 118 | 124 | ||
| 119 | **Parameter:** | 125 | **Parameter:** |
| 120 | 126 | ||
| 121 | | Parameter | Tipe | Deskripsi | | 127 | | Parameter | Tipe | Deskripsi | |
| 122 | | --- | --- | --- | | 128 | | --------- | ------ | ---------- | |
| 123 | | filename | string | Nama file. | | 129 | | filename | string | Nama file. | |
| 124 | 130 | ||
| 125 | **Return:** | 131 | **Return:** |
| 126 | 132 | ||
| 127 | | Tipe Return | Deskripsi | | 133 | | Tipe Return | Deskripsi | |
| 128 | | --- | --- | | 134 | | ----------- | --------- | |
| 129 | | string | Isi file. | | 135 | | string | Isi file. | |
| 130 | 136 | ||
| 131 | ### insert_loader | 137 | ### insert_loader |
| 132 | 138 | ||
| @@ -137,21 +143,22 @@ read_file: function(filename: string): string | |||
| 137 | Menyisipkan loader YueScript ke package loaders (searchers). | 143 | Menyisipkan loader YueScript ke package loaders (searchers). |
| 138 | 144 | ||
| 139 | **Signature:** | 145 | **Signature:** |
| 146 | |||
| 140 | ```lua | 147 | ```lua |
| 141 | insert_loader: function(pos?: integer): boolean | 148 | insert_loader: function(pos?: integer): boolean |
| 142 | ``` | 149 | ``` |
| 143 | 150 | ||
| 144 | **Parameter:** | 151 | **Parameter:** |
| 145 | 152 | ||
| 146 | | Parameter | Tipe | Deskripsi | | 153 | | Parameter | Tipe | Deskripsi | |
| 147 | | --- | --- | --- | | 154 | | --------- | ------- | ------------------------------------------------------------- | |
| 148 | | pos | integer | [Opsional] Posisi untuk menyisipkan loader. Default adalah 3. | | 155 | | pos | integer | [Opsional] Posisi untuk menyisipkan loader. Default adalah 3. | |
| 149 | 156 | ||
| 150 | **Return:** | 157 | **Return:** |
| 151 | 158 | ||
| 152 | | Tipe Return | Deskripsi | | 159 | | Tipe Return | Deskripsi | |
| 153 | | --- | --- | | 160 | | ----------- | --------------------------------------------------------------------------- | |
| 154 | | boolean | Apakah loader berhasil disisipkan. Akan gagal jika loader sudah disisipkan. | | 161 | | boolean | Apakah loader berhasil disisipkan. Akan gagal jika loader sudah disisipkan. | |
| 155 | 162 | ||
| 156 | ### remove_loader | 163 | ### remove_loader |
| 157 | 164 | ||
| @@ -162,15 +169,16 @@ insert_loader: function(pos?: integer): boolean | |||
| 162 | Menghapus loader YueScript dari package loaders (searchers). | 169 | Menghapus loader YueScript dari package loaders (searchers). |
| 163 | 170 | ||
| 164 | **Signature:** | 171 | **Signature:** |
| 172 | |||
| 165 | ```lua | 173 | ```lua |
| 166 | remove_loader: function(): boolean | 174 | remove_loader: function(): boolean |
| 167 | ``` | 175 | ``` |
| 168 | 176 | ||
| 169 | **Return:** | 177 | **Return:** |
| 170 | 178 | ||
| 171 | | Tipe Return | Deskripsi | | 179 | | Tipe Return | Deskripsi | |
| 172 | | --- | --- | | 180 | | ----------- | ------------------------------------------------------------------------ | |
| 173 | | boolean | Apakah loader berhasil dihapus. Akan gagal jika loader belum disisipkan. | | 181 | | boolean | Apakah loader berhasil dihapus. Akan gagal jika loader belum disisipkan. | |
| 174 | 182 | ||
| 175 | ### loadstring | 183 | ### loadstring |
| 176 | 184 | ||
| @@ -181,6 +189,7 @@ remove_loader: function(): boolean | |||
| 181 | Memuat kode YueScript dari string menjadi fungsi. | 189 | Memuat kode YueScript dari string menjadi fungsi. |
| 182 | 190 | ||
| 183 | **Signature:** | 191 | **Signature:** |
| 192 | |||
| 184 | ```lua | 193 | ```lua |
| 185 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): | 194 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): |
| 186 | --[[loaded function]] nil | function(...: any): (any...), | 195 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -189,19 +198,19 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 189 | 198 | ||
| 190 | **Parameter:** | 199 | **Parameter:** |
| 191 | 200 | ||
| 192 | | Parameter | Tipe | Deskripsi | | 201 | | Parameter | Tipe | Deskripsi | |
| 193 | | --- | --- | --- | | 202 | | --------- | ------ | ------------------------- | |
| 194 | | input | string | Kode YueScript. | | 203 | | input | string | Kode YueScript. | |
| 195 | | chunkname | string | Nama chunk kode. | | 204 | | chunkname | string | Nama chunk kode. | |
| 196 | | env | table | Tabel environment. | | 205 | | env | table | Tabel environment. | |
| 197 | | config | Config | [Opsional] Opsi kompiler. | | 206 | | config | Config | [Opsional] Opsi kompiler. | |
| 198 | 207 | ||
| 199 | **Return:** | 208 | **Return:** |
| 200 | 209 | ||
| 201 | | Tipe Return | Deskripsi | | 210 | | Tipe Return | Deskripsi | |
| 202 | | --- | --- | | 211 | | --------------- | ------------------------------------------------- | |
| 203 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | | 212 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | |
| 204 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | | 213 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | |
| 205 | 214 | ||
| 206 | ### loadstring | 215 | ### loadstring |
| 207 | 216 | ||
| @@ -212,6 +221,7 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 212 | Memuat kode YueScript dari string menjadi fungsi. | 221 | Memuat kode YueScript dari string menjadi fungsi. |
| 213 | 222 | ||
| 214 | **Signature:** | 223 | **Signature:** |
| 224 | |||
| 215 | ```lua | 225 | ```lua |
| 216 | loadstring: function(input: string, chunkname: string, config?: Config): | 226 | loadstring: function(input: string, chunkname: string, config?: Config): |
| 217 | --[[loaded function]] nil | function(...: any): (any...), | 227 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -220,18 +230,18 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 220 | 230 | ||
| 221 | **Parameter:** | 231 | **Parameter:** |
| 222 | 232 | ||
| 223 | | Parameter | Tipe | Deskripsi | | 233 | | Parameter | Tipe | Deskripsi | |
| 224 | | --- | --- | --- | | 234 | | --------- | ------ | ------------------------- | |
| 225 | | input | string | Kode YueScript. | | 235 | | input | string | Kode YueScript. | |
| 226 | | chunkname | string | Nama chunk kode. | | 236 | | chunkname | string | Nama chunk kode. | |
| 227 | | config | Config | [Opsional] Opsi kompiler. | | 237 | | config | Config | [Opsional] Opsi kompiler. | |
| 228 | 238 | ||
| 229 | **Return:** | 239 | **Return:** |
| 230 | 240 | ||
| 231 | | Tipe Return | Deskripsi | | 241 | | Tipe Return | Deskripsi | |
| 232 | | --- | --- | | 242 | | --------------- | ------------------------------------------------- | |
| 233 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | | 243 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | |
| 234 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | | 244 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | |
| 235 | 245 | ||
| 236 | ### loadstring | 246 | ### loadstring |
| 237 | 247 | ||
| @@ -242,6 +252,7 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 242 | Memuat kode YueScript dari string menjadi fungsi. | 252 | Memuat kode YueScript dari string menjadi fungsi. |
| 243 | 253 | ||
| 244 | **Signature:** | 254 | **Signature:** |
| 255 | |||
| 245 | ```lua | 256 | ```lua |
| 246 | loadstring: function(input: string, config?: Config): | 257 | loadstring: function(input: string, config?: Config): |
| 247 | --[[loaded function]] nil | function(...: any): (any...), | 258 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -250,17 +261,17 @@ loadstring: function(input: string, config?: Config): | |||
| 250 | 261 | ||
| 251 | **Parameter:** | 262 | **Parameter:** |
| 252 | 263 | ||
| 253 | | Parameter | Tipe | Deskripsi | | 264 | | Parameter | Tipe | Deskripsi | |
| 254 | | --- | --- | --- | | 265 | | --------- | ------ | ------------------------- | |
| 255 | | input | string | Kode YueScript. | | 266 | | input | string | Kode YueScript. | |
| 256 | | config | Config | [Opsional] Opsi kompiler. | | 267 | | config | Config | [Opsional] Opsi kompiler. | |
| 257 | 268 | ||
| 258 | **Return:** | 269 | **Return:** |
| 259 | 270 | ||
| 260 | | Tipe Return | Deskripsi | | 271 | | Tipe Return | Deskripsi | |
| 261 | | --- | --- | | 272 | | --------------- | ------------------------------------------------- | |
| 262 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | | 273 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | |
| 263 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | | 274 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | |
| 264 | 275 | ||
| 265 | ### loadfile | 276 | ### loadfile |
| 266 | 277 | ||
| @@ -271,6 +282,7 @@ loadstring: function(input: string, config?: Config): | |||
| 271 | Memuat kode YueScript dari file menjadi fungsi. | 282 | Memuat kode YueScript dari file menjadi fungsi. |
| 272 | 283 | ||
| 273 | **Signature:** | 284 | **Signature:** |
| 285 | |||
| 274 | ```lua | 286 | ```lua |
| 275 | loadfile: function(filename: string, env: table, config?: Config): | 287 | loadfile: function(filename: string, env: table, config?: Config): |
| 276 | nil | function(...: any): (any...), | 288 | nil | function(...: any): (any...), |
| @@ -279,18 +291,18 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 279 | 291 | ||
| 280 | **Parameter:** | 292 | **Parameter:** |
| 281 | 293 | ||
| 282 | | Parameter | Tipe | Deskripsi | | 294 | | Parameter | Tipe | Deskripsi | |
| 283 | | --- | --- | --- | | 295 | | --------- | ------ | ------------------------- | |
| 284 | | filename | string | Nama file. | | 296 | | filename | string | Nama file. | |
| 285 | | env | table | Tabel environment. | | 297 | | env | table | Tabel environment. | |
| 286 | | config | Config | [Opsional] Opsi kompiler. | | 298 | | config | Config | [Opsional] Opsi kompiler. | |
| 287 | 299 | ||
| 288 | **Return:** | 300 | **Return:** |
| 289 | 301 | ||
| 290 | | Tipe Return | Deskripsi | | 302 | | Tipe Return | Deskripsi | |
| 291 | | --- | --- | | 303 | | --------------- | ------------------------------------------------- | |
| 292 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | | 304 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | |
| 293 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | | 305 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | |
| 294 | 306 | ||
| 295 | ### loadfile | 307 | ### loadfile |
| 296 | 308 | ||
| @@ -301,6 +313,7 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 301 | Memuat kode YueScript dari file menjadi fungsi. | 313 | Memuat kode YueScript dari file menjadi fungsi. |
| 302 | 314 | ||
| 303 | **Signature:** | 315 | **Signature:** |
| 316 | |||
| 304 | ```lua | 317 | ```lua |
| 305 | loadfile: function(filename: string, config?: Config): | 318 | loadfile: function(filename: string, config?: Config): |
| 306 | nil | function(...: any): (any...), | 319 | nil | function(...: any): (any...), |
| @@ -309,17 +322,17 @@ loadfile: function(filename: string, config?: Config): | |||
| 309 | 322 | ||
| 310 | **Parameter:** | 323 | **Parameter:** |
| 311 | 324 | ||
| 312 | | Parameter | Tipe | Deskripsi | | 325 | | Parameter | Tipe | Deskripsi | |
| 313 | | --- | --- | --- | | 326 | | --------- | ------ | ------------------------- | |
| 314 | | filename | string | Nama file. | | 327 | | filename | string | Nama file. | |
| 315 | | config | Config | [Opsional] Opsi kompiler. | | 328 | | config | Config | [Opsional] Opsi kompiler. | |
| 316 | 329 | ||
| 317 | **Return:** | 330 | **Return:** |
| 318 | 331 | ||
| 319 | | Tipe Return | Deskripsi | | 332 | | Tipe Return | Deskripsi | |
| 320 | | --- | --- | | 333 | | --------------- | ------------------------------------------------- | |
| 321 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | | 334 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | |
| 322 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | | 335 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | |
| 323 | 336 | ||
| 324 | ### dofile | 337 | ### dofile |
| 325 | 338 | ||
| @@ -330,23 +343,24 @@ loadfile: function(filename: string, config?: Config): | |||
| 330 | Memuat kode YueScript dari file menjadi fungsi dan mengeksekusinya. | 343 | Memuat kode YueScript dari file menjadi fungsi dan mengeksekusinya. |
| 331 | 344 | ||
| 332 | **Signature:** | 345 | **Signature:** |
| 346 | |||
| 333 | ```lua | 347 | ```lua |
| 334 | dofile: function(filename: string, env: table, config?: Config): any... | 348 | dofile: function(filename: string, env: table, config?: Config): any... |
| 335 | ``` | 349 | ``` |
| 336 | 350 | ||
| 337 | **Parameter:** | 351 | **Parameter:** |
| 338 | 352 | ||
| 339 | | Parameter | Tipe | Deskripsi | | 353 | | Parameter | Tipe | Deskripsi | |
| 340 | | --- | --- | --- | | 354 | | --------- | ------ | ------------------------- | |
| 341 | | filename | string | Nama file. | | 355 | | filename | string | Nama file. | |
| 342 | | env | table | Tabel environment. | | 356 | | env | table | Tabel environment. | |
| 343 | | config | Config | [Opsional] Opsi kompiler. | | 357 | | config | Config | [Opsional] Opsi kompiler. | |
| 344 | 358 | ||
| 345 | **Return:** | 359 | **Return:** |
| 346 | 360 | ||
| 347 | | Tipe Return | Deskripsi | | 361 | | Tipe Return | Deskripsi | |
| 348 | | --- | --- | | 362 | | ----------- | ------------------------------------- | |
| 349 | | any... | Nilai return dari fungsi yang dimuat. | | 363 | | any... | Nilai return dari fungsi yang dimuat. | |
| 350 | 364 | ||
| 351 | ### dofile | 365 | ### dofile |
| 352 | 366 | ||
| @@ -357,22 +371,23 @@ dofile: function(filename: string, env: table, config?: Config): any... | |||
| 357 | Memuat kode YueScript dari file menjadi fungsi dan mengeksekusinya. | 371 | Memuat kode YueScript dari file menjadi fungsi dan mengeksekusinya. |
| 358 | 372 | ||
| 359 | **Signature:** | 373 | **Signature:** |
| 374 | |||
| 360 | ```lua | 375 | ```lua |
| 361 | dofile: function(filename: string, config?: Config): any... | 376 | dofile: function(filename: string, config?: Config): any... |
| 362 | ``` | 377 | ``` |
| 363 | 378 | ||
| 364 | **Parameter:** | 379 | **Parameter:** |
| 365 | 380 | ||
| 366 | | Parameter | Tipe | Deskripsi | | 381 | | Parameter | Tipe | Deskripsi | |
| 367 | | --- | --- | --- | | 382 | | --------- | ------ | ------------------------- | |
| 368 | | filename | string | Nama file. | | 383 | | filename | string | Nama file. | |
| 369 | | config | Config | [Opsional] Opsi kompiler. | | 384 | | config | Config | [Opsional] Opsi kompiler. | |
| 370 | 385 | ||
| 371 | **Return:** | 386 | **Return:** |
| 372 | 387 | ||
| 373 | | Tipe Return | Deskripsi | | 388 | | Tipe Return | Deskripsi | |
| 374 | | --- | --- | | 389 | | ----------- | ------------------------------------- | |
| 375 | | any... | Nilai return dari fungsi yang dimuat. | | 390 | | any... | Nilai return dari fungsi yang dimuat. | |
| 376 | 391 | ||
| 377 | ### find_modulepath | 392 | ### find_modulepath |
| 378 | 393 | ||
| @@ -383,21 +398,22 @@ dofile: function(filename: string, config?: Config): any... | |||
| 383 | Menguraikan nama modul YueScript menjadi path file. | 398 | Menguraikan nama modul YueScript menjadi path file. |
| 384 | 399 | ||
| 385 | **Signature:** | 400 | **Signature:** |
| 401 | |||
| 386 | ```lua | 402 | ```lua |
| 387 | find_modulepath: function(name: string): string | 403 | find_modulepath: function(name: string): string |
| 388 | ``` | 404 | ``` |
| 389 | 405 | ||
| 390 | **Parameter:** | 406 | **Parameter:** |
| 391 | 407 | ||
| 392 | | Parameter | Tipe | Deskripsi | | 408 | | Parameter | Tipe | Deskripsi | |
| 393 | | --- | --- | --- | | 409 | | --------- | ------ | ----------- | |
| 394 | | name | string | Nama modul. | | 410 | | name | string | Nama modul. | |
| 395 | 411 | ||
| 396 | **Return:** | 412 | **Return:** |
| 397 | 413 | ||
| 398 | | Tipe Return | Deskripsi | | 414 | | Tipe Return | Deskripsi | |
| 399 | | --- | --- | | 415 | | ----------- | ---------- | |
| 400 | | string | Path file. | | 416 | | string | Path file. | |
| 401 | 417 | ||
| 402 | ### pcall | 418 | ### pcall |
| 403 | 419 | ||
| @@ -410,21 +426,22 @@ Menangkap error apa pun dan mengembalikan kode status beserta hasil atau objek e | |||
| 410 | Menulis ulang nomor baris error ke nomor baris asli di kode YueScript saat error terjadi. | 426 | Menulis ulang nomor baris error ke nomor baris asli di kode YueScript saat error terjadi. |
| 411 | 427 | ||
| 412 | **Signature:** | 428 | **Signature:** |
| 429 | |||
| 413 | ```lua | 430 | ```lua |
| 414 | pcall: function(f: function, ...: any): boolean, any... | 431 | pcall: function(f: function, ...: any): boolean, any... |
| 415 | ``` | 432 | ``` |
| 416 | 433 | ||
| 417 | **Parameter:** | 434 | **Parameter:** |
| 418 | 435 | ||
| 419 | | Parameter | Tipe | Deskripsi | | 436 | | Parameter | Tipe | Deskripsi | |
| 420 | | --- | --- | --- | | 437 | | --------- | -------- | ---------------------------------- | |
| 421 | | f | function | Fungsi yang akan dipanggil. | | 438 | | f | function | Fungsi yang akan dipanggil. | |
| 422 | | ... | any | Argumen yang diteruskan ke fungsi. | | 439 | | ... | any | Argumen yang diteruskan ke fungsi. | |
| 423 | 440 | ||
| 424 | **Return:** | 441 | **Return:** |
| 425 | 442 | ||
| 426 | | Tipe Return | Deskripsi | | 443 | | Tipe Return | Deskripsi | |
| 427 | | --- | --- | | 444 | | ------------ | ---------------------------------------------- | |
| 428 | | boolean, ... | Kode status dan hasil fungsi atau objek error. | | 445 | | boolean, ... | Kode status dan hasil fungsi atau objek error. | |
| 429 | 446 | ||
| 430 | ### require | 447 | ### require |
| @@ -437,21 +454,22 @@ Memuat modul tertentu. Bisa berupa modul Lua atau modul YueScript. | |||
| 437 | Menulis ulang nomor baris error ke nomor baris asli di kode YueScript jika modul adalah modul YueScript dan pemuatan gagal. | 454 | Menulis ulang nomor baris error ke nomor baris asli di kode YueScript jika modul adalah modul YueScript dan pemuatan gagal. |
| 438 | 455 | ||
| 439 | **Signature:** | 456 | **Signature:** |
| 457 | |||
| 440 | ```lua | 458 | ```lua |
| 441 | require: function(name: string): any... | 459 | require: function(name: string): any... |
| 442 | ``` | 460 | ``` |
| 443 | 461 | ||
| 444 | **Parameter:** | 462 | **Parameter:** |
| 445 | 463 | ||
| 446 | | Parameter | Tipe | Deskripsi | | 464 | | Parameter | Tipe | Deskripsi | |
| 447 | | --- | --- | --- | | 465 | | --------- | ------ | ---------------------------- | |
| 448 | | modname | string | Nama modul yang akan dimuat. | | 466 | | modname | string | Nama modul yang akan dimuat. | |
| 449 | 467 | ||
| 450 | **Return:** | 468 | **Return:** |
| 451 | 469 | ||
| 452 | | Tipe Return | Deskripsi | | 470 | | Tipe Return | Deskripsi | |
| 453 | | --- | --- | | 471 | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 454 | | 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. | | 472 | | 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. | |
| 455 | 473 | ||
| 456 | ### p | 474 | ### p |
| 457 | 475 | ||
| @@ -462,15 +480,16 @@ require: function(name: string): any... | |||
| 462 | Memeriksa struktur nilai yang diteruskan dan mencetak representasi string. | 480 | Memeriksa struktur nilai yang diteruskan dan mencetak representasi string. |
| 463 | 481 | ||
| 464 | **Signature:** | 482 | **Signature:** |
| 483 | |||
| 465 | ```lua | 484 | ```lua |
| 466 | p: function(...: any) | 485 | p: function(...: any) |
| 467 | ``` | 486 | ``` |
| 468 | 487 | ||
| 469 | **Parameter:** | 488 | **Parameter:** |
| 470 | 489 | ||
| 471 | | Parameter | Tipe | Deskripsi | | 490 | | Parameter | Tipe | Deskripsi | |
| 472 | | --- | --- | --- | | 491 | | --------- | ---- | -------------------------- | |
| 473 | | ... | any | Nilai yang akan diperiksa. | | 492 | | ... | any | Nilai yang akan diperiksa. | |
| 474 | 493 | ||
| 475 | ### options | 494 | ### options |
| 476 | 495 | ||
| @@ -481,6 +500,7 @@ p: function(...: any) | |||
| 481 | Opsi kompiler saat ini. | 500 | Opsi kompiler saat ini. |
| 482 | 501 | ||
| 483 | **Signature:** | 502 | **Signature:** |
| 503 | |||
| 484 | ```lua | 504 | ```lua |
| 485 | options: Config.Options | 505 | options: Config.Options |
| 486 | ``` | 506 | ``` |
| @@ -494,21 +514,22 @@ options: Config.Options | |||
| 494 | Fungsi traceback yang menulis ulang nomor baris stack trace ke nomor baris asli di kode YueScript. | 514 | Fungsi traceback yang menulis ulang nomor baris stack trace ke nomor baris asli di kode YueScript. |
| 495 | 515 | ||
| 496 | **Signature:** | 516 | **Signature:** |
| 517 | |||
| 497 | ```lua | 518 | ```lua |
| 498 | traceback: function(message: string): string | 519 | traceback: function(message: string): string |
| 499 | ``` | 520 | ``` |
| 500 | 521 | ||
| 501 | **Parameter:** | 522 | **Parameter:** |
| 502 | 523 | ||
| 503 | | Parameter | Tipe | Deskripsi | | 524 | | Parameter | Tipe | Deskripsi | |
| 504 | | --- | --- | --- | | 525 | | --------- | ------ | ---------------- | |
| 505 | | message | string | Pesan traceback. | | 526 | | message | string | Pesan traceback. | |
| 506 | 527 | ||
| 507 | **Return:** | 528 | **Return:** |
| 508 | 529 | ||
| 509 | | Tipe Return | Deskripsi | | 530 | | Tipe Return | Deskripsi | |
| 510 | | --- | --- | | 531 | | ----------- | ----------------------------------------- | |
| 511 | | string | Pesan traceback yang telah ditulis ulang. | | 532 | | string | Pesan traceback yang telah ditulis ulang. | |
| 512 | 533 | ||
| 513 | ### is_ast | 534 | ### is_ast |
| 514 | 535 | ||
| @@ -519,22 +540,23 @@ traceback: function(message: string): string | |||
| 519 | Memeriksa apakah kode cocok dengan AST yang ditentukan. | 540 | Memeriksa apakah kode cocok dengan AST yang ditentukan. |
| 520 | 541 | ||
| 521 | **Signature:** | 542 | **Signature:** |
| 543 | |||
| 522 | ```lua | 544 | ```lua |
| 523 | is_ast: function(astName: string, code: string): boolean | 545 | is_ast: function(astName: string, code: string): boolean |
| 524 | ``` | 546 | ``` |
| 525 | 547 | ||
| 526 | **Parameter:** | 548 | **Parameter:** |
| 527 | 549 | ||
| 528 | | Parameter | Tipe | Deskripsi | | 550 | | Parameter | Tipe | Deskripsi | |
| 529 | | --- | --- | --- | | 551 | | --------- | ------ | --------- | |
| 530 | | astName | string | Nama AST. | | 552 | | astName | string | Nama AST. | |
| 531 | | code | string | Kode. | | 553 | | code | string | Kode. | |
| 532 | 554 | ||
| 533 | **Return:** | 555 | **Return:** |
| 534 | 556 | ||
| 535 | | Tipe Return | Deskripsi | | 557 | | Tipe Return | Deskripsi | |
| 536 | | --- | --- | | 558 | | ----------- | ----------------------------- | |
| 537 | | boolean | Apakah kode cocok dengan AST. | | 559 | | boolean | Apakah kode cocok dengan AST. | |
| 538 | 560 | ||
| 539 | ### AST | 561 | ### AST |
| 540 | 562 | ||
| @@ -545,6 +567,7 @@ is_ast: function(astName: string, code: string): boolean | |||
| 545 | Definisi tipe AST dengan nama, baris, kolom, dan sub-node. | 567 | Definisi tipe AST dengan nama, baris, kolom, dan sub-node. |
| 546 | 568 | ||
| 547 | **Signature:** | 569 | **Signature:** |
| 570 | |||
| 548 | ```lua | 571 | ```lua |
| 549 | type AST = {string, integer, integer, any} | 572 | type AST = {string, integer, integer, any} |
| 550 | ``` | 573 | ``` |
| @@ -558,6 +581,7 @@ type AST = {string, integer, integer, any} | |||
| 558 | Mengonversi kode menjadi AST. | 581 | Mengonversi kode menjadi AST. |
| 559 | 582 | ||
| 560 | **Signature:** | 583 | **Signature:** |
| 584 | |||
| 561 | ```lua | 585 | ```lua |
| 562 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): | 586 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): |
| 563 | --[[AST]] AST | nil, | 587 | --[[AST]] AST | nil, |
| @@ -566,18 +590,18 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 566 | 590 | ||
| 567 | **Parameter:** | 591 | **Parameter:** |
| 568 | 592 | ||
| 569 | | Parameter | Tipe | Deskripsi | | 593 | | Parameter | Tipe | Deskripsi | |
| 570 | | --- | --- | --- | | 594 | | -------------- | ------- | ---------------------------------------------------------------------------------------- | |
| 571 | | code | string | Kode. | | 595 | | code | string | Kode. | |
| 572 | | flattenLevel | integer | [Opsional] Tingkat perataan. Semakin tinggi berarti semakin rata. Default 0. Maksimum 2. | | 596 | | flattenLevel | integer | [Opsional] Tingkat perataan. Semakin tinggi berarti semakin rata. Default 0. Maksimum 2. | |
| 573 | | astName | string | [Opsional] Nama AST. Default "File". | | 597 | | astName | string | [Opsional] Nama AST. Default "File". | |
| 574 | | reserveComment | boolean | [Opsional] Apakah akan mempertahankan komentar asli. Default false. | | 598 | | reserveComment | boolean | [Opsional] Apakah akan mempertahankan komentar asli. Default false. | |
| 575 | 599 | ||
| 576 | **Return:** | 600 | **Return:** |
| 577 | 601 | ||
| 578 | | Tipe Return | Deskripsi | | 602 | | Tipe Return | Deskripsi | |
| 579 | | --- | --- | | 603 | | ------------- | --------------------------------------------- | |
| 580 | | AST \| nil | AST, atau nil jika konversi gagal. | | 604 | | AST \| nil | AST, atau nil jika konversi gagal. | |
| 581 | | string \| nil | Pesan error, atau nil jika konversi berhasil. | | 605 | | string \| nil | Pesan error, atau nil jika konversi berhasil. | |
| 582 | 606 | ||
| 583 | ### format | 607 | ### format |
| @@ -589,25 +613,26 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 589 | Memformat kode YueScript. | 613 | Memformat kode YueScript. |
| 590 | 614 | ||
| 591 | **Signature:** | 615 | **Signature:** |
| 616 | |||
| 592 | ```lua | 617 | ```lua |
| 593 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string | 618 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string |
| 594 | ``` | 619 | ``` |
| 595 | 620 | ||
| 596 | **Parameter:** | 621 | **Parameter:** |
| 597 | 622 | ||
| 598 | | Parameter | Tipe | Deskripsi | | 623 | | Parameter | Tipe | Deskripsi | |
| 599 | | --- | --- | --- | | 624 | | -------------- | ------- | ------------------------------------------------------------- | |
| 600 | | code | string | Kode. | | 625 | | code | string | Kode. | |
| 601 | | tabSize | integer | [Opsional] Ukuran tab. Default 4. | | 626 | | tabSize | integer | [Opsional] Ukuran tab. Default 4. | |
| 602 | | reserveComment | boolean | [Opsional] Apakah mempertahankan komentar asli. Default true. | | 627 | | reserveComment | boolean | [Opsional] Apakah mempertahankan komentar asli. Default true. | |
| 603 | 628 | ||
| 604 | **Return:** | 629 | **Return:** |
| 605 | 630 | ||
| 606 | | Tipe Return | Deskripsi | | 631 | | Tipe Return | Deskripsi | |
| 607 | | --- | --- | | 632 | | ----------- | ------------------------- | |
| 608 | | string | Kode yang telah diformat. | | 633 | | string | Kode yang telah diformat. | |
| 609 | 634 | ||
| 610 | ### __call | 635 | ### \_\_call |
| 611 | 636 | ||
| 612 | **Tipe:** Metamethod. | 637 | **Tipe:** Metamethod. |
| 613 | 638 | ||
| @@ -617,21 +642,22 @@ Me-require modul YueScript. | |||
| 617 | Menulis ulang nomor baris error ke nomor baris asli di kode YueScript saat pemuatan gagal. | 642 | Menulis ulang nomor baris error ke nomor baris asli di kode YueScript saat pemuatan gagal. |
| 618 | 643 | ||
| 619 | **Signature:** | 644 | **Signature:** |
| 645 | |||
| 620 | ```lua | 646 | ```lua |
| 621 | metamethod __call: function(self: yue, module: string): any... | 647 | metamethod __call: function(self: yue, module: string): any... |
| 622 | ``` | 648 | ``` |
| 623 | 649 | ||
| 624 | **Parameter:** | 650 | **Parameter:** |
| 625 | 651 | ||
| 626 | | Parameter | Tipe | Deskripsi | | 652 | | Parameter | Tipe | Deskripsi | |
| 627 | | --- | --- | --- | | 653 | | --------- | ------ | ----------- | |
| 628 | | module | string | Nama modul. | | 654 | | module | string | Nama modul. | |
| 629 | 655 | ||
| 630 | **Return:** | 656 | **Return:** |
| 631 | 657 | ||
| 632 | | Tipe Return | Deskripsi | | 658 | | Tipe Return | Deskripsi | |
| 633 | | --- | --- | | 659 | | ----------- | ------------ | |
| 634 | | any | Nilai modul. | | 660 | | any | Nilai modul. | |
| 635 | 661 | ||
| 636 | ## Config | 662 | ## Config |
| 637 | 663 | ||
| @@ -648,6 +674,7 @@ Opsi kompilasi kompiler. | |||
| 648 | Apakah kompiler harus mengumpulkan variabel global yang muncul dalam kode. | 674 | Apakah kompiler harus mengumpulkan variabel global yang muncul dalam kode. |
| 649 | 675 | ||
| 650 | **Signature:** | 676 | **Signature:** |
| 677 | |||
| 651 | ```lua | 678 | ```lua |
| 652 | lint_global: boolean | 679 | lint_global: boolean |
| 653 | ``` | 680 | ``` |
| @@ -661,6 +688,7 @@ lint_global: boolean | |||
| 661 | Apakah kompiler harus melakukan return implisit untuk blok kode root. | 688 | Apakah kompiler harus melakukan return implisit untuk blok kode root. |
| 662 | 689 | ||
| 663 | **Signature:** | 690 | **Signature:** |
| 691 | |||
| 664 | ```lua | 692 | ```lua |
| 665 | implicit_return_root: boolean | 693 | implicit_return_root: boolean |
| 666 | ``` | 694 | ``` |
| @@ -674,6 +702,7 @@ implicit_return_root: boolean | |||
| 674 | Apakah kompiler harus mempertahankan nomor baris asli di kode hasil kompilasi. | 702 | Apakah kompiler harus mempertahankan nomor baris asli di kode hasil kompilasi. |
| 675 | 703 | ||
| 676 | **Signature:** | 704 | **Signature:** |
| 705 | |||
| 677 | ```lua | 706 | ```lua |
| 678 | reserve_line_number: boolean | 707 | reserve_line_number: boolean |
| 679 | ``` | 708 | ``` |
| @@ -687,6 +716,7 @@ reserve_line_number: boolean | |||
| 687 | Apakah kompiler harus mempertahankan komentar asli di kode hasil kompilasi. | 716 | Apakah kompiler harus mempertahankan komentar asli di kode hasil kompilasi. |
| 688 | 717 | ||
| 689 | **Signature:** | 718 | **Signature:** |
| 719 | |||
| 690 | ```lua | 720 | ```lua |
| 691 | reserve_comment: boolean | 721 | reserve_comment: boolean |
| 692 | ``` | 722 | ``` |
| @@ -700,6 +730,7 @@ reserve_comment: boolean | |||
| 700 | Apakah kompiler harus menggunakan karakter spasi alih-alih tab di kode hasil kompilasi. | 730 | Apakah kompiler harus menggunakan karakter spasi alih-alih tab di kode hasil kompilasi. |
| 701 | 731 | ||
| 702 | **Signature:** | 732 | **Signature:** |
| 733 | |||
| 703 | ```lua | 734 | ```lua |
| 704 | space_over_tab: boolean | 735 | space_over_tab: boolean |
| 705 | ``` | 736 | ``` |
| @@ -713,6 +744,7 @@ space_over_tab: boolean | |||
| 713 | Apakah kompiler harus memperlakukan kode yang akan dikompilasi sebagai modul yang sama dengan modul yang sedang dikompilasi. Untuk penggunaan internal saja. | 744 | Apakah kompiler harus memperlakukan kode yang akan dikompilasi sebagai modul yang sama dengan modul yang sedang dikompilasi. Untuk penggunaan internal saja. |
| 714 | 745 | ||
| 715 | **Signature:** | 746 | **Signature:** |
| 747 | |||
| 716 | ```lua | 748 | ```lua |
| 717 | same_module: boolean | 749 | same_module: boolean |
| 718 | ``` | 750 | ``` |
| @@ -726,6 +758,7 @@ same_module: boolean | |||
| 726 | Apakah pesan error kompiler harus menyertakan offset nomor baris. Untuk penggunaan internal saja. | 758 | Apakah pesan error kompiler harus menyertakan offset nomor baris. Untuk penggunaan internal saja. |
| 727 | 759 | ||
| 728 | **Signature:** | 760 | **Signature:** |
| 761 | |||
| 729 | ```lua | 762 | ```lua |
| 730 | line_offset: integer | 763 | line_offset: integer |
| 731 | ``` | 764 | ``` |
| @@ -739,6 +772,7 @@ line_offset: integer | |||
| 739 | Enumerasi versi Lua target. | 772 | Enumerasi versi Lua target. |
| 740 | 773 | ||
| 741 | **Signature:** | 774 | **Signature:** |
| 775 | |||
| 742 | ```lua | 776 | ```lua |
| 743 | enum LuaTarget | 777 | enum LuaTarget |
| 744 | "5.1" | 778 | "5.1" |
| @@ -758,6 +792,7 @@ end | |||
| 758 | Opsi tambahan untuk diteruskan ke fungsi kompilasi. | 792 | Opsi tambahan untuk diteruskan ke fungsi kompilasi. |
| 759 | 793 | ||
| 760 | **Signature:** | 794 | **Signature:** |
| 795 | |||
| 761 | ```lua | 796 | ```lua |
| 762 | options: Options | 797 | options: Options |
| 763 | ``` | 798 | ``` |
| @@ -777,6 +812,7 @@ Definisi opsi kompiler tambahan. | |||
| 777 | Versi Lua target untuk kompilasi. | 812 | Versi Lua target untuk kompilasi. |
| 778 | 813 | ||
| 779 | **Signature:** | 814 | **Signature:** |
| 815 | |||
| 780 | ```lua | 816 | ```lua |
| 781 | target: LuaTarget | 817 | target: LuaTarget |
| 782 | ``` | 818 | ``` |
| @@ -790,6 +826,7 @@ target: LuaTarget | |||
| 790 | Path pencarian modul tambahan. | 826 | Path pencarian modul tambahan. |
| 791 | 827 | ||
| 792 | **Signature:** | 828 | **Signature:** |
| 829 | |||
| 793 | ```lua | 830 | ```lua |
| 794 | path: string | 831 | path: string |
| 795 | ``` | 832 | ``` |
| @@ -803,6 +840,7 @@ path: string | |||
| 803 | Apakah akan menampilkan variabel local dalam pesan error traceback. Default false. | 840 | Apakah akan menampilkan variabel local dalam pesan error traceback. Default false. |
| 804 | 841 | ||
| 805 | **Signature:** | 842 | **Signature:** |
| 843 | |||
| 806 | ```lua | 844 | ```lua |
| 807 | dump_locals: boolean | 845 | dump_locals: boolean |
| 808 | ``` | 846 | ``` |
| @@ -816,6 +854,7 @@ dump_locals: boolean | |||
| 816 | Apakah akan menyederhanakan pesan error. Default true. | 854 | Apakah akan menyederhanakan pesan error. Default true. |
| 817 | 855 | ||
| 818 | **Signature:** | 856 | **Signature:** |
| 857 | |||
| 819 | ```lua | 858 | ```lua |
| 820 | simplified: boolean | 859 | simplified: boolean |
| 821 | ``` | 860 | ``` |
diff --git a/doc/docs/id-id/try/index.md b/doc/docs/id-id/try/index.md index c31dc1c..c5127e2 100755 --- a/doc/docs/id-id/try/index.md +++ b/doc/docs/id-id/try/index.md | |||
| @@ -5,6 +5,7 @@ next: false | |||
| 5 | --- | 5 | --- |
| 6 | 6 | ||
| 7 | # Kompiler Online YueScript | 7 | # Kompiler Online YueScript |
| 8 | |||
| 8 | --- | 9 | --- |
| 9 | 10 | ||
| 10 | Coba YueScript di browser dengan WASM. | 11 | Coba YueScript di browser dengan WASM. |
diff --git a/doc/docs/pt-br/doc/advanced/do.md b/doc/docs/pt-br/doc/advanced/do.md index f13d8aa..503c551 100644 --- a/doc/docs/pt-br/doc/advanced/do.md +++ b/doc/docs/pt-br/doc/advanced/do.md | |||
| @@ -8,6 +8,7 @@ do | |||
| 8 | print var | 8 | print var |
| 9 | print var -- nil aqui | 9 | print var -- nil aqui |
| 10 | ``` | 10 | ``` |
| 11 | |||
| 11 | <YueDisplay> | 12 | <YueDisplay> |
| 12 | 13 | ||
| 13 | ```yue | 14 | ```yue |
| @@ -31,6 +32,7 @@ counter = do | |||
| 31 | print counter! | 32 | print counter! |
| 32 | print counter! | 33 | print counter! |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -53,6 +55,7 @@ tbl = { | |||
| 53 | 1234 | 55 | 1234 |
| 54 | } | 56 | } |
| 55 | ``` | 57 | ``` |
| 58 | |||
| 56 | <YueDisplay> | 59 | <YueDisplay> |
| 57 | 60 | ||
| 58 | ```yue | 61 | ```yue |
diff --git a/doc/docs/pt-br/doc/advanced/line-decorators.md b/doc/docs/pt-br/doc/advanced/line-decorators.md index 94d1004..aaf34ea 100644 --- a/doc/docs/pt-br/doc/advanced/line-decorators.md +++ b/doc/docs/pt-br/doc/advanced/line-decorators.md | |||
| @@ -5,6 +5,7 @@ Por conveniência, o loop for e a instrução if podem ser aplicados a instruç | |||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | print "hello world" if name == "Rob" | 6 | print "hello world" if name == "Rob" |
| 7 | ``` | 7 | ``` |
| 8 | |||
| 8 | <YueDisplay> | 9 | <YueDisplay> |
| 9 | 10 | ||
| 10 | ```yue | 11 | ```yue |
| @@ -18,6 +19,7 @@ E com loops básicos: | |||
| 18 | ```yuescript | 19 | ```yuescript |
| 19 | print "item: ", item for item in *items | 20 | print "item: ", item for item in *items |
| 20 | ``` | 21 | ``` |
| 22 | |||
| 21 | <YueDisplay> | 23 | <YueDisplay> |
| 22 | 24 | ||
| 23 | ```yue | 25 | ```yue |
| @@ -33,6 +35,7 @@ game\update! while game\isRunning! | |||
| 33 | 35 | ||
| 34 | reader\parse_line! until reader\eof! | 36 | reader\parse_line! until reader\eof! |
| 35 | ``` | 37 | ``` |
| 38 | |||
| 36 | <YueDisplay> | 39 | <YueDisplay> |
| 37 | 40 | ||
| 38 | ```yue | 41 | ```yue |
diff --git a/doc/docs/pt-br/doc/advanced/macro.md b/doc/docs/pt-br/doc/advanced/macro.md index 846d506..18d33e0 100644 --- a/doc/docs/pt-br/doc/advanced/macro.md +++ b/doc/docs/pt-br/doc/advanced/macro.md | |||
| @@ -32,6 +32,7 @@ macro and = (...) -> "#{ table.concat {...}, ' and ' }" | |||
| 32 | if $and f1!, f2!, f3! | 32 | if $and f1!, f2!, f3! |
| 33 | print "OK" | 33 | print "OK" |
| 34 | ``` | 34 | ``` |
| 35 | |||
| 35 | <YueDisplay> | 36 | <YueDisplay> |
| 36 | 37 | ||
| 37 | ```yue | 38 | ```yue |
| @@ -68,6 +69,7 @@ if $and f1!, f2!, f3! | |||
| 68 | ## Inserir códigos brutos | 69 | ## Inserir códigos brutos |
| 69 | 70 | ||
| 70 | Uma função macro pode retornar uma string YueScript ou uma tabela de configuração contendo códigos Lua. | 71 | Uma função macro pode retornar uma string YueScript ou uma tabela de configuração contendo códigos Lua. |
| 72 | |||
| 71 | ```yuescript | 73 | ```yuescript |
| 72 | macro yueFunc = (var) -> "local #{var} = ->" | 74 | macro yueFunc = (var) -> "local #{var} = ->" |
| 73 | $yueFunc funcA | 75 | $yueFunc funcA |
| @@ -93,6 +95,7 @@ if cond then | |||
| 93 | end | 95 | end |
| 94 | ]==] | 96 | ]==] |
| 95 | ``` | 97 | ``` |
| 98 | |||
| 96 | <YueDisplay> | 99 | <YueDisplay> |
| 97 | 100 | ||
| 98 | ```yue | 101 | ```yue |
| @@ -126,6 +129,7 @@ end | |||
| 126 | ## Exportar macro | 129 | ## Exportar macro |
| 127 | 130 | ||
| 128 | Funções macro podem ser exportadas de um módulo e importadas em outro módulo. Você deve colocar funções export macro em um único arquivo para uso, e apenas definição de macro, importação de macro e expansão de macro inline podem ser colocadas no módulo exportador de macro. | 131 | Funções macro podem ser exportadas de um módulo e importadas em outro módulo. Você deve colocar funções export macro em um único arquivo para uso, e apenas definição de macro, importação de macro e expansão de macro inline podem ser colocadas no módulo exportador de macro. |
| 132 | |||
| 129 | ```yuescript | 133 | ```yuescript |
| 130 | -- arquivo: utils.yue | 134 | -- arquivo: utils.yue |
| 131 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" | 135 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" |
| @@ -140,6 +144,7 @@ import "utils" as { | |||
| 140 | } | 144 | } |
| 141 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ | 145 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ |
| 142 | ``` | 146 | ``` |
| 147 | |||
| 143 | <YueDisplay> | 148 | <YueDisplay> |
| 144 | 149 | ||
| 145 | ```yue | 150 | ```yue |
| @@ -164,10 +169,12 @@ import "utils" as { | |||
| 164 | ## Macro embutida | 169 | ## Macro embutida |
| 165 | 170 | ||
| 166 | Existem algumas macros embutidas, mas você pode sobrescrevê-las declarando macros com os mesmos nomes. | 171 | Existem algumas macros embutidas, mas você pode sobrescrevê-las declarando macros com os mesmos nomes. |
| 172 | |||
| 167 | ```yuescript | 173 | ```yuescript |
| 168 | print $FILE -- obtém string do nome do módulo atual | 174 | print $FILE -- obtém string do nome do módulo atual |
| 169 | print $LINE -- obtém número 2 | 175 | print $LINE -- obtém número 2 |
| 170 | ``` | 176 | ``` |
| 177 | |||
| 171 | <YueDisplay> | 178 | <YueDisplay> |
| 172 | 179 | ||
| 173 | ```yue | 180 | ```yue |
| @@ -234,6 +241,7 @@ macro printNumAndStr = (num `Num, str `String) -> | | |||
| 234 | 241 | ||
| 235 | $printNumAndStr 123, "hello" | 242 | $printNumAndStr 123, "hello" |
| 236 | ``` | 243 | ``` |
| 244 | |||
| 237 | <YueDisplay> | 245 | <YueDisplay> |
| 238 | 246 | ||
| 239 | ```yue | 247 | ```yue |
| @@ -258,6 +266,7 @@ macro printNumAndStr = (num, str) -> | |||
| 258 | 266 | ||
| 259 | $printNumAndStr 123, "hello" | 267 | $printNumAndStr 123, "hello" |
| 260 | ``` | 268 | ``` |
| 269 | |||
| 261 | <YueDisplay> | 270 | <YueDisplay> |
| 262 | 271 | ||
| 263 | ```yue | 272 | ```yue |
diff --git a/doc/docs/pt-br/doc/advanced/module.md b/doc/docs/pt-br/doc/advanced/module.md index 34fd106..ed13107 100644 --- a/doc/docs/pt-br/doc/advanced/module.md +++ b/doc/docs/pt-br/doc/advanced/module.md | |||
| @@ -28,6 +28,7 @@ do | |||
| 28 | import "lpeg" as :C, :Ct, :Cmt | 28 | import "lpeg" as :C, :Ct, :Cmt |
| 29 | import "export" as {one, two, Something:{umm:{ch}}} | 29 | import "export" as {one, two, Something:{umm:{ch}}} |
| 30 | ``` | 30 | ``` |
| 31 | |||
| 31 | <YueDisplay> | 32 | <YueDisplay> |
| 32 | 33 | ||
| 33 | ```yue | 34 | ```yue |
| @@ -67,6 +68,7 @@ do | |||
| 67 | import table.concat | 68 | import table.concat |
| 68 | print concat ["a", tostring 1] | 69 | print concat ["a", tostring 1] |
| 69 | ``` | 70 | ``` |
| 71 | |||
| 70 | <YueDisplay> | 72 | <YueDisplay> |
| 71 | 73 | ||
| 72 | ```yue | 74 | ```yue |
| @@ -98,6 +100,7 @@ do | |||
| 98 | print FLAG | 100 | print FLAG |
| 99 | FLAG = 123 | 101 | FLAG = 123 |
| 100 | ``` | 102 | ``` |
| 103 | |||
| 101 | <YueDisplay> | 104 | <YueDisplay> |
| 102 | 105 | ||
| 103 | ```yue | 106 | ```yue |
| @@ -140,6 +143,7 @@ export y = -> | |||
| 140 | export class Something | 143 | export class Something |
| 141 | umm: "cool" | 144 | umm: "cool" |
| 142 | ``` | 145 | ``` |
| 146 | |||
| 143 | <YueDisplay> | 147 | <YueDisplay> |
| 144 | 148 | ||
| 145 | ```yue | 149 | ```yue |
| @@ -166,6 +170,7 @@ Fazendo export nomeado com desestruturação. | |||
| 166 | export :loadstring, to_lua: tolua = yue | 170 | export :loadstring, to_lua: tolua = yue |
| 167 | export {itemA: {:fieldA = 'default'}} = tb | 171 | export {itemA: {:fieldA = 'default'}} = tb |
| 168 | ``` | 172 | ``` |
| 173 | |||
| 169 | <YueDisplay> | 174 | <YueDisplay> |
| 170 | 175 | ||
| 171 | ```yue | 176 | ```yue |
| @@ -182,6 +187,7 @@ export.itemA = tb | |||
| 182 | export.<index> = items | 187 | export.<index> = items |
| 183 | export["a-b-c"] = 123 | 188 | export["a-b-c"] = 123 |
| 184 | ``` | 189 | ``` |
| 190 | |||
| 185 | <YueDisplay> | 191 | <YueDisplay> |
| 186 | 192 | ||
| 187 | ```yue | 193 | ```yue |
| @@ -208,6 +214,7 @@ else | |||
| 208 | export with tmp | 214 | export with tmp |
| 209 | j = 2000 | 215 | j = 2000 |
| 210 | ``` | 216 | ``` |
| 217 | |||
| 211 | <YueDisplay> | 218 | <YueDisplay> |
| 212 | 219 | ||
| 213 | ```yue | 220 | ```yue |
| @@ -234,6 +241,7 @@ export default -> | |||
| 234 | print "hello" | 241 | print "hello" |
| 235 | 123 | 242 | 123 |
| 236 | ``` | 243 | ``` |
| 244 | |||
| 237 | <YueDisplay> | 245 | <YueDisplay> |
| 238 | 246 | ||
| 239 | ```yue | 247 | ```yue |
diff --git a/doc/docs/pt-br/doc/advanced/try.md b/doc/docs/pt-br/doc/advanced/try.md index fbb4e87..0223feb 100644 --- a/doc/docs/pt-br/doc/advanced/try.md +++ b/doc/docs/pt-br/doc/advanced/try.md | |||
| @@ -29,6 +29,7 @@ catch err | |||
| 29 | print yue.traceback err | 29 | print yue.traceback err |
| 30 | print result | 30 | print result |
| 31 | ``` | 31 | ``` |
| 32 | |||
| 32 | <YueDisplay> | 33 | <YueDisplay> |
| 33 | 34 | ||
| 34 | ```yue | 35 | ```yue |
| @@ -82,6 +83,7 @@ catch e | |||
| 82 | print e | 83 | print e |
| 83 | e | 84 | e |
| 84 | ``` | 85 | ``` |
| 86 | |||
| 85 | <YueDisplay> | 87 | <YueDisplay> |
| 86 | 88 | ||
| 87 | ```yue | 89 | ```yue |
diff --git a/doc/docs/pt-br/doc/assignment/assignment.md b/doc/docs/pt-br/doc/assignment/assignment.md index 1da6bb0..ac3838f 100644 --- a/doc/docs/pt-br/doc/assignment/assignment.md +++ b/doc/docs/pt-br/doc/assignment/assignment.md | |||
| @@ -7,6 +7,7 @@ hello = "world" | |||
| 7 | a, b, c = 1, 2, 3 | 7 | a, b, c = 1, 2, 3 |
| 8 | hello = 123 -- usa a variável existente | 8 | hello = 123 -- usa a variável existente |
| 9 | ``` | 9 | ``` |
| 10 | |||
| 10 | <YueDisplay> | 11 | <YueDisplay> |
| 11 | 12 | ||
| 12 | ```yue | 13 | ```yue |
| @@ -20,6 +21,7 @@ hello = 123 -- usa a variável existente | |||
| 20 | ## Atualização | 21 | ## Atualização |
| 21 | 22 | ||
| 22 | Você pode realizar atribuição de atualização com muitos operadores binários. | 23 | Você pode realizar atribuição de atualização com muitos operadores binários. |
| 24 | |||
| 23 | ```yuescript | 25 | ```yuescript |
| 24 | x = 1 | 26 | x = 1 |
| 25 | x += 1 | 27 | x += 1 |
| @@ -30,6 +32,7 @@ x %= 10 | |||
| 30 | s ..= "world" -- adiciona um novo local se a variável local não existir | 32 | s ..= "world" -- adiciona um novo local se a variável local não existir |
| 31 | arg or= "valor padrão" | 33 | arg or= "valor padrão" |
| 32 | ``` | 34 | ``` |
| 35 | |||
| 33 | <YueDisplay> | 36 | <YueDisplay> |
| 34 | 37 | ||
| 35 | ```yue | 38 | ```yue |
| @@ -48,10 +51,12 @@ arg or= "valor padrão" | |||
| 48 | ## Atribuição encadeada | 51 | ## Atribuição encadeada |
| 49 | 52 | ||
| 50 | Você pode fazer atribuição encadeada para atribuir múltiplos itens ao mesmo valor. | 53 | Você pode fazer atribuição encadeada para atribuir múltiplos itens ao mesmo valor. |
| 54 | |||
| 51 | ```yuescript | 55 | ```yuescript |
| 52 | a = b = c = d = e = 0 | 56 | a = b = c = d = e = 0 |
| 53 | x = y = z = f! | 57 | x = y = z = f! |
| 54 | ``` | 58 | ``` |
| 59 | |||
| 55 | <YueDisplay> | 60 | <YueDisplay> |
| 56 | 61 | ||
| 57 | ```yue | 62 | ```yue |
| @@ -62,6 +67,7 @@ x = y = z = f! | |||
| 62 | </YueDisplay> | 67 | </YueDisplay> |
| 63 | 68 | ||
| 64 | ## Locais explícitos | 69 | ## Locais explícitos |
| 70 | |||
| 65 | ```yuescript | 71 | ```yuescript |
| 66 | do | 72 | do |
| 67 | local a = 1 | 73 | local a = 1 |
| @@ -78,6 +84,7 @@ do | |||
| 78 | a = 1 | 84 | a = 1 |
| 79 | B = 2 | 85 | B = 2 |
| 80 | ``` | 86 | ``` |
| 87 | |||
| 81 | <YueDisplay> | 88 | <YueDisplay> |
| 82 | 89 | ||
| 83 | ```yue | 90 | ```yue |
| @@ -100,6 +107,7 @@ do | |||
| 100 | </YueDisplay> | 107 | </YueDisplay> |
| 101 | 108 | ||
| 102 | ## Globais explícitos | 109 | ## Globais explícitos |
| 110 | |||
| 103 | ```yuescript | 111 | ```yuescript |
| 104 | do | 112 | do |
| 105 | global a = 1 | 113 | global a = 1 |
| @@ -116,6 +124,7 @@ do | |||
| 116 | B = 2 | 124 | B = 2 |
| 117 | local Temp = "um valor local" | 125 | local Temp = "um valor local" |
| 118 | ``` | 126 | ``` |
| 127 | |||
| 119 | <YueDisplay> | 128 | <YueDisplay> |
| 120 | 129 | ||
| 121 | ```yue | 130 | ```yue |
diff --git a/doc/docs/pt-br/doc/assignment/destructuring-assignment.md b/doc/docs/pt-br/doc/assignment/destructuring-assignment.md index 7692885..0c96d4a 100644 --- a/doc/docs/pt-br/doc/assignment/destructuring-assignment.md +++ b/doc/docs/pt-br/doc/assignment/destructuring-assignment.md | |||
| @@ -12,6 +12,7 @@ thing = [1, 2] | |||
| 12 | [a, b] = thing | 12 | [a, b] = thing |
| 13 | print a, b | 13 | print a, b |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -37,6 +38,7 @@ print hello, the_day | |||
| 37 | 38 | ||
| 38 | :day = obj -- OK fazer desestruturação simples sem chaves | 39 | :day = obj -- OK fazer desestruturação simples sem chaves |
| 39 | ``` | 40 | ``` |
| 41 | |||
| 40 | <YueDisplay> | 42 | <YueDisplay> |
| 41 | 43 | ||
| 42 | ```yue | 44 | ```yue |
| @@ -68,6 +70,7 @@ obj2 = { | |||
| 68 | {numbers: [first, second], properties: {color: color}} = obj2 | 70 | {numbers: [first, second], properties: {color: color}} = obj2 |
| 69 | print first, second, color | 71 | print first, second, color |
| 70 | ``` | 72 | ``` |
| 73 | |||
| 71 | <YueDisplay> | 74 | <YueDisplay> |
| 72 | 75 | ||
| 73 | ```yue | 76 | ```yue |
| @@ -95,6 +98,7 @@ Se a instrução de desestruturação for complicada, sinta-se à vontade para e | |||
| 95 | } | 98 | } |
| 96 | } = obj2 | 99 | } = obj2 |
| 97 | ``` | 100 | ``` |
| 101 | |||
| 98 | <YueDisplay> | 102 | <YueDisplay> |
| 99 | 103 | ||
| 100 | ```yue | 104 | ```yue |
| @@ -113,6 +117,7 @@ Se a instrução de desestruturação for complicada, sinta-se à vontade para e | |||
| 113 | ```yuescript | 117 | ```yuescript |
| 114 | {:concat, :insert} = table | 118 | {:concat, :insert} = table |
| 115 | ``` | 119 | ``` |
| 120 | |||
| 116 | <YueDisplay> | 121 | <YueDisplay> |
| 117 | 122 | ||
| 118 | ```yue | 123 | ```yue |
| @@ -126,6 +131,7 @@ Isso é efetivamente o mesmo que import, mas podemos renomear campos que queremo | |||
| 126 | ```yuescript | 131 | ```yuescript |
| 127 | {:mix, :max, random: rand} = math | 132 | {:mix, :max, random: rand} = math |
| 128 | ``` | 133 | ``` |
| 134 | |||
| 129 | <YueDisplay> | 135 | <YueDisplay> |
| 130 | 136 | ||
| 131 | ```yue | 137 | ```yue |
| @@ -139,6 +145,7 @@ Você pode escrever valores padrão ao fazer desestruturação: | |||
| 139 | ```yuescript | 145 | ```yuescript |
| 140 | {:name = "sem nome", :job = "sem emprego"} = person | 146 | {:name = "sem nome", :job = "sem emprego"} = person |
| 141 | ``` | 147 | ``` |
| 148 | |||
| 142 | <YueDisplay> | 149 | <YueDisplay> |
| 143 | 150 | ||
| 144 | ```yue | 151 | ```yue |
| @@ -152,6 +159,7 @@ Você pode usar `_` como placeholder ao fazer desestruturação de lista: | |||
| 152 | ```yuescript | 159 | ```yuescript |
| 153 | [_, two, _, four] = items | 160 | [_, two, _, four] = items |
| 154 | ``` | 161 | ``` |
| 162 | |||
| 155 | <YueDisplay> | 163 | <YueDisplay> |
| 156 | 164 | ||
| 157 | ```yue | 165 | ```yue |
| @@ -171,6 +179,7 @@ print first -- imprime: first | |||
| 171 | print bulk -- imprime: {"second", "third", "fourth"} | 179 | print bulk -- imprime: {"second", "third", "fourth"} |
| 172 | print last -- imprime: last | 180 | print last -- imprime: last |
| 173 | ``` | 181 | ``` |
| 182 | |||
| 174 | <YueDisplay> | 183 | <YueDisplay> |
| 175 | 184 | ||
| 176 | ```yue | 185 | ```yue |
| @@ -195,6 +204,7 @@ O operador spread pode ser usado em diferentes posições para capturar diferent | |||
| 195 | -- Capturar tudo exceto os elementos do meio | 204 | -- Capturar tudo exceto os elementos do meio |
| 196 | [first, ..._, last] = orders | 205 | [first, ..._, last] = orders |
| 197 | ``` | 206 | ``` |
| 207 | |||
| 198 | <YueDisplay> | 208 | <YueDisplay> |
| 199 | 209 | ||
| 200 | ```yue | 210 | ```yue |
| @@ -223,6 +233,7 @@ tuples = [ | |||
| 223 | for [left, right] in *tuples | 233 | for [left, right] in *tuples |
| 224 | print left, right | 234 | print left, right |
| 225 | ``` | 235 | ``` |
| 236 | |||
| 226 | <YueDisplay> | 237 | <YueDisplay> |
| 227 | 238 | ||
| 228 | ```yue | 239 | ```yue |
diff --git a/doc/docs/pt-br/doc/assignment/if-assignment.md b/doc/docs/pt-br/doc/assignment/if-assignment.md index 84094ed..7b1a852 100644 --- a/doc/docs/pt-br/doc/assignment/if-assignment.md +++ b/doc/docs/pt-br/doc/assignment/if-assignment.md | |||
| @@ -6,6 +6,7 @@ Os blocos `if` e `elseif` podem receber uma atribuição no lugar de uma express | |||
| 6 | if user := database.find_user "moon" | 6 | if user := database.find_user "moon" |
| 7 | print user.name | 7 | print user.name |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -23,6 +24,7 @@ elseif world := os.getenv "world" | |||
| 23 | else | 24 | else |
| 24 | print "nada :(" | 25 | print "nada :(" |
| 25 | ``` | 26 | ``` |
| 27 | |||
| 26 | <YueDisplay> | 28 | <YueDisplay> |
| 27 | 29 | ||
| 28 | ```yue | 30 | ```yue |
| @@ -37,11 +39,13 @@ else | |||
| 37 | </YueDisplay> | 39 | </YueDisplay> |
| 38 | 40 | ||
| 39 | Atribuição em if com múltiplos valores de retorno. Apenas o primeiro valor é verificado, os outros valores estão no escopo. | 41 | Atribuição em if com múltiplos valores de retorno. Apenas o primeiro valor é verificado, os outros valores estão no escopo. |
| 42 | |||
| 40 | ```yuescript | 43 | ```yuescript |
| 41 | if success, result := pcall -> "obter resultado sem problemas" | 44 | if success, result := pcall -> "obter resultado sem problemas" |
| 42 | print result -- variável result está no escopo | 45 | print result -- variável result está no escopo |
| 43 | print "OK" | 46 | print "OK" |
| 44 | ``` | 47 | ``` |
| 48 | |||
| 45 | <YueDisplay> | 49 | <YueDisplay> |
| 46 | 50 | ||
| 47 | ```yue | 51 | ```yue |
| @@ -61,6 +65,7 @@ while byte := stream\read_one! | |||
| 61 | -- fazer algo com o byte | 65 | -- fazer algo com o byte |
| 62 | print byte | 66 | print byte |
| 63 | ``` | 67 | ``` |
| 68 | |||
| 64 | <YueDisplay> | 69 | <YueDisplay> |
| 65 | 70 | ||
| 66 | ```yue | 71 | ```yue |
diff --git a/doc/docs/pt-br/doc/assignment/the-using-clause-controlling-destructive-assignment.md b/doc/docs/pt-br/doc/assignment/the-using-clause-controlling-destructive-assignment.md index 02d4162..c49aa15 100644 --- a/doc/docs/pt-br/doc/assignment/the-using-clause-controlling-destructive-assignment.md +++ b/doc/docs/pt-br/doc/assignment/the-using-clause-controlling-destructive-assignment.md | |||
| @@ -17,6 +17,7 @@ my_func! | |||
| 17 | 17 | ||
| 18 | print i -- vai imprimir 0 | 18 | print i -- vai imprimir 0 |
| 19 | ``` | 19 | ``` |
| 20 | |||
| 20 | <YueDisplay> | 21 | <YueDisplay> |
| 21 | 22 | ||
| 22 | ```yue | 23 | ```yue |
| @@ -52,6 +53,7 @@ my_func = (using nil) -> | |||
| 52 | my_func! | 53 | my_func! |
| 53 | print i -- imprime 100, i não é afetado | 54 | print i -- imprime 100, i não é afetado |
| 54 | ``` | 55 | ``` |
| 56 | |||
| 55 | <YueDisplay> | 57 | <YueDisplay> |
| 56 | 58 | ||
| 57 | ```yue | 59 | ```yue |
| @@ -80,6 +82,7 @@ my_func = (add using k, i) -> | |||
| 80 | my_func(22) | 82 | my_func(22) |
| 81 | print i, k -- estes foram atualizados | 83 | print i, k -- estes foram atualizados |
| 82 | ``` | 84 | ``` |
| 85 | |||
| 83 | <YueDisplay> | 86 | <YueDisplay> |
| 84 | 87 | ||
| 85 | ```yue | 88 | ```yue |
diff --git a/doc/docs/pt-br/doc/assignment/varargs-assignment.md b/doc/docs/pt-br/doc/assignment/varargs-assignment.md index 0aab540..6ac67e0 100644 --- a/doc/docs/pt-br/doc/assignment/varargs-assignment.md +++ b/doc/docs/pt-br/doc/assignment/varargs-assignment.md | |||
| @@ -10,6 +10,7 @@ count = select '#', ... | |||
| 10 | first = select 1, ... | 10 | first = select 1, ... |
| 11 | print ok, count, first | 11 | print ok, count, first |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
diff --git a/doc/docs/pt-br/doc/control-flow/conditionals.md b/doc/docs/pt-br/doc/control-flow/conditionals.md index 94e41ec..bc12d4e 100644 --- a/doc/docs/pt-br/doc/control-flow/conditionals.md +++ b/doc/docs/pt-br/doc/control-flow/conditionals.md | |||
| @@ -7,6 +7,7 @@ if have_coins | |||
| 7 | else | 7 | else |
| 8 | print "Sem moedas" | 8 | print "Sem moedas" |
| 9 | ``` | 9 | ``` |
| 10 | |||
| 10 | <YueDisplay> | 11 | <YueDisplay> |
| 11 | 12 | ||
| 12 | ```yue | 13 | ```yue |
| @@ -25,6 +26,7 @@ Uma sintaxe curta para instruções únicas também pode ser usada: | |||
| 25 | have_coins = false | 26 | have_coins = false |
| 26 | if have_coins then print "Tem moedas" else print "Sem moedas" | 27 | if have_coins then print "Tem moedas" else print "Sem moedas" |
| 27 | ``` | 28 | ``` |
| 29 | |||
| 28 | <YueDisplay> | 30 | <YueDisplay> |
| 29 | 31 | ||
| 30 | ```yue | 32 | ```yue |
| @@ -40,6 +42,7 @@ Como instruções if podem ser usadas como expressões, isso também pode ser es | |||
| 40 | have_coins = false | 42 | have_coins = false |
| 41 | print if have_coins then "Tem moedas" else "Sem moedas" | 43 | print if have_coins then "Tem moedas" else "Sem moedas" |
| 42 | ``` | 44 | ``` |
| 45 | |||
| 43 | <YueDisplay> | 46 | <YueDisplay> |
| 44 | 47 | ||
| 45 | ```yue | 48 | ```yue |
| @@ -65,6 +68,7 @@ else | |||
| 65 | 68 | ||
| 66 | print message -- imprime: Sou muito alto | 69 | print message -- imprime: Sou muito alto |
| 67 | ``` | 70 | ``` |
| 71 | |||
| 68 | <YueDisplay> | 72 | <YueDisplay> |
| 69 | 73 | ||
| 70 | ```yue | 74 | ```yue |
| @@ -90,6 +94,7 @@ O oposto de if é unless: | |||
| 90 | unless os.date("%A") == "Monday" | 94 | unless os.date("%A") == "Monday" |
| 91 | print "não é segunda-feira!" | 95 | print "não é segunda-feira!" |
| 92 | ``` | 96 | ``` |
| 97 | |||
| 93 | <YueDisplay> | 98 | <YueDisplay> |
| 94 | 99 | ||
| 95 | ```yue | 100 | ```yue |
| @@ -102,6 +107,7 @@ unless os.date("%A") == "Monday" | |||
| 102 | ```yuescript | 107 | ```yuescript |
| 103 | print "Você tem sorte!" unless math.random! > 0.1 | 108 | print "Você tem sorte!" unless math.random! > 0.1 |
| 104 | ``` | 109 | ``` |
| 110 | |||
| 105 | <YueDisplay> | 111 | <YueDisplay> |
| 106 | 112 | ||
| 107 | ```yue | 113 | ```yue |
| @@ -123,6 +129,7 @@ if a in [1, 3, 5, 7] | |||
| 123 | if a in list | 129 | if a in list |
| 124 | print "verificando se `a` está na lista" | 130 | print "verificando se `a` está na lista" |
| 125 | ``` | 131 | ``` |
| 132 | |||
| 126 | <YueDisplay> | 133 | <YueDisplay> |
| 127 | 134 | ||
| 128 | ```yue | 135 | ```yue |
diff --git a/doc/docs/pt-br/doc/control-flow/continue.md b/doc/docs/pt-br/doc/control-flow/continue.md index 8a3cdff..645bcb4 100644 --- a/doc/docs/pt-br/doc/control-flow/continue.md +++ b/doc/docs/pt-br/doc/control-flow/continue.md | |||
| @@ -9,6 +9,7 @@ while i < 10 | |||
| 9 | continue if i % 2 == 0 | 9 | continue if i % 2 == 0 |
| 10 | print i | 10 | print i |
| 11 | ``` | 11 | ``` |
| 12 | |||
| 12 | <YueDisplay> | 13 | <YueDisplay> |
| 13 | 14 | ||
| 14 | ```yue | 15 | ```yue |
| @@ -29,6 +30,7 @@ odds = for x in *my_numbers | |||
| 29 | continue if x % 2 == 1 | 30 | continue if x % 2 == 1 |
| 30 | x | 31 | x |
| 31 | ``` | 32 | ``` |
| 33 | |||
| 32 | <YueDisplay> | 34 | <YueDisplay> |
| 33 | 35 | ||
| 34 | ```yue | 36 | ```yue |
diff --git a/doc/docs/pt-br/doc/control-flow/for-loop.md b/doc/docs/pt-br/doc/control-flow/for-loop.md index dfd8285..4c99e6d 100644 --- a/doc/docs/pt-br/doc/control-flow/for-loop.md +++ b/doc/docs/pt-br/doc/control-flow/for-loop.md | |||
| @@ -12,6 +12,7 @@ for k = 1, 15, 2 -- um passo opcional fornecido | |||
| 12 | for key, value in pairs object | 12 | for key, value in pairs object |
| 13 | print key, value | 13 | print key, value |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -33,6 +34,7 @@ Os operadores de slicing e **\*** podem ser usados, assim como com compreensões | |||
| 33 | for item in *items[2, 4] | 34 | for item in *items[2, 4] |
| 34 | print item | 35 | print item |
| 35 | ``` | 36 | ``` |
| 37 | |||
| 36 | <YueDisplay> | 38 | <YueDisplay> |
| 37 | 39 | ||
| 38 | ```yue | 40 | ```yue |
| @@ -49,6 +51,7 @@ for item in *items do print item | |||
| 49 | 51 | ||
| 50 | for j = 1, 10, 3 do print j | 52 | for j = 1, 10, 3 do print j |
| 51 | ``` | 53 | ``` |
| 54 | |||
| 52 | <YueDisplay> | 55 | <YueDisplay> |
| 53 | 56 | ||
| 54 | ```yue | 57 | ```yue |
| @@ -70,6 +73,7 @@ doubled_evens = for i = 1, 20 | |||
| 70 | else | 73 | else |
| 71 | i | 74 | i |
| 72 | ``` | 75 | ``` |
| 76 | |||
| 73 | <YueDisplay> | 77 | <YueDisplay> |
| 74 | 78 | ||
| 75 | ```yue | 79 | ```yue |
| @@ -90,6 +94,7 @@ Por exemplo, para encontrar o primeiro número maior que 10: | |||
| 90 | first_large = for n in *numbers | 94 | first_large = for n in *numbers |
| 91 | break n if n > 10 | 95 | break n if n > 10 |
| 92 | ``` | 96 | ``` |
| 97 | |||
| 93 | <YueDisplay> | 98 | <YueDisplay> |
| 94 | 99 | ||
| 95 | ```yue | 100 | ```yue |
| @@ -112,6 +117,7 @@ func_b = -> return for i = 1, 10 do i | |||
| 112 | print func_a! -- imprime nil | 117 | print func_a! -- imprime nil |
| 113 | print func_b! -- imprime objeto table | 118 | print func_b! -- imprime objeto table |
| 114 | ``` | 119 | ``` |
| 120 | |||
| 115 | <YueDisplay> | 121 | <YueDisplay> |
| 116 | 122 | ||
| 117 | ```yue | 123 | ```yue |
diff --git a/doc/docs/pt-br/doc/control-flow/switch.md b/doc/docs/pt-br/doc/control-flow/switch.md index 5c87327..bc41bad 100644 --- a/doc/docs/pt-br/doc/control-flow/switch.md +++ b/doc/docs/pt-br/doc/control-flow/switch.md | |||
| @@ -11,6 +11,7 @@ switch name := "Dan" | |||
| 11 | else | 11 | else |
| 12 | print "Não sei quem você é com o nome #{name}" | 12 | print "Não sei quem você é com o nome #{name}" |
| 13 | ``` | 13 | ``` |
| 14 | |||
| 14 | <YueDisplay> | 15 | <YueDisplay> |
| 15 | 16 | ||
| 16 | ```yue | 17 | ```yue |
| @@ -39,6 +40,7 @@ next_number = switch b | |||
| 39 | else | 40 | else |
| 40 | error "não consigo contar tão alto!" | 41 | error "não consigo contar tão alto!" |
| 41 | ``` | 42 | ``` |
| 43 | |||
| 42 | <YueDisplay> | 44 | <YueDisplay> |
| 43 | 45 | ||
| 44 | ```yue | 46 | ```yue |
| @@ -62,6 +64,7 @@ msg = switch math.random(1, 5) | |||
| 62 | when 2 then "você quase tem sorte" | 64 | when 2 then "você quase tem sorte" |
| 63 | else "não tão sortudo" | 65 | else "não tão sortudo" |
| 64 | ``` | 66 | ``` |
| 67 | |||
| 65 | <YueDisplay> | 68 | <YueDisplay> |
| 66 | 69 | ||
| 67 | ```yue | 70 | ```yue |
| @@ -87,6 +90,7 @@ switch math.random(1, 5) when 1 | |||
| 87 | else | 90 | else |
| 88 | print "não tão sortudo" | 91 | print "não tão sortudo" |
| 89 | ``` | 92 | ``` |
| 93 | |||
| 90 | <YueDisplay> | 94 | <YueDisplay> |
| 91 | 95 | ||
| 92 | ```yue | 96 | ```yue |
| @@ -124,6 +128,7 @@ for item in *items | |||
| 124 | when :width, :height | 128 | when :width, :height |
| 125 | print "tamanho #{width}, #{height}" | 129 | print "tamanho #{width}, #{height}" |
| 126 | ``` | 130 | ``` |
| 131 | |||
| 127 | <YueDisplay> | 132 | <YueDisplay> |
| 128 | 133 | ||
| 129 | ```yue | 134 | ```yue |
| @@ -154,6 +159,7 @@ switch item | |||
| 154 | when {pos: {:x = 50, :y = 200}} | 159 | when {pos: {:x = 50, :y = 200}} |
| 155 | print "Vec2 #{x}, #{y}" -- a desestruturação de tabela ainda passará | 160 | print "Vec2 #{x}, #{y}" -- a desestruturação de tabela ainda passará |
| 156 | ``` | 161 | ``` |
| 162 | |||
| 157 | <YueDisplay> | 163 | <YueDisplay> |
| 158 | 164 | ||
| 159 | ```yue | 165 | ```yue |
| @@ -181,6 +187,7 @@ switch tb | |||
| 181 | when [1, 2, b = 3] -- b tem valor padrão | 187 | when [1, 2, b = 3] -- b tem valor padrão |
| 182 | print "1, 2, #{b}" | 188 | print "1, 2, #{b}" |
| 183 | ``` | 189 | ``` |
| 190 | |||
| 184 | <YueDisplay> | 191 | <YueDisplay> |
| 185 | 192 | ||
| 186 | ```yue | 193 | ```yue |
| @@ -206,6 +213,7 @@ switch tb | |||
| 206 | else | 213 | else |
| 207 | print "inválido" | 214 | print "inválido" |
| 208 | ``` | 215 | ``` |
| 216 | |||
| 209 | <YueDisplay> | 217 | <YueDisplay> |
| 210 | 218 | ||
| 211 | ```yue | 219 | ```yue |
| @@ -231,6 +239,7 @@ switch tb | |||
| 231 | else | 239 | else |
| 232 | print "inválido" | 240 | print "inválido" |
| 233 | ``` | 241 | ``` |
| 242 | |||
| 234 | <YueDisplay> | 243 | <YueDisplay> |
| 235 | 244 | ||
| 236 | ```yue | 245 | ```yue |
| @@ -257,6 +266,7 @@ switch tb | |||
| 257 | ] | 266 | ] |
| 258 | print "correspondido", fourth | 267 | print "correspondido", fourth |
| 259 | ``` | 268 | ``` |
| 269 | |||
| 260 | <YueDisplay> | 270 | <YueDisplay> |
| 261 | 271 | ||
| 262 | ```yue | 272 | ```yue |
| @@ -282,6 +292,7 @@ switch segments | |||
| 282 | print "Recurso:", resource -- imprime: "logs" | 292 | print "Recurso:", resource -- imprime: "logs" |
| 283 | print "Ação:", action -- imprime: "view" | 293 | print "Ação:", action -- imprime: "view" |
| 284 | ``` | 294 | ``` |
| 295 | |||
| 285 | <YueDisplay> | 296 | <YueDisplay> |
| 286 | 297 | ||
| 287 | ```yue | 298 | ```yue |
diff --git a/doc/docs/pt-br/doc/control-flow/while-loop.md b/doc/docs/pt-br/doc/control-flow/while-loop.md index f47f00c..2deb5aa 100644 --- a/doc/docs/pt-br/doc/control-flow/while-loop.md +++ b/doc/docs/pt-br/doc/control-flow/while-loop.md | |||
| @@ -10,6 +10,7 @@ while i > 0 | |||
| 10 | 10 | ||
| 11 | while running == true do my_function! | 11 | while running == true do my_function! |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
| @@ -31,6 +32,7 @@ until i == 0 | |||
| 31 | 32 | ||
| 32 | until running == false do my_function! | 33 | until running == false do my_function! |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -56,6 +58,7 @@ repeat | |||
| 56 | i -= 1 | 58 | i -= 1 |
| 57 | until i == 0 | 59 | until i == 0 |
| 58 | ``` | 60 | ``` |
| 61 | |||
| 59 | <YueDisplay> | 62 | <YueDisplay> |
| 60 | 63 | ||
| 61 | ```yue | 64 | ```yue |
diff --git a/doc/docs/pt-br/doc/data-structures/comprehensions.md b/doc/docs/pt-br/doc/data-structures/comprehensions.md index 1694813..9651352 100644 --- a/doc/docs/pt-br/doc/data-structures/comprehensions.md +++ b/doc/docs/pt-br/doc/data-structures/comprehensions.md | |||
| @@ -10,6 +10,7 @@ O seguinte cria uma cópia da tabela items mas com todos os valores dobrados. | |||
| 10 | items = [ 1, 2, 3, 4 ] | 10 | items = [ 1, 2, 3, 4 ] |
| 11 | doubled = [item * 2 for i, item in ipairs items] | 11 | doubled = [item * 2 for i, item in ipairs items] |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
| @@ -24,6 +25,7 @@ Os itens incluídos na nova tabela podem ser restringidos com uma cláusula when | |||
| 24 | ```yuescript | 25 | ```yuescript |
| 25 | slice = [item for i, item in ipairs items when i > 1 and i < 3] | 26 | slice = [item for i, item in ipairs items when i > 1 and i < 3] |
| 26 | ``` | 27 | ``` |
| 28 | |||
| 27 | <YueDisplay> | 29 | <YueDisplay> |
| 28 | 30 | ||
| 29 | ```yue | 31 | ```yue |
| @@ -37,6 +39,7 @@ Como é comum iterar sobre os valores de uma tabela indexada numericamente, um o | |||
| 37 | ```yuescript | 39 | ```yuescript |
| 38 | doubled = [item * 2 for item in *items] | 40 | doubled = [item * 2 for item in *items] |
| 39 | ``` | 41 | ``` |
| 42 | |||
| 40 | <YueDisplay> | 43 | <YueDisplay> |
| 41 | 44 | ||
| 42 | ```yue | 45 | ```yue |
| @@ -55,6 +58,7 @@ data = | |||
| 55 | flat = [...v for k,v in pairs data] | 58 | flat = [...v for k,v in pairs data] |
| 56 | -- flat agora é [1, 2, 3, 4, 5, 6] | 59 | -- flat agora é [1, 2, 3, 4, 5, 6] |
| 57 | ``` | 60 | ``` |
| 61 | |||
| 58 | <YueDisplay> | 62 | <YueDisplay> |
| 59 | 63 | ||
| 60 | ```yue | 64 | ```yue |
| @@ -79,6 +83,7 @@ y_coords = [9, 2, 3] | |||
| 79 | points = [ [x, y] for x in *x_coords \ | 83 | points = [ [x, y] for x in *x_coords \ |
| 80 | for y in *y_coords] | 84 | for y in *y_coords] |
| 81 | ``` | 85 | ``` |
| 86 | |||
| 82 | <YueDisplay> | 87 | <YueDisplay> |
| 83 | 88 | ||
| 84 | ```yue | 89 | ```yue |
| @@ -96,6 +101,7 @@ Loops for numéricos também podem ser usados em compreensões: | |||
| 96 | ```yuescript | 101 | ```yuescript |
| 97 | evens = [i for i = 1, 100 when i % 2 == 0] | 102 | evens = [i for i = 1, 100 when i % 2 == 0] |
| 98 | ``` | 103 | ``` |
| 104 | |||
| 99 | <YueDisplay> | 105 | <YueDisplay> |
| 100 | 106 | ||
| 101 | ```yue | 107 | ```yue |
| @@ -119,6 +125,7 @@ thing = { | |||
| 119 | 125 | ||
| 120 | thing_copy = {k, v for k, v in pairs thing} | 126 | thing_copy = {k, v for k, v in pairs thing} |
| 121 | ``` | 127 | ``` |
| 128 | |||
| 122 | <YueDisplay> | 129 | <YueDisplay> |
| 123 | 130 | ||
| 124 | ```yue | 131 | ```yue |
| @@ -136,6 +143,7 @@ thing_copy = {k, v for k, v in pairs thing} | |||
| 136 | ```yuescript | 143 | ```yuescript |
| 137 | no_color = {k, v for k, v in pairs thing when k != "color"} | 144 | no_color = {k, v for k, v in pairs thing when k != "color"} |
| 138 | ``` | 145 | ``` |
| 146 | |||
| 139 | <YueDisplay> | 147 | <YueDisplay> |
| 140 | 148 | ||
| 141 | ```yue | 149 | ```yue |
| @@ -150,6 +158,7 @@ O operador **\*** também é suportado. Aqui criamos uma tabela de consulta de r | |||
| 150 | numbers = [1, 2, 3, 4] | 158 | numbers = [1, 2, 3, 4] |
| 151 | sqrts = {i, math.sqrt i for i in *numbers} | 159 | sqrts = {i, math.sqrt i for i in *numbers} |
| 152 | ``` | 160 | ``` |
| 161 | |||
| 153 | <YueDisplay> | 162 | <YueDisplay> |
| 154 | 163 | ||
| 155 | ```yue | 164 | ```yue |
| @@ -167,6 +176,7 @@ Neste exemplo convertemos um array de pares em uma tabela onde o primeiro item d | |||
| 167 | tuples = [ ["hello", "world"], ["foo", "bar"]] | 176 | tuples = [ ["hello", "world"], ["foo", "bar"]] |
| 168 | tbl = {unpack tuple for tuple in *tuples} | 177 | tbl = {unpack tuple for tuple in *tuples} |
| 169 | ``` | 178 | ``` |
| 179 | |||
| 170 | <YueDisplay> | 180 | <YueDisplay> |
| 171 | 181 | ||
| 172 | ```yue | 182 | ```yue |
| @@ -185,6 +195,7 @@ Aqui podemos definir os limites mínimo e máximo, pegando todos os itens com í | |||
| 185 | ```yuescript | 195 | ```yuescript |
| 186 | slice = [item for item in *items[1, 5]] | 196 | slice = [item for item in *items[1, 5]] |
| 187 | ``` | 197 | ``` |
| 198 | |||
| 188 | <YueDisplay> | 199 | <YueDisplay> |
| 189 | 200 | ||
| 190 | ```yue | 201 | ```yue |
| @@ -198,6 +209,7 @@ Qualquer um dos argumentos do slice pode ser omitido para usar um padrão sensat | |||
| 198 | ```yuescript | 209 | ```yuescript |
| 199 | slice = [item for item in *items[2,]] | 210 | slice = [item for item in *items[2,]] |
| 200 | ``` | 211 | ``` |
| 212 | |||
| 201 | <YueDisplay> | 213 | <YueDisplay> |
| 202 | 214 | ||
| 203 | ```yue | 215 | ```yue |
| @@ -211,6 +223,7 @@ Se o limite mínimo for omitido, ele usa como padrão 1. Aqui fornecemos apenas | |||
| 211 | ```yuescript | 223 | ```yuescript |
| 212 | slice = [item for item in *items[,,2]] | 224 | slice = [item for item in *items[,,2]] |
| 213 | ``` | 225 | ``` |
| 226 | |||
| 214 | <YueDisplay> | 227 | <YueDisplay> |
| 215 | 228 | ||
| 216 | ```yue | 229 | ```yue |
| @@ -225,6 +238,7 @@ Tanto o limite mínimo quanto o máximo podem ser negativos, o que significa que | |||
| 225 | -- pegar os últimos 4 itens | 238 | -- pegar os últimos 4 itens |
| 226 | slice = [item for item in *items[-4,-1]] | 239 | slice = [item for item in *items[-4,-1]] |
| 227 | ``` | 240 | ``` |
| 241 | |||
| 228 | <YueDisplay> | 242 | <YueDisplay> |
| 229 | 243 | ||
| 230 | ```yue | 244 | ```yue |
| @@ -239,6 +253,7 @@ O tamanho do passo também pode ser negativo, o que significa que os itens são | |||
| 239 | ```yuescript | 253 | ```yuescript |
| 240 | reverse_slice = [item for item in *items[-1,1,-1]] | 254 | reverse_slice = [item for item in *items[-1,1,-1]] |
| 241 | ``` | 255 | ``` |
| 256 | |||
| 242 | <YueDisplay> | 257 | <YueDisplay> |
| 243 | 258 | ||
| 244 | ```yue | 259 | ```yue |
| @@ -258,6 +273,7 @@ sub_list = items[2, 4] | |||
| 258 | -- pegar os últimos 4 itens | 273 | -- pegar os últimos 4 itens |
| 259 | last_four_items = items[-4, -1] | 274 | last_four_items = items[-4, -1] |
| 260 | ``` | 275 | ``` |
| 276 | |||
| 261 | <YueDisplay> | 277 | <YueDisplay> |
| 262 | 278 | ||
| 263 | ```yue | 279 | ```yue |
diff --git a/doc/docs/pt-br/doc/data-structures/table-literals.md b/doc/docs/pt-br/doc/data-structures/table-literals.md index f0fbdc5..23817ff 100644 --- a/doc/docs/pt-br/doc/data-structures/table-literals.md +++ b/doc/docs/pt-br/doc/data-structures/table-literals.md | |||
| @@ -5,6 +5,7 @@ Como no Lua, as tabelas são delimitadas por chaves. | |||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | some_values = [1, 2, 3, 4] | 6 | some_values = [1, 2, 3, 4] |
| 7 | ``` | 7 | ``` |
| 8 | |||
| 8 | <YueDisplay> | 9 | <YueDisplay> |
| 9 | 10 | ||
| 10 | ```yue | 11 | ```yue |
| @@ -22,6 +23,7 @@ some_values = { | |||
| 22 | ["favorite food"]: "rice" | 23 | ["favorite food"]: "rice" |
| 23 | } | 24 | } |
| 24 | ``` | 25 | ``` |
| 26 | |||
| 25 | <YueDisplay> | 27 | <YueDisplay> |
| 26 | 28 | ||
| 27 | ```yue | 29 | ```yue |
| @@ -42,6 +44,7 @@ profile = | |||
| 42 | shoe_size: 13, | 44 | shoe_size: 13, |
| 43 | favorite_foods: ["ice cream", "donuts"] | 45 | favorite_foods: ["ice cream", "donuts"] |
| 44 | ``` | 46 | ``` |
| 47 | |||
| 45 | <YueDisplay> | 48 | <YueDisplay> |
| 46 | 49 | ||
| 47 | ```yue | 50 | ```yue |
| @@ -63,6 +66,7 @@ values = { | |||
| 63 | occupation: "crime fighting" | 66 | occupation: "crime fighting" |
| 64 | } | 67 | } |
| 65 | ``` | 68 | ``` |
| 69 | |||
| 66 | <YueDisplay> | 70 | <YueDisplay> |
| 67 | 71 | ||
| 68 | ```yue | 72 | ```yue |
| @@ -83,6 +87,7 @@ my_function dance: "Tango", partner: "none" | |||
| 83 | 87 | ||
| 84 | y = type: "dog", legs: 4, tails: 1 | 88 | y = type: "dog", legs: 4, tails: 1 |
| 85 | ``` | 89 | ``` |
| 90 | |||
| 86 | <YueDisplay> | 91 | <YueDisplay> |
| 87 | 92 | ||
| 88 | ```yue | 93 | ```yue |
| @@ -101,6 +106,7 @@ tbl = { | |||
| 101 | end: "hunger" | 106 | end: "hunger" |
| 102 | } | 107 | } |
| 103 | ``` | 108 | ``` |
| 109 | |||
| 104 | <YueDisplay> | 110 | <YueDisplay> |
| 105 | 111 | ||
| 106 | ```yue | 112 | ```yue |
| @@ -121,6 +127,7 @@ person = { :hair, :height, shoe_size: 40 } | |||
| 121 | 127 | ||
| 122 | print_table :hair, :height | 128 | print_table :hair, :height |
| 123 | ``` | 129 | ``` |
| 130 | |||
| 124 | <YueDisplay> | 131 | <YueDisplay> |
| 125 | 132 | ||
| 126 | ```yue | 133 | ```yue |
| @@ -141,6 +148,7 @@ t = { | |||
| 141 | "hello world": true | 148 | "hello world": true |
| 142 | } | 149 | } |
| 143 | ``` | 150 | ``` |
| 151 | |||
| 144 | <YueDisplay> | 152 | <YueDisplay> |
| 145 | 153 | ||
| 146 | ```yue | 154 | ```yue |
| @@ -158,6 +166,7 @@ As tabelas Lua têm tanto uma parte array quanto uma parte hash, mas às vezes v | |||
| 158 | some_values = [1, 2, 3, 4] | 166 | some_values = [1, 2, 3, 4] |
| 159 | list_with_one_element = [1, ] | 167 | list_with_one_element = [1, ] |
| 160 | ``` | 168 | ``` |
| 169 | |||
| 161 | <YueDisplay> | 170 | <YueDisplay> |
| 162 | 171 | ||
| 163 | ```yue | 172 | ```yue |
diff --git a/doc/docs/pt-br/doc/functions/backcalls.md b/doc/docs/pt-br/doc/functions/backcalls.md index 924c10a..bc327a3 100644 --- a/doc/docs/pt-br/doc/functions/backcalls.md +++ b/doc/docs/pt-br/doc/functions/backcalls.md | |||
| @@ -6,6 +6,7 @@ Backcalls são usados para desaninhar callbacks. Eles são definidos usando seta | |||
| 6 | x <- f | 6 | x <- f |
| 7 | print "hello" .. x | 7 | print "hello" .. x |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -21,6 +22,7 @@ Funções seta "fat" também estão disponíveis. | |||
| 21 | <= f | 22 | <= f |
| 22 | print @value | 23 | print @value |
| 23 | ``` | 24 | ``` |
| 25 | |||
| 24 | <YueDisplay> | 26 | <YueDisplay> |
| 25 | 27 | ||
| 26 | ```yue | 28 | ```yue |
| @@ -36,6 +38,7 @@ Você pode especificar um placeholder para onde deseja que a função backcall v | |||
| 36 | (x) <- map _, [1, 2, 3] | 38 | (x) <- map _, [1, 2, 3] |
| 37 | x * 2 | 39 | x * 2 |
| 38 | ``` | 40 | ``` |
| 41 | |||
| 39 | <YueDisplay> | 42 | <YueDisplay> |
| 40 | 43 | ||
| 41 | ```yue | 44 | ```yue |
| @@ -55,6 +58,7 @@ result, msg = do | |||
| 55 | check info | 58 | check info |
| 56 | print result, msg | 59 | print result, msg |
| 57 | ``` | 60 | ``` |
| 61 | |||
| 58 | <YueDisplay> | 62 | <YueDisplay> |
| 59 | 63 | ||
| 60 | ```yue | 64 | ```yue |
diff --git a/doc/docs/pt-br/doc/functions/function-literals.md b/doc/docs/pt-br/doc/functions/function-literals.md index e63888f..590af71 100644 --- a/doc/docs/pt-br/doc/functions/function-literals.md +++ b/doc/docs/pt-br/doc/functions/function-literals.md | |||
| @@ -6,6 +6,7 @@ Todas as funções são criadas usando uma expressão de função. Uma função | |||
| 6 | my_function = -> | 6 | my_function = -> |
| 7 | my_function() -- chama a função vazia | 7 | my_function() -- chama a função vazia |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -24,6 +25,7 @@ func_b = -> | |||
| 24 | value = 100 | 25 | value = 100 |
| 25 | print "The value:", value | 26 | print "The value:", value |
| 26 | ``` | 27 | ``` |
| 28 | |||
| 27 | <YueDisplay> | 29 | <YueDisplay> |
| 28 | 30 | ||
| 29 | ```yue | 31 | ```yue |
| @@ -42,6 +44,7 @@ Se uma função não tem argumentos, ela pode ser chamada usando o operador !, e | |||
| 42 | func_a! | 44 | func_a! |
| 43 | func_b() | 45 | func_b() |
| 44 | ``` | 46 | ``` |
| 47 | |||
| 45 | <YueDisplay> | 48 | <YueDisplay> |
| 46 | 49 | ||
| 47 | ```yue | 50 | ```yue |
| @@ -56,6 +59,7 @@ Funções com argumentos podem ser criadas precedendo a seta com uma lista de no | |||
| 56 | ```yuescript | 59 | ```yuescript |
| 57 | sum = (x, y) -> print "sum", x + y | 60 | sum = (x, y) -> print "sum", x + y |
| 58 | ``` | 61 | ``` |
| 62 | |||
| 59 | <YueDisplay> | 63 | <YueDisplay> |
| 60 | 64 | ||
| 61 | ```yue | 65 | ```yue |
| @@ -72,6 +76,7 @@ print sum 10, 20 | |||
| 72 | 76 | ||
| 73 | a b c "a", "b", "c" | 77 | a b c "a", "b", "c" |
| 74 | ``` | 78 | ``` |
| 79 | |||
| 75 | <YueDisplay> | 80 | <YueDisplay> |
| 76 | 81 | ||
| 77 | ```yue | 82 | ```yue |
| @@ -88,6 +93,7 @@ Para evitar ambiguidade ao chamar funções, parênteses também podem ser usado | |||
| 88 | ```yuescript | 93 | ```yuescript |
| 89 | print "x:", sum(10, 20), "y:", sum(30, 40) | 94 | print "x:", sum(10, 20), "y:", sum(30, 40) |
| 90 | ``` | 95 | ``` |
| 96 | |||
| 91 | <YueDisplay> | 97 | <YueDisplay> |
| 92 | 98 | ||
| 93 | ```yue | 99 | ```yue |
| @@ -104,6 +110,7 @@ As funções convertem a última instrução em seu corpo em uma instrução de | |||
| 104 | sum = (x, y) -> x + y | 110 | sum = (x, y) -> x + y |
| 105 | print "The sum is ", sum 10, 20 | 111 | print "The sum is ", sum 10, 20 |
| 106 | ``` | 112 | ``` |
| 113 | |||
| 107 | <YueDisplay> | 114 | <YueDisplay> |
| 108 | 115 | ||
| 109 | ```yue | 116 | ```yue |
| @@ -118,6 +125,7 @@ E se você precisar retornar explicitamente, pode usar a palavra-chave return: | |||
| 118 | ```yuescript | 125 | ```yuescript |
| 119 | sum = (x, y) -> return x + y | 126 | sum = (x, y) -> return x + y |
| 120 | ``` | 127 | ``` |
| 128 | |||
| 121 | <YueDisplay> | 129 | <YueDisplay> |
| 122 | 130 | ||
| 123 | ```yue | 131 | ```yue |
| @@ -132,6 +140,7 @@ Assim como no Lua, as funções podem retornar múltiplos valores. A última ins | |||
| 132 | mystery = (x, y) -> x + y, x - y | 140 | mystery = (x, y) -> x + y, x - y |
| 133 | a, b = mystery 10, 20 | 141 | a, b = mystery 10, 20 |
| 134 | ``` | 142 | ``` |
| 143 | |||
| 135 | <YueDisplay> | 144 | <YueDisplay> |
| 136 | 145 | ||
| 137 | ```yue | 146 | ```yue |
| @@ -148,6 +157,7 @@ Como é um idioma em Lua enviar um objeto como primeiro argumento ao chamar um m | |||
| 148 | ```yuescript | 157 | ```yuescript |
| 149 | func = (num) => @value + num | 158 | func = (num) => @value + num |
| 150 | ``` | 159 | ``` |
| 160 | |||
| 151 | <YueDisplay> | 161 | <YueDisplay> |
| 152 | 162 | ||
| 153 | ```yue | 163 | ```yue |
| @@ -165,6 +175,7 @@ my_function = (name = "something", height = 100) -> | |||
| 165 | print "Hello I am", name | 175 | print "Hello I am", name |
| 166 | print "My height is", height | 176 | print "My height is", height |
| 167 | ``` | 177 | ``` |
| 178 | |||
| 168 | <YueDisplay> | 179 | <YueDisplay> |
| 169 | 180 | ||
| 170 | ```yue | 181 | ```yue |
| @@ -181,6 +192,7 @@ Uma expressão de valor padrão de argumento é avaliada no corpo da função na | |||
| 181 | some_args = (x = 100, y = x + 1000) -> | 192 | some_args = (x = 100, y = x + 1000) -> |
| 182 | print x + y | 193 | print x + y |
| 183 | ``` | 194 | ``` |
| 195 | |||
| 184 | <YueDisplay> | 196 | <YueDisplay> |
| 185 | 197 | ||
| 186 | ```yue | 198 | ```yue |
| @@ -202,6 +214,7 @@ b = x-10 | |||
| 202 | c = x -y | 214 | c = x -y |
| 203 | d = x- z | 215 | d = x- z |
| 204 | ``` | 216 | ``` |
| 217 | |||
| 205 | <YueDisplay> | 218 | <YueDisplay> |
| 206 | 219 | ||
| 207 | ```yue | 220 | ```yue |
| @@ -223,6 +236,7 @@ Quando há um espaço após uma variável e um literal de string, a chamada de f | |||
| 223 | x = func"hello" + 100 | 236 | x = func"hello" + 100 |
| 224 | y = func "hello" + 100 | 237 | y = func "hello" + 100 |
| 225 | ``` | 238 | ``` |
| 239 | |||
| 226 | <YueDisplay> | 240 | <YueDisplay> |
| 227 | 241 | ||
| 228 | ```yue | 242 | ```yue |
| @@ -247,6 +261,7 @@ cool_func 1, 2, | |||
| 247 | 5, 6, | 261 | 5, 6, |
| 248 | 7, 8 | 262 | 7, 8 |
| 249 | ``` | 263 | ``` |
| 264 | |||
| 250 | <YueDisplay> | 265 | <YueDisplay> |
| 251 | 266 | ||
| 252 | ```yue | 267 | ```yue |
| @@ -269,6 +284,7 @@ my_func 5, 6, 7, | |||
| 269 | 9, 1, 2, | 284 | 9, 1, 2, |
| 270 | 5, 4 | 285 | 5, 4 |
| 271 | ``` | 286 | ``` |
| 287 | |||
| 272 | <YueDisplay> | 288 | <YueDisplay> |
| 273 | 289 | ||
| 274 | ```yue | 290 | ```yue |
| @@ -289,6 +305,7 @@ x = [ | |||
| 289 | 8, 9, 10 | 305 | 8, 9, 10 |
| 290 | ] | 306 | ] |
| 291 | ``` | 307 | ``` |
| 308 | |||
| 292 | <YueDisplay> | 309 | <YueDisplay> |
| 293 | 310 | ||
| 294 | ```yue | 311 | ```yue |
| @@ -309,6 +326,7 @@ y = [ my_func 1, 2, 3, | |||
| 309 | 5, 6, 7 | 326 | 5, 6, 7 |
| 310 | ] | 327 | ] |
| 311 | ``` | 328 | ``` |
| 329 | |||
| 312 | <YueDisplay> | 330 | <YueDisplay> |
| 313 | 331 | ||
| 314 | ```yue | 332 | ```yue |
| @@ -335,6 +353,7 @@ if func 1, 2, 3, | |||
| 335 | print "hello" | 353 | print "hello" |
| 336 | print "I am inside if" | 354 | print "I am inside if" |
| 337 | ``` | 355 | ``` |
| 356 | |||
| 338 | <YueDisplay> | 357 | <YueDisplay> |
| 339 | 358 | ||
| 340 | ```yue | 359 | ```yue |
| @@ -357,9 +376,9 @@ if func 1, 2, 3, | |||
| 357 | 376 | ||
| 358 | YueScript agora suporta desestruturação de parâmetros de função quando o argumento é um objeto. Duas formas de literais de tabela de desestruturação estão disponíveis: | 377 | YueScript agora suporta desestruturação de parâmetros de função quando o argumento é um objeto. Duas formas de literais de tabela de desestruturação estão disponíveis: |
| 359 | 378 | ||
| 360 | * **Literais/parâmetros de objeto envolvidos em chaves**, permitindo valores padrão opcionais quando os campos estão ausentes (ex.: `{:a, :b}`, `{a: a1 = 123}`). | 379 | - **Literais/parâmetros de objeto envolvidos em chaves**, permitindo valores padrão opcionais quando os campos estão ausentes (ex.: `{:a, :b}`, `{a: a1 = 123}`). |
| 361 | 380 | ||
| 362 | * **Sintaxe de tabela simples não envolvida**, começando com uma sequência de ligações chave-valor ou abreviadas e continuando até outra expressão terminá-la (ex.: `:a, b: b1, :c`). Esta forma extrai múltiplos campos do mesmo objeto. | 381 | - **Sintaxe de tabela simples não envolvida**, começando com uma sequência de ligações chave-valor ou abreviadas e continuando até outra expressão terminá-la (ex.: `:a, b: b1, :c`). Esta forma extrai múltiplos campos do mesmo objeto. |
| 363 | 382 | ||
| 364 | ```yuescript | 383 | ```yuescript |
| 365 | f1 = (:a, :b, :c) -> | 384 | f1 = (:a, :b, :c) -> |
| @@ -373,6 +392,7 @@ f2 = ({a: a1 = 123, :b = 'abc'}, c = {}) -> | |||
| 373 | arg1 = {a: 0} | 392 | arg1 = {a: 0} |
| 374 | f2 arg1, arg2 | 393 | f2 arg1, arg2 |
| 375 | ``` | 394 | ``` |
| 395 | |||
| 376 | <YueDisplay> | 396 | <YueDisplay> |
| 377 | 397 | ||
| 378 | ```yue | 398 | ```yue |
| @@ -402,6 +422,7 @@ findFirstEven = (list): nil -> | |||
| 402 | if sub % 2 == 0 | 422 | if sub % 2 == 0 |
| 403 | return sub | 423 | return sub |
| 404 | ``` | 424 | ``` |
| 425 | |||
| 405 | <YueDisplay> | 426 | <YueDisplay> |
| 406 | 427 | ||
| 407 | ```yue | 428 | ```yue |
| @@ -426,6 +447,7 @@ findFirstEven = (list) -> | |||
| 426 | return sub | 447 | return sub |
| 427 | nil | 448 | nil |
| 428 | ``` | 449 | ``` |
| 450 | |||
| 429 | <YueDisplay> | 451 | <YueDisplay> |
| 430 | 452 | ||
| 431 | ```yue | 453 | ```yue |
| @@ -467,6 +489,7 @@ process = (...args) -> | |||
| 467 | 489 | ||
| 468 | process 1, nil, 3, nil, 5 | 490 | process 1, nil, 3, nil, 5 |
| 469 | ``` | 491 | ``` |
| 492 | |||
| 470 | <YueDisplay> | 493 | <YueDisplay> |
| 471 | 494 | ||
| 472 | ```yue | 495 | ```yue |
diff --git a/doc/docs/pt-br/doc/functions/function-stubs.md b/doc/docs/pt-br/doc/functions/function-stubs.md index d13f8ed..74b7821 100644 --- a/doc/docs/pt-br/doc/functions/function-stubs.md +++ b/doc/docs/pt-br/doc/functions/function-stubs.md | |||
| @@ -24,6 +24,7 @@ run_callback my_object.write | |||
| 24 | -- nos permite empacotar o objeto em uma nova função | 24 | -- nos permite empacotar o objeto em uma nova função |
| 25 | run_callback my_object\write | 25 | run_callback my_object\write |
| 26 | ``` | 26 | ``` |
| 27 | |||
| 27 | <YueDisplay> | 28 | <YueDisplay> |
| 28 | 29 | ||
| 29 | ```yue | 30 | ```yue |
diff --git a/doc/docs/pt-br/doc/getting-started/usage.md b/doc/docs/pt-br/doc/getting-started/usage.md index 7653838..055c6c2 100644 --- a/doc/docs/pt-br/doc/getting-started/usage.md +++ b/doc/docs/pt-br/doc/getting-started/usage.md | |||
| @@ -4,49 +4,51 @@ | |||
| 4 | 4 | ||
| 5 | Use o módulo YueScript em Lua: | 5 | Use o módulo YueScript em Lua: |
| 6 | 6 | ||
| 7 | * **Caso 1** | 7 | - **Caso 1** |
| 8 | 8 | ||
| 9 | Use require em "your_yuescript_entry.yue" no Lua. | 9 | Use require em "your_yuescript_entry.yue" no Lua. |
| 10 | ```Lua | 10 | |
| 11 | require("yue")("your_yuescript_entry") | 11 | ```Lua |
| 12 | ``` | 12 | require("yue")("your_yuescript_entry") |
| 13 | E esse código continua funcionando quando você compila "your_yuescript_entry.yue" para "your_yuescript_entry.lua" no mesmo caminho. Nos demais arquivos YueScript, use normalmente o **require** ou **import**. Os números de linha nas mensagens de erro também serão tratados corretamente. | 13 | ``` |
| 14 | 14 | ||
| 15 | * **Caso 2** | 15 | E esse código continua funcionando quando você compila "your_yuescript_entry.yue" para "your_yuescript_entry.lua" no mesmo caminho. Nos demais arquivos YueScript, use normalmente o **require** ou **import**. Os números de linha nas mensagens de erro também serão tratados corretamente. |
| 16 | 16 | ||
| 17 | Requerer o módulo YueScript e reescrever a mensagem manualmente. | 17 | - **Caso 2** |
| 18 | 18 | ||
| 19 | ```lua | 19 | Requerer o módulo YueScript e reescrever a mensagem manualmente. |
| 20 | local yue = require("yue") | 20 | |
| 21 | yue.insert_loader() | 21 | ```lua |
| 22 | local success, result = xpcall(function() | 22 | local yue = require("yue") |
| 23 | return require("yuescript_module_name") | 23 | yue.insert_loader() |
| 24 | end, function(err) | 24 | local success, result = xpcall(function() |
| 25 | return yue.traceback(err) | 25 | return require("yuescript_module_name") |
| 26 | end) | 26 | end, function(err) |
| 27 | ``` | 27 | return yue.traceback(err) |
| 28 | 28 | end) | |
| 29 | * **Caso 3** | 29 | ``` |
| 30 | 30 | ||
| 31 | Usar a função compiladora do YueScript em Lua. | 31 | - **Caso 3** |
| 32 | 32 | ||
| 33 | ```lua | 33 | Usar a função compiladora do YueScript em Lua. |
| 34 | local yue = require("yue") | 34 | |
| 35 | local codes, err, globals = yue.to_lua([[ | 35 | ```lua |
| 36 | f = -> | 36 | local yue = require("yue") |
| 37 | print "hello world" | 37 | local codes, err, globals = yue.to_lua([[ |
| 38 | f! | 38 | f = -> |
| 39 | ]],{ | 39 | print "hello world" |
| 40 | implicit_return_root = true, | 40 | f! |
| 41 | reserve_line_number = true, | 41 | ]],{ |
| 42 | lint_global = true, | 42 | implicit_return_root = true, |
| 43 | space_over_tab = false, | 43 | reserve_line_number = true, |
| 44 | options = { | 44 | lint_global = true, |
| 45 | target = "5.4", | 45 | space_over_tab = false, |
| 46 | path = "/script" | 46 | options = { |
| 47 | } | 47 | target = "5.4", |
| 48 | }) | 48 | path = "/script" |
| 49 | ``` | 49 | } |
| 50 | }) | ||
| 51 | ``` | ||
| 50 | 52 | ||
| 51 | ## Ferramenta YueScript | 53 | ## Ferramenta YueScript |
| 52 | 54 | ||
diff --git a/doc/docs/pt-br/doc/language-basics/attributes.md b/doc/docs/pt-br/doc/language-basics/attributes.md index 8e27f21..18bc585 100644 --- a/doc/docs/pt-br/doc/language-basics/attributes.md +++ b/doc/docs/pt-br/doc/language-basics/attributes.md | |||
| @@ -6,6 +6,7 @@ Suporte de sintaxe para atributos do Lua 5.4. E você ainda pode usar tanto a de | |||
| 6 | const a = 123 | 6 | const a = 123 |
| 7 | close _ = <close>: -> print "Fora do escopo." | 7 | close _ = <close>: -> print "Fora do escopo." |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -21,6 +22,7 @@ Você pode fazer desestruturação com variáveis atribuídas como constante. | |||
| 21 | const {:a, :b, c, d} = tb | 22 | const {:a, :b, c, d} = tb |
| 22 | -- a = 1 | 23 | -- a = 1 |
| 23 | ``` | 24 | ``` |
| 25 | |||
| 24 | <YueDisplay> | 26 | <YueDisplay> |
| 25 | 27 | ||
| 26 | ```yue | 28 | ```yue |
| @@ -36,6 +38,7 @@ Você também pode declarar uma variável global como `const`. | |||
| 36 | global const Constant = 123 | 38 | global const Constant = 123 |
| 37 | -- Constant = 1 | 39 | -- Constant = 1 |
| 38 | ``` | 40 | ``` |
| 41 | |||
| 39 | <YueDisplay> | 42 | <YueDisplay> |
| 40 | 43 | ||
| 41 | ```yue | 44 | ```yue |
diff --git a/doc/docs/pt-br/doc/language-basics/comment.md b/doc/docs/pt-br/doc/language-basics/comment.md index ed3102d..6316084 100644 --- a/doc/docs/pt-br/doc/language-basics/comment.md +++ b/doc/docs/pt-br/doc/language-basics/comment.md | |||
| @@ -12,6 +12,7 @@ Está OK. | |||
| 12 | 12 | ||
| 13 | func --[[port]] 3000, --[[ip]] "192.168.1.1" | 13 | func --[[port]] 3000, --[[ip]] "192.168.1.1" |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
diff --git a/doc/docs/pt-br/doc/language-basics/literals.md b/doc/docs/pt-br/doc/language-basics/literals.md index b32b73a..6db3f01 100644 --- a/doc/docs/pt-br/doc/language-basics/literals.md +++ b/doc/docs/pt-br/doc/language-basics/literals.md | |||
| @@ -12,6 +12,7 @@ some_string = "Aqui está uma string | |||
| 12 | -- Interpolação de string está disponível apenas em strings com aspas duplas. | 12 | -- Interpolação de string está disponível apenas em strings com aspas duplas. |
| 13 | print "Tenho #{math.random! * 100}% de certeza." | 13 | print "Tenho #{math.random! * 100}% de certeza." |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -34,6 +35,7 @@ integer = 1_000_000 | |||
| 34 | hex = 0xEF_BB_BF | 35 | hex = 0xEF_BB_BF |
| 35 | binary = 0B10011 | 36 | binary = 0B10011 |
| 36 | ``` | 37 | ``` |
| 38 | |||
| 37 | <YueDisplay> | 39 | <YueDisplay> |
| 38 | 40 | ||
| 39 | ```yue | 41 | ```yue |
| @@ -55,6 +57,7 @@ str = | | |||
| 55 | - item1 | 57 | - item1 |
| 56 | - #{expr} | 58 | - #{expr} |
| 57 | ``` | 59 | ``` |
| 60 | |||
| 58 | <YueDisplay> | 61 | <YueDisplay> |
| 59 | 62 | ||
| 60 | ```yue | 63 | ```yue |
| @@ -78,6 +81,7 @@ fn = -> | |||
| 78 | bar: baz | 81 | bar: baz |
| 79 | return str | 82 | return str |
| 80 | ``` | 83 | ``` |
| 84 | |||
| 81 | <YueDisplay> | 85 | <YueDisplay> |
| 82 | 86 | ||
| 83 | ```yue | 87 | ```yue |
| @@ -99,6 +103,7 @@ str = | | |||
| 99 | path: "C:\Program Files\App" | 103 | path: "C:\Program Files\App" |
| 100 | note: 'Ele disse: "#{Hello}!"' | 104 | note: 'Ele disse: "#{Hello}!"' |
| 101 | ``` | 105 | ``` |
| 106 | |||
| 102 | <YueDisplay> | 107 | <YueDisplay> |
| 103 | 108 | ||
| 104 | ```yue | 109 | ```yue |
diff --git a/doc/docs/pt-br/doc/language-basics/operator.md b/doc/docs/pt-br/doc/language-basics/operator.md index aba9c50..6371343 100644 --- a/doc/docs/pt-br/doc/language-basics/operator.md +++ b/doc/docs/pt-br/doc/language-basics/operator.md | |||
| @@ -6,6 +6,7 @@ Todos os operadores binários e unários do Lua estão disponíveis. Além disso | |||
| 6 | tb\func! if tb ~= nil | 6 | tb\func! if tb ~= nil |
| 7 | tb::func! if tb != nil | 7 | tb::func! if tb != nil |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -27,6 +28,7 @@ a = 5 | |||
| 27 | print 1 <= a <= 10 | 28 | print 1 <= a <= 10 |
| 28 | -- saída: true | 29 | -- saída: true |
| 29 | ``` | 30 | ``` |
| 31 | |||
| 30 | <YueDisplay> | 32 | <YueDisplay> |
| 31 | 33 | ||
| 32 | ```yue | 34 | ```yue |
| @@ -64,6 +66,7 @@ print v(1) > v(2) <= v(3) | |||
| 64 | false | 66 | false |
| 65 | ]] | 67 | ]] |
| 66 | ``` | 68 | ``` |
| 69 | |||
| 67 | <YueDisplay> | 70 | <YueDisplay> |
| 68 | 71 | ||
| 69 | ```yue | 72 | ```yue |
| @@ -101,6 +104,7 @@ O operador **[] =** é usado para anexar valores a tabelas. | |||
| 101 | tab = [] | 104 | tab = [] |
| 102 | tab[] = "Value" | 105 | tab[] = "Value" |
| 103 | ``` | 106 | ``` |
| 107 | |||
| 104 | <YueDisplay> | 108 | <YueDisplay> |
| 105 | 109 | ||
| 106 | ```yue | 110 | ```yue |
| @@ -118,6 +122,7 @@ tbB = [4, 5, 6] | |||
| 118 | tbA[] = ...tbB | 122 | tbA[] = ...tbB |
| 119 | -- tbA agora é [1, 2, 3, 4, 5, 6] | 123 | -- tbA agora é [1, 2, 3, 4, 5, 6] |
| 120 | ``` | 124 | ``` |
| 125 | |||
| 121 | <YueDisplay> | 126 | <YueDisplay> |
| 122 | 127 | ||
| 123 | ```yue | 128 | ```yue |
| @@ -149,6 +154,7 @@ a = {1, 2, 3, x: 1} | |||
| 149 | b = {4, 5, y: 1} | 154 | b = {4, 5, y: 1} |
| 150 | merge = {...a, ...b} | 155 | merge = {...a, ...b} |
| 151 | ``` | 156 | ``` |
| 157 | |||
| 152 | <YueDisplay> | 158 | <YueDisplay> |
| 153 | 159 | ||
| 154 | ```yue | 160 | ```yue |
| @@ -179,6 +185,7 @@ last = data.items[#] | |||
| 179 | second_last = data.items[#-1] | 185 | second_last = data.items[#-1] |
| 180 | data.items[#] = 1 | 186 | data.items[#] = 1 |
| 181 | ``` | 187 | ``` |
| 188 | |||
| 182 | <YueDisplay> | 189 | <YueDisplay> |
| 183 | 190 | ||
| 184 | ```yue | 191 | ```yue |
| @@ -212,6 +219,7 @@ print d.value | |||
| 212 | 219 | ||
| 213 | close _ = <close>: -> print "fora do escopo" | 220 | close _ = <close>: -> print "fora do escopo" |
| 214 | ``` | 221 | ``` |
| 222 | |||
| 215 | <YueDisplay> | 223 | <YueDisplay> |
| 216 | 224 | ||
| 217 | ```yue | 225 | ```yue |
| @@ -245,6 +253,7 @@ print tb.value | |||
| 245 | tb.<> = __index: {item: "hello"} | 253 | tb.<> = __index: {item: "hello"} |
| 246 | print tb.item | 254 | print tb.item |
| 247 | ``` | 255 | ``` |
| 256 | |||
| 248 | <YueDisplay> | 257 | <YueDisplay> |
| 249 | 258 | ||
| 250 | ```yue | 259 | ```yue |
| @@ -266,6 +275,7 @@ Desestruture a metatable com chave de metamétodo cercada por **<>**. | |||
| 266 | {item, :new, :<close>, <index>: getter} = tb | 275 | {item, :new, :<close>, <index>: getter} = tb |
| 267 | print item, new, close, getter | 276 | print item, new, close, getter |
| 268 | ``` | 277 | ``` |
| 278 | |||
| 269 | <YueDisplay> | 279 | <YueDisplay> |
| 270 | 280 | ||
| 271 | ```yue | 281 | ```yue |
| @@ -293,6 +303,7 @@ with? io.open "test.txt", "w" | |||
| 293 | \write "hello" | 303 | \write "hello" |
| 294 | \close! | 304 | \close! |
| 295 | ``` | 305 | ``` |
| 306 | |||
| 296 | <YueDisplay> | 307 | <YueDisplay> |
| 297 | 308 | ||
| 298 | ```yue | 309 | ```yue |
| @@ -329,6 +340,7 @@ readFile "example.txt" | |||
| 329 | |> render | 340 | |> render |
| 330 | 341 | ||
| 331 | ``` | 342 | ``` |
| 343 | |||
| 332 | <YueDisplay> | 344 | <YueDisplay> |
| 333 | 345 | ||
| 334 | ```yue | 346 | ```yue |
| @@ -349,6 +361,7 @@ readFile "example.txt" | |||
| 349 | ## Coalescência de nil | 361 | ## Coalescência de nil |
| 350 | 362 | ||
| 351 | O operador de coalescência de nil **??** retorna o valor do operando esquerdo se não for **nil**; caso contrário, avalia o operando direito e retorna seu resultado. O operador **??** não avalia seu operando direito se o operando esquerdo avaliar para não-nil. | 363 | O operador de coalescência de nil **??** retorna o valor do operando esquerdo se não for **nil**; caso contrário, avalia o operando direito e retorna seu resultado. O operador **??** não avalia seu operando direito se o operando esquerdo avaliar para não-nil. |
| 364 | |||
| 352 | ```yuescript | 365 | ```yuescript |
| 353 | local a, b, c, d | 366 | local a, b, c, d |
| 354 | a = b ?? c ?? d | 367 | a = b ?? c ?? d |
| @@ -356,6 +369,7 @@ func a ?? {} | |||
| 356 | 369 | ||
| 357 | a ??= false | 370 | a ??= false |
| 358 | ``` | 371 | ``` |
| 372 | |||
| 359 | <YueDisplay> | 373 | <YueDisplay> |
| 360 | 374 | ||
| 361 | ```yue | 375 | ```yue |
| @@ -413,6 +427,7 @@ tb = | |||
| 413 | tb: { } | 427 | tb: { } |
| 414 | 428 | ||
| 415 | ``` | 429 | ``` |
| 430 | |||
| 416 | <YueDisplay> | 431 | <YueDisplay> |
| 417 | 432 | ||
| 418 | ```yue | 433 | ```yue |
diff --git a/doc/docs/pt-br/doc/language-basics/whitespace.md b/doc/docs/pt-br/doc/language-basics/whitespace.md index df844f9..bad11d1 100644 --- a/doc/docs/pt-br/doc/language-basics/whitespace.md +++ b/doc/docs/pt-br/doc/language-basics/whitespace.md | |||
| @@ -9,6 +9,7 @@ Uma instrução normalmente termina em uma quebra de linha. Você também pode u | |||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | a = 1; b = 2; print a + b | 10 | a = 1; b = 2; print a + b |
| 11 | ``` | 11 | ``` |
| 12 | |||
| 12 | <YueDisplay> | 13 | <YueDisplay> |
| 13 | 14 | ||
| 14 | ```yue | 15 | ```yue |
| @@ -29,6 +30,7 @@ Rx.Observable | |||
| 29 | \map (value) -> value .. '!' | 30 | \map (value) -> value .. '!' |
| 30 | \subscribe print | 31 | \subscribe print |
| 31 | ``` | 32 | ``` |
| 33 | |||
| 32 | <YueDisplay> | 34 | <YueDisplay> |
| 33 | 35 | ||
| 34 | ```yue | 36 | ```yue |
diff --git a/doc/docs/pt-br/doc/objects/object-oriented-programming.md b/doc/docs/pt-br/doc/objects/object-oriented-programming.md index 3d5f061..54a559a 100644 --- a/doc/docs/pt-br/doc/objects/object-oriented-programming.md +++ b/doc/docs/pt-br/doc/objects/object-oriented-programming.md | |||
| @@ -15,6 +15,7 @@ class Inventory | |||
| 15 | else | 15 | else |
| 16 | @items[name] = 1 | 16 | @items[name] = 1 |
| 17 | ``` | 17 | ``` |
| 18 | |||
| 18 | <YueDisplay> | 19 | <YueDisplay> |
| 19 | 20 | ||
| 20 | ```yue | 21 | ```yue |
| @@ -46,6 +47,7 @@ inv = Inventory! | |||
| 46 | inv\add_item "t-shirt" | 47 | inv\add_item "t-shirt" |
| 47 | inv\add_item "pants" | 48 | inv\add_item "pants" |
| 48 | ``` | 49 | ``` |
| 50 | |||
| 49 | <YueDisplay> | 51 | <YueDisplay> |
| 50 | 52 | ||
| 51 | ```yue | 53 | ```yue |
| @@ -77,6 +79,7 @@ b\give_item "shirt" | |||
| 77 | -- vai imprimir tanto pants quanto shirt | 79 | -- vai imprimir tanto pants quanto shirt |
| 78 | print item for item in *a.clothes | 80 | print item for item in *a.clothes |
| 79 | ``` | 81 | ``` |
| 82 | |||
| 80 | <YueDisplay> | 83 | <YueDisplay> |
| 81 | 84 | ||
| 82 | ```yue | 85 | ```yue |
| @@ -104,6 +107,7 @@ class Person | |||
| 104 | new: => | 107 | new: => |
| 105 | @clothes = [] | 108 | @clothes = [] |
| 106 | ``` | 109 | ``` |
| 110 | |||
| 107 | <YueDisplay> | 111 | <YueDisplay> |
| 108 | 112 | ||
| 109 | ```yue | 113 | ```yue |
| @@ -125,6 +129,7 @@ class BackPack extends Inventory | |||
| 125 | if #@items > size then error "backpack is full" | 129 | if #@items > size then error "backpack is full" |
| 126 | super name | 130 | super name |
| 127 | ``` | 131 | ``` |
| 132 | |||
| 128 | <YueDisplay> | 133 | <YueDisplay> |
| 129 | 134 | ||
| 130 | ```yue | 135 | ```yue |
| @@ -141,7 +146,7 @@ Aqui estendemos nossa classe Inventory e limitamos a quantidade de itens que ela | |||
| 141 | 146 | ||
| 142 | Neste exemplo, não definimos um construtor na subclasse, então o construtor da classe pai é chamado quando criamos uma nova instância. Se definirmos um construtor, podemos usar o método super para chamar o construtor pai. | 147 | Neste exemplo, não definimos um construtor na subclasse, então o construtor da classe pai é chamado quando criamos uma nova instância. Se definirmos um construtor, podemos usar o método super para chamar o construtor pai. |
| 143 | 148 | ||
| 144 | Sempre que uma classe herda de outra, ela envia uma mensagem à classe pai chamando o método __inherited na classe pai se ele existir. A função recebe dois argumentos: a classe que está sendo herdada e a classe filha. | 149 | Sempre que uma classe herda de outra, ela envia uma mensagem à classe pai chamando o método \_\_inherited na classe pai se ele existir. A função recebe dois argumentos: a classe que está sendo herdada e a classe filha. |
| 145 | 150 | ||
| 146 | ```yuescript | 151 | ```yuescript |
| 147 | class Shelf | 152 | class Shelf |
| @@ -151,6 +156,7 @@ class Shelf | |||
| 151 | -- vai imprimir: Shelf was inherited by Cupboard | 156 | -- vai imprimir: Shelf was inherited by Cupboard |
| 152 | class Cupboard extends Shelf | 157 | class Cupboard extends Shelf |
| 153 | ``` | 158 | ``` |
| 159 | |||
| 154 | <YueDisplay> | 160 | <YueDisplay> |
| 155 | 161 | ||
| 156 | ```yue | 162 | ```yue |
| @@ -189,6 +195,7 @@ class MyClass extends ParentClass | |||
| 189 | -- super como valor é igual à classe pai: | 195 | -- super como valor é igual à classe pai: |
| 190 | assert super == ParentClass | 196 | assert super == ParentClass |
| 191 | ``` | 197 | ``` |
| 198 | |||
| 192 | <YueDisplay> | 199 | <YueDisplay> |
| 193 | 200 | ||
| 194 | ```yue | 201 | ```yue |
| @@ -209,7 +216,7 @@ class MyClass extends ParentClass | |||
| 209 | 216 | ||
| 210 | ## Tipos | 217 | ## Tipos |
| 211 | 218 | ||
| 212 | Cada instância de uma classe carrega seu tipo consigo. Isso é armazenado na propriedade especial __class. Esta propriedade contém o objeto da classe. O objeto da classe é o que chamamos para construir uma nova instância. Também podemos indexar o objeto da classe para recuperar métodos e propriedades da classe. | 219 | Cada instância de uma classe carrega seu tipo consigo. Isso é armazenado na propriedade especial \_\_class. Esta propriedade contém o objeto da classe. O objeto da classe é o que chamamos para construir uma nova instância. Também podemos indexar o objeto da classe para recuperar métodos e propriedades da classe. |
| 213 | 220 | ||
| 214 | ```yuescript | 221 | ```yuescript |
| 215 | b = BackPack! | 222 | b = BackPack! |
| @@ -217,6 +224,7 @@ assert b.__class == BackPack | |||
| 217 | 224 | ||
| 218 | print BackPack.size -- imprime 10 | 225 | print BackPack.size -- imprime 10 |
| 219 | ``` | 226 | ``` |
| 227 | |||
| 220 | <YueDisplay> | 228 | <YueDisplay> |
| 221 | 229 | ||
| 222 | ```yue | 230 | ```yue |
| @@ -238,15 +246,16 @@ Uma classe é composta por duas tabelas. A própria tabela da classe e a tabela | |||
| 238 | 246 | ||
| 239 | A metatable do objeto da classe lê propriedades da base se não existirem no objeto da classe. Isso significa que podemos acessar funções e propriedades diretamente da classe. | 247 | A metatable do objeto da classe lê propriedades da base se não existirem no objeto da classe. Isso significa que podemos acessar funções e propriedades diretamente da classe. |
| 240 | 248 | ||
| 241 | É importante notar que atribuir ao objeto da classe não atribui à base, então não é uma forma válida de adicionar novos métodos às instâncias. Em vez disso, a base deve ser alterada explicitamente. Veja o campo __base abaixo. | 249 | É importante notar que atribuir ao objeto da classe não atribui à base, então não é uma forma válida de adicionar novos métodos às instâncias. Em vez disso, a base deve ser alterada explicitamente. Veja o campo \_\_base abaixo. |
| 242 | 250 | ||
| 243 | O objeto da classe tem algumas propriedades especiais: | 251 | O objeto da classe tem algumas propriedades especiais: |
| 244 | 252 | ||
| 245 | O nome da classe quando foi declarada é armazenado como string no campo __name do objeto da classe. | 253 | O nome da classe quando foi declarada é armazenado como string no campo \_\_name do objeto da classe. |
| 246 | 254 | ||
| 247 | ```yuescript | 255 | ```yuescript |
| 248 | print BackPack.__name -- imprime Backpack | 256 | print BackPack.__name -- imprime Backpack |
| 249 | ``` | 257 | ``` |
| 258 | |||
| 250 | <YueDisplay> | 259 | <YueDisplay> |
| 251 | 260 | ||
| 252 | ```yue | 261 | ```yue |
| @@ -255,9 +264,9 @@ print BackPack.__name -- imprime Backpack | |||
| 255 | 264 | ||
| 256 | </YueDisplay> | 265 | </YueDisplay> |
| 257 | 266 | ||
| 258 | O objeto base é armazenado em __base. Podemos modificar esta tabela para adicionar funcionalidade a instâncias que já foram criadas e às que ainda serão criadas. | 267 | O objeto base é armazenado em \_\_base. Podemos modificar esta tabela para adicionar funcionalidade a instâncias que já foram criadas e às que ainda serão criadas. |
| 259 | 268 | ||
| 260 | Se a classe estende de algo, o objeto da classe pai é armazenado em __parent. | 269 | Se a classe estende de algo, o objeto da classe pai é armazenado em \_\_parent. |
| 261 | 270 | ||
| 262 | ## Variáveis de classe | 271 | ## Variáveis de classe |
| 263 | 272 | ||
| @@ -272,6 +281,7 @@ Things\some_func! | |||
| 272 | -- variáveis de classe não visíveis em instâncias | 281 | -- variáveis de classe não visíveis em instâncias |
| 273 | assert Things().some_func == nil | 282 | assert Things().some_func == nil |
| 274 | ``` | 283 | ``` |
| 284 | |||
| 275 | <YueDisplay> | 285 | <YueDisplay> |
| 276 | 286 | ||
| 277 | ```yue | 287 | ```yue |
| @@ -286,7 +296,7 @@ assert Things().some_func == nil | |||
| 286 | 296 | ||
| 287 | </YueDisplay> | 297 | </YueDisplay> |
| 288 | 298 | ||
| 289 | Em expressões, podemos usar @@ para acessar um valor armazenado no __class de self. Assim, @@hello é abreviação para self.__class.hello. | 299 | Em expressões, podemos usar @@ para acessar um valor armazenado no **class de self. Assim, @@hello é abreviação para self.**class.hello. |
| 290 | 300 | ||
| 291 | ```yuescript | 301 | ```yuescript |
| 292 | class Counter | 302 | class Counter |
| @@ -300,6 +310,7 @@ Counter! | |||
| 300 | 310 | ||
| 301 | print Counter.count -- imprime 2 | 311 | print Counter.count -- imprime 2 |
| 302 | ``` | 312 | ``` |
| 313 | |||
| 303 | <YueDisplay> | 314 | <YueDisplay> |
| 304 | 315 | ||
| 305 | ```yue | 316 | ```yue |
| @@ -322,6 +333,7 @@ A semântica de chamada de @@ é semelhante a @. Chamar um nome @@ passará a cl | |||
| 322 | ```yuescript | 333 | ```yuescript |
| 323 | @@hello 1,2,3,4 | 334 | @@hello 1,2,3,4 |
| 324 | ``` | 335 | ``` |
| 336 | |||
| 325 | <YueDisplay> | 337 | <YueDisplay> |
| 326 | 338 | ||
| 327 | ```yue | 339 | ```yue |
| @@ -340,6 +352,7 @@ Aqui está uma forma alternativa de criar variável de classe comparada ao descr | |||
| 340 | class Things | 352 | class Things |
| 341 | @class_var = "hello world" | 353 | @class_var = "hello world" |
| 342 | ``` | 354 | ``` |
| 355 | |||
| 343 | <YueDisplay> | 356 | <YueDisplay> |
| 344 | 357 | ||
| 345 | ```yue | 358 | ```yue |
| @@ -361,6 +374,7 @@ class MoreThings | |||
| 361 | some_method: => | 374 | some_method: => |
| 362 | log "hello world: " .. secret | 375 | log "hello world: " .. secret |
| 363 | ``` | 376 | ``` |
| 377 | |||
| 364 | <YueDisplay> | 378 | <YueDisplay> |
| 365 | 379 | ||
| 366 | ```yue | 380 | ```yue |
| @@ -376,14 +390,15 @@ class MoreThings | |||
| 376 | 390 | ||
| 377 | ## Valores @ e @@ | 391 | ## Valores @ e @@ |
| 378 | 392 | ||
| 379 | Quando @ e @@ são prefixados na frente de um nome, eles representam, respectivamente, esse nome acessado em self e self.__class. | 393 | Quando @ e @@ são prefixados na frente de um nome, eles representam, respectivamente, esse nome acessado em self e self.\_\_class. |
| 380 | 394 | ||
| 381 | Se forem usados sozinhos, são aliases para self e self.__class. | 395 | Se forem usados sozinhos, são aliases para self e self.\_\_class. |
| 382 | 396 | ||
| 383 | ```yuescript | 397 | ```yuescript |
| 384 | assert @ == self | 398 | assert @ == self |
| 385 | assert @@ == self.__class | 399 | assert @@ == self.__class |
| 386 | ``` | 400 | ``` |
| 401 | |||
| 387 | <YueDisplay> | 402 | <YueDisplay> |
| 388 | 403 | ||
| 389 | ```yue | 404 | ```yue |
| @@ -398,6 +413,7 @@ Por exemplo, uma forma rápida de criar uma nova instância da mesma classe a pa | |||
| 398 | ```yuescript | 413 | ```yuescript |
| 399 | some_instance_method = (...) => @@ ... | 414 | some_instance_method = (...) => @@ ... |
| 400 | ``` | 415 | ``` |
| 416 | |||
| 401 | <YueDisplay> | 417 | <YueDisplay> |
| 402 | 418 | ||
| 403 | ```yue | 419 | ```yue |
| @@ -423,6 +439,7 @@ class Something | |||
| 423 | @@biz = biz | 439 | @@biz = biz |
| 424 | @@baz = baz | 440 | @@baz = baz |
| 425 | ``` | 441 | ``` |
| 442 | |||
| 426 | <YueDisplay> | 443 | <YueDisplay> |
| 427 | 444 | ||
| 428 | ```yue | 445 | ```yue |
| @@ -448,6 +465,7 @@ new = (@fieldA, @fieldB) => @ | |||
| 448 | obj = new {}, 123, "abc" | 465 | obj = new {}, 123, "abc" |
| 449 | print obj | 466 | print obj |
| 450 | ``` | 467 | ``` |
| 468 | |||
| 451 | <YueDisplay> | 469 | <YueDisplay> |
| 452 | 470 | ||
| 453 | ```yue | 471 | ```yue |
| @@ -467,6 +485,7 @@ x = class Bucket | |||
| 467 | drops: 0 | 485 | drops: 0 |
| 468 | add_drop: => @drops += 1 | 486 | add_drop: => @drops += 1 |
| 469 | ``` | 487 | ``` |
| 488 | |||
| 470 | <YueDisplay> | 489 | <YueDisplay> |
| 471 | 490 | ||
| 472 | ```yue | 491 | ```yue |
| @@ -479,7 +498,7 @@ x = class Bucket | |||
| 479 | 498 | ||
| 480 | ## Classes anônimas | 499 | ## Classes anônimas |
| 481 | 500 | ||
| 482 | O nome pode ser omitido ao declarar uma classe. O atributo __name será nil, a menos que a expressão da classe esteja em uma atribuição. O nome no lado esquerdo da atribuição é usado em vez de nil. | 501 | O nome pode ser omitido ao declarar uma classe. O atributo \_\_name será nil, a menos que a expressão da classe esteja em uma atribuição. O nome no lado esquerdo da atribuição é usado em vez de nil. |
| 483 | 502 | ||
| 484 | ```yuescript | 503 | ```yuescript |
| 485 | BigBucket = class extends Bucket | 504 | BigBucket = class extends Bucket |
| @@ -487,6 +506,7 @@ BigBucket = class extends Bucket | |||
| 487 | 506 | ||
| 488 | assert Bucket.__name == "BigBucket" | 507 | assert Bucket.__name == "BigBucket" |
| 489 | ``` | 508 | ``` |
| 509 | |||
| 490 | <YueDisplay> | 510 | <YueDisplay> |
| 491 | 511 | ||
| 492 | ```yue | 512 | ```yue |
| @@ -503,6 +523,7 @@ Você pode até omitir o corpo, significando que pode escrever uma classe anôni | |||
| 503 | ```yuescript | 523 | ```yuescript |
| 504 | x = class | 524 | x = class |
| 505 | ``` | 525 | ``` |
| 526 | |||
| 506 | <YueDisplay> | 527 | <YueDisplay> |
| 507 | 528 | ||
| 508 | ```yue | 529 | ```yue |
| @@ -532,6 +553,7 @@ y\func! | |||
| 532 | 553 | ||
| 533 | assert y.__class.__parent ~= X -- X não é pai de Y | 554 | assert y.__class.__parent ~= X -- X não é pai de Y |
| 534 | ``` | 555 | ``` |
| 556 | |||
| 535 | <YueDisplay> | 557 | <YueDisplay> |
| 536 | 558 | ||
| 537 | ```yue | 559 | ```yue |
diff --git a/doc/docs/pt-br/doc/objects/with-statement.md b/doc/docs/pt-br/doc/objects/with-statement.md index 6495d09..e5a56e5 100644 --- a/doc/docs/pt-br/doc/objects/with-statement.md +++ b/doc/docs/pt-br/doc/objects/with-statement.md | |||
| @@ -15,6 +15,7 @@ with Person! | |||
| 15 | \save! | 15 | \save! |
| 16 | print .name | 16 | print .name |
| 17 | ``` | 17 | ``` |
| 18 | |||
| 18 | <YueDisplay> | 19 | <YueDisplay> |
| 19 | 20 | ||
| 20 | ```yue | 21 | ```yue |
| @@ -33,6 +34,7 @@ A instrução with também pode ser usada como expressão que retorna o valor ao | |||
| 33 | file = with File "favorite_foods.txt" | 34 | file = with File "favorite_foods.txt" |
| 34 | \set_encoding "utf8" | 35 | \set_encoding "utf8" |
| 35 | ``` | 36 | ``` |
| 37 | |||
| 36 | <YueDisplay> | 38 | <YueDisplay> |
| 37 | 39 | ||
| 38 | ```yue | 40 | ```yue |
| @@ -52,6 +54,7 @@ create_person = (name, relatives) -> | |||
| 52 | 54 | ||
| 53 | me = create_person "Leaf", [dad, mother, sister] | 55 | me = create_person "Leaf", [dad, mother, sister] |
| 54 | ``` | 56 | ``` |
| 57 | |||
| 55 | <YueDisplay> | 58 | <YueDisplay> |
| 56 | 59 | ||
| 57 | ```yue | 60 | ```yue |
| @@ -74,6 +77,7 @@ with str := "Hello" | |||
| 74 | print "original:", str | 77 | print "original:", str |
| 75 | print "upper:", \upper! | 78 | print "upper:", \upper! |
| 76 | ``` | 79 | ``` |
| 80 | |||
| 77 | <YueDisplay> | 81 | <YueDisplay> |
| 78 | 82 | ||
| 79 | ```yue | 83 | ```yue |
| @@ -95,6 +99,7 @@ with tb | |||
| 95 | ["key-name"] = value | 99 | ["key-name"] = value |
| 96 | [] = "abc" -- anexando a "tb" | 100 | [] = "abc" -- anexando a "tb" |
| 97 | ``` | 101 | ``` |
| 102 | |||
| 98 | <YueDisplay> | 103 | <YueDisplay> |
| 99 | 104 | ||
| 100 | ```yue | 105 | ```yue |
| @@ -115,6 +120,7 @@ with tb | |||
| 115 | with? obj | 120 | with? obj |
| 116 | print obj.name | 121 | print obj.name |
| 117 | ``` | 122 | ``` |
| 123 | |||
| 118 | <YueDisplay> | 124 | <YueDisplay> |
| 119 | 125 | ||
| 120 | ```yue | 126 | ```yue |
diff --git a/doc/docs/pt-br/doc/reference/the-yuescript-library.md b/doc/docs/pt-br/doc/reference/the-yuescript-library.md index 2a65ffb..7775cd5 100644 --- a/doc/docs/pt-br/doc/reference/the-yuescript-library.md +++ b/doc/docs/pt-br/doc/reference/the-yuescript-library.md | |||
| @@ -17,6 +17,7 @@ A biblioteca da linguagem YueScript. | |||
| 17 | A versão do YueScript. | 17 | A versão do YueScript. |
| 18 | 18 | ||
| 19 | **Assinatura:** | 19 | **Assinatura:** |
| 20 | |||
| 20 | ```lua | 21 | ```lua |
| 21 | version: string | 22 | version: string |
| 22 | ``` | 23 | ``` |
| @@ -30,6 +31,7 @@ version: string | |||
| 30 | O separador de arquivos da plataforma atual. | 31 | O separador de arquivos da plataforma atual. |
| 31 | 32 | ||
| 32 | **Assinatura:** | 33 | **Assinatura:** |
| 34 | |||
| 33 | ```lua | 35 | ```lua |
| 34 | dirsep: string | 36 | dirsep: string |
| 35 | ``` | 37 | ``` |
| @@ -43,6 +45,7 @@ dirsep: string | |||
| 43 | O cache de código de módulo compilado. | 45 | O cache de código de módulo compilado. |
| 44 | 46 | ||
| 45 | **Assinatura:** | 47 | **Assinatura:** |
| 48 | |||
| 46 | ```lua | 49 | ```lua |
| 47 | yue_compiled: {string: string} | 50 | yue_compiled: {string: string} |
| 48 | ``` | 51 | ``` |
| @@ -56,6 +59,7 @@ yue_compiled: {string: string} | |||
| 56 | A função de compilação do YueScript. Compila o código YueScript para código Lua. | 59 | A função de compilação do YueScript. Compila o código YueScript para código Lua. |
| 57 | 60 | ||
| 58 | **Assinatura:** | 61 | **Assinatura:** |
| 62 | |||
| 59 | ```lua | 63 | ```lua |
| 60 | to_lua: function(code: string, config?: Config): | 64 | to_lua: function(code: string, config?: Config): |
| 61 | --[[codes]] string | nil, | 65 | --[[codes]] string | nil, |
| @@ -65,17 +69,17 @@ to_lua: function(code: string, config?: Config): | |||
| 65 | 69 | ||
| 66 | **Parâmetros:** | 70 | **Parâmetros:** |
| 67 | 71 | ||
| 68 | | Parâmetro | Tipo | Descrição | | 72 | | Parâmetro | Tipo | Descrição | |
| 69 | | --- | --- | --- | | 73 | | --------- | ------ | ----------------------------------- | |
| 70 | | code | string | O código YueScript. | | 74 | | code | string | O código YueScript. | |
| 71 | | config | Config | [Opcional] As opções do compilador. | | 75 | | config | Config | [Opcional] As opções do compilador. | |
| 72 | 76 | ||
| 73 | **Retorna:** | 77 | **Retorna:** |
| 74 | 78 | ||
| 75 | | Tipo de Retorno | Descrição | | 79 | | Tipo de Retorno | Descrição | |
| 76 | | --- | --- | | 80 | | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | |
| 77 | | string \| nil | O código Lua compilado, ou nil se a compilação falhou. | | 81 | | string \| nil | O código Lua compilado, ou nil se a compilação falhou. | |
| 78 | | string \| nil | A mensagem de erro, ou nil se a compilação foi bem-sucedida. | | 82 | | string \| nil | A mensagem de erro, ou nil se a compilação foi bem-sucedida. | |
| 79 | | {{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. | | 83 | | {{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. | |
| 80 | 84 | ||
| 81 | ### file_exist | 85 | ### file_exist |
| @@ -87,21 +91,22 @@ to_lua: function(code: string, config?: Config): | |||
| 87 | Função de verificação de existência do arquivo fonte. Pode ser sobrescrita para personalizar o comportamento. | 91 | Função de verificação de existência do arquivo fonte. Pode ser sobrescrita para personalizar o comportamento. |
| 88 | 92 | ||
| 89 | **Assinatura:** | 93 | **Assinatura:** |
| 94 | |||
| 90 | ```lua | 95 | ```lua |
| 91 | file_exist: function(filename: string): boolean | 96 | file_exist: function(filename: string): boolean |
| 92 | ``` | 97 | ``` |
| 93 | 98 | ||
| 94 | **Parâmetros:** | 99 | **Parâmetros:** |
| 95 | 100 | ||
| 96 | | Parâmetro | Tipo | Descrição | | 101 | | Parâmetro | Tipo | Descrição | |
| 97 | | --- | --- | --- | | 102 | | --------- | ------ | ------------------ | |
| 98 | | filename | string | O nome do arquivo. | | 103 | | filename | string | O nome do arquivo. | |
| 99 | 104 | ||
| 100 | **Retorna:** | 105 | **Retorna:** |
| 101 | 106 | ||
| 102 | | Tipo de Retorno | Descrição | | 107 | | Tipo de Retorno | Descrição | |
| 103 | | --- | --- | | 108 | | --------------- | -------------------- | |
| 104 | | boolean | Se o arquivo existe. | | 109 | | boolean | Se o arquivo existe. | |
| 105 | 110 | ||
| 106 | ### read_file | 111 | ### read_file |
| 107 | 112 | ||
| @@ -112,21 +117,22 @@ file_exist: function(filename: string): boolean | |||
| 112 | Função de leitura do arquivo fonte. Pode ser sobrescrita para personalizar o comportamento. | 117 | Função de leitura do arquivo fonte. Pode ser sobrescrita para personalizar o comportamento. |
| 113 | 118 | ||
| 114 | **Assinatura:** | 119 | **Assinatura:** |
| 120 | |||
| 115 | ```lua | 121 | ```lua |
| 116 | read_file: function(filename: string): string | 122 | read_file: function(filename: string): string |
| 117 | ``` | 123 | ``` |
| 118 | 124 | ||
| 119 | **Parâmetros:** | 125 | **Parâmetros:** |
| 120 | 126 | ||
| 121 | | Parâmetro | Tipo | Descrição | | 127 | | Parâmetro | Tipo | Descrição | |
| 122 | | --- | --- | --- | | 128 | | --------- | ------ | ------------------ | |
| 123 | | filename | string | O nome do arquivo. | | 129 | | filename | string | O nome do arquivo. | |
| 124 | 130 | ||
| 125 | **Retorna:** | 131 | **Retorna:** |
| 126 | 132 | ||
| 127 | | Tipo de Retorno | Descrição | | 133 | | Tipo de Retorno | Descrição | |
| 128 | | --- | --- | | 134 | | --------------- | ---------------------- | |
| 129 | | string | O conteúdo do arquivo. | | 135 | | string | O conteúdo do arquivo. | |
| 130 | 136 | ||
| 131 | ### insert_loader | 137 | ### insert_loader |
| 132 | 138 | ||
| @@ -137,21 +143,22 @@ read_file: function(filename: string): string | |||
| 137 | Insere o carregador YueScript nos carregadores de pacote (searchers). | 143 | Insere o carregador YueScript nos carregadores de pacote (searchers). |
| 138 | 144 | ||
| 139 | **Assinatura:** | 145 | **Assinatura:** |
| 146 | |||
| 140 | ```lua | 147 | ```lua |
| 141 | insert_loader: function(pos?: integer): boolean | 148 | insert_loader: function(pos?: integer): boolean |
| 142 | ``` | 149 | ``` |
| 143 | 150 | ||
| 144 | **Parâmetros:** | 151 | **Parâmetros:** |
| 145 | 152 | ||
| 146 | | Parâmetro | Tipo | Descrição | | 153 | | Parâmetro | Tipo | Descrição | |
| 147 | | --- | --- | --- | | 154 | | --------- | ------- | ----------------------------------------------------------- | |
| 148 | | pos | integer | [Opcional] A posição para inserir o carregador. Padrão é 3. | | 155 | | pos | integer | [Opcional] A posição para inserir o carregador. Padrão é 3. | |
| 149 | 156 | ||
| 150 | **Retorna:** | 157 | **Retorna:** |
| 151 | 158 | ||
| 152 | | Tipo de Retorno | Descrição | | 159 | | Tipo de Retorno | Descrição | |
| 153 | | --- | --- | | 160 | | --------------- | -------------------------------------------------------------------------------------- | |
| 154 | | boolean | Se o carregador foi inserido com sucesso. Falhará se o carregador já estiver inserido. | | 161 | | boolean | Se o carregador foi inserido com sucesso. Falhará se o carregador já estiver inserido. | |
| 155 | 162 | ||
| 156 | ### remove_loader | 163 | ### remove_loader |
| 157 | 164 | ||
| @@ -162,15 +169,16 @@ insert_loader: function(pos?: integer): boolean | |||
| 162 | Remove o carregador YueScript dos carregadores de pacote (searchers). | 169 | Remove o carregador YueScript dos carregadores de pacote (searchers). |
| 163 | 170 | ||
| 164 | **Assinatura:** | 171 | **Assinatura:** |
| 172 | |||
| 165 | ```lua | 173 | ```lua |
| 166 | remove_loader: function(): boolean | 174 | remove_loader: function(): boolean |
| 167 | ``` | 175 | ``` |
| 168 | 176 | ||
| 169 | **Retorna:** | 177 | **Retorna:** |
| 170 | 178 | ||
| 171 | | Tipo de Retorno | Descrição | | 179 | | Tipo de Retorno | Descrição | |
| 172 | | --- | --- | | 180 | | --------------- | --------------------------------------------------------------------------------------- | |
| 173 | | boolean | Se o carregador foi removido com sucesso. Falhará se o carregador não estiver inserido. | | 181 | | boolean | Se o carregador foi removido com sucesso. Falhará se o carregador não estiver inserido. | |
| 174 | 182 | ||
| 175 | ### loadstring | 183 | ### loadstring |
| 176 | 184 | ||
| @@ -181,6 +189,7 @@ remove_loader: function(): boolean | |||
| 181 | Carrega código YueScript de uma string em uma função. | 189 | Carrega código YueScript de uma string em uma função. |
| 182 | 190 | ||
| 183 | **Assinatura:** | 191 | **Assinatura:** |
| 192 | |||
| 184 | ```lua | 193 | ```lua |
| 185 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): | 194 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): |
| 186 | --[[loaded function]] nil | function(...: any): (any...), | 195 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -189,19 +198,19 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 189 | 198 | ||
| 190 | **Parâmetros:** | 199 | **Parâmetros:** |
| 191 | 200 | ||
| 192 | | Parâmetro | Tipo | Descrição | | 201 | | Parâmetro | Tipo | Descrição | |
| 193 | | --- | --- | --- | | 202 | | --------- | ------ | ----------------------------------- | |
| 194 | | input | string | O código YueScript. | | 203 | | input | string | O código YueScript. | |
| 195 | | chunkname | string | O nome do chunk de código. | | 204 | | chunkname | string | O nome do chunk de código. | |
| 196 | | env | table | A tabela de ambiente. | | 205 | | env | table | A tabela de ambiente. | |
| 197 | | config | Config | [Opcional] As opções do compilador. | | 206 | | config | Config | [Opcional] As opções do compilador. | |
| 198 | 207 | ||
| 199 | **Retorna:** | 208 | **Retorna:** |
| 200 | 209 | ||
| 201 | | Tipo de Retorno | Descrição | | 210 | | Tipo de Retorno | Descrição | |
| 202 | | --- | --- | | 211 | | --------------- | -------------------------------------------------------------- | |
| 203 | | function \| nil | A função carregada, ou nil se o carregamento falhou. | | 212 | | function \| nil | A função carregada, ou nil se o carregamento falhou. | |
| 204 | | string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | | 213 | | string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | |
| 205 | 214 | ||
| 206 | ### loadstring | 215 | ### loadstring |
| 207 | 216 | ||
| @@ -212,6 +221,7 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 212 | Carrega código YueScript de uma string em uma função. | 221 | Carrega código YueScript de uma string em uma função. |
| 213 | 222 | ||
| 214 | **Assinatura:** | 223 | **Assinatura:** |
| 224 | |||
| 215 | ```lua | 225 | ```lua |
| 216 | loadstring: function(input: string, chunkname: string, config?: Config): | 226 | loadstring: function(input: string, chunkname: string, config?: Config): |
| 217 | --[[loaded function]] nil | function(...: any): (any...), | 227 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -220,18 +230,18 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 220 | 230 | ||
| 221 | **Parâmetros:** | 231 | **Parâmetros:** |
| 222 | 232 | ||
| 223 | | Parâmetro | Tipo | Descrição | | 233 | | Parâmetro | Tipo | Descrição | |
| 224 | | --- | --- | --- | | 234 | | --------- | ------ | ----------------------------------- | |
| 225 | | input | string | O código YueScript. | | 235 | | input | string | O código YueScript. | |
| 226 | | chunkname | string | O nome do chunk de código. | | 236 | | chunkname | string | O nome do chunk de código. | |
| 227 | | config | Config | [Opcional] As opções do compilador. | | 237 | | config | Config | [Opcional] As opções do compilador. | |
| 228 | 238 | ||
| 229 | **Retorna:** | 239 | **Retorna:** |
| 230 | 240 | ||
| 231 | | Tipo de Retorno | Descrição | | 241 | | Tipo de Retorno | Descrição | |
| 232 | | --- | --- | | 242 | | --------------- | -------------------------------------------------------------- | |
| 233 | | function \| nil | A função carregada, ou nil se o carregamento falhou. | | 243 | | function \| nil | A função carregada, ou nil se o carregamento falhou. | |
| 234 | | string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | | 244 | | string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | |
| 235 | 245 | ||
| 236 | ### loadstring | 246 | ### loadstring |
| 237 | 247 | ||
| @@ -242,6 +252,7 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 242 | Carrega código YueScript de uma string em uma função. | 252 | Carrega código YueScript de uma string em uma função. |
| 243 | 253 | ||
| 244 | **Assinatura:** | 254 | **Assinatura:** |
| 255 | |||
| 245 | ```lua | 256 | ```lua |
| 246 | loadstring: function(input: string, config?: Config): | 257 | loadstring: function(input: string, config?: Config): |
| 247 | --[[loaded function]] nil | function(...: any): (any...), | 258 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -250,17 +261,17 @@ loadstring: function(input: string, config?: Config): | |||
| 250 | 261 | ||
| 251 | **Parâmetros:** | 262 | **Parâmetros:** |
| 252 | 263 | ||
| 253 | | Parâmetro | Tipo | Descrição | | 264 | | Parâmetro | Tipo | Descrição | |
| 254 | | --- | --- | --- | | 265 | | --------- | ------ | ----------------------------------- | |
| 255 | | input | string | O código YueScript. | | 266 | | input | string | O código YueScript. | |
| 256 | | config | Config | [Opcional] As opções do compilador. | | 267 | | config | Config | [Opcional] As opções do compilador. | |
| 257 | 268 | ||
| 258 | **Retorna:** | 269 | **Retorna:** |
| 259 | 270 | ||
| 260 | | Tipo de Retorno | Descrição | | 271 | | Tipo de Retorno | Descrição | |
| 261 | | --- | --- | | 272 | | --------------- | -------------------------------------------------------------- | |
| 262 | | function \| nil | A função carregada, ou nil se o carregamento falhou. | | 273 | | function \| nil | A função carregada, ou nil se o carregamento falhou. | |
| 263 | | string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | | 274 | | string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | |
| 264 | 275 | ||
| 265 | ### loadfile | 276 | ### loadfile |
| 266 | 277 | ||
| @@ -271,6 +282,7 @@ loadstring: function(input: string, config?: Config): | |||
| 271 | Carrega código YueScript de um arquivo em uma função. | 282 | Carrega código YueScript de um arquivo em uma função. |
| 272 | 283 | ||
| 273 | **Assinatura:** | 284 | **Assinatura:** |
| 285 | |||
| 274 | ```lua | 286 | ```lua |
| 275 | loadfile: function(filename: string, env: table, config?: Config): | 287 | loadfile: function(filename: string, env: table, config?: Config): |
| 276 | nil | function(...: any): (any...), | 288 | nil | function(...: any): (any...), |
| @@ -279,18 +291,18 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 279 | 291 | ||
| 280 | **Parâmetros:** | 292 | **Parâmetros:** |
| 281 | 293 | ||
| 282 | | Parâmetro | Tipo | Descrição | | 294 | | Parâmetro | Tipo | Descrição | |
| 283 | | --- | --- | --- | | 295 | | --------- | ------ | ----------------------------------- | |
| 284 | | filename | string | O nome do arquivo. | | 296 | | filename | string | O nome do arquivo. | |
| 285 | | env | table | A tabela de ambiente. | | 297 | | env | table | A tabela de ambiente. | |
| 286 | | config | Config | [Opcional] As opções do compilador. | | 298 | | config | Config | [Opcional] As opções do compilador. | |
| 287 | 299 | ||
| 288 | **Retorna:** | 300 | **Retorna:** |
| 289 | 301 | ||
| 290 | | Tipo de Retorno | Descrição | | 302 | | Tipo de Retorno | Descrição | |
| 291 | | --- | --- | | 303 | | --------------- | -------------------------------------------------------------- | |
| 292 | | function \| nil | A função carregada, ou nil se o carregamento falhou. | | 304 | | function \| nil | A função carregada, ou nil se o carregamento falhou. | |
| 293 | | string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | | 305 | | string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | |
| 294 | 306 | ||
| 295 | ### loadfile | 307 | ### loadfile |
| 296 | 308 | ||
| @@ -301,6 +313,7 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 301 | Carrega código YueScript de um arquivo em uma função. | 313 | Carrega código YueScript de um arquivo em uma função. |
| 302 | 314 | ||
| 303 | **Assinatura:** | 315 | **Assinatura:** |
| 316 | |||
| 304 | ```lua | 317 | ```lua |
| 305 | loadfile: function(filename: string, config?: Config): | 318 | loadfile: function(filename: string, config?: Config): |
| 306 | nil | function(...: any): (any...), | 319 | nil | function(...: any): (any...), |
| @@ -309,17 +322,17 @@ loadfile: function(filename: string, config?: Config): | |||
| 309 | 322 | ||
| 310 | **Parâmetros:** | 323 | **Parâmetros:** |
| 311 | 324 | ||
| 312 | | Parâmetro | Tipo | Descrição | | 325 | | Parâmetro | Tipo | Descrição | |
| 313 | | --- | --- | --- | | 326 | | --------- | ------ | ----------------------------------- | |
| 314 | | filename | string | O nome do arquivo. | | 327 | | filename | string | O nome do arquivo. | |
| 315 | | config | Config | [Opcional] As opções do compilador. | | 328 | | config | Config | [Opcional] As opções do compilador. | |
| 316 | 329 | ||
| 317 | **Retorna:** | 330 | **Retorna:** |
| 318 | 331 | ||
| 319 | | Tipo de Retorno | Descrição | | 332 | | Tipo de Retorno | Descrição | |
| 320 | | --- | --- | | 333 | | --------------- | -------------------------------------------------------------- | |
| 321 | | function \| nil | A função carregada, ou nil se o carregamento falhou. | | 334 | | function \| nil | A função carregada, ou nil se o carregamento falhou. | |
| 322 | | string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | | 335 | | string \| nil | A mensagem de erro, ou nil se o carregamento foi bem-sucedido. | |
| 323 | 336 | ||
| 324 | ### dofile | 337 | ### dofile |
| 325 | 338 | ||
| @@ -330,23 +343,24 @@ loadfile: function(filename: string, config?: Config): | |||
| 330 | Carrega código YueScript de um arquivo em uma função e o executa. | 343 | Carrega código YueScript de um arquivo em uma função e o executa. |
| 331 | 344 | ||
| 332 | **Assinatura:** | 345 | **Assinatura:** |
| 346 | |||
| 333 | ```lua | 347 | ```lua |
| 334 | dofile: function(filename: string, env: table, config?: Config): any... | 348 | dofile: function(filename: string, env: table, config?: Config): any... |
| 335 | ``` | 349 | ``` |
| 336 | 350 | ||
| 337 | **Parâmetros:** | 351 | **Parâmetros:** |
| 338 | 352 | ||
| 339 | | Parâmetro | Tipo | Descrição | | 353 | | Parâmetro | Tipo | Descrição | |
| 340 | | --- | --- | --- | | 354 | | --------- | ------ | ----------------------------------- | |
| 341 | | filename | string | O nome do arquivo. | | 355 | | filename | string | O nome do arquivo. | |
| 342 | | env | table | A tabela de ambiente. | | 356 | | env | table | A tabela de ambiente. | |
| 343 | | config | Config | [Opcional] As opções do compilador. | | 357 | | config | Config | [Opcional] As opções do compilador. | |
| 344 | 358 | ||
| 345 | **Retorna:** | 359 | **Retorna:** |
| 346 | 360 | ||
| 347 | | Tipo de Retorno | Descrição | | 361 | | Tipo de Retorno | Descrição | |
| 348 | | --- | --- | | 362 | | --------------- | ------------------------------------------ | |
| 349 | | any... | Os valores de retorno da função carregada. | | 363 | | any... | Os valores de retorno da função carregada. | |
| 350 | 364 | ||
| 351 | ### dofile | 365 | ### dofile |
| 352 | 366 | ||
| @@ -357,22 +371,23 @@ dofile: function(filename: string, env: table, config?: Config): any... | |||
| 357 | Carrega código YueScript de um arquivo em uma função e o executa. | 371 | Carrega código YueScript de um arquivo em uma função e o executa. |
| 358 | 372 | ||
| 359 | **Assinatura:** | 373 | **Assinatura:** |
| 374 | |||
| 360 | ```lua | 375 | ```lua |
| 361 | dofile: function(filename: string, config?: Config): any... | 376 | dofile: function(filename: string, config?: Config): any... |
| 362 | ``` | 377 | ``` |
| 363 | 378 | ||
| 364 | **Parâmetros:** | 379 | **Parâmetros:** |
| 365 | 380 | ||
| 366 | | Parâmetro | Tipo | Descrição | | 381 | | Parâmetro | Tipo | Descrição | |
| 367 | | --- | --- | --- | | 382 | | --------- | ------ | ----------------------------------- | |
| 368 | | filename | string | O nome do arquivo. | | 383 | | filename | string | O nome do arquivo. | |
| 369 | | config | Config | [Opcional] As opções do compilador. | | 384 | | config | Config | [Opcional] As opções do compilador. | |
| 370 | 385 | ||
| 371 | **Retorna:** | 386 | **Retorna:** |
| 372 | 387 | ||
| 373 | | Tipo de Retorno | Descrição | | 388 | | Tipo de Retorno | Descrição | |
| 374 | | --- | --- | | 389 | | --------------- | ------------------------------------------ | |
| 375 | | any... | Os valores de retorno da função carregada. | | 390 | | any... | Os valores de retorno da função carregada. | |
| 376 | 391 | ||
| 377 | ### find_modulepath | 392 | ### find_modulepath |
| 378 | 393 | ||
| @@ -383,21 +398,22 @@ dofile: function(filename: string, config?: Config): any... | |||
| 383 | Resolve o nome do módulo YueScript para o caminho do arquivo. | 398 | Resolve o nome do módulo YueScript para o caminho do arquivo. |
| 384 | 399 | ||
| 385 | **Assinatura:** | 400 | **Assinatura:** |
| 401 | |||
| 386 | ```lua | 402 | ```lua |
| 387 | find_modulepath: function(name: string): string | 403 | find_modulepath: function(name: string): string |
| 388 | ``` | 404 | ``` |
| 389 | 405 | ||
| 390 | **Parâmetros:** | 406 | **Parâmetros:** |
| 391 | 407 | ||
| 392 | | Parâmetro | Tipo | Descrição | | 408 | | Parâmetro | Tipo | Descrição | |
| 393 | | --- | --- | --- | | 409 | | --------- | ------ | ----------------- | |
| 394 | | name | string | O nome do módulo. | | 410 | | name | string | O nome do módulo. | |
| 395 | 411 | ||
| 396 | **Retorna:** | 412 | **Retorna:** |
| 397 | 413 | ||
| 398 | | Tipo de Retorno | Descrição | | 414 | | Tipo de Retorno | Descrição | |
| 399 | | --- | --- | | 415 | | --------------- | --------------------- | |
| 400 | | string | O caminho do arquivo. | | 416 | | string | O caminho do arquivo. | |
| 401 | 417 | ||
| 402 | ### pcall | 418 | ### pcall |
| 403 | 419 | ||
| @@ -410,22 +426,23 @@ Captura quaisquer erros e retorna um código de status e resultados ou objeto de | |||
| 410 | Reescreve o número da linha do erro para o número da linha original no código YueScript quando ocorrem erros. | 426 | Reescreve o número da linha do erro para o número da linha original no código YueScript quando ocorrem erros. |
| 411 | 427 | ||
| 412 | **Assinatura:** | 428 | **Assinatura:** |
| 429 | |||
| 413 | ```lua | 430 | ```lua |
| 414 | pcall: function(f: function, ...: any): boolean, any... | 431 | pcall: function(f: function, ...: any): boolean, any... |
| 415 | ``` | 432 | ``` |
| 416 | 433 | ||
| 417 | **Parâmetros:** | 434 | **Parâmetros:** |
| 418 | 435 | ||
| 419 | | Parâmetro | Tipo | Descrição | | 436 | | Parâmetro | Tipo | Descrição | |
| 420 | | --- | --- | --- | | 437 | | --------- | -------- | ---------------------------------- | |
| 421 | | f | function | A função a chamar. | | 438 | | f | function | A função a chamar. | |
| 422 | | ... | any | Argumentos a passar para a função. | | 439 | | ... | any | Argumentos a passar para a função. | |
| 423 | 440 | ||
| 424 | **Retorna:** | 441 | **Retorna:** |
| 425 | 442 | ||
| 426 | | Tipo de Retorno | Descrição | | 443 | | Tipo de Retorno | Descrição | |
| 427 | | --- | --- | | 444 | | --------------- | ---------------------------------------------------------- | |
| 428 | | boolean, ... | Código de status e resultados da função ou objeto de erro. | | 445 | | boolean, ... | Código de status e resultados da função ou objeto de erro. | |
| 429 | 446 | ||
| 430 | ### require | 447 | ### require |
| 431 | 448 | ||
| @@ -437,21 +454,22 @@ Carrega um módulo dado. Pode ser um módulo Lua ou um módulo YueScript. | |||
| 437 | 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. | 454 | 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. |
| 438 | 455 | ||
| 439 | **Assinatura:** | 456 | **Assinatura:** |
| 457 | |||
| 440 | ```lua | 458 | ```lua |
| 441 | require: function(name: string): any... | 459 | require: function(name: string): any... |
| 442 | ``` | 460 | ``` |
| 443 | 461 | ||
| 444 | **Parâmetros:** | 462 | **Parâmetros:** |
| 445 | 463 | ||
| 446 | | Parâmetro | Tipo | Descrição | | 464 | | Parâmetro | Tipo | Descrição | |
| 447 | | --- | --- | --- | | 465 | | --------- | ------ | ---------------------------- | |
| 448 | | modname | string | O nome do módulo a carregar. | | 466 | | modname | string | O nome do módulo a carregar. | |
| 449 | 467 | ||
| 450 | **Retorna:** | 468 | **Retorna:** |
| 451 | 469 | ||
| 452 | | Tipo de Retorno | Descrição | | 470 | | Tipo de Retorno | Descrição | |
| 453 | | --- | --- | | 471 | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 454 | | 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. | | 472 | | 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. | |
| 455 | 473 | ||
| 456 | ### p | 474 | ### p |
| 457 | 475 | ||
| @@ -462,15 +480,16 @@ require: function(name: string): any... | |||
| 462 | Inspeciona as estruturas dos valores passados e imprime representações em string. | 480 | Inspeciona as estruturas dos valores passados e imprime representações em string. |
| 463 | 481 | ||
| 464 | **Assinatura:** | 482 | **Assinatura:** |
| 483 | |||
| 465 | ```lua | 484 | ```lua |
| 466 | p: function(...: any) | 485 | p: function(...: any) |
| 467 | ``` | 486 | ``` |
| 468 | 487 | ||
| 469 | **Parâmetros:** | 488 | **Parâmetros:** |
| 470 | 489 | ||
| 471 | | Parâmetro | Tipo | Descrição | | 490 | | Parâmetro | Tipo | Descrição | |
| 472 | | --- | --- | --- | | 491 | | --------- | ---- | ------------------------- | |
| 473 | | ... | any | Os valores a inspecionar. | | 492 | | ... | any | Os valores a inspecionar. | |
| 474 | 493 | ||
| 475 | ### options | 494 | ### options |
| 476 | 495 | ||
| @@ -481,6 +500,7 @@ p: function(...: any) | |||
| 481 | As opções atuais do compilador. | 500 | As opções atuais do compilador. |
| 482 | 501 | ||
| 483 | **Assinatura:** | 502 | **Assinatura:** |
| 503 | |||
| 484 | ```lua | 504 | ```lua |
| 485 | options: Config.Options | 505 | options: Config.Options |
| 486 | ``` | 506 | ``` |
| @@ -494,21 +514,22 @@ options: Config.Options | |||
| 494 | 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. | 514 | 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. |
| 495 | 515 | ||
| 496 | **Assinatura:** | 516 | **Assinatura:** |
| 517 | |||
| 497 | ```lua | 518 | ```lua |
| 498 | traceback: function(message: string): string | 519 | traceback: function(message: string): string |
| 499 | ``` | 520 | ``` |
| 500 | 521 | ||
| 501 | **Parâmetros:** | 522 | **Parâmetros:** |
| 502 | 523 | ||
| 503 | | Parâmetro | Tipo | Descrição | | 524 | | Parâmetro | Tipo | Descrição | |
| 504 | | --- | --- | --- | | 525 | | --------- | ------ | ------------------------ | |
| 505 | | message | string | A mensagem de traceback. | | 526 | | message | string | A mensagem de traceback. | |
| 506 | 527 | ||
| 507 | **Retorna:** | 528 | **Retorna:** |
| 508 | 529 | ||
| 509 | | Tipo de Retorno | Descrição | | 530 | | Tipo de Retorno | Descrição | |
| 510 | | --- | --- | | 531 | | --------------- | ---------------------------------- | |
| 511 | | string | A mensagem de traceback reescrita. | | 532 | | string | A mensagem de traceback reescrita. | |
| 512 | 533 | ||
| 513 | ### is_ast | 534 | ### is_ast |
| 514 | 535 | ||
| @@ -519,22 +540,23 @@ traceback: function(message: string): string | |||
| 519 | Verifica se o código corresponde ao AST especificado. | 540 | Verifica se o código corresponde ao AST especificado. |
| 520 | 541 | ||
| 521 | **Assinatura:** | 542 | **Assinatura:** |
| 543 | |||
| 522 | ```lua | 544 | ```lua |
| 523 | is_ast: function(astName: string, code: string): boolean | 545 | is_ast: function(astName: string, code: string): boolean |
| 524 | ``` | 546 | ``` |
| 525 | 547 | ||
| 526 | **Parâmetros:** | 548 | **Parâmetros:** |
| 527 | 549 | ||
| 528 | | Parâmetro | Tipo | Descrição | | 550 | | Parâmetro | Tipo | Descrição | |
| 529 | | --- | --- | --- | | 551 | | --------- | ------ | -------------- | |
| 530 | | astName | string | O nome do AST. | | 552 | | astName | string | O nome do AST. | |
| 531 | | code | string | O código. | | 553 | | code | string | O código. | |
| 532 | 554 | ||
| 533 | **Retorna:** | 555 | **Retorna:** |
| 534 | 556 | ||
| 535 | | Tipo de Retorno | Descrição | | 557 | | Tipo de Retorno | Descrição | |
| 536 | | --- | --- | | 558 | | --------------- | ------------------------------- | |
| 537 | | boolean | Se o código corresponde ao AST. | | 559 | | boolean | Se o código corresponde ao AST. | |
| 538 | 560 | ||
| 539 | ### AST | 561 | ### AST |
| 540 | 562 | ||
| @@ -545,6 +567,7 @@ is_ast: function(astName: string, code: string): boolean | |||
| 545 | A definição do tipo AST com nome, linha, coluna e subnós. | 567 | A definição do tipo AST com nome, linha, coluna e subnós. |
| 546 | 568 | ||
| 547 | **Assinatura:** | 569 | **Assinatura:** |
| 570 | |||
| 548 | ```lua | 571 | ```lua |
| 549 | type AST = {string, integer, integer, any} | 572 | type AST = {string, integer, integer, any} |
| 550 | ``` | 573 | ``` |
| @@ -558,6 +581,7 @@ type AST = {string, integer, integer, any} | |||
| 558 | Converte o código para o AST. | 581 | Converte o código para o AST. |
| 559 | 582 | ||
| 560 | **Assinatura:** | 583 | **Assinatura:** |
| 584 | |||
| 561 | ```lua | 585 | ```lua |
| 562 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): | 586 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): |
| 563 | --[[AST]] AST | nil, | 587 | --[[AST]] AST | nil, |
| @@ -566,19 +590,19 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 566 | 590 | ||
| 567 | **Parâmetros:** | 591 | **Parâmetros:** |
| 568 | 592 | ||
| 569 | | Parâmetro | Tipo | Descrição | | 593 | | Parâmetro | Tipo | Descrição | |
| 570 | | --- | --- | --- | | 594 | | -------------- | ------- | ------------------------------------------------------------------------------------------------------ | |
| 571 | | code | string | O código. | | 595 | | code | string | O código. | |
| 572 | | flattenLevel | integer | [Opcional] O nível de achatamento. Nível mais alto significa mais achatamento. Padrão é 0. Máximo é 2. | | 596 | | flattenLevel | integer | [Opcional] O nível de achatamento. Nível mais alto significa mais achatamento. Padrão é 0. Máximo é 2. | |
| 573 | | astName | string | [Opcional] O nome do AST. Padrão é "File". | | 597 | | astName | string | [Opcional] O nome do AST. Padrão é "File". | |
| 574 | | reserveComment | boolean | [Opcional] Se deve preservar os comentários originais. Padrão é false. | | 598 | | reserveComment | boolean | [Opcional] Se deve preservar os comentários originais. Padrão é false. | |
| 575 | 599 | ||
| 576 | **Retorna:** | 600 | **Retorna:** |
| 577 | 601 | ||
| 578 | | Tipo de Retorno | Descrição | | 602 | | Tipo de Retorno | Descrição | |
| 579 | | --- | --- | | 603 | | --------------- | ----------------------------------------------------------- | |
| 580 | | AST \| nil | O AST, ou nil se a conversão falhou. | | 604 | | AST \| nil | O AST, ou nil se a conversão falhou. | |
| 581 | | string \| nil | A mensagem de erro, ou nil se a conversão foi bem-sucedida. | | 605 | | string \| nil | A mensagem de erro, ou nil se a conversão foi bem-sucedida. | |
| 582 | 606 | ||
| 583 | ### format | 607 | ### format |
| 584 | 608 | ||
| @@ -589,25 +613,26 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 589 | Formata o código YueScript. | 613 | Formata o código YueScript. |
| 590 | 614 | ||
| 591 | **Assinatura:** | 615 | **Assinatura:** |
| 616 | |||
| 592 | ```lua | 617 | ```lua |
| 593 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string | 618 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string |
| 594 | ``` | 619 | ``` |
| 595 | 620 | ||
| 596 | **Parâmetros:** | 621 | **Parâmetros:** |
| 597 | 622 | ||
| 598 | | Parâmetro | Tipo | Descrição | | 623 | | Parâmetro | Tipo | Descrição | |
| 599 | | --- | --- | --- | | 624 | | -------------- | ------- | --------------------------------------------------------------------- | |
| 600 | | code | string | O código. | | 625 | | code | string | O código. | |
| 601 | | tabSize | integer | [Opcional] O tamanho da tabulação. Padrão é 4. | | 626 | | tabSize | integer | [Opcional] O tamanho da tabulação. Padrão é 4. | |
| 602 | | reserveComment | boolean | [Opcional] Se deve preservar os comentários originais. Padrão é true. | | 627 | | reserveComment | boolean | [Opcional] Se deve preservar os comentários originais. Padrão é true. | |
| 603 | 628 | ||
| 604 | **Retorna:** | 629 | **Retorna:** |
| 605 | 630 | ||
| 606 | | Tipo de Retorno | Descrição | | 631 | | Tipo de Retorno | Descrição | |
| 607 | | --- | --- | | 632 | | --------------- | ------------------- | |
| 608 | | string | O código formatado. | | 633 | | string | O código formatado. | |
| 609 | 634 | ||
| 610 | ### __call | 635 | ### \_\_call |
| 611 | 636 | ||
| 612 | **Tipo:** Metamétodo. | 637 | **Tipo:** Metamétodo. |
| 613 | 638 | ||
| @@ -617,21 +642,22 @@ Requer o módulo YueScript. | |||
| 617 | Reescreve o número da linha do erro para o número da linha original no código YueScript quando o carregamento falha. | 642 | Reescreve o número da linha do erro para o número da linha original no código YueScript quando o carregamento falha. |
| 618 | 643 | ||
| 619 | **Assinatura:** | 644 | **Assinatura:** |
| 645 | |||
| 620 | ```lua | 646 | ```lua |
| 621 | metamethod __call: function(self: yue, module: string): any... | 647 | metamethod __call: function(self: yue, module: string): any... |
| 622 | ``` | 648 | ``` |
| 623 | 649 | ||
| 624 | **Parâmetros:** | 650 | **Parâmetros:** |
| 625 | 651 | ||
| 626 | | Parâmetro | Tipo | Descrição | | 652 | | Parâmetro | Tipo | Descrição | |
| 627 | | --- | --- | --- | | 653 | | --------- | ------ | ----------------- | |
| 628 | | module | string | O nome do módulo. | | 654 | | module | string | O nome do módulo. | |
| 629 | 655 | ||
| 630 | **Retorna:** | 656 | **Retorna:** |
| 631 | 657 | ||
| 632 | | Tipo de Retorno | Descrição | | 658 | | Tipo de Retorno | Descrição | |
| 633 | | --- | --- | | 659 | | --------------- | ------------------ | |
| 634 | | any | O valor do módulo. | | 660 | | any | O valor do módulo. | |
| 635 | 661 | ||
| 636 | ## Config | 662 | ## Config |
| 637 | 663 | ||
| @@ -648,6 +674,7 @@ As opções de compilação do compilador. | |||
| 648 | Se o compilador deve coletar as variáveis globais que aparecem no código. | 674 | Se o compilador deve coletar as variáveis globais que aparecem no código. |
| 649 | 675 | ||
| 650 | **Assinatura:** | 676 | **Assinatura:** |
| 677 | |||
| 651 | ```lua | 678 | ```lua |
| 652 | lint_global: boolean | 679 | lint_global: boolean |
| 653 | ``` | 680 | ``` |
| @@ -661,6 +688,7 @@ lint_global: boolean | |||
| 661 | Se o compilador deve fazer retorno implícito para o bloco de código raiz. | 688 | Se o compilador deve fazer retorno implícito para o bloco de código raiz. |
| 662 | 689 | ||
| 663 | **Assinatura:** | 690 | **Assinatura:** |
| 691 | |||
| 664 | ```lua | 692 | ```lua |
| 665 | implicit_return_root: boolean | 693 | implicit_return_root: boolean |
| 666 | ``` | 694 | ``` |
| @@ -674,6 +702,7 @@ implicit_return_root: boolean | |||
| 674 | Se o compilador deve preservar o número da linha original no código compilado. | 702 | Se o compilador deve preservar o número da linha original no código compilado. |
| 675 | 703 | ||
| 676 | **Assinatura:** | 704 | **Assinatura:** |
| 705 | |||
| 677 | ```lua | 706 | ```lua |
| 678 | reserve_line_number: boolean | 707 | reserve_line_number: boolean |
| 679 | ``` | 708 | ``` |
| @@ -687,6 +716,7 @@ reserve_line_number: boolean | |||
| 687 | Se o compilador deve preservar os comentários originais no código compilado. | 716 | Se o compilador deve preservar os comentários originais no código compilado. |
| 688 | 717 | ||
| 689 | **Assinatura:** | 718 | **Assinatura:** |
| 719 | |||
| 690 | ```lua | 720 | ```lua |
| 691 | reserve_comment: boolean | 721 | reserve_comment: boolean |
| 692 | ``` | 722 | ``` |
| @@ -700,6 +730,7 @@ reserve_comment: boolean | |||
| 700 | Se o compilador deve usar o caractere de espaço em vez do caractere de tabulação no código compilado. | 730 | Se o compilador deve usar o caractere de espaço em vez do caractere de tabulação no código compilado. |
| 701 | 731 | ||
| 702 | **Assinatura:** | 732 | **Assinatura:** |
| 733 | |||
| 703 | ```lua | 734 | ```lua |
| 704 | space_over_tab: boolean | 735 | space_over_tab: boolean |
| 705 | ``` | 736 | ``` |
| @@ -713,6 +744,7 @@ space_over_tab: boolean | |||
| 713 | 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. | 744 | 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. |
| 714 | 745 | ||
| 715 | **Assinatura:** | 746 | **Assinatura:** |
| 747 | |||
| 716 | ```lua | 748 | ```lua |
| 717 | same_module: boolean | 749 | same_module: boolean |
| 718 | ``` | 750 | ``` |
| @@ -726,6 +758,7 @@ same_module: boolean | |||
| 726 | Se a mensagem de erro do compilador deve incluir o deslocamento do número da linha. Apenas para uso interno. | 758 | Se a mensagem de erro do compilador deve incluir o deslocamento do número da linha. Apenas para uso interno. |
| 727 | 759 | ||
| 728 | **Assinatura:** | 760 | **Assinatura:** |
| 761 | |||
| 729 | ```lua | 762 | ```lua |
| 730 | line_offset: integer | 763 | line_offset: integer |
| 731 | ``` | 764 | ``` |
| @@ -739,6 +772,7 @@ line_offset: integer | |||
| 739 | A enumeração da versão alvo do Lua. | 772 | A enumeração da versão alvo do Lua. |
| 740 | 773 | ||
| 741 | **Assinatura:** | 774 | **Assinatura:** |
| 775 | |||
| 742 | ```lua | 776 | ```lua |
| 743 | enum LuaTarget | 777 | enum LuaTarget |
| 744 | "5.1" | 778 | "5.1" |
| @@ -758,6 +792,7 @@ end | |||
| 758 | As opções extras a serem passadas para a função de compilação. | 792 | As opções extras a serem passadas para a função de compilação. |
| 759 | 793 | ||
| 760 | **Assinatura:** | 794 | **Assinatura:** |
| 795 | |||
| 761 | ```lua | 796 | ```lua |
| 762 | options: Options | 797 | options: Options |
| 763 | ``` | 798 | ``` |
| @@ -777,6 +812,7 @@ A definição das opções extras do compilador. | |||
| 777 | A versão alvo do Lua para a compilação. | 812 | A versão alvo do Lua para a compilação. |
| 778 | 813 | ||
| 779 | **Assinatura:** | 814 | **Assinatura:** |
| 815 | |||
| 780 | ```lua | 816 | ```lua |
| 781 | target: LuaTarget | 817 | target: LuaTarget |
| 782 | ``` | 818 | ``` |
| @@ -790,6 +826,7 @@ target: LuaTarget | |||
| 790 | O caminho de busca de módulo extra. | 826 | O caminho de busca de módulo extra. |
| 791 | 827 | ||
| 792 | **Assinatura:** | 828 | **Assinatura:** |
| 829 | |||
| 793 | ```lua | 830 | ```lua |
| 794 | path: string | 831 | path: string |
| 795 | ``` | 832 | ``` |
| @@ -803,6 +840,7 @@ path: string | |||
| 803 | Se deve incluir as variáveis locais na mensagem de erro do traceback. Padrão é false. | 840 | Se deve incluir as variáveis locais na mensagem de erro do traceback. Padrão é false. |
| 804 | 841 | ||
| 805 | **Assinatura:** | 842 | **Assinatura:** |
| 843 | |||
| 806 | ```lua | 844 | ```lua |
| 807 | dump_locals: boolean | 845 | dump_locals: boolean |
| 808 | ``` | 846 | ``` |
| @@ -816,6 +854,7 @@ dump_locals: boolean | |||
| 816 | Se deve simplificar a mensagem de erro. Padrão é true. | 854 | Se deve simplificar a mensagem de erro. Padrão é true. |
| 817 | 855 | ||
| 818 | **Assinatura:** | 856 | **Assinatura:** |
| 857 | |||
| 819 | ```lua | 858 | ```lua |
| 820 | simplified: boolean | 859 | simplified: boolean |
| 821 | ``` | 860 | ``` |
diff --git a/doc/docs/pt-br/index.md b/doc/docs/pt-br/index.md index 818bb58..e62095f 100644 --- a/doc/docs/pt-br/index.md +++ b/doc/docs/pt-br/index.md | |||
| @@ -21,4 +21,5 @@ footer: | |||
| 21 | message: Licença MIT. | 21 | message: Licença MIT. |
| 22 | copyright: Copyright © 2017-2026 Li Jin. Todos os direitos reservados. | 22 | copyright: Copyright © 2017-2026 Li Jin. Todos os direitos reservados. |
| 23 | --- | 23 | --- |
| 24 | |||
| 24 | --- | 25 | --- |
diff --git a/doc/docs/pt-br/try/index.md b/doc/docs/pt-br/try/index.md index 624b3bf..918162d 100755 --- a/doc/docs/pt-br/try/index.md +++ b/doc/docs/pt-br/try/index.md | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | # Compilador online do YueScript | 1 | # Compilador online do YueScript |
| 2 | |||
| 2 | --- | 3 | --- |
| 3 | 4 | ||
| 4 | Experimente YueScript no navegador com WASM. | 5 | Experimente YueScript no navegador com WASM. |
diff --git a/doc/docs/try/index.md b/doc/docs/try/index.md index 85a903b..37d513d 100755 --- a/doc/docs/try/index.md +++ b/doc/docs/try/index.md | |||
| @@ -5,6 +5,7 @@ next: false | |||
| 5 | --- | 5 | --- |
| 6 | 6 | ||
| 7 | # YueScript Online Compiler | 7 | # YueScript Online Compiler |
| 8 | |||
| 8 | --- | 9 | --- |
| 9 | 10 | ||
| 10 | Try YueScript in the browser with WASM. | 11 | Try YueScript in the browser with WASM. |
diff --git a/doc/docs/zh/doc/advanced/do.md b/doc/docs/zh/doc/advanced/do.md index 52dca26..a2d5d19 100644 --- a/doc/docs/zh/doc/advanced/do.md +++ b/doc/docs/zh/doc/advanced/do.md | |||
| @@ -8,6 +8,7 @@ do | |||
| 8 | print var | 8 | print var |
| 9 | print var -- 这里是nil | 9 | print var -- 这里是nil |
| 10 | ``` | 10 | ``` |
| 11 | |||
| 11 | <YueDisplay> | 12 | <YueDisplay> |
| 12 | 13 | ||
| 13 | ```yue | 14 | ```yue |
| @@ -31,6 +32,7 @@ counter = do | |||
| 31 | print counter! | 32 | print counter! |
| 32 | print counter! | 33 | print counter! |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -53,6 +55,7 @@ tbl = { | |||
| 53 | 1234 | 55 | 1234 |
| 54 | } | 56 | } |
| 55 | ``` | 57 | ``` |
| 58 | |||
| 56 | <YueDisplay> | 59 | <YueDisplay> |
| 57 | 60 | ||
| 58 | ```yue | 61 | ```yue |
diff --git a/doc/docs/zh/doc/advanced/line-decorators.md b/doc/docs/zh/doc/advanced/line-decorators.md index 86a1bd9..853e396 100644 --- a/doc/docs/zh/doc/advanced/line-decorators.md +++ b/doc/docs/zh/doc/advanced/line-decorators.md | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | print "你好,世界" if name == "Rob" | 6 | print "你好,世界" if name == "Rob" |
| 7 | ``` | 7 | ``` |
| 8 | |||
| 8 | <YueDisplay> | 9 | <YueDisplay> |
| 9 | 10 | ||
| 10 | ```yue | 11 | ```yue |
| @@ -18,6 +19,7 @@ print "你好,世界" if name == "Rob" | |||
| 18 | ```yuescript | 19 | ```yuescript |
| 19 | print "项目: ", item for item in *items | 20 | print "项目: ", item for item in *items |
| 20 | ``` | 21 | ``` |
| 22 | |||
| 21 | <YueDisplay> | 23 | <YueDisplay> |
| 22 | 24 | ||
| 23 | ```yue | 25 | ```yue |
| @@ -33,6 +35,7 @@ game\update! while game\isRunning! | |||
| 33 | 35 | ||
| 34 | reader\parse_line! until reader\eof! | 36 | reader\parse_line! until reader\eof! |
| 35 | ``` | 37 | ``` |
| 38 | |||
| 36 | <YueDisplay> | 39 | <YueDisplay> |
| 37 | 40 | ||
| 38 | ```yue | 41 | ```yue |
diff --git a/doc/docs/zh/doc/advanced/macro.md b/doc/docs/zh/doc/advanced/macro.md index 91be42c..64cfa6d 100644 --- a/doc/docs/zh/doc/advanced/macro.md +++ b/doc/docs/zh/doc/advanced/macro.md | |||
| @@ -32,6 +32,7 @@ macro and = (...) -> "#{ table.concat {...}, ' and ' }" | |||
| 32 | if $and f1!, f2!, f3! | 32 | if $and f1!, f2!, f3! |
| 33 | print "OK" | 33 | print "OK" |
| 34 | ``` | 34 | ``` |
| 35 | |||
| 35 | <YueDisplay> | 36 | <YueDisplay> |
| 36 | 37 | ||
| 37 | ```yue | 38 | ```yue |
| @@ -94,6 +95,7 @@ if cond then | |||
| 94 | end | 95 | end |
| 95 | ]==] | 96 | ]==] |
| 96 | ``` | 97 | ``` |
| 98 | |||
| 97 | <YueDisplay> | 99 | <YueDisplay> |
| 98 | 100 | ||
| 99 | ```yue | 101 | ```yue |
| @@ -142,6 +144,7 @@ import "utils" as { | |||
| 142 | } | 144 | } |
| 143 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ | 145 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ |
| 144 | ``` | 146 | ``` |
| 147 | |||
| 145 | <YueDisplay> | 148 | <YueDisplay> |
| 146 | 149 | ||
| 147 | ```yue | 150 | ```yue |
| @@ -172,6 +175,7 @@ import "utils" as { | |||
| 172 | print $FILE -- 获取当前模块名称的字符串 | 175 | print $FILE -- 获取当前模块名称的字符串 |
| 173 | print $LINE -- 获取当前代码行数:2 | 176 | print $LINE -- 获取当前代码行数:2 |
| 174 | ``` | 177 | ``` |
| 178 | |||
| 175 | <YueDisplay> | 179 | <YueDisplay> |
| 176 | 180 | ||
| 177 | ```yue | 181 | ```yue |
| @@ -202,6 +206,7 @@ macro BodyType = $Enum( | |||
| 202 | print "有效的枚举类型:", $BodyType Static | 206 | print "有效的枚举类型:", $BodyType Static |
| 203 | -- print "编译报错的枚举类型:", $BodyType Unknown | 207 | -- print "编译报错的枚举类型:", $BodyType Unknown |
| 204 | ``` | 208 | ``` |
| 209 | |||
| 205 | <YueDisplay> | 210 | <YueDisplay> |
| 206 | 211 | ||
| 207 | ```yue | 212 | ```yue |
| @@ -237,6 +242,7 @@ macro printNumAndStr = (num `Num, str `String) -> | | |||
| 237 | 242 | ||
| 238 | $printNumAndStr 123, "hello" | 243 | $printNumAndStr 123, "hello" |
| 239 | ``` | 244 | ``` |
| 245 | |||
| 240 | <YueDisplay> | 246 | <YueDisplay> |
| 241 | 247 | ||
| 242 | ```yue | 248 | ```yue |
| @@ -261,6 +267,7 @@ macro printNumAndStr = (num, str) -> | |||
| 261 | 267 | ||
| 262 | $printNumAndStr 123, "hello" | 268 | $printNumAndStr 123, "hello" |
| 263 | ``` | 269 | ``` |
| 270 | |||
| 264 | <YueDisplay> | 271 | <YueDisplay> |
| 265 | 272 | ||
| 266 | ```yue | 273 | ```yue |
diff --git a/doc/docs/zh/doc/advanced/module.md b/doc/docs/zh/doc/advanced/module.md index bae6618..6c90f0e 100644 --- a/doc/docs/zh/doc/advanced/module.md +++ b/doc/docs/zh/doc/advanced/module.md | |||
| @@ -28,6 +28,7 @@ do | |||
| 28 | import "lpeg" as :C, :Ct, :Cmt | 28 | import "lpeg" as :C, :Ct, :Cmt |
| 29 | import "export" as {one, two, Something:{umm:{ch}}} | 29 | import "export" as {one, two, Something:{umm:{ch}}} |
| 30 | ``` | 30 | ``` |
| 31 | |||
| 31 | <YueDisplay> | 32 | <YueDisplay> |
| 32 | 33 | ||
| 33 | ```yue | 34 | ```yue |
| @@ -67,6 +68,7 @@ do | |||
| 67 | import table.concat | 68 | import table.concat |
| 68 | print concat ["a", tostring 1] | 69 | print concat ["a", tostring 1] |
| 69 | ``` | 70 | ``` |
| 71 | |||
| 70 | <YueDisplay> | 72 | <YueDisplay> |
| 71 | 73 | ||
| 72 | ```yue | 74 | ```yue |
| @@ -98,6 +100,7 @@ do | |||
| 98 | print FLAG | 100 | print FLAG |
| 99 | FLAG = 123 | 101 | FLAG = 123 |
| 100 | ``` | 102 | ``` |
| 103 | |||
| 101 | <YueDisplay> | 104 | <YueDisplay> |
| 102 | 105 | ||
| 103 | ```yue | 106 | ```yue |
| @@ -140,6 +143,7 @@ export y = -> | |||
| 140 | export class Something | 143 | export class Something |
| 141 | umm: "cool" | 144 | umm: "cool" |
| 142 | ``` | 145 | ``` |
| 146 | |||
| 143 | <YueDisplay> | 147 | <YueDisplay> |
| 144 | 148 | ||
| 145 | ```yue | 149 | ```yue |
| @@ -166,6 +170,7 @@ export class Something | |||
| 166 | export :loadstring, to_lua: tolua = yue | 170 | export :loadstring, to_lua: tolua = yue |
| 167 | export {itemA: {:fieldA = '默认值'}} = tb | 171 | export {itemA: {:fieldA = '默认值'}} = tb |
| 168 | ``` | 172 | ``` |
| 173 | |||
| 169 | <YueDisplay> | 174 | <YueDisplay> |
| 170 | 175 | ||
| 171 | ```yue | 176 | ```yue |
| @@ -182,6 +187,7 @@ export.itemA = tb | |||
| 182 | export.<index> = items | 187 | export.<index> = items |
| 183 | export["a-b-c"] = 123 | 188 | export["a-b-c"] = 123 |
| 184 | ``` | 189 | ``` |
| 190 | |||
| 185 | <YueDisplay> | 191 | <YueDisplay> |
| 186 | 192 | ||
| 187 | ```yue | 193 | ```yue |
| @@ -208,6 +214,7 @@ else | |||
| 208 | export with tmp | 214 | export with tmp |
| 209 | j = 2000 | 215 | j = 2000 |
| 210 | ``` | 216 | ``` |
| 217 | |||
| 211 | <YueDisplay> | 218 | <YueDisplay> |
| 212 | 219 | ||
| 213 | ```yue | 220 | ```yue |
| @@ -234,6 +241,7 @@ export default -> | |||
| 234 | print "你好" | 241 | print "你好" |
| 235 | 123 | 242 | 123 |
| 236 | ``` | 243 | ``` |
| 244 | |||
| 237 | <YueDisplay> | 245 | <YueDisplay> |
| 238 | 246 | ||
| 239 | ```yue | 247 | ```yue |
diff --git a/doc/docs/zh/doc/advanced/try.md b/doc/docs/zh/doc/advanced/try.md index b4de24d..ef90831 100644 --- a/doc/docs/zh/doc/advanced/try.md +++ b/doc/docs/zh/doc/advanced/try.md | |||
| @@ -29,6 +29,7 @@ catch err | |||
| 29 | print yue.traceback err | 29 | print yue.traceback err |
| 30 | print result | 30 | print result |
| 31 | ``` | 31 | ``` |
| 32 | |||
| 32 | <YueDisplay> | 33 | <YueDisplay> |
| 33 | 34 | ||
| 34 | ```yue | 35 | ```yue |
| @@ -82,6 +83,7 @@ catch e | |||
| 82 | print e | 83 | print e |
| 83 | e | 84 | e |
| 84 | ``` | 85 | ``` |
| 86 | |||
| 85 | <YueDisplay> | 87 | <YueDisplay> |
| 86 | 88 | ||
| 87 | ```yue | 89 | ```yue |
diff --git a/doc/docs/zh/doc/assignment/assignment.md b/doc/docs/zh/doc/assignment/assignment.md index 49561fb..7245e18 100644 --- a/doc/docs/zh/doc/assignment/assignment.md +++ b/doc/docs/zh/doc/assignment/assignment.md | |||
| @@ -7,6 +7,7 @@ hello = "world" | |||
| 7 | a, b, c = 1, 2, 3 | 7 | a, b, c = 1, 2, 3 |
| 8 | hello = 123 -- 访问现有的变量 | 8 | hello = 123 -- 访问现有的变量 |
| 9 | ``` | 9 | ``` |
| 10 | |||
| 10 | <YueDisplay> | 11 | <YueDisplay> |
| 11 | 12 | ||
| 12 | ```yue | 13 | ```yue |
| @@ -31,6 +32,7 @@ x %= 10 | |||
| 31 | s ..= "world" -- 如果执行更新的局部变量不存在,将新建一个局部变量 | 32 | s ..= "world" -- 如果执行更新的局部变量不存在,将新建一个局部变量 |
| 32 | arg or= "默认值" | 33 | arg or= "默认值" |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -54,6 +56,7 @@ arg or= "默认值" | |||
| 54 | a = b = c = d = e = 0 | 56 | a = b = c = d = e = 0 |
| 55 | x = y = z = f! | 57 | x = y = z = f! |
| 56 | ``` | 58 | ``` |
| 59 | |||
| 57 | <YueDisplay> | 60 | <YueDisplay> |
| 58 | 61 | ||
| 59 | ```yue | 62 | ```yue |
| @@ -81,6 +84,7 @@ do | |||
| 81 | a = 1 | 84 | a = 1 |
| 82 | B = 2 | 85 | B = 2 |
| 83 | ``` | 86 | ``` |
| 87 | |||
| 84 | <YueDisplay> | 88 | <YueDisplay> |
| 85 | 89 | ||
| 86 | ```yue | 90 | ```yue |
| @@ -120,6 +124,7 @@ do | |||
| 120 | B = 2 | 124 | B = 2 |
| 121 | local Temp = "一个局部值" | 125 | local Temp = "一个局部值" |
| 122 | ``` | 126 | ``` |
| 127 | |||
| 123 | <YueDisplay> | 128 | <YueDisplay> |
| 124 | 129 | ||
| 125 | ```yue | 130 | ```yue |
diff --git a/doc/docs/zh/doc/assignment/destructuring-assignment.md b/doc/docs/zh/doc/assignment/destructuring-assignment.md index 29219d3..469071f 100644 --- a/doc/docs/zh/doc/assignment/destructuring-assignment.md +++ b/doc/docs/zh/doc/assignment/destructuring-assignment.md | |||
| @@ -12,8 +12,8 @@ thing = [1, 2] | |||
| 12 | [a, b] = thing | 12 | [a, b] = thing |
| 13 | print a, b | 13 | print a, b |
| 14 | ``` | 14 | ``` |
| 15 | <YueDisplay> | ||
| 16 | 15 | ||
| 16 | <YueDisplay> | ||
| 17 | 17 | ||
| 18 | ```yue | 18 | ```yue |
| 19 | thing = [1, 2] | 19 | thing = [1, 2] |
| @@ -38,6 +38,7 @@ print hello, the_day | |||
| 38 | 38 | ||
| 39 | :day = obj -- 可以不带大括号进行简单的解构 | 39 | :day = obj -- 可以不带大括号进行简单的解构 |
| 40 | ``` | 40 | ``` |
| 41 | |||
| 41 | <YueDisplay> | 42 | <YueDisplay> |
| 42 | 43 | ||
| 43 | ```yue | 44 | ```yue |
| @@ -69,6 +70,7 @@ obj2 = { | |||
| 69 | {numbers: [first, second], properties: {color: color}} = obj2 | 70 | {numbers: [first, second], properties: {color: color}} = obj2 |
| 70 | print first, second, color | 71 | print first, second, color |
| 71 | ``` | 72 | ``` |
| 73 | |||
| 72 | <YueDisplay> | 74 | <YueDisplay> |
| 73 | 75 | ||
| 74 | ```yue | 76 | ```yue |
| @@ -96,6 +98,7 @@ print first, second, color | |||
| 96 | } | 98 | } |
| 97 | } = obj2 | 99 | } = obj2 |
| 98 | ``` | 100 | ``` |
| 101 | |||
| 99 | <YueDisplay> | 102 | <YueDisplay> |
| 100 | 103 | ||
| 101 | ```yue | 104 | ```yue |
| @@ -114,6 +117,7 @@ print first, second, color | |||
| 114 | ```yuescript | 117 | ```yuescript |
| 115 | {:concat, :insert} = table | 118 | {:concat, :insert} = table |
| 116 | ``` | 119 | ``` |
| 120 | |||
| 117 | <YueDisplay> | 121 | <YueDisplay> |
| 118 | 122 | ||
| 119 | ```yue | 123 | ```yue |
| @@ -127,6 +131,7 @@ print first, second, color | |||
| 127 | ```yuescript | 131 | ```yuescript |
| 128 | {:mix, :max, random: rand} = math | 132 | {:mix, :max, random: rand} = math |
| 129 | ``` | 133 | ``` |
| 134 | |||
| 130 | <YueDisplay> | 135 | <YueDisplay> |
| 131 | 136 | ||
| 132 | ```yue | 137 | ```yue |
| @@ -140,6 +145,7 @@ print first, second, color | |||
| 140 | ```yuescript | 145 | ```yuescript |
| 141 | {:name = "nameless", :job = "jobless"} = person | 146 | {:name = "nameless", :job = "jobless"} = person |
| 142 | ``` | 147 | ``` |
| 148 | |||
| 143 | <YueDisplay> | 149 | <YueDisplay> |
| 144 | 150 | ||
| 145 | ```yue | 151 | ```yue |
| @@ -153,6 +159,7 @@ print first, second, color | |||
| 153 | ```yuescript | 159 | ```yuescript |
| 154 | [_, two, _, four] = items | 160 | [_, two, _, four] = items |
| 155 | ``` | 161 | ``` |
| 162 | |||
| 156 | <YueDisplay> | 163 | <YueDisplay> |
| 157 | 164 | ||
| 158 | ```yue | 165 | ```yue |
| @@ -172,6 +179,7 @@ print first -- 打印: first | |||
| 172 | print bulk -- 打印: {"second", "third", "fourth"} | 179 | print bulk -- 打印: {"second", "third", "fourth"} |
| 173 | print last -- 打印: last | 180 | print last -- 打印: last |
| 174 | ``` | 181 | ``` |
| 182 | |||
| 175 | <YueDisplay> | 183 | <YueDisplay> |
| 176 | 184 | ||
| 177 | ```yue | 185 | ```yue |
| @@ -196,6 +204,7 @@ print last -- 打印: last | |||
| 196 | -- 跳过中间的元素,只捕获第一个和最后一个元素 | 204 | -- 跳过中间的元素,只捕获第一个和最后一个元素 |
| 197 | [first, ..._, last] = orders | 205 | [first, ..._, last] = orders |
| 198 | ``` | 206 | ``` |
| 207 | |||
| 199 | <YueDisplay> | 208 | <YueDisplay> |
| 200 | 209 | ||
| 201 | ```yue | 210 | ```yue |
| @@ -224,6 +233,7 @@ tuples = [ | |||
| 224 | for [left, right] in *tuples | 233 | for [left, right] in *tuples |
| 225 | print left, right | 234 | print left, right |
| 226 | ``` | 235 | ``` |
| 236 | |||
| 227 | <YueDisplay> | 237 | <YueDisplay> |
| 228 | 238 | ||
| 229 | ```yue | 239 | ```yue |
diff --git a/doc/docs/zh/doc/assignment/if-assignment.md b/doc/docs/zh/doc/assignment/if-assignment.md index e4077e1..915b1d5 100644 --- a/doc/docs/zh/doc/assignment/if-assignment.md +++ b/doc/docs/zh/doc/assignment/if-assignment.md | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | if user := database.find_user "moon" | 6 | if user := database.find_user "moon" |
| 7 | print user.name | 7 | print user.name |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -23,6 +24,7 @@ elseif world := os.getenv "world" | |||
| 23 | else | 24 | else |
| 24 | print "什么都没有 :(" | 25 | print "什么都没有 :(" |
| 25 | ``` | 26 | ``` |
| 27 | |||
| 26 | <YueDisplay> | 28 | <YueDisplay> |
| 27 | 29 | ||
| 28 | ```yue | 30 | ```yue |
| @@ -43,6 +45,7 @@ if success, result := pcall -> "无报错地获取结果" | |||
| 43 | print result -- 变量 result 是有作用域的 | 45 | print result -- 变量 result 是有作用域的 |
| 44 | print "好的" | 46 | print "好的" |
| 45 | ``` | 47 | ``` |
| 48 | |||
| 46 | <YueDisplay> | 49 | <YueDisplay> |
| 47 | 50 | ||
| 48 | ```yue | 51 | ```yue |
| @@ -62,6 +65,7 @@ while byte := stream\read_one! | |||
| 62 | -- 对 byte 做一些操作 | 65 | -- 对 byte 做一些操作 |
| 63 | print byte | 66 | print byte |
| 64 | ``` | 67 | ``` |
| 68 | |||
| 65 | <YueDisplay> | 69 | <YueDisplay> |
| 66 | 70 | ||
| 67 | ```yue | 71 | ```yue |
diff --git a/doc/docs/zh/doc/assignment/the-using-clause-controlling-destructive-assignment.md b/doc/docs/zh/doc/assignment/the-using-clause-controlling-destructive-assignment.md index 722de6f..8a9acf4 100644 --- a/doc/docs/zh/doc/assignment/the-using-clause-controlling-destructive-assignment.md +++ b/doc/docs/zh/doc/assignment/the-using-clause-controlling-destructive-assignment.md | |||
| @@ -17,6 +17,7 @@ my_func! | |||
| 17 | 17 | ||
| 18 | print i -- 将打印 0 | 18 | print i -- 将打印 0 |
| 19 | ``` | 19 | ``` |
| 20 | |||
| 20 | <YueDisplay> | 21 | <YueDisplay> |
| 21 | 22 | ||
| 22 | ```yue | 23 | ```yue |
| @@ -52,6 +53,7 @@ my_func = (using nil) -> | |||
| 52 | my_func! | 53 | my_func! |
| 53 | print i -- 打印 100,i 没有受到影响 | 54 | print i -- 打印 100,i 没有受到影响 |
| 54 | ``` | 55 | ``` |
| 56 | |||
| 55 | <YueDisplay> | 57 | <YueDisplay> |
| 56 | 58 | ||
| 57 | ```yue | 59 | ```yue |
| @@ -80,6 +82,7 @@ my_func = (add using k, i) -> | |||
| 80 | my_func(22) | 82 | my_func(22) |
| 81 | print i, k -- 这些已经被更新 | 83 | print i, k -- 这些已经被更新 |
| 82 | ``` | 84 | ``` |
| 85 | |||
| 83 | <YueDisplay> | 86 | <YueDisplay> |
| 84 | 87 | ||
| 85 | ```yue | 88 | ```yue |
diff --git a/doc/docs/zh/doc/assignment/varargs-assignment.md b/doc/docs/zh/doc/assignment/varargs-assignment.md index 6cc4278..cc9206e 100644 --- a/doc/docs/zh/doc/assignment/varargs-assignment.md +++ b/doc/docs/zh/doc/assignment/varargs-assignment.md | |||
| @@ -10,6 +10,7 @@ count = select '#', ... | |||
| 10 | first = select 1, ... | 10 | first = select 1, ... |
| 11 | print ok, count, first | 11 | print ok, count, first |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
diff --git a/doc/docs/zh/doc/control-flow/conditionals.md b/doc/docs/zh/doc/control-flow/conditionals.md index ba77f40..3a4d5d1 100644 --- a/doc/docs/zh/doc/control-flow/conditionals.md +++ b/doc/docs/zh/doc/control-flow/conditionals.md | |||
| @@ -7,6 +7,7 @@ if have_coins | |||
| 7 | else | 7 | else |
| 8 | print "没有硬币" | 8 | print "没有硬币" |
| 9 | ``` | 9 | ``` |
| 10 | |||
| 10 | <YueDisplay> | 11 | <YueDisplay> |
| 11 | 12 | ||
| 12 | ```yue | 13 | ```yue |
| @@ -25,6 +26,7 @@ else | |||
| 25 | have_coins = false | 26 | have_coins = false |
| 26 | if have_coins then print "有硬币" else print "没有硬币" | 27 | if have_coins then print "有硬币" else print "没有硬币" |
| 27 | ``` | 28 | ``` |
| 29 | |||
| 28 | <YueDisplay> | 30 | <YueDisplay> |
| 29 | 31 | ||
| 30 | ```yue | 32 | ```yue |
| @@ -40,6 +42,7 @@ if have_coins then print "有硬币" else print "没有硬币" | |||
| 40 | have_coins = false | 42 | have_coins = false |
| 41 | print if have_coins then "有硬币" else "没有硬币" | 43 | print if have_coins then "有硬币" else "没有硬币" |
| 42 | ``` | 44 | ``` |
| 45 | |||
| 43 | <YueDisplay> | 46 | <YueDisplay> |
| 44 | 47 | ||
| 45 | ```yue | 48 | ```yue |
| @@ -65,6 +68,7 @@ else | |||
| 65 | 68 | ||
| 66 | print message -- 打印: 我很高 | 69 | print message -- 打印: 我很高 |
| 67 | ``` | 70 | ``` |
| 71 | |||
| 68 | <YueDisplay> | 72 | <YueDisplay> |
| 69 | 73 | ||
| 70 | ```yue | 74 | ```yue |
| @@ -90,8 +94,8 @@ print message -- 打印: 我很高 | |||
| 90 | unless os.date("%A") == "Monday" | 94 | unless os.date("%A") == "Monday" |
| 91 | print "今天不是星期一!" | 95 | print "今天不是星期一!" |
| 92 | ``` | 96 | ``` |
| 93 | <YueDisplay> | ||
| 94 | 97 | ||
| 98 | <YueDisplay> | ||
| 95 | 99 | ||
| 96 | ```yue | 100 | ```yue |
| 97 | unless os.date("%A") == "Monday" | 101 | unless os.date("%A") == "Monday" |
| @@ -103,6 +107,7 @@ unless os.date("%A") == "Monday" | |||
| 103 | ```yuescript | 107 | ```yuescript |
| 104 | print "你真幸运!" unless math.random! > 0.1 | 108 | print "你真幸运!" unless math.random! > 0.1 |
| 105 | ``` | 109 | ``` |
| 110 | |||
| 106 | <YueDisplay> | 111 | <YueDisplay> |
| 107 | 112 | ||
| 108 | ```yue | 113 | ```yue |
| @@ -124,6 +129,7 @@ if a in [1, 3, 5, 7] | |||
| 124 | if a in list | 129 | if a in list |
| 125 | print "检查`a`是否在列表中" | 130 | print "检查`a`是否在列表中" |
| 126 | ``` | 131 | ``` |
| 132 | |||
| 127 | <YueDisplay> | 133 | <YueDisplay> |
| 128 | 134 | ||
| 129 | ```yue | 135 | ```yue |
diff --git a/doc/docs/zh/doc/control-flow/continue.md b/doc/docs/zh/doc/control-flow/continue.md index 9fab8a3..3b1a093 100644 --- a/doc/docs/zh/doc/control-flow/continue.md +++ b/doc/docs/zh/doc/control-flow/continue.md | |||
| @@ -9,6 +9,7 @@ while i < 10 | |||
| 9 | continue if i % 2 == 0 | 9 | continue if i % 2 == 0 |
| 10 | print i | 10 | print i |
| 11 | ``` | 11 | ``` |
| 12 | |||
| 12 | <YueDisplay> | 13 | <YueDisplay> |
| 13 | 14 | ||
| 14 | ```yue | 15 | ```yue |
| @@ -29,6 +30,7 @@ odds = for x in *my_numbers | |||
| 29 | continue if x % 2 == 1 | 30 | continue if x % 2 == 1 |
| 30 | x | 31 | x |
| 31 | ``` | 32 | ``` |
| 33 | |||
| 32 | <YueDisplay> | 34 | <YueDisplay> |
| 33 | 35 | ||
| 34 | ```yue | 36 | ```yue |
diff --git a/doc/docs/zh/doc/control-flow/for-loop.md b/doc/docs/zh/doc/control-flow/for-loop.md index 212ff81..52180b7 100644 --- a/doc/docs/zh/doc/control-flow/for-loop.md +++ b/doc/docs/zh/doc/control-flow/for-loop.md | |||
| @@ -12,6 +12,7 @@ for k = 1, 15, 2 -- 提供了一个遍历的步长 | |||
| 12 | for key, value in pairs object | 12 | for key, value in pairs object |
| 13 | print key, value | 13 | print key, value |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -33,6 +34,7 @@ for key, value in pairs object | |||
| 33 | for item in *items[2, 4] | 34 | for item in *items[2, 4] |
| 34 | print item | 35 | print item |
| 35 | ``` | 36 | ``` |
| 37 | |||
| 36 | <YueDisplay> | 38 | <YueDisplay> |
| 37 | 39 | ||
| 38 | ```yue | 40 | ```yue |
| @@ -49,6 +51,7 @@ for item in *items do print item | |||
| 49 | 51 | ||
| 50 | for j = 1, 10, 3 do print j | 52 | for j = 1, 10, 3 do print j |
| 51 | ``` | 53 | ``` |
| 54 | |||
| 52 | <YueDisplay> | 55 | <YueDisplay> |
| 53 | 56 | ||
| 54 | ```yue | 57 | ```yue |
| @@ -70,6 +73,7 @@ doubled_evens = for i = 1, 20 | |||
| 70 | else | 73 | else |
| 71 | i | 74 | i |
| 72 | ``` | 75 | ``` |
| 76 | |||
| 73 | <YueDisplay> | 77 | <YueDisplay> |
| 74 | 78 | ||
| 75 | ```yue | 79 | ```yue |
| @@ -90,6 +94,7 @@ doubled_evens = for i = 1, 20 | |||
| 90 | first_large = for n in *numbers | 94 | first_large = for n in *numbers |
| 91 | break n if n > 10 | 95 | break n if n > 10 |
| 92 | ``` | 96 | ``` |
| 97 | |||
| 93 | <YueDisplay> | 98 | <YueDisplay> |
| 94 | 99 | ||
| 95 | ```yue | 100 | ```yue |
| @@ -110,6 +115,7 @@ func_b = -> return for i = 1, 10 do i | |||
| 110 | print func_a! -- 打印 nil | 115 | print func_a! -- 打印 nil |
| 111 | print func_b! -- 打印 table 对象 | 116 | print func_b! -- 打印 table 对象 |
| 112 | ``` | 117 | ``` |
| 118 | |||
| 113 | <YueDisplay> | 119 | <YueDisplay> |
| 114 | 120 | ||
| 115 | ```yue | 121 | ```yue |
diff --git a/doc/docs/zh/doc/control-flow/switch.md b/doc/docs/zh/doc/control-flow/switch.md index 700bc2a..69ba5b5 100644 --- a/doc/docs/zh/doc/control-flow/switch.md +++ b/doc/docs/zh/doc/control-flow/switch.md | |||
| @@ -11,6 +11,7 @@ switch name := "Dan" | |||
| 11 | else | 11 | else |
| 12 | print "我不认识你,你的名字是#{name}" | 12 | print "我不认识你,你的名字是#{name}" |
| 13 | ``` | 13 | ``` |
| 14 | |||
| 14 | <YueDisplay> | 15 | <YueDisplay> |
| 15 | 16 | ||
| 16 | ```yue | 17 | ```yue |
| @@ -39,6 +40,7 @@ next_number = switch b | |||
| 39 | else | 40 | else |
| 40 | error "数字数得太大了!" | 41 | error "数字数得太大了!" |
| 41 | ``` | 42 | ``` |
| 43 | |||
| 42 | <YueDisplay> | 44 | <YueDisplay> |
| 43 | 45 | ||
| 44 | ```yue | 46 | ```yue |
| @@ -62,6 +64,7 @@ msg = switch math.random(1, 5) | |||
| 62 | when 2 then "你差点很幸运" | 64 | when 2 then "你差点很幸运" |
| 63 | else "不太幸运" | 65 | else "不太幸运" |
| 64 | ``` | 66 | ``` |
| 67 | |||
| 65 | <YueDisplay> | 68 | <YueDisplay> |
| 66 | 69 | ||
| 67 | ```yue | 70 | ```yue |
| @@ -87,6 +90,7 @@ switch math.random(1, 5) when 1 | |||
| 87 | else | 90 | else |
| 88 | print "不太幸运" | 91 | print "不太幸运" |
| 89 | ``` | 92 | ``` |
| 93 | |||
| 90 | <YueDisplay> | 94 | <YueDisplay> |
| 91 | 95 | ||
| 92 | ```yue | 96 | ```yue |
| @@ -124,6 +128,7 @@ for item in *items | |||
| 124 | when :width, :height | 128 | when :width, :height |
| 125 | print "尺寸 #{width}, #{height}" | 129 | print "尺寸 #{width}, #{height}" |
| 126 | ``` | 130 | ``` |
| 131 | |||
| 127 | <YueDisplay> | 132 | <YueDisplay> |
| 128 | 133 | ||
| 129 | ```yue | 134 | ```yue |
| @@ -154,6 +159,7 @@ switch item | |||
| 154 | when {pos: {:x = 50, :y = 200}} | 159 | when {pos: {:x = 50, :y = 200}} |
| 155 | print "Vec2 #{x}, #{y}" -- 表格解构仍然会通过 | 160 | print "Vec2 #{x}, #{y}" -- 表格解构仍然会通过 |
| 156 | ``` | 161 | ``` |
| 162 | |||
| 157 | <YueDisplay> | 163 | <YueDisplay> |
| 158 | 164 | ||
| 159 | ```yue | 165 | ```yue |
| @@ -181,6 +187,7 @@ switch tb | |||
| 181 | when [1, 2, b = 3] -- 变量b有默认值 | 187 | when [1, 2, b = 3] -- 变量b有默认值 |
| 182 | print "1, 2, #{b}" | 188 | print "1, 2, #{b}" |
| 183 | ``` | 189 | ``` |
| 190 | |||
| 184 | <YueDisplay> | 191 | <YueDisplay> |
| 185 | 192 | ||
| 186 | ```yue | 193 | ```yue |
| @@ -206,6 +213,7 @@ switch tb | |||
| 206 | else | 213 | else |
| 207 | print "无效值" | 214 | print "无效值" |
| 208 | ``` | 215 | ``` |
| 216 | |||
| 209 | <YueDisplay> | 217 | <YueDisplay> |
| 210 | 218 | ||
| 211 | ```yue | 219 | ```yue |
| @@ -231,6 +239,7 @@ switch tb | |||
| 231 | else | 239 | else |
| 232 | print "无效值" | 240 | print "无效值" |
| 233 | ``` | 241 | ``` |
| 242 | |||
| 234 | <YueDisplay> | 243 | <YueDisplay> |
| 235 | 244 | ||
| 236 | ```yue | 245 | ```yue |
| @@ -257,6 +266,7 @@ switch tb | |||
| 257 | ] | 266 | ] |
| 258 | print "匹配成功", fourth | 267 | print "匹配成功", fourth |
| 259 | ``` | 268 | ``` |
| 269 | |||
| 260 | <YueDisplay> | 270 | <YueDisplay> |
| 261 | 271 | ||
| 262 | ```yue | 272 | ```yue |
| @@ -282,6 +292,7 @@ switch segments | |||
| 282 | print "Resource:", resource -- 打印: "logs" | 292 | print "Resource:", resource -- 打印: "logs" |
| 283 | print "Action:", action -- 打印: "view" | 293 | print "Action:", action -- 打印: "view" |
| 284 | ``` | 294 | ``` |
| 295 | |||
| 285 | <YueDisplay> | 296 | <YueDisplay> |
| 286 | 297 | ||
| 287 | ```yue | 298 | ```yue |
diff --git a/doc/docs/zh/doc/control-flow/while-loop.md b/doc/docs/zh/doc/control-flow/while-loop.md index 5995890..3c624fe 100644 --- a/doc/docs/zh/doc/control-flow/while-loop.md +++ b/doc/docs/zh/doc/control-flow/while-loop.md | |||
| @@ -10,6 +10,7 @@ while i > 0 | |||
| 10 | 10 | ||
| 11 | while running == true do my_function! | 11 | while running == true do my_function! |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
| @@ -31,6 +32,7 @@ until i == 0 | |||
| 31 | 32 | ||
| 32 | until running == false do my_function! | 33 | until running == false do my_function! |
| 33 | ``` | 34 | ``` |
| 35 | |||
| 34 | <YueDisplay> | 36 | <YueDisplay> |
| 35 | 37 | ||
| 36 | ```yue | 38 | ```yue |
| @@ -56,6 +58,7 @@ repeat | |||
| 56 | i -= 1 | 58 | i -= 1 |
| 57 | until i == 0 | 59 | until i == 0 |
| 58 | ``` | 60 | ``` |
| 61 | |||
| 59 | <YueDisplay> | 62 | <YueDisplay> |
| 60 | 63 | ||
| 61 | ```yue | 64 | ```yue |
diff --git a/doc/docs/zh/doc/data-structures/comprehensions.md b/doc/docs/zh/doc/data-structures/comprehensions.md index fd25b22..62f0896 100644 --- a/doc/docs/zh/doc/data-structures/comprehensions.md +++ b/doc/docs/zh/doc/data-structures/comprehensions.md | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | items = [1, 2, 3, 4] | 10 | items = [1, 2, 3, 4] |
| 11 | doubled = [item * 2 for i, item in ipairs items] | 11 | doubled = [item * 2 for i, item in ipairs items] |
| 12 | ``` | 12 | ``` |
| 13 | |||
| 13 | <YueDisplay> | 14 | <YueDisplay> |
| 14 | 15 | ||
| 15 | ```yue | 16 | ```yue |
| @@ -24,6 +25,7 @@ doubled = [item * 2 for i, item in ipairs items] | |||
| 24 | ```yuescript | 25 | ```yuescript |
| 25 | slice = [item for i, item in ipairs items when i > 1 and i < 3] | 26 | slice = [item for i, item in ipairs items when i > 1 and i < 3] |
| 26 | ``` | 27 | ``` |
| 28 | |||
| 27 | <YueDisplay> | 29 | <YueDisplay> |
| 28 | 30 | ||
| 29 | ```yue | 31 | ```yue |
| @@ -37,6 +39,7 @@ slice = [item for i, item in ipairs items when i > 1 and i < 3] | |||
| 37 | ```yuescript | 39 | ```yuescript |
| 38 | doubled = [item * 2 for item in *items] | 40 | doubled = [item * 2 for item in *items] |
| 39 | ``` | 41 | ``` |
| 42 | |||
| 40 | <YueDisplay> | 43 | <YueDisplay> |
| 41 | 44 | ||
| 42 | ```yue | 45 | ```yue |
| @@ -55,6 +58,7 @@ data = | |||
| 55 | flat = [...v for k,v in pairs data] | 58 | flat = [...v for k,v in pairs data] |
| 56 | -- flat 现在为 [1, 2, 3, 4, 5, 6] | 59 | -- flat 现在为 [1, 2, 3, 4, 5, 6] |
| 57 | ``` | 60 | ``` |
| 61 | |||
| 58 | <YueDisplay> | 62 | <YueDisplay> |
| 59 | 63 | ||
| 60 | ```yue | 64 | ```yue |
| @@ -79,6 +83,7 @@ y_coords = [9, 2, 3] | |||
| 79 | points = [ [x, y] for x in *x_coords \ | 83 | points = [ [x, y] for x in *x_coords \ |
| 80 | for y in *y_coords] | 84 | for y in *y_coords] |
| 81 | ``` | 85 | ``` |
| 86 | |||
| 82 | <YueDisplay> | 87 | <YueDisplay> |
| 83 | 88 | ||
| 84 | ```yue | 89 | ```yue |
| @@ -96,6 +101,7 @@ for y in *y_coords] | |||
| 96 | ```yuescript | 101 | ```yuescript |
| 97 | evens = [i for i = 1, 100 when i % 2 == 0] | 102 | evens = [i for i = 1, 100 when i % 2 == 0] |
| 98 | ``` | 103 | ``` |
| 104 | |||
| 99 | <YueDisplay> | 105 | <YueDisplay> |
| 100 | 106 | ||
| 101 | ```yue | 107 | ```yue |
| @@ -119,6 +125,7 @@ thing = { | |||
| 119 | 125 | ||
| 120 | thing_copy = {k, v for k, v in pairs thing} | 126 | thing_copy = {k, v for k, v in pairs thing} |
| 121 | ``` | 127 | ``` |
| 128 | |||
| 122 | <YueDisplay> | 129 | <YueDisplay> |
| 123 | 130 | ||
| 124 | ```yue | 131 | ```yue |
| @@ -136,6 +143,7 @@ thing_copy = {k, v for k, v in pairs thing} | |||
| 136 | ```yuescript | 143 | ```yuescript |
| 137 | no_color = {k, v for k, v in pairs thing when k != "color"} | 144 | no_color = {k, v for k, v in pairs thing when k != "color"} |
| 138 | ``` | 145 | ``` |
| 146 | |||
| 139 | <YueDisplay> | 147 | <YueDisplay> |
| 140 | 148 | ||
| 141 | ```yue | 149 | ```yue |
| @@ -150,6 +158,7 @@ no_color = {k, v for k, v in pairs thing when k != "color"} | |||
| 150 | numbers = [1, 2, 3, 4] | 158 | numbers = [1, 2, 3, 4] |
| 151 | sqrts = {i, math.sqrt i for i in *numbers} | 159 | sqrts = {i, math.sqrt i for i in *numbers} |
| 152 | ``` | 160 | ``` |
| 161 | |||
| 153 | <YueDisplay> | 162 | <YueDisplay> |
| 154 | 163 | ||
| 155 | ```yue | 164 | ```yue |
| @@ -167,6 +176,7 @@ sqrts = {i, math.sqrt i for i in *numbers} | |||
| 167 | tuples = [ ["hello", "world"], ["foo", "bar"]] | 176 | tuples = [ ["hello", "world"], ["foo", "bar"]] |
| 168 | tbl = {unpack tuple for tuple in *tuples} | 177 | tbl = {unpack tuple for tuple in *tuples} |
| 169 | ``` | 178 | ``` |
| 179 | |||
| 170 | <YueDisplay> | 180 | <YueDisplay> |
| 171 | 181 | ||
| 172 | ```yue | 182 | ```yue |
| @@ -185,6 +195,7 @@ tbl = {unpack tuple for tuple in *tuples} | |||
| 185 | ```yuescript | 195 | ```yuescript |
| 186 | slice = [item for item in *items[1, 5]] | 196 | slice = [item for item in *items[1, 5]] |
| 187 | ``` | 197 | ``` |
| 198 | |||
| 188 | <YueDisplay> | 199 | <YueDisplay> |
| 189 | 200 | ||
| 190 | ```yue | 201 | ```yue |
| @@ -198,6 +209,7 @@ slice = [item for item in *items[1, 5]] | |||
| 198 | ```yuescript | 209 | ```yuescript |
| 199 | slice = [item for item in *items[2,]] | 210 | slice = [item for item in *items[2,]] |
| 200 | ``` | 211 | ``` |
| 212 | |||
| 201 | <YueDisplay> | 213 | <YueDisplay> |
| 202 | 214 | ||
| 203 | ```yue | 215 | ```yue |
| @@ -211,8 +223,8 @@ slice = [item for item in *items[2,]] | |||
| 211 | ```yuescript | 223 | ```yuescript |
| 212 | slice = [item for item in *items[,,2]] | 224 | slice = [item for item in *items[,,2]] |
| 213 | ``` | 225 | ``` |
| 214 | <YueDisplay> | ||
| 215 | 226 | ||
| 227 | <YueDisplay> | ||
| 216 | 228 | ||
| 217 | ```yue | 229 | ```yue |
| 218 | slice = [item for item in *items[,,2]] | 230 | slice = [item for item in *items[,,2]] |
| @@ -226,6 +238,7 @@ slice = [item for item in *items[,,2]] | |||
| 226 | -- 取最后4个元素 | 238 | -- 取最后4个元素 |
| 227 | slice = [item for item in *items[-4,-1]] | 239 | slice = [item for item in *items[-4,-1]] |
| 228 | ``` | 240 | ``` |
| 241 | |||
| 229 | <YueDisplay> | 242 | <YueDisplay> |
| 230 | 243 | ||
| 231 | ```yue | 244 | ```yue |
| @@ -240,6 +253,7 @@ slice = [item for item in *items[-4,-1]] | |||
| 240 | ```yuescript | 253 | ```yuescript |
| 241 | reverse_slice = [item for item in *items[-1,1,-1]] | 254 | reverse_slice = [item for item in *items[-1,1,-1]] |
| 242 | ``` | 255 | ``` |
| 256 | |||
| 243 | <YueDisplay> | 257 | <YueDisplay> |
| 244 | 258 | ||
| 245 | ```yue | 259 | ```yue |
| @@ -259,6 +273,7 @@ sub_list = items[2, 4] | |||
| 259 | -- 取最后4个元素作为新的列表 | 273 | -- 取最后4个元素作为新的列表 |
| 260 | last_four_items = items[-4, -1] | 274 | last_four_items = items[-4, -1] |
| 261 | ``` | 275 | ``` |
| 276 | |||
| 262 | <YueDisplay> | 277 | <YueDisplay> |
| 263 | 278 | ||
| 264 | ```yue | 279 | ```yue |
diff --git a/doc/docs/zh/doc/data-structures/table-literals.md b/doc/docs/zh/doc/data-structures/table-literals.md index a111950..a8ff9b8 100644 --- a/doc/docs/zh/doc/data-structures/table-literals.md +++ b/doc/docs/zh/doc/data-structures/table-literals.md | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | some_values = [1, 2, 3, 4] | 6 | some_values = [1, 2, 3, 4] |
| 7 | ``` | 7 | ``` |
| 8 | |||
| 8 | <YueDisplay> | 9 | <YueDisplay> |
| 9 | 10 | ||
| 10 | ```yue | 11 | ```yue |
| @@ -22,6 +23,7 @@ some_values = { | |||
| 22 | ["favorite food"]: "rice" | 23 | ["favorite food"]: "rice" |
| 23 | } | 24 | } |
| 24 | ``` | 25 | ``` |
| 26 | |||
| 25 | <YueDisplay> | 27 | <YueDisplay> |
| 26 | 28 | ||
| 27 | ```yue | 29 | ```yue |
| @@ -42,6 +44,7 @@ profile = | |||
| 42 | shoe_size: 13, | 44 | shoe_size: 13, |
| 43 | favorite_foods: ["冰淇淋", "甜甜圈"] | 45 | favorite_foods: ["冰淇淋", "甜甜圈"] |
| 44 | ``` | 46 | ``` |
| 47 | |||
| 45 | <YueDisplay> | 48 | <YueDisplay> |
| 46 | 49 | ||
| 47 | ```yue | 50 | ```yue |
| @@ -63,6 +66,7 @@ values = { | |||
| 63 | occupation: "打击犯罪" | 66 | occupation: "打击犯罪" |
| 64 | } | 67 | } |
| 65 | ``` | 68 | ``` |
| 69 | |||
| 66 | <YueDisplay> | 70 | <YueDisplay> |
| 67 | 71 | ||
| 68 | ```yue | 72 | ```yue |
| @@ -83,6 +87,7 @@ my_function dance: "探戈", partner: "无" | |||
| 83 | 87 | ||
| 84 | y = type: "狗", legs: 4, tails: 1 | 88 | y = type: "狗", legs: 4, tails: 1 |
| 85 | ``` | 89 | ``` |
| 90 | |||
| 86 | <YueDisplay> | 91 | <YueDisplay> |
| 87 | 92 | ||
| 88 | ```yue | 93 | ```yue |
| @@ -101,6 +106,7 @@ tbl = { | |||
| 101 | end: "饥饿" | 106 | end: "饥饿" |
| 102 | } | 107 | } |
| 103 | ``` | 108 | ``` |
| 109 | |||
| 104 | <YueDisplay> | 110 | <YueDisplay> |
| 105 | 111 | ||
| 106 | ```yue | 112 | ```yue |
| @@ -121,6 +127,7 @@ person = { :hair, :height, shoe_size: 40 } | |||
| 121 | 127 | ||
| 122 | print_table :hair, :height | 128 | print_table :hair, :height |
| 123 | ``` | 129 | ``` |
| 130 | |||
| 124 | <YueDisplay> | 131 | <YueDisplay> |
| 125 | 132 | ||
| 126 | ```yue | 133 | ```yue |
| @@ -141,6 +148,7 @@ t = { | |||
| 141 | "你好 世界": true | 148 | "你好 世界": true |
| 142 | } | 149 | } |
| 143 | ``` | 150 | ``` |
| 151 | |||
| 144 | <YueDisplay> | 152 | <YueDisplay> |
| 145 | 153 | ||
| 146 | ```yue | 154 | ```yue |
| @@ -158,6 +166,7 @@ t = { | |||
| 158 | some_values = [ 1, 2, 3, 4 ] | 166 | some_values = [ 1, 2, 3, 4 ] |
| 159 | list_with_one_element = [ 1, ] | 167 | list_with_one_element = [ 1, ] |
| 160 | ``` | 168 | ``` |
| 169 | |||
| 161 | <YueDisplay> | 170 | <YueDisplay> |
| 162 | 171 | ||
| 163 | ```yue | 172 | ```yue |
diff --git a/doc/docs/zh/doc/functions/backcalls.md b/doc/docs/zh/doc/functions/backcalls.md index 4c32fac..7baac90 100644 --- a/doc/docs/zh/doc/functions/backcalls.md +++ b/doc/docs/zh/doc/functions/backcalls.md | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | x <- f | 6 | x <- f |
| 7 | print "hello" .. x | 7 | print "hello" .. x |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -21,6 +22,7 @@ print "hello" .. x | |||
| 21 | <= f | 22 | <= f |
| 22 | print @value | 23 | print @value |
| 23 | ``` | 24 | ``` |
| 25 | |||
| 24 | <YueDisplay> | 26 | <YueDisplay> |
| 25 | 27 | ||
| 26 | ```yue | 28 | ```yue |
| @@ -36,6 +38,7 @@ print @value | |||
| 36 | (x) <- map _, [1, 2, 3] | 38 | (x) <- map _, [1, 2, 3] |
| 37 | x * 2 | 39 | x * 2 |
| 38 | ``` | 40 | ``` |
| 41 | |||
| 39 | <YueDisplay> | 42 | <YueDisplay> |
| 40 | 43 | ||
| 41 | ```yue | 44 | ```yue |
| @@ -55,6 +58,7 @@ result, msg = do | |||
| 55 | check info | 58 | check info |
| 56 | print result, msg | 59 | print result, msg |
| 57 | ``` | 60 | ``` |
| 61 | |||
| 58 | <YueDisplay> | 62 | <YueDisplay> |
| 59 | 63 | ||
| 60 | ```yue | 64 | ```yue |
diff --git a/doc/docs/zh/doc/functions/function-literals.md b/doc/docs/zh/doc/functions/function-literals.md index efe920b..163d155 100644 --- a/doc/docs/zh/doc/functions/function-literals.md +++ b/doc/docs/zh/doc/functions/function-literals.md | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | my_function = -> | 6 | my_function = -> |
| 7 | my_function() -- 调用空函数 | 7 | my_function() -- 调用空函数 |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -24,6 +25,7 @@ func_b = -> | |||
| 24 | value = 100 | 25 | value = 100 |
| 25 | print "这个值是:", value | 26 | print "这个值是:", value |
| 26 | ``` | 27 | ``` |
| 28 | |||
| 27 | <YueDisplay> | 29 | <YueDisplay> |
| 28 | 30 | ||
| 29 | ```yue | 31 | ```yue |
| @@ -42,6 +44,7 @@ func_b = -> | |||
| 42 | func_a! | 44 | func_a! |
| 43 | func_b() | 45 | func_b() |
| 44 | ``` | 46 | ``` |
| 47 | |||
| 45 | <YueDisplay> | 48 | <YueDisplay> |
| 46 | 49 | ||
| 47 | ```yue | 50 | ```yue |
| @@ -56,6 +59,7 @@ func_b() | |||
| 56 | ```yuescript | 59 | ```yuescript |
| 57 | sum = (x, y) -> print "数字的和", x + y | 60 | sum = (x, y) -> print "数字的和", x + y |
| 58 | ``` | 61 | ``` |
| 62 | |||
| 59 | <YueDisplay> | 63 | <YueDisplay> |
| 60 | 64 | ||
| 61 | ```yue | 65 | ```yue |
| @@ -72,6 +76,7 @@ print sum 10, 20 | |||
| 72 | 76 | ||
| 73 | a b c "a", "b", "c" | 77 | a b c "a", "b", "c" |
| 74 | ``` | 78 | ``` |
| 79 | |||
| 75 | <YueDisplay> | 80 | <YueDisplay> |
| 76 | 81 | ||
| 77 | ```yue | 82 | ```yue |
| @@ -88,6 +93,7 @@ a b c "a", "b", "c" | |||
| 88 | ```yuescript | 93 | ```yuescript |
| 89 | print "x:", sum(10, 20), "y:", sum(30, 40) | 94 | print "x:", sum(10, 20), "y:", sum(30, 40) |
| 90 | ``` | 95 | ``` |
| 96 | |||
| 91 | <YueDisplay> | 97 | <YueDisplay> |
| 92 | 98 | ||
| 93 | ```yue | 99 | ```yue |
| @@ -104,6 +110,7 @@ print "x:", sum(10, 20), "y:", sum(30, 40) | |||
| 104 | sum = (x, y) -> x + y | 110 | sum = (x, y) -> x + y |
| 105 | print "数字的和是", sum 10, 20 | 111 | print "数字的和是", sum 10, 20 |
| 106 | ``` | 112 | ``` |
| 113 | |||
| 107 | <YueDisplay> | 114 | <YueDisplay> |
| 108 | 115 | ||
| 109 | ```yue | 116 | ```yue |
| @@ -118,6 +125,7 @@ print "数字的和是", sum 10, 20 | |||
| 118 | ```yuescript | 125 | ```yuescript |
| 119 | sum = (x, y) -> return x + y | 126 | sum = (x, y) -> return x + y |
| 120 | ``` | 127 | ``` |
| 128 | |||
| 121 | <YueDisplay> | 129 | <YueDisplay> |
| 122 | 130 | ||
| 123 | ```yue | 131 | ```yue |
| @@ -132,6 +140,7 @@ sum = (x, y) -> return x + y | |||
| 132 | mystery = (x, y) -> x + y, x - y | 140 | mystery = (x, y) -> x + y, x - y |
| 133 | a, b = mystery 10, 20 | 141 | a, b = mystery 10, 20 |
| 134 | ``` | 142 | ``` |
| 143 | |||
| 135 | <YueDisplay> | 144 | <YueDisplay> |
| 136 | 145 | ||
| 137 | ```yue | 146 | ```yue |
| @@ -148,6 +157,7 @@ a, b = mystery 10, 20 | |||
| 148 | ```yuescript | 157 | ```yuescript |
| 149 | func = (num) => @value + num | 158 | func = (num) => @value + num |
| 150 | ``` | 159 | ``` |
| 160 | |||
| 151 | <YueDisplay> | 161 | <YueDisplay> |
| 152 | 162 | ||
| 153 | ```yue | 163 | ```yue |
| @@ -165,6 +175,7 @@ my_function = (name = "某物", height = 100) -> | |||
| 165 | print "你好,我是", name | 175 | print "你好,我是", name |
| 166 | print "我的高度是", height | 176 | print "我的高度是", height |
| 167 | ``` | 177 | ``` |
| 178 | |||
| 168 | <YueDisplay> | 179 | <YueDisplay> |
| 169 | 180 | ||
| 170 | ```yue | 181 | ```yue |
| @@ -181,6 +192,7 @@ my_function = (name = "某物", height = 100) -> | |||
| 181 | some_args = (x = 100, y = x + 1000) -> | 192 | some_args = (x = 100, y = x + 1000) -> |
| 182 | print x + y | 193 | print x + y |
| 183 | ``` | 194 | ``` |
| 195 | |||
| 184 | <YueDisplay> | 196 | <YueDisplay> |
| 185 | 197 | ||
| 186 | ```yue | 198 | ```yue |
| @@ -202,6 +214,7 @@ b = x-10 | |||
| 202 | c = x -y | 214 | c = x -y |
| 203 | d = x- z | 215 | d = x- z |
| 204 | ``` | 216 | ``` |
| 217 | |||
| 205 | <YueDisplay> | 218 | <YueDisplay> |
| 206 | 219 | ||
| 207 | ```yue | 220 | ```yue |
| @@ -223,6 +236,7 @@ d = x- z | |||
| 223 | x = func"hello" + 100 | 236 | x = func"hello" + 100 |
| 224 | y = func "hello" + 100 | 237 | y = func "hello" + 100 |
| 225 | ``` | 238 | ``` |
| 239 | |||
| 226 | <YueDisplay> | 240 | <YueDisplay> |
| 227 | 241 | ||
| 228 | ```yue | 242 | ```yue |
| @@ -247,6 +261,7 @@ cool_func 1, 2, | |||
| 247 | 5, 6, | 261 | 5, 6, |
| 248 | 7, 8 | 262 | 7, 8 |
| 249 | ``` | 263 | ``` |
| 264 | |||
| 250 | <YueDisplay> | 265 | <YueDisplay> |
| 251 | 266 | ||
| 252 | ```yue | 267 | ```yue |
| @@ -269,6 +284,7 @@ my_func 5, 6, 7, | |||
| 269 | 9, 1, 2, | 284 | 9, 1, 2, |
| 270 | 5, 4 | 285 | 5, 4 |
| 271 | ``` | 286 | ``` |
| 287 | |||
| 272 | <YueDisplay> | 288 | <YueDisplay> |
| 273 | 289 | ||
| 274 | ```yue | 290 | ```yue |
| @@ -289,6 +305,7 @@ x = [ | |||
| 289 | 8, 9, 10 | 305 | 8, 9, 10 |
| 290 | ] | 306 | ] |
| 291 | ``` | 307 | ``` |
| 308 | |||
| 292 | <YueDisplay> | 309 | <YueDisplay> |
| 293 | 310 | ||
| 294 | ```yue | 311 | ```yue |
| @@ -309,6 +326,7 @@ y = [ my_func 1, 2, 3, | |||
| 309 | 5, 6, 7 | 326 | 5, 6, 7 |
| 310 | ] | 327 | ] |
| 311 | ``` | 328 | ``` |
| 329 | |||
| 312 | <YueDisplay> | 330 | <YueDisplay> |
| 313 | 331 | ||
| 314 | ```yue | 332 | ```yue |
| @@ -335,6 +353,7 @@ if func 1, 2, 3, | |||
| 335 | print "hello" | 353 | print "hello" |
| 336 | print "我在if内部" | 354 | print "我在if内部" |
| 337 | ``` | 355 | ``` |
| 356 | |||
| 338 | <YueDisplay> | 357 | <YueDisplay> |
| 339 | 358 | ||
| 340 | ```yue | 359 | ```yue |
| @@ -373,6 +392,7 @@ f2 = ({a: a1 = 123, :b = 'abc'}, c = {}) -> | |||
| 373 | arg1 = {a: 0} | 392 | arg1 = {a: 0} |
| 374 | f2 arg1, arg2 | 393 | f2 arg1, arg2 |
| 375 | ``` | 394 | ``` |
| 395 | |||
| 376 | <YueDisplay> | 396 | <YueDisplay> |
| 377 | 397 | ||
| 378 | ```yue | 398 | ```yue |
| @@ -402,6 +422,7 @@ findFirstEven = (list): nil -> | |||
| 402 | if sub % 2 == 0 | 422 | if sub % 2 == 0 |
| 403 | return sub | 423 | return sub |
| 404 | ``` | 424 | ``` |
| 425 | |||
| 405 | <YueDisplay> | 426 | <YueDisplay> |
| 406 | 427 | ||
| 407 | ```yue | 428 | ```yue |
| @@ -426,6 +447,7 @@ findFirstEven = (list) -> | |||
| 426 | return sub | 447 | return sub |
| 427 | nil | 448 | nil |
| 428 | ``` | 449 | ``` |
| 450 | |||
| 429 | <YueDisplay> | 451 | <YueDisplay> |
| 430 | 452 | ||
| 431 | ```yue | 453 | ```yue |
| @@ -467,6 +489,7 @@ process = (...args) -> | |||
| 467 | 489 | ||
| 468 | process 1, nil, 3, nil, 5 | 490 | process 1, nil, 3, nil, 5 |
| 469 | ``` | 491 | ``` |
| 492 | |||
| 470 | <YueDisplay> | 493 | <YueDisplay> |
| 471 | 494 | ||
| 472 | ```yue | 495 | ```yue |
diff --git a/doc/docs/zh/doc/functions/function-stubs.md b/doc/docs/zh/doc/functions/function-stubs.md index af08feb..888c3eb 100644 --- a/doc/docs/zh/doc/functions/function-stubs.md +++ b/doc/docs/zh/doc/functions/function-stubs.md | |||
| @@ -24,6 +24,7 @@ run_callback my_object.write | |||
| 24 | -- 让我们把对象捆绑到一个新函数中 | 24 | -- 让我们把对象捆绑到一个新函数中 |
| 25 | run_callback my_object\write | 25 | run_callback my_object\write |
| 26 | ``` | 26 | ``` |
| 27 | |||
| 27 | <YueDisplay> | 28 | <YueDisplay> |
| 28 | 29 | ||
| 29 | ```yue | 30 | ```yue |
diff --git a/doc/docs/zh/doc/getting-started/introduction.md b/doc/docs/zh/doc/getting-started/introduction.md index 827d163..7911363 100644 --- a/doc/docs/zh/doc/getting-started/introduction.md +++ b/doc/docs/zh/doc/getting-started/introduction.md | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | Yue(月)是中文中“月亮”的名称。 | 5 | Yue(月)是中文中“月亮”的名称。 |
| 6 | 6 | ||
| 7 | ## 月之脚本概览 | 7 | ## 月之脚本概览 |
| 8 | |||
| 8 | ```yuescript | 9 | ```yuescript |
| 9 | -- 导入语法 | 10 | -- 导入语法 |
| 10 | import p, to_lua from "yue" | 11 | import p, to_lua from "yue" |
| @@ -49,6 +50,7 @@ with apple | |||
| 49 | -- 类似js的导出语法 | 50 | -- 类似js的导出语法 |
| 50 | export 🌛 = "月之脚本" | 51 | export 🌛 = "月之脚本" |
| 51 | ``` | 52 | ``` |
| 53 | |||
| 52 | <YueDisplay> | 54 | <YueDisplay> |
| 53 | 55 | ||
| 54 | ```yue | 56 | ```yue |
diff --git a/doc/docs/zh/doc/getting-started/usage.md b/doc/docs/zh/doc/getting-started/usage.md index b9d84d4..c9bad2e 100644 --- a/doc/docs/zh/doc/getting-started/usage.md +++ b/doc/docs/zh/doc/getting-started/usage.md | |||
| @@ -4,49 +4,51 @@ | |||
| 4 | 4 | ||
| 5 |   在 Lua 中使用月之脚本模块: | 5 |   在 Lua 中使用月之脚本模块: |
| 6 | 6 | ||
| 7 | * **用法 1** | 7 | - **用法 1** |
| 8 | 8 | ||
| 9 |   在 Lua 中引入 "你的脚本入口文件.yue"。 | 9 |   在 Lua 中引入 "你的脚本入口文件.yue"。 |
| 10 | 10 | ||
| 11 | ```Lua | 11 | ```Lua |
| 12 | require("yue")("你的脚本入口文件") | 12 | require("yue")("你的脚本入口文件") |
| 13 | ``` | 13 | ``` |
| 14 | 14 | ||
| 15 |   当你在同一路径下把 "你的脚本入口文件.yue" 编译成了 "你的脚本入口文件.lua" 时,仍然可以使用这个代码加载 .lua 代码文件。在其余的月之脚本文件中,只需正常使用 **require** 或 **import** 进行脚本引用即可。错误消息中的代码行号也会被正确处理。 | 15 |   当你在同一路径下把 "你的脚本入口文件.yue" 编译成了 "你的脚本入口文件.lua" 时,仍然可以使用这个代码加载 .lua 代码文件。在其余的月之脚本文件中,只需正常使用 **require** 或 **import** 进行脚本引用即可。错误消息中的代码行号也会被正确处理。 |
| 16 | 16 | ||
| 17 | * **用法 2** | 17 | - **用法 2** |
| 18 | 18 | ||
| 19 |   手动引入月之脚本模块并重写错误消息来帮助调试。 | 19 |   手动引入月之脚本模块并重写错误消息来帮助调试。 |
| 20 | ```lua | 20 | |
| 21 | local yue = require("yue") | 21 | ```lua |
| 22 | yue.insert_loaders() | 22 | local yue = require("yue") |
| 23 | local success, result = xpcall(function() | 23 | yue.insert_loaders() |
| 24 | return require("yuescript_module_name") | 24 | local success, result = xpcall(function() |
| 25 | end, function(err) | 25 | return require("yuescript_module_name") |
| 26 | return yue.traceback(err) | 26 | end, function(err) |
| 27 | end) | 27 | return yue.traceback(err) |
| 28 | ``` | 28 | end) |
| 29 | 29 | ``` | |
| 30 | * **用法 3** | 30 | |
| 31 | 31 | - **用法 3** | |
| 32 |   在 Lua 中使用月之脚本编译器功能。 | 32 | |
| 33 | ```lua | 33 |   在 Lua 中使用月之脚本编译器功能。 |
| 34 | local yue = require("yue") | 34 | |
| 35 | local codes, err, globals = yue.to_lua([[ | 35 | ```lua |
| 36 | f = -> | 36 | local yue = require("yue") |
| 37 | print "hello world" | 37 | local codes, err, globals = yue.to_lua([[ |
| 38 | f! | 38 | f = -> |
| 39 | ]],{ | 39 | print "hello world" |
| 40 | implicit_return_root = true, | 40 | f! |
| 41 | reserve_line_number = true, | 41 | ]],{ |
| 42 | lint_global = true, | 42 | implicit_return_root = true, |
| 43 | space_over_tab = false, | 43 | reserve_line_number = true, |
| 44 | options = { | 44 | lint_global = true, |
| 45 | target = "5.4", | 45 | space_over_tab = false, |
| 46 | path = "/script" | 46 | options = { |
| 47 | } | 47 | target = "5.4", |
| 48 | }) | 48 | path = "/script" |
| 49 | ``` | 49 | } |
| 50 | }) | ||
| 51 | ``` | ||
| 50 | 52 | ||
| 51 | ## 月之脚本编译工具 | 53 | ## 月之脚本编译工具 |
| 52 | 54 | ||
diff --git a/doc/docs/zh/doc/language-basics/attributes.md b/doc/docs/zh/doc/language-basics/attributes.md index 3dc3b0b..43bc5f9 100644 --- a/doc/docs/zh/doc/language-basics/attributes.md +++ b/doc/docs/zh/doc/language-basics/attributes.md | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | const a = 123 | 6 | const a = 123 |
| 7 | close _ = <close>: -> print "超出范围。" | 7 | close _ = <close>: -> print "超出范围。" |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -21,6 +22,7 @@ close _ = <close>: -> print "超出范围。" | |||
| 21 | const {:a, :b, c, d} = tb | 22 | const {:a, :b, c, d} = tb |
| 22 | -- a = 1 | 23 | -- a = 1 |
| 23 | ``` | 24 | ``` |
| 25 | |||
| 24 | <YueDisplay> | 26 | <YueDisplay> |
| 25 | 27 | ||
| 26 | ```yue | 28 | ```yue |
| @@ -36,6 +38,7 @@ const {:a, :b, c, d} = tb | |||
| 36 | global const Constant = 123 | 38 | global const Constant = 123 |
| 37 | -- Constant = 1 | 39 | -- Constant = 1 |
| 38 | ``` | 40 | ``` |
| 41 | |||
| 39 | <YueDisplay> | 42 | <YueDisplay> |
| 40 | 43 | ||
| 41 | ```yue | 44 | ```yue |
diff --git a/doc/docs/zh/doc/language-basics/comment.md b/doc/docs/zh/doc/language-basics/comment.md index f6a7b4e..0e69979 100644 --- a/doc/docs/zh/doc/language-basics/comment.md +++ b/doc/docs/zh/doc/language-basics/comment.md | |||
| @@ -12,6 +12,7 @@ str = --[[ | |||
| 12 | 12 | ||
| 13 | func --[[端口]] 3000, --[[ip]] "192.168.1.1" | 13 | func --[[端口]] 3000, --[[ip]] "192.168.1.1" |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
diff --git a/doc/docs/zh/doc/language-basics/literals.md b/doc/docs/zh/doc/language-basics/literals.md index 1592bae..0837c71 100644 --- a/doc/docs/zh/doc/language-basics/literals.md +++ b/doc/docs/zh/doc/language-basics/literals.md | |||
| @@ -12,6 +12,7 @@ some_string = "这是一个字符串 | |||
| 12 | -- 字符串插值只在双引号字符串中可用。 | 12 | -- 字符串插值只在双引号字符串中可用。 |
| 13 | print "我有#{math.random! * 100}%的把握。" | 13 | print "我有#{math.random! * 100}%的把握。" |
| 14 | ``` | 14 | ``` |
| 15 | |||
| 15 | <YueDisplay> | 16 | <YueDisplay> |
| 16 | 17 | ||
| 17 | ```yue | 18 | ```yue |
| @@ -34,8 +35,8 @@ integer = 1_000_000 | |||
| 34 | hex = 0xEF_BB_BF | 35 | hex = 0xEF_BB_BF |
| 35 | binary = 0B10011 | 36 | binary = 0B10011 |
| 36 | ``` | 37 | ``` |
| 37 | <YueDisplay> | ||
| 38 | 38 | ||
| 39 | <YueDisplay> | ||
| 39 | 40 | ||
| 40 | ```yue | 41 | ```yue |
| 41 | integer = 1_000_000 | 42 | integer = 1_000_000 |
| @@ -56,6 +57,7 @@ str = | | |||
| 56 | - item1 | 57 | - item1 |
| 57 | - #{expr} | 58 | - #{expr} |
| 58 | ``` | 59 | ``` |
| 60 | |||
| 59 | <YueDisplay> | 61 | <YueDisplay> |
| 60 | 62 | ||
| 61 | ```yue | 63 | ```yue |
| @@ -79,6 +81,7 @@ fn = -> | |||
| 79 | bar: baz | 81 | bar: baz |
| 80 | return str | 82 | return str |
| 81 | ``` | 83 | ``` |
| 84 | |||
| 82 | <YueDisplay> | 85 | <YueDisplay> |
| 83 | 86 | ||
| 84 | ```yue | 87 | ```yue |
| @@ -100,6 +103,7 @@ str = | | |||
| 100 | path: "C:\Program Files\App" | 103 | path: "C:\Program Files\App" |
| 101 | note: 'He said: "#{Hello}!"' | 104 | note: 'He said: "#{Hello}!"' |
| 102 | ``` | 105 | ``` |
| 106 | |||
| 103 | <YueDisplay> | 107 | <YueDisplay> |
| 104 | 108 | ||
| 105 | ```yue | 109 | ```yue |
diff --git a/doc/docs/zh/doc/language-basics/operator.md b/doc/docs/zh/doc/language-basics/operator.md index 6c9fc5b..d948667 100644 --- a/doc/docs/zh/doc/language-basics/operator.md +++ b/doc/docs/zh/doc/language-basics/operator.md | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | tb\func! if tb ~= nil | 6 | tb\func! if tb ~= nil |
| 7 | tb::func! if tb != nil | 7 | tb::func! if tb != nil |
| 8 | ``` | 8 | ``` |
| 9 | |||
| 9 | <YueDisplay> | 10 | <YueDisplay> |
| 10 | 11 | ||
| 11 | ```yue | 12 | ```yue |
| @@ -27,6 +28,7 @@ a = 5 | |||
| 27 | print 1 <= a <= 10 | 28 | print 1 <= a <= 10 |
| 28 | -- 输出:true | 29 | -- 输出:true |
| 29 | ``` | 30 | ``` |
| 31 | |||
| 30 | <YueDisplay> | 32 | <YueDisplay> |
| 31 | 33 | ||
| 32 | ```yue | 34 | ```yue |
| @@ -64,6 +66,7 @@ print v(1) > v(2) <= v(3) | |||
| 64 | false | 66 | false |
| 65 | ]] | 67 | ]] |
| 66 | ``` | 68 | ``` |
| 69 | |||
| 67 | <YueDisplay> | 70 | <YueDisplay> |
| 68 | 71 | ||
| 69 | ```yue | 72 | ```yue |
| @@ -101,6 +104,7 @@ print v(1) > v(2) <= v(3) | |||
| 101 | tab = [] | 104 | tab = [] |
| 102 | tab[] = "Value" | 105 | tab[] = "Value" |
| 103 | ``` | 106 | ``` |
| 107 | |||
| 104 | <YueDisplay> | 108 | <YueDisplay> |
| 105 | 109 | ||
| 106 | ```yue | 110 | ```yue |
| @@ -118,6 +122,7 @@ tbB = [4, 5, 6] | |||
| 118 | tbA[] = ...tbB | 122 | tbA[] = ...tbB |
| 119 | -- tbA 现在为 [1, 2, 3, 4, 5, 6] | 123 | -- tbA 现在为 [1, 2, 3, 4, 5, 6] |
| 120 | ``` | 124 | ``` |
| 125 | |||
| 121 | <YueDisplay> | 126 | <YueDisplay> |
| 122 | 127 | ||
| 123 | ```yue | 128 | ```yue |
| @@ -149,6 +154,7 @@ a = {1, 2, 3, x: 1} | |||
| 149 | b = {4, 5, y: 1} | 154 | b = {4, 5, y: 1} |
| 150 | merge = {...a, ...b} | 155 | merge = {...a, ...b} |
| 151 | ``` | 156 | ``` |
| 157 | |||
| 152 | <YueDisplay> | 158 | <YueDisplay> |
| 153 | 159 | ||
| 154 | ```yue | 160 | ```yue |
| @@ -179,6 +185,7 @@ last = data.items[#] | |||
| 179 | second_last = data.items[#-1] | 185 | second_last = data.items[#-1] |
| 180 | data.items[#] = 1 | 186 | data.items[#] = 1 |
| 181 | ``` | 187 | ``` |
| 188 | |||
| 182 | <YueDisplay> | 189 | <YueDisplay> |
| 183 | 190 | ||
| 184 | ```yue | 191 | ```yue |
| @@ -212,6 +219,7 @@ print d.value | |||
| 212 | 219 | ||
| 213 | close _ = <close>: -> print "超出范围" | 220 | close _ = <close>: -> print "超出范围" |
| 214 | ``` | 221 | ``` |
| 222 | |||
| 215 | <YueDisplay> | 223 | <YueDisplay> |
| 216 | 224 | ||
| 217 | ```yue | 225 | ```yue |
| @@ -245,8 +253,8 @@ print tb.value | |||
| 245 | tb.<> = __index: {item: "hello"} | 253 | tb.<> = __index: {item: "hello"} |
| 246 | print tb.item | 254 | print tb.item |
| 247 | ``` | 255 | ``` |
| 248 | <YueDisplay> | ||
| 249 | 256 | ||
| 257 | <YueDisplay> | ||
| 250 | 258 | ||
| 251 | ```yue | 259 | ```yue |
| 252 | -- 使用包含字段 "value" 的元表创建 | 260 | -- 使用包含字段 "value" 的元表创建 |
| @@ -267,6 +275,7 @@ print tb.item | |||
| 267 | {item, :new, :<close>, <index>: getter} = tb | 275 | {item, :new, :<close>, <index>: getter} = tb |
| 268 | print item, new, close, getter | 276 | print item, new, close, getter |
| 269 | ``` | 277 | ``` |
| 278 | |||
| 270 | <YueDisplay> | 279 | <YueDisplay> |
| 271 | 280 | ||
| 272 | ```yue | 281 | ```yue |
| @@ -294,6 +303,7 @@ with? io.open "test.txt", "w" | |||
| 294 | \write "你好" | 303 | \write "你好" |
| 295 | \close! | 304 | \close! |
| 296 | ``` | 305 | ``` |
| 306 | |||
| 297 | <YueDisplay> | 307 | <YueDisplay> |
| 298 | 308 | ||
| 299 | ```yue | 309 | ```yue |
| @@ -330,6 +340,7 @@ readFile "example.txt" | |||
| 330 | |> render | 340 | |> render |
| 331 | 341 | ||
| 332 | ``` | 342 | ``` |
| 343 | |||
| 333 | <YueDisplay> | 344 | <YueDisplay> |
| 334 | 345 | ||
| 335 | ```yue | 346 | ```yue |
| @@ -358,6 +369,7 @@ func a ?? {} | |||
| 358 | 369 | ||
| 359 | a ??= false | 370 | a ??= false |
| 360 | ``` | 371 | ``` |
| 372 | |||
| 361 | <YueDisplay> | 373 | <YueDisplay> |
| 362 | 374 | ||
| 363 | ```yue | 375 | ```yue |
| @@ -414,6 +426,7 @@ tb = | |||
| 414 | func: => @value + 2 | 426 | func: => @value + 2 |
| 415 | tb: { } | 427 | tb: { } |
| 416 | ``` | 428 | ``` |
| 429 | |||
| 417 | <YueDisplay> | 430 | <YueDisplay> |
| 418 | 431 | ||
| 419 | ```yue | 432 | ```yue |
diff --git a/doc/docs/zh/doc/language-basics/whitespace.md b/doc/docs/zh/doc/language-basics/whitespace.md index 1886e23..e27165f 100644 --- a/doc/docs/zh/doc/language-basics/whitespace.md +++ b/doc/docs/zh/doc/language-basics/whitespace.md | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | a = 1; b = 2; print a + b | 10 | a = 1; b = 2; print a + b |
| 11 | ``` | 11 | ``` |
| 12 | |||
| 12 | <YueDisplay> | 13 | <YueDisplay> |
| 13 | 14 | ||
| 14 | ```yue | 15 | ```yue |
| @@ -29,6 +30,7 @@ Rx.Observable | |||
| 29 | \map (value) -> value .. '!' | 30 | \map (value) -> value .. '!' |
| 30 | \subscribe print | 31 | \subscribe print |
| 31 | ``` | 32 | ``` |
| 33 | |||
| 32 | <YueDisplay> | 34 | <YueDisplay> |
| 33 | 35 | ||
| 34 | ```yue | 36 | ```yue |
diff --git a/doc/docs/zh/doc/objects/object-oriented-programming.md b/doc/docs/zh/doc/objects/object-oriented-programming.md index 9eb94d8..04f816a 100644 --- a/doc/docs/zh/doc/objects/object-oriented-programming.md +++ b/doc/docs/zh/doc/objects/object-oriented-programming.md | |||
| @@ -15,6 +15,7 @@ class Inventory | |||
| 15 | else | 15 | else |
| 16 | @items[name] = 1 | 16 | @items[name] = 1 |
| 17 | ``` | 17 | ``` |
| 18 | |||
| 18 | <YueDisplay> | 19 | <YueDisplay> |
| 19 | 20 | ||
| 20 | ```yue | 21 | ```yue |
| @@ -44,8 +45,8 @@ inv = Inventory! | |||
| 44 | inv\add_item "t-shirt" | 45 | inv\add_item "t-shirt" |
| 45 | inv\add_item "pants" | 46 | inv\add_item "pants" |
| 46 | ``` | 47 | ``` |
| 47 | <YueDisplay> | ||
| 48 | 48 | ||
| 49 | <YueDisplay> | ||
| 49 | 50 | ||
| 50 | ```yue | 51 | ```yue |
| 51 | inv = Inventory! | 52 | inv = Inventory! |
| @@ -76,6 +77,7 @@ b\give_item "shirt" | |||
| 76 | -- 会同时打印出裤子和衬衫 | 77 | -- 会同时打印出裤子和衬衫 |
| 77 | print item for item in *a.clothes | 78 | print item for item in *a.clothes |
| 78 | ``` | 79 | ``` |
| 80 | |||
| 79 | <YueDisplay> | 81 | <YueDisplay> |
| 80 | 82 | ||
| 81 | ```yue | 83 | ```yue |
| @@ -103,6 +105,7 @@ class Person | |||
| 103 | new: => | 105 | new: => |
| 104 | @clothes = [] | 106 | @clothes = [] |
| 105 | ``` | 107 | ``` |
| 108 | |||
| 106 | <YueDisplay> | 109 | <YueDisplay> |
| 107 | 110 | ||
| 108 | ```yue | 111 | ```yue |
| @@ -124,6 +127,7 @@ class BackPack extends Inventory | |||
| 124 | if #@items > size then error "背包已满" | 127 | if #@items > size then error "背包已满" |
| 125 | super name | 128 | super name |
| 126 | ``` | 129 | ``` |
| 130 | |||
| 127 | <YueDisplay> | 131 | <YueDisplay> |
| 128 | 132 | ||
| 129 | ```yue | 133 | ```yue |
| @@ -150,6 +154,7 @@ class Shelf | |||
| 150 | -- 将打印: Shelf 被 Cupboard 继承 | 154 | -- 将打印: Shelf 被 Cupboard 继承 |
| 151 | class Cupboard extends Shelf | 155 | class Cupboard extends Shelf |
| 152 | ``` | 156 | ``` |
| 157 | |||
| 153 | <YueDisplay> | 158 | <YueDisplay> |
| 154 | 159 | ||
| 155 | ```yue | 160 | ```yue |
| @@ -186,6 +191,7 @@ class MyClass extends ParentClass | |||
| 186 | -- super 作为值等于父类: | 191 | -- super 作为值等于父类: |
| 187 | assert super == ParentClass | 192 | assert super == ParentClass |
| 188 | ``` | 193 | ``` |
| 194 | |||
| 189 | <YueDisplay> | 195 | <YueDisplay> |
| 190 | 196 | ||
| 191 | ```yue | 197 | ```yue |
| @@ -214,6 +220,7 @@ assert b.__class == BackPack | |||
| 214 | 220 | ||
| 215 | print BackPack.size -- 打印 10 | 221 | print BackPack.size -- 打印 10 |
| 216 | ``` | 222 | ``` |
| 223 | |||
| 217 | <YueDisplay> | 224 | <YueDisplay> |
| 218 | 225 | ||
| 219 | ```yue | 226 | ```yue |
| @@ -235,13 +242,14 @@ print BackPack.size -- 打印 10 | |||
| 235 | 242 | ||
| 236 |   如果在类对象的元表中找不到某个属性,系统会从基表中检索该属性。这就意味着我们可以直接从类本身访问到其方法和属性。 | 243 |   如果在类对象的元表中找不到某个属性,系统会从基表中检索该属性。这就意味着我们可以直接从类本身访问到其方法和属性。 |
| 237 | 244 | ||
| 238 |   需要特别注意的是,对类对象的赋值并不会影响到基表,因此这不是向实例添加新方法的正确方式。相反,需要直接修改基表。关于这点,可以参考下面的 “__base” 字段。 | 245 |   需要特别注意的是,对类对象的赋值并不会影响到基表,因此这不是向实例添加新方法的正确方式。相反,需要直接修改基表。关于这点,可以参考下面的 “\_\_base” 字段。 |
| 239 | 246 | ||
| 240 |   此外,类对象包含几个特殊的属性:当类被声明时,类的名称会作为一个字符串存储在类对象的 “__name” 字段中。 | 247 |   此外,类对象包含几个特殊的属性:当类被声明时,类的名称会作为一个字符串存储在类对象的 “\_\_name” 字段中。 |
| 241 | 248 | ||
| 242 | ```yuescript | 249 | ```yuescript |
| 243 | print BackPack.__name -- 打印 Backpack | 250 | print BackPack.__name -- 打印 Backpack |
| 244 | ``` | 251 | ``` |
| 252 | |||
| 245 | <YueDisplay> | 253 | <YueDisplay> |
| 246 | 254 | ||
| 247 | ```yue | 255 | ```yue |
| @@ -267,6 +275,7 @@ Things\some_func! | |||
| 267 | -- 类变量在实例中不可见 | 275 | -- 类变量在实例中不可见 |
| 268 | assert Things().some_func == nil | 276 | assert Things().some_func == nil |
| 269 | ``` | 277 | ``` |
| 278 | |||
| 270 | <YueDisplay> | 279 | <YueDisplay> |
| 271 | 280 | ||
| 272 | ```yue | 281 | ```yue |
| @@ -295,6 +304,7 @@ Counter! | |||
| 295 | 304 | ||
| 296 | print Counter.count -- 输出 2 | 305 | print Counter.count -- 输出 2 |
| 297 | ``` | 306 | ``` |
| 307 | |||
| 298 | <YueDisplay> | 308 | <YueDisplay> |
| 299 | 309 | ||
| 300 | ```yue | 310 | ```yue |
| @@ -317,6 +327,7 @@ print Counter.count -- 输出 2 | |||
| 317 | ```yuescript | 327 | ```yuescript |
| 318 | @@hello 1,2,3,4 | 328 | @@hello 1,2,3,4 |
| 319 | ``` | 329 | ``` |
| 330 | |||
| 320 | <YueDisplay> | 331 | <YueDisplay> |
| 321 | 332 | ||
| 322 | ```yue | 333 | ```yue |
| @@ -335,6 +346,7 @@ print Counter.count -- 输出 2 | |||
| 335 | class Things | 346 | class Things |
| 336 | @class_var = "hello world" | 347 | @class_var = "hello world" |
| 337 | ``` | 348 | ``` |
| 349 | |||
| 338 | <YueDisplay> | 350 | <YueDisplay> |
| 339 | 351 | ||
| 340 | ```yue | 352 | ```yue |
| @@ -356,6 +368,7 @@ class MoreThings | |||
| 356 | some_method: => | 368 | some_method: => |
| 357 | log "hello world: " .. secret | 369 | log "hello world: " .. secret |
| 358 | ``` | 370 | ``` |
| 371 | |||
| 359 | <YueDisplay> | 372 | <YueDisplay> |
| 360 | 373 | ||
| 361 | ```yue | 374 | ```yue |
| @@ -379,6 +392,7 @@ class MoreThings | |||
| 379 | assert @ == self | 392 | assert @ == self |
| 380 | assert @@ == self.__class | 393 | assert @@ == self.__class |
| 381 | ``` | 394 | ``` |
| 395 | |||
| 382 | <YueDisplay> | 396 | <YueDisplay> |
| 383 | 397 | ||
| 384 | ```yue | 398 | ```yue |
| @@ -393,6 +407,7 @@ assert @@ == self.__class | |||
| 393 | ```yuescript | 407 | ```yuescript |
| 394 | some_instance_method = (...) => @@ ... | 408 | some_instance_method = (...) => @@ ... |
| 395 | ``` | 409 | ``` |
| 410 | |||
| 396 | <YueDisplay> | 411 | <YueDisplay> |
| 397 | 412 | ||
| 398 | ```yue | 413 | ```yue |
| @@ -418,6 +433,7 @@ class Something | |||
| 418 | @@biz = biz | 433 | @@biz = biz |
| 419 | @@baz = baz | 434 | @@baz = baz |
| 420 | ``` | 435 | ``` |
| 436 | |||
| 421 | <YueDisplay> | 437 | <YueDisplay> |
| 422 | 438 | ||
| 423 | ```yue | 439 | ```yue |
| @@ -443,6 +459,7 @@ new = (@fieldA, @fieldB) => @ | |||
| 443 | obj = new {}, 123, "abc" | 459 | obj = new {}, 123, "abc" |
| 444 | print obj | 460 | print obj |
| 445 | ``` | 461 | ``` |
| 462 | |||
| 446 | <YueDisplay> | 463 | <YueDisplay> |
| 447 | 464 | ||
| 448 | ```yue | 465 | ```yue |
| @@ -462,6 +479,7 @@ x = class Bucket | |||
| 462 | drops: 0 | 479 | drops: 0 |
| 463 | add_drop: => @drops += 1 | 480 | add_drop: => @drops += 1 |
| 464 | ``` | 481 | ``` |
| 482 | |||
| 465 | <YueDisplay> | 483 | <YueDisplay> |
| 466 | 484 | ||
| 467 | ```yue | 485 | ```yue |
| @@ -482,6 +500,7 @@ BigBucket = class extends Bucket | |||
| 482 | 500 | ||
| 483 | assert Bucket.__name == "BigBucket" | 501 | assert Bucket.__name == "BigBucket" |
| 484 | ``` | 502 | ``` |
| 503 | |||
| 485 | <YueDisplay> | 504 | <YueDisplay> |
| 486 | 505 | ||
| 487 | ```yue | 506 | ```yue |
| @@ -498,6 +517,7 @@ assert Bucket.__name == "BigBucket" | |||
| 498 | ```yuescript | 517 | ```yuescript |
| 499 | x = class | 518 | x = class |
| 500 | ``` | 519 | ``` |
| 520 | |||
| 501 | <YueDisplay> | 521 | <YueDisplay> |
| 502 | 522 | ||
| 503 | ```yue | 523 | ```yue |
| @@ -527,6 +547,7 @@ y\func! | |||
| 527 | 547 | ||
| 528 | assert y.__class.__parent ~= X -- X 不是 Y 的父类 | 548 | assert y.__class.__parent ~= X -- X 不是 Y 的父类 |
| 529 | ``` | 549 | ``` |
| 550 | |||
| 530 | <YueDisplay> | 551 | <YueDisplay> |
| 531 | 552 | ||
| 532 | ```yue | 553 | ```yue |
diff --git a/doc/docs/zh/doc/objects/with-statement.md b/doc/docs/zh/doc/objects/with-statement.md index fbd3633..0925050 100644 --- a/doc/docs/zh/doc/objects/with-statement.md +++ b/doc/docs/zh/doc/objects/with-statement.md | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | # with 语句 | 1 | # with 语句 |
| 2 | 2 | ||
| 3 | |||
| 4 | 在编写 Lua 代码时,我们在创建对象后的常见操作是立即调用这个对象一系列操作函数并设置一系列属性。 | 3 | 在编写 Lua 代码时,我们在创建对象后的常见操作是立即调用这个对象一系列操作函数并设置一系列属性。 |
| 5 | 4 | ||
| 6 | 这导致在代码中多次重复引用对象的名称,增加了不必要的文本噪音。一个常见的解决方案是在创建对象时,在构造函数传入一个表,该表包含要覆盖设置的键和值的集合。这样做的缺点是该对象的构造函数必须支持这种初始化形式。 | 5 | 这导致在代码中多次重复引用对象的名称,增加了不必要的文本噪音。一个常见的解决方案是在创建对象时,在构造函数传入一个表,该表包含要覆盖设置的键和值的集合。这样做的缺点是该对象的构造函数必须支持这种初始化形式。 |
| @@ -16,6 +15,7 @@ with Person! | |||
| 16 | \save! | 15 | \save! |
| 17 | print .name | 16 | print .name |
| 18 | ``` | 17 | ``` |
| 18 | |||
| 19 | <YueDisplay> | 19 | <YueDisplay> |
| 20 | 20 | ||
| 21 | ```yue | 21 | ```yue |
| @@ -34,6 +34,7 @@ with 语句也可以用作一个表达式,并返回它的代码块正在处理 | |||
| 34 | file = with File "favorite_foods.txt" | 34 | file = with File "favorite_foods.txt" |
| 35 | \set_encoding "utf8" | 35 | \set_encoding "utf8" |
| 36 | ``` | 36 | ``` |
| 37 | |||
| 37 | <YueDisplay> | 38 | <YueDisplay> |
| 38 | 39 | ||
| 39 | ```yue | 40 | ```yue |
| @@ -53,6 +54,7 @@ create_person = (name, relatives) -> | |||
| 53 | 54 | ||
| 54 | me = create_person "Leaf", [dad, mother, sister] | 55 | me = create_person "Leaf", [dad, mother, sister] |
| 55 | ``` | 56 | ``` |
| 57 | |||
| 56 | <YueDisplay> | 58 | <YueDisplay> |
| 57 | 59 | ||
| 58 | ```yue | 60 | ```yue |
| @@ -75,6 +77,7 @@ with str := "你好" | |||
| 75 | print "原始:", str | 77 | print "原始:", str |
| 76 | print "大写:", \upper! | 78 | print "大写:", \upper! |
| 77 | ``` | 79 | ``` |
| 80 | |||
| 78 | <YueDisplay> | 81 | <YueDisplay> |
| 79 | 82 | ||
| 80 | ```yue | 83 | ```yue |
| @@ -96,6 +99,7 @@ with tb | |||
| 96 | ["key-name"] = value | 99 | ["key-name"] = value |
| 97 | [] = "abc" -- 追加到 "tb" | 100 | [] = "abc" -- 追加到 "tb" |
| 98 | ``` | 101 | ``` |
| 102 | |||
| 99 | <YueDisplay> | 103 | <YueDisplay> |
| 100 | 104 | ||
| 101 | ```yue | 105 | ```yue |
| @@ -116,6 +120,7 @@ with tb | |||
| 116 | with? obj | 120 | with? obj |
| 117 | print obj.name | 121 | print obj.name |
| 118 | ``` | 122 | ``` |
| 123 | |||
| 119 | <YueDisplay> | 124 | <YueDisplay> |
| 120 | 125 | ||
| 121 | ```yue | 126 | ```yue |
diff --git a/doc/docs/zh/doc/reference/license-mit.md b/doc/docs/zh/doc/reference/license-mit.md index 24b5b15..7979663 100644 --- a/doc/docs/zh/doc/reference/license-mit.md +++ b/doc/docs/zh/doc/reference/license-mit.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # MIT 许可证 | 1 | # MIT 许可证 |
| 2 | 2 | ||
| 3 | 版权 (c) 2017-2026 李瑾 \<dragon-fly@qq.com\> | 3 | 版权 (c) 2017-2026 李瑾 \<dragon-fly@qq.com\> |
| 4 | 4 | ||
| 5 | 特此免费授予任何获得本软件副本和相关文档文件(下称“软件”)的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、转授许可和/或出售该软件副本,以及再授权被配发了本软件的人如上的权利,须在下列条件下: | 5 | 特此免费授予任何获得本软件副本和相关文档文件(下称“软件”)的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、转授许可和/或出售该软件副本,以及再授权被配发了本软件的人如上的权利,须在下列条件下: |
| 6 | 上述版权声明和本许可声明应包含在该软件的所有副本或实质成分中。 | 6 | 上述版权声明和本许可声明应包含在该软件的所有副本或实质成分中。 |
diff --git a/doc/docs/zh/doc/reference/the-yuescript-library.md b/doc/docs/zh/doc/reference/the-yuescript-library.md index 54e26f7..9565b01 100644 --- a/doc/docs/zh/doc/reference/the-yuescript-library.md +++ b/doc/docs/zh/doc/reference/the-yuescript-library.md | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | 月之脚本版本。 | 17 | 月之脚本版本。 |
| 18 | 18 | ||
| 19 | **签名:** | 19 | **签名:** |
| 20 | |||
| 20 | ```lua | 21 | ```lua |
| 21 | version: string | 22 | version: string |
| 22 | ``` | 23 | ``` |
| @@ -30,6 +31,7 @@ version: string | |||
| 30 | 当前平台的文件分隔符。 | 31 | 当前平台的文件分隔符。 |
| 31 | 32 | ||
| 32 | **签名:** | 33 | **签名:** |
| 34 | |||
| 33 | ```lua | 35 | ```lua |
| 34 | dirsep: string | 36 | dirsep: string |
| 35 | ``` | 37 | ``` |
| @@ -43,6 +45,7 @@ dirsep: string | |||
| 43 | 编译模块代码缓存。 | 45 | 编译模块代码缓存。 |
| 44 | 46 | ||
| 45 | **签名:** | 47 | **签名:** |
| 48 | |||
| 46 | ```lua | 49 | ```lua |
| 47 | yue_compiled: {string: string} | 50 | yue_compiled: {string: string} |
| 48 | ``` | 51 | ``` |
| @@ -56,6 +59,7 @@ yue_compiled: {string: string} | |||
| 56 | 月之脚本的编译函数。它将 YueScript 代码编译为 Lua 代码。 | 59 | 月之脚本的编译函数。它将 YueScript 代码编译为 Lua 代码。 |
| 57 | 60 | ||
| 58 | **签名:** | 61 | **签名:** |
| 62 | |||
| 59 | ```lua | 63 | ```lua |
| 60 | to_lua: function(code: string, config?: Config): | 64 | to_lua: function(code: string, config?: Config): |
| 61 | --[[codes]] string | nil, | 65 | --[[codes]] string | nil, |
| @@ -65,17 +69,17 @@ to_lua: function(code: string, config?: Config): | |||
| 65 | 69 | ||
| 66 | **参数:** | 70 | **参数:** |
| 67 | 71 | ||
| 68 | | 参数名 | 类型 | 描述 | | 72 | | 参数名 | 类型 | 描述 | |
| 69 | | --- | --- | --- | | 73 | | ------ | ------ | ------------------- | |
| 70 | | code | string | YueScript 代码。 | | 74 | | code | string | YueScript 代码。 | |
| 71 | | config | Config | [可选] 编译器选项。 | | 75 | | config | Config | [可选] 编译器选项。 | |
| 72 | 76 | ||
| 73 | **返回值:** | 77 | **返回值:** |
| 74 | 78 | ||
| 75 | | 返回类型 | 描述 | | 79 | | 返回类型 | 描述 | |
| 76 | | --- | --- | | 80 | | ----------------------------------- | ------------------------------------------------------------------------------------------ | |
| 77 | | string \| nil | 编译后的 Lua 代码,如果编译失败则为 nil。 | | 81 | | string \| nil | 编译后的 Lua 代码,如果编译失败则为 nil。 | |
| 78 | | string \| nil | 错误消息,如果编译成功则为 nil。 | | 82 | | string \| nil | 错误消息,如果编译成功则为 nil。 | |
| 79 | | {{string, integer, integer}} \| nil | 代码中出现的全局变量(带有名称、行和列),如果编译器选项 `lint_global` 为 false 则为 nil。 | | 83 | | {{string, integer, integer}} \| nil | 代码中出现的全局变量(带有名称、行和列),如果编译器选项 `lint_global` 为 false 则为 nil。 | |
| 80 | 84 | ||
| 81 | ### file_exist | 85 | ### file_exist |
| @@ -87,21 +91,22 @@ to_lua: function(code: string, config?: Config): | |||
| 87 | 检查源文件是否存在的函数。可以覆盖该函数以自定义行为。 | 91 | 检查源文件是否存在的函数。可以覆盖该函数以自定义行为。 |
| 88 | 92 | ||
| 89 | **签名:** | 93 | **签名:** |
| 94 | |||
| 90 | ```lua | 95 | ```lua |
| 91 | file_exist: function(filename: string): boolean | 96 | file_exist: function(filename: string): boolean |
| 92 | ``` | 97 | ``` |
| 93 | 98 | ||
| 94 | **参数:** | 99 | **参数:** |
| 95 | 100 | ||
| 96 | | 参数名 | 类型 | 描述 | | 101 | | 参数名 | 类型 | 描述 | |
| 97 | | --- | --- | --- | | 102 | | -------- | ------ | -------- | |
| 98 | | filename | string | 文件名。 | | 103 | | filename | string | 文件名。 | |
| 99 | 104 | ||
| 100 | **返回值:** | 105 | **返回值:** |
| 101 | 106 | ||
| 102 | | 返回类型 | 描述 | | 107 | | 返回类型 | 描述 | |
| 103 | | --- | --- | | 108 | | -------- | -------------- | |
| 104 | | boolean | 文件是否存在。 | | 109 | | boolean | 文件是否存在。 | |
| 105 | 110 | ||
| 106 | ### read_file | 111 | ### read_file |
| 107 | 112 | ||
| @@ -112,21 +117,22 @@ file_exist: function(filename: string): boolean | |||
| 112 | 读取源文件的函数。可以覆盖该函数以自定义行为。 | 117 | 读取源文件的函数。可以覆盖该函数以自定义行为。 |
| 113 | 118 | ||
| 114 | **签名:** | 119 | **签名:** |
| 120 | |||
| 115 | ```lua | 121 | ```lua |
| 116 | read_file: function(filename: string): string | 122 | read_file: function(filename: string): string |
| 117 | ``` | 123 | ``` |
| 118 | 124 | ||
| 119 | **参数:** | 125 | **参数:** |
| 120 | 126 | ||
| 121 | | 参数名 | 类型 | 描述 | | 127 | | 参数名 | 类型 | 描述 | |
| 122 | | --- | --- | --- | | 128 | | -------- | ------ | -------- | |
| 123 | | filename | string | 文件名。 | | 129 | | filename | string | 文件名。 | |
| 124 | 130 | ||
| 125 | **返回值:** | 131 | **返回值:** |
| 126 | 132 | ||
| 127 | | 返回类型 | 描述 | | 133 | | 返回类型 | 描述 | |
| 128 | | --- | --- | | 134 | | -------- | ---------- | |
| 129 | | string | 文件内容。 | | 135 | | string | 文件内容。 | |
| 130 | 136 | ||
| 131 | ### insert_loader | 137 | ### insert_loader |
| 132 | 138 | ||
| @@ -137,21 +143,22 @@ read_file: function(filename: string): string | |||
| 137 | 将 YueScript 加载器插入到 Lua 包加载器(搜索器)中。 | 143 | 将 YueScript 加载器插入到 Lua 包加载器(搜索器)中。 |
| 138 | 144 | ||
| 139 | **签名:** | 145 | **签名:** |
| 146 | |||
| 140 | ```lua | 147 | ```lua |
| 141 | insert_loader: function(pos?: integer): boolean | 148 | insert_loader: function(pos?: integer): boolean |
| 142 | ``` | 149 | ``` |
| 143 | 150 | ||
| 144 | **参数:** | 151 | **参数:** |
| 145 | 152 | ||
| 146 | | 参数名 | 类型 | 描述 | | 153 | | 参数名 | 类型 | 描述 | |
| 147 | | --- | --- | --- | | 154 | | ------ | ------- | ------------------------------------- | |
| 148 | | pos | integer | [可选] 要插入加载器的位置。默认为 3。 | | 155 | | pos | integer | [可选] 要插入加载器的位置。默认为 3。 | |
| 149 | 156 | ||
| 150 | **返回值:** | 157 | **返回值:** |
| 151 | 158 | ||
| 152 | | 返回类型 | 描述 | | 159 | | 返回类型 | 描述 | |
| 153 | | --- | --- | | 160 | | -------- | ---------------------------------------------------- | |
| 154 | | boolean | 是否成功插入加载器。如果加载器已经插入,则返回失败。 | | 161 | | boolean | 是否成功插入加载器。如果加载器已经插入,则返回失败。 | |
| 155 | 162 | ||
| 156 | ### remove_loader | 163 | ### remove_loader |
| 157 | 164 | ||
| @@ -162,15 +169,16 @@ insert_loader: function(pos?: integer): boolean | |||
| 162 | 从 Lua 包加载器(搜索器)中移除 YueScript 加载器。 | 169 | 从 Lua 包加载器(搜索器)中移除 YueScript 加载器。 |
| 163 | 170 | ||
| 164 | **签名:** | 171 | **签名:** |
| 172 | |||
| 165 | ```lua | 173 | ```lua |
| 166 | remove_loader: function(): boolean | 174 | remove_loader: function(): boolean |
| 167 | ``` | 175 | ``` |
| 168 | 176 | ||
| 169 | **返回值:** | 177 | **返回值:** |
| 170 | 178 | ||
| 171 | | 返回类型 | 描述 | | 179 | | 返回类型 | 描述 | |
| 172 | | --- | --- | | 180 | | -------- | -------------------------------------------------- | |
| 173 | | boolean | 是否成功移除加载器。如果加载器未插入,则返回失败。 | | 181 | | boolean | 是否成功移除加载器。如果加载器未插入,则返回失败。 | |
| 174 | 182 | ||
| 175 | ### loadstring | 183 | ### loadstring |
| 176 | 184 | ||
| @@ -181,6 +189,7 @@ remove_loader: function(): boolean | |||
| 181 | 将 YueScript 代码字符串加载为一个函数。 | 189 | 将 YueScript 代码字符串加载为一个函数。 |
| 182 | 190 | ||
| 183 | **签名:** | 191 | **签名:** |
| 192 | |||
| 184 | ```lua | 193 | ```lua |
| 185 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): | 194 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): |
| 186 | --[[loaded function]] nil | function(...: any): (any...), | 195 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -189,19 +198,19 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 189 | 198 | ||
| 190 | **参数:** | 199 | **参数:** |
| 191 | 200 | ||
| 192 | | 参数名 | 类型 | 描述 | | 201 | | 参数名 | 类型 | 描述 | |
| 193 | | --- | --- | --- | | 202 | | --------- | ------ | ------------------- | |
| 194 | | input | string | YueScript 代码。 | | 203 | | input | string | YueScript 代码。 | |
| 195 | | chunkname | string | 代码块的名称。 | | 204 | | chunkname | string | 代码块的名称。 | |
| 196 | | env | table | 环境表。 | | 205 | | env | table | 环境表。 | |
| 197 | | config | Config | [可选] 编译器选项。 | | 206 | | config | Config | [可选] 编译器选项。 | |
| 198 | 207 | ||
| 199 | **返回值:** | 208 | **返回值:** |
| 200 | 209 | ||
| 201 | | 返回类型 | 描述 | | 210 | | 返回类型 | 描述 | |
| 202 | | --- | --- | | 211 | | --------------- | ---------------------------------- | |
| 203 | | function \| nil | 加载的函数,如果加载失败则为 nil。 | | 212 | | function \| nil | 加载的函数,如果加载失败则为 nil。 | |
| 204 | | string \| nil | 错误消息,如果加载成功则为 nil。 | | 213 | | string \| nil | 错误消息,如果加载成功则为 nil。 | |
| 205 | 214 | ||
| 206 | ### loadstring | 215 | ### loadstring |
| 207 | 216 | ||
| @@ -212,6 +221,7 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 212 | 将 YueScript 代码字符串加载为一个函数。 | 221 | 将 YueScript 代码字符串加载为一个函数。 |
| 213 | 222 | ||
| 214 | **签名:** | 223 | **签名:** |
| 224 | |||
| 215 | ```lua | 225 | ```lua |
| 216 | loadstring: function(input: string, chunkname: string, config?: Config): | 226 | loadstring: function(input: string, chunkname: string, config?: Config): |
| 217 | --[[loaded function]] nil | function(...: any): (any...), | 227 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -220,18 +230,18 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 220 | 230 | ||
| 221 | **参数:** | 231 | **参数:** |
| 222 | 232 | ||
| 223 | | 参数名 | 类型 | 描述 | | 233 | | 参数名 | 类型 | 描述 | |
| 224 | | --- | --- | --- | | 234 | | --------- | ------ | ------------------- | |
| 225 | | input | string | YueScript 代码。 | | 235 | | input | string | YueScript 代码。 | |
| 226 | | chunkname | string | 代码块的名称。 | | 236 | | chunkname | string | 代码块的名称。 | |
| 227 | | config | Config | [可选] 编译器选项。 | | 237 | | config | Config | [可选] 编译器选项。 | |
| 228 | 238 | ||
| 229 | **返回值:** | 239 | **返回值:** |
| 230 | 240 | ||
| 231 | | 返回类型 | 描述 | | 241 | | 返回类型 | 描述 | |
| 232 | | --- | --- | | 242 | | --------------- | ---------------------------------- | |
| 233 | | function \| nil | 加载的函数,如果加载失败则为 nil。 | | 243 | | function \| nil | 加载的函数,如果加载失败则为 nil。 | |
| 234 | | string \| nil | 错误消息,如果加载成功则为 nil。 | | 244 | | string \| nil | 错误消息,如果加载成功则为 nil。 | |
| 235 | 245 | ||
| 236 | ### loadstring | 246 | ### loadstring |
| 237 | 247 | ||
| @@ -242,6 +252,7 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 242 | 将 YueScript 代码字符串加载为一个函数。 | 252 | 将 YueScript 代码字符串加载为一个函数。 |
| 243 | 253 | ||
| 244 | **签名:** | 254 | **签名:** |
| 255 | |||
| 245 | ```lua | 256 | ```lua |
| 246 | loadstring: function(input: string, config?: Config): | 257 | loadstring: function(input: string, config?: Config): |
| 247 | --[[loaded function]] nil | function(...: any): (any...), | 258 | --[[loaded function]] nil | function(...: any): (any...), |
| @@ -250,17 +261,17 @@ loadstring: function(input: string, config?: Config): | |||
| 250 | 261 | ||
| 251 | **参数:** | 262 | **参数:** |
| 252 | 263 | ||
| 253 | | 参数名 | 类型 | 描述 | | 264 | | 参数名 | 类型 | 描述 | |
| 254 | | --- | --- | --- | | 265 | | ------ | ------ | ------------------- | |
| 255 | | input | string | YueScript 代码。 | | 266 | | input | string | YueScript 代码。 | |
| 256 | | config | Config | [可选] 编译器选项。 | | 267 | | config | Config | [可选] 编译器选项。 | |
| 257 | 268 | ||
| 258 | **返回值:** | 269 | **返回值:** |
| 259 | 270 | ||
| 260 | | 返回类型 | 描述 | | 271 | | 返回类型 | 描述 | |
| 261 | | --- | --- | | 272 | | --------------- | ---------------------------------- | |
| 262 | | function \| nil | 加载的函数,如果加载失败则为 nil。 | | 273 | | function \| nil | 加载的函数,如果加载失败则为 nil。 | |
| 263 | | string \| nil | 错误消息,如果加载成功则为 nil。 | | 274 | | string \| nil | 错误消息,如果加载成功则为 nil。 | |
| 264 | 275 | ||
| 265 | ### loadfile | 276 | ### loadfile |
| 266 | 277 | ||
| @@ -271,6 +282,7 @@ loadstring: function(input: string, config?: Config): | |||
| 271 | 将 YueScript 代码文件加载为一个函数。 | 282 | 将 YueScript 代码文件加载为一个函数。 |
| 272 | 283 | ||
| 273 | **签名:** | 284 | **签名:** |
| 285 | |||
| 274 | ```lua | 286 | ```lua |
| 275 | loadfile: function(filename: string, env: table, config?: Config): | 287 | loadfile: function(filename: string, env: table, config?: Config): |
| 276 | nil | function(...: any): (any...), | 288 | nil | function(...: any): (any...), |
| @@ -279,18 +291,18 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 279 | 291 | ||
| 280 | **参数:** | 292 | **参数:** |
| 281 | 293 | ||
| 282 | | 参数名 | 类型 | 描述 | | 294 | | 参数名 | 类型 | 描述 | |
| 283 | | --- | --- | --- | | 295 | | -------- | ------ | ------------------- | |
| 284 | | filename | string | 文件名。 | | 296 | | filename | string | 文件名。 | |
| 285 | | env | table | 环境表。 | | 297 | | env | table | 环境表。 | |
| 286 | | config | Config | [可选] 编译器选项。 | | 298 | | config | Config | [可选] 编译器选项。 | |
| 287 | 299 | ||
| 288 | **返回值:** | 300 | **返回值:** |
| 289 | 301 | ||
| 290 | | 返回类型 | 描述 | | 302 | | 返回类型 | 描述 | |
| 291 | | --- | --- | | 303 | | --------------- | ---------------------------------- | |
| 292 | | function \| nil | 加载的函数,如果加载失败则为 nil。 | | 304 | | function \| nil | 加载的函数,如果加载失败则为 nil。 | |
| 293 | | string \| nil | 错误消息,如果加载成功则为 nil。 | | 305 | | string \| nil | 错误消息,如果加载成功则为 nil。 | |
| 294 | 306 | ||
| 295 | ### loadfile | 307 | ### loadfile |
| 296 | 308 | ||
| @@ -301,6 +313,7 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 301 | 将 YueScript 代码文件加载为一个函数。 | 313 | 将 YueScript 代码文件加载为一个函数。 |
| 302 | 314 | ||
| 303 | **签名:** | 315 | **签名:** |
| 316 | |||
| 304 | ```lua | 317 | ```lua |
| 305 | loadfile: function(filename: string, config?: Config): | 318 | loadfile: function(filename: string, config?: Config): |
| 306 | nil | function(...: any): (any...), | 319 | nil | function(...: any): (any...), |
| @@ -309,17 +322,17 @@ loadfile: function(filename: string, config?: Config): | |||
| 309 | 322 | ||
| 310 | **参数:** | 323 | **参数:** |
| 311 | 324 | ||
| 312 | | 参数名 | 类型 | 描述 | | 325 | | 参数名 | 类型 | 描述 | |
| 313 | | --- | --- | --- | | 326 | | -------- | ------ | ------------------- | |
| 314 | | filename | string | 文件名。 | | 327 | | filename | string | 文件名。 | |
| 315 | | config | Config | [可选] 编译器选项。 | | 328 | | config | Config | [可选] 编译器选项。 | |
| 316 | 329 | ||
| 317 | **返回值:** | 330 | **返回值:** |
| 318 | 331 | ||
| 319 | | 返回类型 | 描述 | | 332 | | 返回类型 | 描述 | |
| 320 | | --- | --- | | 333 | | --------------- | ---------------------------------- | |
| 321 | | function \| nil | 加载的函数,如果加载失败则为 nil。 | | 334 | | function \| nil | 加载的函数,如果加载失败则为 nil。 | |
| 322 | | string \| nil | 错误消息,如果加载成功则为 nil。 | | 335 | | string \| nil | 错误消息,如果加载成功则为 nil。 | |
| 323 | 336 | ||
| 324 | ### dofile | 337 | ### dofile |
| 325 | 338 | ||
| @@ -330,23 +343,24 @@ loadfile: function(filename: string, config?: Config): | |||
| 330 | 将 YueScript 代码文件加载为一个函数并执行。 | 343 | 将 YueScript 代码文件加载为一个函数并执行。 |
| 331 | 344 | ||
| 332 | **签名:** | 345 | **签名:** |
| 346 | |||
| 333 | ```lua | 347 | ```lua |
| 334 | dofile: function(filename: string, env: table, config?: Config): any... | 348 | dofile: function(filename: string, env: table, config?: Config): any... |
| 335 | ``` | 349 | ``` |
| 336 | 350 | ||
| 337 | **参数:** | 351 | **参数:** |
| 338 | 352 | ||
| 339 | | 参数名 | 类型 | 描述 | | 353 | | 参数名 | 类型 | 描述 | |
| 340 | | --- | --- | --- | | 354 | | -------- | ------ | ------------------- | |
| 341 | | filename | string | 文件名。 | | 355 | | filename | string | 文件名。 | |
| 342 | | env | table | 环境表。 | | 356 | | env | table | 环境表。 | |
| 343 | | config | Config | [可选] 编译器选项。 | | 357 | | config | Config | [可选] 编译器选项。 | |
| 344 | 358 | ||
| 345 | **返回值:** | 359 | **返回值:** |
| 346 | 360 | ||
| 347 | | 返回类型 | 描述 | | 361 | | 返回类型 | 描述 | |
| 348 | | --- | --- | | 362 | | -------- | -------------------------- | |
| 349 | | any... | 加载的函数执行后的返回值。 | | 363 | | any... | 加载的函数执行后的返回值。 | |
| 350 | 364 | ||
| 351 | ### dofile | 365 | ### dofile |
| 352 | 366 | ||
| @@ -357,22 +371,23 @@ dofile: function(filename: string, env: table, config?: Config): any... | |||
| 357 | 将 YueScript 代码文件加载为一个函数并执行。 | 371 | 将 YueScript 代码文件加载为一个函数并执行。 |
| 358 | 372 | ||
| 359 | **签名:** | 373 | **签名:** |
| 374 | |||
| 360 | ```lua | 375 | ```lua |
| 361 | dofile: function(filename: string, config?: Config): any... | 376 | dofile: function(filename: string, config?: Config): any... |
| 362 | ``` | 377 | ``` |
| 363 | 378 | ||
| 364 | **参数:** | 379 | **参数:** |
| 365 | 380 | ||
| 366 | | 参数名 | 类型 | 描述 | | 381 | | 参数名 | 类型 | 描述 | |
| 367 | | --- | --- | --- | | 382 | | -------- | ------ | ------------------- | |
| 368 | | filename | string | 文件名。 | | 383 | | filename | string | 文件名。 | |
| 369 | | config | Config | [可选] 编译器选项。 | | 384 | | config | Config | [可选] 编译器选项。 | |
| 370 | 385 | ||
| 371 | **返回值:** | 386 | **返回值:** |
| 372 | 387 | ||
| 373 | | 返回类型 | 描述 | | 388 | | 返回类型 | 描述 | |
| 374 | | --- | --- | | 389 | | -------- | -------------------------- | |
| 375 | | any... | 加载的函数执行后的返回值。 | | 390 | | any... | 加载的函数执行后的返回值。 | |
| 376 | 391 | ||
| 377 | ### find_modulepath | 392 | ### find_modulepath |
| 378 | 393 | ||
| @@ -383,21 +398,22 @@ dofile: function(filename: string, config?: Config): any... | |||
| 383 | 将 YueScript 模块名解析为文件路径。 | 398 | 将 YueScript 模块名解析为文件路径。 |
| 384 | 399 | ||
| 385 | **签名:** | 400 | **签名:** |
| 401 | |||
| 386 | ```lua | 402 | ```lua |
| 387 | find_modulepath: function(name: string): string | 403 | find_modulepath: function(name: string): string |
| 388 | ``` | 404 | ``` |
| 389 | 405 | ||
| 390 | **参数:** | 406 | **参数:** |
| 391 | 407 | ||
| 392 | | 参数名 | 类型 | 描述 | | 408 | | 参数名 | 类型 | 描述 | |
| 393 | | --- | --- | --- | | 409 | | ------ | ------ | -------- | |
| 394 | | name | string | 模块名。 | | 410 | | name | string | 模块名。 | |
| 395 | 411 | ||
| 396 | **返回值:** | 412 | **返回值:** |
| 397 | 413 | ||
| 398 | | 返回类型 | 描述 | | 414 | | 返回类型 | 描述 | |
| 399 | | --- | --- | | 415 | | -------- | ---------- | |
| 400 | | string | 文件路径。 | | 416 | | string | 文件路径。 | |
| 401 | 417 | ||
| 402 | ### pcall | 418 | ### pcall |
| 403 | 419 | ||
| @@ -410,21 +426,22 @@ find_modulepath: function(name: string): string | |||
| 410 | 当发生错误时,将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 | 426 | 当发生错误时,将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 |
| 411 | 427 | ||
| 412 | **签名:** | 428 | **签名:** |
| 429 | |||
| 413 | ```lua | 430 | ```lua |
| 414 | pcall: function(f: function, ...: any): boolean, any... | 431 | pcall: function(f: function, ...: any): boolean, any... |
| 415 | ``` | 432 | ``` |
| 416 | 433 | ||
| 417 | **参数:** | 434 | **参数:** |
| 418 | 435 | ||
| 419 | | 参数名 | 类型 | 描述 | | 436 | | 参数名 | 类型 | 描述 | |
| 420 | | --- | --- | --- | | 437 | | ------ | -------- | -------------------- | |
| 421 | | f | function | 要调用的函数。 | | 438 | | f | function | 要调用的函数。 | |
| 422 | | ... | any | 要传递给函数的参数。 | | 439 | | ... | any | 要传递给函数的参数。 | |
| 423 | 440 | ||
| 424 | **返回值:** | 441 | **返回值:** |
| 425 | 442 | ||
| 426 | | 返回类型 | 描述 | | 443 | | 返回类型 | 描述 | |
| 427 | | --- | --- | | 444 | | ------------ | ---------------------------- | |
| 428 | | boolean, ... | 状态码和函数结果或错误信息。 | | 445 | | boolean, ... | 状态码和函数结果或错误信息。 | |
| 429 | 446 | ||
| 430 | ### require | 447 | ### require |
| @@ -437,21 +454,22 @@ pcall: function(f: function, ...: any): boolean, any... | |||
| 437 | 如果模块是 YueScript 模块且加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 | 454 | 如果模块是 YueScript 模块且加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 |
| 438 | 455 | ||
| 439 | **签名:** | 456 | **签名:** |
| 457 | |||
| 440 | ```lua | 458 | ```lua |
| 441 | require: function(name: string): any... | 459 | require: function(name: string): any... |
| 442 | ``` | 460 | ``` |
| 443 | 461 | ||
| 444 | **参数:** | 462 | **参数:** |
| 445 | 463 | ||
| 446 | | 参数名 | 类型 | 描述 | | 464 | | 参数名 | 类型 | 描述 | |
| 447 | | --- | --- | --- | | 465 | | ------- | ------ | ---------------- | |
| 448 | | modname | string | 要加载的模块名。 | | 466 | | modname | string | 要加载的模块名。 | |
| 449 | 467 | ||
| 450 | **返回值:** | 468 | **返回值:** |
| 451 | 469 | ||
| 452 | | 返回类型 | 描述 | | 470 | | 返回类型 | 描述 | |
| 453 | | --- | --- | | 471 | | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 454 | | any | 如果模块已经加载,则返回 package.loaded[modname] 中存储的值。否则,尝试查找加载器并返回 package.loaded[modname] 的最终值和加载器数据作为第二个结果。 | | 472 | | any | 如果模块已经加载,则返回 package.loaded[modname] 中存储的值。否则,尝试查找加载器并返回 package.loaded[modname] 的最终值和加载器数据作为第二个结果。 | |
| 455 | 473 | ||
| 456 | ### p | 474 | ### p |
| 457 | 475 | ||
| @@ -462,15 +480,16 @@ require: function(name: string): any... | |||
| 462 | 检查传递的值的内部结构,并打印值出它的字符串表示。 | 480 | 检查传递的值的内部结构,并打印值出它的字符串表示。 |
| 463 | 481 | ||
| 464 | **签名:** | 482 | **签名:** |
| 483 | |||
| 465 | ```lua | 484 | ```lua |
| 466 | p: function(...: any) | 485 | p: function(...: any) |
| 467 | ``` | 486 | ``` |
| 468 | 487 | ||
| 469 | **参数:** | 488 | **参数:** |
| 470 | 489 | ||
| 471 | | 参数名 | 类型 | 描述 | | 490 | | 参数名 | 类型 | 描述 | |
| 472 | | --- | --- | --- | | 491 | | ------ | ---- | ------------ | |
| 473 | | ... | any | 要检查的值。 | | 492 | | ... | any | 要检查的值。 | |
| 474 | 493 | ||
| 475 | ### options | 494 | ### options |
| 476 | 495 | ||
| @@ -481,6 +500,7 @@ p: function(...: any) | |||
| 481 | 当前编译器选项。 | 500 | 当前编译器选项。 |
| 482 | 501 | ||
| 483 | **签名:** | 502 | **签名:** |
| 503 | |||
| 484 | ```lua | 504 | ```lua |
| 485 | options: Config.Options | 505 | options: Config.Options |
| 486 | ``` | 506 | ``` |
| @@ -494,21 +514,22 @@ options: Config.Options | |||
| 494 | 重写堆栈跟踪中的行号为 YueScript 代码中的原始行号的 traceback 函数。 | 514 | 重写堆栈跟踪中的行号为 YueScript 代码中的原始行号的 traceback 函数。 |
| 495 | 515 | ||
| 496 | **签名:** | 516 | **签名:** |
| 517 | |||
| 497 | ```lua | 518 | ```lua |
| 498 | traceback: function(message: string): string | 519 | traceback: function(message: string): string |
| 499 | ``` | 520 | ``` |
| 500 | 521 | ||
| 501 | **参数:** | 522 | **参数:** |
| 502 | 523 | ||
| 503 | | 参数名 | 类型 | 描述 | | 524 | | 参数名 | 类型 | 描述 | |
| 504 | | --- | --- | --- | | 525 | | ------- | ------ | -------------- | |
| 505 | | message | string | 堆栈跟踪消息。 | | 526 | | message | string | 堆栈跟踪消息。 | |
| 506 | 527 | ||
| 507 | **返回值:** | 528 | **返回值:** |
| 508 | 529 | ||
| 509 | | 返回类型 | 描述 | | 530 | | 返回类型 | 描述 | |
| 510 | | --- | --- | | 531 | | -------- | ---------------------- | |
| 511 | | string | 重写后的堆栈跟踪消息。 | | 532 | | string | 重写后的堆栈跟踪消息。 | |
| 512 | 533 | ||
| 513 | ### is_ast | 534 | ### is_ast |
| 514 | 535 | ||
| @@ -519,22 +540,23 @@ traceback: function(message: string): string | |||
| 519 | 检查代码是否匹配指定的 AST。 | 540 | 检查代码是否匹配指定的 AST。 |
| 520 | 541 | ||
| 521 | **签名:** | 542 | **签名:** |
| 543 | |||
| 522 | ```lua | 544 | ```lua |
| 523 | is_ast: function(astName: string, code: string): boolean | 545 | is_ast: function(astName: string, code: string): boolean |
| 524 | ``` | 546 | ``` |
| 525 | 547 | ||
| 526 | **参数:** | 548 | **参数:** |
| 527 | 549 | ||
| 528 | | 参数名 | 类型 | 描述 | | 550 | | 参数名 | 类型 | 描述 | |
| 529 | | --- | --- | --- | | 551 | | ------- | ------ | ---------- | |
| 530 | | astName | string | AST 名称。 | | 552 | | astName | string | AST 名称。 | |
| 531 | | code | string | 代码。 | | 553 | | code | string | 代码。 | |
| 532 | 554 | ||
| 533 | **返回值:** | 555 | **返回值:** |
| 534 | 556 | ||
| 535 | | 返回类型 | 描述 | | 557 | | 返回类型 | 描述 | |
| 536 | | --- | --- | | 558 | | -------- | ------------------ | |
| 537 | | boolean | 代码是否匹配 AST。 | | 559 | | boolean | 代码是否匹配 AST。 | |
| 538 | 560 | ||
| 539 | ### AST | 561 | ### AST |
| 540 | 562 | ||
| @@ -545,6 +567,7 @@ is_ast: function(astName: string, code: string): boolean | |||
| 545 | AST 类型定义,带有名称、行、列和子节点。 | 567 | AST 类型定义,带有名称、行、列和子节点。 |
| 546 | 568 | ||
| 547 | **签名:** | 569 | **签名:** |
| 570 | |||
| 548 | ```lua | 571 | ```lua |
| 549 | type AST = {string, integer, integer, any} | 572 | type AST = {string, integer, integer, any} |
| 550 | ``` | 573 | ``` |
| @@ -558,6 +581,7 @@ type AST = {string, integer, integer, any} | |||
| 558 | 将代码转换为 AST。 | 581 | 将代码转换为 AST。 |
| 559 | 582 | ||
| 560 | **签名:** | 583 | **签名:** |
| 584 | |||
| 561 | ```lua | 585 | ```lua |
| 562 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): | 586 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): |
| 563 | --[[AST]] AST | nil, | 587 | --[[AST]] AST | nil, |
| @@ -566,18 +590,18 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 566 | 590 | ||
| 567 | **参数:** | 591 | **参数:** |
| 568 | 592 | ||
| 569 | | 参数名 | 类型 | 描述 | | 593 | | 参数名 | 类型 | 描述 | |
| 570 | | --- | --- | --- | | 594 | | -------------- | ------- | ------------------------------------------------------------------------------ | |
| 571 | | code | string | 代码。 | | 595 | | code | string | 代码。 | |
| 572 | | flattenLevel | integer | [可选] 扁平化级别。级别越高,会消除更多的 AST 结构的嵌套。默认为 0。最大为 2。 | | 596 | | flattenLevel | integer | [可选] 扁平化级别。级别越高,会消除更多的 AST 结构的嵌套。默认为 0。最大为 2。 | |
| 573 | | astName | string | [可选] AST 名称。默认为 "File"。 | | 597 | | astName | string | [可选] AST 名称。默认为 "File"。 | |
| 574 | | reserveComment | boolean | [可选] 是否保留原始注释。默认为 false。 | | 598 | | reserveComment | boolean | [可选] 是否保留原始注释。默认为 false。 | |
| 575 | 599 | ||
| 576 | **返回值:** | 600 | **返回值:** |
| 577 | 601 | ||
| 578 | | 返回类型 | 描述 | | 602 | | 返回类型 | 描述 | |
| 579 | | --- | --- | | 603 | | ------------- | -------------------------------- | |
| 580 | | AST \| nil | AST,如果转换失败则为 nil。 | | 604 | | AST \| nil | AST,如果转换失败则为 nil。 | |
| 581 | | string \| nil | 错误消息,如果转换成功则为 nil。 | | 605 | | string \| nil | 错误消息,如果转换成功则为 nil。 | |
| 582 | 606 | ||
| 583 | ### format | 607 | ### format |
| @@ -589,25 +613,26 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 589 | 格式化 YueScript 代码。 | 613 | 格式化 YueScript 代码。 |
| 590 | 614 | ||
| 591 | **签名:** | 615 | **签名:** |
| 616 | |||
| 592 | ```lua | 617 | ```lua |
| 593 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string | 618 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string |
| 594 | ``` | 619 | ``` |
| 595 | 620 | ||
| 596 | **参数:** | 621 | **参数:** |
| 597 | 622 | ||
| 598 | | 参数名 | 类型 | 描述 | | 623 | | 参数名 | 类型 | 描述 | |
| 599 | | --- | --- | --- | | 624 | | -------------- | ------- | -------------------------------------- | |
| 600 | | code | string | 代码。 | | 625 | | code | string | 代码。 | |
| 601 | | tabSize | integer | [可选] 制表符大小。默认为 4。 | | 626 | | tabSize | integer | [可选] 制表符大小。默认为 4。 | |
| 602 | | reserveComment | boolean | [可选] 是否保留原始注释。默认为 true。 | | 627 | | reserveComment | boolean | [可选] 是否保留原始注释。默认为 true。 | |
| 603 | 628 | ||
| 604 | **返回值:** | 629 | **返回值:** |
| 605 | 630 | ||
| 606 | | 返回类型 | 描述 | | 631 | | 返回类型 | 描述 | |
| 607 | | --- | --- | | 632 | | -------- | ---------------- | |
| 608 | | string | 格式化后的代码。 | | 633 | | string | 格式化后的代码。 | |
| 609 | 634 | ||
| 610 | ### __call | 635 | ### \_\_call |
| 611 | 636 | ||
| 612 | **类型:** 元方法。 | 637 | **类型:** 元方法。 |
| 613 | 638 | ||
| @@ -617,21 +642,22 @@ format: function(code: string, tabSize?: number, reserveComment?: boolean): stri | |||
| 617 | 如果发生加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 | 642 | 如果发生加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 |
| 618 | 643 | ||
| 619 | **签名:** | 644 | **签名:** |
| 645 | |||
| 620 | ```lua | 646 | ```lua |
| 621 | metamethod __call: function(self: yue, module: string): any... | 647 | metamethod __call: function(self: yue, module: string): any... |
| 622 | ``` | 648 | ``` |
| 623 | 649 | ||
| 624 | **参数:** | 650 | **参数:** |
| 625 | 651 | ||
| 626 | | 参数名 | 类型 | 描述 | | 652 | | 参数名 | 类型 | 描述 | |
| 627 | | --- | --- | --- | | 653 | | ------ | ------ | -------- | |
| 628 | | module | string | 模块名。 | | 654 | | module | string | 模块名。 | |
| 629 | 655 | ||
| 630 | **返回值:** | 656 | **返回值:** |
| 631 | 657 | ||
| 632 | | 返回类型 | 描述 | | 658 | | 返回类型 | 描述 | |
| 633 | | --- | --- | | 659 | | -------- | -------- | |
| 634 | | any | 模块值。 | | 660 | | any | 模块值。 | |
| 635 | 661 | ||
| 636 | ## Config | 662 | ## Config |
| 637 | 663 | ||
| @@ -648,6 +674,7 @@ metamethod __call: function(self: yue, module: string): any... | |||
| 648 | 编译器是否应该收集代码中出现的全局变量。 | 674 | 编译器是否应该收集代码中出现的全局变量。 |
| 649 | 675 | ||
| 650 | **签名:** | 676 | **签名:** |
| 677 | |||
| 651 | ```lua | 678 | ```lua |
| 652 | lint_global: boolean | 679 | lint_global: boolean |
| 653 | ``` | 680 | ``` |
| @@ -661,6 +688,7 @@ lint_global: boolean | |||
| 661 | 编译器是否应该对根层级的代码块进行隐式的表达式返回。 | 688 | 编译器是否应该对根层级的代码块进行隐式的表达式返回。 |
| 662 | 689 | ||
| 663 | **签名:** | 690 | **签名:** |
| 691 | |||
| 664 | ```lua | 692 | ```lua |
| 665 | implicit_return_root: boolean | 693 | implicit_return_root: boolean |
| 666 | ``` | 694 | ``` |
| @@ -674,6 +702,7 @@ implicit_return_root: boolean | |||
| 674 | 编译器是否应该在编译后的代码中保留原始行号。 | 702 | 编译器是否应该在编译后的代码中保留原始行号。 |
| 675 | 703 | ||
| 676 | **签名:** | 704 | **签名:** |
| 705 | |||
| 677 | ```lua | 706 | ```lua |
| 678 | reserve_line_number: boolean | 707 | reserve_line_number: boolean |
| 679 | ``` | 708 | ``` |
| @@ -687,6 +716,7 @@ reserve_line_number: boolean | |||
| 687 | 编译器是否应该在编译后的代码中保留原始注释。 | 716 | 编译器是否应该在编译后的代码中保留原始注释。 |
| 688 | 717 | ||
| 689 | **签名:** | 718 | **签名:** |
| 719 | |||
| 690 | ```lua | 720 | ```lua |
| 691 | reserve_comment: boolean | 721 | reserve_comment: boolean |
| 692 | ``` | 722 | ``` |
| @@ -700,6 +730,7 @@ reserve_comment: boolean | |||
| 700 | 编译器是否应该在编译后的代码中使用空格字符而不是制表符字符。 | 730 | 编译器是否应该在编译后的代码中使用空格字符而不是制表符字符。 |
| 701 | 731 | ||
| 702 | **签名:** | 732 | **签名:** |
| 733 | |||
| 703 | ```lua | 734 | ```lua |
| 704 | space_over_tab: boolean | 735 | space_over_tab: boolean |
| 705 | ``` | 736 | ``` |
| @@ -713,6 +744,7 @@ space_over_tab: boolean | |||
| 713 | 编译器是否应该将要编译的代码视为当前正在编译的模块。仅供编译器内部使用。 | 744 | 编译器是否应该将要编译的代码视为当前正在编译的模块。仅供编译器内部使用。 |
| 714 | 745 | ||
| 715 | **签名:** | 746 | **签名:** |
| 747 | |||
| 716 | ```lua | 748 | ```lua |
| 717 | same_module: boolean | 749 | same_module: boolean |
| 718 | ``` | 750 | ``` |
| @@ -726,6 +758,7 @@ same_module: boolean | |||
| 726 | 编译器错误消息是否应该包含行号偏移量。仅供编译器内部使用。 | 758 | 编译器错误消息是否应该包含行号偏移量。仅供编译器内部使用。 |
| 727 | 759 | ||
| 728 | **签名:** | 760 | **签名:** |
| 761 | |||
| 729 | ```lua | 762 | ```lua |
| 730 | line_offset: integer | 763 | line_offset: integer |
| 731 | ``` | 764 | ``` |
| @@ -739,6 +772,7 @@ line_offset: integer | |||
| 739 | 目标 Lua 版本枚举。 | 772 | 目标 Lua 版本枚举。 |
| 740 | 773 | ||
| 741 | **签名:** | 774 | **签名:** |
| 775 | |||
| 742 | ```lua | 776 | ```lua |
| 743 | enum LuaTarget | 777 | enum LuaTarget |
| 744 | "5.1" | 778 | "5.1" |
| @@ -758,6 +792,7 @@ end | |||
| 758 | 要传递给编译函数的额外选项。 | 792 | 要传递给编译函数的额外选项。 |
| 759 | 793 | ||
| 760 | **签名:** | 794 | **签名:** |
| 795 | |||
| 761 | ```lua | 796 | ```lua |
| 762 | options: Options | 797 | options: Options |
| 763 | ``` | 798 | ``` |
| @@ -777,6 +812,7 @@ options: Options | |||
| 777 | 编译目标 Lua 版本。 | 812 | 编译目标 Lua 版本。 |
| 778 | 813 | ||
| 779 | **签名:** | 814 | **签名:** |
| 815 | |||
| 780 | ```lua | 816 | ```lua |
| 781 | target: LuaTarget | 817 | target: LuaTarget |
| 782 | ``` | 818 | ``` |
| @@ -790,6 +826,7 @@ target: LuaTarget | |||
| 790 | 额外模块搜索路径。 | 826 | 额外模块搜索路径。 |
| 791 | 827 | ||
| 792 | **签名:** | 828 | **签名:** |
| 829 | |||
| 793 | ```lua | 830 | ```lua |
| 794 | path: string | 831 | path: string |
| 795 | ``` | 832 | ``` |
| @@ -803,6 +840,7 @@ path: string | |||
| 803 | 是否在回溯错误消息中输出代码块的局部变量。默认为 false。 | 840 | 是否在回溯错误消息中输出代码块的局部变量。默认为 false。 |
| 804 | 841 | ||
| 805 | **签名:** | 842 | **签名:** |
| 843 | |||
| 806 | ```lua | 844 | ```lua |
| 807 | dump_locals: boolean | 845 | dump_locals: boolean |
| 808 | ``` | 846 | ``` |
| @@ -816,6 +854,7 @@ dump_locals: boolean | |||
| 816 | 是否简化输出的错误消息。默认为 true。 | 854 | 是否简化输出的错误消息。默认为 true。 |
| 817 | 855 | ||
| 818 | **签名:** | 856 | **签名:** |
| 857 | |||
| 819 | ```lua | 858 | ```lua |
| 820 | simplified: boolean | 859 | simplified: boolean |
| 821 | ``` | 860 | ``` |
diff --git a/doc/docs/zh/try/index.md b/doc/docs/zh/try/index.md index c5678b7..7e198b0 100755 --- a/doc/docs/zh/try/index.md +++ b/doc/docs/zh/try/index.md | |||
| @@ -5,6 +5,7 @@ next: false | |||
| 5 | --- | 5 | --- |
| 6 | 6 | ||
| 7 | # 月之脚本的在线编译器 | 7 | # 月之脚本的在线编译器 |
| 8 | |||
| 8 | --- | 9 | --- |
| 9 | 10 | ||
| 10 | 在这里试试 WASM 版的 YueScript 吧。 | 11 | 在这里试试 WASM 版的 YueScript 吧。 |
