Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: A simple list oriented language in Perl

by kvale (Monsignor)
on May 10, 2006 at 23:26 UTC ( [id://548588]=note: print w/replies, xml ) Need Help??


in reply to A simple list oriented language in Perl

When designing and implementing a new language, it is best to start by creating a grammar for the elements in your language, keeping in mind the semantics of each element as you go along.

For instance, your assignment might take on the form

<assign> =: <assign-token> "->{\n" <assign-list> "}\n" <assign-token> =: "\w+" <assign-list> =: <assign-element> <assign-list> | (null) <assign-element> =: "[0-9]+\n"
where nonterminal elements are in <> and literals and regexes are in "".

Once you have created a grammar you can implement it using Parse::RecDescent or your own recursive desecnt set of routines. Once you have the parser working, you can begin to create the translation routines.

Programming macro languages can be a bit tricky due to expansion rules. What gets expanded when? How do I quote expressions to prevent expansions? And so on. Two good examples of macro languages that deal with these issues are m4 and TeX. Both have good documentation.

-Mark

Replies are listed 'Best First'.
Re^2: A simple list oriented language in Perl
by blazar (Canon) on May 11, 2006 at 12:22 UTC
    Programming macro languages can be a bit tricky due to expansion rules. What gets expanded when? How do I quote expressions to prevent expansions? And so on. Two good examples of macro languages that deal with these issues are m4 and TeX. Both have good documentation.

    In fact TeX itself is even in the opinion of very knowledgeable TeXperts, a real mess. See for example David Kastrup's posts in this thread (also available from Google Groups).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://548588]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-25 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found