Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well you should probably look at EBNF to show your grammar in a widely accepted manner.</p> <p>I think it would look something like this:</p> <pre><code>S = Combination { ',' Combination } . Combination = Hand ['+' | '-' Hand] . Hand = Card Card ["s" | "o"] . Card = rank [ color ] . </code></pre> <p>Where {} means 0 or more occurences, [] means 0 or 1 occurence and | means either whats left of | or whats right of |.</p> <p>So basically what this comes down to is a start symbol (S) that says that the parser has to handle from 1 to any number of combinations that are all separated by a ",".</p> <p>These combinations consist of a description of a card and then either a "+", a "-" and another card description or nothing.</p> <p>A card description consists of rank and optionally a color (spades, hearts, etc.). The fact that rank and color aren't capitalized shows that they can't be further divided into subparts (making them a terminal class). </p> <p>My example doesn't provide the offsuite/suite possibility and that is mainly because in you're examples one time the o/s comes at the very end "AK-ATo" and one time in the middle "A2s+". </p> <p>Are these examples your own creation or are they given to you from an external source (read: you can't change them)? </p> <p>If you can change them I would strongly recommend placing those at one specified position of a combination (for example at the end) to make creating the grammar and ultimately the parsing a lot easier.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload