Related articles |
---|
flex and bison in vc++6 or vc++8 eng.sharif@gmail.com (eng.sharif@gmail.com) (2007-03-14) |
Re: flex and bison in vc++6 or vc++8 bill@qswtools.com (Bill Cox) (2007-03-16) |
Re: flex and bison in vc++6 or vc++8 gneuner2@comcast.net (George Neuner) (2007-03-17) |
Re: flex and bison in vc++6 or vc++8 eng.sharif@gmail.com (eng.sharif@gmail.com) (2007-03-20) |
Re: flex and bison in vc++6 or vc++8 gneuner2@comcast.net (George Neuner) (2007-03-21) |
From: | "eng.sharif@gmail.com" <eng.sharif@gmail.com> |
Newsgroups: | comp.compilers |
Date: | 20 Mar 2007 08:53:45 -0400 |
Organization: | Compilers Central |
References: | 07-03-05207-03-062 |
Keywords: | yacc, Windows |
Posted-Date: | 20 Mar 2007 08:53:45 EDT |
On Mar 17, 9:42 pm, George Neuner <gneun...@comcast.net> wrote:
> On 14 Mar 2007 14:34:20 -0400, "eng.sha...@gmail.com"
>
> <eng.sha...@gmail.com> wrote:
> >i want help in work in flex and bison with vc++6 or vc++8
> >there are many problem in linker.exe files
>
> What problems? We can't offer specific help unless we know what
> you've tried and what error messages you are getting.
>
> >step by step plz
>
> In general you add the ".y" and ".l" files to your project and then
> open the property page for each file and define a custom build for it.
> The custom build dialog allows you to specify additional dependencies
> for each file (for example you usually build the ".y" file before the
> ".l" file to generate token header files), what output files will be
> produced and the command line required to run the foreign tool.
>
> After you've defined the custom builds for your files, you should do
> an individual compile on each file (in the appropriate order) and then
> add each of the output files to your project.
>
> Once all the files have been compiled one time and the output files
> added to the project, VC will handle the dependencies properly.
>
> The exact steps to define a custom build and compile files depend on
> what version of VisualC++ or Visual Studio you are running.
>
> George
thax for all
my vesion of c is VisualC++ 8 in Visual Studio 2005
my file
example.l //////////////////////////////////////////////////////////////////
/* example.l */
%{
#include "example.parser.h"
%}
%option noyywrap
%%
[ \t]+ { /* ignore whitespace */ }
"(" { return LPAREN; }
")" { return RPAREN; }
"+" { return PLUS; }
"-" { return MINUS; }
"*" { return STAR; }
\n { return NEWLINE; }
[0-9]+ { yylval = atoi(yytext); return NUMBER; }
. { printf("Invalid character '%s'", yytext); }
%%
and
example.y ////////////////////////////////////////////////////////////////////////
/* example.y */
%{
#define YYSTYPE int
#define int yylex()
%}
%token PLUS MINUS STAR LPAREN RPAREN NUMBER NEWLINE
%left PLUS MINUS
%left STAR
%%
line : /* empty */
| line expr NEWLINE { printf("%d\n", $2); }
expr : LPAREN expr RPAREN { $$ = $2; }
| expr PLUS expr { $$ = $1 + $3; }
| expr MINUS expr { $$ = $1 - $3; }
| expr STAR expr { $$ = $1 * $3; }
| NUMBER { $$ = $1; }
;
%%
int yyerror (char const *msg) {
printf("Error: %s\n", msg);
}
int main() {
printf("%d\n", yyparse());
return 0;
}
/////////////////////////////////////
my files after compile
Header Files :
example.parser.h
stdafx.h
Source Files:
example.l
example.parser.c
example.y
lex.example.c
stdafx.cpp
but in build solution i have more errors
////////////////////////
------ Build started: Project: example, Configuration: Debug Win32
------
Compiling...
lex.example.c
..\example.l(16) : warning C4013: 'atoi' undefined; assuming extern
returning int
lex.example.c(911) : warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data
lex.example.c(1258) : warning C4996: 'fileno' was declared deprecated
d:\program files\microsoft visual studio 8\vc\include
\stdio.h(688) : see declaration of 'fileno'
Message: 'The POSIX name for this item is deprecated. Instead,
use the ISO C++ conformant name: _fileno. See online help for
details.'
lex.example.c(1449) : warning C4013: 'exit' undefined; assuming extern
returning int
lex.example.c(1496) : warning C4013: 'malloc' undefined; assuming
extern returning int
lex.example.c(1496) : warning C4312: 'type cast' : conversion from
'int' to 'void *' of greater size
lex.example.c(1514) : warning C4013: 'realloc' undefined; assuming
extern returning int
lex.example.c(1514) : warning C4312: 'type cast' : conversion from
'int' to 'void *' of greater size
lex.example.c(1524) : warning C4013: 'free' undefined; assuming extern
returning int
Linking...
example.parser.obj : error LNK2019: unresolved external symbol _yylex
referenced in function _yyparse
example.parser.obj : error LNK2019: unresolved external symbol _alloca
referenced in function _yyparse
C:\Documents and Settings\sharif.SYNRYU\My Documents\Visual Studio
2005\Projects\example\Debug\example.exe : fatal error LNK1120: 2
unresolved externals
Build log was saved at "file://c:\Documents and Settings\sharif.SYNRYU
\My Documents\Visual Studio 2005\Projects\example\example\Debug
\BuildLog.htm"
example - 3 error(s), 9 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========
this is all
what is problem in my work ?
[Looks to me like you're using a Bison parser that expects to find
GCC extensions in the C compiler. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.