lib/parser/koi-reference-parser.treetop in koi-reference-parser-0.0.1 vs lib/parser/koi-reference-parser.treetop in koi-reference-parser-0.0.2
- old
+ new
@@ -1,197 +1,197 @@
-grammar KoiReferenceParser
-
- rule block
- statement+ <Block>
- end
-
- rule statement
- space? ( hash_assignment / assignment / if / unless / function_call ) ';'? space? <Statement>
- end
-
- rule nil
- "nil" <NilLiteral>
- end
-
- rule true
- "true" <TrueLiteral>
- end
-
- rule false
- "false" <FalseLiteral>
- end
-
- rule integer
- ('+' / '-')? [0-9]+ <IntegerLiteral>
- end
-
- rule float
- ('+' / '-')? [0-9]+ '.' [0-9]+ <FloatLiteral>
- end
-
- rule string
- '"' ([^"\\] / "\\" . )* '"' <StringLiteral>
- end
-
- rule identifier
- '$'? [a-zA-Z] [a-zA-Z0-9_]* <Identifier>
- end
-
- rule hash_assignment
- identifier hash_accessor_list space? assignment_operator space? ( hash / function_definition / expression ) <HashAssignment>
- end
-
- rule assignment
- identifier space? assignment_operator space? ( hash / function_definition / expression ) <Assignment>
- end
-
- ##################
- # Flow control
-
- rule if
- 'if(' space? expression space? ')' space
- block
- space? 'end' space? <If>
- end
-
- rule unless
- 'unless(' space? expression space? ')' space
- block
- space? 'end' space? <Unless>
- end
-
- ##################
- # Functions
-
- rule function_call
- identifier space? '(' space? expression? space? ','? expression? space? ')' <FunctionCall>
- end
-
- rule function_definition
- 'function(' space? identifier space? ')'
- block
- space? 'end' <FunctionDefinition>
- end
-
- ##################
- # Whitespace
-
- rule space
- [\s]+ <Whitespace>
- end
-
- ##################
- # Hashes
-
- rule hash_accessor_list
- hash_accessor+ <HashAccessorList>
- end
-
- rule hash_accessor
- '[' expression ']' <HashAccessor>
- end
-
- rule hash
- '{' key_value_list? '}' <HashLiteral>
- end
-
- rule key_value_list
- key_value+ <KeyValueList>
- end
-
- rule key_value
- space? expression space? '=>' space? expression space? ','? <KeyValue>
- end
-
- rule key
- space? expression space? <Key>
- end
-
- rule value
- space? expression space? <Value>
- end
-
- ##################
- # Expressions
-
- rule expression
- space? (hash_access / comparative / additive) <Expression>
- end
-
- rule hash_access
- identifier hash_accessor_list <HashAccess>
- end
-
- rule comparative
- additive space? (equality_operator / inequality_operator / greater_than_operator / less_than_operator) space? additive <ComparativeExpression>
- end
-
- rule additive
- multitive space? additive_operator space? additive <AdditiveExpression>
- /
- multitive
- end
-
- rule additive_operator
- addition_operator
- /
- subtraction_operator
- end
-
- rule multitive
- primary space? multitive_operator space? multitive <MultitiveExpression>
- /
- primary
- end
-
- rule multitive_operator
- multiplication_operator
- /
- division_operator
- end
-
- rule primary
- function_call / nil / false / true / identifier / float / integer / string
- /
- '(' space? expression space? ')' <Expression>
- end
-
- ##################
- # Operators
-
- rule assignment_operator
- '=' <AssignmentOperator>
- end
-
- rule addition_operator
- '+' <AdditionOperator>
- end
-
- rule subtraction_operator
- '-' <SubtractionOperator>
- end
-
- rule multiplication_operator
- '*' <MultiplicationOperator>
- end
-
- rule division_operator
- '/' <DivisionOperator>
- end
-
- rule equality_operator
- '==' <EqualityOperator>
- end
-
- rule inequality_operator
- '!=' <InequalityOperator>
- end
-
- rule greater_than_operator
- '>' <GreaterThanOperator>
- end
-
- rule less_than_operator
- '<' <LessThanOperator>
- end
-
-end
+grammar KoiReferenceParser
+
+ rule block
+ statement+ <Block>
+ end
+
+ rule statement
+ space? ( hash_assignment / assignment / if / unless / function_call ) ';'? space? <Statement>
+ end
+
+ rule nil
+ "nil" <NilLiteral>
+ end
+
+ rule true
+ "true" <TrueLiteral>
+ end
+
+ rule false
+ "false" <FalseLiteral>
+ end
+
+ rule integer
+ ('+' / '-')? [0-9]+ <IntegerLiteral>
+ end
+
+ rule float
+ ('+' / '-')? [0-9]+ '.' [0-9]+ <FloatLiteral>
+ end
+
+ rule string
+ '"' ([^"\\] / "\\" . )* '"' <StringLiteral>
+ end
+
+ rule identifier
+ '$'? [a-zA-Z] [a-zA-Z0-9_]* <Identifier>
+ end
+
+ rule hash_assignment
+ identifier hash_accessor_list space? assignment_operator space? ( hash / function_definition / expression ) <HashAssignment>
+ end
+
+ rule assignment
+ identifier space? assignment_operator space? ( hash / function_definition / expression ) <Assignment>
+ end
+
+ ##################
+ # Flow control
+
+ rule if
+ 'if(' space? expression space? ')' space
+ block
+ space? 'end' space? <If>
+ end
+
+ rule unless
+ 'unless(' space? expression space? ')' space
+ block
+ space? 'end' space? <Unless>
+ end
+
+ ##################
+ # Functions
+
+ rule function_call
+ identifier space? '(' space? expression? space? ','? expression? space? ')' <FunctionCall>
+ end
+
+ rule function_definition
+ 'function(' space? identifier space? ')'
+ block
+ space? 'end' <FunctionDefinition>
+ end
+
+ ##################
+ # Whitespace
+
+ rule space
+ [\s]+ <Whitespace>
+ end
+
+ ##################
+ # Hashes
+
+ rule hash_accessor_list
+ hash_accessor+ <HashAccessorList>
+ end
+
+ rule hash_accessor
+ '[' expression ']' <HashAccessor>
+ end
+
+ rule hash
+ '{' key_value_list? '}' <HashLiteral>
+ end
+
+ rule key_value_list
+ key_value+ <KeyValueList>
+ end
+
+ rule key_value
+ space? expression space? '=>' space? expression space? ','? <KeyValue>
+ end
+
+ rule key
+ space? expression space? <Key>
+ end
+
+ rule value
+ space? expression space? <Value>
+ end
+
+ ##################
+ # Expressions
+
+ rule expression
+ space? (hash_access / comparative / additive) <Expression>
+ end
+
+ rule hash_access
+ identifier hash_accessor_list <HashAccess>
+ end
+
+ rule comparative
+ additive space? (equality_operator / inequality_operator / greater_than_operator / less_than_operator) space? additive <ComparativeExpression>
+ end
+
+ rule additive
+ multitive space? additive_operator space? additive <AdditiveExpression>
+ /
+ multitive
+ end
+
+ rule additive_operator
+ addition_operator
+ /
+ subtraction_operator
+ end
+
+ rule multitive
+ primary space? multitive_operator space? multitive <MultitiveExpression>
+ /
+ primary
+ end
+
+ rule multitive_operator
+ multiplication_operator
+ /
+ division_operator
+ end
+
+ rule primary
+ function_call / nil / false / true / identifier / float / integer / string
+ /
+ '(' space? expression space? ')' <Expression>
+ end
+
+ ##################
+ # Operators
+
+ rule assignment_operator
+ '=' <AssignmentOperator>
+ end
+
+ rule addition_operator
+ '+' <AdditionOperator>
+ end
+
+ rule subtraction_operator
+ '-' <SubtractionOperator>
+ end
+
+ rule multiplication_operator
+ '*' <MultiplicationOperator>
+ end
+
+ rule division_operator
+ '/' <DivisionOperator>
+ end
+
+ rule equality_operator
+ '==' <EqualityOperator>
+ end
+
+ rule inequality_operator
+ '!=' <InequalityOperator>
+ end
+
+ rule greater_than_operator
+ '>' <GreaterThanOperator>
+ end
+
+ rule less_than_operator
+ '<' <LessThanOperator>
+ end
+
+end