Browse Source

Versão inicial da gramática Portugol para JavaScript

Lucas de Souza 6 years ago
parent
commit
938651d40e

+ 35 - 0
.gitignore

@@ -0,0 +1,35 @@
+#compiled files
+/build
+
+# dependencies
+/node_modules
+
+# misc
+/.sass-cache
+/connect.lock
+/coverage
+/libpeerconnection.log
+npm-debug.log
+yarn-error.log
+testem.log
+/typings
+
+# System Files
+.DS_Store
+Thumbs.db
+
+# IDEs and editors
+/.idea
+.project
+.classpath
+.c9/
+*.launch
+.settings/
+*.sublime-workspace
+
+# IDE - VSCode
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json

+ 9 - 0
grammar/index.js

@@ -0,0 +1,9 @@
+import {ivprogLexer} from './ivprogLexer';
+import {ivprogParser} from './ivprogParser';
+import {ivprogVisitor} from './ivprogVisitor';
+import {ivprogListener} from './ivprogListener';
+
+exports.ivprogVisitor = ivprogVisitor;
+exports.ivprogParser = ivprogParser;
+exports.ivprogLexer = ivprogLexer;
+exports.ivprogListener = ivprogListener;

+ 182 - 0
grammar/ivprog.g4

@@ -0,0 +1,182 @@
+grammar ivprog;
+@parser::header
+{
+  import {ASA, NoGlobal} from '../js/asa';
+}
+
+@parser::members
+{
+  this.criarTrechoCodigoFonte = function(tokenAntlr)
+    {
+      if (tokenAntlr != null)
+      {
+        const linha = tokenAntlr.getLine();
+        const coluna = tokenAntlr.getCharPositionInLine();
+        const tamanhoTexto = tokenAntlr.getText().length();
+        
+        return {linha: linha, coluna: coluna, tamanhoTexto: tamanhoTexto};
+      }
+      
+      return null;
+  }
+}
+
+
+
+PR_PROGRAMA     : 'programa'    ;
+PR_REAL       : 'real'    ;
+PR_VAZIO        : 'vazio'   ;
+PR_LOGICO       : 'logico'    ;
+PR_CADEIA       : 'cadeia'    ;
+PR_INTEIRO        : 'inteiro'   ;
+PR_CARACTER     : 'caracter'    ;    
+PR_ESCOLHA        : 'escolha'   ;
+PR_CASO       : 'caso'    ;
+PR_CONTRARIO      : 'contrario' ;
+PR_CONST        : 'const'   ;
+PR_FUNCAO       : 'funcao'    ;
+PR_RETORNE        : 'retorne'   ;  
+PR_PARA       : 'para'    ;
+PR_PARE       : 'pare'    ;
+PR_FACA       : 'faca'    ;
+PR_ENQUANTO     : 'enquanto'    ;
+PR_SE       : 'se'    ;
+PR_SENAO        : 'senao'   ;
+
+
+GAMBIARRA   : '.' |'á'| 'à'| 'ã'|'â'|'é'|'ê'|'í'|'ó'|'ô'|'õ'|'ú'|'ü'|'ç'|'Ä'|'À'|'Ã'|'Â'|'É'|'Ê'|'Ë'|'Ó'|'Ô'|'Õ'|'Ú'|'Ü'|'Ç'|'#'|'$'|'"'|'§'|'?'|'¹'|'²'|'³'|'£'|'¢'|'¬'|'ª'|'º'|'~'|'\''|'`'|'\\'|'@';
+ 
+fragment PR_FALSO     : 'falso'   ;
+fragment PR_VERDADEIRO    : 'verdadeiro'    ;
+
+OPERADOR_NAO      : 'nao'   ;
+
+LOGICO        :   PR_VERDADEIRO | PR_FALSO  ;
+
+ID        : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*  ;
+
+ID_BIBLIOTECA     : ID '.' ID;
+
+INTEIRO         : '0'..'9'+ | ('0x'|'0X')(DIGIT_HEX)+ | ('0b'|'0B')('0'|'1')+;
+
+REAL          :   ('0'..'9')+ '.' ('0'..'9')+ ;
+    
+CADEIA        : '"' ( SEQ_ESC | ~('\\'|'"') )* '"'  ;
+
+CARACTER        :   '\'' ( SEQ_ESC | ~('\''|'\\') ) '\''  ;
+
+ESPACO        : ( ' ' | '\t' | '\r' | '\n') -> skip  ;
+
+
+fragment DIGIT_HEX    :   ('0'..'9'|'a'..'f'|'A'..'F')  ;
+
+fragment SEQ_ESC      :  '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')  |   ESC_UNICODE  |   ESC_OCTAL   ;
+
+fragment ESC_OCTAL    : '\\' ('0'..'3') ('0'..'7') ('0'..'7')  |   '\\' ('0'..'7') ('0'..'7')    |   '\\' ('0'..'7')    ;
+
+fragment ESC_UNICODE    : '\\' 'u' DIGIT_HEX DIGIT_HEX DIGIT_HEX DIGIT_HEX  ;
+
+COMENTARIO      :   
+
+  ('//' ~('\n'|'\r')* '\r'? '\n' |  
+  
+   '/*' ( options {greedy=false;} : . )* '*/') -> skip
+ ;
+
+
+parse returns [asa]:
+
+  prog = programa EOF
+  {
+    $asa = $prog.asa;
+  }
+;
+
+
+programa returns [asa] :
+
+  PR_PROGRAMA
+  '{'   
+    {
+      $asa = new ASA();
+    }
+
+    (declaracoesGlobais[$asa])*
+  '}'
+;
+
+declaracoesGlobais [asa]:
+  vList = listaDeclaracoes
+  {
+    if ($asa != null) {
+      this.globais = new NoGlobal();
+      $vList.lista.forEach( v => this.globais.addDeclaracao(v));
+      $asa.nos.push($vList.lista);
+    }
+  }
+;
+
+listaDeclaracoes returns [lista]
+@init{
+  $lista = [];
+}:
+  (tokenConst = PR_CONST)? informacaoTipoDado = declaracaoTipoDado
+
+  ( vDeclaracao = declaracao[$tokenConst, $informacaoTipoDado.informacaoTipoDado]
+    {
+      if($ctx.vDeclaracao) {
+        $lista.push($vDeclaracao.rDeclaracao);
+      }
+      $ctx.vDeclaracao = null;
+    }
+  )
+  ( ',' vDeclaracao = declaracao[$tokenConst, $informacaoTipoDado.informacaoTipoDado]
+    {
+      if($ctx.vDeclaracao) {
+        $lista.push($vDeclaracao.rDeclaracao);
+      }
+      $ctx.vDeclaracao = null;
+    }
+  )*
+;
+
+declaracao [tokenConst, informacaoTipoDado] returns[rDeclaracao]:  
+
+  (ID (tk1 = '[' (ind1 = expressao)? ']' (tk2 = '[' (ind2 = expressao)? ']')?)? ('=' inicializacao = expressao)?) 
+  {
+    const constante = ($tokenConst != null);
+    const tipoDado = ($informacaoTipoDado != null)? $informacaoTipoDado.tipoDado : null;
+    const nome = ($ID != null)? $ID.text : null;
+    
+    if (($tk1 == null) && ($tk2 == null))
+      $rDeclaracao = new NoDeclaracaoVariavel(nome, tipoDado, constante);
+    else
+    
+    if (($tk1 != null) && ($tk2 == null))
+      $rDeclaracao = new NoDeclaracaoVetor(nome, tipoDado, $ind1.text, constante);
+    
+    else
+    
+    if (($tk1 != null) && ($tk2 != null))
+      $rDeclaracao = new NoDeclaracaoMatriz(nome, tipoDado, $ind1.text, $ind2.text, constante);
+  
+    $rDeclaracao.setInicializacao(inicializacao);
+    $rDeclaracao.setTrechoCodigoFonteNome(criarTrechoCodigoFonte($ID));
+    $rDeclaracao.setTrechoCodigoFonteTipoDado(($informacaoTipoDado != null)? $informacaoTipoDado.getTrechoCodigoFonte(): null);
+  }
+;
+
+declaracaoTipoDado returns[informacaoTipoDado]:
+
+  (tokenTipoDado = PR_INTEIRO | tokenTipoDado = PR_REAL | tokenTipoDado = PR_CARACTER | tokenTipoDado = PR_CADEIA | tokenTipoDado = PR_LOGICO)
+  {
+    $informacaoTipoDado = new InformacaoTipoDado();
+    $informacaoTipoDado.setTipoDado($tokenTipoDado);
+    $informacaoTipoDado.setTrechoCodigoFonte(criarTrechoCodigoFonte($tokenTipoDado));
+  }
+;
+
+expressao:
+  INTEIRO
+  | CADEIA
+;

File diff suppressed because it is too large
+ 90 - 0
grammar/ivprog.interp


+ 62 - 0
grammar/ivprog.tokens

@@ -0,0 +1,62 @@
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+T__5=6
+PR_PROGRAMA=7
+PR_REAL=8
+PR_VAZIO=9
+PR_LOGICO=10
+PR_CADEIA=11
+PR_INTEIRO=12
+PR_CARACTER=13
+PR_ESCOLHA=14
+PR_CASO=15
+PR_CONTRARIO=16
+PR_CONST=17
+PR_FUNCAO=18
+PR_RETORNE=19
+PR_PARA=20
+PR_PARE=21
+PR_FACA=22
+PR_ENQUANTO=23
+PR_SE=24
+PR_SENAO=25
+GAMBIARRA=26
+OPERADOR_NAO=27
+LOGICO=28
+ID=29
+ID_BIBLIOTECA=30
+INTEIRO=31
+REAL=32
+CADEIA=33
+CARACTER=34
+ESPACO=35
+COMENTARIO=36
+'{'=1
+'}'=2
+','=3
+'['=4
+']'=5
+'='=6
+'programa'=7
+'real'=8
+'vazio'=9
+'logico'=10
+'cadeia'=11
+'inteiro'=12
+'caracter'=13
+'escolha'=14
+'caso'=15
+'contrario'=16
+'const'=17
+'funcao'=18
+'retorne'=19
+'para'=20
+'pare'=21
+'faca'=22
+'enquanto'=23
+'se'=24
+'senao'=25
+'nao'=27

File diff suppressed because it is too large
+ 131 - 0
grammar/ivprogLexer.interp


+ 355 - 0
grammar/ivprogLexer.js

@@ -0,0 +1,355 @@
+// Generated from grammar/ivprog.g4 by ANTLR 4.7.1
+// jshint ignore: start
+var antlr4 = require('antlr4/index');
+
+
+var serializedATN = ["\u0003\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964",
+    "\u0002&\u0180\b\u0001\u0004\u0002\t\u0002\u0004\u0003\t\u0003\u0004",
+    "\u0004\t\u0004\u0004\u0005\t\u0005\u0004\u0006\t\u0006\u0004\u0007\t",
+    "\u0007\u0004\b\t\b\u0004\t\t\t\u0004\n\t\n\u0004\u000b\t\u000b\u0004",
+    "\f\t\f\u0004\r\t\r\u0004\u000e\t\u000e\u0004\u000f\t\u000f\u0004\u0010",
+    "\t\u0010\u0004\u0011\t\u0011\u0004\u0012\t\u0012\u0004\u0013\t\u0013",
+    "\u0004\u0014\t\u0014\u0004\u0015\t\u0015\u0004\u0016\t\u0016\u0004\u0017",
+    "\t\u0017\u0004\u0018\t\u0018\u0004\u0019\t\u0019\u0004\u001a\t\u001a",
+    "\u0004\u001b\t\u001b\u0004\u001c\t\u001c\u0004\u001d\t\u001d\u0004\u001e",
+    "\t\u001e\u0004\u001f\t\u001f\u0004 \t \u0004!\t!\u0004\"\t\"\u0004#",
+    "\t#\u0004$\t$\u0004%\t%\u0004&\t&\u0004\'\t\'\u0004(\t(\u0004)\t)\u0004",
+    "*\t*\u0004+\t+\u0003\u0002\u0003\u0002\u0003\u0003\u0003\u0003\u0003",
+    "\u0004\u0003\u0004\u0003\u0005\u0003\u0005\u0003\u0006\u0003\u0006\u0003",
+    "\u0007\u0003\u0007\u0003\b\u0003\b\u0003\b\u0003\b\u0003\b\u0003\b\u0003",
+    "\b\u0003\b\u0003\b\u0003\t\u0003\t\u0003\t\u0003\t\u0003\t\u0003\n\u0003",
+    "\n\u0003\n\u0003\n\u0003\n\u0003\n\u0003\u000b\u0003\u000b\u0003\u000b",
+    "\u0003\u000b\u0003\u000b\u0003\u000b\u0003\u000b\u0003\f\u0003\f\u0003",
+    "\f\u0003\f\u0003\f\u0003\f\u0003\f\u0003\r\u0003\r\u0003\r\u0003\r\u0003",
+    "\r\u0003\r\u0003\r\u0003\r\u0003\u000e\u0003\u000e\u0003\u000e\u0003",
+    "\u000e\u0003\u000e\u0003\u000e\u0003\u000e\u0003\u000e\u0003\u000e\u0003",
+    "\u000f\u0003\u000f\u0003\u000f\u0003\u000f\u0003\u000f\u0003\u000f\u0003",
+    "\u000f\u0003\u000f\u0003\u0010\u0003\u0010\u0003\u0010\u0003\u0010\u0003",
+    "\u0010\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0003",
+    "\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0012\u0003",
+    "\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0003\u0013\u0003",
+    "\u0013\u0003\u0013\u0003\u0013\u0003\u0013\u0003\u0013\u0003\u0013\u0003",
+    "\u0014\u0003\u0014\u0003\u0014\u0003\u0014\u0003\u0014\u0003\u0014\u0003",
+    "\u0014\u0003\u0014\u0003\u0015\u0003\u0015\u0003\u0015\u0003\u0015\u0003",
+    "\u0015\u0003\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003",
+    "\u0017\u0003\u0017\u0003\u0017\u0003\u0017\u0003\u0017\u0003\u0018\u0003",
+    "\u0018\u0003\u0018\u0003\u0018\u0003\u0018\u0003\u0018\u0003\u0018\u0003",
+    "\u0018\u0003\u0018\u0003\u0019\u0003\u0019\u0003\u0019\u0003\u001a\u0003",
+    "\u001a\u0003\u001a\u0003\u001a\u0003\u001a\u0003\u001a\u0003\u001b\u0003",
+    "\u001b\u0003\u001c\u0003\u001c\u0003\u001c\u0003\u001c\u0003\u001c\u0003",
+    "\u001c\u0003\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0003",
+    "\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0003\u001d\u0003",
+    "\u001e\u0003\u001e\u0003\u001e\u0003\u001e\u0003\u001f\u0003\u001f\u0005",
+    "\u001f\u00fd\n\u001f\u0003 \u0003 \u0007 \u0101\n \f \u000e \u0104\u000b",
+    " \u0003!\u0003!\u0003!\u0003!\u0003\"\u0006\"\u010b\n\"\r\"\u000e\"",
+    "\u010c\u0003\"\u0003\"\u0003\"\u0003\"\u0005\"\u0113\n\"\u0003\"\u0006",
+    "\"\u0116\n\"\r\"\u000e\"\u0117\u0003\"\u0003\"\u0003\"\u0003\"\u0005",
+    "\"\u011e\n\"\u0003\"\u0006\"\u0121\n\"\r\"\u000e\"\u0122\u0005\"\u0125",
+    "\n\"\u0003#\u0006#\u0128\n#\r#\u000e#\u0129\u0003#\u0003#\u0006#\u012e",
+    "\n#\r#\u000e#\u012f\u0003$\u0003$\u0003$\u0007$\u0135\n$\f$\u000e$\u0138",
+    "\u000b$\u0003$\u0003$\u0003%\u0003%\u0003%\u0005%\u013f\n%\u0003%\u0003",
+    "%\u0003&\u0003&\u0003&\u0003&\u0003\'\u0003\'\u0003(\u0003(\u0003(\u0003",
+    "(\u0005(\u014d\n(\u0003(\u0003(\u0005(\u0151\n(\u0003)\u0003)\u0003",
+    ")\u0003)\u0003)\u0003)\u0003)\u0003)\u0003)\u0005)\u015c\n)\u0003*\u0003",
+    "*\u0003*\u0003*\u0003*\u0003*\u0003*\u0003+\u0003+\u0003+\u0003+\u0007",
+    "+\u0169\n+\f+\u000e+\u016c\u000b+\u0003+\u0005+\u016f\n+\u0003+\u0003",
+    "+\u0003+\u0003+\u0003+\u0007+\u0176\n+\f+\u000e+\u0179\u000b+\u0003",
+    "+\u0003+\u0005+\u017d\n+\u0003+\u0003+\u0002\u0002,\u0003\u0003\u0005",
+    "\u0004\u0007\u0005\t\u0006\u000b\u0007\r\b\u000f\t\u0011\n\u0013\u000b",
+    "\u0015\f\u0017\r\u0019\u000e\u001b\u000f\u001d\u0010\u001f\u0011!\u0012",
+    "#\u0013%\u0014\'\u0015)\u0016+\u0017-\u0018/\u00191\u001a3\u001b5\u001c",
+    "7\u00029\u0002;\u001d=\u001e?\u001fA C!E\"G#I$K%M\u0002O\u0002Q\u0002",
+    "S\u0002U&\u0003\u0002\u000b\u001d\u0002$&))00AB^^bb\u0080\u0080\u00a4",
+    "\u00a5\u00a9\u00a9\u00ac\u00ac\u00ae\u00ae\u00b4\u00b5\u00bb\u00bc\u00c2",
+    "\u00c2\u00c4\u00c6\u00c9\u00c9\u00cb\u00cd\u00d5\u00d7\u00dc\u00dc\u00de",
+    "\u00de\u00e2\u00e5\u00e9\u00e9\u00eb\u00ec\u00ef\u00ef\u00f5\u00f7\u00fc",
+    "\u00fc\u00fe\u00fe\u0005\u0002C\\aac|\u0006\u00022;C\\aac|\u0004\u0002",
+    "$$^^\u0004\u0002))^^\u0005\u0002\u000b\f\u000f\u000f\"\"\u0005\u0002",
+    "2;CHch\u0007\u0002ddhhppttvv\u0004\u0002\f\f\u000f\u000f\u0002\u0191",
+    "\u0002\u0003\u0003\u0002\u0002\u0002\u0002\u0005\u0003\u0002\u0002\u0002",
+    "\u0002\u0007\u0003\u0002\u0002\u0002\u0002\t\u0003\u0002\u0002\u0002",
+    "\u0002\u000b\u0003\u0002\u0002\u0002\u0002\r\u0003\u0002\u0002\u0002",
+    "\u0002\u000f\u0003\u0002\u0002\u0002\u0002\u0011\u0003\u0002\u0002\u0002",
+    "\u0002\u0013\u0003\u0002\u0002\u0002\u0002\u0015\u0003\u0002\u0002\u0002",
+    "\u0002\u0017\u0003\u0002\u0002\u0002\u0002\u0019\u0003\u0002\u0002\u0002",
+    "\u0002\u001b\u0003\u0002\u0002\u0002\u0002\u001d\u0003\u0002\u0002\u0002",
+    "\u0002\u001f\u0003\u0002\u0002\u0002\u0002!\u0003\u0002\u0002\u0002",
+    "\u0002#\u0003\u0002\u0002\u0002\u0002%\u0003\u0002\u0002\u0002\u0002",
+    "\'\u0003\u0002\u0002\u0002\u0002)\u0003\u0002\u0002\u0002\u0002+\u0003",
+    "\u0002\u0002\u0002\u0002-\u0003\u0002\u0002\u0002\u0002/\u0003\u0002",
+    "\u0002\u0002\u00021\u0003\u0002\u0002\u0002\u00023\u0003\u0002\u0002",
+    "\u0002\u00025\u0003\u0002\u0002\u0002\u0002;\u0003\u0002\u0002\u0002",
+    "\u0002=\u0003\u0002\u0002\u0002\u0002?\u0003\u0002\u0002\u0002\u0002",
+    "A\u0003\u0002\u0002\u0002\u0002C\u0003\u0002\u0002\u0002\u0002E\u0003",
+    "\u0002\u0002\u0002\u0002G\u0003\u0002\u0002\u0002\u0002I\u0003\u0002",
+    "\u0002\u0002\u0002K\u0003\u0002\u0002\u0002\u0002U\u0003\u0002\u0002",
+    "\u0002\u0003W\u0003\u0002\u0002\u0002\u0005Y\u0003\u0002\u0002\u0002",
+    "\u0007[\u0003\u0002\u0002\u0002\t]\u0003\u0002\u0002\u0002\u000b_\u0003",
+    "\u0002\u0002\u0002\ra\u0003\u0002\u0002\u0002\u000fc\u0003\u0002\u0002",
+    "\u0002\u0011l\u0003\u0002\u0002\u0002\u0013q\u0003\u0002\u0002\u0002",
+    "\u0015w\u0003\u0002\u0002\u0002\u0017~\u0003\u0002\u0002\u0002\u0019",
+    "\u0085\u0003\u0002\u0002\u0002\u001b\u008d\u0003\u0002\u0002\u0002\u001d",
+    "\u0096\u0003\u0002\u0002\u0002\u001f\u009e\u0003\u0002\u0002\u0002!",
+    "\u00a3\u0003\u0002\u0002\u0002#\u00ad\u0003\u0002\u0002\u0002%\u00b3",
+    "\u0003\u0002\u0002\u0002\'\u00ba\u0003\u0002\u0002\u0002)\u00c2\u0003",
+    "\u0002\u0002\u0002+\u00c7\u0003\u0002\u0002\u0002-\u00cc\u0003\u0002",
+    "\u0002\u0002/\u00d1\u0003\u0002\u0002\u00021\u00da\u0003\u0002\u0002",
+    "\u00023\u00dd\u0003\u0002\u0002\u00025\u00e3\u0003\u0002\u0002\u0002",
+    "7\u00e5\u0003\u0002\u0002\u00029\u00eb\u0003\u0002\u0002\u0002;\u00f6",
+    "\u0003\u0002\u0002\u0002=\u00fc\u0003\u0002\u0002\u0002?\u00fe\u0003",
+    "\u0002\u0002\u0002A\u0105\u0003\u0002\u0002\u0002C\u0124\u0003\u0002",
+    "\u0002\u0002E\u0127\u0003\u0002\u0002\u0002G\u0131\u0003\u0002\u0002",
+    "\u0002I\u013b\u0003\u0002\u0002\u0002K\u0142\u0003\u0002\u0002\u0002",
+    "M\u0146\u0003\u0002\u0002\u0002O\u0150\u0003\u0002\u0002\u0002Q\u015b",
+    "\u0003\u0002\u0002\u0002S\u015d\u0003\u0002\u0002\u0002U\u017c\u0003",
+    "\u0002\u0002\u0002WX\u0007}\u0002\u0002X\u0004\u0003\u0002\u0002\u0002",
+    "YZ\u0007\u007f\u0002\u0002Z\u0006\u0003\u0002\u0002\u0002[\\\u0007.",
+    "\u0002\u0002\\\b\u0003\u0002\u0002\u0002]^\u0007]\u0002\u0002^\n\u0003",
+    "\u0002\u0002\u0002_`\u0007_\u0002\u0002`\f\u0003\u0002\u0002\u0002a",
+    "b\u0007?\u0002\u0002b\u000e\u0003\u0002\u0002\u0002cd\u0007r\u0002\u0002",
+    "de\u0007t\u0002\u0002ef\u0007q\u0002\u0002fg\u0007i\u0002\u0002gh\u0007",
+    "t\u0002\u0002hi\u0007c\u0002\u0002ij\u0007o\u0002\u0002jk\u0007c\u0002",
+    "\u0002k\u0010\u0003\u0002\u0002\u0002lm\u0007t\u0002\u0002mn\u0007g",
+    "\u0002\u0002no\u0007c\u0002\u0002op\u0007n\u0002\u0002p\u0012\u0003",
+    "\u0002\u0002\u0002qr\u0007x\u0002\u0002rs\u0007c\u0002\u0002st\u0007",
+    "|\u0002\u0002tu\u0007k\u0002\u0002uv\u0007q\u0002\u0002v\u0014\u0003",
+    "\u0002\u0002\u0002wx\u0007n\u0002\u0002xy\u0007q\u0002\u0002yz\u0007",
+    "i\u0002\u0002z{\u0007k\u0002\u0002{|\u0007e\u0002\u0002|}\u0007q\u0002",
+    "\u0002}\u0016\u0003\u0002\u0002\u0002~\u007f\u0007e\u0002\u0002\u007f",
+    "\u0080\u0007c\u0002\u0002\u0080\u0081\u0007f\u0002\u0002\u0081\u0082",
+    "\u0007g\u0002\u0002\u0082\u0083\u0007k\u0002\u0002\u0083\u0084\u0007",
+    "c\u0002\u0002\u0084\u0018\u0003\u0002\u0002\u0002\u0085\u0086\u0007",
+    "k\u0002\u0002\u0086\u0087\u0007p\u0002\u0002\u0087\u0088\u0007v\u0002",
+    "\u0002\u0088\u0089\u0007g\u0002\u0002\u0089\u008a\u0007k\u0002\u0002",
+    "\u008a\u008b\u0007t\u0002\u0002\u008b\u008c\u0007q\u0002\u0002\u008c",
+    "\u001a\u0003\u0002\u0002\u0002\u008d\u008e\u0007e\u0002\u0002\u008e",
+    "\u008f\u0007c\u0002\u0002\u008f\u0090\u0007t\u0002\u0002\u0090\u0091",
+    "\u0007c\u0002\u0002\u0091\u0092\u0007e\u0002\u0002\u0092\u0093\u0007",
+    "v\u0002\u0002\u0093\u0094\u0007g\u0002\u0002\u0094\u0095\u0007t\u0002",
+    "\u0002\u0095\u001c\u0003\u0002\u0002\u0002\u0096\u0097\u0007g\u0002",
+    "\u0002\u0097\u0098\u0007u\u0002\u0002\u0098\u0099\u0007e\u0002\u0002",
+    "\u0099\u009a\u0007q\u0002\u0002\u009a\u009b\u0007n\u0002\u0002\u009b",
+    "\u009c\u0007j\u0002\u0002\u009c\u009d\u0007c\u0002\u0002\u009d\u001e",
+    "\u0003\u0002\u0002\u0002\u009e\u009f\u0007e\u0002\u0002\u009f\u00a0",
+    "\u0007c\u0002\u0002\u00a0\u00a1\u0007u\u0002\u0002\u00a1\u00a2\u0007",
+    "q\u0002\u0002\u00a2 \u0003\u0002\u0002\u0002\u00a3\u00a4\u0007e\u0002",
+    "\u0002\u00a4\u00a5\u0007q\u0002\u0002\u00a5\u00a6\u0007p\u0002\u0002",
+    "\u00a6\u00a7\u0007v\u0002\u0002\u00a7\u00a8\u0007t\u0002\u0002\u00a8",
+    "\u00a9\u0007c\u0002\u0002\u00a9\u00aa\u0007t\u0002\u0002\u00aa\u00ab",
+    "\u0007k\u0002\u0002\u00ab\u00ac\u0007q\u0002\u0002\u00ac\"\u0003\u0002",
+    "\u0002\u0002\u00ad\u00ae\u0007e\u0002\u0002\u00ae\u00af\u0007q\u0002",
+    "\u0002\u00af\u00b0\u0007p\u0002\u0002\u00b0\u00b1\u0007u\u0002\u0002",
+    "\u00b1\u00b2\u0007v\u0002\u0002\u00b2$\u0003\u0002\u0002\u0002\u00b3",
+    "\u00b4\u0007h\u0002\u0002\u00b4\u00b5\u0007w\u0002\u0002\u00b5\u00b6",
+    "\u0007p\u0002\u0002\u00b6\u00b7\u0007e\u0002\u0002\u00b7\u00b8\u0007",
+    "c\u0002\u0002\u00b8\u00b9\u0007q\u0002\u0002\u00b9&\u0003\u0002\u0002",
+    "\u0002\u00ba\u00bb\u0007t\u0002\u0002\u00bb\u00bc\u0007g\u0002\u0002",
+    "\u00bc\u00bd\u0007v\u0002\u0002\u00bd\u00be\u0007q\u0002\u0002\u00be",
+    "\u00bf\u0007t\u0002\u0002\u00bf\u00c0\u0007p\u0002\u0002\u00c0\u00c1",
+    "\u0007g\u0002\u0002\u00c1(\u0003\u0002\u0002\u0002\u00c2\u00c3\u0007",
+    "r\u0002\u0002\u00c3\u00c4\u0007c\u0002\u0002\u00c4\u00c5\u0007t\u0002",
+    "\u0002\u00c5\u00c6\u0007c\u0002\u0002\u00c6*\u0003\u0002\u0002\u0002",
+    "\u00c7\u00c8\u0007r\u0002\u0002\u00c8\u00c9\u0007c\u0002\u0002\u00c9",
+    "\u00ca\u0007t\u0002\u0002\u00ca\u00cb\u0007g\u0002\u0002\u00cb,\u0003",
+    "\u0002\u0002\u0002\u00cc\u00cd\u0007h\u0002\u0002\u00cd\u00ce\u0007",
+    "c\u0002\u0002\u00ce\u00cf\u0007e\u0002\u0002\u00cf\u00d0\u0007c\u0002",
+    "\u0002\u00d0.\u0003\u0002\u0002\u0002\u00d1\u00d2\u0007g\u0002\u0002",
+    "\u00d2\u00d3\u0007p\u0002\u0002\u00d3\u00d4\u0007s\u0002\u0002\u00d4",
+    "\u00d5\u0007w\u0002\u0002\u00d5\u00d6\u0007c\u0002\u0002\u00d6\u00d7",
+    "\u0007p\u0002\u0002\u00d7\u00d8\u0007v\u0002\u0002\u00d8\u00d9\u0007",
+    "q\u0002\u0002\u00d90\u0003\u0002\u0002\u0002\u00da\u00db\u0007u\u0002",
+    "\u0002\u00db\u00dc\u0007g\u0002\u0002\u00dc2\u0003\u0002\u0002\u0002",
+    "\u00dd\u00de\u0007u\u0002\u0002\u00de\u00df\u0007g\u0002\u0002\u00df",
+    "\u00e0\u0007p\u0002\u0002\u00e0\u00e1\u0007c\u0002\u0002\u00e1\u00e2",
+    "\u0007q\u0002\u0002\u00e24\u0003\u0002\u0002\u0002\u00e3\u00e4\t\u0002",
+    "\u0002\u0002\u00e46\u0003\u0002\u0002\u0002\u00e5\u00e6\u0007h\u0002",
+    "\u0002\u00e6\u00e7\u0007c\u0002\u0002\u00e7\u00e8\u0007n\u0002\u0002",
+    "\u00e8\u00e9\u0007u\u0002\u0002\u00e9\u00ea\u0007q\u0002\u0002\u00ea",
+    "8\u0003\u0002\u0002\u0002\u00eb\u00ec\u0007x\u0002\u0002\u00ec\u00ed",
+    "\u0007g\u0002\u0002\u00ed\u00ee\u0007t\u0002\u0002\u00ee\u00ef\u0007",
+    "f\u0002\u0002\u00ef\u00f0\u0007c\u0002\u0002\u00f0\u00f1\u0007f\u0002",
+    "\u0002\u00f1\u00f2\u0007g\u0002\u0002\u00f2\u00f3\u0007k\u0002\u0002",
+    "\u00f3\u00f4\u0007t\u0002\u0002\u00f4\u00f5\u0007q\u0002\u0002\u00f5",
+    ":\u0003\u0002\u0002\u0002\u00f6\u00f7\u0007p\u0002\u0002\u00f7\u00f8",
+    "\u0007c\u0002\u0002\u00f8\u00f9\u0007q\u0002\u0002\u00f9<\u0003\u0002",
+    "\u0002\u0002\u00fa\u00fd\u00059\u001d\u0002\u00fb\u00fd\u00057\u001c",
+    "\u0002\u00fc\u00fa\u0003\u0002\u0002\u0002\u00fc\u00fb\u0003\u0002\u0002",
+    "\u0002\u00fd>\u0003\u0002\u0002\u0002\u00fe\u0102\t\u0003\u0002\u0002",
+    "\u00ff\u0101\t\u0004\u0002\u0002\u0100\u00ff\u0003\u0002\u0002\u0002",
+    "\u0101\u0104\u0003\u0002\u0002\u0002\u0102\u0100\u0003\u0002\u0002\u0002",
+    "\u0102\u0103\u0003\u0002\u0002\u0002\u0103@\u0003\u0002\u0002\u0002",
+    "\u0104\u0102\u0003\u0002\u0002\u0002\u0105\u0106\u0005? \u0002\u0106",
+    "\u0107\u00070\u0002\u0002\u0107\u0108\u0005? \u0002\u0108B\u0003\u0002",
+    "\u0002\u0002\u0109\u010b\u00042;\u0002\u010a\u0109\u0003\u0002\u0002",
+    "\u0002\u010b\u010c\u0003\u0002\u0002\u0002\u010c\u010a\u0003\u0002\u0002",
+    "\u0002\u010c\u010d\u0003\u0002\u0002\u0002\u010d\u0125\u0003\u0002\u0002",
+    "\u0002\u010e\u010f\u00072\u0002\u0002\u010f\u0113\u0007z\u0002\u0002",
+    "\u0110\u0111\u00072\u0002\u0002\u0111\u0113\u0007Z\u0002\u0002\u0112",
+    "\u010e\u0003\u0002\u0002\u0002\u0112\u0110\u0003\u0002\u0002\u0002\u0113",
+    "\u0115\u0003\u0002\u0002\u0002\u0114\u0116\u0005M\'\u0002\u0115\u0114",
+    "\u0003\u0002\u0002\u0002\u0116\u0117\u0003\u0002\u0002\u0002\u0117\u0115",
+    "\u0003\u0002\u0002\u0002\u0117\u0118\u0003\u0002\u0002\u0002\u0118\u0125",
+    "\u0003\u0002\u0002\u0002\u0119\u011a\u00072\u0002\u0002\u011a\u011e",
+    "\u0007d\u0002\u0002\u011b\u011c\u00072\u0002\u0002\u011c\u011e\u0007",
+    "D\u0002\u0002\u011d\u0119\u0003\u0002\u0002\u0002\u011d\u011b\u0003",
+    "\u0002\u0002\u0002\u011e\u0120\u0003\u0002\u0002\u0002\u011f\u0121\u0004",
+    "23\u0002\u0120\u011f\u0003\u0002\u0002\u0002\u0121\u0122\u0003\u0002",
+    "\u0002\u0002\u0122\u0120\u0003\u0002\u0002\u0002\u0122\u0123\u0003\u0002",
+    "\u0002\u0002\u0123\u0125\u0003\u0002\u0002\u0002\u0124\u010a\u0003\u0002",
+    "\u0002\u0002\u0124\u0112\u0003\u0002\u0002\u0002\u0124\u011d\u0003\u0002",
+    "\u0002\u0002\u0125D\u0003\u0002\u0002\u0002\u0126\u0128\u00042;\u0002",
+    "\u0127\u0126\u0003\u0002\u0002\u0002\u0128\u0129\u0003\u0002\u0002\u0002",
+    "\u0129\u0127\u0003\u0002\u0002\u0002\u0129\u012a\u0003\u0002\u0002\u0002",
+    "\u012a\u012b\u0003\u0002\u0002\u0002\u012b\u012d\u00070\u0002\u0002",
+    "\u012c\u012e\u00042;\u0002\u012d\u012c\u0003\u0002\u0002\u0002\u012e",
+    "\u012f\u0003\u0002\u0002\u0002\u012f\u012d\u0003\u0002\u0002\u0002\u012f",
+    "\u0130\u0003\u0002\u0002\u0002\u0130F\u0003\u0002\u0002\u0002\u0131",
+    "\u0136\u0007$\u0002\u0002\u0132\u0135\u0005O(\u0002\u0133\u0135\n\u0005",
+    "\u0002\u0002\u0134\u0132\u0003\u0002\u0002\u0002\u0134\u0133\u0003\u0002",
+    "\u0002\u0002\u0135\u0138\u0003\u0002\u0002\u0002\u0136\u0134\u0003\u0002",
+    "\u0002\u0002\u0136\u0137\u0003\u0002\u0002\u0002\u0137\u0139\u0003\u0002",
+    "\u0002\u0002\u0138\u0136\u0003\u0002\u0002\u0002\u0139\u013a\u0007$",
+    "\u0002\u0002\u013aH\u0003\u0002\u0002\u0002\u013b\u013e\u0007)\u0002",
+    "\u0002\u013c\u013f\u0005O(\u0002\u013d\u013f\n\u0006\u0002\u0002\u013e",
+    "\u013c\u0003\u0002\u0002\u0002\u013e\u013d\u0003\u0002\u0002\u0002\u013f",
+    "\u0140\u0003\u0002\u0002\u0002\u0140\u0141\u0007)\u0002\u0002\u0141",
+    "J\u0003\u0002\u0002\u0002\u0142\u0143\t\u0007\u0002\u0002\u0143\u0144",
+    "\u0003\u0002\u0002\u0002\u0144\u0145\b&\u0002\u0002\u0145L\u0003\u0002",
+    "\u0002\u0002\u0146\u0147\t\b\u0002\u0002\u0147N\u0003\u0002\u0002\u0002",
+    "\u0148\u014c\u0007^\u0002\u0002\u0149\u014d\t\t\u0002\u0002\u014a\u014d",
+    "\u0003\u0002\u0002\u0002\u014b\u014d\t\u0006\u0002\u0002\u014c\u0149",
+    "\u0003\u0002\u0002\u0002\u014c\u014a\u0003\u0002\u0002\u0002\u014c\u014b",
+    "\u0003\u0002\u0002\u0002\u014d\u0151\u0003\u0002\u0002\u0002\u014e\u0151",
+    "\u0005S*\u0002\u014f\u0151\u0005Q)\u0002\u0150\u0148\u0003\u0002\u0002",
+    "\u0002\u0150\u014e\u0003\u0002\u0002\u0002\u0150\u014f\u0003\u0002\u0002",
+    "\u0002\u0151P\u0003\u0002\u0002\u0002\u0152\u0153\u0007^\u0002\u0002",
+    "\u0153\u0154\u000425\u0002\u0154\u0155\u000429\u0002\u0155\u015c\u0004",
+    "29\u0002\u0156\u0157\u0007^\u0002\u0002\u0157\u0158\u000429\u0002\u0158",
+    "\u015c\u000429\u0002\u0159\u015a\u0007^\u0002\u0002\u015a\u015c\u0004",
+    "29\u0002\u015b\u0152\u0003\u0002\u0002\u0002\u015b\u0156\u0003\u0002",
+    "\u0002\u0002\u015b\u0159\u0003\u0002\u0002\u0002\u015cR\u0003\u0002",
+    "\u0002\u0002\u015d\u015e\u0007^\u0002\u0002\u015e\u015f\u0007w\u0002",
+    "\u0002\u015f\u0160\u0005M\'\u0002\u0160\u0161\u0005M\'\u0002\u0161\u0162",
+    "\u0005M\'\u0002\u0162\u0163\u0005M\'\u0002\u0163T\u0003\u0002\u0002",
+    "\u0002\u0164\u0165\u00071\u0002\u0002\u0165\u0166\u00071\u0002\u0002",
+    "\u0166\u016a\u0003\u0002\u0002\u0002\u0167\u0169\n\n\u0002\u0002\u0168",
+    "\u0167\u0003\u0002\u0002\u0002\u0169\u016c\u0003\u0002\u0002\u0002\u016a",
+    "\u0168\u0003\u0002\u0002\u0002\u016a\u016b\u0003\u0002\u0002\u0002\u016b",
+    "\u016e\u0003\u0002\u0002\u0002\u016c\u016a\u0003\u0002\u0002\u0002\u016d",
+    "\u016f\u0007\u000f\u0002\u0002\u016e\u016d\u0003\u0002\u0002\u0002\u016e",
+    "\u016f\u0003\u0002\u0002\u0002\u016f\u0170\u0003\u0002\u0002\u0002\u0170",
+    "\u017d\u0007\f\u0002\u0002\u0171\u0172\u00071\u0002\u0002\u0172\u0173",
+    "\u0007,\u0002\u0002\u0173\u0177\u0003\u0002\u0002\u0002\u0174\u0176",
+    "\u000b\u0002\u0002\u0002\u0175\u0174\u0003\u0002\u0002\u0002\u0176\u0179",
+    "\u0003\u0002\u0002\u0002\u0177\u0175\u0003\u0002\u0002\u0002\u0177\u0178",
+    "\u0003\u0002\u0002\u0002\u0178\u017a\u0003\u0002\u0002\u0002\u0179\u0177",
+    "\u0003\u0002\u0002\u0002\u017a\u017b\u0007,\u0002\u0002\u017b\u017d",
+    "\u00071\u0002\u0002\u017c\u0164\u0003\u0002\u0002\u0002\u017c\u0171",
+    "\u0003\u0002\u0002\u0002\u017d\u017e\u0003\u0002\u0002\u0002\u017e\u017f",
+    "\b+\u0002\u0002\u017fV\u0003\u0002\u0002\u0002\u0017\u0002\u00fc\u0102",
+    "\u010c\u0112\u0117\u011d\u0122\u0124\u0129\u012f\u0134\u0136\u013e\u014c",
+    "\u0150\u015b\u016a\u016e\u0177\u017c\u0003\b\u0002\u0002"].join("");
+
+
+var atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN);
+
+var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });
+
+function ivprogLexer(input) {
+	antlr4.Lexer.call(this, input);
+    this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
+    return this;
+}
+
+ivprogLexer.prototype = Object.create(antlr4.Lexer.prototype);
+ivprogLexer.prototype.constructor = ivprogLexer;
+
+Object.defineProperty(ivprogLexer.prototype, "atn", {
+        get : function() {
+                return atn;
+        }
+});
+
+ivprogLexer.EOF = antlr4.Token.EOF;
+ivprogLexer.T__0 = 1;
+ivprogLexer.T__1 = 2;
+ivprogLexer.T__2 = 3;
+ivprogLexer.T__3 = 4;
+ivprogLexer.T__4 = 5;
+ivprogLexer.T__5 = 6;
+ivprogLexer.PR_PROGRAMA = 7;
+ivprogLexer.PR_REAL = 8;
+ivprogLexer.PR_VAZIO = 9;
+ivprogLexer.PR_LOGICO = 10;
+ivprogLexer.PR_CADEIA = 11;
+ivprogLexer.PR_INTEIRO = 12;
+ivprogLexer.PR_CARACTER = 13;
+ivprogLexer.PR_ESCOLHA = 14;
+ivprogLexer.PR_CASO = 15;
+ivprogLexer.PR_CONTRARIO = 16;
+ivprogLexer.PR_CONST = 17;
+ivprogLexer.PR_FUNCAO = 18;
+ivprogLexer.PR_RETORNE = 19;
+ivprogLexer.PR_PARA = 20;
+ivprogLexer.PR_PARE = 21;
+ivprogLexer.PR_FACA = 22;
+ivprogLexer.PR_ENQUANTO = 23;
+ivprogLexer.PR_SE = 24;
+ivprogLexer.PR_SENAO = 25;
+ivprogLexer.GAMBIARRA = 26;
+ivprogLexer.OPERADOR_NAO = 27;
+ivprogLexer.LOGICO = 28;
+ivprogLexer.ID = 29;
+ivprogLexer.ID_BIBLIOTECA = 30;
+ivprogLexer.INTEIRO = 31;
+ivprogLexer.REAL = 32;
+ivprogLexer.CADEIA = 33;
+ivprogLexer.CARACTER = 34;
+ivprogLexer.ESPACO = 35;
+ivprogLexer.COMENTARIO = 36;
+
+ivprogLexer.prototype.channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ];
+
+ivprogLexer.prototype.modeNames = [ "DEFAULT_MODE" ];
+
+ivprogLexer.prototype.literalNames = [ null, "'{'", "'}'", "','", "'['", 
+                                       "']'", "'='", "'programa'", "'real'", 
+                                       "'vazio'", "'logico'", "'cadeia'", 
+                                       "'inteiro'", "'caracter'", "'escolha'", 
+                                       "'caso'", "'contrario'", "'const'", 
+                                       "'funcao'", "'retorne'", "'para'", 
+                                       "'pare'", "'faca'", "'enquanto'", 
+                                       "'se'", "'senao'", null, "'nao'" ];
+
+ivprogLexer.prototype.symbolicNames = [ null, null, null, null, null, null, 
+                                        null, "PR_PROGRAMA", "PR_REAL", 
+                                        "PR_VAZIO", "PR_LOGICO", "PR_CADEIA", 
+                                        "PR_INTEIRO", "PR_CARACTER", "PR_ESCOLHA", 
+                                        "PR_CASO", "PR_CONTRARIO", "PR_CONST", 
+                                        "PR_FUNCAO", "PR_RETORNE", "PR_PARA", 
+                                        "PR_PARE", "PR_FACA", "PR_ENQUANTO", 
+                                        "PR_SE", "PR_SENAO", "GAMBIARRA", 
+                                        "OPERADOR_NAO", "LOGICO", "ID", 
+                                        "ID_BIBLIOTECA", "INTEIRO", "REAL", 
+                                        "CADEIA", "CARACTER", "ESPACO", 
+                                        "COMENTARIO" ];
+
+ivprogLexer.prototype.ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", 
+                                    "T__5", "PR_PROGRAMA", "PR_REAL", "PR_VAZIO", 
+                                    "PR_LOGICO", "PR_CADEIA", "PR_INTEIRO", 
+                                    "PR_CARACTER", "PR_ESCOLHA", "PR_CASO", 
+                                    "PR_CONTRARIO", "PR_CONST", "PR_FUNCAO", 
+                                    "PR_RETORNE", "PR_PARA", "PR_PARE", 
+                                    "PR_FACA", "PR_ENQUANTO", "PR_SE", "PR_SENAO", 
+                                    "GAMBIARRA", "PR_FALSO", "PR_VERDADEIRO", 
+                                    "OPERADOR_NAO", "LOGICO", "ID", "ID_BIBLIOTECA", 
+                                    "INTEIRO", "REAL", "CADEIA", "CARACTER", 
+                                    "ESPACO", "DIGIT_HEX", "SEQ_ESC", "ESC_OCTAL", 
+                                    "ESC_UNICODE", "COMENTARIO" ];
+
+ivprogLexer.prototype.grammarFileName = "ivprog.g4";
+
+
+
+exports.ivprogLexer = ivprogLexer;
+

+ 62 - 0
grammar/ivprogLexer.tokens

@@ -0,0 +1,62 @@
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+T__5=6
+PR_PROGRAMA=7
+PR_REAL=8
+PR_VAZIO=9
+PR_LOGICO=10
+PR_CADEIA=11
+PR_INTEIRO=12
+PR_CARACTER=13
+PR_ESCOLHA=14
+PR_CASO=15
+PR_CONTRARIO=16
+PR_CONST=17
+PR_FUNCAO=18
+PR_RETORNE=19
+PR_PARA=20
+PR_PARE=21
+PR_FACA=22
+PR_ENQUANTO=23
+PR_SE=24
+PR_SENAO=25
+GAMBIARRA=26
+OPERADOR_NAO=27
+LOGICO=28
+ID=29
+ID_BIBLIOTECA=30
+INTEIRO=31
+REAL=32
+CADEIA=33
+CARACTER=34
+ESPACO=35
+COMENTARIO=36
+'{'=1
+'}'=2
+','=3
+'['=4
+']'=5
+'='=6
+'programa'=7
+'real'=8
+'vazio'=9
+'logico'=10
+'cadeia'=11
+'inteiro'=12
+'caracter'=13
+'escolha'=14
+'caso'=15
+'contrario'=16
+'const'=17
+'funcao'=18
+'retorne'=19
+'para'=20
+'pare'=21
+'faca'=22
+'enquanto'=23
+'se'=24
+'senao'=25
+'nao'=27

