From 942970ddc1f64e7bbd650cc500ea78d99a7b16a3 Mon Sep 17 00:00:00 2001 From: Ludovic Jacomme Date: Tue, 23 Jul 2002 10:44:41 +0000 Subject: [PATCH] Petit bug dans la grammaire --- alliance/src/ctp/src/ctp_l.l | 4 +- alliance/src/ctp/src/ctp_parse.c | 2 - alliance/src/ctp/src/ctp_y.y | 131 ++++++++++++++++++++++++++++--- 3 files changed, 121 insertions(+), 16 deletions(-) diff --git a/alliance/src/ctp/src/ctp_l.l b/alliance/src/ctp/src/ctp_l.l index 83eb101f..5b413bed 100644 --- a/alliance/src/ctp/src/ctp_l.l +++ b/alliance/src/ctp/src/ctp_l.l @@ -64,10 +64,11 @@ static el_mc tab_mc []= {"ag" ,_AG}, {"and" ,_AND}, {"array" ,ARRAY}, + {"assume" ,_ASSUME}, {"au" ,_AU}, {"ax" ,_AX}, {"begin" ,_BEGIN}, - {"constant" ,CONSTANT}, + {"define" ,_DEFINE}, {"downto" ,DOWNTO}, {"ef" ,_EF}, {"eg" ,_EG}, @@ -79,6 +80,7 @@ static el_mc tab_mc []= {"false" ,_FALSE}, {"high" ,_HIGH}, {"ift" ,_IFT}, + {"initial" ,_INITIAL}, {"is" ,IS}, {"left" ,_LEFT}, {"length" ,_LENGTH}, diff --git a/alliance/src/ctp/src/ctp_parse.c b/alliance/src/ctp/src/ctp_parse.c index 01ee99cd..57e10dce 100644 --- a/alliance/src/ctp/src/ctp_parse.c +++ b/alliance/src/ctp/src/ctp_parse.c @@ -86,8 +86,6 @@ ctlfig_list *loadctlfig( InputFileName ) int Value; int Index; - fprintf( stdout, "loadctlfig InputFileName %s\n", InputFileName ); - ctp_y_in = mbkfopen( InputFileName, "ctl", "r" ); if ( ctp_y_in == (FILE *)0 ) diff --git a/alliance/src/ctp/src/ctp_y.y b/alliance/src/ctp/src/ctp_y.y index ee959902..41f81bb9 100644 --- a/alliance/src/ctp/src/ctp_y.y +++ b/alliance/src/ctp/src/ctp_y.y @@ -130,7 +130,9 @@ %token CASE %token COMPONENT %token CONFIGURATION -%token CONSTANT +%token _DEFINE +%token _ASSUME +%token _INITIAL %token CharacterLit %token Colon %token Comma @@ -217,7 +219,6 @@ %left DoubleStar %right ABS _NOT -%type .VarAsgn__expression. %type expression %type relation..AND__relation.. %type relation..OR__relation.. @@ -334,6 +335,8 @@ ctl_declarative_part block_declarative_item : constant_declaration | variable_declaration + | assumption_declaration + | initial_declaration | type_declaration | subtype_declaration | error @@ -344,7 +347,7 @@ block_declarative_item ; constant_declaration - : CONSTANT + : _DEFINE Identifier Colon type_mark @@ -411,27 +414,109 @@ constant_declaration } ; +assumption_declaration + : _ASSUME + Identifier + constant_VarAsgn__expression + Semicolon_ERR + { + ctltype_list *Type; + ctldecl_list *CtlAss; + vexexpr *VexValue; + chain_list *HeadChain; + chain_list *ScanChain; + ctp_vexstr *VexStr; + short Signed; + long Left; + long Right; + short Width; + long AttrLeft; + long AttrRight; + + VexValue = simpvexexpr( $3.VEX ); + + Type = val_type( "boolean" ); + + AttrLeft = -1; + AttrRight = -1; + + CtlAss = (ctldecl_list *)ctp_addstr( 'A',0, Type, + VEX_TYPE_BOOLEAN, 0, $2, AttrLeft,AttrRight,VexValue); + + Signed = 0; + Left = -1; + Right = -1; + + addtab(hshtab,$2,CTP_MODNAM,CTP_SYMDFN,CTP_CSTDFN); + addtab(hshtab,$2,CTP_MODNAM,CTP_TYPDFN,VEX_TYPE_BOOLEAN); + addtab(hshtab,$2,CTP_MODNAM,CTP_WMNDFN,Left); + addtab(hshtab,$2,CTP_MODNAM,CTP_WMXDFN,Right); + addtab(hshtab,$2,CTP_MODNAM,CTP_ATLDFN,AttrLeft); + addtab(hshtab,$2,CTP_MODNAM,CTP_ATRDFN,AttrRight); + addtab(hshtab,$2,CTP_MODNAM,CTP_LBLDFN,0); + addtab(hshtab,$2,CTP_MODNAM,CTP_PNTDFN,(long)CtlAss->VEX_ATOM); + addtab(hshtab,$2,CTP_MODNAM,CTP_SUNDFN,Signed ); + } + ; + +initial_declaration + : _INITIAL + Identifier + constant_VarAsgn__expression + Semicolon_ERR + { + ctltype_list *Type; + ctldecl_list *CtlAss; + vexexpr *VexValue; + chain_list *HeadChain; + chain_list *ScanChain; + ctp_vexstr *VexStr; + short Signed; + long Left; + long Right; + short Width; + long AttrLeft; + long AttrRight; + + VexValue = simpvexexpr( $3.VEX ); + + Type = val_type( "boolean" ); + + AttrLeft = -1; + AttrRight = -1; + + CtlAss = (ctldecl_list *)ctp_addstr( 'I',0, Type, + VEX_TYPE_BOOLEAN, 0, $2, AttrLeft,AttrRight,VexValue); + + Signed = 0; + Left = -1; + Right = -1; + + addtab(hshtab,$2,CTP_MODNAM,CTP_SYMDFN,CTP_CSTDFN); + addtab(hshtab,$2,CTP_MODNAM,CTP_TYPDFN,VEX_TYPE_BOOLEAN); + addtab(hshtab,$2,CTP_MODNAM,CTP_WMNDFN,Left); + addtab(hshtab,$2,CTP_MODNAM,CTP_WMXDFN,Right); + addtab(hshtab,$2,CTP_MODNAM,CTP_ATLDFN,AttrLeft); + addtab(hshtab,$2,CTP_MODNAM,CTP_ATRDFN,AttrRight); + addtab(hshtab,$2,CTP_MODNAM,CTP_LBLDFN,0); + addtab(hshtab,$2,CTP_MODNAM,CTP_PNTDFN,(long)CtlAss->VEX_ATOM); + addtab(hshtab,$2,CTP_MODNAM,CTP_SUNDFN,Signed ); + } + ; + + constant_VarAsgn__expression : VarAsgn expression { $$ = $2; } ; -.VarAsgn__expression. - : /*empty*/ - { $$.VEX = NULL ;} - | VarAsgn - expression - { $$ = $2 ;} - ; - variable_declaration : _VARIABLE identifier_list Colon type_mark .constraint. - .VarAsgn__expression. Semicolon_ERR { char *LocalName; @@ -2070,7 +2155,7 @@ vexexpr *exp; if ( object == 'C' ) { - CtlDeclar = addctldeclcst( CTP_HEADFIG, vex_pnt ); + CtlDeclar = addctldecldef( CTP_HEADFIG, vex_pnt ); CtlDeclar->TYPE = prtype; CtlDeclar->VEX_INIT = exp; addctlline( CTP_HEADFIG, &CtlDeclar->LINE, CTP_LINNUM ); @@ -2086,6 +2171,26 @@ vexexpr *exp; pnt = (void *)CtlDeclar; } + else + if ( object == 'A' ) + { + CtlDeclar = addctldeclass( CTP_HEADFIG, vex_pnt ); + CtlDeclar->TYPE = prtype; + CtlDeclar->VEX_INIT = exp; + addctlline( CTP_HEADFIG, &CtlDeclar->LINE, CTP_LINNUM ); + + pnt = (void *)CtlDeclar; + } + else + if ( object == 'I' ) + { + CtlDeclar = addctldeclinit( CTP_HEADFIG, vex_pnt ); + CtlDeclar->TYPE = prtype; + CtlDeclar->VEX_INIT = exp; + addctlline( CTP_HEADFIG, &CtlDeclar->LINE, CTP_LINNUM ); + + pnt = (void *)CtlDeclar; + } return (pnt); }