I’ve been workin on Gleemin’s ability text interpreter, particularly the part of the grammar that recognises mana expressions. I’ve added a small update on Gleemin’s repository on Git. The following is from the comments in the latest source file (mana_grammar.pl). It will probably be of interest to anyone who is writing or thinking of writing a parser for ability text.
+-Textual mana symbols-+
The text version of the CompRules and the Magic Set FAQs consistently list mana values as capital letters or numbers enclosed in curly braces: {12}{X}{W}{U}{B}{R}{G}, etc.
The Gatherer’s text spoilers and text spoilers from sets’ product pages on the M:tG site take a more liberal approach.
The Gatehrer’s text spoilers list mana values as capital letters or numbers when they appear in cards’ mana costs (the mana symbols in the upper right corner), and as capital letters or numbers enclosed in curly braces when they appear in a card’s text box.
For example:
======================================================================
Name: Abbey Matron
Cost: 2W
Type: Creature — Human Cleric
Pow/Tgh: (1/3)
Rules Text: {W}, {T}: Abbey Matron gets +0/+3 until end of turn.
Set/Rarity: Homelands Common, Homelands Common
======================================================================
(http://gatherer.wizards.com/Pages/Search/Default.aspx?text=+[{W}])
On the other hand, hybrid mana is represented on The Gatherer as capital letters enclosed in parentheses in cards’ mana costs and as lower case letters enclosed in parentheses, enclosed in curly braces in a card’s text box:
======================================================================
Name: Avatar of Discord
Cost: (B/R)(B/R)(B/R)
Type: Creature — Avatar
Pow/Tgh: (5/3)
Rules Text: ({(b/r)} can be paid with either {B} or {R}.)
Flying
When Avatar of Discord enters the battlefield, sacrifice
it unless you discard two cards.
Set/Rarity: Archenemy Rare, Dissension Rare
=======================================================================
(http://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Dissension%22])
- but the other way around minus the curly braces in the text spoilers on sets’ product pages:
=======================================================================
Card Name: Avatar of Discord
Cost: (b/r)(b/r)(b/r)
Type: Creature - Avatar
Pow/Tgh: 5/3
Rules Text: ((B/R) can be paid with either B or R.)
Flying
When Avatar of Discord comes into play, sacrifice it
unless you discard two cards.
Set/Rarity: Dissension rare
=======================================================================
(http://www.wizards.com/magic/generic/cardlists/dissension_spoiler_en.txt)
It’s also interesting to note that the reminder text in The Gatherer text spoiler refers to a symbol that can not be found in the rest of that text (since it doesn’t use the same notation as the mana cost it is meant to clarify).
Curiously, searching The Gatherer for B/R seems to find the same (7) cards as searching for b/r, while searching for {(b/r)} finds nothing.
Similar considerations apply to:
Monocoloured hybrid mana (listed as {2/W} etc in the set FAQs and CompRules):
=======================================================================
Name: Advice from the Fae
Cost: (2/U)(2/U)(2/U)
Type: Sorcery
Pow/Tgh:
Rules Text: ({(2/u)} can be paid with any two mana or with {U}. This
card's converted mana cost is 6.) Look at the top five
cards of your library. If you control more creatures
than each other player, put two of those cards into your
hand. Otherwise, put one of them into your hand. Then
put the rest on the bottom of your library in any order.
Set/Rarity: Shadowmoor Uncommon
=======================================================================
(http://gatherer.wizards.com/Pages/Search/Default.aspx?output=spoiler&m
ethod=text&action=advanced&set=|[%22Shadowmoor%22])
Phyrexian mana (listed as {W/P} etc in the set FAQs and CompRules):
=======================================================================
Name: Act of Aggression
Cost: 3(R/P)(R/P)
Type: Instant
Pow/Tgh:
Rules Text: ({(r/p)} can be paid with either {R} or 2 life.)
Gain control of target creature an opponent controls
until end of turn. Untap that creature. It gains haste
until end of turn.
Set/Rarity: New Phyrexia Uncommon
=======================================================================
(http://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22New%20Ph
yrexia%22])
And also to Snow mana. In particular, the symbol for Snow mana is listed as {S} in FAQs and the CompRules, but appears as {S}i} in Gatherer searches, except apparently in the case of adjacent snow mana symbols where it appears as {S}i{S}i}:
=======================================================================
Name: Frost Raptor
Cost: 2U
Type: Snow Creature — Bird
Pow/Tgh: (2/2)
Rules Text: Flying
{S}i{S}i}: Frost Raptor gains shroud until end of turn.
({S}i} can be paid with one mana from a snow permanent.)
Set/Rarity: Coldsnap Common
=======================================================================
(http://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Coldsnap%
22])
-while in the text spoiler for Coldsnap, it appears as “oSi” (possibly as some kind of obscure in-joke on standardisation):
=======================================================================
CardName: Adarkar Windform
Cost: 4U
Type: Snow Creature - Illusion
Pow/Tgh: 3/3
Rules Text: Flying 1oSi: Target creature loses flying until end of turn.
(oSi can be paid with one mana from a snow permanent.)
Set/Rarity: Coldsnap Uncommon
=======================================================================
(http://www.wizards.com/magic/generic/cardlists/coldsnap_spoiler_en.txt)
Fun as all this variety may be, the grammar in this source file will have to focus on one kind of textual representation of mana symbols, lest madness sets in. This has to be the one in the CompRules, which are, after all, the “ultimate authority for the game”. Any other syntax will have to be compensated for at an earlier point in the parsing sequence (most probably the tokeniser).



