eugeniucarvalho 6 years ago
commit
37ca9d7fac
100 changed files with 1111 additions and 0 deletions
  1. BIN
      antlr-4.7-complete.jar
  2. 73 0
      build.xml
  3. 4 0
      build/built-jar.properties
  4. 0 0
      build/classes/.netbeans_automatic_build
  5. 0 0
      build/classes/.netbeans_update_resources
  6. BIN
      build/classes/API/AllocatorInterface.class
  7. BIN
      build/classes/API/Api.class
  8. BIN
      build/classes/API/Base.class
  9. BIN
      build/classes/API/Constantes.class
  10. BIN
      build/classes/API/Functions.class
  11. BIN
      build/classes/API/Gen.class
  12. BIN
      build/classes/API/Imports.class
  13. BIN
      build/classes/API/Instruction.class
  14. BIN
      build/classes/API/Interfaces.class
  15. BIN
      build/classes/API/RegistroBase.class
  16. BIN
      build/classes/API/Tipos.class
  17. BIN
      build/classes/API/Utils.class
  18. BIN
      build/classes/API/Variaveis.class
  19. BIN
      build/classes/IntermediaryCode/Allocation.class
  20. BIN
      build/classes/IntermediaryCode/BaseTacGen$1.class
  21. BIN
      build/classes/IntermediaryCode/BaseTacGen$2.class
  22. BIN
      build/classes/IntermediaryCode/BaseTacGen.class
  23. BIN
      build/classes/IntermediaryCode/Block.class
  24. BIN
      build/classes/IntermediaryCode/BlockOcorrences.class
  25. BIN
      build/classes/IntermediaryCode/Code.class
  26. BIN
      build/classes/IntermediaryCode/CodeOtimizadorProcessor.class
  27. BIN
      build/classes/IntermediaryCode/CodeProcessing.class
  28. BIN
      build/classes/IntermediaryCode/DataFrame.class
  29. BIN
      build/classes/IntermediaryCode/Filtros.class
  30. BIN
      build/classes/IntermediaryCode/Interval.class
  31. BIN
      build/classes/IntermediaryCode/Ocorrence.class
  32. BIN
      build/classes/IntermediaryCode/OcorrenceFinderProcessor.class
  33. BIN
      build/classes/IntermediaryCode/TacGenInterface.class
  34. BIN
      build/classes/IntermediaryCode/TestInstruction.class
  35. BIN
      build/classes/Output/Mif.class
  36. BIN
      build/classes/Output/MifFactory.class
  37. BIN
      build/classes/ast/AbstractSyntaxTree.class
  38. BIN
      build/classes/ast/Node.class
  39. BIN
      build/classes/ast/NodeInterface.class
  40. BIN
      build/classes/ast/Semantic.class
  41. BIN
      build/classes/common/ErrorReport.class
  42. BIN
      build/classes/common/Log.class
  43. BIN
      build/classes/compiler/IVANNOSYS.class
  44. BIN
      build/classes/compiler/IvannosysCompiler.class
  45. BIN
      build/classes/compiler/IvannosysTargetArch.class
  46. BIN
      build/classes/compiler/SyntaxError$SyntaxErrorItem.class
  47. BIN
      build/classes/compiler/SyntaxError.class
  48. BIN
      build/classes/exception/ExcecaoAtribuicaoInvalidaValor.class
  49. BIN
      build/classes/exception/ExcecaoAtribuicaoInvalidaVariavelNaoDeclarada.class
  50. BIN
      build/classes/exception/ExcecaoConstantNaoDeclarada.class
  51. BIN
      build/classes/exception/ExcecaoFuncaoIncompativelTipo.class
  52. BIN
      build/classes/exception/ExcecaoFuncaoNaoDeclarada.class
  53. BIN
      build/classes/exception/ExcecaoParametroNaoDeclarado.class
  54. BIN
      build/classes/exception/ExcecaoParametroTipoInvalido.class
  55. BIN
      build/classes/exception/ExcecaoVariavelIndefinida.class
  56. BIN
      build/classes/exception/ExcecaoVariavelInexperado.class
  57. BIN
      build/classes/exception/ExcecaoVariavelNaoDeclarada.class
  58. BIN
      build/classes/exception/ImportedException.class
  59. 50 0
      build/classes/grammar/GrammarAddress.g4
  60. 664 0
      build/classes/grammar/IvannosysGrammar.g4
  61. 160 0
      build/classes/grammar/IvannosysGrammar.tokens
  62. BIN
      build/classes/grammar/IvannosysGrammarBaseListener.class
  63. BIN
      build/classes/grammar/IvannosysGrammarBaseVisitor.class
  64. BIN
      build/classes/grammar/IvannosysGrammarLexer.class
  65. 160 0
      build/classes/grammar/IvannosysGrammarLexer.tokens
  66. BIN
      build/classes/grammar/IvannosysGrammarListener.class
  67. BIN
      build/classes/grammar/IvannosysGrammarParser$Anon_fieldContext.class
  68. BIN
      build/classes/grammar/IvannosysGrammarParser$ArgumentsContext.class
  69. BIN
      build/classes/grammar/IvannosysGrammarParser$ArrayTypeContext.class
  70. BIN
      build/classes/grammar/IvannosysGrammarParser$Assign_modifyContext.class
  71. BIN
      build/classes/grammar/IvannosysGrammarParser$BaseTypeContext.class
  72. BIN
      build/classes/grammar/IvannosysGrammarParser$Base_stmtContext.class
  73. BIN
      build/classes/grammar/IvannosysGrammarParser$Build_stmtContext.class
  74. BIN
      build/classes/grammar/IvannosysGrammarParser$BuildtagContext.class
  75. BIN
      build/classes/grammar/IvannosysGrammarParser$BuildtagsContext.class
  76. BIN
      build/classes/grammar/IvannosysGrammarParser$CallExprContext.class
  77. BIN
      build/classes/grammar/IvannosysGrammarParser$Catch_exceptionContext.class
  78. BIN
      build/classes/grammar/IvannosysGrammarParser$CompositeContext.class
  79. BIN
      build/classes/grammar/IvannosysGrammarParser$Dec_constContext.class
  80. BIN
      build/classes/grammar/IvannosysGrammarParser$Dec_const_partContext.class
  81. BIN
      build/classes/grammar/IvannosysGrammarParser$Dec_varContext.class
  82. BIN
      build/classes/grammar/IvannosysGrammarParser$Dec_var_partContext.class
  83. BIN
      build/classes/grammar/IvannosysGrammarParser$Dec_var_shortContext.class
  84. BIN
      build/classes/grammar/IvannosysGrammarParser$Def_assign_opContext.class
  85. BIN
      build/classes/grammar/IvannosysGrammarParser$Def_blockContext.class
  86. BIN
      build/classes/grammar/IvannosysGrammarParser$Def_caseContext.class
  87. BIN
      build/classes/grammar/IvannosysGrammarParser$Def_forContext.class
  88. BIN
      build/classes/grammar/IvannosysGrammarParser$Def_functionContext.class
  89. BIN
      build/classes/grammar/IvannosysGrammarParser$Def_ifContext.class
  90. BIN
      build/classes/grammar/IvannosysGrammarParser$Def_if_blockContext.class
  91. BIN
      build/classes/grammar/IvannosysGrammarParser$Def_interfaceContext.class
  92. BIN
      build/classes/grammar/IvannosysGrammarParser$Def_switchContext.class
  93. BIN
      build/classes/grammar/IvannosysGrammarParser$Def_typeContext.class
  94. BIN
      build/classes/grammar/IvannosysGrammarParser$DeleteContext.class
  95. BIN
      build/classes/grammar/IvannosysGrammarParser$Element_listContext.class
  96. BIN
      build/classes/grammar/IvannosysGrammarParser$ExpressionContext.class
  97. BIN
      build/classes/grammar/IvannosysGrammarParser$Expression_listContext.class
  98. BIN
      build/classes/grammar/IvannosysGrammarParser$Expression_list_typedContext.class
  99. BIN
      build/classes/grammar/IvannosysGrammarParser$Expression_seletorContext.class
  100. 0 0
      build/classes/grammar/IvannosysGrammarParser$FallthroughStmtContext.class

BIN
antlr-4.7-complete.jar


+ 73 - 0
build.xml

@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
+<project name="Ivannosys" default="default" basedir=".">
+    <description>Builds, tests, and runs the project Ivannosys.</description>
+    <import file="nbproject/build-impl.xml"/>
+    <!--
+
+    There exist several targets which are by default empty and which can be 
+    used for execution of your tasks. These targets are usually executed 
+    before and after some main targets. They are: 
+
+      -pre-init:                 called before initialization of project properties
+      -post-init:                called after initialization of project properties
+      -pre-compile:              called before javac compilation
+      -post-compile:             called after javac compilation
+      -pre-compile-single:       called before javac compilation of single file
+      -post-compile-single:      called after javac compilation of single file
+      -pre-compile-test:         called before javac compilation of JUnit tests
+      -post-compile-test:        called after javac compilation of JUnit tests
+      -pre-compile-test-single:  called before javac compilation of single JUnit test
+      -post-compile-test-single: called after javac compilation of single JUunit test
+      -pre-jar:                  called before JAR building
+      -post-jar:                 called after JAR building
+      -post-clean:               called after cleaning build products
+
+    (Targets beginning with '-' are not intended to be called on their own.)
+
+    Example of inserting an obfuscator after compilation could look like this:
+
+        <target name="-post-compile">
+            <obfuscate>
+                <fileset dir="${build.classes.dir}"/>
+            </obfuscate>
+        </target>
+
+    For list of available properties check the imported 
+    nbproject/build-impl.xml file. 
+
+
+    Another way to customize the build is by overriding existing main targets.
+    The targets of interest are: 
+
+      -init-macrodef-javac:     defines macro for javac compilation
+      -init-macrodef-junit:     defines macro for junit execution
+      -init-macrodef-debug:     defines macro for class debugging
+      -init-macrodef-java:      defines macro for class execution
+      -do-jar:                  JAR building
+      run:                      execution of project 
+      -javadoc-build:           Javadoc generation
+      test-report:              JUnit report generation
+
+    An example of overriding the target for project execution could look like this:
+
+        <target name="run" depends="Ivannosys-impl.jar">
+            <exec dir="bin" executable="launcher.exe">
+                <arg file="${dist.jar}"/>
+            </exec>
+        </target>
+
+    Notice that the overridden target depends on the jar target and not only on 
+    the compile target as the regular run target does. Again, for a list of available 
+    properties which you can use, check the target you are overriding in the
+    nbproject/build-impl.xml file. 
+
+    -->
+</project>

+ 4 - 0
build/built-jar.properties

@@ -0,0 +1,4 @@
+#Fri, 13 Oct 2017 16:44:36 -0300
+
+
+C\:\\Users\\EUGENIO\ CARVALHO\\Desktop\\projects\\Ivannosys=

+ 0 - 0
build/classes/.netbeans_automatic_build


+ 0 - 0
build/classes/.netbeans_update_resources


BIN
build/classes/API/AllocatorInterface.class


BIN
build/classes/API/Api.class


BIN
build/classes/API/Base.class


BIN
build/classes/API/Constantes.class


BIN
build/classes/API/Functions.class


BIN
build/classes/API/Gen.class


BIN
build/classes/API/Imports.class


BIN
build/classes/API/Instruction.class


BIN
build/classes/API/Interfaces.class


BIN
build/classes/API/RegistroBase.class


BIN
build/classes/API/Tipos.class


BIN
build/classes/API/Utils.class


BIN
build/classes/API/Variaveis.class


BIN
build/classes/IntermediaryCode/Allocation.class


BIN
build/classes/IntermediaryCode/BaseTacGen$1.class


BIN
build/classes/IntermediaryCode/BaseTacGen$2.class


BIN
build/classes/IntermediaryCode/BaseTacGen.class


BIN
build/classes/IntermediaryCode/Block.class


BIN
build/classes/IntermediaryCode/BlockOcorrences.class


BIN
build/classes/IntermediaryCode/Code.class


BIN
build/classes/IntermediaryCode/CodeOtimizadorProcessor.class


BIN
build/classes/IntermediaryCode/CodeProcessing.class


BIN
build/classes/IntermediaryCode/DataFrame.class


BIN
build/classes/IntermediaryCode/Filtros.class


BIN
build/classes/IntermediaryCode/Interval.class


BIN
build/classes/IntermediaryCode/Ocorrence.class


BIN
build/classes/IntermediaryCode/OcorrenceFinderProcessor.class


BIN
build/classes/IntermediaryCode/TacGenInterface.class


BIN
build/classes/IntermediaryCode/TestInstruction.class


BIN
build/classes/Output/Mif.class


BIN
build/classes/Output/MifFactory.class


BIN
build/classes/ast/AbstractSyntaxTree.class


BIN
build/classes/ast/Node.class


BIN
build/classes/ast/NodeInterface.class


BIN
build/classes/ast/Semantic.class


BIN
build/classes/common/ErrorReport.class


BIN
build/classes/common/Log.class


BIN
build/classes/compiler/IVANNOSYS.class


BIN
build/classes/compiler/IvannosysCompiler.class


BIN
build/classes/compiler/IvannosysTargetArch.class


BIN
build/classes/compiler/SyntaxError$SyntaxErrorItem.class


BIN
build/classes/compiler/SyntaxError.class


BIN
build/classes/exception/ExcecaoAtribuicaoInvalidaValor.class


BIN
build/classes/exception/ExcecaoAtribuicaoInvalidaVariavelNaoDeclarada.class


BIN
build/classes/exception/ExcecaoConstantNaoDeclarada.class


BIN
build/classes/exception/ExcecaoFuncaoIncompativelTipo.class


BIN
build/classes/exception/ExcecaoFuncaoNaoDeclarada.class


BIN
build/classes/exception/ExcecaoParametroNaoDeclarado.class


BIN
build/classes/exception/ExcecaoParametroTipoInvalido.class


BIN
build/classes/exception/ExcecaoVariavelIndefinida.class


BIN
build/classes/exception/ExcecaoVariavelInexperado.class


BIN
build/classes/exception/ExcecaoVariavelNaoDeclarada.class


BIN
build/classes/exception/ImportedException.class


+ 50 - 0
build/classes/grammar/GrammarAddress.g4

@@ -0,0 +1,50 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+ /**
+ TODO:
+ SwitchCASE incompleto
+ */
+
+grammar GrammarAddress; 
+
+assing
+    : expression EOF
+    ;
+
+expression 
+    : R_PAR_E expression R_PAR_D               #expr_par
+    | expression op=R_OP_MULT  expression      #expr_arit_md
+    | expression op=R_OP_ADD expression        #expr_arit_as
+    | T_INTEIRO                                #expr_integer
+    | variable                                 #expr_id
+    ;
+variable
+    : modificator? ID
+    ;
+modificator
+    : '.' //type
+    | '_' //variable
+    ;
+
+//DEFINICAO DE TOKENS ----------------------------------------------------------
+
+R_PAR_E                 : '(';
+R_PAR_D                 : ')';
+R_CHA_E                 : '[';
+R_CHA_D                 : ']';
+R_OP_ADD                : '+';
+R_OP_MULT               : '*';
+
+fragment    DIGITO      : [0-9] ;
+fragment    CHARACTER   : [a-zA-Z_] ;
+fragment    CHARACTER_UP: [A-Z];
+
+ID                      : CHARACTER ( CHARACTER | DIGITO )* ;
+T_INTEIRO               : DIGITO+ ;
+
+R_LINE_COMMENT          : '//' .*? '\r'? '\n' -> skip ;  // Match "#" stuff '\n'
+R_WS                    : (' '|'\t'|'\r'|'\n')+ -> skip ;
+R_COMMENT               : '/*' .*? '*/' -> skip ; // Match "/*" stuff "*/"

+ 664 - 0
build/classes/grammar/IvannosysGrammar.g4

