Analytic Martial Arts

Wednesday, February 22, 2012

A Grammar for Describing Forms, V2

I've made more headway on my project to simplify notation typesetting, details of which can be found at Shiny Ideas. As a byproduct of this work I've refined the grammar which I previously described here; the updated version is as follows:

start → line*
line → blankline | actionline | definitionline
blankline → [ \t]* '\n'
actionline → left ',' center ',' right (',' annotation ){0,1} '\n]
definitionline → \w+ '\n'
left → atom*
center → atom*
right → atom*
annotation → .+
atom → direction | jump | turn | literal | action
direction → 'LEFT' | 'RIGHT' | 'FORWARD' | 'BACK' | 'BACKLEFT' | 'BACKRIGHT' | 'FORWARDLEFT' | 'FORWARDRIGHT'
jump → 'JUMP'
turn → ( 'TURNLEFT' | 'TURNRIGHT' ) ( '(' \d+ ')' ){0,1}
literal → \" .+ \"
action → symbol ( '(' modifiers+ ')' ){0,1}
modifiers → direction | symbol | grapple
symbol → \w+
grapple → 'GRAPPLE'

The changes from the previous version are as follows:

  • Addition of definition lines. These are intended to allow named blocks of notation to be interpolated with another notation block i.e. if you have a particular sequence that repeats multiple times you can define it once and then insert it in multiple locations. Note that this feature only makes sense in the context of the larger notation document format that I'm currently developing.
  • Action lines may now include an optional annotation.

There may be a few more, small modifications as I actually put this grammar to use, but at the moment I believe it encapsulates all the notation I've developed so far.

No comments: