straightline/src/main/java/org/poormanscastle/studies/compilers/utils/grammartools/ast/symboltable/SymbolTable.java
/**
     * called by the symbol table creator visitor when a function is found in the AST.
     *
     * @param function
     */
called by the symbol table creator visitor when a function is found in the AST.
@param function
called by the symbol table creator visitor when a function is found in the AST . @param function
public void addFunctionDeclaration(Function function, List<Parameter> parameters) {
        List<String> parameterNames = new LinkedList<>();
        Map<Symbol, Binding> parameterBindings = new HashMap<>();
        for (Parameter parameter : parameters) {
            parameterNames.add(parameter.getId());
            parameterBindings.put(Symbol.getSymbol(parameter.getId()), new Binding(parameter.getType().name()));
        }
        functionTable.put(function.getId(), new FunctionDeclaration(function.getId(),
                function.getValueType().name(), parameterNames, parameterBindings));
    }
public void addFunctionDeclaration ( Function function , List < Parameter > parameters ) { List < String > parameterNames = new LinkedList < > ( ) ; Map < Symbol , Binding > parameterBindings = new HashMap < > ( ) ; for ( Parameter parameter : parameters ) { parameterNames . add ( parameter . getId ( ) ) ; parameterBindings . put ( Symbol . getSymbol ( parameter . getId ( ) ) , new Binding ( parameter . getType ( ) . name ( ) ) ) ; } functionTable . put ( function . getId ( ) , new FunctionDeclaration ( function . getId ( ) , function . getValueType ( ) . name ( ) , parameterNames , parameterBindings ) ) ; }
called by the symbol table creator visitor when a function is found in the AST.
called by the symbol table creator visitor when a function is found in the AST .