@andrivet/z80-assembler 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Z80 Assembler in Typescript
3
+ *
4
+ * File: Assets.ts
5
+ * Description: Assets used by the compiler and packaged by Vite
6
+ * Author: Sebastien Andrivet
7
+ * License: GPLv3
8
+ * Copyrights: Copyright (C) 2023 Sebastien Andrivet
9
+ */
10
+ /**
11
+ * Assembler Z80 en Typescript
12
+ *
13
+ * Fichier: Assets.ts
14
+ * Description: Ressources utilisées par le compilateur and emballées par Vite
15
+ * Author: Sebastien Andrivet
16
+ * License: GPLv3
17
+ * Copyrights: Copyright (C) 2023 Sebastien Andrivet
18
+ */
19
+ import assetCharacters from '../assets/code/characters.zx81?raw';
20
+ import assetSystemVariables from '../assets/code/system-variables.zx81?raw';
21
+ import assetBasicLine1 from '../assets/code/basic-line1.zx81?raw';
22
+ import assetBasicLine2 from '../assets/code/basic-line2.zx81?raw';
23
+ import assetDisplay from '../assets/code/display.zx81?raw';
24
+ import assetBasicEnd from '../assets/code/basic-end.zx81?raw';
25
+ export { assetCharacters, assetSystemVariables, assetBasicLine1, assetBasicLine2, assetDisplay, assetBasicEnd };
@@ -7,21 +7,42 @@
7
7
  * License: GPLv3
8
8
  * Copyrights: Copyright (C) 2023 Sebastien Andrivet
9
9
  */
10
+ /**
11
+ * Assembler Z80 en Typescript
12
+ *
13
+ * Fichier: Ast.ts
14
+ * Description: Types pour construire un arbre syntaxique abstrait.
15
+ * Author: Sebastien Andrivet
16
+ * License: GPLv3
17
+ * Copyrights: Copyright (C) 2023 Sebastien Andrivet
18
+ */
10
19
  import { bytes } from '../types/Types';
11
20
  import { ByteValue, Expression, PosInfo, WordValue } from "../grammar/z80";
12
21
  /**
13
- * A function taking no argument and returning a number (if it is known) or null (if it is unknown)
22
+ * A function taking no argument and returning a number (if it is known) or null (if it is unknown).
23
+ * Une function qui ne prend pas d'argument et qui retourne un nombre (s'il est connu) ou null (s'il est inconnu).
14
24
  */
15
25
  export type EvalFunc = () => number | null;
16
26
  /**
17
- * An abstract element generated by the parser
27
+ * An abstract element generated by the parser.
28
+ * Un élément abstrait générà par l'analyseur.
18
29
  */
19
30
  export interface AstBase {
31
+ /**
32
+ * The number of bytes that will be generated by this element.
33
+ * Le nombre d'octets générés par cet élément.
34
+ */
20
35
  get size(): number;
36
+ /**
37
+ * Generate actual bytes.
38
+ * Génération des octets
39
+ * @param instructionAddress Address of the next byte to generate,
40
+ * Adresse du prochain octet à générer.
41
+ */
21
42
  generate(instructionAddress: number): bytes;
22
43
  }
23
44
  /**
24
- * An AST element is either a number (the raw byte value) or derived from AstBase
45
+ * An AST element is either a number (the raw byte value) or derived from AstBase.
25
46
  */
26
47
  export type AstElement = number | AstBase;
27
48
  /**
@@ -65,22 +86,22 @@ interface InnerExpression<E extends Evaluable> {
65
86
  /**
66
87
  * A Binary operation interface, i.e. a function with two arguments and that returns a number.
67
88
  */
68
- interface BinaryOperation {
69
- (a: number, b: number): number;
70
- }
89
+ type BinaryOperation = (a: number, b: number) => number;
71
90
  /**
72
91
  * A Unary operation interface, i.e. a function with one argument and that returns a number.
73
92
  */
