2011-03-23 28 views
0

我在BNF语法,我用BNF转换到这个语法转化为可执行的程序用C代码。然而,我有一个具体的问题,关于$ 1的GrammarCl'没有在GrammarCl.y文件中声明的类型,我不知道如何解决这个问题。我已经看过很多论坛,并且搜索了这个并尝试了很多东西,但仍然不知道如何解决它。

我得到的错误是:

gcc的-g -W -Wall -c Absyn.c
柔性-PGrammarCl -oLexer.c GrammarCl.l
gcc的-g -W -Wall - çLexer.c
Lexer.c:1362:警告: 'yyunput' 定义但未使用
Lexer.c:1408:警告: '输入' 定义但未使用
野牛-t -pGrammarCl GrammarCl.y -o Parser.c
GrammarCl.y:614.70-71:$ 1 of GrammarCl' has no declared type
GrammarCl.y:614.74-75: $2 of
Grammar CL”没有声明的类型
化妆:* [Parser.c]错误1

以下是GrammarCl.y文件语法:

/* This Bison file was machine-generated by BNFC */ 
%{ 
#include <stdlib.h> 
#include <stdio.h> 
#include <string.h> 
#include "Absyn.h" 
#define initialize_lexer GrammarCl_initialize_lexer 
extern int yyparse(void); 
extern int yylex(void); 
extern int initialize_lexer(FILE * inp); 
void yyerror(const char *str) 
{ 
    fprintf(stderr,"error: %s\n",str); 
} 

GrammarCl YY_RESULT_GrammarCl_ = 0; 
GrammarCl pGrammarCl(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_GrammarCl_; 
    } 
} 

Dictionary YY_RESULT_Dictionary_ = 0; 
Dictionary pDictionary(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Dictionary_; 
    } 
} 

Action YY_RESULT_Action_ = 0; 
Action pAction(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Action_; 
    } 
} 

Words YY_RESULT_Words_ = 0; 
Words pWords(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Words_; 
    } 
} 

Contract YY_RESULT_Contract_ = 0; 
Contract pContract(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Contract_; 
    } 
} 

Statement YY_RESULT_Statement_ = 0; 
Statement pStatement(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Statement_; 
    } 
} 

StatementSequence YY_RESULT_StatementSequence_ = 0; 
StatementSequence pStatementSequence(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_StatementSequence_; 
    } 
} 

Sentence YY_RESULT_Sentence_ = 0; 
Sentence pSentence(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Sentence_; 
    } 
} 

ListClause YY_RESULT_ListClause_ = 0; 
ListClause pListClause(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_ListClause_; 
    } 
} 

ListClauseXorOBL YY_RESULT_ListClauseXorOBL_ = 0; 
ListClauseXorOBL pListClauseXorOBL(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_ListClauseXorOBL_; 
    } 
} 

ListClauseXorPER YY_RESULT_ListClauseXorPER_ = 0; 
ListClauseXorPER pListClauseXorPER(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_ListClauseXorPER_; 
    } 
} 

Clause YY_RESULT_Clause_ = 0; 
Clause pClause(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Clause_; 
    } 
} 

TestOpClause YY_RESULT_TestOpClause_ = 0; 
TestOpClause pTestOpClause(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_TestOpClause_; 
    } 
} 

TestOpCoAct YY_RESULT_TestOpCoAct_ = 0; 
TestOpCoAct pTestOpCoAct(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_TestOpCoAct_; 
    } 
} 

CTD YY_RESULT_CTD_ = 0; 
CTD pCTD(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_CTD_; 
    } 
} 

CTDCoAct YY_RESULT_CTDCoAct_ = 0; 
CTDCoAct pCTDCoAct(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_CTDCoAct_; 
    } 
} 

CTP YY_RESULT_CTP_ = 0; 
CTP pCTP(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_CTP_; 
    } 
} 

