Skip to content

Commit

Permalink
fix: fix parsing regression
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreminger committed Oct 21, 2023
1 parent ecce39b commit 5c5d5ba
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/parser/LatexToSympy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1499,21 +1499,23 @@ export class LatexToSympy extends LatexParserVisitor<string | Statement | UnitBl
visitU_block = (ctx: U_blockContext): UnitBlockData => {
let units = "";
let unitsLatex = "";
let units_valid: boolean;
let units_valid = false;
let units_dimensions: number[] = [];

units = this.visit(ctx.u_expr()) as string;
unitsLatex = `\\left${this.sourceLatex.slice(
ctx.start.column,
ctx.stop.column + ctx.stop.text.length
)}`;
const { dimensions, unitsValid } = checkUnits(units);
if (unitsValid) {
units_dimensions = dimensions;
units_valid = true;
} else {
this.addParsingErrorMessage(`Unknown Dimension ${units}`);
units_valid = false;
if(ctx) {
units = this.visit(ctx.u_expr()) as string;
unitsLatex = `\\left${this.sourceLatex.slice(
ctx.start.column,
ctx.stop.column + ctx.stop.text.length
)}`;
const { dimensions, unitsValid } = checkUnits(units);
if (unitsValid) {
units_dimensions = dimensions;
units_valid = true;
} else {
this.addParsingErrorMessage(`Unknown Dimension ${units}`);
units_valid = false;
}
}

return {
Expand Down

0 comments on commit 5c5d5ba

Please sign in to comment.