[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Parsing if, while, for, etc
From: |
Akim Demaille |
Subject: |
Re: Parsing if, while, for, etc |
Date: |
07 Dec 2000 13:56:59 +0100 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands) |
>>>>> "JB" == JB <address@hidden> writes:
JB> Hey, thanks for the detail! Yeppers, I have Modern Compiler
JB> Implementation in C, but unfortunately I understand very little of
JB> it. It is written very poorly in my opinion. I still don't
JB> understand why textbook authors can't write in plain English so
JB> people can read and understand their books, instead of filling
JB> their books with unintelligible squiggles and marks that mean
JB> nothing. Why? Why not a book that people can actually read with
JB> clear, plain English text and clear diagrammes? Beats me.
I disagree with about all your points :)
JB> Why is GNU awk a good example? What is awk?
Use any search engine.
JB> Yes, intermediate representation is something I'm struggling with,
JB> but I am also struggling with how to build if, while, for
JB> etc. What are those bits beginning with '@'?
See the Bison documentation.
JB> WHILE_LOOP: WHILE expr DO stmt_list END WHILE ; { /* C code of
JB> some sort */ }
JB> In the part where the C code goes, if I was writing an interpreter
JB> and wanted to execute this straight away, could I just write:
JB> { while ($2) { $4; } }
JB> .... or am I missing something? What would $4 contain in this
JB> case? Would I need to pass it into a function I write myself to
JB> extract the individual statements, if any? Hmm...
I'm not sure you were writing `meta' stuff or real stuff. Of course
you cannot mean to write
WHILE_LOOP: WHILE expr DO stmt_list END WHILE
{ while ($2) { $4; } }
since $2 and $4 are meaningful only when you run the parser generated
by Bison. But as *pseudo* code, what your wrote is meaningful.
JB> Can you shed any light on this for me? I have tried reading the
JB> bison input file for gcc, but it is too advanced for me to break
JB> up into pieces and learn from. I looked for the functions the file
JB> referred to when it recognised something, but couldn't find them
JB> anywhere.
Sorry, but you'll have to give more details on your intentions. And I
think you should look at awk.y in Gawk's package, you'll learn there.
- Parsing if, while, for, etc, James Buchanan, 2000/12/02
- Re: Parsing if, while, for, etc, Akim Demaille, 2000/12/07
- Re: Parsing if, while, for, etc, Hans Aberg, 2000/12/07