I'm trying to figure out which is the best way to parse the following simple grammar, using a hand-written parser: stmtseq = {stmt} stmt = "if" expr "then"...
... The closing square bracket is in the wrong place, isn't it? ... The grammar is incomplete and glosses over the existence of "normal" simple statements,...
Rainer Thonnes
rainer@...
Jun 5, 2005 10:25 pm
554
... Sorry about that. It should be: stmt = "if" expr "then" stmtseq ["else" stmtseq] "endif" ... I did mean "not". The loop should continue while one of...
... Hmm. What am I missing here? Is "token" not the same thing as what "is_token" looks at before consuming it? If so, then it seems to me that all the...
Rainer Thonnes
rainer@...
Jun 6, 2005 8:58 pm
556
Hello All, I designed a new object oriented programming language named "Awal" as part of my MS Computer Sciences thesis. Now I want to develop a fully working...
I'm trying to figure out how to generate quads. I can generate p-code while parsing, or generate an AST and generate p-code from that, but I have not figured...
... There is *very little* to do actually. Your AST is almost exactly in the right format; you just have to output each AST entry in the right order. for each...
... Wow - it turned out to be so easy. I've looked at your example many times, but for some reason it never clicked. However, something you said in the above...
... A brief aside from the subject... what you describe above is what happens so often in programming, at least to me - I can read all the books, look at...
... In the else part, you need explicit tests for left and/or right also being leaf nodes. If they are, don't gen_expr - just use the name... so... ... will...
... I can definitely relate. Mine was Wirth's Pascal-s. It seemed like such a mystery until only just a few years ago. ... Nope! ... Me too. Thanks again for...
... Just thought I'd thank everyone who answered to this question I posed. I went through all of your answers. There were lots of great VMs there, but they all...
Hi, I used to hand-grow all my parsers, and a while ago thought I'd give Flex/Yacc a try again. I actually got it to wonderfully lex and parse my language, but...
... You have to define yyval as a union. I hand-grow by lexers so there may be a specific typename to use, but in any case here is the start of one of my...
Olivier Galibert
galibert@...
Jun 23, 2005 6:55 pm
566
Hello, ... Here is something I wrote a while ago: http://fuse.superglue.se/mcc_i386.tar.gz It's a compiler for a small subset of C. I don't think you can call...
... They're not using flex/bison anymore but hand-made recursive parsers instead... OG....
Olivier Galibert
galibert@...
Jun 23, 2005 6:59 pm
568
... Thanks, that filled in some of the blanks. Somehow I completely overlooked %type in favor of %token, which caused part of my problem. Your example showed...
... AFAIK that's a new development, though. I remember reading somewhere (gnustep-discuss?) that this new parser was checked in only recently. But I think the...
... It was actual, practical code, that's exactly what I had hoped for. Yes, it's a little larger than I'd have needed, but it demonstrated that I was on the...
... If you are working in C++, there are more interesting ways to work, like Boost.Spirit (http://www.boost.org/libs/spirit/index.html) - but you need to be a...
If I define two regular-expression rules such as: "if" { return TT_IF; } [a-zA-Z]([a-zA-Z]|[0-9] { return TT_IDENTIFIER; } Then in my code I have something...
... Assuming this is a general question and not specific to yacc/lex ... there are two ways of combining lexers and parsers. The yacc/lex model is that you...
... The Edinburgh Computer History Project has quite a few versions of the same basic parser as it was developed over the years, but this is about the earliest...
... Yep :-) By the way, found this today: http://easynews.dl.sourceforge.net/sourceforge/inger/CompilerConstruction.pdf 246 page book on writing a compiler for...
I actually ran across a PDF on oolex yesterday and found that their approach made sense to me. What it described was the concept that each lexer rule is in a...
Someone also mentioned that FLex/Lex returns against the rule with the longest match. Assuming you have "IF " as your input and two rules, one for 'IF' and...
... I dunno, why don't you try it out! Here's an oldie from the 60's: in FORTRAN you can have a for loop DO 10 I = 1, 10 and a simple assignment DO10I = 1.10 ...