Language Genesis: Part 1 - Parsing.

Published December 27, 2007
Advertisement
The final 4 pages or so of BNF got coded over the weekend. Clocks in at around 1750 lines excluding library code. A nice 2 hours worth of simple bugfixing, then another hour fixing the BNF.

(for those curious, there needs to be special care taken with Array Types, Nullable Types and Namespace or TypeName entries so that they don't infinitely loop. You can't just parse their entries individually, you need to look for the rank specifiers, ?, and . respectively and shortcut things if they're not there)

I'm sure there's tons more little gotchas or things I typo'd. I'll fix/clean these as I need or come across them, but this should be good enough to begin on the simple extension. First on the chart is replacing is/as/(cast) with ducktyping equivalents.

And tonight's 'screenshot':

Parsing target:
class foo{}


Resultant un-pruned tree:
CompilationUnit  0:4 - class foo {}  rms.Support.Parsing.Token.Sequence  0:4 - class foo {}    rms.Support.Parsing.Token.Sequence  0:0 -      rms.Support.Parsing.Token.Sequence  0:0 -        rms.Support.Parsing.Token.Series  0:0 -        rms.Support.Parsing.Token.Series  0:0 -      rms.Support.Parsing.Token.Series  0:0 -    rms.Support.Parsing.Token.Series  0:4 - class foo {}      TypeDeclaration  0:4 - class foo {}        ClassDeclaration  0:4 - class foo {}          rms.Support.Parsing.Token.Sequence  0:4 - class foo {}            rms.Support.Parsing.Token.Sequence  0:4 - class foo {}              rms.Support.Parsing.Token.Sequence  0:2 - class foo                rms.Support.Parsing.Token.Sequence  0:2 - class foo                  rms.Support.Parsing.Token.Sequence  0:2 - class foo                    rms.Support.Parsing.Token.Sequence  0:2 - class foo                      rms.Support.Parsing.Token.Sequence  0:1 - class                        rms.Support.Parsing.Token.Sequence  0:0 -                          rms.Support.Parsing.Token.Sequence  0:0 -                            rms.Support.Parsing.Token.Series  0:0 -                            rms.Support.Parsing.Token.Series  0:0 -                          rms.Support.Parsing.Token.LiteralTokenParser  0:0 -                        ClassKeyword  0:1 - class                          rms.Support.Parsing.Token.LiteralTokenParser  0:1 - class                      Identifier  1:2 - foo                        rms.Support.Parsing.Token.TokenTypeParser  1:2 - foo                    rms.Support.Parsing.Token.LiteralTokenParser  2:2 -                  rms.Support.Parsing.Token.LiteralTokenParser  2:2 -                rms.Support.Parsing.Token.Series  2:2 -              ClassBody  2:4 - {}                rms.Support.Parsing.Token.Sequence  2:4 - {}                  rms.Support.Parsing.Token.Sequence  2:3 - {                    rms.Support.Parsing.Token.LiteralTokenParser  2:3 - {                    rms.Support.Parsing.Token.Series  3:3 -                  rms.Support.Parsing.Token.LiteralTokenParser  3:4 - }            rms.Support.Parsing.Token.LiteralTokenParser  4:4 - 
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement