Skip to content

Instantly share code, notes, and snippets.

@jbowles
Created November 23, 2012 15:40
Show Gist options
  • Save jbowles/4136172 to your computer and use it in GitHub Desktop.
Save jbowles/4136172 to your computer and use it in GitHub Desktop.
Horizon Transactional Grammar First Draft
(def simple-grammar
  {:hub [:node-unique-accept :node-unique-check :node-unique-persist]
   :node-unique-accept [:ParseUrl :ParseParams :AcceptBool]
   :node-unique-check [:FormatRead :FormatCheckBool]
   :node-unique-persist [:SaveOrUpdate :PersistBool]
   :ParseUrl #{"http, www, mattcutts.com, /blog/seo-glossary-url-definitions/" "http, jbowles, github.com/" "http, www, cs.dartmouth.edu, /~mckeeman/cs48/mxcom/doc, FiniteAutomata.pdf" "https, www, ruby-toolbox.com, categories/state_machines.html"}
   :ParseParams #{"program address city state zip" "fname lname school program address city state zip" "fname lname school state zip" "fname lname city state zip"}
   :AcceptBool #{"0" "1"} ;;[] (one-of [0 1])
   :FormatRead #{"UTF8" "other stuff"}
   :FormatCheckBool #{"0" "1"} ;;[] (one-of [0 1])
   :SaveOrUpdate #{"id:3274 source_id:4739274 parent_id:59843 uuid:rujfd*JHI7fieo state_type:26 timestamp:2012-11-20" "id:89432 source_id:43927 parent_id:4893026 uuid:fjodau8Y*B state_type:26 timestamp:2012-11-19" "id:8493726 source_id:943278 parent_id:48932764 uuid:JG&^&*FGO( state_type:15 timestamp:2012-09-01" "id:85943782 source_id:483271 parent_id:9032747 uuid:JHIJY^F^&IH state_type:46 timestamp:2010-12-23"}
   :PersistBool #{"0" "1"}}) ;;[] (one-of [0 1])})

A :hub is composed of :nodes, a :node is composed of formulas like :ParseUrl, and a formula is composed of steps (above you only see the return values of the steps, for example :FormatRead is the formula and "UTF8" "other stuff" are the possible return value fo the step. Technically the grammar would consist of the functions/methods of steps themselves and not the return values. However, you could generate actual transactions that would get you the return values of the steps, much like I did above.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment