3 ms·
A simplified universal parsing format (AST) that equally describes all languages. It needs to allow seamless switching between different languages in the same
by austincheney 8y ago
A simplified universal parsing format (AST) that equally describes all languages. It needs to allow seamless switching between different languages in the same file and also allow recursively nesting of different languages within each other without resulting in a deviating from the simplified parse format.
The solution is written and it appears correct and viable. As in all things related to parsers the devil's in the details in attempts to prove edge cases with exotic tests and use cases.
- bordercases 8y agoThat sounds unbelievably useful, is it open source?
- austincheney 8y agoYes. https://github.com/unibeautify/parse-framework https://github.com/unibeautify/parse-framework The demo is at http://prettydiff.com/parse-framework/runtimes/browsertest.xhtml http://prettydiff.com/parse-framework/runtimes/browsertest.x... The backstory is at https://github.com/Unibeautify/parse-framework/issues/54 https://github.com/Unibeautify/parse-framework/issues/54 Please keep in mind this is a single person's pet project, so it doesn't cure world hunger or eliminate all disease just yet. Drop in some JSX or HTML with embedded JavaScript to see it go.
- oldandtired 8y agoDoes this handle languages like Icon or Unicon in which the concept of "failure is always an option"?
- austincheney 8y agoI honestly don't know. I have only written lexers, the part that does the analysis, for a few languages. The output format is completely language agnostic though. Go read through the docs or play with the demo to see what the output format looks like.
- yxhuvud 8y agoHow do the switching happen? You just allow a node in one language to be some root of another, or is it more complicated?
- austincheney 8y agoThe structure is defined using the begin and stack data fields of a given token. The begin points to the index of the current token's parent and the stack describes the structure contained by that parent. Items in the global space have no parent, so I assign a begin value of -1 and stack value of global. I use -1 because there is no such index in an array.