Parse and Evaluate MetaLanguage

3 views
Skip to first unread message

Joe Joe

unread,
May 13, 2008, 10:04:56 AM5/13/08
to gold-pars...@googlegroups.com
Hi

I am rookie when it comes to Parser/Lexers

I have a meta-language file that i want to process to retrieve the logic in the document. It is a series of IF THEN ELSE that are also nested

if TYPE = '01'
then
        if PRODUCT IN LIST( LIST1 )
        then
             if CAT>3
             then
                  PRODUCTTYPE = "PRODUCT01"
             else
                  PRODUCTTYPE = "PRODUCT02"
        else
             ........
else
........

What I need is to get the info that get's you to the final or endpoint results
ie
"PRODUCT01" is TYPE ="01" and IN LIST1 and CAT>3
"PRODUCT02" is TYPE ="01" and IN LIST1 and NOT CAT>3

Can I use GOLD to do this???
Also any examples/hints on how I would implement this???
I am working in C#

Thanks

Dave Dolan

unread,
May 13, 2008, 10:25:47 AM5/13/08
to gold-pars...@googlegroups.com
yes you can use gold to do this.
 
However, you will have to actually write your own code after gold generates a DFA.  An example like the one you're asking about is in the help files that come with gold.  Also check around for the downloads. Nesting of valid nestable expressions to any level doesn't phase an LALR system as long as the syntax is valid (Gold is LALR, so if any other LALR system can do it, you can do it with gold.)  The only thing gold provides you is a nice way to debug your DFA, and some engines in lots of languages to help you write your own consuming parser.  It will not automatically generate a 'parser' for you to 'drop in' to your code.  You still have quite a bit of code to do after the DFA is produced, and loaded into the engine.
 
That being said, the templates for the Calitha Engine are the easiest to understand the output from.  If you're using C#, are new to Gold, (and apparently parsers in general) then check out the Calitha engine and samples on the download page.
 
--dave

Reply all
Reply to author
Forward
0 new messages