# Use "#" character to insert comments # Blank lines are ignored # Use "0" to denote end state, "1" for start state # States must all be in ascending order (I think...) # Format must follow: # # STATE_NUM:(space)+comment # (tab)+STATE_NUM:(space)+char,(space)+char(tab)+comment # # TODO, this needs fixing... 0: START: ATTR_NAME="\0t", MODE=ATTR_VAL 0: ( PUSH set STATE=NODE and jump to the start of the NODE state's logic 1: GROUP_END: ): POP x else: throw error "missing operator" 2: NODE: x #: FLUSH, ATTR_NAME="id", MODE=ATTR_VAL x .: FLUSH, ATTR_NAME="className", MODE=ATTR_VAL x [: FLUSH, STATE=ATTR_NAME x {: CREATE, PARENT=last_node_created, ATTR_NAME="nodeValue", MODE=ATTR_VAL, STATE=TEXT x (: throw error "missing operator" x else: if MODE=null, throw error "missing operator"; CONSUME 1-2: START/NODE/GROUP_END: x W: skip character x >: CREATE, STATE=START, PARENT=last_node_created x ^: CREATE, STATE=START, PARENT=PARENT.parentNode; throw error if parent is null x +: CREATE, STATE=START x ): if STATE != GROUP_END, CREATE; STATE=GROUP_END, POP x E: if group/parentheses stack is not empty, throw error "missing parentheses" if STATE != GROUP_END, CREATE; stop parsing... 3: STRING: x "': STATE=STR_STATE x else: CONSUME x E: throw error "missing matching quote" #4 TEXT: x W: skip character x "': STR_STATE=TEXT_WS, STATE=STRING x else: CONSUME, STATE=TEXT_WS x E: "missing closing curly brace" #5 TEXT_WS: x W: if TEXT_WS_START = 0, set TEXT_WS_START to the current length of the string builder; CONSUME x }: CREATE, STATE=GROUP_END x "': TEXT_WS_START=0, STR_STATE=TEXT_WS, STATE=STRING x else: TEXT_WS_START=0, CONSUME x E: "missing closing curly brace" #6-7 ATTR_NAME/ATTR_EQUALS: x W: skip character x ]: MODE=null, STATE=NODE x =: if STATE != ATTR_EQUALS, throw error "missing attribute name"; STATE=ATTR_VAL x "': MODE=ATTR_NAME, ATTR_STATE=ATTR_EQUALS, STR_STATE=ATTR_DEF, STATE=STRING x else: MODE=ATTR_NAME, CONSUME, ATTR_STATE=ATTR_EQUALS, STATE=ATTR_DEF x E: throw error "missing closing bracket" #8 ATTR_VAL: x W: skip character x ]E: throw error "missing attribute value" x =: throw error "invalid '=' in attribute list" x "': MODE=ATTR_VAL, ATTR_STATE=ATTR_NAME, STR_STATE=ATTR_DEF, STATE=STRING x else: MODE=ATTR_VAL, CONSUME, ATTR_STATE=ATTR_NAME, STATE=ATTR_DEF #9 ATTR_DEF: x =: if ATTR_STATE = ATTR_NAME, throw "invalid '=' in attribute list"; FLUSH, STATE=ATTR_VAL x W: FLUSH, STATE=ATTR_STATE x ]: FLUSH, MODE=null, STATE=NODE x "': STR_STATE=ATTR_DEF, STATE=STRING x else: CONSUME x E: throw error "missing closing bracket"