@@ -0,0 +1,3140 @@
+package ruke.vrj;%0A%0Aimport java.util.ArrayList;%0A%0A/**%0A * MIT License%0A *%0A * Copyright (c) 2017 Franco Montenegro%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy%0A * of this software and associated documentation files (the %22Software%22), to deal%0A * in the Software without restriction, including without limitation the rights%0A * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A * copies of the Software, and to permit persons to whom the Software is%0A * furnished to do so, subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in all%0A * copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE%0A * SOFTWARE.%0A */%0Apublic class TypeChecker %7B%0A%0A  public static boolean isValidNumber(final Symbol expression) %7B%0A    return expression.type.equals(%22integer%22) %7C%7C expression.type.equals(%22real%22);%0A  %7D%0A%0A  public static boolean isValidFunctionCall(final Symbol function, final ArrayList%3CSymbol%3E args) %7B%0A    if (function.params.size() != args.size()) %7B%0A      return false;%0A    %7D%0A%0A    for (int i = 0, max = function.params.size(); i %3C max; i++) %7B%0A      if (args.get(i).flags.contains(SymbolFlag.ARRAY)) %7B%0A        return false;%0A      %7D%0A%0A      if (!TypeChecker.compatible(function.params.get(i), args.get(i))) %7B%0A        return false;%0A      %7D%0A    %7D%0A%0A    return true;%0A  %7D%0A%0A  public static boolean isValidArrayIndex(final Symbol index) %7B%0A    if (!%22integer%22.equals(index.type)) %7B%0A      return false;%0A    %7D%0A%0A    if (index.flags.contains(SymbolFlag.VARIABLE) && index.flags.contains(SymbolFlag.ARRAY)) %7B%0A      return false;%0A    %7D%0A%0A    return true;%0A  %7D%0A%0A  public static boolean isStruct(final Symbol struct) %7B%0A    return struct.flags.contains(SymbolFlag.STRUCT);%0A  %7D%0A%0A  public static boolean isLibrary(final Symbol library) %7B%0A    return library.flags.contains(SymbolFlag.LIBRARY);%0A  %7D%0A%0A  public static boolean isValidInitializer(final Symbol initializer) %7B%0A    if (!initializer.flags.contains(SymbolFlag.FUNCTION)) %7B%0A      return false;%0A    %7D%0A%0A    if (!initializer.params.isEmpty()) %7B%0A      return false;%0A    %7D%0A%0A    if (initializer.parent != null) %7B%0A      final boolean parentIsStruct = TypeChecker.isStruct(initializer.parent);%0A      final boolean initializerNotStatic = !initializer.flags.contains(SymbolFlag.STATIC);%0A%0A      if (parentIsStruct && initializerNotStatic) %7B%0A        return false;%0A      %7D%0A    %7D%0A%0A    return true;%0A  %7D%0A%0A  public static boolean compatible(final Symbol a, final Symbol b) %7B%0A    final Symbol aType = a.getTypes().get(0);%0A%0A    for (final Symbol bType : b.getTypes()) %7B%0A      if (aType.equals(bType)) %7B%0A        return true;%0A      %7D%0A    %7D%0A%0A    return false;%0A  %7D%0A%0A%7D%0A

Add TypeChecker class