|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Jul 2006
Città: Milano
Messaggi: 131
|
[C++] Problema funzione membro
Ho bisongo di far collaborare un analizzatore lessicale e uno grammaticale(Parser Generator) con una classe composta da me... in particolar modo l'analisi lessicale viene fatta dalla classe myparser.
Io devo costruire un oggetto della classe parser nella mia classe(che si chiama CIdentityDlg). Come devo procedere? Spero di essere stato chiaro...Grazie...
__________________
"Due cose sono infinite: l'universo e la stupidità umana ma sull'universo nutro ancora dubbi..."(A. Einstein) |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Mar 2006
Città: Bergamo
Messaggi: 2499
|
devi aggiungere nella tua classe una variabile membro del tipo parser.
nel tuo .h, nella zona protected: Codice:
protected:
Cparser m_parser;
__________________
ho concluso con: kvegeta, doctordb, Leland Gaunt.
|
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Jul 2006
Città: Milano
Messaggi: 131
|
inserendo:
Codice:
protected: myparser m_parser; Codice:
C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2146: syntax error : missing ';' before identifier 'm_parser' C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2501: 'myparser' : missing storage-class or type specifiers C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2501: 'm_parser' : missing storage-class or type specifiers IdentityDlg.cpp C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2146: syntax error : missing ';' before identifier 'm_parser' C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2501: 'myparser' : missing storage-class or type specifiers C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2501: 'm_parser' : missing storage-class or type specifiers Generating Code... Error executing cl.exe. Identity.exe - 6 error(s), 0 warning(s)
__________________
"Due cose sono infinite: l'universo e la stupidità umana ma sull'universo nutro ancora dubbi..."(A. Einstein) |
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Mar 2006
Città: Bergamo
Messaggi: 2499
|
hai incluso il file header della classe parser?
__________________
ho concluso con: kvegeta, doctordb, Leland Gaunt.
|
|
|
|
|
|
#5 |
|
Member
Iscritto dal: Jul 2006
Città: Milano
Messaggi: 131
|
Si, ho aggiunto il file al progetto...
#include "myparser.h" e poi ho aggiunto tale header anche nel mio progetto tramite il pulsante add to project... non so cos'altro provare...è da due giorni che sono bloccato e non riesco a trovare soluzioni...cos'altro potrei fare?
__________________
"Due cose sono infinite: l'universo e la stupidità umana ma sull'universo nutro ancora dubbi..."(A. Einstein) |
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Perché non ci fai vedere un po' del codice della classe ?
|
|
|
|
|
|
#7 |
|
Member
Iscritto dal: Jul 2006
Città: Milano
Messaggi: 131
|
Questa è "myparser.h" generata automaticamente dall'analizzatore grammaticale
Codice:
#ifndef _MYPARSER_H
#define _MYPARSER_H
#include <yycpars.h>
#define CORE 257
#define VIRGOLA 258
#define DELTA 259
#define PARENTESIAPERTA 260
#define PARENTESICHIUSA 261
#define NUMBER 262
/////////////////////////////////////////////////////////////////////////////
// myparser
#ifndef YYEXPPARSER
#define YYEXPPARSER
#endif
class YYEXPPARSER YYFAR myparser : public _YL yyfparser {
public:
myparser();
virtual ~myparser();
protected:
void yytables();
virtual void yyaction(int action);
#ifdef YYDEBUG
void YYFAR* yyattribute1(int index) const;
void yyinitdebug(void YYFAR** p, int count) const;
#endif
// attribute functions
virtual void yystacktoval(int index);
virtual void yyvaltostack(int index);
virtual void yylvaltoval();
virtual void yyvaltolval();
virtual void yylvaltostack(int index);
virtual void YYFAR* yynewattribute(int count);
virtual void yydeleteattribute(void YYFAR* attribute);
virtual void yycopyattribute(void YYFAR* dest, const void YYFAR* src, int count);
public:
#line 23 ".\\myparser.y"
// place any extra class members here
//int parse();
#line 75 "myparser.h"
};
#ifndef YYPARSERNAME
#define YYPARSERNAME myparser
#endif
#line 40 ".\\myparser.y"
#ifndef YYSTYPE
#define YYSTYPE int
#endif
#line 88 "myparser.h"
#endif
Pe creare un oggetto di questo tipo nella mia classe IdentityDlg.cpp dichiaro Codice:
#include "myparser.h" Codice:
protected: myparser m_parser; Codice:
C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2146: syntax error : missing ';' before identifier 'm_parser' C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2501: 'myparser' : missing storage-class or type specifiers C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2501: 'm_parser' : missing storage-class or type specifiers IdentityDlg.cpp C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2146: syntax error : missing ';' before identifier 'm_parser' C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2501: 'myparser' : missing storage-class or type specifiers C:\Documents and Settings\Pa_co\Desktop\identity + Linguaggio\Identity\IdentityDlg.h(244) : error C2501: 'm_parser' : missing storage-class or type specifiers Generating Code... Error executing cl.exe. Identity.exe - 6 error(s), 0 warning(s)
__________________
"Due cose sono infinite: l'universo e la stupidità umana ma sull'universo nutro ancora dubbi..."(A. Einstein) Ultima modifica di pa_co : 14-12-2007 alle 15:47. |
|
|
|
|
|
#8 |
|
Senior Member
Iscritto dal: Mar 2006
Città: Bergamo
Messaggi: 2499
|
#include "myparser.h" devi includerla nel tuo .h
__________________
ho concluso con: kvegeta, doctordb, Leland Gaunt.
|
|
|
|
|
|
#9 |
|
Member
Iscritto dal: Jul 2006
Città: Milano
Messaggi: 131
|
Spostando l'include nel .h mi da questi errori....
Codice:
Deleting intermediate files and output files for project 'Identity - Win32 Release'. --------------------Configuration: Identity - Win32 Release-------------------- Performing Custom Build Step on .\mylexer.l Performing Custom Build Step on .\myparser.y Compiling resources... Compiling... StdAfx.cpp Compiling... Identity.cpp IdentityDlg.cpp Generating Code... Linking... Identity.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall myparser::~myparser(void)" (??1myparser@@UAE@XZ) IdentityDlg.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall myparser::~myparser(void)" (??1myparser@@UAE@XZ) IdentityDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall myparser::myparser(void)" (??0myparser@@QAE@XZ) Release/Identity.exe : fatal error LNK1120: 2 unresolved externals Error executing link.exe. Identity.exe - 4 error(s), 0 warning(s)
__________________
"Due cose sono infinite: l'universo e la stupidità umana ma sull'universo nutro ancora dubbi..."(A. Einstein) |
|
|
|
|
|
#10 |
|
Senior Member
Iscritto dal: Mar 2006
Città: Bergamo
Messaggi: 2499
|
sembra quasi che manchino le implementazioni nel file myparser.h del construttore e del distruttore della classe myparser.
mhhh ma hai incluso la classe myparser nel tuo progetto? viene compilata?
__________________
ho concluso con: kvegeta, doctordb, Leland Gaunt.
|
|
|
|
|
|
#11 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Devi aggiungere il ,cpp al tuo progetto. Infatti non stai compilando myparser.cpp.
|
|
|
|
|
|
#12 |
|
Member
Iscritto dal: Jul 2006
Città: Milano
Messaggi: 131
|
Ho risolto, grazie mille per tutti i consigli...sono stati utilissimi...senza non ce l'avrei mai fatta...i problemi erano due...
il primo che non avevo incluso il .cpp nel progetto(pensavo che includere l'header bastasse) il secondo era che utilizzavo la libreria sbagliata... adesso sembra funzionare... Grazie ancora...
__________________
"Due cose sono infinite: l'universo e la stupidità umana ma sull'universo nutro ancora dubbi..."(A. Einstein) |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 05:07.











ho concluso con: kvegeta, doctordb, Leland Gaunt.








