Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| en:presentation [2025/12/24 16:34] – root | en:presentation [2026/04/03 12:13] (Version actuelle) – root | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ===== W Language Description ===== | ===== W Language Description ===== | ||
| - | The W language is a procedural, loosely typed language with flexible and powerful data structures. | + | The W language is a procedural language, with dynamic typing and with flexible and powerful data structures. |
| ==== Comments ==== | ==== Comments ==== | ||
| Comments are written after the semicolon (;). They can appear either alone on a line or at the end of a line after an instruction. | Comments are written after the semicolon (;). They can appear either alone on a line or at the end of a line after an instruction. | ||
| Empty lines are considered comments. | Empty lines are considered comments. | ||
| - | < | + | < |
| ; First comment | ; First comment | ||
| ; Other comment | ; Other comment | ||
| Ligne 20: | Ligne 20: | ||
| During execution, any exception automatically causes a jump to the beginning of the exception block of the current program or subroutine. This is the equivalent of a systematic '' | During execution, any exception automatically causes a jump to the beginning of the exception block of the current program or subroutine. This is the equivalent of a systematic '' | ||
| Let's revisit the classic //Hello world// example : | Let's revisit the classic //Hello world// example : | ||
| - | < | + | < |
| ; classic example... | ; classic example... | ||
| Ligne 37: | Ligne 37: | ||
| The source file to be included must be located in the [[w: | The source file to be included must be located in the [[w: | ||
| - | < | + | < |
| include " | include " | ||
| </ | </ | ||
| Ligne 48: | Ligne 48: | ||
| ==== Data Types ==== | ==== Data Types ==== | ||
| Variables must be declared, but without a type, and can be declared anywhere in the code. They only become usable after their declaration; | Variables must be declared, but without a type, and can be declared anywhere in the code. They only become usable after their declaration; | ||
| - | < | + | < |
| ; declaration of 3 variables | ; declaration of 3 variables | ||
| declare x, y, tmp | declare x, y, tmp | ||
| Ligne 59: | Ligne 59: | ||
| * Subroutine: stores the address of a subroutine | * Subroutine: stores the address of a subroutine | ||
| * Object: identical to Hashtable and allows storing/ | * Object: identical to Hashtable and allows storing/ | ||
| - | * | + | * Param: Since parameters passed to subroutines are all by reference, each parameter is of this type, pointing to the actual variable: each action on the parameter will actually act on the variable passed as a parameter. |
| + | |||
| + | An 8th type, Buffer, is used only internally by the W executor (for managing the expression and call stack). | ||
| + | |||
| + | === Scope === | ||
| + | Variables declared in the main block (begin/ | ||
| + | Variables declared in libraries and subroutines have local scope to the subroutine. | ||
| + | Subroutines, | ||
| + | Variables belonging to a hashtable are only accessible via the hashtable, except for classes and objects stored globally. | ||
| + | |||
| + | === Usage === | ||
| + | Variables are assigned using the //let// statement. It is possible to // | ||
| + | <code wlang> | ||
| + | declare h, n, d | ||
| + | |||
| + | let h = {} ; h is a Hashtable | ||
| + | let n = -12.34 ; n is a Number | ||
| + | let d = " | ||
| + | |||
| + | ; h will contain 2 variables of type Number, x and y, which are not declared with " | ||
| + | let h.x = 10 | ||
| + | let h.y = 20 | ||
| + | |||
| + | </ | ||
| + | ==== Exceptions ==== | ||
| + | Every program and subroutine must contain an instruction [[w: | ||
| + | |||
| + | Finally, the system variable `[w: | ||
| + | At any time, the `[w: | ||
| + | |||
| + | Example | ||
| + | <code wlang> | ||
| + | begin test | ||
| + | declare x | ||
| + | let x = 10 | ||
| + | let y = 20 ; => raises an EX_NOVAR exception (undeclared variable " | ||
| + | echo "Not displayed"; | ||
| + | except | ||
| + | catch; => exits the program without error | ||
| + | echo " | ||
| + | end | ||
| + | </ | ||
| + | ===== List of instructions ===== | ||
| + | In alphabetical order | ||
| + | ===== Internal operation ===== | ||
| + | The W source code is compiled into // | ||
| + | This p-code is a series of elementary instructions specific to the W language.\\ | ||
| + | It is the same program that analyzes the W source code and breaks it down into p-code instructions: | ||
| + | * in interpreted mode, the instructions are then executed directly | ||
| + | * in compiled mode, the instructions are written to the output assembler file. Finally, this assembler file is converted into binary, a digital translation of the p-code instructions. | ||
| + | The p-code executor can also be called from another process, with p-code serving as a plugin-type language/ | ||
| + | |||
| + | The binary format of p-code is big-endian, allowing the same W binary file to be used on any type of operating system and architecture. | ||
| + | |||
| + | Expressions only concern variables of type Dynamic and Number and are managed in a stack using Reverse Polish Notation. | ||
| + | |||
| + | List of instructions in W. | ||
| + | |||
| + | Compilation rules for transforming W source code into p-code (W assembler). | ||