Skip to content

Commit

Permalink
Merge pull request #1236 from veryl-lang/fix_type_modifier
Browse files Browse the repository at this point in the history
Fix syntax error at type with modifier in expression
  • Loading branch information
dalance authored Feb 8, 2025
2 parents 4b43566 + be0951b commit aae7a95
Show file tree
Hide file tree
Showing 13 changed files with 17,489 additions and 16,745 deletions.
2 changes: 1 addition & 1 deletion crates/analyzer/src/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ impl Evaluator {
Factor::InsideExpression(_) => Evaluated::Unknown,
Factor::OutsideExpression(_) => Evaluated::Unknown,
Factor::TypeExpression(_) => Evaluated::Unknown,
Factor::FactorType(_) => Evaluated::Unknown,
Factor::FactorTypeFactor(_) => Evaluated::Unknown,
}
}

Expand Down
14 changes: 12 additions & 2 deletions crates/analyzer/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,18 @@ impl TryFrom<&syntax_tree::Expression> for Type {
};

match value {
syntax_tree::Factor::FactorType(x) => {
let factor_type: Type = x.factor_type.as_ref().into();
syntax_tree::Factor::FactorTypeFactor(x) => {
let factor = &x.factor_type_factor;

let mut modifier = Vec::new();
for x in &factor.factor_type_factor_list {
match &*x.type_modifier {
syntax_tree::TypeModifier::Tri(_) => modifier.push(TypeModifier::Tri),
syntax_tree::TypeModifier::Signed(_) => modifier.push(TypeModifier::Signed),
}
}
let mut factor_type: Type = factor.factor_type.as_ref().into();
factor_type.modifier = modifier;
Ok(factor_type)
}
syntax_tree::Factor::IdentifierFactor(x) => {
Expand Down
3 changes: 2 additions & 1 deletion crates/emitter/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1900,6 +1900,7 @@ impl VerylWalker for Emitter {
if self.signed {
self.space(1);
self.str("signed");
self.signed = false;
}
if self.in_scalar_type {
self.align_finish(align_kind::TYPE);
Expand Down Expand Up @@ -1949,6 +1950,7 @@ impl VerylWalker for Emitter {
if self.signed {
self.space(1);
self.str("signed");
self.signed = false;
}
self.align_finish(align_kind::TYPE);
self.align_start(align_kind::WIDTH);
Expand All @@ -1962,7 +1964,6 @@ impl VerylWalker for Emitter {
}
ScalarTypeGroup::FactorType(x) => self.factor_type(&x.factor_type),
}
self.signed = false;
self.in_scalar_type = false;
self.align_finish(align_kind::WIDTH);
}
Expand Down
9 changes: 9 additions & 0 deletions crates/formatter/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,15 @@ impl VerylWalker for Formatter {
}
}

/// Semantic action for non-terminal 'FactorTypeFactor'
fn factor_type_factor(&mut self, arg: &FactorTypeFactor) {
for x in &arg.factor_type_factor_list {
self.type_modifier(&x.type_modifier);
self.space(1);
}
self.factor_type(&arg.factor_type);
}

/// Semantic action for non-terminal 'ArgumentList'
#[inline(never)]
fn argument_list(&mut self, arg: &ArgumentList) {
Expand Down
1,069 changes: 536 additions & 533 deletions crates/parser/src/generated/veryl-exp.par

Large diffs are not rendered by default.

Loading

0 comments on commit aae7a95

Please sign in to comment.