init
This commit is contained in:
@@ -0,0 +1,235 @@
|
||||
==================
|
||||
Declarations
|
||||
==================
|
||||
|
||||
immutable :: 1
|
||||
mutable := 2
|
||||
typed: i32: 3
|
||||
deferred: i32
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(declaration
|
||||
(identifier)
|
||||
(signed_numeric_literal
|
||||
(integer_literal)))
|
||||
(declaration
|
||||
(identifier)
|
||||
(signed_numeric_literal
|
||||
(integer_literal)))
|
||||
(declaration
|
||||
(identifier)
|
||||
(primitive_type)
|
||||
(signed_numeric_literal
|
||||
(integer_literal)))
|
||||
(declaration
|
||||
(identifier)
|
||||
(primitive_type)))
|
||||
|
||||
==================
|
||||
Types and constructors
|
||||
==================
|
||||
|
||||
Point :: &{
|
||||
x: i32:
|
||||
y: i32 = 0
|
||||
}
|
||||
point := &Point.{ x: 1; y = 2 }
|
||||
maybe: []{i32?}: [nil, 1->|.some]
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(declaration
|
||||
(identifier)
|
||||
(type_definition
|
||||
(product_type
|
||||
(product_field
|
||||
(identifier)
|
||||
(primitive_type))
|
||||
(product_field
|
||||
(identifier)
|
||||
(primitive_type)
|
||||
(signed_numeric_literal
|
||||
(integer_literal))))))
|
||||
(declaration
|
||||
(identifier)
|
||||
(product_constructor
|
||||
(identifier)
|
||||
(product_entry
|
||||
(identifier)
|
||||
(signed_numeric_literal
|
||||
(integer_literal)))
|
||||
(product_entry
|
||||
(identifier)
|
||||
(signed_numeric_literal
|
||||
(integer_literal)))))
|
||||
(declaration
|
||||
(identifier)
|
||||
(array_type
|
||||
(grouped_type
|
||||
(optional_type
|
||||
(primitive_type))))
|
||||
(collection_literal
|
||||
(collection_entry
|
||||
(nil_literal))
|
||||
(collection_entry
|
||||
(pipeline_expression
|
||||
(signed_numeric_literal
|
||||
(integer_literal))
|
||||
(direct_pipeline_stage
|
||||
(pipeline_callable
|
||||
(sum_constructor
|
||||
(identifier)))))))))
|
||||
|
||||
==================
|
||||
Control flow and patterns
|
||||
==================
|
||||
|
||||
describe: []i32 -> str: @ values: []i32 { match values {
|
||||
[] => 'empty'
|
||||
[first, ...rest] if first > 0 => 'positive'
|
||||
_ => 'other'
|
||||
} }
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(declaration
|
||||
(identifier)
|
||||
(function_type
|
||||
(array_type
|
||||
(primitive_type))
|
||||
(primitive_type))
|
||||
(function_literal
|
||||
(typed_parameter
|
||||
(identifier)
|
||||
(array_type
|
||||
(primitive_type)))
|
||||
(block
|
||||
(match_expression
|
||||
(identifier)
|
||||
(match_arm
|
||||
(pattern
|
||||
(array_pattern))
|
||||
(string_literal))
|
||||
(match_arm
|
||||
(pattern
|
||||
(array_pattern
|
||||
(array_pattern_entry
|
||||
(pattern
|
||||
(identifier)))
|
||||
(array_pattern_entry
|
||||
(identifier))))
|
||||
(binary_expression
|
||||
(identifier)
|
||||
(signed_numeric_literal
|
||||
(integer_literal)))
|
||||
(string_literal))
|
||||
(match_arm
|
||||
(pattern)
|
||||
(string_literal)))))))
|
||||
|
||||
==================
|
||||
Physical-line continuations
|
||||
==================
|
||||
|
||||
value := 'text' # the newline remains significant
|
||||
->reverse_chrs
|
||||
|
||||
ready :: first
|
||||
and second
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(declaration
|
||||
(identifier)
|
||||
(pipeline_expression
|
||||
(string_literal)
|
||||
(comment)
|
||||
(continuation_pipeline_stage
|
||||
(pipeline_callable
|
||||
(identifier)))))
|
||||
(declaration
|
||||
(identifier)
|
||||
(binary_expression
|
||||
(identifier)
|
||||
(identifier))))
|
||||
==================
|
||||
Compact range after an integer
|
||||
==================
|
||||
|
||||
slice :: (source,0..<limit)
|
||||
trailing_dot :: 1.
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(declaration
|
||||
(identifier)
|
||||
(tuple_value
|
||||
(identifier)
|
||||
(range_expression
|
||||
(signed_numeric_literal
|
||||
(integer_literal))
|
||||
(identifier))))
|
||||
(declaration
|
||||
(identifier)
|
||||
(signed_numeric_literal
|
||||
(float_literal))))
|
||||
|
||||
==================
|
||||
Typed function declarations
|
||||
==================
|
||||
|
||||
double :: @ value: i32 { value * 2 }
|
||||
square :: @ value: i32 => i32 { value * value }
|
||||
add :: @ (left: i32, right: i32) { left + right }
|
||||
unit :: @ { () }
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(declaration
|
||||
(identifier)
|
||||
(function_literal
|
||||
(typed_parameter
|
||||
(identifier)
|
||||
(primitive_type))
|
||||
(block
|
||||
(binary_expression
|
||||
(identifier)
|
||||
(signed_numeric_literal
|
||||
(integer_literal))))))
|
||||
(declaration
|
||||
(identifier)
|
||||
(function_literal
|
||||
(typed_parameter
|
||||
(identifier)
|
||||
(primitive_type))
|
||||
(primitive_type)
|
||||
(block
|
||||
(binary_expression
|
||||
(identifier)
|
||||
(identifier)))))
|
||||
(declaration
|
||||
(identifier)
|
||||
(function_literal
|
||||
(typed_tuple_pattern
|
||||
(typed_tuple_component
|
||||
(identifier)
|
||||
(primitive_type))
|
||||
(typed_tuple_component
|
||||
(identifier)
|
||||
(primitive_type)))
|
||||
(block
|
||||
(binary_expression
|
||||
(identifier)
|
||||
(identifier)))))
|
||||
(declaration
|
||||
(identifier)
|
||||
(function_literal
|
||||
(block
|
||||
(unit_literal)))))
|
||||
Reference in New Issue
Block a user