llvmir some opt
This commit is contained in:
49
frontend/ast/block/Block.java
Normal file
49
frontend/ast/block/Block.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package frontend.ast.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import error.Errors;
|
||||
import frontend.ast.Node;
|
||||
import frontend.ast.SyntaxType;
|
||||
import frontend.lexer.TokenStream;
|
||||
import frontend.lexer.TokenType;
|
||||
import frontend.ast.token.TokenNode;
|
||||
|
||||
public class Block extends Node {
|
||||
private boolean isFuncBlock;
|
||||
|
||||
public Block(TokenStream ts) {
|
||||
super(SyntaxType.BLOCK, ts);
|
||||
isFuncBlock = false;
|
||||
}
|
||||
|
||||
public void parse(Errors errors) {
|
||||
TokenNode lbrace = new TokenNode(this.ts);
|
||||
addChild(lbrace);
|
||||
while (getCurrToken().getType() != TokenType.RBRACE) {
|
||||
BlockItem bit = new BlockItem(this.ts);
|
||||
bit.parse(errors);
|
||||
addChild(bit);
|
||||
}
|
||||
TokenNode rbrace = new TokenNode(this.ts);
|
||||
addChild(rbrace);
|
||||
}
|
||||
|
||||
public ArrayList<BlockItem> getBlockItems() {
|
||||
ArrayList<BlockItem> blockItems = new ArrayList<>();
|
||||
for (int i = 0; i < getChildren().size(); i++) {
|
||||
if (getChild(i) instanceof BlockItem) {
|
||||
blockItems.add((BlockItem) getChild(i));
|
||||
}
|
||||
}
|
||||
return blockItems;
|
||||
}
|
||||
|
||||
public boolean isFuncBlock() {
|
||||
return isFuncBlock;
|
||||
}
|
||||
|
||||
public void setIsFuncBlock(boolean isFuncBlock) {
|
||||
this.isFuncBlock = isFuncBlock;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user