Mail Archives: djgpp/1996/05/13/07:30:10
Nicholas Lynch wrote:
>
> I've been trying to use Bison to create a script language for an RPG. I
> downloaded a little something about YACC off the net, it has helped a bit
> (I don't remember what the file was called exactly) but I still have a
> few questions.
Have you checked the examples in the bison info file?
> I want to encorporate subroutines in my language. So, I thought that I might
> be able to do that like this:
>
> subroutine: sub_name '(' arguments ')' '{' expressions '}'
> ;
>
> But I am lost as to how I would define arguments and expressions. For
> arguments I need some way of passing muliple arguments, even no arguments,
> with ',' characters separating each.
arguments:
/* no arguments */
| one_or_more_arguments
;
one_or_more_arguments:
argument
| one_or_more_arguments ',' argument
;
argument:
IDENTIFIER
;
> Something else that is starting to bother me, would I have to do a sweep
> of my entire script looking for subroutines before I could run it? Because
> I'ld have to know what subroutines are defined, where they are and the
> arguments for each.
You definitely have to have its definition before to run a subroutine. But
you can check all sub-routine calls to see if there is any undefined
one. If there isn't, you can execute the parsed part of the script.
> I think this may be a bit tricky for a beginner :)
Surely.
> << If there is a better newsgroup to take this to, please tell me, I feel
> extremely off-topic >>
There's a comp.compilers newsgroup you can try. (I don't know its exact
purpose, though.)
Regards,
Wang TianXing
- Raw text -