Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: A simple list oriented language in Perl

by kvale (Monsignor)
on May 10, 2006 at 23:26 UTC ( #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


Comment on Re: A simple list oriented language in Perl
Download Code
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
Node Status?
node history
Node Type: note [id://548588]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (14)
As of 2014-07-30 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (234 votes), past polls