I am trying to create a c-like programming language. I am writing the
first (very simple) interpreter for the language in PLY, then I will
use that to write a compiler for the language (basically bootstrapping
so that the language can be self-compiling).
One feature of the language is that it allows operator definition.
For example:
//define "and" as the same as "&&"
operator (and) in (x and y)
{
return(x && y);
}
//define the ternary operator
operator ( ? , : ) in ( x ? y : z )
{
if x
return y;
return z;
}
The difficulty with this is that after an operator is defined, the
lexer/parser must understand that operator.
There are three options for how to deal with this as far as I can
tell: I can pre-parse with a simple regex and define all the operators
before parsing with PLY, I can change PLY, or I can just put off this
feature until the first self-compiling version of my language.
My question is: is there a simpler solution that I am missing?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ply-hack" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/ply-hack?hl=en
-~----------~----~----~----~------~----~------~--~---