29 lines
804 B
Java
29 lines
804 B
Java
package frontend.ast.block;
|
|
|
|
import error.Errors;
|
|
import frontend.ast.Node;
|
|
import frontend.ast.SyntaxType;
|
|
import frontend.lexer.TokenStream;
|
|
import frontend.lexer.TokenType;
|
|
import frontend.ast.decl.Decl;
|
|
|
|
public class BlockItem extends Node {
|
|
public BlockItem(TokenStream ts) {
|
|
super(SyntaxType.BLOCK_ITEM, ts);
|
|
}
|
|
|
|
public void parse(Errors errors) {
|
|
if (getCurrToken().getType() == TokenType.CONSTTK
|
|
|| getCurrToken().getType() == TokenType.STATICTK
|
|
|| getCurrToken().getType() == TokenType.INTTK) {
|
|
Decl decl = new Decl(this.ts);
|
|
decl.parse(errors);
|
|
addChild(decl);
|
|
} else {
|
|
Stmt stmt = new Stmt(this.ts);
|
|
stmt.parse(errors);
|
|
addChild(stmt);
|
|
}
|
|
}
|
|
}
|