找回密码
 点一下
查看: 2986|回复: 5

Jass ANTLR Grammar

[复制链接]
发表于 2008-7-13 12:29:20 | 显示全部楼层 |阅读模式
By slunk731 Wc3c
开源的..C#...
最近感觉智力严重下降..
我已经懒得看他到底写了些啥了..
全部copy过来完事...
So, I decided to play around with the idea of Grimoire extensions. I'm not much of a delphi guy, though, so first I needed to put together an interpreter for Jass. I decided to use ANTLR to these ends, and the results are very good.

Attached are:
-A .g file which can be opened in ANTLR. The grammar was developed in ANTLRWorks 1.2b5. Any post-3.1 version of ANTLR should be able to run it, but if you're a programming languages noob like me, I'd recommend using ANTLRWorks.

Using ANTLR, you can use this .g file to export source files for a Jass interpreter to about half a dozen different languages. I used C#, but you can use C, Java, Objective C, ActionScript, etc. I know that C# works for a fact, though, and I cannot vouch for the usefulness of the exporters for the other languages.

-A C# project showing off the Jass interpreter exported with ANTLR. It's a console project that takes a Jass file in as a single argument. It will attempt to parse the Jass file, displaying parse errors. There is a known bug, located in the C# ANTLR runtimes that causes it to get confused by UNIX/Mac newlines, so the line of a syntax error will be displayed incorrectly in some cases. This doesn't stop it from parsing correctly, though, because my grammar is done right.

Included in the project are Program.cs, written by me, and JassLexer.cs/JassParser.cs, exported by ANTLR. Also the necessary dll's of the ANTLR runtimes are included. The only changes made to JassLexer.cs/JassParser.cs after exporting is that I changed the text of the token name strings at the top of JassParser.cs, to make syntax error messages more informative.

-The binaries exported by compiling the C# project, so you can test it without pulling out visual studio.

Let me know if you enjoy this stuff- I'll be using it to write my obfuscator!

Update: I decided to go ahead and clean up/comment the .G file, so it's a little more legible now, hopefully.

JASSGrammar.zip

399 KB, 下载次数: 78

发表于 2008-7-13 12:42:39 | 显示全部楼层
  [s:166]

完全



不懂

等翻译
回复

使用道具 举报

发表于 2008-7-13 21:30:25 | 显示全部楼层
先下来放着
回复

使用道具 举报

发表于 2008-7-14 07:11:04 | 显示全部楼层
……………………………………………………………………………………………………………………………………555………………………………………………………………支持下把
回复

使用道具 举报

发表于 2008-7-25 00:59:15 | 显示全部楼层
不支持中文的啊
回复

使用道具 举报

发表于 2008-7-27 13:05:54 | 显示全部楼层
看不懂..什么...啊..
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-4-27 22:10 , Processed in 0.122433 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表