/[cuyo]/cuyo/src/parser.yy
ViewVC logotype

Diff of /cuyo/src/parser.yy

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.48 by caeles, Sat Nov 26 21:29:52 2005 UTC revision 1.49 by caeles, Sun Nov 27 02:57:05 2005 UTC
# Line 28  Line 28 
28  #include "knoten.h"  #include "knoten.h"
29  #include "blop.h"  #include "blop.h"
30  #include "variable.h"  #include "variable.h"
31    #include "ort.h"
32    
33    
34  /***********************************************************************/  /***********************************************************************/
# Line 114  static DefKnoten * gAktDefKnoten; Line 115  static DefKnoten * gAktDefKnoten;
115    ListenKnoten * listenknoten;    ListenKnoten * listenknoten;
116    WortKnoten * wortknoten;    WortKnoten * wortknoten;
117    Variable * variable;    Variable * variable;
118      Ort * ort;
119    int variablen_ort[2];    int variablen_ort[2];
120  }  }
121    
# Line 140  static DefKnoten * gAktDefKnoten; Line 142  static DefKnoten * gAktDefKnoten;
142  %token SWITCH_TOK IF_TOK BIS_TOK VAR_TOK BUSY_TOK  %token SWITCH_TOK IF_TOK BIS_TOK VAR_TOK BUSY_TOK
143  %token ADD_TOK SUB_TOK MUL_TOK DIV_TOK MOD_TOK  %token ADD_TOK SUB_TOK MUL_TOK DIV_TOK MOD_TOK
144  %token RND_TOK GGT_TOK BONUS_TOK MESSAGE_TOK EXPLODE_TOK  %token RND_TOK GGT_TOK BONUS_TOK MESSAGE_TOK EXPLODE_TOK
145    %token FREMD_TOK
146  %token <str> REINWORT_TOK WORT_TOK NACHBAR8_TOK NACHBAR6_TOK  %token <str> REINWORT_TOK WORT_TOK NACHBAR8_TOK NACHBAR6_TOK
147  %token <zahl> NULLEINS_TOK ZAHL_TOK HALBZAHL_TOK BUCHSTABE_TOK PFEIL_TOK  %token <zahl> NULLEINS_TOK ZAHL_TOK HALBZAHL_TOK BUCHSTABE_TOK PFEIL_TOK
148    
149  %type <zahl> zuweisungs_operator zahl zahl_oder_halbzahl vorzeichen_zahl  %type <zahl> zuweisungs_operator zahl halbzahl zahl_oder_halbzahl vorzeichen_zahl
150  %type <str> wort links_von_def proc_def_wort var_def_wort  %type <str> wort links_von_def proc_def_wort var_def_wort
151  %type <code> code code_1 stern_at buch_stern auswahl_liste set_zeile  %type <code> code code_1 stern_at buch_stern auswahl_liste set_zeile
152  %type <code> ausdruck  %type <code> ausdruck halbort nulleins_ort
153  /*%type <bed> bedingung*/  /*%type <bed> bedingung*/
154    
155  %type <knoten> rechts_von_def def_liste_eintrag  %type <knoten> rechts_von_def def_liste_eintrag
156  %type <listenknoten> def_liste  %type <listenknoten> def_liste
157    %type <ort> ort absort relort
158  %type <variablen_ort> variablen_ort  %type <variablen_ort> variablen_ort
159    
160  /* Eigentlich wäre es naheliegend und schön, wenn alles einen DefKnoten  /* Eigentlich wäre es naheliegend und schön, wenn alles einen DefKnoten
# Line 485  zuweisungs_operator: '=' { $$ = set_code Line 489  zuweisungs_operator: '=' { $$ = set_code
489  ;  ;
490    
491  /* * oder *@(x,y) oder @(x,y)* */  /* * oder *@(x,y) oder @(x,y)* */
492  stern_at: '*'             { $$ = newCode0(mal_code); }  stern_at:
493    | '*' '@' '(' zahl_oder_halbzahl ',' zahl_oder_halbzahl ')'    {      '*'       { $$ = newCode0(mal_code); }
494        $$ = newCode3(mal_code_relativ, $4, $6, 1);    | '*' ort   { $$ = newCode2(mal_code_fremd, $2, 1); }
495      }    | ort '*'   { $$ = newCode2(mal_code_fremd, $1, -1); }
   | '@' '(' zahl_oder_halbzahl ',' zahl_oder_halbzahl ')' '*'    {  
       $$ = newCode3(mal_code_relativ, $3, $5, -1);  
     }  
496  ;  ;
497    
498  /* Buchtabe oder Buchstabe* oder *; und evtl. @(bla, blub) */  /* Buchtabe oder Buchstabe* oder *; und evtl. @(bla, blub) */
# Line 635  variablen_ort: Line 636  variablen_ort:
636      }      }
637  ;  ;
638    
639    halbort:
640        ausdruck   { $$ = $1; }
641      | halbzahl   { $$ = newCode1(zahl_acode, $1); }
642    ;
643    
644    nulleins_ort:
645        '(' ausdruck ')'   { $$ = $2; }
646      | NULLEINS_TOK       { $$ = newCode1(zahl_acode, $1); }
647    ;
648    
649    absort:
650                                      { $$ = new Ort(absort_global); }
651      | '(' halbort ',' halbort ')'   { $$ = new Ort(absort_feld, $2, $4); }
652      | nulleins_ort                  { $$ = new Ort(absort_fall, $1); }
653    ;
654    
655    relort:
656        '(' halbort ',' halbort ')'   { $$ = new Ort($2, $4); }
657      | nulleins_ort                  { $$ = new Ort($1); }
658    ;
659    
660    ort:
661        '@' relort         { $$ = $2; }
662      | FREMD_TOK absort   { $$ = $2; }
663    ;
664    
665    
666    
667    
668    
669  zahl: ZAHL_TOK   { $$ = $1; }  zahl: ZAHL_TOK   { $$ = $1; }
670     | NULLEINS_TOK   { $$ = $1; }     | NULLEINS_TOK   { $$ = $1; }
671  ;  ;
672    
673    zahl_oder_halbzahl: vorzeichen_zahl    { $$ = $1; }
674       | halbzahl                          { $$ = $1; }
675    ;
676    
677  /* Bei relativen Koordinaten für Variablenangaben dürfen in Y-Richtung  /* Bei relativen Koordinaten für Variablenangaben dürfen in Y-Richtung
678     auch Halbganze Zahlen angegeben werden... (für Hex-Level) */     auch Halbganze Zahlen angegeben werden... (für Hex-Level) */
679  zahl_oder_halbzahl: vorzeichen_zahl    { $$ = $1; }  halbzahl:
680     | HALBZAHL_TOK                      {       HALBZAHL_TOK                      {
681         /* Halbzahlen sollen intern aufgerundet gespeichert werden... */         /* Halbzahlen sollen intern aufgerundet gespeichert werden... */
682         $$ = $1 + 1;         $$ = $1 + 1;
683       }       }

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26