I've been using python at work for quite some time now and I'm really liking the ease of use of it's syntax. Just for fun, I'd like to write a python-galaxy parser that runs as a third party tool, but I've no idea how to start. Could anyone perhaps guide me to a starting point on how I might begin writing such a parser (as a 3rd party tool)?
PS: If it works out well enough for my personal use, I will probably release it to public.
PPS: I thought about using a python file to handle the parsing as well, but I'm trying not to rely on an IDE if possible.
Procedure wise, I intend to use it in the following manner.
Written in notepad+ +, run the parser pointing to the notepad file, which outputs into MapScript.galaxy so I can import it into the map and run it directly.
Note that writing something like that is a lot of work and you need a lot of time if you want to develop a python->galaxy compiler AND use it to build your maps with.
If you really want to do this you should look for parser/lexer generators. For example ANTLR for java. I don't know if something like this exists for python. For your information Galaxy++ uses SableCC with C# (and if I remember correctly vJass uses GOLD) but there are a lot of other tools for different languages.
With these tools you can define your own language (in form of a grammar and in your case a copy of the python grammar) and use the tools to generate some classes that help you to parse the input language and compile it to something different. But this is not automatically done. You would have to define how the different language constructs are translated which is not that easy with galaxy being the output language.
You would have to think about how to translate classes, ranges, ... to galaxy which does not have these kinds of constructs. You would also have to live without a garbage collector ;)
Wow, thanks for the quick response :) This information ought to do for a start. Thanks!
I actually thought of another idea over the last hour. A python class library that buffers code into galaxy, then writes it to a MapScript.galaxy file. It's not quite what I had in mind, but I think it just might work for my little venture. It's a somewhat different principle. Rather than read python script and translate it, it directly uses python to write the file.
PS: I understand it's a lot of work, thus why I intend to do it for fun lol. Wouldn't want to arouse too much excitement in the public over something that may never get released.
I actually thought of another idea over the last hour. A python class library that buffers code into galaxy, then writes it to a MapScript.galaxy file. It's not quite what I had in mind, but I think it just might work for my little venture. It's a somewhat different principle. Rather than read python script and translate it, it directly uses python to write the file.
Not quite sure what you mean. Something like StringTemplate to define reoccurring structures that directly evaluate to galaxy but easily write them in python? If so ,yes, that would be much easier to implement and could be quite useful as a personal helper tool.
Oh and if its for fun, every solution is good enough :)
I personally still use Andromeda. Hopefully gex will get around to fixing the code base so that development and maintenance can continue. At the moment, though, it is perfectly usable. Unfortunately, the forums on sc2mod.com are down, so there isn't a good documentation anywhere. Perhaps I should repost the main documentation here.
I've been using python at work for quite some time now and I'm really liking the ease of use of it's syntax. Just for fun, I'd like to write a python-galaxy parser that runs as a third party tool, but I've no idea how to start. Could anyone perhaps guide me to a starting point on how I might begin writing such a parser (as a 3rd party tool)?
PS: If it works out well enough for my personal use, I will probably release it to public.
PPS: I thought about using a python file to handle the parsing as well, but I'm trying not to rely on an IDE if possible.
Procedure wise, I intend to use it in the following manner.
Written in notepad+ +, run the parser pointing to the notepad file, which outputs into MapScript.galaxy so I can import it into the map and run it directly.
Note that writing something like that is a lot of work and you need a lot of time if you want to develop a python->galaxy compiler AND use it to build your maps with.
If you really want to do this you should look for parser/lexer generators. For example ANTLR for java. I don't know if something like this exists for python. For your information Galaxy
++
uses SableCC with C# (and if I remember correctly vJass uses GOLD) but there are a lot of other tools for different languages.With these tools you can define your own language (in form of a grammar and in your case a copy of the python grammar) and use the tools to generate some classes that help you to parse the input language and compile it to something different. But this is not automatically done. You would have to define how the different language constructs are translated which is not that easy with galaxy being the output language.
You would have to think about how to translate classes, ranges, ... to galaxy which does not have these kinds of constructs. You would also have to live without a garbage collector ;)
@Slarti: Go
Wow, thanks for the quick response :) This information ought to do for a start. Thanks!
I actually thought of another idea over the last hour. A python class library that buffers code into galaxy, then writes it to a MapScript.galaxy file. It's not quite what I had in mind, but I think it just might work for my little venture. It's a somewhat different principle. Rather than read python script and translate it, it directly uses python to write the file.
PS: I understand it's a lot of work, thus why I intend to do it for fun lol. Wouldn't want to arouse too much excitement in the public over something that may never get released.
Not quite sure what you mean. Something like StringTemplate to define reoccurring structures that directly evaluate to galaxy but easily write them in python? If so ,yes, that would be much easier to implement and could be quite useful as a personal helper tool.
Oh and if its for fun, every solution is good enough :)
@Slarti: Go
From a quick look at the description, string template does look like what I have in mind. A code generator :) with the convenience of coding in python
@FuzzYD: Go
Don't kill yourself too much working on this. A better alternative is coming sometime in the next few months.
@grim001: Go
I'm intrigued, are the details confidential? I'm curious to know a little about what this alternative might be
@grim001: Go
Ah, hype much? :)
But really, what is it about? I guess you talk about "cosmos" as you made an equally informative post in the galaxy
++
thread.Any hint on what we can do with it? Regardless, really nice to see that you're doing something for/with sc2
@Slarti: Go
If you want specific info at this point, you'll have to find me on sc2mapster's IRC.
I personally still use Andromeda. Hopefully gex will get around to fixing the code base so that development and maintenance can continue. At the moment, though, it is perfectly usable. Unfortunately, the forums on sc2mod.com are down, so there isn't a good documentation anywhere. Perhaps I should repost the main documentation here.
@XPilot: Go
I didn't know gex was still alive