Skip to content

Commit

Permalink
Include binary_properties and script Unicode categories in automatic …
Browse files Browse the repository at this point in the history
…name resolution.

Fixes #23
  • Loading branch information
mike-lischke committed Dec 28, 2024
1 parent 7e910cf commit b935fe7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"ignorePaths": [
".eslintrc.json",
"build/PropertyValueAliases.txt",
"src/generated/*"
"src/generated/*",
"templates/*"
]
}
3 changes: 1 addition & 2 deletions src/codegen/OutputModelController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ export class OutputModelController {
ruleFunction.fillNamedActions(this.delegate, r);

if (r instanceof LeftRecursiveRule) {
this.buildLeftRecursiveRuleFunction(r,
ruleFunction as LeftRecursiveRuleFunction);
this.buildLeftRecursiveRuleFunction(r, ruleFunction as LeftRecursiveRuleFunction);
} else {
this.buildNormalRuleFunction(r, ruleFunction);
}
Expand Down
4 changes: 3 additions & 1 deletion src/codegen/model/SemPred.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export class SemPred extends Action {
super(factory, ast);
const failNode = ast.getOptionAST("fail");
const gen = factory.getGenerator()!;
this.predicate = ast.getText()!;

// Remove the outer braces and the trailing question mark.
this.predicate = ast.getText().substring(1, ast.getText().length - 2);
if (this.predicate.startsWith("{") && this.predicate.endsWith("}")) {
this.predicate = this.predicate.substring(1, this.predicate.length - 2);
}
Expand Down
2 changes: 1 addition & 1 deletion src/support/Unicode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface ICodePointLookupResult {
}

/** Used in ambiguous cases (when an isolated property string (or value string) resolves to multiple entries). */
const defaultCategories = ["block", "general_category"];
const defaultCategories = ["block", "general_category", "binary_property", "script"];

/**
* Determines the Unicode codepoint range for a given Unicode attribute.
Expand Down
20 changes: 12 additions & 8 deletions src/tool-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,18 @@ export const parseToolParameters = (args: string[]): IToolParameters => {

const result = prepared.opts<IToolParameters>();

const list = globSync(prepared.args);
if (list.length > 0) {
// When using a glob pattern we cannot have exact output paths.
result.exactOutputDir = false;
result.args = list;
} else {
result.args = prepared.args;
}
result.args = [];
prepared.args.forEach((arg) => {
if (arg.includes("*")) {
const list = globSync(prepared.args);

// When using a glob pattern we cannot have exact output paths.
result.exactOutputDir = false;
result.args.push(...list);
} else {
result.args.push(arg);
}
});

return result;
};
3 changes: 2 additions & 1 deletion src/tool/Alternative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export class Alternative implements AttributeResolver, IAlternative {
public actions = new Array<ActionAST>();

public constructor(r: Rule, altNum: number) {
this.rule = r; this.altNum = altNum;
this.rule = r;
this.altNum = altNum;
}

public resolvesToToken(x: string, node: ActionAST): boolean {
Expand Down

0 comments on commit b935fe7

Please sign in to comment.