74
- interface UnaryOperation {
75
- (a: number): number;
76
- }
93
+ type UnaryOperation = (a: number) => number;
77
94
  /**
78
- * A Binary function such as: 2 * 4 * 2.
79
- * @param left Left side of the binary function (an array of operands).
95
+ * A Binary operation such as: 2 * 4.
96
+ * Une expression binaire telle que: 2 * 4.
97
+ * @param left Left side of the binary function.
98
+ * Le coté gauche de l'opération binaire.
80
99
  * @param right Right side of the binary function.
100
+ * Le coté droit de l'opération binaire
81
101
  * @param op Operation to be applied to the left and right side.
102
+ * L'opération à appliquer aux opérandes
82
103
  */
83
- export declare function binaryOperation<Operation extends BinaryOperation, Inner extends Evaluable, Left extends InnerExpression<Inner>, Right extends Evaluable>(left: Left[], right: Right, op: Operation): EvalFunc;
104
+ export declare function binaryOperation<Operation extends BinaryOperation, Inner extends Evaluable, Left extends InnerExpression<Inner>, Right extends Evaluable>(left: Left | null, right: Right, op: Operation): EvalFunc;
84
105
  /**
85
106
  * A map of strings versus binary operations. For example: '*' => operatorMul
86
107
  */
@@ -94,18 +115,22 @@ type UnaryOperationsMap = {
94
115
  [key: string]: UnaryOperation;
95
116
  };
96
117
  /**
97
- * A Inner Operator i.e. that extends an Inner Expression, itself extending an Evaluable.
118
+ * An Inner Operator i.e. that extends an Inner Expression, itself extending an Evaluable.
98
119
  */
99
120
  interface InnerOp<E extends Evaluable> extends InnerExpression<E> {
100
121
  op: string;
101
122
  }
102
123
  /**
103
- * A Binary function such as: 2 * 4 * 2.
104
- * @param left Left side of the binary function (an array of operands).
124
+ * A Binary operation such as: 2 * 4.
125
+ * Une expression binaire telle que: 2 * 4.
126
+ * @param left Left side of the binary function.
127
+ * Le coté gauche de l'opération binaire.
105
128
  * @param right Right side of the binary function.
129
+ * Le coté droit de l'opération binaire
106
130
  * @param map Map the operations to be applied to the left and right side.
131
+ * Une correspondance pour les opérations à appliquer aux opérandes.
107
132
  */
108
- export declare function binaryOperations<Inner extends Evaluable, Left extends InnerOp<Inner>, Right extends Evaluable>(left: Left[], right: Right, map: BinaryOperationsMap): EvalFunc;
133
+ export declare function binaryOperations<Inner extends Evaluable, Left extends InnerOp<Inner>, Right extends Evaluable>(left: Left | null, right: Right, map: BinaryOperationsMap): EvalFunc;
109
134
  /**
110
135
  * A Unary operation.
111
136
  * @param e The argument.
@@ -135,67 +160,97 @@ export declare const operatorInvert: (a: number) => number;
135
160
  export declare const operatorIdentity: (a: number) => number;
136
161
  /**
137
162
  * Returns an AST element that represents the low part of a little-endian 16-bit value.
163
+ * Retourne un élément de l'AST qui représente la partie basse d'une valeur 16 bits en petit boutiste.
138
164
  * @param pos The position of the element in the source.
139
- * @param e The little-endian 16-bit value
165
+ * La position de l'élément dans le code source.
166
+ * @param e The 16-bit value.
167
+ * La valeur 16-bit.
140
168
  */
141
169
  export declare function value16LE(pos: PosInfo, e: Expression): AstElement;
142
170
  /**
143
171
  * Returns an AST element that represents an 8-bit unsigned value.
172
+ * Retourne un élément de l'AST qui représente une valeur 8 bits.
144
173
  * @param pos The position of the element in the source.
145
- * @param e The 8-bit unsigned value
174
+ * La position de l'élément dans le code source.
175
+ * @param e The 8-bit unsigned value.
176
+ * La valeur 8-bit.
146
177
  */
