Skip to content

Commit

Permalink
Improve handling of Crystal's quoted labels (compiler-explorer#2789)
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Jul 20, 2021
1 parent abee7b3 commit 9829915
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/asm-parser-crystal.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export class CrystalAsmParser extends AsmParser {

// Crystal labels are not mangled, instead they are enclosed in quotes
// whenever necessary
this.labelDef = /^([\w$.@]+|"[^"]+"):$/;
this.indentedLabelDef = /^\s*([\w$.@]+|"[^"]+"):/;
this.labelFindNonMips = /[\w.][\w$.@]*|"[^"]+"/g;
this.labelFindMips = /[\w$.@]+|"[^"]+"/g;
this.definesGlobal = /^\s*\.(?:globa?l|GLB|export)\s*([.A-Z_a-z][\w$.]*|"[^"]+")/;
this.definesWeak = /^\s*\.(?:weakext|weak)\s*([.A-Z_a-z][\w$.]*|"[^"]+")/;
this.labelDef = /^([\w$.@]+|"(?:[^"\\]|\\.)+"):$/;
this.indentedLabelDef = /^\s*([\w$.@]+|"(?:[^"\\]|\\.)+"):/;
this.labelFindNonMips = /[\w.][\w$.@]*|"(?:[^"\\]|\\.)+"/g;
this.labelFindMips = /[\w$.@]+|"(?:[^"\\]|\\.)+"/g;
this.definesGlobal = /^\s*\.(?:globa?l|GLB|export)\s*([.A-Z_a-z][\w$.]*|"(?:[^"\\]|\\.)+")/;
this.definesWeak = /^\s*\.(?:weakext|weak)\s*([.A-Z_a-z][\w$.]*|"(?:[^"\\]|\\.)+")/;
}
}
2 changes: 2 additions & 0 deletions static/modes/asm-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ function definition() {
[/^<.*>$/, {token: 'annotation'}],
// Label definition
[/^[.a-zA-Z0-9_$?@].*:/, {token: 'type.identifier'}],
// Label definition (quoted)
[/^"([^"\\]|\\.)*":/, {token: 'type.identifier'}],
// Label definition (ARM style)
[/^\s*[|][^|]*[|]/, {token: 'type.identifier'}],
// Label definition (CL style)
Expand Down

0 comments on commit 9829915

Please sign in to comment.