Conventional parsers must be modified to create an effective structure editor.
Most parsers create an AST (abstract syntax tree), but structure parsers create a CST (concrete syntax tree). This is because the parser must take note of things that affect the code appearance and not just the code output.
The parser should provide error feedback, but should NEVER give up when creating structure. Instead, it should use sane fallbacks as to always create an editable CST, within reason. Every CST should correspond almost 1:1 with corresponding code, whether that code is valid or invalid.