147
178
  export declare function value8(pos: PosInfo, e: Expression): AstElement;
148
179
  /**
149
180
  * Returns an AST element that represents an 8-bit signed value.
181
+ * Retourne un élément de l'AST qui représente une valeur 8 bits signée.
150
182
  * @param pos The position of the element in the source.
183
+ * La position de l'élément dans le code source.
151
184
  * @param s The sign of the value.
152
185
  * @param e The 8-bit signed value
186
+ * La valeur 8-bit signée.
153
187
  */
154
188
  export declare function svalue8(pos: PosInfo, s: string, e: Expression): AstElement;
155
189
  /**
156
190
  * Returns an AST element that represents an offset for a JR (jump relative) opcode.
191
+ * Retourne un élément de l'AST qui représente un décalage pour un saut relatif JR.
157
192
  * @param pos The position of the element in the source.
158
- * @param e The offset value
193
+ * La position de l'élément dans le code source.
194
+ * @param e The offset value.
195
+ * La valeur du décalage.
159
196
  */
160
197
  export declare function jrOffset(pos: PosInfo, e: Expression): AstElement;
161
198
  /**
162
- * Returns an AST element that represents an offset for a JR (jump relative) opcode.
199
+ * Returns an AST element that represents an relative offset for a JR (jump relative) opcode.
200
+ * Retourne un élément de l'AST qui représente un décalage relatif pour un saut relatif JR.
163
201
  * @param pos The position of the element in the source.
202
+ * La position de l'élément dans le code source.
164
203
  * @param label The label that will give the offset value
204
+ * L'étiquette qui va donner la valeur du décalage.
165
205
  */
166
206
  export declare function jrRelativeOffset(pos: PosInfo, label: string): AstElement;
167
207
  /**
168
208
  * An Inner Byte, i.e. it contains an inner field that is a Byte value.
209
+ * Un octet interne, c.-à-d. qui contient un champ inner de type ByteValue.
169
210
  */
170
211
  export interface InnerByte {
171
212
  inner: ByteValue;
172
213
  }
173
214
  /**
174
215
  * An Inner Word, i.e. it contains an inner field that is a Word value.
216
+ * Un mot interne, c.-à-d. qui contient un champ inner de type WordValue.
175
217
  */
176
218
  export interface InnerWord {
177
219
  inner: WordValue;
178
220
  }
179
221
  /**
180
- * The bytes of a Byte directive
222
+ * The bytes of a Byte directive.
223
+ * Les octets d'une directive Byte.
181
224
  * @param _ The position of the bytes in the source code.
225
+ * La position des octets dans le code source.
182
226
  * @param data0 The first byte.
227
+ * Le premier octet.
183
228
  * @param data The other bytes.
229
+ * Les autres octets.
184
230
  */
185
231
  export declare function dataBytes(_: PosInfo, data0: ByteValue, data: InnerByte[]): AstElements;
186
232
  /**
187
- * The words of a Word directive
233
+ * The words of a Word directive.
234
+ * Les mots d'une directive Word.
188
235
  * @param _ The position of the words in the source code.
236
+ * La position des mots dans le code source.
189
237
  * @param data0 The first word.
238
+ * Le premier mot.
190
239
  * @param data The other words.
240
+ * Les autres mots.
191
241
  */
192
242
  export declare function dataWords(_: PosInfo, data0: WordValue, data: InnerWord[]): AstElements;
193
243
  /**
194
244
  * The parameters of a block of data.
245
+ * Les paramètres d'un bloc de données.
195
246
  * @param pos0 The position of the length in the source code.
247
+ * La position de la taille dans le code source.
196
248
  * @param length The length (in bytes) of the block
249
+ * La taille (en octets) du bloc.
197
250
  * @param pos1 The position of the value in the source code.
251
+ * La position de la valeur dans le code source.
198
252
  * @param value The value used to initialize the block.
253
+ * La valeur utilisée pour initialiser le bloc.
199
254
  */
