vfmt: EnumDecl

pull/3878/head
Alexander Medvednikov 2020-02-28 17:21:20 +01:00
parent ee9cfe22ec
commit 6855c746bb
4 changed files with 14 additions and 1 deletions

View File

@ -36,6 +36,8 @@ pub fn (node &FnDecl) str(t &table.Table) string {
}
f.write(')')
if node.typ != table.void_type {
// typ := t.type_to_str(node.typ)
// if typ.starts_with('
f.write(' ' + t.type_to_str(node.typ))
}
return f.str()

View File

@ -149,6 +149,13 @@ fn (f mut Fmt) stmt(node ast.Stmt) {
f.stmts(it.stmts)
f.writeln('}')
}
ast.EnumDecl {
f.writeln('enum $it.name {')
for val in it.vals {
f.writeln('\t' + val)
}
f.writeln('}\n')
}
ast.ExprStmt {
f.expr(it.expr)
if !f.single_line_if {
@ -156,7 +163,9 @@ fn (f mut Fmt) stmt(node ast.Stmt) {
}
}
ast.FnDecl {
f.write(it.str(f.table))
s := it.str(f.table)
// f.write(it.str(f.table))
f.write(s.replace(f.cur_mod + '.', '')) // `Expr` instead of `ast.Expr` in mod ast
f.writeln(' {')
f.stmts(it.stmts)
f.writeln('}\n')

View File

@ -10,6 +10,7 @@ void println(string s);
void matches();
void end();
int pi = 3;
int pi2 = pi;
typedef struct {
int age;

View File

@ -3,6 +3,7 @@
const (
pi = 3
pi2 = pi
//s = 'hi'
)