@@ -0,0 +1,664 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+grammar IvannosysGrammar;
+
+@header {
+    import java.util.HashMap;
+    import java.util.Stack;
+}
+@members {
+     HashMap<String, String> decfunc = new HashMap<>();    
+     HashMap<String, String> decmet = new HashMap<>();    
+     HashMap<String, String> decvars = new HashMap<>();
+     HashMap<String, String> operandos;
+     HashMap<String, String> boolExpr;
+     String travaOperandos = null;
+}
+// Estrutura de um programa    
+init
+    : buildtags? R_PACKAGE ID R_PT_VIRG imports* programPart+ EOF 
+    ;
+
+// Estrutura de um import
+
+imports                
+    : R_IMPORTE R_PAR_E import_part (import_part )*  R_PAR_D
+    | R_IMPORTE import_part
+    ;
+import_part
+    : ID? T_STRING 
+    ;
+// Fim do importe -> Ini partes do programa
+
+programPart 
+    : dec_const
+    | dec_var
+    | def_type
+    | def_interface
+    | def_function
+    ;
+// Fim partes do programa -> Ini  Declaracao de tipo
+
+def_type
+    : R_TIPO ID  ( structType |  type )
+    ;
+     
+def_interface 
+    : R_TIPO ID R_INTERFACE R_COL_E func_spec+ R_COL_D 
+    ;
+
+func_spec 
+    :   ID arguments return_dec
+    ;
+
+// Fim Declaracao de tipo -> Ini  
+
+dec_var
+    : R_VAR R_PAR_E dec_var_part+ R_PAR_D
+    | R_VAR dec_var_part
+    ;
+
+dec_var_part
+    : id_list (type (R_EQ expression_list)? | R_EQ expression_list)
+    ;
+
+dec_var_short
+    : id_list R_SHORT_VAR expression_list // Declaracao reconhecendo o tipo do valor atribuido
+    ;
+
+id_list
+    : ID (R_VIRGULA ID)*
+    ;
+
+// Fim Declaracao de variavel -> Ini Operacao de atribuicao
+
+def_assign_op
+    : expression_list assign_modify? R_EQ expression_list
+    ;
+
+assign_modify
+    : R_OP_ADD | R_OP_SUB | R_OP_AST | R_OP_DIV | R_ASSIG_EXTEND | R_ASSIG_COPY
+    ;
+
+// Fim Operacao de atribuicao -> Ini  
+
+index
+    : R_CHA_E expression R_CHA_D
+    ;
+
+arguments
+    // expression_list -> chamadas de funcao
+    // expression_list_typed -> declaracao de funcao
+    : R_PAR_E (expression_list | expression_list_typed  (R_VIRGULA expression_list_typed)*)? R_PAR_D
+    ;
+
+expression_list_typed 
+    : id_list? type
+    ;
+
+// Ini - Constantes   
+dec_const
+    : R_CONSTANTE dec_const_part
+    | R_CONSTANTE R_PAR_E dec_const_part (dec_const_part)* R_PAR_D
+    ;
+dec_const_part
+    : ID type? R_EQ primitive_value
+    ;
+
+// Fim - Constantes   -> Ini  Funcoes
+def_function
+    : R_FUNCTION receive_type? (name=ID)? arguments return_dec? def_block
+    ;
+
+return_dec
+    : type (R_VIRGULA type)*
+    ;
+
+receive_type
+    : R_PAR_E ID R_OP_AST? type R_PAR_D   
+    ;
+
+// Fim - Funcoes   -> Ini  Switch
+
+def_switch
+    : R_SWITCH test R_COL_E def_case+ R_COL_D
+    ;
+
+
+def_case
+    : R_CASE expression_list R_COLON statement_list R_BREAK?
+    | R_DEFAULT R_COLON statement_list
+    ;
+
+statement_list
+    : statement+
+    ;
+// Fim - Switch   -> Ini  Valores
+
+primitive_value
+    : T_INTEIRO 
+    | (T_BOOL_TRUE | T_BOOL_FALSE) 
+    | T_CHAR
+    ;
+
+// Fim - Valores   -> Ini  Chamada de funcao
+
+//def_funcao_call locals[String functionName]
+//    :ID call_assinature {$functionName = $ID.text; } //funcao
+//    ;
+// Fim Chamada de funcao -> Ini If
+
+def_if locals[int ltipo]
+    : def_if_block (R_ELSE def_if_block)* (R_ELSE def_block)?
+    ;
+
+def_if_block
+    : R_IF test def_block
+    ;
+
+// Fim If -> Ini Lacos
+
+def_for
+    : R_FOR ( for_clause | for_each )? def_block // Like for
+    ;
+for_clause
+    : (initialization R_PT_VIRG)? test (R_PT_VIRG increment)?
+    ;
+
+initialization
+    :base_stmt
+    ;
+
+test 
+    : expression
+    | base_stmt (R_PT_VIRG expression)? 
+    ;
+
+increment
+    :base_stmt
+    ;
+
+for_each
+    : primary_expr R_VIRGULA primary_expr ( R_EQ | R_SHORT_VAR) R_RANGE range
+    ;
+
+range 
+    : expression
+    ;
+// Fim Lacos -> Ini Retorno de funcao
+
+return_stmt            
+    : R_RETURN expression_list?
+    ;
+
+//Regra  produz recurssao de parametros em uma funcao.
+
+// Fim Retorno de funcao -> Ini 
+
+expression_list                                                                 
+    : expression (R_VIRGULA expression)*
+    ;
+
+expression
+    //    | expression BINARY_OP expression
+    // | expression ('||' | '&&' | '==' | '!=' | '<' | '<=' | '>' | '>=' | '+' | '-' | '|' | '^' | '*' | '/' | '%' | '<<' | '>>' | '&' | '&^') expression
+    : R_PAR_E expression R_PAR_D
+    | unary_expr
+    | expression op=( 
+        R_OP_MOD| R_END |
+        R_OP_AST | R_OP_DIV| 
+        R_OP_ADD | R_OP_SUB ) expression
+    
+    | expression op=(R_SHIFT_LEFT | R_SHIFT_RIGHT) expression
+    | expression op=(R_BIT_AND | R_BIT_XOR | R_BIT_OR) expression
+      
+    | expression op=(R_COMP_EQ | R_COMP_DIFF |
+                     R_COMP_LT | R_COMP_LTE | 
+                     R_COMP_GT | R_COMP_GTE) expression
+    | expression op=(R_OR | R_AND) expression
+    ;
+
+unary_expr
+    : op=(R_REFERENCE|R_OP_SUB|R_EXCLAMATION|R_OP_AST) primary_expr
+    | primary_expr
+    ;
+
+primary_expr returns[String id]
+    : operand                               {$id = $operand.Value;}                                                                   //#expr_operando// acesso de um operando
+    | literal
+    | pe  = primary_expr index              {$id = $pe.id;}                                           //#expr_index// acesso de um index
+    | pee = primary_expr expression_seletor {$id = $pee.id;}                                         //#expr_selector// acesso de um atributo
+    | pea = primary_expr arguments                {$id = $pea.id;}                    //#expr_arguments// chamada de uma funcao ou metodo
+    ;
+
+
+operand  returns[String Value]
+    : ID                {$Value=$ID.text;}
+    | primitive_value   {$Value=$primitive_value.text;}
+    ;
+
+
+literal 
+    : func_literal
+    | composite
+    ;
+
+base_stmt 
+    :
+    | inc_dec 
+    | def_assign_op
+    | dec_var_short
+    | expression
+    ;
+
+func_literal
+    : R_FUNCTION arguments return_dec? def_block
+    ;
+
+composite
+    : literalType literal_value
+    ;
+literalType
+    : typename
+    | structType
+    | arrayType
+    ;
+
+structType
+    :  R_STRUCT R_COL_E fieldDecl+ R_COL_D 
+    ;
+
+fieldDecl
+    :(id_list type| anon_field) T_STRING?
+    ; 
+anon_field 
+    : R_OP_AST? typename
+    ;
+         
+arrayType
+    : R_CHA_E expression? R_CHA_D typename
+    ;
+
+inc_dec 
+    : expression op=( R_OP_PP| R_OP_SS)
+    ;
+
+literal_value
+    : R_COL_E ( (expression_list | element_list) R_VIRGULA )? R_COL_D
+    ;
+
+element_list
+    : keyed_element (R_VIRGULA keyed_element)*
+    ;
+
+keyed_element
+    : ID R_COLON expression
+    ;
+
+expression_seletor
+    : R_PONTO ID
+    ;
+
+// Definicao de um bloco de instrucoes
+def_block locals[HashMap<String, String> retornos = new HashMap<>();]
+    : R_COL_E statement+ R_COL_D
+    ;
+
+callExpr:
+    | primary_expr arguments
+    ;
+
+statement
+    : dec_var_short //R_PT_VIRG
+    | dec_var //R_PT_VIRG
+    | def_assign_op //R_PT_VIRG
+    | dec_const 
+    | inc_dec
+    | primary_expr
+    | label_stmt
+    //| def_read R_PT_VIRG
+    //| def_print R_PT_VIRG
+    | return_stmt //R_PT_VIRG     
+    //| def_funcao_call R_PT_VIRG
+    //| expression //R_PT_VIRG
+    | delete //R_PT_VIRG
+    | throwStmt
+    | fallthroughStmt // dentro de um case do switch avanca para o proximo caso
+    | def_if
+    | def_for
+    | def_switch
+    | flux_control
+    | try_catch
+    ;
+// Fim da definicao de um bloco de instrucoes
+fallthroughStmt
+    : R_FALLTHROUGH
+    ;
+label_stmt
+    : ID R_COLON statement
+    ;
+
+throwStmt
+    : R_THROW expression R_PT_VIRG
+    ;
+// Inicio do try cath
+try_catch
+    : R_TRY def_block 
+      catch_exception
+      finally_try ?
+    ;
+
+catch_exception
+    : R_CATCH R_PAR_E dec_var R_PAR_D def_block
+    ;
+
+finally_try
+    : R_FINALLY def_block
+    ;
+
+// Fim do try cath
+// Ids de controle de fluxo dentro do codigo
+flux_control locals[String control]
+    : R_GOTO ID            {$control = $R_GOTO.text;}
+    | R_CONTINUE           {$control = $R_CONTINUE.text;}
+    | R_BREAK              {$control = $R_BREAK.text;}
+    ;
+
+// Definicao de new para alocar enderecos de memoria
+newstmt 
+    : R_NEW R_PAR_E type (R_VIRGULA T_INTEIRO)? R_PAR_D
+    ;
+
+// Definicao de delete para liberar areas de memoria
+delete
+    : R_DELETE expression( R_VIRGULA expression)?
+    ;
+// Definicao dos tipos
+type returns[String ltype,String keytype,String valuetype]
+    : typename          {$ltype = $typename.ltype;}
+    | indexedType       {$ltype = $indexedType.ltype;}
+    | mapType           {$ltype = "map";}
+    ;
+
+indexedType returns[String ltype]
+    : typename          {$ltype = $typename.ltype;}
+    | index it=indexedType {$ltype = $it.ltype;}
+    ;
+
+typename returns[String ltype, Boolean pointer]
+    : ID                   {$ltype = $ID.text;}
+    | qualifiedId          {$ltype = $qualifiedId.text;}
+    | baseType             {$ltype = $baseType.ltype;}
+    | R_OP_AST tn=typename {$ltype = $tn.ltype;}
+    ;
+
+qualifiedId
+    : ID R_PONTO ID
+    ;
+
+baseType returns[String ltype]
+    : R_INT          {$ltype = $R_INT.text;}
+    | R_BOOL         {$ltype = $R_BOOL.text;} 
+    | R_CHAR         {$ltype = $R_CHAR.text;}
+    | R_STRING       {$ltype = $R_STRING.text;}
+    | R_ERROR        {$ltype = $R_ERROR.text;}
+    ;
+
+
+mapType returns[String keytype,String valuetype]
+    : R_MAP R_CHA_E k=type R_CHA_D v=type {
+                                            $keytype=$k.text;
+                                            $valuetype=$v.text;
+                                          }
+    ;
+buildtags 
+    : build_stmt+
+    ;
+build_stmt 
+    : R_AT buildtag ID (R_VIRGULA ID)*
+    ;
+buildtag
+    : BUILD_TARGET
+    ;
+
+//DEFINICAO DE TOKENS ----------------------------------------------------------
+BUILD_TARGET            :'target';
+R_BIT_AND               : '&';
+R_BIT_XOR               : '^';
+R_BIT_OR                : '|';
+R_SHIFT_LEFT            : '<<';
+R_SHIFT_RIGHT           : '>>';
+R_AT                    : '@';    
+R_DBL_SLASH             : '//';
+R_REFERENCE             : '&';
+R_INTERFACE             : 'interface';
+R_RANGE                 : 'range';
+R_STRUCT                : 'struct';
+R_OP_MOD                : '%';
+R_VAR                   : 'var';
+R_SHORT_VAR             : ':=';
+R_GOTO                  : 'goto';
+R_FALLTHROUGH           : 'fallthrough';
+R_MAP                   : 'map';
+R_ERROR                 : 'error';
+R_NEW                   : 'new';
+R_DELETE                : 'delete';
+R_TRY                   : 'try';
+R_CATCH                 : 'catch';
+R_FINALLY               : 'finally';
+R_DEFAULT               : 'default';
+//R_PRINT                 : 'print';
+//R_READ                  : 'read';
+R_IMPORTE               : 'import';
+//R_INIT_LIBRARY          : 'library';
+R_PACKAGE               : 'package';
+//R_THREAD                : 'thread';
+R_TRAP                  : 'trap';
+R_INT                   : 'int';
+R_CHAR                  : 'char';
+R_BOOL                  : 'bool';
+R_STRING                : 'string';
+//R_OBJECT                : 'object';
+//R_ARRAY                 : 'array';
+//R_EXCEPTION             : 'Exception';
+R_TIPO                  : 'type';
+R_FUNCTION              : 'func';
+//R_METHOD                : 'method';ARO
+R_CONSTANTE             : 'const';
+R_IN                    : 'in';
+R_SWITCH                : 'switch';
+R_CASE                  : 'case';
+R_FOR                   : 'for';
+R_RETURN                : 'return';
+R_CONTINUE              : 'continue';
+R_BREAK                 : 'break';
+R_THROW                 : 'throw';
+R_ELSE                  : 'else';
+R_IF                    : 'if';
+//R_ASYNC                 : 'async';
+//T_TRAP_SYNC             : 'SYNC';
+//T_TRAP_EXEC             : 'EXEC';
+//T_TRAP_SYNEXEC          : 'SYNEXEC';
+//T_TRAP_SEND             : 'SEND';
+//T_TRAP_RECEIVE          : 'RECEIVE';
+R_EXCLAMATION           : '!';
+R_PT_VIRG               : ';';
+R_PAR_E                 : '(';
+R_PAR_D                 : ')';
+R_COL_E                 : '{';
+R_COL_D                 : '}';
+R_CHA_E                 : '[';
+R_CHA_D                 : ']';
+R_EQ                    : '=';
+R_VIRGULA               : ',';
+R_PONTO                 : '.';
+R_COLON                 : ':';
+R_END                   : '&' ;
+
+R_AND                   : '&&' ;
+R_OR                    : '||';
+//Comparison
+R_COMP_EQ               : '==' ;
+R_COMP_DIFF             : '!=';
+R_COMP_LTE              : '<=' ;
+R_COMP_LT               : '<' ;
+R_COMP_GTE              : '>=' ;
+R_COMP_GT               : '>' ;
+//assing
+R_ASSIG_EXTEND          : '::';
+R_ASSIG_COPY            : ':';
+//arithmetic
+R_OP_DIV                : '/';
+R_OP_ADD                : '+';
+R_OP_SUB                : '-';
+R_OP_AST                : '*';
+R_OP_NEG                : '!';
+R_OP_SS                 : '--';
+R_OP_PP                 : '++';
+R_UND                   : '_';
+R_INTERROGATION         : '?';
+
+T_CHAR                  : '\'' .? '\'' ;
+T_STRING                : '"' .*? '"' ;
+T_BOOL_TRUE             : 'true';              
+T_BOOL_FALSE            : 'false' ;              
+T_NULL                  : 'nil'; 
+
+ID                      : LETTER ( LETTER | DIGITO )*;
+T_INTEIRO               : DIGITO+ ;
+
+fragment    LETTER      : ('a'..'z' | 'A'..'Z' | '_') ;
+fragment    DIGITO      : '0'..'9' ;
+
+//ID                      : CHARACTER ( CHARACTER | DIGITO )* ;
+//fragment    CHARACTER   : [_a-zA-Z]
+//                        ;
+
+R_LINE_COMMENT          : '//' .*? '\r'? '\n' -> skip ;  // Match "#" stuff '\n'
+R_WS                    : (' '|'\t'|'\r'|'\n')+ -> skip ;
+R_COMMENT               : '/*' .*? '*/' -> skip ; // Match "/*" stuff "*/"
+
+
+/*
+/*
+: ID literal_value                                                             #expr_literal
+ | R_REFERENCE expression                                                       #expr_pointer
+ | R_PAR_E expression R_PAR_D                                                   #expr_par
+ | expression (R_PT_VIRG expression)                                            #expr_chain_operacoes
+ | expression op=(R_OP_AST | R_OP_DIV) expression                               #expr_arit_md
+ | expression op=(R_OP_ADD | R_OP_SUB) expression                               #expr_arit_as
+ | expression op=(R_COMP_LT | R_COMP_GT | R_COMP_LTE | R_COMP_GTE) expression   #expr_comp_lt
+ | expression op=(R_COMP_DIFF | R_COMP_EQ) expression                           #expr_comp_eqd
+ | expression R_AND expression                                                  #expr_and
+ | expression R_OR expression                                                   #expr_or
+ | expression primitive_value                                                   #expr_primitive_value
+ | expression ( R_OP_PP| R_OP_SS)                                               #expr_inc_dec
+ | R_OP_SUB expression                                                          #expr_negative
+ | R_PAR_E type R_PAR_D expression                                              #expr_assertion
+ | R_EXCLAMATION expression                                                     #expr_neg_bool
+ | expression R_INTERROGATION expression R_COLON expression                     #expr_ternary
+ | def_function                                                                 #expr_def_function
+ | newstmt                                                                      #expr_allocation
+ | ID                                                                           #expr_id
+ ;
+
+inc_dec_stmt
+    : 
+    ;
+
+def_object 
+    : R_COL_E (object_prop ( R_VIRGULA object_prop )*)? R_COL_D
+    ;
+
+object_prop returns[String id]
+    : ID R_COLON expression {$id = $ID.text;}
+    ;
+
+
+address_access_dst
+    : ID indices? access_prop ?
+    ;
+
+access_prop
+    : (R_PONTO ID indices?) access_prop ? 
+    ;
+
+address_access_src
+    : ID indices? call_assinature? access_prop_src?
+    ;
+access_prop_src
+    : (R_PONTO ID indices? call_assinature?) access_prop_src?
+    ;
+address
+    : R_REFERENCE T_INTEIRO 
+    ;
+
+//| R_THREAD    R_OP_AST*   {$ltype = $R_THREAD.text;}
+    //| R_FUNCTION  R_OP_AST*   {$ltype = $R_FUNCTION.text;}
+    //| R_EXCEPTION R_OP_AST*   {$ltype = $R_EXCEPTION.text;}
+  
+    //| def_method
+    //| dec_trap
+    //| dec_thread
+    //| main
+
+call_from_return
+    : (call_assinature | indices | access_prop_src) call_from_return ?
+    ;
+ 
+boolena_operator
+    : R_COMP_EQ | R_COMP_DIFF | R_COMP_LTE | R_COMP_GTE | R_COMP_LT | R_COMP_GT
+    ;
+
+value
+    : expression                #expressionValue
+    //| def_array                 #arrayValue
+    | def_object                #objectValue
+    | address                   #pureAddressValue
+    ;
+
+def_array
+    : R_CHA_E ( value ( R_VIRGULA value )* )?  R_CHA_D
+    ;
+
+gen_list
+    : def_array
+    | address_access_src
+    | def_funcao_call
+    ;
+
+def_print
+    : R_PRINT R_PAR_E list_values R_PAR_D
+    ;
+
+def_read
+    : R_READ R_PAR_E list_vars R_PAR_D
+    ;
+list_vars
+    : address_access_src (R_VIRGULA address_access_src)*
+    ;
+
+
+param_list_dec         
+    : dec_var (R_PT_VIRG dec_var)*
+    ;
+main 
+    : R_FUNCTION R_MAIN R_PAR_E param_list_dec? R_PAR_D R_COLON return_list def_block
+    ;
+dec_thread 
+    : R_IN ID R_PAR_E param_list_dec? R_PAR_D def_block
+    ;
+
+dec_trap locals[String label]
+    : R_TRAP name=trap_id  R_PAR_E param_list_dec? R_PAR_D def_block {$label = $name.text;}
+    ;
+
+trap_id
+    : (T_TRAP_SYNC |T_TRAP_EXEC |T_TRAP_SYNEXEC |T_TRAP_SEND |T_TRAP_RECEIVE) 
+    ;
+
+*/