200
255
  export declare function dataBlock(pos0: PosInfo, length: Expression, pos1: PosInfo | undefined, value: Expression | undefined): AstElement;
201
256
  export {};
@@ -7,10 +7,20 @@
7
7
  * License: GPLv3
8
8
  * Copyrights: Copyright (C) 2023 Sebastien Andrivet
9
9
  */
10
+ /**
11
+ * Assembler Z80 en Typescript
12
+ *
13
+ * Fichier: Compiler.ts
14
+ * Description: Compilateur (assembleur)
15
+ * Author: Sebastien Andrivet
16
+ * License: GPLv3
17
+ * Copyrights: Copyright (C) 2023 Sebastien Andrivet
18
+ */
10
19
  import { PosInfo } from "../grammar/z80";
11
- import { LinesInfo, CompilationInfo } from "../types/Types";
20
+ import { CompilationInfo, LinesInfo } from "../types/Types";
12
21
  /**
13
22
  * Type of the internal data.
23
+ * Type pour l'état interne.
14
24
  */
15
25
  interface ParseDate {
16
26
  outputName: string;
@@ -24,30 +34,45 @@ interface ParseDate {
24
34
  * Internal data (i.e. globals).
25
35
  * Unfortunately, tsPEG does not allow to declare a context for the parsing.
26
36
  * So instead, we use this ugly global.
37
+ * Données internes (c.-à-d. globales).
38
+ * Malheureusement, tsPEG ne permet pas de déclarer un contexte pour l'analyse.
39
+ * Donc à la place, j'utilise ces données globales assez horribles.
27
40
  */
28
41
  declare const parseData: ParseDate;
29
42
  /**
30
- * Set the outputs names (output directive)
43
+ * Set the outputs names (output directive).
44
+ * Définit les noms des fichiers de sortie (directive output).
31
45
  * @param filename Filename for the binary.
46
+ * Nom de fichier pour le binaire.
32
47
  * @param sld Filename for the SLD.
48
+ * Nom de fichier pour le SLD.
33
49
  */
34
50
  declare function setOutputName(filename: string, sld?: string): void;
35
51
  /**
36
- * Set the name of the target (device directive).
52
+ * Set the name of the target (device directive)
53
+ * Définit le nom de la cible (directive device).
37
54
  * @param name The name of the device
55
+ * Le nom de l'appareil.
38
56
  */
39
- declare function setDeviceName(name: string): void;
57
+ declare function setDevice(name: string): void;
40
58
  /**
41
59
  * Include an assembly file (include directive).
60
+ * Inclut un fichier assembleur (directive include).
42
61
  * @param pos Position of the include directive.
62
+ * Position de la directive.
43
63
  * @param filename The filename of the file to be included.
64
+ * Le nom du fichier à inclure.
44
65
  */
45
66
  declare function includeFile(pos: PosInfo, filename: string): LinesInfo;
46
67
  /**
47
68
  * Compile an assembly source code.
69
+ * Compile un fichier source assembleur.
48
70
  * @param filepath The file path of the source code.
71
+ * Le chemin du code source.
49
72
  * @param code The assembly source code.
73
+ * Le code source assembleur.
50
74
  * @param getFileCode A function to get the content of included files.
75
+ * Une fonction pour obtenir le contenu d'un fichier inclus.
51
76
  */
52
77
  declare function compile(filepath: string, code: string, getFileCode: (filename: string) => string): CompilationInfo;
53
- export { parseData, compile, includeFile, setOutputName, setDeviceName };
78
+ export { parseData, compile, includeFile, setOutputName, setDevice };
@@ -1,5 +1,24 @@
1
1
  /**
2
- * Represents a chunk of data to display binary,
2
+ * Z80 Assembler in Typescript
3
+ *
4
+ * File: Formatter.ts
5
+ * Description: Format bytes to display them easily
6
+ * Author: Sebastien Andrivet
7
+ * License: GPLv3
8
+ * Copyrights: Copyright (C) 2023 Sebastien Andrivet
9
+ */
10
+ /**
11
+ * Assembler Z80 en Typescript
12
+ *
13
+ * Fichier: Formatter.ts
14
+ * Description: Formattage d'octets pour les afficher facilement
15
+ * Author: Sebastien Andrivet
16
+ * License: GPLv3
17
+ * Copyrights: Copyright (C) 2023 Sebastien Andrivet
18
+ */
19
+ /**
20
+ * Represents a chunk of data to display binary.
21
+ * Représente un morceau de données pour afficher un binaire.
3
22
  */
4
23
  interface Chunk {
5
24
  address: string;
@@ -7,8 +26,11 @@ interface Chunk {
7
26
  }
8
27
  /**
9
28
  * Format bytes to display them.
29
+ * Formate des octets pour les afficher.
10
30
  * @param bytes An array of bytes.
31
+ * Un tableau d'octets.
11
32
  * @param perLine Number of bytes per line.
33
+ * Le nombre d'octets par line.
12
34
  */
13
35
  declare function formatBytes(bytes: number[], perLine: number): Chunk[];
14
36
  export { formatBytes, Chunk };
@@ -7,10 +7,10 @@
7
7
  * License: GPLv3
8
8
  * Copyrights: Copyright (C) 2023 Sebastien Andrivet
9
9
  */
10
- import { Lines } from "../grammar/z80";
11
10
  import { bytes, LinesInfo } from '../types/Types';
12
11
  /**
13
12
  * Information about a compiled program.
13
+ * Informations sur un programme compilé.
14
14
  */
15
15
  interface ProgramInfo {
16
16
  bytes: bytes;
@@ -21,21 +21,21 @@ interface ProgramInfo {
21
21
  /**
22
22
  * Compute, whenever possible, the value associated with labels.
23
23
  * @param address The starting address.
24
- * @param lines The lines (i.e. the AST)
25
- * @return the address that corresponds to the code after the lines (i.e the new starting address).
24
+ * @param infos The lines (i.e. the AST)
25
+ * @return the address that corresponds to the code after the lines (i.e. the new starting address).
26
26
  */
27
- declare function computeLabels(address: number, lines: Lines): number;
27
+ declare function computeLabels(address: number, infos: LinesInfo[]): number;
28
+ interface GenerationData {
29
+ bytes: bytes;
30
+ sld: string;
31
+ address: number;
32
+ }
28
33
  /**
29
- * Generate machine code bytes for an array of lines (i.e. an AST)
34
+ * Generate machine code bytes and SLD for an array of lines (i.e. an AST)
35
+ * @param mainfile Main file name
30
36
  * @param address The current address.
31
- * @param lines The lines (i.e. the AST)
32
- * @return An array of bytes (numbers)
33
- */
34
- declare function generateLinesBytes(address: number, lines: Lines): bytes;
35
- /**
36
- * Generate debugging information (in Source Level Debugging format)
37
- * @param lines An array of lines with their associated filename
38
- * @return The debugging information (in Source Level Debugging format)
37
+ * @param infos The lines (i.e. the AST) with the associated filename
38
+ * @return An array of bytes (numbers), debug data and the next address
39
39
  */
40
- declare function generateSld(lines: LinesInfo): string;
41
- export { computeLabels, generateLinesBytes, generateSld, ProgramInfo };
40
+ declare function generate(mainfile: string, address: number, infos: LinesInfo[]): GenerationData;
41
+ export { computeLabels, generate, ProgramInfo };
@@ -7,40 +7,66 @@
7
7
  * License: GPLv3
8
8
  * Copyrights: Copyright (C) 2023 Sebastien Andrivet
9
9
  */
10
+ /**
11
+ * Assembler Z80 en Typescript
12
+ *
13
+ * Fichier: Labels.ts
14
+ * Description: Etiquettes associées à des emplacements mémoire.
15
+ * Author: Sebastien Andrivet
16
+ * License: GPLv3
17
+ * Copyrights: Copyright (C) 2023 Sebastien Andrivet
18
+ */
10
19
  import { Expression, PosInfo } from "../grammar/z80";
11
20
  /**
12
21
  * Reset the labels.
22
+ * Supprime toutes les étiquettes.
13
23
  */
14
24
  declare function resetLabels(): void;
15
25
  /**
16
26
  * Add a label.
27
+ * Ajoute une étiquette.
17
28
  * @param pos The position of the label in the source code.
29
+ * La position de l'étiquette dans le code source.
18
30
  * @param name The name of the label.
19
- * @param value The value of the label (if known) or null (if unknown)
31
+ * Le nom de l'étiquette.
32
+ * @param value The value of the label (if known) or null (if unknown).
33
+ * La valeur de l'étiquette (si connue) ou null (si inconnue).
20
34
  */
21
35
  declare function addLabel(pos: PosInfo, name: string, value: number | null): void;
22
36
  /**
23
37
  * Add a label and its associated expression.
38
+ * Ajoute une étiquette et son expression associée.
24
39
  * @param _ The position of the label in the source code.
40
+ * La position de l'étiquette dans le code source.
25
41
  * @param name The name of the label.
42
+ * Le nom de l'étiquette.
26
43
  * @param expression The expression that gives that value of the label.
44
+ * L'expression qui donne la valeur de l'étiquette.
27
45
  */
28
46
  declare function addLabelExpression(_: PosInfo, name: string, expression: Expression): void;
29
47
  /**
30
48
  * Get the value associated with a label.
49
+ * Obtient la valeur associée avec une étiquette.
31
50
  * @param name The name of the label.
51
+ * Le nom de l'étiquette.
32
52
  * @param setUsed Set the used flag or not.
53
+ * Est-ce que l'on doit lever le drapeau d'utilisation ?
33
54
  * @return The value associated with a label or null if it is unknown.
55
+ * La valeur associée avec l'étiquette ou null si elle est inconnue.
34
56
  */
35
57
  declare function getLabelValue(name: string, setUsed?: boolean): number | null;
36
58
  /**
37
59
  * Is a label used in the program or only declared?
60
+ * Est-ce qu'une étiquette a été utilisée ou seulement déclarée ?
38
61
  * @param name The name of the label.
39
- * @return true if the label is used, false if it is unused or undeclared.
62
+ * Le nom de l'étiquette.
63
+ * @return true if the label is used, false otherwise.
64
+ * true si l'étiquette a été utilisée, false sinon.
40
65
  */
41
66
  declare function isLabelUsed(name: string): boolean | undefined;
42
67
  /**
43
68
  * Get the list of labels with an unknown value.
69
+ * Retourne la liste des étiquettes avec une valeur inconnue.
44
70
  */
45
71
  declare function getUnknownLabels(): string[];
46
72
  export { resetLabels, addLabel, addLabelExpression, getLabelValue, isLabelUsed, getUnknownLabels };
@@ -7,62 +7,99 @@
7
7
  * License: GPLv3
8
8
  * Copyrights: Copyright (C) 2023 Sebastien Andrivet
9
9
  */
10
+ /**
11
+ * Assembler Z80 en Typescript
12
+ *
13
+ * Fichier: LoweLevel.ts
14
+ * Description: Fonctions de bas niveau pour l'analyseur.
15
+ * Author: Sebastien Andrivet
16
+ * License: GPLv3
17
+ * Copyrights: Copyright (C) 2023 Sebastien Andrivet
18
+ */
10
19
  import { byte } from "../types/Types";
11
20
  /**
12
21
  * Compute the binary representation of the r argument.
13
- * @param r The argument of the opcode
22
+ * Calcule la représentation binaire de l'argument r.
23
+ * @param r The argument of the opcode.
24
+ * L'argument du code assembleur.
14
25
  * @param offset The number of bits to shift to the left.
26
+ * Le nombre de bits à décaler vers la gauche.
15
27
  */
16
28
  export declare function r_bits(r: string, offset?: number): byte;
17
29
  /**
18
30
  * Compute the binary representation of the dd argument.
19
- * @param dd The argument of the opcode
31
+ * Calcule la représentation binaire de l'argument dd.
32
+ * @param dd The argument of the opcode.
33
+ * L'argument du code assembleur.
20
34
  * @param offset The number of bits to shift to the left.
35
+ * Le nombre de bits à décaler vers la gauche.
21
36
  */
22
37
  export declare function dd_bits(dd: string, offset?: number): byte;
23
38
  /**
24
39
  * Compute the binary representation of the qq argument.
25
- * @param qq The argument of the opcode
40
+ * Calcule la représentation binaire de l'argument qq.
41
+ * @param qq The argument of the opcode.
42
+ * L'argument du code assembleur.
26
43
  * @param offset The number of bits to shift to the left.
44
+ * Le nombre de bits à décaler vers la gauche.
27
45
  */
28
46
  export declare function qq_bits(qq: string, offset?: number): byte;
29
47
  /**
30
48
  * Compute the binary representation of the ss argument.
31
- * @param ss The argument of the opcode
49
+ * Calcule la représentation binaire de l'argument ss.
50
+ * @param ss The argument of the opcode.
51
+ * L'argument du code assembleur.
32
52
  * @param offset The number of bits to shift to the left.
53
+ * Le nombre de bits à décaler vers la gauche.
33
54
  */
34
55
  export declare function ss_bits(ss: string, offset?: number): byte;
35
56
  /**
36
57
  * Compute the binary representation of the pp argument.
37
- * @param pp The argument of the opcode
58
+ * Calcule la représentation binaire de l'argument pp.
59
+ * @param pp The argument of the opcode.
60
+ * L'argument du code assembleur.
38
61
  * @param offset The number of bits to shift to the left.
62
+ * Le nombre de bits à décaler vers la gauche.
39
63
  */
40
64
  export declare function pp_bits(pp: string, offset?: number): byte;
41
65
  /**
42
66
  * Compute the binary representation of the rr argument.
43
- * @param rr The argument of the opcode
67
+ * Calcule la représentation binaire de l'argument rr.
68
+ * @param rr The argument of the opcode.
69
+ * L'argument du code assembleur.
44
70
  * @param offset The number of bits to shift to the left.
71
+ * Le nombre de bits à décaler vers la gauche.
45
72
  */
46
73
  export declare function rr_bits(rr: string, offset?: number): byte;
47
74
  /**
48
75
  * Compute the binary representation of the cc argument.
49
- * @param cc The argument of the opcode
76
+ * Calcule la représentation binaire de l'argument cc.
77
+ * @param cc The argument of the opcode.
78
+ * L'argument du code assembleur.
50
79
  * @param offset The number of bits to shift to the left.
80
+ * Le nombre de bits à décaler vers la gauche.
51
81
  */
52
82
  export declare function cc_bits(cc: string, offset?: number): byte;
53
83
  /**
54
84
  * Compute the binary representation of the jj argument.
55
- * @param jj The argument of the opcode
85
+ * Calcule la représentation binaire de l'argument jj.
86
+ * @param jj The argument of the opcode.
87
+ * L'argument du code assembleur.
56
88
  */
57
89
  export declare function jj_bits(jj?: string): byte;
58
90
  /**
59
91
  * Compute the binary representation of the p argument.
60
- * @param p The argument of the opcode
92
+ * Calcule la représentation binaire de l'argument p.
93
+ * @param p The argument of the opcode.
94
+ * L'argument du code assembleur.
61
95
  * @param offset The number of bits to shift to the left.
96
+ * Le nombre de bits à décaler vers la gauche.
62
97
  */
63
98
  export declare function p_bits(p: number, offset?: number): byte;
64
99
  /**
65
100
  * Compute the binary representation of the mode argument.
66
- * @param mode The argument of the opcode
101
+ * Calcule la représentation binaire de l'argument mode.
102
+ * @param mode The argument of the opcode.
103
+ * L'argument du code assembleur.
67
104
  */
68
105
  export declare function imode(mode: string): byte;
@@ -1,38 +1,77 @@
1
+ /**
2
+ * Z80 Assembler in Typescript
3
+ *
4
+ * File: Parse.ts
5
+ * Description: Fonctions uses by the parser to convert strings
6
+ * Author: Sebastien Andrivet
7
+ * License: GPLv3
8
+ * Copyrights: Copyright (C) 2023 Sebastien Andrivet
9
+ */
10
+ /**
11
+ * Assembler Z80 en Typescript
12
+ *
13
+ * Fichier: Parse.ts
14
+ * Description: Fonctions de conversion de chaines de caractères pour l'analyseur.
15
+ * Author: Sebastien Andrivet
16
+ * License: GPLv3
17
+ * Copyrights: Copyright (C) 2023 Sebastien Andrivet
18
+ */
1
19
  import { PosInfo } from "./z80";
2
20
  /**
3
21
  * Parse a number.
22
+ * Analyse un nombre.
4
23
  * @param pos Position of the number in the source code.
24
+ * Position du nombre dans le code source.
5
25
  * @param str The characters of the number.
26
+ * Les caractères du nombre.
6
27
  * @param base The base of the number.
28
+ * La base du nombre.
7
29
  * @param nbBytes The number of bytes to represent this number (1 or 2)
30
+ * Le nombre d'octets pour représenter ce nombre (1 ou 2)
8
31
  */
9
32
  export declare function parseNumber(pos: PosInfo, str: string, base: number, nbBytes: number): number;
10
- /**
11
- * Parse a simple character, i.e. a character that is not escaped.
12
- * @param pos Position of the character in the source code.
13
- * @param raw Raw representation of the character.
14
- */
15
- export declare function parseSimpleChar(pos: PosInfo, raw: string): number[];
16
33
  /**
17
34
  * Parse a simple escape, i.e. a backslash followed by a character.
18
- * @param value The character after the backslash.
35
+ * Analyse un échappement simple, c.-à-d. une barre oblique inversée suivie d'un caractère.
36
+ * @param pos Position of the character in the source code.
37
+ * Position du caractère dans le code source.
38
+ * @param c The character after the backslash.
39
+ * Le caractère après la barre oblique inversée.
19
40
  */
20
- export declare function parseSimpleEscape(value: string): number[];
41
+ export declare function parseSimpleEscape(pos: PosInfo, c: string): number[];
21
42
  /**
22
43
  * Parse an octal value.
44
+ * Analyse une valeur octale.
23
45
  * @param pos Position of the value in the source code.
46
+ * Position de la valeur dans le code source.
24
47
  * @param value The characters representing the value.
48
+ * Les caractères représentant la valeur.
25
49
  */
26
50
  export declare function parseOctalEscape(pos: PosInfo, value: string): number[];
27
51
  /**
28
52
  * Parse a hexadecimal value.
53
+ * Analyse une valeur hexadécimale.
29
54
  * @param pos Position of the value in the source code.
55
+ * Position de la valeur dans le code source.
30
56
  * @param value The characters representing the value.
57
+ * Les caractères représentant la valeur.
31
58
  */
32
59
  export declare function parseHexadecimalEscape(pos: PosInfo, value: string): number[];
60
+ /**
61
+ * Parse a ZX81 character written in ASCII.
62
+ * Analyse un caractère ZX81 écrit en ASCII.
63
+ * @param pos Position of the character in the source code.
64
+ * Position du caractère dans le code source.
65
+ * @param c The ASCII character.
66
+ * Le caractère ASCII.
67
+ */
68
+ export declare function parseZX81Char(pos: PosInfo, c: string): [number];
33
69
  /**
34
70
  * Parse a ZX81 string written in ASCII.
71
+ * Analyse un chaine ZX81 écrit en ASCII.
35
72
  * @param pos Position of the string in the source code.
73
+ * Position de la chaine dans le code source.
36
74
  * @param str The ASCII string.
75
+ * La chaine ASCII.
37
76
  */
38
77
  export declare function parseZX81String(pos: PosInfo, str: string): number[];