It is currently 16 Apr 2024, 18:02
   
Text Size

Cards Text Grammar

Moderators: silly freak, CCGHQ Admins

Cards Text Grammar

Postby silly freak » 09 Sep 2010, 12:48

This is a list of the possibilities of the "text" line in card files:

General Grammar
Code: Select all
Text:
  Effects
  ActivatedAbility
  TriggeredAbility

ActivatedAbility:
  Costs ":" Effects

TriggeredAbility:
  Trigger "," Effects

Costs:
  Cost
  Cost "," Costs

Effects:
  Effect "."
  Effect Effects
"Features"
Code: Select all
Cost:
  ManaSequence
  "{T}"
  "{Q}"
  "Sacrifice ~"

Effect:
  "Add" ManaSequence "to your mana pool"
  "Draw a card" | "Draw" Number "cards"
  "~ deals" Number "damage to all creatures"
  "Destroy all creatures" ". They can't be regenerated"?

Trigger:
  "When ~ enters the battlefield"
In Progress:
Code: Select all
Effect:
  "You gain" Number "life"
Generally, parsing uses regular expressions, so it is case-sensitive. However, the literals support lowercase in addition to the case in the examples; e.g.
Code: Select all
Example  Regex actually used
"You"    "[Yy]ou"
"you"    "you"
When different literals are combined, e.g.
Code: Select all
Trigger "," Effects
additional whitespace is allowed ("\s*")
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Cards Text Grammar

Postby nantuko84 » 09 Sep 2010, 19:01

Have you tried ANTLR?
It generates lexer and parser with built-in constructions bases on grammar written in format very similar to BNF (Backus Normal Form).
Mage\MagicWars blog: http://mwars.blogspot.com/
nantuko84
DEVELOPER
 
Posts: 266
Joined: 08 Feb 2009, 21:14
Has thanked: 2 times
Been thanked: 9 times

Re: Cards Text Grammar

Postby silly freak » 09 Sep 2010, 19:27

I have heard (and read in your blog) of it, but not yet tried it. I played with DSLs in Scala, and will probably use ANTLR at some point.
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times


Return to Development

Who is online

Users browsing this forum: No registered users and 6 guests


Who is online

In total there are 6 users online :: 0 registered, 0 hidden and 6 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 6 guests

Login Form