Message-ID: <31970C85.5D8E@public1.guangzhou.gd.cn> Date: Mon, 13 May 1996 19:18:45 +0900 From: Wang TianXing Organization: No Organization MIME-Version: 1.0 To: Nicholas Lynch CC: djgpp AT delorie DOT com Subject: Re: Bison, Yacc realted question References: <4n5dor$d1h AT freenet-news DOT carleton DOT ca> Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 7bit 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