[BACK]Return to yy_polymake.y CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / trans

Annotation of OpenXM/src/kan96xx/trans/yy_polymake.y, Revision 1.3

1.3     ! takayama    1: /* $OpenXM: OpenXM/src/kan96xx/trans/yy_polymake.y,v 1.2 2004/04/08 01:49:04 takayama Exp $ */
1.1       takayama    2: /* yacc -d -b yy_polymake -p PM yy_polymake.y */
                      3: /* yacc -d -b yy_polymake -p PM yy_polymake.y ; gcc yylex_polymake.c  yy_polymake.tab.c*/
                      4: %{
                      5: #include <stdio.h>
                      6: #include "yylex_polymake.h"
                      7: %}
                      8:
                      9:
1.3     ! takayama   10: %token PM_emptyLine PM_keyword PM_LCurryBrace PM_RCurryBrace PM_LAngle PM_RAngle PM_LBracket PM_RBracket PM_colon PM_LBrace PM_RBrace
1.1       takayama   11: %token PM_number PM_newline
                     12:
                     13: %%
                     14: program
                     15: :
                     16: programList {
                     17:   pmPrintObject(stdout,$1);
1.2       takayama   18:   fprintf(stdout,"\n");
                     19: }
                     20: | pmemptyLine programList {
                     21:   pmPrintObject(stdout,$2);
1.1       takayama   22:   fprintf(stdout,"\n");
                     23: }
                     24: ;
                     25:
                     26:
                     27: programList
                     28: :
                     29: pmdata {
                     30:   pmObjectp ob;
                     31:   ob = pmNewTreeObject("data");
                     32:   ob = pmAddChild($1,ob);
                     33:   $$ = ob;
                     34: }
                     35: | pmdata programList {
                     36:   pmObjectp ob;
                     37:   ob = $2;
                     38:   ob = pmAddChild($1,ob);
                     39:   $$ = ob;
                     40: }
                     41: ;
                     42:
                     43: pmnumberList
                     44: :
                     45: PM_number {
                     46:   $$=pmNewListObject($1);
                     47: }
                     48: | PM_number pmnumberList {
                     49:   pmObjectp t;
                     50:   t = $2;
                     51:   if (t->tag != PMobject_list) {
                     52:        fprintf(stderr,"pmnumberList: list is broken.");
                     53:        $$=$1;
                     54:   }else{
                     55:        $$=pmCons($1,(struct pmList *)(t->body));
                     56:   }
                     57: }
                     58: ;
                     59:
1.3     ! takayama   60: pmline
        !            61: : dataUnitList PM_newline {
        !            62:   $$=$1;
        !            63: }
        !            64: ;
1.1       takayama   65:
1.3     ! takayama   66: dataUnitList
        !            67: : dataUnit {
        !            68:   $$=$1;
        !            69: }
        !            70: | dataUnit dataUnitList {
        !            71:   pmObjectp t;
        !            72:   t=pmNewListObject($2);
        !            73:   $$=pmCons($1,(struct pmList *)(t->body));
        !            74: }
        !            75: | dataUnitList PM_colon dataUnitList { /* a : b --> COLON(a,b) */
        !            76:   pmObjectp t;
        !            77:   pmObjectp r;
        !            78:   r = pmNewTreeObject("_colon");
        !            79:   r = pmAddChild($3,r);
        !            80:   r = pmAddChild($1,r);
        !            81:   $$=r;
        !            82: }
        !            83: ;
        !            84:
        !            85: dataUnit
        !            86: : pmnumberList {
1.1       takayama   87:   $$=$1;
                     88: }
1.3     ! takayama   89: | PM_LCurryBrace dataUnitList PM_RCurryBrace {
        !            90:   $$=pmAddChild($2,pmNewTreeObject("_set")); /* set */
        !            91:   /*printf("{}");pmPrintObject(stdout,$2);*/
        !            92: }
        !            93: | PM_LAngle dataUnitList PM_RAngle {
        !            94:   $$=pmAddChild($2,pmNewTreeObject("_pairs"));   /* pairs */
        !            95:   /* printf("<>");pmPrintObject(stdout,$2); */
        !            96: }
        !            97: | PM_LBracket dataUnitList PM_RBracket {
        !            98:   $$=pmAddChild($2,pmNewTreeObject("_bracket"));  /* bracket */
        !            99:   /* printf("[]");pmPrintObject(stdout,$2); */
        !           100: }
        !           101: | PM_LBrace dataUnitList PM_RBrace {
        !           102:   $$=pmAddChild($2,pmNewTreeObject("_tuple"));  /* tuple */
        !           103:   /* printf("()");pmPrintObject(stdout,$2); */
1.1       takayama  104: }
                    105: ;
                    106:
                    107: pmlineList
                    108: :
                    109: pmline {
                    110:   $$=pmNewListObject($1);
                    111: }
                    112: | pmline pmlineList {
                    113:   pmObjectp t;
                    114:   t = $2;
                    115:   if (t->tag != PMobject_list) {
                    116:        fprintf(stderr,"pmlineList: list is broken.");
                    117:        $$=$1;
                    118:   }else{
                    119:     $$=pmCons($1,(struct pmList *)(t->body));
                    120:   }
                    121: }
                    122: ;
                    123:
                    124:
                    125: pmdata
                    126: :
                    127: PM_keyword   PM_newline pmemptyLine {
                    128:   $$=pmNewTreeObjecto($1);
                    129: }
                    130: | PM_keyword PM_newline pmlineList pmemptyLine {
                    131:   pmObjectp ob;
                    132:   ob = pmNewTreeObjecto($1);
                    133:   ob = pmAddChild($3,ob);
                    134:   $$=ob;
                    135: }
                    136: ;
                    137:
                    138:
                    139: pmemptyLine
                    140: :
                    141: PM_emptyLine
                    142: ;
                    143:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>