+ 78 - 0
grammar/ivprogListener.js

@@ -0,0 +1,78 @@
+// Generated from grammar/ivprog.g4 by ANTLR 4.7.1
+// jshint ignore: start
+var antlr4 = require('antlr4/index');
+
+// This class defines a complete listener for a parse tree produced by ivprogParser.
+function ivprogListener() {
+	antlr4.tree.ParseTreeListener.call(this);
+	return this;
+}
+
+ivprogListener.prototype = Object.create(antlr4.tree.ParseTreeListener.prototype);
+ivprogListener.prototype.constructor = ivprogListener;
+
+// Enter a parse tree produced by ivprogParser#parse.
+ivprogListener.prototype.enterParse = function(ctx) {
+};
+
+// Exit a parse tree produced by ivprogParser#parse.
+ivprogListener.prototype.exitParse = function(ctx) {
+};
+
+
+// Enter a parse tree produced by ivprogParser#programa.
+ivprogListener.prototype.enterPrograma = function(ctx) {
+};
+
+// Exit a parse tree produced by ivprogParser#programa.
+ivprogListener.prototype.exitPrograma = function(ctx) {
+};
+
+
+// Enter a parse tree produced by ivprogParser#declaracoesGlobais.
+ivprogListener.prototype.enterDeclaracoesGlobais = function(ctx) {
+};
+
+// Exit a parse tree produced by ivprogParser#declaracoesGlobais.
+ivprogListener.prototype.exitDeclaracoesGlobais = function(ctx) {
+};
+
+
+// Enter a parse tree produced by ivprogParser#listaDeclaracoes.
+ivprogListener.prototype.enterListaDeclaracoes = function(ctx) {
+};
+
+// Exit a parse tree produced by ivprogParser#listaDeclaracoes.
+ivprogListener.prototype.exitListaDeclaracoes = function(ctx) {
+};
+
+
+// Enter a parse tree produced by ivprogParser#declaracao.
+ivprogListener.prototype.enterDeclaracao = function(ctx) {
+};
+
+// Exit a parse tree produced by ivprogParser#declaracao.
+ivprogListener.prototype.exitDeclaracao = function(ctx) {
+};
+
+
+// Enter a parse tree produced by ivprogParser#declaracaoTipoDado.
+ivprogListener.prototype.enterDeclaracaoTipoDado = function(ctx) {
+};
+
+// Exit a parse tree produced by ivprogParser#declaracaoTipoDado.
+ivprogListener.prototype.exitDeclaracaoTipoDado = function(ctx) {
+};
+
+
+// Enter a parse tree produced by ivprogParser#expressao.
+ivprogListener.prototype.enterExpressao = function(ctx) {
+};
+
+// Exit a parse tree produced by ivprogParser#expressao.
+ivprogListener.prototype.exitExpressao = function(ctx) {
+};
+
+
+
+exports.ivprogListener = ivprogListener;

