Interweb tech support request

Sep 11, 2008 10:33

Dear Tubes, Please help.

So I'm playing with Yacc for the first time.  I'm learning from the Flex and Bison manuals.  I own the dragon book but I haven't cracked it open yet (which may be part of my problem).

As a first project I'm trying to build a parser for the output of a game I play.  I can't redefine the language. In fact I don't have a ( Read more... )

Leave a comment

questions? i_am_moof September 12 2008, 01:21:29 UTC
It looks like you found your answers. I downloaded the code without reading everything, compiled it, and it seems to work.

Still got questions? I just wrote an assembler for a custom computer design. I made the syntax capable of RPN and infix expression analysis. The assembly language I created is very similar to B and not as advanced as C. If your interested, I may be able to share bits of it. I can show you on Tuesday.

Reply

Re: questions? gramatan September 12 2008, 20:35:34 UTC
Not quite, that's the code without the shift-reduce error because it doesn't associate the PARTSNAME action with the NEW (that starts a PC. I probably shouldn't have put a working version up.

I just put up the actual current version. It's not exactly the same as the initial example but it's equivalent. I also put up the code and data file that the initial example came from.

ftp://frontiernet.net/pub/users/rreay/CoHParserFails.zip

Reply

Re: questions? boba September 12 2008, 20:59:12 UTC
Granted, I'm just looking at the code, not actually running it... (but I can tell already you're using bison and not yacc ( ... )

Reply

Re: questions? boba September 12 2008, 22:02:48 UTC
Walking back from the vending machine, another thought just hit me. What I said above is incomplete.

Is HPMAX always the end of one of these funky long chain of records? More to the point, is NEW always the start of a new chain? You're going to have to reflect that in the grammar, or you'll still get shift/reduce errors.

The parser has to decide, at the end of one of these records, whether it's done or if it continues to the next line. You might make a rule that matches all the possible commands that follow in a given case, ensuring that there's no NEW or such in there. Then, the parser can read ahead (a whole fucking lot), see the NEW (or end of file), and backtrack with all the intervening records being marked together in the same pattern.

Reply

Re: questions? gramatan September 15 2008, 15:01:10 UTC
Whoa interesting. It does appear that HPMAX ends a character definition. There can be extra actions in the middle that define the initial position, orientation, and animation(s) but it does end on HPMAX.

NEW is always the first token in a chain that defines a character. So of the actions between the NEW and HPMAX can occur outside them, but others like PARTSNAME can't

So yeah, I think I see how I can define an in_character_valid non terminal that can by used in a character. The parser can detect a new class of errors and can mark everything associated with that character.

Reply

Re: questions? gramatan September 15 2008, 14:53:08 UTC
I'm torn between doing it in lex and having lex return the action or ignoring the line to line structure and parsing each line independently and adding that higher level of order in my code ( ... )

Reply


Leave a comment

Up