Seem to have fixed newlines and no-parentheses calls.

This commit is contained in:
Jesse Brault 2025-11-03 12:16:28 -06:00
parent da05bb101b
commit 1d11a45c68
3 changed files with 71 additions and 36 deletions

View File

@ -1,9 +1,10 @@
use crate::ast::node::{ use crate::ast::node::{
AssignmentStatement, BacktickString, Call, CompilationUnit, ConcreteUseStatement, AnySpaceSuffixOperator, AssignmentStatement, BacktickString, BoundSuffixOperator, Call,
ConcreteUseStatementSuffix, DString, Expression, ExpressionList, ExpressionStatement, Function, CompilationUnit, ConcreteUseStatement, ConcreteUseStatementSuffix, DString, Expression,
FunctionAliasBody, FunctionBlockBody, FunctionBody, FunctionEqualsBody, GenericParameters, ExpressionList, ExpressionStatement, Function, FunctionAliasBody, FunctionBlockBody,
Identifier, IdentifierExpression, IdentifierOrFqn, LValue, LValueSuffix, Literal, FunctionBody, FunctionEqualsBody, GenericParameters, Identifier, IdentifierExpression,
ModuleLevelDeclaration, ObjectIndex, Parameter, Parameters, PlatformFunction, PrimitiveType, IdentifierOrFqn, LValue, LValueSuffix, Literal, ModuleLevelDeclaration,
NoNewlineSuffixOperator, ObjectIndex, Parameter, Parameters, PlatformFunction, PrimitiveType,
ReturnType, StarUseStatement, Statement, SuffixExpression, SuffixOperator, TypeUse, TypedArray, ReturnType, StarUseStatement, Statement, SuffixExpression, SuffixOperator, TypeUse, TypedArray,
UseStatement, UseStatementIdentifier, UseStatementPrefix, VariableDeclaration, UseStatement, UseStatementIdentifier, UseStatementPrefix, VariableDeclaration,
}; };
@ -676,20 +677,30 @@ fn na_p2_suffix_operator(
diagnostics: &mut Vec<DmDiagnostic>, diagnostics: &mut Vec<DmDiagnostic>,
) { ) {
match suffix_operator { match suffix_operator {
SuffixOperator::PlusPlus => { SuffixOperator::BoundSuffixOperator(bound_suffix) => {
// no-op match bound_suffix {
BoundSuffixOperator::PlusPlus => {
// no-op
}
BoundSuffixOperator::MinusMinus => {
// no-op
}
}
} }
SuffixOperator::MinusMinus => { SuffixOperator::NoNewlineSuffixOperator(no_newline_suffix) => match no_newline_suffix {
// no-op NoNewlineSuffixOperator::ObjectIndex(object_index) => {
} na_p2_object_index(object_index, symbol_table, diagnostics);
SuffixOperator::ObjectProperty(_) => { }
// no-op; props checked during type checking NoNewlineSuffixOperator::Call(call) => {
} na_p2_call(call, symbol_table, diagnostics);
SuffixOperator::ObjectIndex(object_index) => { }
na_p2_object_index(object_index, symbol_table, diagnostics); },
} SuffixOperator::AnySpaceSuffixOperator(any_space_suffix) => {
SuffixOperator::Call(call) => { match any_space_suffix {
na_p2_call(call, symbol_table, diagnostics); AnySpaceSuffixOperator::ObjectProperty(_) => {
// no-op; this is checked during type checking
}
}
} }
} }
} }

View File

@ -1160,13 +1160,23 @@ SuffixExpression:
SuffixOperator: SuffixOperator:
tree_enum: tree_enum:
rules: rules:
- PlusPlus: - BoundSuffixOperator
child: false - NoNewlineSuffixOperator
- MinusMinus: - AnySpaceSuffixOperator
child: false BoundSuffixOperator:
- ObjectProperty leaf_enum:
rules:
- PlusPlus
- MinusMinus
NoNewlineSuffixOperator:
tree_enum:
rules:
- ObjectIndex - ObjectIndex
- Call - Call
AnySpaceSuffixOperator:
tree_enum:
rules:
- ObjectProperty
ObjectProperty: ObjectProperty:
struct: struct:
children: children:

View File

@ -260,7 +260,7 @@ FunctionTypeUse = {
// Generic Arguments // Generic Arguments
GenericArguments = { GenericArguments = !{
"<" "<"
~ TypeUseList ~ TypeUseList
~ ">" ~ ">"
@ -735,7 +735,8 @@ MultiplicativeOperator = {
| Modulo | Modulo
} }
PrefixExpression = { // Compound-atomic because all prefix operators are bound immediately (i.e., no spaces).
PrefixExpression = ${
PrefixOperator* PrefixOperator*
~ SuffixExpression ~ SuffixExpression
} }
@ -746,19 +747,31 @@ PrefixOperator = {
| Negative | Negative
} }
SuffixExpression = { SuffixExpression = ${
PrimaryExpression PrimaryExpression
~ SuffixOperator* ~ SuffixOperator*
} }
SuffixOperator = { SuffixOperator = ${
BoundSuffixOperator
| ( " " | "\t" )* ~ NoNewlineSuffixOperator ~ ( " " | "\t" )*
| WHITESPACE* ~ AnySpaceSuffixOperator ~ WHITESPACE*
}
BoundSuffixOperator = {
PlusPlus PlusPlus
| MinusMinus | MinusMinus
| ObjectProperty }
| ObjectIndex
NoNewlineSuffixOperator = {
ObjectIndex
| Call | Call
} }
AnySpaceSuffixOperator = {
ObjectProperty
}
ObjectProperty = { ObjectProperty = {
"." "."
~ Identifier ~ Identifier
@ -770,10 +783,10 @@ ObjectIndex = {
~ "]" ~ "]"
} }
PrimaryExpression = { PrimaryExpression = !{
Literal Literal
| IdentifierExpression
| FullyQualifiedName | FullyQualifiedName
| IdentifierExpression
| Closure | Closure
| ListExpression | ListExpression
| ParenthesizedExpression | ParenthesizedExpression
@ -810,28 +823,29 @@ ParenthesesCall = {
~ Closure? ~ Closure?
} }
NonParenthesesCall = { NonParenthesesCall = ${
TurboFish? TurboFish?
~ ( " " | "\t" )*
~ ( ~ (
Closure Closure
| ExpressionList | ExpressionList
| ExpressionList ~ Closure | ExpressionList ~ ( " " | "\t" )* ~ Closure
) )
} }
TurboFish = { TurboFish = ${
"::" "::"
~ GenericArguments ~ GenericArguments
} }
ExpressionList = { ExpressionList = !{
Expression Expression
~ ( "," ~ Expression )* ~ ( "," ~ Expression )*
} }
// Closure // Closure
Closure = { Closure = !{
"{" "{"
~ ( ClosureParameters? ~ "->" )? ~ ( ClosureParameters? ~ "->" )?
~ Statement* ~ Statement*