lib/qrb/syntax/q.citrus in qrb-0.2.0 vs lib/qrb/syntax/q.citrus in qrb-0.3.0

- old
+ new

@@ -106,10 +106,11 @@ # terminal forms rule term_type ad_type | builtin_type + | any_type | type_ref end # ad type @@ -117,14 +118,36 @@ (('.' builtin_type_name)? spacing contract (spacing ',' spacing contract)*) <Qrb::Syntax::AdType> end rule contract - ('<' contract_name '>' spacing type (spacing ('\\' up:lambda_expr) spacing ('\\' down:lambda_expr))?) + ('<' contract_name '>' spacing type spacing pair?) <Qrb::Syntax::Contract> end + rule pair + inline_pair + | external_pair + end + + rule inline_pair + ('\\' dress:lambda_expr spacing '\\' undress:lambda_expr) + <Qrb::Syntax::InlinePair> + end + + rule external_pair + ('.' builtin_type_name) + <Qrb::Syntax::ExternalPair> + end + + # any + + rule any_type + '.' + <Qrb::Syntax::AnyType> + end + # builtin and refs rule builtin_type ('.' builtin_type_name) <Qrb::Syntax::BuiltinType> @@ -148,22 +171,22 @@ | (![\(,\)] .)+ expression? ) <Qrb::Syntax::Expression> end - # lexer + # LEXER (names) rule var_name /[a-z]+/ end rule contract_name /[a-z][a-z0-9]*/ end rule constraint_name - /[a-z][a-z_]*/ + /[a-z][a-zA-Z_]*/ end rule attribute_name /[a-z][a-zA-Z0-9_]*/ end @@ -171,11 +194,13 @@ rule type_name /[A-Z][a-zA-Z]+/ end rule builtin_type_name - /[a-zA-Z0-9:]/+ + /[a-zA-Z0-9:]+/ end + + # LEXER (spacing & comments) rule spacing (spaces | comment)* end