Skip to content

Commit aa76852

Browse files
committed
feat: add typescript generator
1 parent 38268db commit aa76852

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ast/ast.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (a *AstGenerator) readTypeDeclaration() TypeDeclaration {
8383

8484
next, _ = a.nextToken(true)
8585

86-
if next.Type != token.IntType {
86+
if next.Type == token.IntType {
8787
d.Kind = Int
8888
} else {
8989
d.Kind = String
@@ -134,6 +134,8 @@ func (a *AstGenerator) readConstDeclaration() ConstDeclaration {
134134
if a.currentToken.Type == token.RightParentheses {
135135
break
136136
}
137+
138+
a.backToken()
137139
}
138140

139141
a.matchNextLine()
@@ -188,3 +190,7 @@ func (a *AstGenerator) Gen() File {
188190

189191
return file
190192
}
193+
194+
func NewAstGenerator(tokens []token.Token) AstGenerator {
195+
return AstGenerator{Tokens: tokens, index: -1}
196+
}

0 commit comments

Comments
 (0)