CTPCoAct YY_RESULT_CTPCoAct_ = 0; 
CTPCoAct pCTPCoAct(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_CTPCoAct_; 
    } 
} 

ObligationCl YY_RESULT_ObligationCl_ = 0; 
ObligationCl pObligationCl(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_ObligationCl_; 
    } 
} 

OblCoAct YY_RESULT_OblCoAct_ = 0; 
OblCoAct pOblCoAct(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_OblCoAct_; 
    } 
} 

ProhibitionCl YY_RESULT_ProhibitionCl_ = 0; 
ProhibitionCl pProhibitionCl(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_ProhibitionCl_; 
    } 
} 

ProCoAct YY_RESULT_ProCoAct_ = 0; 
ProCoAct pProCoAct(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_ProCoAct_; 
    } 
} 

PermissionCl YY_RESULT_PermissionCl_ = 0; 
PermissionCl pPermissionCl(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_PermissionCl_; 
    } 
} 

PerCoAct YY_RESULT_PerCoAct_ = 0; 
PerCoAct pPerCoAct(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_PerCoAct_; 
    } 
} 

CoAct YY_RESULT_CoAct_ = 0; 
CoAct pCoAct(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_CoAct_; 
    } 
} 

CoActStar YY_RESULT_CoActStar_ = 0; 
CoActStar pCoActStar(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_CoActStar_; 
    } 
} 

Endurance YY_RESULT_Endurance_ = 0; 
Endurance pEndurance(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Endurance_; 
    } 
} 

ContradictionWords YY_RESULT_ContradictionWords_ = 0; 
ContradictionWords pContradictionWords(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_ContradictionWords_; 
    } 
} 

ConWor YY_RESULT_ConWor_ = 0; 
ConWor pConWor(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_ConWor_; 
    } 
} 

ContradictoryWor YY_RESULT_ContradictoryWor_ = 0; 
ContradictoryWor pContradictoryWor(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_ContradictoryWor_; 
    } 
} 

Act YY_RESULT_Act_ = 0; 
Act pAct(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Act_; 
    } 
} 

Variable_name YY_RESULT_Variable_name_ = 0; 
Variable_name pVariable_name(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Variable_name_; 
    } 
} 

WordAction YY_RESULT_WordAction_ = 0; 
WordAction pWordAction(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_WordAction_; 
    } 
} 

Lett YY_RESULT_Lett_ = 0; 
Lett pLett(FILE *inp) 
{ 
    initialize_lexer(inp); 
    if (yyparse()) 
    { /* Failure */ 
    return 0; 
    } 
    else 
    { /* Success */ 
    return YY_RESULT_Lett_; 
    } 
} 



%} 

%union 
{ 
    int int_; 
    char char_; 
    double double_; 
    char* string_; 
    GrammarCl grammarcl_; 
    Dictionary dictionary_; 
    Action action_; 
    Words words_; 
    Contract contract_; 
    Statement statement_; 
    StatementSequence statementsequence_; 
    Sentence sentence_; 
    ListClause listclause_; 
    ListClauseXorOBL listclausexorobl_; 
    ListClauseXorPER listclausexorper_; 
    Clause clause_; 
    TestOpClause testopclause_; 
    TestOpCoAct testopcoact_; 
    CTD ctd_; 
    CTDCoAct ctdcoact_; 
    CTP ctp_; 
    CTPCoAct ctpcoact_; 
    ObligationCl obligationcl_; 
    OblCoAct oblcoact_; 
    ProhibitionCl prohibitioncl_; 
    ProCoAct procoact_; 
    PermissionCl permissioncl_; 
    PerCoAct percoact_; 
    CoAct coact_; 
    CoActStar coactstar_; 
    Endurance endurance_; 
    ContradictionWords contradictionwords_; 
    ConWor conwor_; 
    ContradictoryWor contradictorywor_; 
    Act act_; 
    Variable_name variable_name_; 
    WordAction wordaction_; 
    Lett lett_; 

} 

