I (Ron Newcomb) have started on the grand ambition of rewriting Inform’s parser in Inform 7, meaning, the entire Parser.i6t template file. My goal in this is primarily for teaching and learning purposes: we get questions in the forum pretty regularly about just what, exactly, is going on inside that parser. While there’s a handful of Inform 6 experts who know this, I feel it would be in everyone’s best interest if more people could diagnose parser-related problems with their works-in-progress.
My technical goal in this is to have the Inform 7 compiler generate Inform 6 code that resembles the original Parser.i6t code as closely as possible. This is so I don’t have to test anything.
Seriously, a full regression test on a rewrite would be nearly impossible to construct, let alone verify. By ensuring the generated I6 corresponds line-by-line with the original, I also ensure that the I7 code isn’t slower than the original I6. Or at least, not by much.
I’ll further try to use the original I6 names where possible for variables, functions, etc., though I can only go so far. Inform names parameters and locals formulaically, like t_0, t_1, and so on, but the names will at least appear in the comments in the generated I6.
I have two examples already. Version 1 looks like I block-copied Parser.i6t from Appendix B into the IDE and hit compile. Except, it actually does compile. Version 1 is just a base-line to start from. Version 2 I’ve modernized three functions — ScopeWithin, PlaceInScope, and AddToScope — with quite a bit of technical bits added in a volume at the beginning of the file for support. Version 2 also compiles and works, and indicates what later versions will likely look like. Comments at the beginning of the game file are mine, while most of the comments spread throughout are Graham’s from Appendix B.
For the purposes of correctness I won’t include any fixes or upgrades that the extensions site have. For now, this is a pure translation project, nothing more.
I’ll post incremental updates in the forum thread.
Pingback: The “Rewrite The Parser in Inform 7″ Project Nears Completion | Seattle Interactive Fiction