Compare commits
No commits in common. "41693788fcdd283132aa2b8636ff3b216654676c" and "59165f623525cc4330f1f5ae46dab0a43ce8e014" have entirely different histories.
41693788fc
...
59165f6235
@ -9,52 +9,22 @@ $defs:
|
|||||||
type: object
|
type: object
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
description: A definition of a node type.
|
description: A definition of a node type.
|
||||||
oneOf:
|
|
||||||
- $ref: "#/$defs/StructNodeDefinition"
|
|
||||||
- $ref: "#/$defs/EnumNodeDefinition"
|
|
||||||
- $ref: "#/$defs/LeafEnumNodeDefinition"
|
|
||||||
StructNodeDefinition:
|
|
||||||
type: object
|
|
||||||
additionalProperties: false
|
|
||||||
description: A description of a Struct node to be built.
|
|
||||||
properties:
|
properties:
|
||||||
type:
|
|
||||||
const: struct
|
|
||||||
children:
|
children:
|
||||||
|
type: array
|
||||||
description: Ordered child fields for this node.
|
description: Ordered child fields for this node.
|
||||||
items:
|
items:
|
||||||
$ref: "#/$defs/StructChildDefinition"
|
$ref: "#/$defs/StructChildDefinition"
|
||||||
required:
|
|
||||||
- children
|
|
||||||
EnumNodeDefinition:
|
|
||||||
type: object
|
|
||||||
additionalProperties: false
|
|
||||||
description: A description of an Enum node to be built.
|
|
||||||
properties:
|
|
||||||
type:
|
|
||||||
const: enum
|
|
||||||
rules:
|
rules:
|
||||||
type: array
|
type: array
|
||||||
description: Alternative parse rules that build this node.
|
description: Alternative parse rules that build this node.
|
||||||
items:
|
items:
|
||||||
$ref: "#/$defs/EnumChildDefinition"
|
$ref: "#/$defs/EnumChildDefinition"
|
||||||
required:
|
oneOf:
|
||||||
- rules
|
- required:
|
||||||
LeafEnumNodeDefinition:
|
- "children"
|
||||||
type: object
|
- required:
|
||||||
additionalProperties: false
|
- "rules"
|
||||||
description: A description of a leaf-enum node to be built.
|
|
||||||
properties:
|
|
||||||
type:
|
|
||||||
const: leaf_enum
|
|
||||||
rules:
|
|
||||||
type: array
|
|
||||||
description: Alternative parse rules that build this node.
|
|
||||||
items:
|
|
||||||
$ref: "#/$defs/LeafEnumChildDefinition"
|
|
||||||
required:
|
|
||||||
- type
|
|
||||||
- rules
|
|
||||||
StructChildDefinition:
|
StructChildDefinition:
|
||||||
description: A definition of a node's child. Either a bare child name (string) in snake case, or an object.
|
description: A definition of a node's child. Either a bare child name (string) in snake case, or an object.
|
||||||
oneOf:
|
oneOf:
|
||||||
@ -123,10 +93,6 @@ $defs:
|
|||||||
oneOf:
|
oneOf:
|
||||||
- $ref: "#/$defs/BuildSingleTypeChild"
|
- $ref: "#/$defs/BuildSingleTypeChild"
|
||||||
- $ref: "#/$defs/BuildBooleanChild"
|
- $ref: "#/$defs/BuildBooleanChild"
|
||||||
- $ref: "#/$defs/BuildStringChild"
|
|
||||||
- $ref: "#/$defs/BuildDoubleChild"
|
|
||||||
- $ref: "#/$defs/BuildIntChild"
|
|
||||||
- $ref: "#/$defs/BuildLongChild"
|
|
||||||
BuildSingleTypeChild:
|
BuildSingleTypeChild:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
@ -151,54 +117,6 @@ $defs:
|
|||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- rule_present
|
- rule_present
|
||||||
from:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- parse_whole_pair
|
|
||||||
BuildStringChild:
|
|
||||||
type: object
|
|
||||||
additionalProperties: false
|
|
||||||
description: A definition for building a string child.
|
|
||||||
properties:
|
|
||||||
type:
|
|
||||||
const: string
|
|
||||||
from:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- whole_pair
|
|
||||||
BuildDoubleChild:
|
|
||||||
type: object
|
|
||||||
additionalProperties: false
|
|
||||||
description: A definition for building a Double child.
|
|
||||||
properties:
|
|
||||||
type:
|
|
||||||
const: f64
|
|
||||||
from:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- parse_whole_pair
|
|
||||||
BuildIntChild:
|
|
||||||
type: object
|
|
||||||
additionalProperties: false
|
|
||||||
description: A definition for building an Int child.
|
|
||||||
properties:
|
|
||||||
type:
|
|
||||||
const: i32
|
|
||||||
from:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- parse_number_base
|
|
||||||
BuildLongChild:
|
|
||||||
type: object
|
|
||||||
additionalProperties: false
|
|
||||||
description: A definition for building a Long child.
|
|
||||||
properties:
|
|
||||||
type:
|
|
||||||
const: i64
|
|
||||||
from:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- parse_number_base
|
|
||||||
EnumChildDefinition:
|
EnumChildDefinition:
|
||||||
description: A definition of an enum node's child. Either a bare rule (string) in Pascal case, or an object.
|
description: A definition of an enum node's child. Either a bare rule (string) in Pascal case, or an object.
|
||||||
oneOf:
|
oneOf:
|
||||||
@ -217,28 +135,3 @@ $defs:
|
|||||||
required:
|
required:
|
||||||
- rule
|
- rule
|
||||||
- build
|
- build
|
||||||
LeafEnumChildDefinition:
|
|
||||||
description: A definition of a leaf-enum node's child. Either a bare rule-string in Pascal case, or an object.
|
|
||||||
oneOf:
|
|
||||||
- type: string
|
|
||||||
description: Shorthand where the rule name maps onto an empty enum rule.
|
|
||||||
- $ref: "#/$defs/LongLeafEnumChildDefinitionWrapper"
|
|
||||||
LongLeafEnumChildDefinitionWrapper:
|
|
||||||
type: object
|
|
||||||
description: Single-key object mapping the child-name to its spec.
|
|
||||||
minProperties: 1
|
|
||||||
maxProperties: 1
|
|
||||||
additionalProperties: false
|
|
||||||
patternProperties:
|
|
||||||
"^([A-Z][a-z0-9]*)*$":
|
|
||||||
$ref: "#/$defs/LongLeafEnumChildDefinition"
|
|
||||||
LongLeafEnumChildDefinition:
|
|
||||||
type: object
|
|
||||||
additionalProperties: false
|
|
||||||
description: A format for specifying more specific information about a leaf-enum child.
|
|
||||||
properties:
|
|
||||||
child:
|
|
||||||
type: boolean
|
|
||||||
description: If true, a node of the same name is built as the lone member of the enum child.
|
|
||||||
required:
|
|
||||||
- child
|
|
@ -206,517 +206,3 @@ PlatformFunction:
|
|||||||
- identifier
|
- identifier
|
||||||
- parameters
|
- parameters
|
||||||
- return_type
|
- return_type
|
||||||
InterfaceFunction:
|
|
||||||
children:
|
|
||||||
- fn_kw:
|
|
||||||
rule: Fn
|
|
||||||
skip: true
|
|
||||||
- generics:
|
|
||||||
rule: GenericParameters
|
|
||||||
build:
|
|
||||||
or_else_default: true
|
|
||||||
- identifier
|
|
||||||
- parameters
|
|
||||||
- return_type
|
|
||||||
InterfaceDefaultFunction:
|
|
||||||
children:
|
|
||||||
- def_kw:
|
|
||||||
rule: Def
|
|
||||||
skip: true
|
|
||||||
- fn_kw:
|
|
||||||
rule: Fn
|
|
||||||
skip: true
|
|
||||||
- generics:
|
|
||||||
rule: GenericParameters
|
|
||||||
build:
|
|
||||||
or_else_default: true
|
|
||||||
- identifier
|
|
||||||
- parameters
|
|
||||||
- return_type:
|
|
||||||
build:
|
|
||||||
or_else: void
|
|
||||||
- function_body
|
|
||||||
InterfaceOperatorFunction:
|
|
||||||
children:
|
|
||||||
- op_kw:
|
|
||||||
rule: Op
|
|
||||||
skip: true
|
|
||||||
- generics:
|
|
||||||
rule: GenericParameters
|
|
||||||
build:
|
|
||||||
or_else_default: true
|
|
||||||
- operator
|
|
||||||
- parameters
|
|
||||||
- return_type
|
|
||||||
InterfaceDefaultOperatorFunction:
|
|
||||||
children:
|
|
||||||
- def_kw:
|
|
||||||
rule: Def
|
|
||||||
skip: true
|
|
||||||
- op_kw:
|
|
||||||
rule: Op
|
|
||||||
skip: true
|
|
||||||
- generics:
|
|
||||||
rule: GenericParameters
|
|
||||||
build:
|
|
||||||
or_else_default: true
|
|
||||||
- operator
|
|
||||||
- parameters
|
|
||||||
- return_type:
|
|
||||||
build:
|
|
||||||
or_else: void
|
|
||||||
- function_body
|
|
||||||
|
|
||||||
# Function Bodies
|
|
||||||
FunctionBody:
|
|
||||||
rules:
|
|
||||||
- FunctionAliasBody
|
|
||||||
- FunctionEqualsBody
|
|
||||||
- FunctionBlockBody
|
|
||||||
FunctionEqualsBody:
|
|
||||||
children:
|
|
||||||
- expression
|
|
||||||
FunctionAliasBody:
|
|
||||||
children:
|
|
||||||
- alias_kw:
|
|
||||||
rule: Alias
|
|
||||||
skip: true
|
|
||||||
- identifier
|
|
||||||
FunctionBlockBody:
|
|
||||||
children:
|
|
||||||
- statements:
|
|
||||||
rule: Statement
|
|
||||||
vec: true
|
|
||||||
- end_kw:
|
|
||||||
rule: End
|
|
||||||
skip: true
|
|
||||||
|
|
||||||
# Class constructs
|
|
||||||
ClassConstructor:
|
|
||||||
children:
|
|
||||||
- members:
|
|
||||||
rule: Member
|
|
||||||
vec: true
|
|
||||||
Member:
|
|
||||||
children:
|
|
||||||
- is_public:
|
|
||||||
rule: Pub
|
|
||||||
build:
|
|
||||||
type: boolean
|
|
||||||
on: rule_present
|
|
||||||
- is_mut:
|
|
||||||
rule: Mut
|
|
||||||
build:
|
|
||||||
type: boolean
|
|
||||||
on: rule_present
|
|
||||||
- identifier
|
|
||||||
- type_use
|
|
||||||
|
|
||||||
# Statements
|
|
||||||
Statement:
|
|
||||||
rules:
|
|
||||||
- VariableDeclaration
|
|
||||||
- AssignmentStatement
|
|
||||||
- ExpressionStatement
|
|
||||||
- UseStatement
|
|
||||||
- IfElseStatement
|
|
||||||
- IfStatementStatement
|
|
||||||
- WhileStatement
|
|
||||||
- ForStatement
|
|
||||||
VariableDeclaration:
|
|
||||||
children:
|
|
||||||
- let_kw:
|
|
||||||
rule: Let
|
|
||||||
skip: true
|
|
||||||
- is_mut:
|
|
||||||
rule: Mut
|
|
||||||
build:
|
|
||||||
type: boolean
|
|
||||||
on: rule_present
|
|
||||||
- identifier
|
|
||||||
- type_use:
|
|
||||||
optional: true
|
|
||||||
- expression:
|
|
||||||
optional: true
|
|
||||||
AssignmentStatement:
|
|
||||||
children:
|
|
||||||
- left:
|
|
||||||
rule: Expression
|
|
||||||
- right:
|
|
||||||
rule: Expression
|
|
||||||
ExpressionStatement:
|
|
||||||
children:
|
|
||||||
- expression
|
|
||||||
IfStatement:
|
|
||||||
children:
|
|
||||||
- if_clause
|
|
||||||
- if_else_ifs:
|
|
||||||
rule: IfElseIf
|
|
||||||
vec: true
|
|
||||||
- if_else
|
|
||||||
- end_kw:
|
|
||||||
rule: End
|
|
||||||
skip: true
|
|
||||||
IfClause:
|
|
||||||
children:
|
|
||||||
- if_kw:
|
|
||||||
rule: If
|
|
||||||
skip: true
|
|
||||||
- expression
|
|
||||||
- then_kw:
|
|
||||||
rule: Then
|
|
||||||
skip: true
|
|
||||||
- statements:
|
|
||||||
rule: Statement
|
|
||||||
vec: true
|
|
||||||
IfElseIf:
|
|
||||||
children:
|
|
||||||
- else_kw:
|
|
||||||
rule: Else
|
|
||||||
skip: true
|
|
||||||
- if_clause
|
|
||||||
IfElse:
|
|
||||||
children:
|
|
||||||
- else_kw:
|
|
||||||
rule: Else
|
|
||||||
skip: true
|
|
||||||
- statements:
|
|
||||||
rule: Statement
|
|
||||||
vec: true
|
|
||||||
WhileStatement:
|
|
||||||
children:
|
|
||||||
- while_kw:
|
|
||||||
rule: While
|
|
||||||
skip: true
|
|
||||||
- expression
|
|
||||||
- do_kw:
|
|
||||||
rule: Do
|
|
||||||
skip: true
|
|
||||||
- statements:
|
|
||||||
rule: Statement
|
|
||||||
vec: true
|
|
||||||
- end_kw:
|
|
||||||
rule: End
|
|
||||||
skip: true
|
|
||||||
ForStatement:
|
|
||||||
children:
|
|
||||||
- for_kw:
|
|
||||||
rule: For
|
|
||||||
skip: true
|
|
||||||
- identifier
|
|
||||||
- in_kw:
|
|
||||||
rule: In
|
|
||||||
skip: true
|
|
||||||
- expression
|
|
||||||
- do_kw:
|
|
||||||
rule: Do
|
|
||||||
skip: true
|
|
||||||
- statement:
|
|
||||||
rule: Statement
|
|
||||||
vec: true
|
|
||||||
- end_kw:
|
|
||||||
rule: End
|
|
||||||
vec: true
|
|
||||||
|
|
||||||
# Expressions
|
|
||||||
Expression:
|
|
||||||
children:
|
|
||||||
- ternary_expression
|
|
||||||
TernaryExpression:
|
|
||||||
children:
|
|
||||||
- or_expression
|
|
||||||
- ternary_alternatives:
|
|
||||||
optional: true
|
|
||||||
TernaryAlternatives:
|
|
||||||
children:
|
|
||||||
- ternary_true_alternative
|
|
||||||
- ternary_false_alternative
|
|
||||||
TernaryTrueAlternative:
|
|
||||||
children:
|
|
||||||
- expression
|
|
||||||
TernaryFalseAlternative:
|
|
||||||
children:
|
|
||||||
- expression
|
|
||||||
OrExpression:
|
|
||||||
children:
|
|
||||||
- left:
|
|
||||||
rule: AndExpression
|
|
||||||
- or_sym:
|
|
||||||
rule: Or
|
|
||||||
skip: true
|
|
||||||
- right:
|
|
||||||
rule: Expression
|
|
||||||
optional: true
|
|
||||||
AndExpression:
|
|
||||||
children:
|
|
||||||
- left:
|
|
||||||
rule: ComparisonExpression
|
|
||||||
- and_sym:
|
|
||||||
rule: And
|
|
||||||
skip: true
|
|
||||||
- right:
|
|
||||||
rule: Expression
|
|
||||||
optional: true
|
|
||||||
ComparisonExpression:
|
|
||||||
children:
|
|
||||||
- left:
|
|
||||||
rule: ShiftExpression
|
|
||||||
- operator:
|
|
||||||
rule: ComparisonOperator
|
|
||||||
optional: true
|
|
||||||
- right:
|
|
||||||
rule: Expression
|
|
||||||
optional: true
|
|
||||||
ComparisonOperator:
|
|
||||||
rules:
|
|
||||||
- Greater
|
|
||||||
- Less
|
|
||||||
- GreaterEqual
|
|
||||||
- LessEqual
|
|
||||||
- EqualTo
|
|
||||||
- NotEqualTo
|
|
||||||
ShiftExpression:
|
|
||||||
children:
|
|
||||||
- left:
|
|
||||||
rule: AdditiveExpression
|
|
||||||
- operator:
|
|
||||||
rule: ShiftOperator
|
|
||||||
optional: true
|
|
||||||
- right:
|
|
||||||
rule: Expression
|
|
||||||
ShiftOperator:
|
|
||||||
rules:
|
|
||||||
- LeftShift
|
|
||||||
- RightShift
|
|
||||||
AdditiveExpression:
|
|
||||||
children:
|
|
||||||
- left:
|
|
||||||
rule: MultiplicativeExpression
|
|
||||||
- operator:
|
|
||||||
rule: AdditiveOperator
|
|
||||||
optional: true
|
|
||||||
- right:
|
|
||||||
rule: Expression
|
|
||||||
optional: true
|
|
||||||
MultiplicativeExpression:
|
|
||||||
children:
|
|
||||||
- left:
|
|
||||||
rule: PrefixExpression
|
|
||||||
- operator:
|
|
||||||
rule: MultiplicativeOperator
|
|
||||||
optional: true
|
|
||||||
- right:
|
|
||||||
rule: Expression
|
|
||||||
MultiplicativeOperator:
|
|
||||||
type: leaf_enum
|
|
||||||
rules:
|
|
||||||
- Multiply
|
|
||||||
- Divide
|
|
||||||
- Modulo
|
|
||||||
PrefixExpression:
|
|
||||||
children:
|
|
||||||
- operators:
|
|
||||||
rule: PrefixOperator
|
|
||||||
vec: true
|
|
||||||
PrefixOperator:
|
|
||||||
type: leaf_enum
|
|
||||||
rules:
|
|
||||||
- Spread
|
|
||||||
- Not
|
|
||||||
- Negative
|
|
||||||
SuffixExpression:
|
|
||||||
children:
|
|
||||||
- left:
|
|
||||||
rule: PrimaryExpression
|
|
||||||
- operators:
|
|
||||||
rule: SuffixOperator
|
|
||||||
vec: true
|
|
||||||
SuffixOperator:
|
|
||||||
type: leaf_enum
|
|
||||||
rules:
|
|
||||||
- PlusPlus
|
|
||||||
- MinusMinus
|
|
||||||
- ObjectProperty:
|
|
||||||
child: true
|
|
||||||
- ObjectIndex:
|
|
||||||
child: true
|
|
||||||
- Call:
|
|
||||||
child: true
|
|
||||||
ObjectProperty:
|
|
||||||
children:
|
|
||||||
- identifier
|
|
||||||
ObjectIndex:
|
|
||||||
children:
|
|
||||||
- expression
|
|
||||||
PrimaryExpression:
|
|
||||||
rules:
|
|
||||||
- Literal
|
|
||||||
- FullyQualifiedName
|
|
||||||
- Closure
|
|
||||||
- ParenthesizedExpression
|
|
||||||
ParenthesizedExpression:
|
|
||||||
children:
|
|
||||||
- expression
|
|
||||||
|
|
||||||
# Calls
|
|
||||||
Call:
|
|
||||||
rules:
|
|
||||||
- ParenthesesCall
|
|
||||||
- NonParenthesesCall
|
|
||||||
ParenthesesCall:
|
|
||||||
children:
|
|
||||||
- turbo_fish:
|
|
||||||
optional: true
|
|
||||||
- expression_list:
|
|
||||||
optional: true
|
|
||||||
- closure:
|
|
||||||
optional: true
|
|
||||||
NonParenthesesCall:
|
|
||||||
children:
|
|
||||||
- turbo_fish:
|
|
||||||
optional: true
|
|
||||||
- expression_list:
|
|
||||||
optional: true
|
|
||||||
- closure:
|
|
||||||
optional: true
|
|
||||||
TurboFish:
|
|
||||||
children:
|
|
||||||
- generic_arguments
|
|
||||||
ExpressionList:
|
|
||||||
children:
|
|
||||||
- expressions:
|
|
||||||
rule: Expression
|
|
||||||
vec: true
|
|
||||||
|
|
||||||
# Closure
|
|
||||||
Closure:
|
|
||||||
children:
|
|
||||||
- closure_parameters:
|
|
||||||
build:
|
|
||||||
or_else_default: true
|
|
||||||
- statements:
|
|
||||||
rule: Statement
|
|
||||||
vec: true
|
|
||||||
ClosureParameters:
|
|
||||||
children:
|
|
||||||
- parameters:
|
|
||||||
rule: ClosureParameters
|
|
||||||
vec: true
|
|
||||||
ClosureParameter:
|
|
||||||
children:
|
|
||||||
- identifier
|
|
||||||
- type_use:
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
# Literals
|
|
||||||
Literal:
|
|
||||||
rules:
|
|
||||||
- NumberLiteral
|
|
||||||
- StringLiteral
|
|
||||||
- BooleanLiteral
|
|
||||||
NumberLiteral:
|
|
||||||
rules:
|
|
||||||
- DoubleLiteral
|
|
||||||
- LongLiteral
|
|
||||||
- IntLiteral
|
|
||||||
IntLiteral:
|
|
||||||
children:
|
|
||||||
- number_base
|
|
||||||
- literal:
|
|
||||||
build:
|
|
||||||
type: i32
|
|
||||||
from: parse_number_base
|
|
||||||
LongLiteral:
|
|
||||||
children:
|
|
||||||
- number_base
|
|
||||||
- literal:
|
|
||||||
build:
|
|
||||||
type: i64
|
|
||||||
from: parse_number_base
|
|
||||||
DoubleLiteral:
|
|
||||||
children:
|
|
||||||
- literal:
|
|
||||||
build:
|
|
||||||
type: f64
|
|
||||||
from: parse_whole_pair
|
|
||||||
NumberBase:
|
|
||||||
rules:
|
|
||||||
- BinaryBase
|
|
||||||
- HexadecimalBase
|
|
||||||
- DecimalBase
|
|
||||||
DecimalBase:
|
|
||||||
children:
|
|
||||||
- literal:
|
|
||||||
build:
|
|
||||||
type: string
|
|
||||||
from: whole_pair
|
|
||||||
BinaryBase:
|
|
||||||
children:
|
|
||||||
- binary_digits
|
|
||||||
BinaryDigits:
|
|
||||||
children:
|
|
||||||
- literal:
|
|
||||||
build:
|
|
||||||
type: string
|
|
||||||
from: whole_pair
|
|
||||||
HexadecimalBase:
|
|
||||||
children:
|
|
||||||
- hexadecimal_digits
|
|
||||||
HexadecimalDigits:
|
|
||||||
children:
|
|
||||||
- literal:
|
|
||||||
build:
|
|
||||||
type: string
|
|
||||||
from: whole_pair
|
|
||||||
StringLiteral:
|
|
||||||
rules:
|
|
||||||
- SingleQuoteString
|
|
||||||
- DoubleQuoteString
|
|
||||||
- BacktickString
|
|
||||||
SingleQuoteString:
|
|
||||||
children:
|
|
||||||
- string_inner:
|
|
||||||
optional: true
|
|
||||||
DoubleQuoteString:
|
|
||||||
children:
|
|
||||||
- inners:
|
|
||||||
rule: DStringInner
|
|
||||||
vec: true
|
|
||||||
- expressions:
|
|
||||||
rule: DStringExpression
|
|
||||||
vec: true
|
|
||||||
StringInner:
|
|
||||||
children:
|
|
||||||
- literal:
|
|
||||||
build:
|
|
||||||
type: string
|
|
||||||
from: whole_pair
|
|
||||||
DStringInner:
|
|
||||||
children:
|
|
||||||
- literal:
|
|
||||||
build:
|
|
||||||
type: string
|
|
||||||
from: whole_pair
|
|
||||||
DStringExpression:
|
|
||||||
children:
|
|
||||||
- expression
|
|
||||||
BacktickString:
|
|
||||||
children:
|
|
||||||
- inners:
|
|
||||||
rule: BacktickInner
|
|
||||||
vec: true
|
|
||||||
- expressions:
|
|
||||||
rule: DStringExpression
|
|
||||||
vec: true
|
|
||||||
BacktickInner:
|
|
||||||
children:
|
|
||||||
- literal:
|
|
||||||
build:
|
|
||||||
type: string
|
|
||||||
from: whole_pair
|
|
||||||
BooleanLiteral:
|
|
||||||
children:
|
|
||||||
- literal:
|
|
||||||
build:
|
|
||||||
type: boolean
|
|
||||||
from: parse_whole_pair
|
|
@ -30,8 +30,6 @@ Alias = { "alias" }
|
|||||||
True = { "true" }
|
True = { "true" }
|
||||||
False = { "false" }
|
False = { "false" }
|
||||||
Use = { "use" }
|
Use = { "use" }
|
||||||
Then = { "then" }
|
|
||||||
Do = { "do" }
|
|
||||||
End = { "end" }
|
End = { "end" }
|
||||||
Companion = { "comp" }
|
Companion = { "comp" }
|
||||||
|
|
||||||
@ -81,10 +79,6 @@ Keyword = {
|
|||||||
| True
|
| True
|
||||||
| False
|
| False
|
||||||
| Use
|
| Use
|
||||||
| Then
|
|
||||||
| Do
|
|
||||||
| End
|
|
||||||
| Companion
|
|
||||||
| Byte
|
| Byte
|
||||||
| Short
|
| Short
|
||||||
| Char
|
| Char
|
||||||
@ -464,7 +458,8 @@ PlatformFunction = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InterfaceFunction = {
|
InterfaceFunction = {
|
||||||
Fn
|
FunctionModifier?
|
||||||
|
~ Fn
|
||||||
~ GenericParameters?
|
~ GenericParameters?
|
||||||
~ Identifier
|
~ Identifier
|
||||||
~ Parameters
|
~ Parameters
|
||||||
@ -473,16 +468,18 @@ InterfaceFunction = {
|
|||||||
|
|
||||||
InterfaceDefaultFunction = {
|
InterfaceDefaultFunction = {
|
||||||
Def
|
Def
|
||||||
|
~ FunctionModifier?
|
||||||
~ Fn
|
~ Fn
|
||||||
~ GenericParameters?
|
~ GenericParameters?
|
||||||
~ Identifier
|
~ Identifier
|
||||||
~ Parameters
|
~ Parameters
|
||||||
~ ReturnType?
|
~ ReturnType
|
||||||
~ FunctionBody
|
~ FunctionBody
|
||||||
}
|
}
|
||||||
|
|
||||||
InterfaceOperatorFunction = {
|
InterfaceOperatorFunction = {
|
||||||
Op
|
FunctionModifier?
|
||||||
|
~ Op
|
||||||
~ GenericParameters?
|
~ GenericParameters?
|
||||||
~ Operator
|
~ Operator
|
||||||
~ Parameters
|
~ Parameters
|
||||||
@ -491,11 +488,12 @@ InterfaceOperatorFunction = {
|
|||||||
|
|
||||||
InterfaceDefaultOperatorFunction = {
|
InterfaceDefaultOperatorFunction = {
|
||||||
Def
|
Def
|
||||||
|
~ FunctionModifier?
|
||||||
~ Op
|
~ Op
|
||||||
~ GenericParameters?
|
~ GenericParameters?
|
||||||
~ Operator
|
~ Operator
|
||||||
~ Parameters
|
~ Parameters
|
||||||
~ ReturnType?
|
~ ReturnType
|
||||||
~ FunctionBody
|
~ FunctionBody
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,7 +502,7 @@ InterfaceDefaultOperatorFunction = {
|
|||||||
FunctionBody = {
|
FunctionBody = {
|
||||||
FunctionAliasBody
|
FunctionAliasBody
|
||||||
| FunctionEqualsBody
|
| FunctionEqualsBody
|
||||||
| FunctionBlockBody
|
| BlockStatement
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionEqualsBody = {
|
FunctionEqualsBody = {
|
||||||
@ -517,23 +515,30 @@ FunctionAliasBody = {
|
|||||||
~ Identifier
|
~ Identifier
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionBlockBody = {
|
|
||||||
Statement*
|
|
||||||
~ End
|
|
||||||
}
|
|
||||||
|
|
||||||
// Class constructs
|
// Class constructs
|
||||||
|
|
||||||
ClassConstructor = {
|
ClassConstructor = {
|
||||||
"("
|
"("
|
||||||
~ Member
|
~ DataMember
|
||||||
~ ( "," ~ Member )*
|
~ ( "," ~ DataMember )*
|
||||||
~ ")"
|
~ ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
Member = {
|
DataMember = {
|
||||||
Pub?
|
Property
|
||||||
~ Mut?
|
| Field
|
||||||
|
}
|
||||||
|
|
||||||
|
Property = {
|
||||||
|
Mut?
|
||||||
|
~ Identifier
|
||||||
|
~ ":"
|
||||||
|
~ TypeUse
|
||||||
|
}
|
||||||
|
|
||||||
|
Field = {
|
||||||
|
Mut?
|
||||||
|
~ Fld
|
||||||
~ Identifier
|
~ Identifier
|
||||||
~ ":"
|
~ ":"
|
||||||
~ TypeUse
|
~ TypeUse
|
||||||
@ -541,14 +546,29 @@ Member = {
|
|||||||
|
|
||||||
// Statements
|
// Statements
|
||||||
|
|
||||||
|
BlockStatement = {
|
||||||
|
"{"
|
||||||
|
~ Statement*
|
||||||
|
~ Expression?
|
||||||
|
~ "}"
|
||||||
|
}
|
||||||
|
|
||||||
Statement = {
|
Statement = {
|
||||||
VariableDeclaration
|
(
|
||||||
| AssignmentStatement
|
VariableDeclaration
|
||||||
| ExpressionStatement
|
| AssignmentStatement
|
||||||
| UseStatement
|
| CallStatement
|
||||||
| IfStatement
|
| ReturnStatement
|
||||||
| WhileStatement
|
| UseStatement
|
||||||
| ForStatement
|
)
|
||||||
|
~ Semicolon
|
||||||
|
| (
|
||||||
|
BlockStatement
|
||||||
|
| IfElseStatement
|
||||||
|
| IfStatement
|
||||||
|
| WhileStatement
|
||||||
|
| ForStatement
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableDeclaration = {
|
VariableDeclaration = {
|
||||||
@ -565,50 +585,63 @@ AssignmentStatement = {
|
|||||||
~ Expression
|
~ Expression
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionStatement = {
|
CallStatement = {
|
||||||
Expression
|
PrimaryExpression
|
||||||
|
~ ObjectAccess?
|
||||||
|
~ ParenthesesCall
|
||||||
|
~ (
|
||||||
|
ObjectAccess
|
||||||
|
| ParenthesesCall
|
||||||
|
| PlusPlus
|
||||||
|
| MinusMinus
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnStatement = {
|
||||||
|
Return
|
||||||
|
~ Expression?
|
||||||
}
|
}
|
||||||
|
|
||||||
IfStatement = {
|
IfStatement = {
|
||||||
IfClause
|
|
||||||
~ IfElseIf*
|
|
||||||
~ IfElse?
|
|
||||||
~ End
|
|
||||||
}
|
|
||||||
|
|
||||||
IfClause = {
|
|
||||||
If
|
If
|
||||||
|
~ "("
|
||||||
~ Expression
|
~ Expression
|
||||||
~ Then
|
~ ")"
|
||||||
~ Statement*
|
~ BlockStatement
|
||||||
}
|
}
|
||||||
|
|
||||||
IfElseIf = {
|
IfElseStatement = {
|
||||||
Else
|
IfStatement
|
||||||
~ IfClause
|
~ ElseIf*
|
||||||
|
~ ElseBlock?
|
||||||
}
|
}
|
||||||
|
|
||||||
IfElse = {
|
ElseIf = {
|
||||||
Else
|
Else
|
||||||
~ Statement*
|
~ IfStatement
|
||||||
|
}
|
||||||
|
|
||||||
|
ElseBlock = {
|
||||||
|
Else
|
||||||
|
~ BlockStatement
|
||||||
}
|
}
|
||||||
|
|
||||||
WhileStatement = {
|
WhileStatement = {
|
||||||
While
|
While
|
||||||
|
~ "("
|
||||||
~ Expression
|
~ Expression
|
||||||
~ Do
|
~ ")"
|
||||||
~ Statement*
|
~ BlockStatement
|
||||||
~ End
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ForStatement = {
|
ForStatement = {
|
||||||
For
|
For
|
||||||
|
~ "("
|
||||||
~ Identifier
|
~ Identifier
|
||||||
~ In
|
~ In
|
||||||
~ Expression
|
~ Expression
|
||||||
~ Do
|
~ ")"
|
||||||
~ Statement*
|
~ BlockStatement
|
||||||
~ End
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expressions
|
// Expressions
|
||||||
@ -619,22 +652,12 @@ Expression = {
|
|||||||
|
|
||||||
TernaryExpression = {
|
TernaryExpression = {
|
||||||
OrExpression
|
OrExpression
|
||||||
~ ( TernaryAlternatives )?
|
~ (
|
||||||
}
|
"?"
|
||||||
|
~ Expression
|
||||||
TernaryAlternatives = {
|
~ ":"
|
||||||
TernaryTrueAlternative
|
~ Expression
|
||||||
~ TernaryFalseAlternative
|
)?
|
||||||
}
|
|
||||||
|
|
||||||
TernaryTrueAlternative = {
|
|
||||||
"?"
|
|
||||||
~ Expression
|
|
||||||
}
|
|
||||||
|
|
||||||
TernaryFalseAlternative = {
|
|
||||||
":"
|
|
||||||
~ Expression
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OrExpression = {
|
OrExpression = {
|
||||||
@ -650,93 +673,52 @@ AndExpression = {
|
|||||||
ComparisonExpression = {
|
ComparisonExpression = {
|
||||||
ShiftExpression
|
ShiftExpression
|
||||||
~ (
|
~ (
|
||||||
ComparisonOperator
|
( Greater | Less | GreaterEqual | LessEqual | EqualTo | NotEqualTo )
|
||||||
~ Expression
|
~ Expression
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
|
|
||||||
ComparisonOperator = {
|
|
||||||
Greater
|
|
||||||
| Less
|
|
||||||
| GreaterEqual
|
|
||||||
| LessEqual
|
|
||||||
| EqualTo
|
|
||||||
| NotEqualTo
|
|
||||||
}
|
|
||||||
|
|
||||||
ShiftExpression = {
|
ShiftExpression = {
|
||||||
AdditiveExpression
|
AdditiveExpression
|
||||||
~ (
|
~ ( ( LeftShift | RightShift ) ~ Expression )?
|
||||||
ShiftOperator
|
|
||||||
~ Expression
|
|
||||||
)?
|
|
||||||
}
|
|
||||||
|
|
||||||
ShiftOperator = {
|
|
||||||
LeftShift
|
|
||||||
| RightShift
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AdditiveExpression = {
|
AdditiveExpression = {
|
||||||
MultiplicativeExpression
|
MultiplicativeExpression
|
||||||
~ (
|
~ (
|
||||||
AdditiveOperator
|
( Add | Subtract )
|
||||||
~ Expression
|
~ Expression
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
|
|
||||||
AdditiveOperator = {
|
|
||||||
Add
|
|
||||||
| Subtract
|
|
||||||
}
|
|
||||||
|
|
||||||
MultiplicativeExpression = {
|
MultiplicativeExpression = {
|
||||||
PrefixExpression
|
PrefixExpression
|
||||||
~ (
|
~ (
|
||||||
MultiplicativeOperator
|
( Multiply | Divide | Modulo )
|
||||||
~ Expression
|
~ Expression
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiplicativeOperator = {
|
|
||||||
Multiply
|
|
||||||
| Divide
|
|
||||||
| Modulo
|
|
||||||
}
|
|
||||||
|
|
||||||
PrefixExpression = {
|
PrefixExpression = {
|
||||||
PrefixOperator*
|
(
|
||||||
|
Spread
|
||||||
|
| BorrowMut
|
||||||
|
| Borrow
|
||||||
|
| Mut
|
||||||
|
| Not
|
||||||
|
| Negative
|
||||||
|
)*
|
||||||
~ SuffixExpression
|
~ SuffixExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
PrefixOperator = {
|
|
||||||
Spread
|
|
||||||
| Not
|
|
||||||
| Negative
|
|
||||||
}
|
|
||||||
|
|
||||||
SuffixExpression = {
|
SuffixExpression = {
|
||||||
PrimaryExpression
|
PrimaryExpression
|
||||||
~ SuffixOperator*
|
~ (
|
||||||
}
|
ObjectAccess
|
||||||
|
| ParenthesesCall
|
||||||
SuffixOperator = {
|
| PlusPlus
|
||||||
PlusPlus
|
| MinusMinus
|
||||||
| MinusMinus
|
)*
|
||||||
| ObjectProperty
|
|
||||||
| ObjectIndex
|
|
||||||
| Call
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectProperty = {
|
|
||||||
"."
|
|
||||||
~ Identifier
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectIndex = {
|
|
||||||
"["
|
|
||||||
~ Expression
|
|
||||||
~ "]"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimaryExpression = {
|
PrimaryExpression = {
|
||||||
@ -752,13 +734,23 @@ ParenthesizedExpression = {
|
|||||||
~ ")"
|
~ ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calls
|
ObjectAccess = {
|
||||||
|
( ObjectProperty | ObjectIndex )+
|
||||||
Call = {
|
|
||||||
ParenthesesCall
|
|
||||||
| NonParenthesesCall
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObjectProperty = {
|
||||||
|
"."
|
||||||
|
~ Identifier
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectIndex = {
|
||||||
|
"["
|
||||||
|
~ Expression
|
||||||
|
~ "]"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calls
|
||||||
|
|
||||||
ParenthesesCall = {
|
ParenthesesCall = {
|
||||||
TurboFish?
|
TurboFish?
|
||||||
~ "("
|
~ "("
|
||||||
@ -767,15 +759,6 @@ ParenthesesCall = {
|
|||||||
~ Closure?
|
~ Closure?
|
||||||
}
|
}
|
||||||
|
|
||||||
NonParenthesesCall = {
|
|
||||||
TurboFish?
|
|
||||||
~ (
|
|
||||||
Closure
|
|
||||||
| ExpressionList
|
|
||||||
| ExpressionList ~ Closure
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
TurboFish = {
|
TurboFish = {
|
||||||
"::"
|
"::"
|
||||||
~ GenericArguments
|
~ GenericArguments
|
||||||
@ -789,9 +772,13 @@ ExpressionList = {
|
|||||||
// Closure
|
// Closure
|
||||||
|
|
||||||
Closure = {
|
Closure = {
|
||||||
"{"
|
( Cons | Mut )?
|
||||||
|
~ Move?
|
||||||
|
~ ClosureCaptures?
|
||||||
|
~ "{"
|
||||||
~ ( ClosureParameters? ~ "->" )?
|
~ ( ClosureParameters? ~ "->" )?
|
||||||
~ Statement*
|
~ Statement*
|
||||||
|
~ Expression?
|
||||||
~ "}"
|
~ "}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,6 +792,19 @@ ClosureParameter = {
|
|||||||
~ ( ":" ~ TypeUse )?
|
~ ( ":" ~ TypeUse )?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClosureCaptures = {
|
||||||
|
"|"
|
||||||
|
~ ClosureCapture
|
||||||
|
~ ( "," ~ ClosureCapture )*
|
||||||
|
~ "|"
|
||||||
|
}
|
||||||
|
|
||||||
|
ClosureCapture = {
|
||||||
|
Borrow*
|
||||||
|
~ Mut?
|
||||||
|
~ Identifier
|
||||||
|
}
|
||||||
|
|
||||||
// Literals
|
// Literals
|
||||||
|
|
||||||
Literal = {
|
Literal = {
|
||||||
@ -823,7 +823,7 @@ IntLiteral = { NumberBase }
|
|||||||
|
|
||||||
LongLiteral = ${ NumberBase ~ "L" }
|
LongLiteral = ${ NumberBase ~ "L" }
|
||||||
|
|
||||||
DoubleLiteral = @{ DecimalBase ~ "." ~ DecimalBase}
|
DoubleLiteral = ${ DecimalBase ~ "." ~ Digit+ }
|
||||||
|
|
||||||
NumberBase = {
|
NumberBase = {
|
||||||
BinaryBase
|
BinaryBase
|
||||||
@ -831,17 +831,18 @@ NumberBase = {
|
|||||||
| DecimalBase
|
| DecimalBase
|
||||||
}
|
}
|
||||||
|
|
||||||
DecimalBase = @{ '0'..'9'+ }
|
DecimalBase = @{
|
||||||
|
"0"
|
||||||
|
| DecimalStartDigit ~ Digit*
|
||||||
|
}
|
||||||
|
|
||||||
BinaryBase = { "0b" ~ BinaryDigits }
|
BinaryBase = @{ "0b" ~ Digit+ }
|
||||||
|
|
||||||
BinaryDigits = @{ BinaryDigit+ }
|
DecimalStartDigit = { '1'..'9' }
|
||||||
|
|
||||||
BinaryDigit = { "0" | "1" }
|
Digit = @{ '0'..'9'+ }
|
||||||
|
|
||||||
HexadecimalBase = { "0x" ~ HexadecimalDigits }
|
HexadecimalBase = @{ "0x" ~ HexadecimalDigit+ }
|
||||||
|
|
||||||
HexadecimalDigits = @{ HexadecimalDigit+ }
|
|
||||||
|
|
||||||
HexadecimalDigit = { '0'..'9' | 'a'..'f' }
|
HexadecimalDigit = { '0'..'9' | 'a'..'f' }
|
||||||
|
|
||||||
@ -873,7 +874,7 @@ DStringInner = @{ DStringChar+ }
|
|||||||
DStringChar = {
|
DStringChar = {
|
||||||
!( "\"" | "\\" | "${" ) ~ ANY
|
!( "\"" | "\\" | "${" ) ~ ANY
|
||||||
| "\\" ~ ( "\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t" | "$" )
|
| "\\" ~ ( "\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t" | "$" )
|
||||||
| "\\" ~ "u" ~ ASCII_HEX_DIGIT{4}
|
| "\\" ~ ( "u" ~ ASCII_HEX_DIGIT{4} )
|
||||||
}
|
}
|
||||||
|
|
||||||
DStringExpression = {
|
DStringExpression = {
|
||||||
@ -892,9 +893,9 @@ BacktickString = {
|
|||||||
BacktickInner = @{ BacktickStringChar+ }
|
BacktickInner = @{ BacktickStringChar+ }
|
||||||
|
|
||||||
BacktickStringChar = {
|
BacktickStringChar = {
|
||||||
!( "`" | "\\" | "${" ) ~ ANY
|
!( "\\`" | "\\" | "${" ) ~ ANY
|
||||||
| "\\" ~ ( "`" | "\\" | "/" | "b" | "f" | "n" | "r" | "t" | "$" )
|
| "\\" ~ ( "`" | "\\" | "/" | "b" | "f" | "n" | "r" | "t" | "$" )
|
||||||
| "\\" ~ "u" ~ ASCII_HEX_DIGIT{4}
|
| "\\" ~ ( "u" ~ ASCII_HEX_DIGIT{4} )
|
||||||
}
|
}
|
||||||
|
|
||||||
BooleanLiteral = { True | False }
|
BooleanLiteral = { True | False }
|
||||||
|
Loading…
Reference in New Issue
Block a user