%token _ERROR_ 
%token _SYMB_0 /* = */ 
%token _SYMB_1 /* ; */ 
%token _SYMB_2 /* ( */ 
%token _SYMB_3 /* ) */ 
%token _SYMB_4 /* It is mandatory to */ 
%token _SYMB_5 /* if not */ 
%token _SYMB_6 /* It is prohibited to */ 
%token _SYMB_7 /* It is permitted to */ 
%token _SYMB_8 /* after then */ 
%token _SYMB_9 /* As long as */ 
%token _SYMB_10 /* as long as */ 
%token _SYMB_11 /* # */ 
%token _SYMB_12 /* After */ 
%token _SYMB_13 /* Always */ 
%token _SYMB_14 /* Contract */ 
%token _SYMB_15 /* Contradiction */ 
%token _SYMB_16 /* Dictionary */ 
%token _SYMB_17 /* If */ 
%token _SYMB_18 /* When */ 
%token _SYMB_19 /* after */ 
%token _SYMB_20 /* always */ 
%token _SYMB_21 /* and */ 
%token _SYMB_22 /* as */ 
%token _SYMB_23 /* bas */ 
%token _SYMB_24 /* begin1 */ 
%token _SYMB_25 /* begin2 */ 
%token _SYMB_26 /* begin3 */ 
%token _SYMB_27 /* concurrently */ 
%token _SYMB_28 /* end1 */ 
%token _SYMB_29 /* end2 */ 
%token _SYMB_30 /* end3 */ 
%token _SYMB_31 /* if */ 
%token _SYMB_32 /* not */ 
%token _SYMB_33 /* or */ 
%token _SYMB_34 /* then */ 

%type <grammarcl_> GrammarCl 
%type <dictionary_> Dictionary 
%type <action_> Action 
%type <words_> Words 
%type <contract_> Contract 
%type <statement_> Statement 
%type <statementsequence_> StatementSequence 
%type <sentence_> Sentence 
%type <listclause_> ListClause 
%type <listclausexorobl_> ListClauseXorOBL 
%type <listclausexorper_> ListClauseXorPER 
%type <clause_> Clause 
%type <testopclause_> TestOpClause 
%type <testopcoact_> TestOpCoAct 
%type <ctd_> CTD 
%type <ctdcoact_> CTDCoAct 
%type <ctp_> CTP 
%type <ctpcoact_> CTPCoAct 
%type <obligationcl_> ObligationCl 
%type <oblcoact_> OblCoAct 
%type <prohibitioncl_> ProhibitionCl 
%type <procoact_> ProCoAct 
%type <permissioncl_> PermissionCl 
%type <percoact_> PerCoAct 
%type <coact_> CoAct 
%type <coactstar_> CoActStar 
%type <endurance_> Endurance 
%type <contradictionwords_> ContradictionWords 
%type <conwor_> ConWor 
%type <contradictorywor_> ContradictoryWor 
%type <act_> Act 
%type <variable_name_> Variable_name 
%type <wordaction_> WordAction 
%type <lett_> Lett 

%token<string_> _STRING_ 

%% 
GrammarCl : _SYMB_16 _SYMB_14 ContradictionWords { $$ = make_Grammar($1, $2, $3); YY_RESULT_GrammarCl_= $$; } 
; 
Dictionary : _SYMB_16 _SYMB_24 Action _SYMB_28 { $$ = make_DDictionary($3); YY_RESULT_Dictionary_= $$; } 
; 
Action : Words { $$ = make_RecurA($1); YY_RESULT_Action_= $$; } 
    | Action Action { $$ = make_RecurB($1, $2); YY_RESULT_Action_= $$; } 
