Skip to content

Commit

Permalink
Changed init of some action splitter regular expressions
Browse files Browse the repository at this point in the history
Hopefully this makes the test run fine in GH.
  • Loading branch information
mike-lischke committed Nov 19, 2024
1 parent 79f96a0 commit b25a851
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/grammars/ActionSplitter.g4
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@ lexer grammar ActionSplitter;
// $antlr-format alignTrailingComments on, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments off, useTab off
// $antlr-format allowShortRulesOnASingleLine on, alignSemicolons none, minEmptyLines 0

@header {
/* eslint-disable */
@header {/* eslint-disable */
import { Character } from "../support/Character.js";
import type { ActionSplitterListener } from "../parse/ActionSplitterListener.js";
}

@members {
static readonly #attrValueExpr = /[^=][^;]*/;
static readonly #ws = /[ \t\n\r]+/;
static readonly #id = /[a-zA-Z_][a-zA-Z0-9_]*/;
static readonly #setNonLocalAttr = new RegExp(`\\$(?<x>${this.#id.source})::(<y>${this.#id.source})\s?=(?<expr>${this.#attrValueExpr.source});`);
static readonly #nonLocalAttr = new RegExp(`\\$(?<x>${this.#id.source})::(?<y>${this.#id.source})`);
static readonly #qualifiedAttr = new RegExp(`\\$(?<x>${this.#id.source}).(?<y>${this.#id.source})`);
static readonly #setAttr = new RegExp(`\\$(?<x>${this.#id.source})\s?=(?<expr>${this.#attrValueExpr.source});`);
static readonly #attr = new RegExp(`\\$(?<x>${this.#id.source})`);
const attrValueExpr = /[^=][^;]*/;
const id = /[a-zA-Z_][a-zA-Z0-9_]*/;
const setNonLocalAttr = new RegExp(`\\$(?<x>${id.source})::(<y>${id.source})\\s?=(?<expr>${attrValueExpr.source});`);
const nonLocalAttr = new RegExp(`\\$(?<x>${id.source})::(?<y>${id.source})`);
const qualifiedAttr = new RegExp(`\\$(?<x>${id.source}).(?<y>${id.source})`);
const setAttr = new RegExp(`\\$(?<x>${id.source})\\s?=(?<expr>${attrValueExpr.source});`);
const attr = new RegExp(`\\$(?<x>${id.source})`);}

@members {
/** Force filtering (and return tokens). Sends token values to the delegate. */
public getActionTokens(delegate: ActionSplitterListener): Token[] {
const tokens = this.getAllTokens();
Expand All @@ -46,7 +43,7 @@ public getActionTokens(delegate: ActionSplitterListener): Token[] {
const text = t.text!;
// Parse the text and extract the named groups from the match result.
const match = text.match(ActionSplitter.#setNonLocalAttr);
const match = text.match(setNonLocalAttr);
if (match === null) {
throw new Error(`Mismatched input '${text}'`);
}
Expand All @@ -60,7 +57,7 @@ public getActionTokens(delegate: ActionSplitterListener): Token[] {
case ActionSplitter.NONLOCAL_ATTR: {
const text = t.text!;
const match = text.match(ActionSplitter.#nonLocalAttr);
const match = text.match(nonLocalAttr);
if (match === null) {
throw new Error(`Mismatched input '${text}'`);
}
Expand All @@ -74,7 +71,7 @@ public getActionTokens(delegate: ActionSplitterListener): Token[] {
case ActionSplitter.QUALIFIED_ATTR: {
let text = t.text!;
const match = text.match(ActionSplitter.#qualifiedAttr);
const match = text.match(qualifiedAttr);
if (match === null) {
throw new Error(`Mismatched input '${text}'`);
}
Expand Down Expand Up @@ -102,7 +99,7 @@ public getActionTokens(delegate: ActionSplitterListener): Token[] {
case ActionSplitter.SET_ATTR: {
const text = t.text!;
const match = text.match(ActionSplitter.#setAttr);
const match = text.match(setAttr);
if (match === null) {
throw new Error(`Mismatched input '${text}'`);
}
Expand All @@ -116,7 +113,7 @@ public getActionTokens(delegate: ActionSplitterListener): Token[] {
case ActionSplitter.ATTR: {
const text = t.text!;
const match = text.match(ActionSplitter.#attr);
const match = text.match(attr);
if (match === null) {
throw new Error(`Mismatched input '${text}'`);
}
Expand Down

0 comments on commit b25a851

Please sign in to comment.