@jhlagado/azm 0.2.2 → 0.2.3

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.
@@ -26,19 +26,7 @@ export function parseNextSourceItems(lines, options = {}) {
26
26
  if (afterTopLevelEnd && !isPostEndParseAllowed(line.text)) {
27
27
  continue;
28
28
  }
29
- const colonLayoutHeader = /^([A-Za-z_][A-Za-z0-9_]*):\s*\.(type|union)\s*$/.exec(stripLineComment(line.text).trim());
30
- if (colonLayoutHeader) {
31
- const directive = colonLayoutHeader[2] ?? 'type';
32
- diagnostics.push(parseDiagnostic(line, `Use "${colonLayoutHeader[1] ?? ''} .${directive}" for layouts; colon labels mark addresses.`));
33
- const endDirective = directive === 'union' ? '.endunion' : '.endtype';
34
- for (index += 1; index < pendingLines.length; index += 1) {
35
- if (stripLineComment(pendingLines[index].text).trim() === endDirective) {
36
- break;
37
- }
38
- }
39
- continue;
40
- }
41
- const nameLeftTypeAlias = /^([A-Za-z_][A-Za-z0-9_]*)\s+\.typealias\s+(.+)$/.exec(stripLineComment(line.text).trim());
29
+ const nameLeftTypeAlias = /^([A-Za-z_][A-Za-z0-9_]*)(?::\s*|\s+)\.typealias\s+(.+)$/.exec(stripLineComment(line.text).trim());
42
30
  if (nameLeftTypeAlias) {
43
31
  const typeExprText = nameLeftTypeAlias[2] ?? '';
44
32
  const typeExpr = parseTypeExpr(typeExprText);
@@ -60,7 +48,7 @@ export function parseNextSourceItems(lines, options = {}) {
60
48
  diagnostics.push(parseDiagnostic(line, `Use "${typeAlias[1] ?? ''} .typealias ..." for type aliases.`));
61
49
  continue;
62
50
  }
63
- const nameLeftLayoutHeader = /^([A-Za-z_][A-Za-z0-9_]*)\s+\.(type|union)\s*$/.exec(stripLineComment(line.text).trim());
51
+ const nameLeftLayoutHeader = /^([A-Za-z_][A-Za-z0-9_]*)(?::\s*|\s+)\.(type|union)\s*$/.exec(stripLineComment(line.text).trim());
64
52
  const prefixLayoutHeader = /^\.(type|union)\s+([A-Za-z_][A-Za-z0-9_]*)\s*$/.exec(stripLineComment(line.text).trim());
65
53
  if (prefixLayoutHeader) {
66
54
  const directive = prefixLayoutHeader[1] ?? 'type';
@@ -202,11 +190,7 @@ function evaluateConditionalExpression(line, expressionText, equates, locationDe
202
190
  }
203
191
  function recordConditionalEquate(line, equates, locationDependentEquates, directiveAliasPolicy) {
204
192
  const text = normalizeDirectiveAlias(stripLineComment(line.text), directiveAliasPolicy).trim();
205
- const statement = /^(@?[A-Za-z_.$?][A-Za-z0-9_.$?]*):\s*(.+)$/.exec(text);
206
- if (statement && /^\.equ\b/.test(statement[2] ?? '')) {
207
- return;
208
- }
209
- const equ = /^([A-Za-z_.$?][A-Za-z0-9_.$?]*)\s+\.equ\s+(.+)$/.exec(text);
193
+ const equ = /^([A-Za-z_.$?][A-Za-z0-9_.$?]*)(?::\s*|\s+)\.equ\s+(.+)$/.exec(text);
210
194
  if (!equ) {
211
195
  return;
212
196
  }
@@ -14,9 +14,9 @@ export function parseLogicalLine(line, options = {}) {
14
14
  const labelName = normalizeEntryLabelName(rawLabel);
15
15
  const isEntry = rawLabel.startsWith('@');
16
16
  const statementText = labelWithStatement[2] ?? '';
17
- const invalidDeclaration = parseColonDeclarationError(labelName, statementText);
18
- if (invalidDeclaration) {
19
- return { items: [], diagnostics: [parseError(line, invalidDeclaration)] };
17
+ const declaration = parseColonDeclaration(line, labelName, statementText, span);
18
+ if (declaration) {
19
+ return withLineComment(line, declaration);
20
20
  }
21
21
  const parsedStatement = parseCanonicalStatement(line, statementText, span);
22
22
  return withLineComment(line, {
@@ -254,21 +254,14 @@ function parseCanonicalStatement(line, text, span) {
254
254
  }
255
255
  return { items: [], diagnostics: [parseError(line, `unsupported source line: ${text}`)] };
256
256
  }
257
- function parseColonDeclarationError(name, statementText) {
258
- if (/^\.equ\b/.test(statementText)) {
259
- return `Use "${name} .equ ..." for constants; colon labels mark addresses.`;
260
- }
261
- if (/^\.enum\b/.test(statementText)) {
262
- return `Use "${name} .enum ..." for enums; colon labels mark addresses.`;
263
- }
264
- if (/^\.typealias\b/.test(statementText)) {
265
- return `Use "${name} .typealias ..." for type aliases; colon labels mark addresses.`;
266
- }
267
- if (/^\.type\b/.test(statementText)) {
268
- return `Use "${name} .type" for layouts; colon labels mark addresses.`;
257
+ function parseColonDeclaration(line, name, statementText, span) {
258
+ const equ = /^\.equ\s+(.+)$/.exec(statementText);
259
+ if (equ) {
260
+ return parseEquItem(line, name, equ[1] ?? '', span);
269
261
  }
270
- if (/^\.union\b/.test(statementText)) {
271
- return `Use "${name} .union" for layouts; colon labels mark addresses.`;
262
+ const enumDecl = /^\.enum\s+(.+)$/.exec(statementText);
263
+ if (enumDecl) {
264
+ return parseEnumItem(line, name, enumDecl[1] ?? '', span);
272
265
  }
273
266
  return undefined;
274
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jhlagado/azm",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "AZM assembler for the Z80 family (Node.js CLI)",
5
5
  "license": "GPL-3.0-only",
6
6
  "engines": {