ivprog-visual-1.0.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Definição das classes utilizadas para armazenar o algoritmo
  2. var tiposDados = Object.freeze({void:"void", integer:"integer", real:"real", text:"text", boolean:"boolean"});
  3. var Variavel = function(tipo, nome, valor, dimensoes = 0, eh_constante = false) {
  4. this.tipo = tipo;
  5. this.nome = nome;
  6. this.valor = valor;
  7. this.dimensoes = dimensoes;
  8. this.eh_constante = eh_constante;
  9. };
  10. var Funcao = function(nome, tipo_retorno = tiposDados.void, dimensoes_retorno = 0, lista_parametros = null, eh_principal = false, esta_oculta = false) {
  11. this.nome = nome;
  12. this.tipo_retorno = tipo_retorno;
  13. this.dimensoes_retorno = dimensoes_retorno;
  14. this.lista_parametros = lista_parametros;
  15. this.eh_principal = eh_principal;
  16. this.esta_oculta = esta_oculta;
  17. };
  18. var Comando = function(tipo) {
  19. this.tipo = tipo;
  20. };
  21. var Expressao = function(conteudo) {
  22. this.conteudo = conteudo;
  23. };
  24. var Programa = function () {
  25. this.funcoes = new Array();
  26. };
  27. function adicionarFuncao(funcao) {
  28. programa.funcoes.push(funcao);
  29. }
  30. // Adicionando a função principal automaticamente
  31. var programa = new Programa();
  32. var funcaoPrincipal = new Funcao("principal", tiposDados.void, 0, new Array(), true);
  33. funcaoPrincipal.lista_parametros.push(new Variavel(tiposDados.text, "args"));
  34. adicionarFuncao(funcaoPrincipal);