🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Tangent: Parsing

Published April 14, 2008
Advertisement
I have today off and completely for my own use. I'm not a big fan of vacations, and using my time for just a personal day is so nice.

This morning then was work on Tangent. Whimsy pushed me to work on simple parsing for expressions. Not quite sure why since it's not the next step in the work (though it's probably because the actual next steps are more daunting).

Anyways, the lexical stuff is using the Lexer stuff for C# I have from an existing project. The grammar for things is currently very, very simple:

block := { statement* }statement := element* ;element := identifier|member_access|type_parameterization|paren_expression|operator_shorthand|blockidentifier := member_access := .type_parameterization := < element >paren_expression := ( element* )operator_shorthand := 


Very simple. Most of the work will be done later taking the stream of elements and organizing them into a sane order of operations. There is a slight problem with this compared to more traditional parsers, mainly the type parameterization.

Something like Dictionary foo will need to be Dictionary<(int,string)> foo. Mildly annoying, but multi-parameter generics aren't terribly common and I can't think of a better way to keep things intuitive-ish, while also disambiguating the angle bracket usages.

And I don't suspect things will get much more complex for code that isn't type declarations.
Previous Entry Tangent: Expressions
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