UPSB v3

Naming Committee / [topic][5.27] Formal Grammar

  1. Zombo
    Date: Wed, Jan 6 2010 03:34:09

    This project attempts to formally define the grammar used for breakdowns. Clearly defining the grammar is useful for implementing breakdown parsing programs. The following topic is based on Skatox' project on FPSB (http://thefpsb.penspinning.fr/viewtopic.php?f=67&t=6587).

    Lexicon

    The first step in defining the grammar is to define the lexicon, which contains the vocabulary used in the language. For Pen Spinning, the stub looks like this:

    CODE
    TRICK_NAME : "sonic" | "backaround" | "thumbaround" | "charge" | "infinity"
    -----------------------------
    STYLE_MODIFIER : "fingerless" | "aerial"
    -----------------------------
    SPIN_MODIFIER :  (0 + ([123456789].[0123456789]*).".".(0+5)
    -----------------------------
    DIRECTION_MODIFIER : "reverse" | "normal"
    -----------------------------
    LINK_WORD : ">"
    -----------------------------


    Observe the special construct used for SPIN_MODIFIER. This is what we call a regular expression. Because it is impossible to list all possibilities, the regular expression enumerates all possible variants of n.0 or n.5 (0.5, 1.0, 1.5 ... 23.5, etc.)

    Syntax

    Now that we have the vocabulary, we need to know how to put them together to make breakdowns. Here's a stub:
    CODE
    COMBO :
    TRICK |
    TRICK LINK_WORD COMBO
    -----------------------------
    TRICK :
    TRICK_STYLE_MODS TRICK_DIRECTION_MOD TRICK_NAME TRICK_SPIN_MOD
    -----------------------------
    TRICK_STYLE_MODS :
    STYLE_MODIFIER TRICK_STYLE_MODS | EMPTY
    -----------------------------
    TRICK_DIRECTION_MOD :
    DIRECTION_MODIFIER | EMPTY
    -----------------------------
    TRICK_SPIN_MOD :
    SPIN_MODIFIER | EMPTY
    -----------------------------
    EMPTY :

    -----------------------------


    Notice that the recursive nature of the rules. Elements in CAPITALS are considered non-terminals, while those in lower case are considered terminals. The way it works is that as long as your combo contains non-terminals, it is incomplete. The whole combo must be eventually written in lower-case. If you can't do it, it means you have an incorrect combo, syntaxically speaking.

    Example

    Suppose I want to write:

    sonic > backaround > fingerless thumbaround 1.5 > fingerless aerial infinity

    First of all, notice that this combo makes no sense in the real world because the tricks don't exist. Semantically, it has no real meaning, but that does not mean it is not syntaxically correct.

    First thing to do is create a new COMBO element:

    COMBO

    Using our COMBO rules, we can translate it to:

    TRICK LINK_WORD COMBO

    We have 4 tricks in our combo, so we'll expand the right-most COMBO again:

    TRICK LINK_WORD TRICK LINK_WORD COMBO

    and again:

    TRICK LINK_WORD TRICK LINK_WORD TRICK LINK_WORD COMBO

    Finally we replace the last COMBO with TRICK:

    TRICK LINK_WORD TRICK LINK_WORD TRICK LINK_WORD TRICK

    We have the general structure. LINK_WORD are easy to replace because they only have 1 terminal, ">":

    TRICK > TRICK > TRICK > TRICK

    Now let's look at our TRICK rule and expand the last one:

    TRICK > TRICK > TRICK > TRICK_STYLE_MODS TRICK_DIRECTION_MOD TRICK_NAME TRICK_SPIN_MOD

    TRICK_STYLE_MODS can be expanded to :

    ... STYLE_MODIFIER TRICK_STYLE_MODS ...

    STYLE_MODIFIER we want is fingerless, which is in our lexicon:

    ... fingerless TRICK_STYLE_MODS ...

    we still have another style modifier to add so we use the recursive rule:

    ... fingerless STYLE_MODIFIER TRICK_STYLE_MODS ...

    this new STYLE_MODIFIER element will be aerial:

    ... fingerless aerial TRICK_STYLE_MODS ...

    TRICK_STYLE_MODS can now be replaced by EMPTY:

    ... fingerless aerial EMPTY ...

    Which can be replaced by the terminal "" (empty string):

    ... fingerless aerial ...

    This is what we have now:

    TRICK > TRICK > TRICK > fingerless aerial TRICK_DIRECTION_MOD TRICK_NAME TRICK_SPIN_MOD

    TRICK_NAME is easy, it's just infinity in our lexicon:

    TRICK > TRICK > TRICK > fingerless aerial TRICK_DIRECTION_MOD infinity TRICK_SPIN_MOD

    there's no direction or spin mods, so make both EMPTY:

    TRICK > TRICK > TRICK > fingerless aerial EMPTY infinity EMPTY

    Terminate those:

    TRICK > TRICK > TRICK > fingerless aerial infinity

    Same process can be done for the other 3 tricks, ultimately we get:

    sonic > backaround > fingerless thumbaround 1.5 > fingerless aerial infinity

    since we were able to construct this breakdown entirely using our rules AND we have no more non-terminals left, it is syntactically correct.

    What next?

    As far as grammar is concerned, the lexicon obviously needs to be expanded to cover all known tricks, the link-words are also missing the interrupted notation. For the syntax rules, you'll notice the omission of fingerslots. Fingerslots have a certain semantic meaning, because slots from one trick must correspond to the ones of the next and are therefore difficult to integrate as syntax. It's better left as semantic analysis AFTER the combo is validated to be syntactically correct.

    Once the grammar is ready, we can implement it and run analysis on breakdowns.
    - Simple stuff include counting direction changes, total rotation, ratio of reverse and normal tricks.
    - It can also allow us to maintain a database of combos, where one could not only find breakdowns of famous combos, but type breakdowns and find if they've been used in a combo or similar to other combos known, etc.
    - Fancier projects could include a virtual combo simulator, which can understand breakdowns and produce a 3D video of the chosen combo under any lighting and camera angle possible...
    - Finally, combos can be translated from one notation to another easily. Hybrid notations can be notated as "macros" which are automatically translated/converted to interrupted notation and vice versa.

  2. hoiboy
    Date: Wed, Jan 6 2010 04:24:40

    the modifier "twisted" isn't standardized

    twisted sonic/sonic vs. twisted cobra bite/cobra bite

  3. Shadowserpant
    Date: Wed, Jan 6 2010 04:28:18

    yeah i don't know how twisted can be defined

  4. Zombo
    Date: Wed, Jan 6 2010 05:08:51

    QUOTE (hoiboy @ Jan 5 2010, 11:24 PM) <{POST_SNAPBACK}>
    the modifier "twisted" isn't standardized

    twisted sonic/sonic vs. twisted cobra bite/cobra bite


    shit sorry, i should remove it