+ 160 - 0
build/classes/grammar/IvannosysGrammar.tokens

@@ -0,0 +1,160 @@
+R_ASSIG_COPY=68
+R_ERROR=19
+R_CATCH=23
+R_MAP=18
+R_RANGE=11
+R_SHIFT_RIGHT=6
+T_STRING=79
+R_COL_E=50
+R_OP_AST=72
+R_COL_D=51
+R_OP_ADD=70
+R_CASE=38
+R_NEW=20
+T_BOOL_TRUE=80
+R_OP_MOD=13
+R_TRAP=28
+R_OP_SUB=71
+R_THROW=43
+R_INTERROGATION=77
+R_WS=86
+ID=83
+R_CONSTANTE=35
+R_COMP_GTE=65
+BUILD_TARGET=1
+R_COMP_LTE=63
+R_OR=60
+R_CHAR=30
+R_TRY=22
+R_OP_DIV=69
+R_PT_VIRG=47
+R_SHORT_VAR=15
+R_GOTO=16
+R_DEFAULT=25
+T_CHAR=78
+R_ELSE=44
+T_NULL=82
+R_EQ=54
+R_OP_NEG=73
+R_COMP_GT=66
+R_REFERENCE=9
+R_BREAK=42
+R_TIPO=33
+R_INTERFACE=10
+R_PAR_E=48
+R_DELETE=21
+R_BIT_AND=2
+R_PAR_D=49
+R_STRUCT=12
+T_BOOL_FALSE=81
+R_COMP_LT=64
+R_FUNCTION=34
+R_ASSIG_EXTEND=67
+R_FOR=39
+R_SWITCH=37
+R_OP_SS=74
+R_IF=45
+R_BOOL=31
+R_PONTO=56
+R_IN=36
+R_STRING=32
+R_COLON=57
+R_AT=7
+R_COMMENT=87
+R_UND=76
+R_IMPORTE=26
+T_INTEIRO=84
+R_SHIFT_LEFT=5
+R_PACKAGE=27
+R_LINE_COMMENT=85
+R_AND=59
+R_VAR=14
+R_INT=29
+R_BIT_XOR=3
+R_FALLTHROUGH=17
+R_CONTINUE=41
+R_EXCLAMATION=46
+R_COMP_DIFF=62
+R_CHA_E=52
+R_CHA_D=53
+R_BIT_OR=4
+R_OP_PP=75
+R_COMP_EQ=61
+R_END=58
+R_DBL_SLASH=8
+R_RETURN=40
+R_FINALLY=24
+R_VIRGULA=55
+'>='=65
+'/'=69
+'=='=61
+'trap'=28
+'string'=32
+'switch'=37
+':='=15
+'type'=33
+'>'=66
+'||'=60
+'&&'=59
+';'=47
+'return'=40
+'for'=39
+'+'=70
+'.'=56
+'//'=8
+'delete'=21
+'^'=3
+'import'=26
+'error'=19
+'>>'=6
+'++'=75
+'struct'=12
+'true'=80
+'catch'=23
+'else'=44
+'func'=34
+'break'=42
+'{'=50
+'package'=27
+'?'=77
+'try'=22
+'var'=14
+'int'=29
+'if'=45
+'('=48
+'-'=71
+','=55
+'default'=25
+'in'=36
+']'=53
+'finally'=24
+'|'=4
+'new'=20
+'const'=35
+'goto'=16
+'='=54
+'map'=18
+'@'=7
+'::'=67
+'throw'=43
+'_'=76
+'bool'=31
+')'=49
+'%'=13
+'target'=1
+'char'=30
+'case'=38
+'}'=51
+'range'=11
+'nil'=82
+'<<'=5
+'fallthrough'=17
+'<='=63
+'!='=62
+'false'=81
+'continue'=41
+'--'=74
+'<'=64
+'*'=72
+'['=52
+'interface'=10