; 
Words : Variable_name _SYMB_0 _STRING_ _SYMB_1 { $$ = make_WWrd($1, $3); YY_RESULT_Words_= $$; } 
; 
Contract : _SYMB_14 _SYMB_25 Statement _SYMB_29 { $$ = make_CCon($3); YY_RESULT_Contract_= $$; } 
; 
Statement : StatementSequence { $$ = make_RecurC($1); YY_RESULT_Statement_= $$; } 
    | Statement Statement { $$ = make_RecurD($1, $2); YY_RESULT_Statement_= $$; } 
; 
StatementSequence : Sentence _SYMB_1 { $$ = make_SA($1); YY_RESULT_StatementSequence_= $$; } 
; 
Sentence : ListClause { $$ = make_SentA($1); YY_RESULT_Sentence_= $$; } 
    | Sentence Sentence { $$ = make_SentB($1, $2); YY_RESULT_Sentence_= $$; } 
; 
ListClause : Clause { $$ = make_LLiAA($1); YY_RESULT_ListClause_= $$; } 
    | _SYMB_2 ListClauseXorOBL _SYMB_3 { $$ = make_LLiAB($2); YY_RESULT_ListClause_= $$; } 
    | ListClauseXorPER { $$ = make_LLiAC($1); YY_RESULT_ListClause_= $$; } 
    | ListClause _SYMB_21 ListClause { $$ = make_LLiAD($1, $3); YY_RESULT_ListClause_= $$; } 
    | _SYMB_2 ListClause _SYMB_21 ListClause _SYMB_3 { $$ = make_LLiAE($2, $4); YY_RESULT_ListClause_= $$; } 
; 
ListClauseXorOBL : ObligationCl { $$ = make_LLiXA($1); YY_RESULT_ListClauseXorOBL_= $$; } 
    | ListClauseXorOBL _SYMB_33 ListClauseXorOBL { $$ = make_LLiXC($1, $3); YY_RESULT_ListClauseXorOBL_= $$; } 
; 
ListClauseXorPER : PermissionCl { $$ = make_LListXPA($1); YY_RESULT_ListClauseXorPER_= $$; } 
    | _SYMB_2 ListClauseXorPER _SYMB_33 ListClauseXorPER _SYMB_3 { $$ = make_LListXPB($2, $4); YY_RESULT_ListClauseXorPER_= $$; } 
    | ListClauseXorPER _SYMB_33 ListClauseXorPER { $$ = make_LListXPC($1, $3); YY_RESULT_ListClauseXorPER_= $$; } 
; 
Clause : TestOpClause { $$ = make_CClA($1); YY_RESULT_Clause_= $$; } 
    | CTD { $$ = make_CClB($1); YY_RESULT_Clause_= $$; } 
    | CTP { $$ = make_CClC($1); YY_RESULT_Clause_= $$; } 
    | ObligationCl { $$ = make_CClD($1); YY_RESULT_Clause_= $$; } 
    | ProhibitionCl { $$ = make_CClE($1); YY_RESULT_Clause_= $$; } 
    | PermissionCl { $$ = make_CClF($1); YY_RESULT_Clause_= $$; } 
    | ListClauseXorOBL { $$ = make_CClG($1); YY_RESULT_Clause_= $$; } 
    | ListClauseXorPER { $$ = make_CClH($1); YY_RESULT_Clause_= $$; } 
; 
TestOpClause : TestOpCoAct { $$ = make_TTestA($1); YY_RESULT_TestOpClause_= $$; } 
; 
TestOpCoAct : _SYMB_2 _SYMB_17 _SYMB_2 CoActStar _SYMB_3 _SYMB_34 Clause _SYMB_3 { $$ = make_TTestOpCA($4, $7); YY_RESULT_TestOpCoAct_= $$; } 
    | _SYMB_2 _SYMB_2 _SYMB_13 _SYMB_3 _SYMB_2 _SYMB_17 _SYMB_2 CoActStar _SYMB_3 _SYMB_34 Clause _SYMB_3 _SYMB_3 { $$ = make_TTestOpCB($8, $11); YY_RESULT_TestOpCoAct_= $$; } 
    | _SYMB_2 _SYMB_2 _SYMB_12 _SYMB_3 _SYMB_2 _SYMB_17 _SYMB_2 CoActStar _SYMB_3 _SYMB_34 Clause _SYMB_3 _SYMB_3 { $$ = make_TTestOpCC($8, $11); YY_RESULT_TestOpCoAct_= $$; } 
    | _SYMB_2 _SYMB_2 _SYMB_18 _SYMB_3 _SYMB_2 _SYMB_17 _SYMB_2 CoActStar _SYMB_3 _SYMB_34 Clause _SYMB_3 _SYMB_3 { $$ = make_TTestOpCD($8, $11); YY_RESULT_TestOpCoAct_= $$; } 
; 
CTD : CTDCoAct { $$ = make_CCTDA($1); YY_RESULT_CTD_= $$; } 
; 
CTDCoAct : _SYMB_2 _SYMB_4 _SYMB_2 CoAct _SYMB_3 _SYMB_5 _SYMB_2 CoAct _SYMB_3 _SYMB_34 Clause _SYMB_3 { $$ = make_CCTDSB($4, $8, $11); YY_RESULT_CTDCoAct_= $$; } 
; 
CTP : CTPCoAct { $$ = make_CCTA($1); YY_RESULT_CTP_= $$; } 
; 
CTPCoAct : _SYMB_2 _SYMB_6 _SYMB_2 CoAct _SYMB_3 _SYMB_31 _SYMB_2 CoAct _SYMB_3 _SYMB_34 Clause _SYMB_3 { $$ = make_CCTPSB($4, $8, $11); YY_RESULT_CTPCoAct_= $$; } 
; 
ObligationCl : OblCoAct { $$ = make_OOblCA($1); YY_RESULT_ObligationCl_= $$; } 
; 
OblCoAct : _SYMB_2 _SYMB_4 _SYMB_2 CoAct _SYMB_3 _SYMB_3 { $$ = make_OOblA($4); YY_RESULT_OblCoAct_= $$; } 
; 
ProhibitionCl : ProCoAct { $$ = make_PProCA($1); YY_RESULT_ProhibitionCl_= $$; } 
; 
ProCoAct : _SYMB_2 _SYMB_6 _SYMB_2 CoAct _SYMB_3 _SYMB_3 { $$ = make_PProA($4); YY_RESULT_ProCoAct_= $$; } 
; 
PermissionCl : PerCoAct { $$ = make_PPermA($1); YY_RESULT_PermissionCl_= $$; } 
; 
PerCoAct : _SYMB_2 _SYMB_7 _SYMB_2 CoAct _SYMB_3 _SYMB_3 { $$ = make_PPerA($4); YY_RESULT_PerCoAct_= $$; } 
; 
CoAct : Act { $$ = make_CCAA($1); YY_RESULT_CoAct_= $$; } 
    | CoAct _SYMB_21 CoAct { $$ = make_CCAB($1, $3); YY_RESULT_CoAct_= $$; } 
    | CoAct _SYMB_33 CoAct { $$ = make_CCAC($1, $3); YY_RESULT_CoAct_= $$; } 
    | CoAct _SYMB_8 CoAct { $$ = make_CCAD($1, $3); YY_RESULT_CoAct_= $$; } 
    | CoAct _SYMB_21 CoAct _SYMB_27 { $$ = make_CCAE($1, $3); YY_RESULT_CoAct_= $$; } 
    | _SYMB_2 Endurance _SYMB_2 CoAct _SYMB_3 _SYMB_3 { $$ = make_CCAF($2, $4); YY_RESULT_CoAct_= $$; } 
    | _SYMB_2 _SYMB_32 _SYMB_2 CoAct _SYMB_3 _SYMB_3 { $$ = make_CCAG($4); YY_RESULT_CoAct_= $$; } 
; 
CoActStar : CoAct { $$ = make_CCAH($1); YY_RESULT_CoActStar_= $$; } 
    | CoActStar _SYMB_21 CoActStar { $$ = make_CCAI($1, $3); YY_RESULT_CoActStar_= $$; } 
    | CoActStar _SYMB_33 CoActStar { $$ = make_CCAJ($1, $3); YY_RESULT_CoActStar_= $$; } 
    | CoActStar _SYMB_8 CoActStar { $$ = make_CCAK($1, $3); YY_RESULT_CoActStar_= $$; } 
    | CoActStar _SYMB_21 CoActStar _SYMB_27 { $$ = make_CCAL($1, $3); YY_RESULT_CoActStar_= $$; } 
    | _SYMB_2 Endurance _SYMB_2 CoActStar _SYMB_3 _SYMB_3 { $$ = make_CCAM($2, $4); YY_RESULT_CoActStar_= $$; } 
    | _SYMB_2 _SYMB_32 _SYMB_2 CoActStar _SYMB_3 _SYMB_3 { $$ = make_CCAN($4); YY_RESULT_CoActStar_= $$; } 
; 
Endurance : _SYMB_9 { $$ = make_EENA(); YY_RESULT_Endurance_= $$; } 
    | _SYMB_13 { $$ = make_EENB(); YY_RESULT_Endurance_= $$; } 
    | _SYMB_10 { $$ = make_EENC(); YY_RESULT_Endurance_= $$; } 
    | _SYMB_20 { $$ = make_EEND(); YY_RESULT_Endurance_= $$; } 
    | _SYMB_19 { $$ = make_EENE(); YY_RESULT_Endurance_= $$; } 
    | _SYMB_12 { $$ = make_EENF(); YY_RESULT_Endurance_= $$; } 
; 
ContradictionWords : _SYMB_15 _SYMB_26 ConWor _SYMB_30 { $$ = make_CConWorStr($3); YY_RESULT_ContradictionWords_= $$; } 
; 
ConWor : ContradictoryWor { $$ = make_RecurE($1); YY_RESULT_ConWor_= $$; } 
    | ContradictoryWor ConWor { $$ = make_RecurF($1, $2); YY_RESULT_ConWor_= $$; } 
; 
ContradictoryWor : Act _SYMB_11 Act _SYMB_1 { $$ = make_CW($1, $3); YY_RESULT_ContradictoryWor_= $$; } 
; 
Act : Variable_name { $$ = make_AAc($1); YY_RESULT_Act_= $$; } 
; 
Variable_name : Lett { $$ = make_WWA($1); YY_RESULT_Variable_name_= $$; } 
; 
WordAction : Lett { $$ = make_WWB($1); YY_RESULT_WordAction_= $$; } 
; 
Lett : _SYMB_22 { $$ = make_LLTA(); YY_RESULT_Lett_= $$; } 
    | _SYMB_23 { $$ = make_LLTB(); YY_RESULT_Lett_= $$; } 
; 
+1

嗨,欢迎来到StackOverflow!您可以在每行前加上'>>''来阻止引用行,并在这些行的末尾添加两个空格;您可以通过在编辑器中突出显示代码来格式化代码,然后单击大括号图标。这两种方法都可以帮助您提高问题的可读性! :-)在这个问题上,我已经为你做了这些工作,但是在将来要牢记这些提示。 :-) – 2011-03-23 15:13:06

回答

0

在我看来就像你不没有%type声明指示词法分析器返回值为_SYMB_16_SYMB_14的值。

0

你可能必须使用名称的类型>2,分别为“名称的类型”哪里是你%union成员之一$<名称的类型>1$<。就像$<wordaction_>1$<endurance_>2一样,任何类型都适合上下文。

1

你不一定需要所有令牌%型。许多标记(比如运算符)没有与它们相关的类型,但它们仍然可以在语法规则中执行操作。 你确实需要在某个地方发送它时设置一个类型。例如someObject.intVariable = $ 3应该变成someObject.intVariable = $ 3 因为你声明你的union的int类型是int_。