Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Anybody know Bison/Yacc?
2017-07-23 13:25
oziphantom

Registered: Oct 2014
Posts: 478
Anybody know Bison/Yacc?

I want to extend the VICE monitor to be able to look up an address in a "bank" on a break.. so something like
break $1234 IF @IO:D010 & $40 = $40
where @IO:D010 looks up the VIC register D010 and get its value.

CMD_BANK BANKNAME end_cmd
                     { mon_bank(e_default_space, $2); }
seems to be the C you can use to change the banks
int monbank = mon_interfaces[mem]->current_bank;/code] seems like it would allow you to save the current bank. And
MEMSPACE src_mem = addr_memspace(start_addr);
WORD start = addr_location(start_addr);
byte1 = mon_get_mem_val(src_mem, start));
could be used to look up the value, its just a matter of putting it all together in a yacc file to glue it together and make it work as part of the condition_expression, so if somebody could help me with the yacc modifications I would greatly appreciate it ;)

For completeness it probably needs to be C: only and making it take the form @C:(bank):Addr to make it clear might be best..
2017-07-26 13:37
knue

Registered: Dec 2012
Posts: 37
yes, I know yacc/bison. It's been a while though and I highly recommend anyone who wants to write a parser to *not* use these tools. Anyway, what do you want to know?
2017-07-26 13:41
chatGPZ

Registered: Dec 2001
Posts: 11088
Quote:
I highly recommend anyone who wants to write a parser to *not* use these tools.

*grin*
2017-07-26 16:14
iAN CooG

Registered: May 2002
Posts: 3128
knue: good, find a better solution, and post to vice@sourceforge the changes for vice monitor.
(yes, I'm ironic)
2017-07-26 16:24
oziphantom

Registered: Oct 2014
Posts: 478
How to modify this https://sourceforge.net/p/vice-emu/code/HEAD/tree/trunk/vice/sr.. file.

Such that the
cond_expr: cond_expr COMPARE_OP cond_expr
           {
               $$ = new_cond; $$->is_parenthized = FALSE;
               $$->child1 = $1; $$->child2 = $3; $$->operation = $2;
           }
         | cond_expr COMPARE_OP error
           { return ERR_INCOMPLETE_COMPARE_OP; }
         | L_PAREN cond_expr R_PAREN
           { $$ = $2; $$->is_parenthized = TRUE; }
         | L_PAREN cond_expr error
           { return ERR_MISSING_CLOSE_PAREN; }
         | compare_operand
           { $$ = $1; }
         ;

compare_operand: register { $$ = new_cond;
                            $$->operation = e_INV;
                            $$->is_parenthized = FALSE;
                            $$->reg_num = $1; $$->is_reg = TRUE;
                            $$->child1 = NULL; $$->child2 = NULL;
                          }
               | number   { $$ = new_cond;
                            $$->operation = e_INV;
                            $$->is_parenthized = FALSE;
                            $$->value = $1; $$->is_reg = FALSE;
                            $$->child1 = NULL; $$->child2 = NULL;
                          }
               ;

can also handle having something of the form @C:BANKNAME:ADDR handled as one of the "rules" at the moment it handles a register such that it is .A .X .Y .SP and a number $1000, I don't need to "C" code part done, just the yacc part ;)
Allowing the user the form a monitor command such as
break $4000 IF @C:IO:D500 != $3e at the moment it handles break $4000 IF .A != $40
2017-07-26 20:07
Compyx

Registered: Jan 2005
Posts: 631
I have to agree with knue, bison/yuck is horrible. Keeps me from doing any serious work on the monitor. As with most GNU stuff, this sort of stuff worked in the 70's when memory and storage space where very valuable. Not so much now.
2017-07-26 21:20
knue

Registered: Dec 2012
Posts: 37
ok, this is what you have to do.

In mon_parse.y you need to add sth like this:
compare_operand: register { $$ = new_cond;
                            $$->operation = e_INV;
                            $$->is_parenthized = FALSE;
                            $$->reg_num = $1; $$->is_reg = TRUE;
                            $$->child1 = NULL; $$->child2 = NULL;
                          }
               | number   { $$ = new_cond;
                            $$->operation = e_INV;
                            $$->is_parenthized = FALSE;
                            $$->value = $1; $$->is_reg = FALSE;
                            $$->child1 = NULL; $$->child2 = NULL;
                          }
               | '@' BANKNAME ':' number { 
                            $$ = new_cond;
                            $$->operation = e_INV;
                            $$->is_parenthized = FALSE;
                            $$->bankname = $2; $$->value = $4; $$->is_reg = FALSE;
                            $$->child1 = NULL; $$->child2 = NULL;
               }
               ;

Of course, you'll add a another field bankname to cond_node_s in montypes.h.
Be careful to not read garbage data when you read from this field. All other parts of the code which construct this thing must initialize this field with some default value. Check:
%type<cond_node> opt_if_cond_expr cond_expr compare_operand

Here you can see, which rules create a cond_node and need to initialize this new field.

ah, this code uses the syntax:
@bankname:number
2017-07-26 21:31
knue

Registered: Dec 2012
Posts: 37
speaking of cond_node_s. you can probably put value and reg_num in a union.
2017-07-27 20:07
Count Zero

Registered: Jan 2003
Posts: 1810
Phew - thx knue and ozi for going for this. My last small changes on that yacc shice broke a few things and had to be reverted :)

That feature addition would rock a lot!
2017-07-28 10:07
oziphantom

Registered: Oct 2014
Posts: 478
ERROR -- Unexpected token:
  break c253 if @io:$d020 == 0
                 ^


Doesn't like it, I tried adding spaces, no difference


Where banks are defined as
Available banks (some may be equivalent to others):
default *cpu ram rom io ram1 intfunc extfunc cart c64rom vdc
2017-07-28 10:45
oziphantom

Registered: Oct 2014
Posts: 478
maybe the lex file needs some modifications?
 
... 5 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Krill/Plush
lA-sTYLe/Quantum
jmin
rime/Fancy Rats
syntaxerror
kbs/Pht/Lxt
Jope/Extend
McMeatLoaf
zscs
Guests online: 351
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.5)
2 Black Beard  (9.4)
3 hedning  (9.2)
4 Baracuda  (9.1)
5 Irata  (8.5)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.045 sec.