Files
MY_COMPILER/frontend/ast/func/FuncFParams.java
2025-12-12 20:14:00 +08:00

39 lines
1.0 KiB
Java
Executable File

package frontend.ast.func;
import error.Errors;
import frontend.ast.Node;
import frontend.ast.SyntaxType;
import frontend.lexer.TokenStream;
import frontend.lexer.TokenType;
import frontend.ast.token.TokenNode;
import java.util.ArrayList;
public class FuncFParams extends Node {
public FuncFParams(TokenStream ts) {
super(SyntaxType.FUNC_FORMAL_PARAM_S, ts);
}
public void parse(Errors errors) {
while (true) {
FuncFParam ffp = new FuncFParam(this.ts);
ffp.parse(errors);
addChild(ffp);
if (getCurrToken().getType() == TokenType.COMMA) {
TokenNode comma = new TokenNode(this.ts);
addChild(comma);
} else {
break;
}
}
}
public ArrayList<FuncFParam> getParamList() {
ArrayList<FuncFParam> paramList = new ArrayList<>();
for (int i = 0; i < getChildren().size(); i += 2) {
paramList.add((FuncFParam) getChild(i));
}
return paramList;
}
}