Sign in to follow this  
ThoughtCriminal

handling symbol redefinition (parsers)

Recommended Posts

Just a quick MASM example: foo dd 0 FOO dd 0 error A2005: symbol redefinition : foo How do parsers handle the case of symbols? I think so internally will change all to upper or lower. I tried to Google but have not found anything. So any tips on managing case in parsers? Thanks.

Share this post


Link to post
Share on other sites
For symbol tables in languages where identifiers are case-insensitive, parsers generally store the entries indexed with the all upper or all lower case. More recent parsers will also store the original string as a data member for the symbol entry so the symbol can be referenced by the symbol table as the original case that the user had entered.

Share this post


Link to post
Share on other sites
Hmmmm, you gave me an idea.

I think what you are saying is if the parser reads the symbol:

Foo dd 0

The symbol manager could give it an internal name toupper FOO.

But later on if the paser finds:

fOO dd 0

The symbol manager would try to give it the internal name FOO, but with a check should find that FOO is already taken internally thus a symbol redefinition has occured.

A user name: Foo , and an internal name FOO. Force the internal names to upper or lower case and any case of ambiguity is removed.

Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this