Skip to content

Instantly share code, notes, and snippets.

@MrSmith33
Last active January 31, 2023 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrSmith33/c6291d302b1057b53788d3b7843f38b2 to your computer and use it in GitHub Desktop.
Save MrSmith33/c6291d302b1057b53788d3b7843f38b2 to your computer and use it in GitHub Desktop.
Sublime text regexp for matching D error messages
Regular expression for matching error messages in Sublime Text.
Insert into `file_regex` parameter of `.sublime-project` file. Then clicking the line with error message opens correct source file.
--- Escaped for file_regex (\ -> \\)
^(?:\\s*)(?:.*(?: at |@))?((?:[^\\(: ]|:(?!\\d))+)(?:\\(|:)(\\d+)(?:(?:,|:)(\\d+))?\\)?(?:: (.*))?
--- Raw regex (developed with https://regexr.com, used flags: global, multiline)
^(?:\s*)(?:.*(?: at |@))?((?:[^\(: ]|:(?!\d))+)(?:\(|:)(\d+)(?:(?:,|:)(\d+))?\)?(?:: (.*))?
--- Matches
file: fe\ast\expr\call.d
line: 515
col?: 30
msg?: Error: msg
--- Supports
digitalmars and gnu error style () vs :: (-verror-style=gnu)
both messages with and without columns (-vcolumns)
messages from Windows and Linux stack traces
: in paths (disk name on Windows)
: in error messages
whitespace at the start of the line
--- Test suite
fe\ast\expr\call.d:515: msg
fe\ast\expr\call.d:515: Error: msg
D:\fe\ast\expr\call.d:515: Error: msg
fe\ast\expr\call.d:515:30: Error: msg
D:\fe\ast\expr\call.d:515:30: Error: msg
fe\ast\expr\call.d(515,30): Error: msg
D:\fe\ast\expr\call.d(515,30): Error: msg
fe\ast\expr\call.d:193:30: Error: msg
D:\fe\ast\expr\call.d:193:30: Error: msg
0x00007FF78FBC861B in context.CompilationContext.end_ice at fe\ast\expr\call.d(427)
0x00007FF78FBC861B in context.CompilationContext.end_ice at D:\fe\ast\expr\call.d(427)
fe/passes/ast_to_ir.d:129 void driver.Driver.compile() [0x5648b36b9a2a]
core.exception.SwitchError@D:\fe\ast\expr\call.d(131): No appropriate switch clause found
--- All of the above + whitespace at the start
--- Result
fe\ast\expr\call.d | 515 | | msg
fe\ast\expr\call.d | 515 | | Error: msg
D:\fe\ast\expr\call.d | 515 | | Error: msg
fe\ast\expr\call.d | 515 | 30 | Error: msg
D:\fe\ast\expr\call.d | 515 | 30 | Error: msg
fe\ast\expr\call.d | 515 | 30 | Error: msg
D:\fe\ast\expr\call.d | 515 | 30 | Error: msg
fe\ast\expr\call.d | 193 | 30 | Error: msg
D:\fe\ast\expr\call.d | 193 | 30 | Error: msg
fe\ast\expr\call.d | 427 | |
D:\fe\ast\expr\call.d | 427 | |
fe/passes/ast_to_ir.d | 129 | |
D:\fe\ast\expr\call.d | 131 | | No appropriate switch clause found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment