[antlr-interest] Please help with my first project

Philippe Lavoie philippe.lavoie at cactus.ca
Thu Jan 23 12:55:03 PST 2003


Thanks

Do you know if there is simple example of this somewhere?

I might change my syntax to be Perl like and use special symbols to
identify kernel or an image

$result = $image open #k1 close #k2

That might simplify things a bit. Still, I though I needed to embed the
actions inside the Parser or the TreeParser class.

I often see 'symbol table' mentioned. I have yet to see a tutorial or an
example that use them. Anybody knows where I can get more documentation
regarding this on the net, i.e. how I can set-up such a thing using
antlr?


Phil


-----Original Message-----
From: mzukowski at yci.com [mailto:mzukowski at yci.com] 
Sent: Thursday, January 23, 2003 2:53 PM
To: antlr-interest at yahoogroups.com
Subject: RE: [antlr-interest] Please help with my first project

Those are questions of semantics and probably best handled in a tree
parser.
After the syntax is ok the program is parsed and then represented as an
AST.
Perhaps a symbol table is built at that point too.  Further passes over
the
AST can do type checking.  In your case a further pass would actually
interpret the code and execute your image processing functions.

Monty

-----Original Message-----
From: Philippe Lavoie <philippe.lavoie at cactus.ca>
[mailto:philippe.lavoie at cactus.ca]
Sent: Thursday, January 23, 2003 11:17 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Please help with my first project


Hi,

I'm running into several problems and if some kind sould wouldn't mind
helping out, I'd really appreciate it.

I have basically this problem:
  - how to declare context dependant grammar

I want to create a language to be used as an interface to my
mathematical mophology library (i.e. image processing operators). I
think that antlr is up to the challenge but unfortunately it seems I'm
not. I've read a lot of tutorials but it seems it's not enough :(

Here is an example of a program I'd like to parse

// Start
Image image;
Kernel k1;
Kernel k2;

k1 = disk(10);
k2 = matrix(3,3);
k2[0] = "001";
k2[1] = "010";
k2[2] = "100";

image.load("someimage.png");

Image result;
result = (image open k1) close k2;

result.save("result.png");
// End



I can't figure out how to restrict .load and .save to an image that
has been declared nor can I figure out how to differentiate between a
kernel and an image assignment since both k1 or result are viewed as
ID by the lexer.

I could do the above in C++, but I kind of would like to have an
interpreted syntax version like above to speed up my tests.

Thanks for any tips.

Phil


 

Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/ 



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list