Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
159 lines (158 sloc) 3.77 KB
grammar AnsiSmalltalk
rule root
(statements)
end
rule statements
((expressions) (separator_p) ("^" (expression) "."0*1)0*1)
end
rule expressions
(((expression) ".")0* (expression)0*1)
end
rule separator_p
(separator)0*1
end
rule expression
((assignment_expression) | (normal_expression))
end
rule separator
((comment) | (space))1*
end
rule assignment_expression
((separator_p) (assignment) (normal_expression))
end
rule normal_expression
((separator_p) ((cascaded_message_expression) | (message_expression) | (primary)) (separator_p))
end
rule comment
("\"" ("\"\"" | (!"\"" .))0* "\"")
end
rule space
[\s]1*
end
rule assignment
((variable_name) (separator_p) (":=" | "_"))
end
rule cascaded_message_expression
((message_expression) (";" (separator_p) (message_send))1*)
end
rule message_expression
((keyword_expression) | (binary_expression) | (unary_expression))
end
rule primary
((literal) | (block) | (brace_expression) | ("(" (expression) ")") | (variable_name))
end
rule variable_name
(bindable_identifier)
end
rule message_send
((keyword_send) | (binary_send) | (unary_send))
end
rule keyword_expression
((binary_object) (keyword_send))
end
rule binary_expression
((unary_object) ((separator_p) (binary_send))1*)
end
rule unary_expression
((primary) ((separator_p) (unary_send))1*)
end
rule literal
((character_constant) | (number) | (symbol_constant) | (string) | (array_constant) | (reserved_identifier))
end
rule block
("[" (separator_p) ((block_arguments)0*1 (separator_p) (code_body)) "]")
end
rule brace_expression
("{" (separator_p) ((expressions) (separator_p) (expression)0*1) (separator_p) "."0*1 (separator_p) "}")
end
rule bindable_identifier
(!(reserved_identifier) (identifier))
end
rule keyword_send
((separator_p) (keyword) (separator_p) (binary_object))1*
end
rule binary_send
((binary_selector) (separator_p) (unary_object))
end
rule unary_send
((identifier) !(":" | (letter) | (digit)))
end
rule binary_object
((binary_expression) | (unary_object))
end
rule unary_object
((unary_expression) | (primary))
end
rule character_constant
("$" .)
end
rule number
((scaled_decimal) | (float) | (integer))
end
rule symbol_constant
("#" (symbol))
end
rule string
("'" ("''" | (!"'" .))0* "'")
end
rule array_constant
("#" (array))
end
rule reserved_identifier
("true" | "false" | "nil" | "self" | "super")
end
rule block_arguments
(((separator_p) ":" (variable_name) (separator_p))1* "|")
end
rule code_body
((locals)0*1 (statements))
end
rule identifier
((letter) ((letter) | (digit) | "_")0*)
end
rule keyword
((identifier) ":")
end
rule binary_selector
(("-"1* | (special)) (special)0*)
end
rule letter
[A-Za-z]
end
rule digit
[\d]
end
rule scaled_decimal
(((decimal) ("." (digit)1*)0*1) "s" (decimal))
end
rule float
((scientific_float) | (normal_float))
end
rule integer
((radix) | (decimal))
end
rule symbol
((keyword)1* | (identifier) | (binary_selector) | (string))
end
rule array
("(" (((number) | (symbol_constant) | (symbol) | (string) | (character_constant) | (array_constant) | (array)) | (separator))0* ")")
end
rule locals
("|" (separator_p) ((variable_name) (separator_p))0* "|")
end
rule special
("+" | "*" | "/" | "\\" | "~" | "<" | ">" | "=" | "@" | "%" | "&" | "?" | "!" | "`" | "," | "|")
end
rule decimal
("-"0*1 (digit)1*)
end
rule scientific_float
(((normal_float) | (integer)) [edq] (integer))
end
rule normal_float
((decimal) "." (digit)1*)
end
rule radix
((decimal) "r" ((digit) | (letter))1*)
end
end
Something went wrong with that request. Please try again.