+ 837 - 0
grammar/ivprogParser.js

@@ -0,0 +1,837 @@
+// Generated from grammar/ivprog.g4 by ANTLR 4.7.1
+// jshint ignore: start
+var antlr4 = require('antlr4/index');
+var ivprogListener = require('./ivprogListener').ivprogListener;
+
+  import {ASA, NoGlobal} from '../js/asa';
+
+var grammarFileName = "ivprog.g4";
+
+var serializedATN = ["\u0003\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964",
+    "\u0003&S\u0004\u0002\t\u0002\u0004\u0003\t\u0003\u0004\u0004\t\u0004",
+    "\u0004\u0005\t\u0005\u0004\u0006\t\u0006\u0004\u0007\t\u0007\u0004\b",
+    "\t\b\u0003\u0002\u0003\u0002\u0003\u0002\u0003\u0002\u0003\u0003\u0003",
+    "\u0003\u0003\u0003\u0003\u0003\u0007\u0003\u0019\n\u0003\f\u0003\u000e",
+    "\u0003\u001c\u000b\u0003\u0003\u0003\u0003\u0003\u0003\u0004\u0003\u0004",
+    "\u0003\u0004\u0003\u0005\u0005\u0005$\n\u0005\u0003\u0005\u0003\u0005",
+    "\u0003\u0005\u0003\u0005\u0003\u0005\u0003\u0005\u0003\u0005\u0003\u0005",
+    "\u0007\u0005.\n\u0005\f\u0005\u000e\u00051\u000b\u0005\u0003\u0006\u0003",
+    "\u0006\u0003\u0006\u0005\u00066\n\u0006\u0003\u0006\u0003\u0006\u0003",
+    "\u0006\u0005\u0006;\n\u0006\u0003\u0006\u0005\u0006>\n\u0006\u0005\u0006",
+    "@\n\u0006\u0003\u0006\u0003\u0006\u0005\u0006D\n\u0006\u0003\u0006\u0003",
+    "\u0006\u0003\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0005",
+    "\u0007M\n\u0007\u0003\u0007\u0003\u0007\u0003\b\u0003\b\u0003\b\u0002",
+    "\u0002\t\u0002\u0004\u0006\b\n\f\u000e\u0002\u0003\u0004\u0002!!##\u0002",
+    "W\u0002\u0010\u0003\u0002\u0002\u0002\u0004\u0014\u0003\u0002\u0002",
+    "\u0002\u0006\u001f\u0003\u0002\u0002\u0002\b#\u0003\u0002\u0002\u0002",
+    "\n2\u0003\u0002\u0002\u0002\fL\u0003\u0002\u0002\u0002\u000eP\u0003",
+    "\u0002\u0002\u0002\u0010\u0011\u0005\u0004\u0003\u0002\u0011\u0012\u0007",
+    "\u0002\u0002\u0003\u0012\u0013\b\u0002\u0001\u0002\u0013\u0003\u0003",
+    "\u0002\u0002\u0002\u0014\u0015\u0007\t\u0002\u0002\u0015\u0016\u0007",
+    "\u0003\u0002\u0002\u0016\u001a\b\u0003\u0001\u0002\u0017\u0019\u0005",
+    "\u0006\u0004\u0002\u0018\u0017\u0003\u0002\u0002\u0002\u0019\u001c\u0003",
+    "\u0002\u0002\u0002\u001a\u0018\u0003\u0002\u0002\u0002\u001a\u001b\u0003",
+    "\u0002\u0002\u0002\u001b\u001d\u0003\u0002\u0002\u0002\u001c\u001a\u0003",
+    "\u0002\u0002\u0002\u001d\u001e\u0007\u0004\u0002\u0002\u001e\u0005\u0003",
+    "\u0002\u0002\u0002\u001f \u0005\b\u0005\u0002 !\b\u0004\u0001\u0002",
+    "!\u0007\u0003\u0002\u0002\u0002\"$\u0007\u0013\u0002\u0002#\"\u0003",
+    "\u0002\u0002\u0002#$\u0003\u0002\u0002\u0002$%\u0003\u0002\u0002\u0002",
+    "%&\u0005\f\u0007\u0002&\'\u0005\n\u0006\u0002\'(\b\u0005\u0001\u0002",
+    "(/\u0003\u0002\u0002\u0002)*\u0007\u0005\u0002\u0002*+\u0005\n\u0006",
+    "\u0002+,\b\u0005\u0001\u0002,.\u0003\u0002\u0002\u0002-)\u0003\u0002",
+    "\u0002\u0002.1\u0003\u0002\u0002\u0002/-\u0003\u0002\u0002\u0002/0\u0003",
+    "\u0002\u0002\u00020\t\u0003\u0002\u0002\u00021/\u0003\u0002\u0002\u0002",
+    "2?\u0007\u001f\u0002\u000235\u0007\u0006\u0002\u000246\u0005\u000e\b",
+    "\u000254\u0003\u0002\u0002\u000256\u0003\u0002\u0002\u000267\u0003\u0002",
+    "\u0002\u00027=\u0007\u0007\u0002\u00028:\u0007\u0006\u0002\u00029;\u0005",
+    "\u000e\b\u0002:9\u0003\u0002\u0002\u0002:;\u0003\u0002\u0002\u0002;",
+    "<\u0003\u0002\u0002\u0002<>\u0007\u0007\u0002\u0002=8\u0003\u0002\u0002",
+    "\u0002=>\u0003\u0002\u0002\u0002>@\u0003\u0002\u0002\u0002?3\u0003\u0002",
+    "\u0002\u0002?@\u0003\u0002\u0002\u0002@C\u0003\u0002\u0002\u0002AB\u0007",
+    "\b\u0002\u0002BD\u0005\u000e\b\u0002CA\u0003\u0002\u0002\u0002CD\u0003",
+    "\u0002\u0002\u0002DE\u0003\u0002\u0002\u0002EF\b\u0006\u0001\u0002F",
+    "\u000b\u0003\u0002\u0002\u0002GM\u0007\u000e\u0002\u0002HM\u0007\n\u0002",
+    "\u0002IM\u0007\u000f\u0002\u0002JM\u0007\r\u0002\u0002KM\u0007\f\u0002",
+    "\u0002LG\u0003\u0002\u0002\u0002LH\u0003\u0002\u0002\u0002LI\u0003\u0002",
+    "\u0002\u0002LJ\u0003\u0002\u0002\u0002LK\u0003\u0002\u0002\u0002MN\u0003",
+    "\u0002\u0002\u0002NO\b\u0007\u0001\u0002O\r\u0003\u0002\u0002\u0002",
+    "PQ\t\u0002\u0002\u0002Q\u000f\u0003\u0002\u0002\u0002\u000b\u001a#/",
+    "5:=?CL"].join("");
+
+
+var atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN);
+
+var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });
+
+var sharedContextCache = new antlr4.PredictionContextCache();
+
+var literalNames = [ null, "'{'", "'}'", "','", "'['", "']'", "'='", "'programa'", 
+                     "'real'", "'vazio'", "'logico'", "'cadeia'", "'inteiro'", 
+                     "'caracter'", "'escolha'", "'caso'", "'contrario'", 
+                     "'const'", "'funcao'", "'retorne'", "'para'", "'pare'", 
+                     "'faca'", "'enquanto'", "'se'", "'senao'", null, "'nao'" ];
+
+var symbolicNames = [ null, null, null, null, null, null, null, "PR_PROGRAMA", 
+                      "PR_REAL", "PR_VAZIO", "PR_LOGICO", "PR_CADEIA", "PR_INTEIRO", 
+                      "PR_CARACTER", "PR_ESCOLHA", "PR_CASO", "PR_CONTRARIO", 
+                      "PR_CONST", "PR_FUNCAO", "PR_RETORNE", "PR_PARA", 
+                      "PR_PARE", "PR_FACA", "PR_ENQUANTO", "PR_SE", "PR_SENAO", 
+                      "GAMBIARRA", "OPERADOR_NAO", "LOGICO", "ID", "ID_BIBLIOTECA", 
+                      "INTEIRO", "REAL", "CADEIA", "CARACTER", "ESPACO", 
+                      "COMENTARIO" ];
+
+var ruleNames =  [ "parse", "programa", "declaracoesGlobais", "listaDeclaracoes", 
+                   "declaracao", "declaracaoTipoDado", "expressao" ];
+
+function ivprogParser (input) {
+	antlr4.Parser.call(this, input);
+    this._interp = new antlr4.atn.ParserATNSimulator(this, atn, decisionsToDFA, sharedContextCache);
+    this.ruleNames = ruleNames;
+    this.literalNames = literalNames;
+    this.symbolicNames = symbolicNames;
+
+	  this.criarTrechoCodigoFonte = function(tokenAntlr)
+	    {
+	      if (tokenAntlr != null)
+	      {
+	        const linha = tokenAntlr.getLine();
+	        const coluna = tokenAntlr.getCharPositionInLine();
+	        const tamanhoTexto = tokenAntlr.getText().length();
+	        
+	        return {linha: linha, coluna: coluna, tamanhoTexto: tamanhoTexto};
+	      }
+	      
+	      return null;
+	  }
+
+    return this;
+}
+
+ivprogParser.prototype = Object.create(antlr4.Parser.prototype);
+ivprogParser.prototype.constructor = ivprogParser;
+
+Object.defineProperty(ivprogParser.prototype, "atn", {
+	get : function() {
+		return atn;
+	}
+});
+
+ivprogParser.EOF = antlr4.Token.EOF;
+ivprogParser.T__0 = 1;
+ivprogParser.T__1 = 2;
+ivprogParser.T__2 = 3;
+ivprogParser.T__3 = 4;
+ivprogParser.T__4 = 5;
+ivprogParser.T__5 = 6;
+ivprogParser.PR_PROGRAMA = 7;
+ivprogParser.PR_REAL = 8;
+ivprogParser.PR_VAZIO = 9;
+ivprogParser.PR_LOGICO = 10;
+ivprogParser.PR_CADEIA = 11;
+ivprogParser.PR_INTEIRO = 12;
+ivprogParser.PR_CARACTER = 13;
+ivprogParser.PR_ESCOLHA = 14;
+ivprogParser.PR_CASO = 15;
+ivprogParser.PR_CONTRARIO = 16;
+ivprogParser.PR_CONST = 17;
+ivprogParser.PR_FUNCAO = 18;
+ivprogParser.PR_RETORNE = 19;
+ivprogParser.PR_PARA = 20;
+ivprogParser.PR_PARE = 21;
+ivprogParser.PR_FACA = 22;
+ivprogParser.PR_ENQUANTO = 23;
+ivprogParser.PR_SE = 24;
+ivprogParser.PR_SENAO = 25;
+ivprogParser.GAMBIARRA = 26;
+ivprogParser.OPERADOR_NAO = 27;
+ivprogParser.LOGICO = 28;
+ivprogParser.ID = 29;
+ivprogParser.ID_BIBLIOTECA = 30;
+ivprogParser.INTEIRO = 31;
+ivprogParser.REAL = 32;
+ivprogParser.CADEIA = 33;
+ivprogParser.CARACTER = 34;
+ivprogParser.ESPACO = 35;
+ivprogParser.COMENTARIO = 36;
+
+ivprogParser.RULE_parse = 0;
+ivprogParser.RULE_programa = 1;
+ivprogParser.RULE_declaracoesGlobais = 2;
+ivprogParser.RULE_listaDeclaracoes = 3;
+ivprogParser.RULE_declaracao = 4;
+ivprogParser.RULE_declaracaoTipoDado = 5;
+ivprogParser.RULE_expressao = 6;
+
+function ParseContext(parser, parent, invokingState) {
+	if(parent===undefined) {
+	    parent = null;
+	}
+	if(invokingState===undefined || invokingState===null) {
+		invokingState = -1;
+	}
+	antlr4.ParserRuleContext.call(this, parent, invokingState);
+    this.parser = parser;
+    this.ruleIndex = ivprogParser.RULE_parse;
+    this.asa = null
+    this.prog = null; // ProgramaContext
+    return this;
+}
+
+ParseContext.prototype = Object.create(antlr4.ParserRuleContext.prototype);
+ParseContext.prototype.constructor = ParseContext;
+
+ParseContext.prototype.EOF = function() {
+    return this.getToken(ivprogParser.EOF, 0);
+};
+
+ParseContext.prototype.programa = function() {
+    return this.getTypedRuleContext(ProgramaContext,0);
+};
+
+ParseContext.prototype.enterRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.enterParse(this);
+	}
+};
+
+ParseContext.prototype.exitRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.exitParse(this);
+	}
+};
+
+
+
+
+ivprogParser.ParseContext = ParseContext;
+
+ivprogParser.prototype.parse = function() {
+
+    var localctx = new ParseContext(this, this._ctx, this.state);
+    this.enterRule(localctx, 0, ivprogParser.RULE_parse);
+    try {
+        this.enterOuterAlt(localctx, 1);
+        this.state = 14;
+        localctx.prog = this.programa();
+        this.state = 15;
+        this.match(ivprogParser.EOF);
+
+            localctx.asa =  localctx.prog.asa
+          
+    } catch (re) {
+    	if(re instanceof antlr4.error.RecognitionException) {
+	        localctx.exception = re;
+	        this._errHandler.reportError(this, re);
+	        this._errHandler.recover(this, re);
+	    } else {
+	    	throw re;
+	    }
+    } finally {
+        this.exitRule();
+    }
+    return localctx;
+};
+
+function ProgramaContext(parser, parent, invokingState) {
+	if(parent===undefined) {
+	    parent = null;
+	}
+	if(invokingState===undefined || invokingState===null) {
+		invokingState = -1;
+	}
+	antlr4.ParserRuleContext.call(this, parent, invokingState);
+    this.parser = parser;
+    this.ruleIndex = ivprogParser.RULE_programa;
+    this.asa = null
+    return this;
+}
+
+ProgramaContext.prototype = Object.create(antlr4.ParserRuleContext.prototype);
+ProgramaContext.prototype.constructor = ProgramaContext;
+
+ProgramaContext.prototype.PR_PROGRAMA = function() {
+    return this.getToken(ivprogParser.PR_PROGRAMA, 0);
+};
+
+ProgramaContext.prototype.declaracoesGlobais = function(i) {
+    if(i===undefined) {
+        i = null;
+    }
+    if(i===null) {
+        return this.getTypedRuleContexts(DeclaracoesGlobaisContext);
+    } else {
+        return this.getTypedRuleContext(DeclaracoesGlobaisContext,i);
+    }
+};
+
+ProgramaContext.prototype.enterRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.enterPrograma(this);
+	}
+};
+
+ProgramaContext.prototype.exitRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.exitPrograma(this);
+	}
+};
+
+
+
+
+ivprogParser.ProgramaContext = ProgramaContext;
+
+ivprogParser.prototype.programa = function() {
+
+    var localctx = new ProgramaContext(this, this._ctx, this.state);
+    this.enterRule(localctx, 2, ivprogParser.RULE_programa);
+    var _la = 0; // Token type
+    try {
+        this.enterOuterAlt(localctx, 1);
+        this.state = 18;
+        this.match(ivprogParser.PR_PROGRAMA);
+        this.state = 19;
+        this.match(ivprogParser.T__0);
+
+              localctx.asa =  new ASA()
+            
+        this.state = 24;
+        this._errHandler.sync(this);
+        _la = this._input.LA(1);
+        while((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << ivprogParser.PR_REAL) | (1 << ivprogParser.PR_LOGICO) | (1 << ivprogParser.PR_CADEIA) | (1 << ivprogParser.PR_INTEIRO) | (1 << ivprogParser.PR_CARACTER) | (1 << ivprogParser.PR_CONST))) !== 0)) {
+            this.state = 21;
+            this.declaracoesGlobais(localctx.asa);
+            this.state = 26;
+            this._errHandler.sync(this);
+            _la = this._input.LA(1);
+        }
+        this.state = 27;
+        this.match(ivprogParser.T__1);
+    } catch (re) {
+    	if(re instanceof antlr4.error.RecognitionException) {
+	        localctx.exception = re;
+	        this._errHandler.reportError(this, re);
+	        this._errHandler.recover(this, re);
+	    } else {
+	    	throw re;
+	    }
+    } finally {
+        this.exitRule();
+    }
+    return localctx;
+};
+
+function DeclaracoesGlobaisContext(parser, parent, invokingState, asa) {
+	if(parent===undefined) {
+	    parent = null;
+	}
+	if(invokingState===undefined || invokingState===null) {
+		invokingState = -1;
+	}
+	antlr4.ParserRuleContext.call(this, parent, invokingState);
+    this.parser = parser;
+    this.ruleIndex = ivprogParser.RULE_declaracoesGlobais;
+    this.asa = null
+    this.vList = null; // ListaDeclaracoesContext
+    this.asa = asa || null;
+    return this;
+}
+
+DeclaracoesGlobaisContext.prototype = Object.create(antlr4.ParserRuleContext.prototype);
+DeclaracoesGlobaisContext.prototype.constructor = DeclaracoesGlobaisContext;
+
+DeclaracoesGlobaisContext.prototype.listaDeclaracoes = function() {
+    return this.getTypedRuleContext(ListaDeclaracoesContext,0);
+};
+
+DeclaracoesGlobaisContext.prototype.enterRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.enterDeclaracoesGlobais(this);
+	}
+};
+
+DeclaracoesGlobaisContext.prototype.exitRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.exitDeclaracoesGlobais(this);
+	}
+};
+
+
+
+
+ivprogParser.DeclaracoesGlobaisContext = DeclaracoesGlobaisContext;
+
+ivprogParser.prototype.declaracoesGlobais = function(asa) {
+
+    var localctx = new DeclaracoesGlobaisContext(this, this._ctx, this.state, asa);
+    this.enterRule(localctx, 4, ivprogParser.RULE_declaracoesGlobais);
+    try {
+        this.enterOuterAlt(localctx, 1);
+        this.state = 29;
+        localctx.vList = this.listaDeclaracoes();
+
+            if (localctx.asa != null) {
+              this.globais = new NoGlobal();
+              localctx.vList.lista.forEach( v => this.globais.addDeclaracao(v));
+              localctx.asa.nos.push(localctx.vList.lista);
+            }
+          
+    } catch (re) {
+    	if(re instanceof antlr4.error.RecognitionException) {
+	        localctx.exception = re;
+	        this._errHandler.reportError(this, re);
+	        this._errHandler.recover(this, re);
+	    } else {
+	    	throw re;
+	    }
+    } finally {
+        this.exitRule();
+    }
+    return localctx;
+};
+
+function ListaDeclaracoesContext(parser, parent, invokingState) {
+	if(parent===undefined) {
+	    parent = null;
+	}
+	if(invokingState===undefined || invokingState===null) {
+		invokingState = -1;
+	}
+	antlr4.ParserRuleContext.call(this, parent, invokingState);
+    this.parser = parser;
+    this.ruleIndex = ivprogParser.RULE_listaDeclaracoes;
+    this.lista = null
+    this.tokenConst = null; // Token
+    this.informacaoTipoDado = null; // DeclaracaoTipoDadoContext
+    this.vDeclaracao = null; // DeclaracaoContext
+    return this;
+}
+
+ListaDeclaracoesContext.prototype = Object.create(antlr4.ParserRuleContext.prototype);
+ListaDeclaracoesContext.prototype.constructor = ListaDeclaracoesContext;
+
+ListaDeclaracoesContext.prototype.declaracaoTipoDado = function() {
+    return this.getTypedRuleContext(DeclaracaoTipoDadoContext,0);
+};
+
+ListaDeclaracoesContext.prototype.declaracao = function(i) {
+    if(i===undefined) {
+        i = null;
+    }
+    if(i===null) {
+        return this.getTypedRuleContexts(DeclaracaoContext);
+    } else {
+        return this.getTypedRuleContext(DeclaracaoContext,i);
+    }
+};
+
+ListaDeclaracoesContext.prototype.PR_CONST = function() {
+    return this.getToken(ivprogParser.PR_CONST, 0);
+};
+
+ListaDeclaracoesContext.prototype.enterRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.enterListaDeclaracoes(this);
+	}
+};
+
+ListaDeclaracoesContext.prototype.exitRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.exitListaDeclaracoes(this);
+	}
+};
+
+
+
+
+ivprogParser.ListaDeclaracoesContext = ListaDeclaracoesContext;
+
+ivprogParser.prototype.listaDeclaracoes = function() {
+
+    var localctx = new ListaDeclaracoesContext(this, this._ctx, this.state);
+    this.enterRule(localctx, 6, ivprogParser.RULE_listaDeclaracoes);
+
+      localctx.lista =  []
+
+    var _la = 0; // Token type
+    try {
+        this.enterOuterAlt(localctx, 1);
+        this.state = 33;
+        this._errHandler.sync(this);
+        _la = this._input.LA(1);
+        if(_la===ivprogParser.PR_CONST) {
+            this.state = 32;
+            localctx.tokenConst = this.match(ivprogParser.PR_CONST);
+        }
+
+        this.state = 35;
+        localctx.informacaoTipoDado = this.declaracaoTipoDado();
+
+        this.state = 36;
+        localctx.vDeclaracao = this.declaracao(localctx.tokenConst, localctx.informacaoTipoDado.informacaoTipoDado);
+
+              if(localctx.vDeclaracao) {
+                localctx.lista.push(localctx.vDeclaracao.rDeclaracao);
+              }
+              localctx.vDeclaracao = null;
+            
+        this.state = 45;
+        this._errHandler.sync(this);
+        _la = this._input.LA(1);
+        while(_la===ivprogParser.T__2) {
+            this.state = 39;
+            this.match(ivprogParser.T__2);
+            this.state = 40;
+            localctx.vDeclaracao = this.declaracao(localctx.tokenConst, localctx.informacaoTipoDado.informacaoTipoDado);
+
+                  if(localctx.vDeclaracao) {
+                    localctx.lista.push(localctx.vDeclaracao.rDeclaracao);
+                  }
+                  localctx.vDeclaracao = null;
+                
+            this.state = 47;
+            this._errHandler.sync(this);
+            _la = this._input.LA(1);
+        }
+    } catch (re) {
+    	if(re instanceof antlr4.error.RecognitionException) {
+	        localctx.exception = re;
+	        this._errHandler.reportError(this, re);
+	        this._errHandler.recover(this, re);
+	    } else {
+	    	throw re;
+	    }
+    } finally {
+        this.exitRule();
+    }
+    return localctx;
+};
+
+function DeclaracaoContext(parser, parent, invokingState, tokenConst, informacaoTipoDado) {
+	if(parent===undefined) {
+	    parent = null;
+	}
+	if(invokingState===undefined || invokingState===null) {
+		invokingState = -1;
+	}
+	antlr4.ParserRuleContext.call(this, parent, invokingState);
+    this.parser = parser;
+    this.ruleIndex = ivprogParser.RULE_declaracao;
+    this.tokenConst = null
+    this.informacaoTipoDado = null
+    this.rDeclaracao = null
+    this._ID = null; // Token
+    this.tk1 = null; // Token
+    this.ind1 = null; // ExpressaoContext
+    this.tk2 = null; // Token
+    this.ind2 = null; // ExpressaoContext
+    this.inicializacao = null; // ExpressaoContext
+    this.tokenConst = tokenConst || null;
+    this.informacaoTipoDado = informacaoTipoDado || null;
+    return this;
+}
+
+DeclaracaoContext.prototype = Object.create(antlr4.ParserRuleContext.prototype);
+DeclaracaoContext.prototype.constructor = DeclaracaoContext;
+
+DeclaracaoContext.prototype.ID = function() {
+    return this.getToken(ivprogParser.ID, 0);
+};
+
+DeclaracaoContext.prototype.expressao = function(i) {
+    if(i===undefined) {
+        i = null;
+    }
+    if(i===null) {
+        return this.getTypedRuleContexts(ExpressaoContext);
+    } else {
+        return this.getTypedRuleContext(ExpressaoContext,i);
+    }
+};
+
+DeclaracaoContext.prototype.enterRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.enterDeclaracao(this);
+	}
+};
+
+DeclaracaoContext.prototype.exitRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.exitDeclaracao(this);
+	}
+};
+
+
+
+
+ivprogParser.DeclaracaoContext = DeclaracaoContext;
+
+ivprogParser.prototype.declaracao = function(tokenConst, informacaoTipoDado) {
+
+    var localctx = new DeclaracaoContext(this, this._ctx, this.state, tokenConst, informacaoTipoDado);
+    this.enterRule(localctx, 8, ivprogParser.RULE_declaracao);
+    var _la = 0; // Token type
+    try {
+        this.enterOuterAlt(localctx, 1);
+        this.state = 48;
+        localctx._ID = this.match(ivprogParser.ID);
+        this.state = 61;
+        this._errHandler.sync(this);
+        _la = this._input.LA(1);
+        if(_la===ivprogParser.T__3) {
+            this.state = 49;
+            localctx.tk1 = this.match(ivprogParser.T__3);
+            this.state = 51;
+            this._errHandler.sync(this);
+            _la = this._input.LA(1);
+            if(_la===ivprogParser.INTEIRO || _la===ivprogParser.CADEIA) {
+                this.state = 50;
+                localctx.ind1 = this.expressao();
+            }
+
+            this.state = 53;
+            this.match(ivprogParser.T__4);
+            this.state = 59;
+            this._errHandler.sync(this);
+            _la = this._input.LA(1);
+            if(_la===ivprogParser.T__3) {
+                this.state = 54;
+                localctx.tk2 = this.match(ivprogParser.T__3);
+                this.state = 56;
+                this._errHandler.sync(this);
+                _la = this._input.LA(1);
+                if(_la===ivprogParser.INTEIRO || _la===ivprogParser.CADEIA) {
+                    this.state = 55;
+                    localctx.ind2 = this.expressao();
+                }
+
+                this.state = 58;
+                this.match(ivprogParser.T__4);
+            }
+
+        }
+
+        this.state = 65;
+        this._errHandler.sync(this);
+        _la = this._input.LA(1);
+        if(_la===ivprogParser.T__5) {
+            this.state = 63;
+            this.match(ivprogParser.T__5);
+            this.state = 64;
+            localctx.inicializacao = this.expressao();
+        }
+
+
+            const constante = (localctx.tokenConst != null);
+            const tipoDado = (localctx.informacaoTipoDado != null)? localctx.informacaoTipoDado.tipoDado : null;
+            const nome = (localctx._ID != null)? (localctx._ID===null ? null : localctx._ID.text) : null;
+            
+            if ((localctx.tk1 == null) && (localctx.tk2 == null))
+              localctx.rDeclaracao =  new NoDeclaracaoVariavel(nome, tipoDado, constante)
+            else
+            
+            if ((localctx.tk1 != null) && (localctx.tk2 == null))
+              localctx.rDeclaracao =  new NoDeclaracaoVetor(nome, tipoDado, (localctx.ind1===null ? null : this._input.getText(new antlr4.Interval(localctx.ind1.start,localctx.ind1.stop))), constante)
+            
+            else
+            
+            if ((localctx.tk1 != null) && (localctx.tk2 != null))
+              localctx.rDeclaracao =  new NoDeclaracaoMatriz(nome, tipoDado, (localctx.ind1===null ? null : this._input.getText(new antlr4.Interval(localctx.ind1.start,localctx.ind1.stop))), (localctx.ind2===null ? null : this._input.getText(new antlr4.Interval(localctx.ind2.start,localctx.ind2.stop))), constante)
+          
+            localctx.rDeclaracao.setInicializacao(inicializacao);
+            localctx.rDeclaracao.setTrechoCodigoFonteNome(criarTrechoCodigoFonte(localctx._ID));
+            localctx.rDeclaracao.setTrechoCodigoFonteTipoDado((localctx.informacaoTipoDado != null)? localctx.informacaoTipoDado.getTrechoCodigoFonte(): null);
+          
+    } catch (re) {
+    	if(re instanceof antlr4.error.RecognitionException) {
+	        localctx.exception = re;
+	        this._errHandler.reportError(this, re);
+	        this._errHandler.recover(this, re);
+	    } else {
+	    	throw re;
+	    }
+    } finally {
+        this.exitRule();
+    }
+    return localctx;
+};
+
+function DeclaracaoTipoDadoContext(parser, parent, invokingState) {
+	if(parent===undefined) {
+	    parent = null;
+	}
+	if(invokingState===undefined || invokingState===null) {
+		invokingState = -1;
+	}
+	antlr4.ParserRuleContext.call(this, parent, invokingState);
+    this.parser = parser;
+    this.ruleIndex = ivprogParser.RULE_declaracaoTipoDado;
+    this.informacaoTipoDado = null
+    this.tokenTipoDado = null; // Token
+    return this;
+}
+
+DeclaracaoTipoDadoContext.prototype = Object.create(antlr4.ParserRuleContext.prototype);
+DeclaracaoTipoDadoContext.prototype.constructor = DeclaracaoTipoDadoContext;
+
+DeclaracaoTipoDadoContext.prototype.PR_INTEIRO = function() {
+    return this.getToken(ivprogParser.PR_INTEIRO, 0);
+};
+
+DeclaracaoTipoDadoContext.prototype.PR_REAL = function() {
+    return this.getToken(ivprogParser.PR_REAL, 0);
+};
+
+DeclaracaoTipoDadoContext.prototype.PR_CARACTER = function() {
+    return this.getToken(ivprogParser.PR_CARACTER, 0);
+};
+
+DeclaracaoTipoDadoContext.prototype.PR_CADEIA = function() {
+    return this.getToken(ivprogParser.PR_CADEIA, 0);
+};
+
+DeclaracaoTipoDadoContext.prototype.PR_LOGICO = function() {
+    return this.getToken(ivprogParser.PR_LOGICO, 0);
+};
+
+DeclaracaoTipoDadoContext.prototype.enterRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.enterDeclaracaoTipoDado(this);
+	}
+};
+
+DeclaracaoTipoDadoContext.prototype.exitRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.exitDeclaracaoTipoDado(this);
+	}
+};
+
+
+
+
+ivprogParser.DeclaracaoTipoDadoContext = DeclaracaoTipoDadoContext;
+
+ivprogParser.prototype.declaracaoTipoDado = function() {
+
+    var localctx = new DeclaracaoTipoDadoContext(this, this._ctx, this.state);
+    this.enterRule(localctx, 10, ivprogParser.RULE_declaracaoTipoDado);
+    try {
+        this.enterOuterAlt(localctx, 1);
+        this.state = 74;
+        this._errHandler.sync(this);
+        switch(this._input.LA(1)) {
+        case ivprogParser.PR_INTEIRO:
+            this.state = 69;
+            localctx.tokenTipoDado = this.match(ivprogParser.PR_INTEIRO);
+            break;
+        case ivprogParser.PR_REAL:
+            this.state = 70;
+            localctx.tokenTipoDado = this.match(ivprogParser.PR_REAL);
+            break;
+        case ivprogParser.PR_CARACTER:
+            this.state = 71;
+            localctx.tokenTipoDado = this.match(ivprogParser.PR_CARACTER);
+            break;
+        case ivprogParser.PR_CADEIA:
+            this.state = 72;
+            localctx.tokenTipoDado = this.match(ivprogParser.PR_CADEIA);
+            break;
+        case ivprogParser.PR_LOGICO:
+            this.state = 73;
+            localctx.tokenTipoDado = this.match(ivprogParser.PR_LOGICO);
+            break;
+        default:
+            throw new antlr4.error.NoViableAltException(this);
+        }
+
+            localctx.informacaoTipoDado =  new InformacaoTipoDado()
+            localctx.informacaoTipoDado.setTipoDado(localctx.tokenTipoDado);
+            localctx.informacaoTipoDado.setTrechoCodigoFonte(criarTrechoCodigoFonte(localctx.tokenTipoDado));
+          
+    } catch (re) {
+    	if(re instanceof antlr4.error.RecognitionException) {
+	        localctx.exception = re;
+	        this._errHandler.reportError(this, re);
+	        this._errHandler.recover(this, re);
+	    } else {
+	    	throw re;
+	    }
+    } finally {
+        this.exitRule();
+    }
+    return localctx;
+};
+
+function ExpressaoContext(parser, parent, invokingState) {
+	if(parent===undefined) {
+	    parent = null;
+	}
+	if(invokingState===undefined || invokingState===null) {
+		invokingState = -1;
+	}
+	antlr4.ParserRuleContext.call(this, parent, invokingState);
+    this.parser = parser;
+    this.ruleIndex = ivprogParser.RULE_expressao;
+    return this;
+}
+
+ExpressaoContext.prototype = Object.create(antlr4.ParserRuleContext.prototype);
+ExpressaoContext.prototype.constructor = ExpressaoContext;
+
+ExpressaoContext.prototype.INTEIRO = function() {
+    return this.getToken(ivprogParser.INTEIRO, 0);
+};
+
+ExpressaoContext.prototype.CADEIA = function() {
+    return this.getToken(ivprogParser.CADEIA, 0);
+};
+
+ExpressaoContext.prototype.enterRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.enterExpressao(this);
+	}
+};
+
+ExpressaoContext.prototype.exitRule = function(listener) {
+    if(listener instanceof ivprogListener ) {
+        listener.exitExpressao(this);
+	}
+};
+
+
+
+
+ivprogParser.ExpressaoContext = ExpressaoContext;
+
+ivprogParser.prototype.expressao = function() {
+
+    var localctx = new ExpressaoContext(this, this._ctx, this.state);
+    this.enterRule(localctx, 12, ivprogParser.RULE_expressao);
+    var _la = 0; // Token type
+    try {
+        this.enterOuterAlt(localctx, 1);
+        this.state = 78;
+        _la = this._input.LA(1);
+        if(!(_la===ivprogParser.INTEIRO || _la===ivprogParser.CADEIA)) {
+        this._errHandler.recoverInline(this);
+        }
+        else {
+        	this._errHandler.reportMatch(this);
+            this.consume();
+        }
+    } catch (re) {
+    	if(re instanceof antlr4.error.RecognitionException) {
+	        localctx.exception = re;
+	        this._errHandler.reportError(this, re);
+	        this._errHandler.recover(this, re);
+	    } else {
+	    	throw re;
+	    }
+    } finally {
+        this.exitRule();
+    }
+    return localctx;
+};
+
+
+exports.ivprogParser = ivprogParser;

+ 40 - 0
grammar/ivprogVisitor.js

@@ -0,0 +1,40 @@
+// Generated from ../ivprog/grammar/ivprog.g4 by ANTLR 4.7.1
+// jshint ignore: start
+var antlr4 = require('antlr4/index');
+
+// This class defines a complete generic visitor for a parse tree produced by ivprogParser.
+
+function ivprogVisitor() {
+	antlr4.tree.ParseTreeVisitor.call(this);
+	return this;
+}
+
+ivprogVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype);
+ivprogVisitor.prototype.constructor = ivprogVisitor;
+
+// Visit a parse tree produced by ivprogParser#parse.
+ivprogVisitor.prototype.visitParse = function(ctx) {
+  return this.visitChildren(ctx);
+};
+
+
+// Visit a parse tree produced by ivprogParser#programa.
+ivprogVisitor.prototype.visitPrograma = function(ctx) {
+  return this.visitChildren(ctx);
+};
+
+
+// Visit a parse tree produced by ivprogParser#declaracoesGlobais.
+ivprogVisitor.prototype.visitDeclaracoesGlobais = function(ctx) {
+  return this.visitChildren(ctx);
+};
+
+
+// Visit a parse tree produced by ivprogParser#listaDeclaracoes.
+ivprogVisitor.prototype.visitListaDeclaracoes = function(ctx) {
+  return this.visitChildren(ctx);
+};
+
+
+
+exports.ivprogVisitor = ivprogVisitor;

+ 3 - 0
i18n/pt-br.js

@@ -0,0 +1,3 @@
+export default {
+  'key': 'value',
+}

+ 10 - 0
index.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title></title>
+</head>
+<body>
+
+</body>
+<script type="text/javascript" src="build/ivprog.bundle.js"></script>
+</html>

+ 8 - 0
ivprog.sublime-project

@@ -0,0 +1,8 @@
+{
+	"folders":
+	[
+		{
+			"path": "."
+		}
+	]
+}

+ 6 - 0
js/asa/ASA.js

@@ -0,0 +1,6 @@
+export class ASA {
+
+  constructor() {
+    this.nos = [];
+  }
+}

+ 8 - 0
js/asa/NoDeclaracao.js

@@ -0,0 +1,8 @@
+export class NoDeclaracao {
+
+  constructor(id, tipo, valor = null) {
+    this.id = id;
+    this.tipo = tipo;
+    this.valor = valor;
+  }
+}

+ 10 - 0
js/asa/NoGlobal.js

@@ -0,0 +1,10 @@
+export class NoGlobal {
+
+  constructor() {
+    this.declaracoes = [];
+  }
+
+  addDeclaracao(decl) {
+    this.declaracoes.push(decl);
+  }
+}

+ 7 - 0
js/asa/index.js