BIN
build/classes/grammar/IvannosysGrammarBaseListener.class


BIN
build/classes/grammar/IvannosysGrammarBaseVisitor.class


BIN
build/classes/grammar/IvannosysGrammarLexer.class


+ 160 - 0
build/classes/grammar/IvannosysGrammarLexer.tokens

@@ -0,0 +1,160 @@
+R_ASSIG_COPY=68
+R_ERROR=19
+R_CATCH=23
+R_MAP=18
+R_RANGE=11
+R_SHIFT_RIGHT=6
+T_STRING=79
+R_COL_E=50
+R_OP_AST=72
+R_COL_D=51
+R_OP_ADD=70
+R_CASE=38
+R_NEW=20
+T_BOOL_TRUE=80
+R_OP_MOD=13
+R_TRAP=28
+R_OP_SUB=71
+R_THROW=43
+R_INTERROGATION=77
+R_WS=86
+ID=83
+R_CONSTANTE=35
+R_COMP_GTE=65
+BUILD_TARGET=1
+R_COMP_LTE=63
+R_OR=60
+R_CHAR=30
+R_TRY=22
+R_OP_DIV=69
+R_PT_VIRG=47
+R_SHORT_VAR=15
+R_GOTO=16
+R_DEFAULT=25
+T_CHAR=78
+R_ELSE=44
+T_NULL=82
+R_EQ=54
+R_OP_NEG=73
+R_COMP_GT=66
+R_REFERENCE=9
+R_BREAK=42
+R_TIPO=33
+R_INTERFACE=10
+R_PAR_E=48
+R_DELETE=21
+R_BIT_AND=2
+R_PAR_D=49
+R_STRUCT=12
+T_BOOL_FALSE=81
+R_COMP_LT=64
+R_FUNCTION=34
+R_ASSIG_EXTEND=67
+R_FOR=39
+R_SWITCH=37
+R_OP_SS=74
+R_IF=45
+R_BOOL=31
+R_PONTO=56
+R_IN=36
+R_STRING=32
+R_COLON=57
+R_AT=7
+R_COMMENT=87
+R_UND=76
+R_IMPORTE=26
+T_INTEIRO=84
+R_SHIFT_LEFT=5
+R_PACKAGE=27
+R_LINE_COMMENT=85
+R_AND=59
+R_VAR=14
+R_INT=29
+R_BIT_XOR=3
+R_FALLTHROUGH=17
+R_CONTINUE=41
+R_EXCLAMATION=46
+R_COMP_DIFF=62
+R_CHA_E=52
+R_CHA_D=53
+R_BIT_OR=4
+R_OP_PP=75
+R_COMP_EQ=61
+R_END=58
+R_DBL_SLASH=8
+R_RETURN=40
+R_FINALLY=24
+R_VIRGULA=55
+'>='=65
+'/'=69
+'=='=61
+'trap'=28
+'string'=32
+'switch'=37
+':='=15
+'type'=33
+'>'=66
+'||'=60
+'&&'=59
+';'=47
+'return'=40
+'for'=39
+'+'=70
+'.'=56
+'//'=8
+'delete'=21
+'^'=3
+'import'=26
+'error'=19
+'>>'=6
+'++'=75
+'struct'=12
+'true'=80
+'catch'=23
+'else'=44
+'func'=34
+'break'=42
+'{'=50
+'package'=27
+'?'=77
+'try'=22
+'var'=14
+'int'=29
+'if'=45
+'('=48
+'-'=71
+','=55
+'default'=25
+'in'=36
+']'=53
+'finally'=24
+'|'=4
+'new'=20
+'const'=35
+'goto'=16
+'='=54
+'map'=18
+'@'=7
+'::'=67
+'throw'=43
+'_'=76
+'bool'=31
+')'=49
+'%'=13
+'target'=1
+'char'=30
+'case'=38
+'}'=51
+'range'=11
+'nil'=82
+'<<'=5
+'fallthrough'=17
+'<='=63
+'!='=62
+'false'=81
+'continue'=41
+'--'=74
+'<'=64
+'*'=72
+'['=52
+'interface'=10

BIN
build/classes/grammar/IvannosysGrammarListener.class


BIN
build/classes/grammar/IvannosysGrammarParser$Anon_fieldContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$ArgumentsContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$ArrayTypeContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Assign_modifyContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$BaseTypeContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Base_stmtContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Build_stmtContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$BuildtagContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$BuildtagsContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$CallExprContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Catch_exceptionContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$CompositeContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Dec_constContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Dec_const_partContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Dec_varContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Dec_var_partContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Dec_var_shortContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Def_assign_opContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Def_blockContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Def_caseContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Def_forContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Def_functionContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Def_ifContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Def_if_blockContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Def_interfaceContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Def_switchContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Def_typeContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$DeleteContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Element_listContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$ExpressionContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Expression_listContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Expression_list_typedContext.class


BIN
build/classes/grammar/IvannosysGrammarParser$Expression_seletorContext.class


+ 0 - 0
build/classes/grammar/IvannosysGrammarParser$FallthroughStmtContext.class


Some files were not shown because too many files changed in this diff