mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-14 16:45:07 +01:00
parse hello world
This commit is contained in:
parent
727cfc692c
commit
f229dd7fdc
7 changed files with 239 additions and 29 deletions
|
|
@ -5,9 +5,9 @@ type Result = std::io::Result<()>;
|
|||
use crate::{
|
||||
ast::{
|
||||
ArithOpKind, Atom, BinaryOp, ComparisonKind, Decl, DeclAttr, DeclSpec, Declarator,
|
||||
DirectDeclarator, Expr, ExprBinary, ExprUnary, ExternalDecl, FunctionDef,
|
||||
FunctionParamDecl, InitDecl, IntTyKind, IntTySignedness, NormalDecl, Stmt, TypeSpecifier,
|
||||
UnaryOp,
|
||||
DirectDeclarator, Expr, ExprBinary, ExprPostfix, ExprUnary, ExternalDecl, FunctionDef,
|
||||
FunctionParamDecl, InitDecl, IntTyKind, IntTySignedness, NormalDecl, PostfixOp, Stmt,
|
||||
TypeSpecifier, UnaryOp,
|
||||
},
|
||||
Span, Spanned,
|
||||
};
|
||||
|
|
@ -335,6 +335,36 @@ impl<W: Write> PrettyPrinter<W> {
|
|||
Ok(())
|
||||
}
|
||||
Expr::Binary(binary) => self.binary(binary),
|
||||
Expr::Postfix(ExprPostfix { lhs, op }) => {
|
||||
self.expr(&lhs.0)?;
|
||||
match op {
|
||||
PostfixOp::Call(args) => {
|
||||
self.string("(")?;
|
||||
let mut first = true;
|
||||
for (expr, _) in args {
|
||||
if !first {
|
||||
self.string(", ")?;
|
||||
}
|
||||
first = false;
|
||||
self.expr(expr)?;
|
||||
}
|
||||
self.string(")")?;
|
||||
Ok(())
|
||||
}
|
||||
PostfixOp::Member((ident, _)) => {
|
||||
self.string(".")?;
|
||||
self.string(ident)?;
|
||||
Ok(())
|
||||
}
|
||||
PostfixOp::ArrowMember((ident, _)) => {
|
||||
self.string("->")?;
|
||||
self.string(ident)?;
|
||||
Ok(())
|
||||
}
|
||||
PostfixOp::Increment => self.string("++"),
|
||||
PostfixOp::Decrement => self.string("--"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue