예제 #1
0
 public void AddSymbol(SymbolLight symbol)
 {
     f_symbols.Add(symbol);
 }
예제 #2
0
        public static void SemanticAnalise(L1Program program)
        {
            foreach (FunctionDefinition functionDef in program.Functions)
            {
                if (functionDef.IsEmbedded)
                    continue;

                SymbolTableLight table = new SymbolTableLight();
                foreach (FunctionParameter parameter in functionDef.Header.Parameters)
                {
                    SymbolLight symbol = new SymbolLight(parameter.Name, parameter.Type);
                    table.AddSymbol(symbol);
                }

                f_currentFunction = functionDef;

                CheckForLabelsDuplicates(f_currentFunction.Statements);

                ValidateStatementList(functionDef.Statements, table);

                if (functionDef.Header.ReturnType != null && !HasReturn(functionDef.Statements))
                {
                    CompilerServices.AddError(
                        functionDef.Location,
                        "Not all branches of execution return value"
                    );
                }
            }
        }