Skip to content

Commit

Permalink
Merge pull request #102 from Settis/fixEquals
Browse files Browse the repository at this point in the history
Fix equals
  • Loading branch information
Settis authored Dec 9, 2023
2 parents bb784bb + 4f8aac1 commit 92ab886
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

- disable autocompletion for addressing mode
- disable autocompletion for hex digits
- no more crashes on recovered parse result
- correct handling of using '=' sign in expressions

## [1.3.1] - 2023-07-11

Expand Down
12 changes: 12 additions & 0 deletions e2eTests/useCases/equalsWithoutSpaces.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
text: |2
PROCESSOR 6502
{SOME|someDef} = 2
IF SOM{|someGetDef}E=3
ENDIF
actions:
someDef:
type: DefinitionResult
someGetDef:
type: GetDefinition
result: someDef
27 changes: 16 additions & 11 deletions server/src/parser/ast/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ import { AstNode, FileNode } from "./nodes";
import { Visitor } from "./visitor";

export function parseText(uri: string, text: string): ParsingResult {
if (text === '') return getEmptyResult(uri);
const lexerResult = DASM_LEXER.tokenize(text);
const errors = lexerResult.errors.map(it => convertLexingError(it, uri));
DASM_PARSER.input = lexerResult.tokens;
const cst = DASM_PARSER.text();
errors.push(...DASM_PARSER.errors.map(it => convertParserError(it, uri)));
const visitor = new Visitor(uri);
return {
errors,
ast: visitor.constructAst(cst)
};
if (text === '') return getEmptyResult(uri);
try {
const lexerResult = DASM_LEXER.tokenize(text);
const errors = lexerResult.errors.map(it => convertLexingError(it, uri));
DASM_PARSER.input = lexerResult.tokens;
const cst = DASM_PARSER.text();
errors.push(...DASM_PARSER.errors.map(it => convertParserError(it, uri)));
const visitor = new Visitor(uri);
return {
errors,
ast: visitor.constructAst(cst)
};
} catch (error) {
console.error(error);
return getEmptyResult(uri);
}
}

export type ParsingResult = {
Expand Down
2 changes: 2 additions & 0 deletions server/src/parser/cst/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const SET_OF_BINARY_SIGNS = new Set([
lexer.LessSigh,
lexer.LessOrEqualSign,
lexer.EqualSign,
lexer.AssignSign,
lexer.NotEqualSign,
lexer.ArithmeticAndSign,
lexer.XorSign,
Expand Down Expand Up @@ -231,6 +232,7 @@ class DasmParser extends CstParser {
{ALT: () => this.CONSUME(lexer.LessSigh)},
{ALT: () => this.CONSUME(lexer.LessOrEqualSign)},
{ALT: () => this.CONSUME(lexer.EqualSign)},
{ALT: () => this.CONSUME(lexer.AssignSign)},
{ALT: () => this.CONSUME(lexer.NotEqualSign)},
{ALT: () => this.CONSUME(lexer.ArithmeticAndSign)},
{ALT: () => this.CONSUME(lexer.XorSign)},
Expand Down

0 comments on commit 92ab886

Please sign in to comment.