Custom Preprocessor breaks brightScript/brighterScript parsing #562
Replies: 3 comments 2 replies
-
Could you provide a few syntax examples of the custom statements? For things like "I don't recognize that function", we can solve lots of those types of problems with later plugin hooks. For custom code that is invalid syntax, I don't think there's another way to handle this at the moment. For example, using handlebars syntax like this:
wouldn't work because the But values in strings could definitely be solved after the parser phase because they're valid syntax to start with.
I've toyed with the idea of hooks inside the tokenizer (lexer) and parser so you could do this type of thing, but haven't gotten around to it yet. Another option is, if your replaced code is SMALLER than the original custom statements, you could pad with space characters to ensure the inserted code is the same size as the original. But that doesn't solve when the replacement text is longer than the original |
Beta Was this translation helpful? Give feedback.
-
@justinMBullard I guess it's not an option to support |
Beta Was this translation helpful? Give feedback.
-
That said, a syntax for "DSLs" would be nice @TwitchBronBron. Whatever is captured between certain characters is kept as-is in a special token, meant to be processed by a plugin post tokenzation or after transpilation. Maybe the mustache double-curly braces for instance. |
Beta Was this translation helpful? Give feedback.
-
In my project we have a custom preprocessor. It has some of its own custom statements that act similar to enums, but cause parsing errors for both brightscript and brigherscript files. Eventually it is probably best to migrate to brigherScripts enums. However, until that transition can be made, I would like to be able to create a plug-in that would bridge compatibility between our custom preprocessor and brighterscript.
I am working on a compiler plug-in using beforeFileParse events and modifying the source.source. This is working but it also changes the column information. I know it is causing issues when reporting parsing errors. The underline errors in VSCode match up with the substituted code not the code from the file. I need to research to see how this affects rokucommunity/bslint.
I went the route of beforeFileParse because I didn't see any other way to affect the tokens before parsing occurs. Is there another way?
Beta Was this translation helpful? Give feedback.
All reactions