Ptr = Struct.new(:type)
Int = Struct.new(:min, :max)
Float = Struct.new(:bits)
+ Nilable = Struct.new(:type)
end
module Ast
SPACE = /([ \t\v\n\r]+|#.*\n)/
IDENT = /[_a-zA-Z][_a-zA-Z0-9]*/
BRACES = /[\(\)\[\]\{\}\.]/
- OPERATORS = /[*\/=+-:\$]/
+ OPERATORS = /[*\/=+-:\$?]/
INTEGER = /[0-9]+/
STRING = /"(\\"|[^"])*"/
ID_TYPES = {
struct_type()
elsif matches("*")
pointer_type()
+ elsif matches("?")
+ nilable_type()
# elsif matches(:func)
# func_type()
else
Type::Ptr.new(type_specifier())
end
+ def nilable_type()
+ expect("?")
+ Type::Nilable.new(type_specifier())
+ end
+
#######################################
# Variable Definitions
#######################################