Compiling -- gcc -- Lex & Yacc
William Case
billlinux at rogers.com
Tue Jul 22 23:13:37 UTC 2008
Thanks Patrick;
I am not being defensive, but ...
On Tue, 2008-07-22 at 16:16 -0430, Patrick O'Callaghan wrote:
> On Tue, 2008-07-22 at 13:38 -0400, William Case wrote:
> > Hi;
> >
> > I am working my way through the compiling process. I want to be precise
> > about my question so that responders do not waste time on answering the
> > wrong question.
> >
> > Where can I find/see which preprocessor, lexical analysiser, parser etc.
> > the gcc compliler is using in Fedora? What order are they being used in
> > and any other instructions or agruments that are being passed to them by
> > gcc (the compiler) besides the original/modified code?
>
> Bill, you seem to have some misconceptions. Although lexical analysis
> and parsing are inevitably involved in compilation, it doesn't mean they
> are visible as separate processes. In fact the 'gcc' manual says
> "Compilation can involve up to four stages: preprocessing, compilation
> proper, assembly and linking, always in that order." Note that it
> doesn't mention lexing and parsing, since these are subsumed under
> "compilation proper".
>
Although not explained that way in Wikipedia, for example, I had come to
understand that. It is more a problem of lack of vocabulary at to ask
a question properly at this stage when one is relatively new to a
subject, than it is a lack of understanding.
> > I have gone through 'info gcc' but that does not seem to lead to the
> > answer of my specific question. I have read as much as I could
> > regarding 'make'. That didn't seem to have an answer either. Maybe I
> > missed it!
>
> 'Make' just calls other programs according to a recipe, some of the
> rules for which are built-in. It has nothing specific to do with the
> actual mechanics of compiling.
>
Yes. Simply based on an outside hope that some of the make commands
might be revealing.
> > I know the answers, from reading patches and pieces (cpp, lex and Yacc
> > -- I think).
>
> 'cpp' is the preprocessor, which handles things like #defines and
> #includes. However 'lex' and 'yacc' are *not* the lexical analysis and
> parsing phases (in the GNU universe the equivalents are actually 'flex'
> and 'bison'). They are tools used some time in the past when the
> compiler itself was being written to *generate* a lexical analyzer and
> parser. In fact I don't remember offhand if gcc even uses them but I
> suspect not (some features of C and C++ syntax make it tricky to handle
> with yacc, though it can be done). Even if it does, you won't see them
> being invoked when compiling a program.
>
An example of how far someone without the technical language sometimes
has to reach in order to explain what they want to know.
> > But seeing is believing. Somewhere (which I can't seem to
> > find) there must be a declaration, or official text or manual that says
> > for sure that I have a certain version of gcc that definetly calls on
> > these specific programs.
>
> "gcc -v prog.c" will show you what's happening in excruciating detail.
>
I am up to working it through in excruciating detail.
> Looking at the source code for 'gcc' is an illuminating experience. Note
> that it's a very large complex program but patience is rewarded.
That is how I got here; trying to look at kernel code in excruciating
detail. That led me to review some of what I had taught myself about C;
which led me to look at how some code is dealt with when compiled.
I was getting concerned if I kept pushing back far enough I would have
to study genetics to figure out how I got here to ask the damn stupid
question in the first place.
As well, Markku Kolkka in another post has suggested some sites that
look promising. I'll break for a bit; clear my mind and then start
reading.
--
Regards Bill;
Fedora 9, Gnome 2.22.3
Evo.2.22.3.1, Emacs 22.2.1
More information about the users
mailing list