Third iteration of QMake parser, looking for a parser generator

Roberto Raggi roberto.raggi at
Tue Jul 3 11:19:28 UTC 2007


Il giorno 03/lug/07, alle ore 12:52, Andreas Pakulat ha scritto:
> Its not documented. Not at all. And no the .g file in it and the
> resulting code is no documentation that I can work with. Sorry, I  
> really
> looked into it and hoped it could be used, but thats not possible.

there is pretty much nothing to document. It's a plain standard LALR  
tool. So if you know LALR you know how to use QLALR :-) But I  
understand that you need an example :-) I tough that Qt Script (and  
QLALR) was enough.

I have attached a mini-c interpreter/compiler implemented using QLALR  
and LLVM (I did it in 2-3 hours, so don't expect too much).

you need LLVM 2 to compile minic. The parser is about ~800 loc. QLALR  
has two streams of code. The bit stream and the decl stream. If you  
want you can merge two stream using the directive (%merged_output  
filename), if you don't do that you need to assign file names to the  
streams (using the %decl and the %impl directive). You write to the  
bit stream using a  /. ./ block (or to the decl stream using /: :/ ).  
QLALR defines a few macros ($rule, $rule_number, $table, and  
$header). A macro can be used inside a stream block. For example,

TranslationUnit ::= ExternalDefinition ;
case $rule_number: {
   TranslationUnitAST *ast = new TranslationUnitAST;
   sym(1).translation_unit_ast = ast;
   translation_unit = ast;
} break;

The rest of the input file is pretty much like bison. You declare  
tokens using %token, %nonassoc, %left, and %right. You declare rule  
LeftSymbol ::= This IS a RULE ;

you can also use : instead of ::=

>> I have to say that I'm not very familiar with cmake,
> Its about qmake, not cmake ;)
oops :-)

> Hand-written scanner: No, I don't have time for that, especially for
> qmake language.
write a scanner by hand is not a big deal, but I can understand why  
you want to use a generator. I like generators. It's only that for  
qmake it doesn't look like you really need one.

ciao robe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: minic.tar.gz
Type: application/x-gzip
Size: 9915 bytes
Desc: not available
URL: <>

More information about the KDevelop-devel mailing list