use of priv.bajdcc.LALR1.grammar.symbol.IManageSymbol in project jMiniLang by bajdcc.
the class Semantic method run.
/**
* 进行语义处理
*/
private void run() throws SyntaxException {
if (!arrErrors.isEmpty()) {
System.err.println(getTrackerError());
throw new SyntaxException(SyntaxError.COMPILE_ERROR, arrErrors.get(0).position, "出现语法错误");
}
/* 规则集合 */
ArrayList<RuleItem> items = npa.getRuleItems();
/* 符号表查询接口 */
IQuerySymbol query = getQuerySymbolService();
/* 符号表管理接口 */
IManageSymbol manage = getManageSymbolService();
/* 语义错误处理接口 */
ISemanticRecorder recorder = getSemanticRecorderService();
/* 复制单词流 */
ArrayList<Token> tokens = arrTokens.stream().map(Token::copy).collect(Collectors.toCollection(ArrayList::new));
/* 运行时自动机 */
SemanticMachine machine = new SemanticMachine(items, arrActions, tokens, query, manage, recorder, debug);
/* 遍历所有指令 */
arrInsts.forEach(machine::run);
object = machine.getObject();
if (object != null) {
Function entry = (Function) object;
manage.getManageScopeService().registerFunc(entry);
}
}
Aggregations