@@ -0,0 +1,7 @@
+import { ASA } from './ASA';
+import { NoGlobal } from './NoGlobal';
+import { NoDeclaracao } from './NoDeclaracao';
+
+exports.ASA = ASA;
+exports.NoGlobal = NoGlobal;
+exports.NoDeclaracao = NoDeclaracao;

+ 33 - 0
js/main.js

@@ -0,0 +1,33 @@
+import { InputStream, CommonTokenStream } from 'antlr4/index';
+import { ivprogParser, ivprogLexer, ivprogVisitor, ivprogListener } from '../grammar/';
+
+class MyVisitor extends ivprogVisitor {
+ 
+  visitParse(ctx) { console.log(ctx);}
+
+  visitPrograma(ctx) { console.log(ctx);}
+
+  visitListaDeclaracoes(ctx) { console.log(ctx);}
+
+  visitDeclaracoesGlobais(ctx) { console.log(ctx);}
+
+}
+
+class MyListener extends ivprogListener {
+  enterParse(ctx) {
+    console.log(ctx);
+  }
+
+  exitParse(ctx) {
+    console.log(ctx);
+  }
+}
+
+const list = new MyListener();
+const vist = new MyVisitor();
+const input = ""; // Load string content
+const lexer = new ivprogLexer(new InputStream(input));
+const parser = new ivprogParser(new CommonTokenStream(lexer));
+const result = parser.parse().enterRule(list);
+//const result = vist.visit(parser.programa());
+

File diff suppressed because it is too large
+ 5726 - 0
package-lock.json


+ 38 - 0
package.json

@@ -0,0 +1,38 @@
+{
+  "name": "ivprog",
+  "version": "0.1.0",
+  "description": "IMA para o ensino de programação",
+  "main": "js/main.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1",
+    "babel": "babel --presets env js/main.js -o build/ivprog.bunlde.js",
+    "start": "http-server",
+    "webpack": "webpack"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/git.lcalion.com/ivprog.git"
+  },
+  "keywords": [
+    "programação",
+    "ensino",
+    "visual"
+  ],
+  "author": "LInE-IME/USP",
+  "license": "MIT",
+  "bugs": {
+    "url": "https://github.com/git.lcalion.com/ivprog/issues"
+  },
+  "homepage": "https://github.com/git.lcalion.com/ivprog#readme",
+  "devDependencies": {
+    "antlr4-webpack-loader": "^0.1.1",
+    "babel-core": "^6.26.3",
+    "babel-loader": "^7.1.5",
+    "babel-preset-env": "^1.7.0",
+    "webpack": "^4.16.5",
+    "webpack-cli": "^3.1.0"
+  },
+  "dependencies": {
+    "antlr4": "^4.7.1"
+  }
+}

+ 28 - 0
webpack.config.js

@@ -0,0 +1,28 @@
+var path = require('path');
+var webpack = require('webpack');
+module.exports = {
+    entry: './js/main.js',
+    output: {
+        path: path.resolve(__dirname, 'build'),
+        filename: 'ivprog.bundle.js'
+    },
+    node: {
+        fs: 'empty',
+    },
+    module: {
+        rules: [
+            {
+                test: /\.js$/,
+                loader: 'babel-loader',
+                query: {
+                    presets: ['env']
+                }
+            },
+            { test: /\.g4/, loader: 'antlr4-webpack-loader' }
+        ]
+    },
+    stats: {
+        colors: true
+    },
+    devtool: 'source-map'
+};