added cycling to parser

master
melvin 2013-02-13 12:30:51 +08:00
parent 182fe0233a
commit bfdb0ed9ea
4 changed files with 53 additions and 5 deletions

View File

@ -466,7 +466,7 @@ parser/test_all: $(MAG) grammar/rules.txt
parser/run: $(MAG)
$(JAVA) magic.grammar.Check
grammar/parsable.txt: grammar/mtg.peg
grammar/parsable.txt: src/magic/grammar/MagicRuleParser.java
make parser/test_all > grammar/test_all.out
cat grammar/test_all.out | grep PARSED | sed 's/PARSED: //' | sort | uniq > $@
cat grammar/test_all.out | grep FAILED | sort | uniq -c | sort -n > grammar/failed.txt

View File

@ -174,6 +174,7 @@ Keyword
/ "level" SPACE Number "-" Number
/ "level" SPACE Number "+"
/ "champion" SPACE "a" "n"? SPACE SelectCreature
/ "cycling" SPACE ManaCost
;
ColorlessCost

View File

@ -1276,6 +1276,39 @@ cumulative upkeep {r}
cumulative upkeep {u}
cumulative upkeep {u}{r}
cumulative upkeep {w}
cycling {1}{b}
cycling {1}{b}{b}
cycling {1}{r}
cycling {1}{r}{r}
cycling {1}{u}
cycling {1}{w}
cycling {2}
cycling {2}{b}
cycling {2}{g}
cycling {2}{g}{g}
cycling {2}{r}
cycling {2}{u}
cycling {2}{w}
cycling {3}
cycling {3}{b}{b}
cycling {4}{g}{g}
cycling {4}{u}{u}
cycling {5}{b}{r}{g}
cycling {5}{g}{w}{u}
cycling {5}{r}{g}{w}
cycling {5}{r}{r}
cycling {5}{u}{b}{r}
cycling {5}{w}{u}{b}
cycling {b}
cycling {b}{b}
cycling {b/r}
cycling {g}
cycling {g/w}
cycling {r}
cycling {r/g}
cycling {u}
cycling {u/b}
cycling {w}
@ deals 10 damage to target creature or player.
@ deals 10 damage to target player and you gain 10 life.
@ deals 13 damage to each creature.

View File

@ -1,6 +1,6 @@
//=========================================================================
//
// This file was generated by Mouse 1.5 at 2012-12-16 04:21:25 GMT
// This file was generated by Mouse 1.5 at 2013-02-13 04:29:45 GMT
// from grammar '/home/melvin/Modules/magarena/grammar/mtg.peg'.
//
//=========================================================================
@ -432,7 +432,7 @@ public class MagicRuleParser extends magic.grammar.ParserMemo
// ManaCost / "replicate" SPACE ManaCost / "miracle" SPACE ManaCost
// / "level up" SPACE ManaCost / "level" SPACE Number "-" Number /
// "level" SPACE Number "+" / "champion" SPACE "a" "n"? SPACE
// SelectCreature ;
// SelectCreature / "cycling" SPACE ManaCost ;
//=====================================================================
private boolean Keyword()
{
@ -498,6 +498,7 @@ public class MagicRuleParser extends magic.grammar.ParserMemo
if (Keyword_20()) return sem.action() && accept();
if (Keyword_21()) return sem.action() && accept();
if (Keyword_22()) return sem.action() && accept();
if (Keyword_23()) return sem.action() && accept();
return reject();
}
@ -781,6 +782,18 @@ public class MagicRuleParser extends magic.grammar.ParserMemo
return acceptInner();
}
//-------------------------------------------------------------------
// Keyword_23 = "cycling" SPACE ManaCost
//-------------------------------------------------------------------
private boolean Keyword_23()
{
if (savedInner(Keyword_23)) return reuseInner();
if (!next("cycling")) return rejectInner();
if (!SPACE()) return rejectInner();
if (!ManaCost()) return rejectInner();
return acceptInner();
}
//=====================================================================
// ColorlessCost = "{" Number "}" / "{x}" ;
//=====================================================================
@ -4603,6 +4616,7 @@ public class MagicRuleParser extends magic.grammar.ParserMemo
final Cache Keyword_20 = new Cache("Keyword_20"); // "level" SPACE Number "-" Number
final Cache Keyword_21 = new Cache("Keyword_21"); // "level" SPACE Number "+"
final Cache Keyword_22 = new Cache("Keyword_22"); // "champion" SPACE "a" "n"? SPACE SelectCreature
final Cache Keyword_23 = new Cache("Keyword_23"); // "cycling" SPACE ManaCost
final Cache ColorlessCost_0 = new Cache("ColorlessCost_0"); // "{" Number "}"
final Cache ManaCost_0 = new Cache("ManaCost_0"); // ColorlessCost+ HybridSingleCost* SingleColor*
final Cache ManaCost_1 = new Cache("ManaCost_1"); // HybridSingleCost+ SingleColor*
@ -4780,8 +4794,8 @@ public class MagicRuleParser extends magic.grammar.ParserMemo
Keyword_4,Keyword_5,Keyword_6,Keyword_7,Keyword_8,Keyword_9,
Keyword_10,Keyword_11,Keyword_12,Keyword_13,Keyword_14,Keyword_15,
Keyword_16,Keyword_17,Keyword_18,Keyword_19,Keyword_20,Keyword_21,
Keyword_22,ColorlessCost_0,ManaCost_0,ManaCost_1,ManaCost_2,
CastTrigger_0,CastTrigger_1,EntersBattlefieldTrigger_0,
Keyword_22,Keyword_23,ColorlessCost_0,ManaCost_0,ManaCost_1,
ManaCost_2,CastTrigger_0,CastTrigger_1,EntersBattlefieldTrigger_0,
DiesTrigger_0,DiesTrigger_1,DealsDamageTrigger_0,DamageReceiver_0,
DamageReceiver_1,DamageReceiver_2,DamageReceiver_3,
DamageReceiver_4,DamageReceiver_5,DamageReceiver_6,