4 ms·
The syntax will be broken 99% of the time and making a parser that recovers gracefully under any circumstance is very hard. You could make an editor that only
by EdiX 11y ago
The syntax will be broken 99% of the time and making a parser that recovers gracefully under any circumstance is very hard.
You could make an editor that only allows valid programs but that opens up a lot of UI problems, it was tried many times and it never took off in practice.
- Kristine1975 11y agoYet Eclipse and IntelliJ IDEA (and most likely a lot of other IDE's) successfully use AST's for their code editor. The syntax will only be broken locally, so it's not that hard to recover.
- scotty79 11y agoI tried Eclipse many times over last decade. Always used for few weeks before code highlighting and completion drove me insane due to multiple crashes, hangups and slowdowns. Trouble with elaborate 'correct' solutions starts when you need another thing. I don't think support in Eclipse for .cjsx or PureScript or whatever is coming soon. I won't wait 10 years till they get it 'right'. I'll use Atom to get the 95% right in few months.
- EdiX 11y agoI said it's very hard not that it's impossible. If you think it's easy write a parser with recovery for every language Atom supports.
- barrkel 11y agoIt doesn't need a full AST. It needs a tokenizer and a nesting level or potentially a stack of different classes of token nesting. This parser would not be difficult to write; the only "recovery" is in choosing how to react to mismatched token pairs. The simplified problem means heuristics could potentially be used.
- professor_etc 11y agoNot just broken, but broken and changing. Efficiently updating an AST as the user types, especially when their changes could trigger dramatic alterations to the structure of the tree (e.g., typing /*) is a very hard problem. A responsive editor is pretty much always going to have to take some shortcuts.