Przeglądaj źródła

Implement LanguageService and the structure to translate the module

Lucas de Souza 5 lat temu
rodzic
commit
f9c53a34cb
61 zmienionych plików z 831 dodań i 113 usunięć
  1. 244 0
      grammar/en/ivprog.g4
  2. 0 0
      grammar/es/ivprog.g4
  3. 6 3
      grammar/index.js
  4. 244 0
      grammar/pt/ivprog.g4
  5. 3 0
      i18n/en/error.json
  6. 9 0
      i18n/en/index.js
  7. 3 0
      i18n/en/message.json
  8. 25 0
      i18n/en/ui.json
  9. 3 0
      i18n/es/error.json
  10. 9 0
      i18n/es/index.js
  11. 3 0
      i18n/es/message.json
  12. 25 0
      i18n/es/ui.json
  13. 1 5
      i18n/i18n-engine.js
  14. 9 0
      i18n/index.js
  15. 0 3
      i18n/pt-br.js
  16. 3 0
      i18n/pt/error.json
  17. 9 0
      i18n/pt/index.js
  18. 3 0
      i18n/pt/message.json
  19. 25 0
      i18n/pt/ui.json
  20. 9 7
      js/iassign-integration-functions.js
  21. 1 1
      js/processor/ivprogProcessor.js
  22. 19 9
      js/services/languageService.js
  23. 49 0
      js/services/localizedStringsService.js
  24. 8 11
      tests/test00.spec.js
  25. 3 6
      tests/test01.spec.js
  26. 2 3
      tests/test02.spec.js
  27. 3 4
      tests/test03.spec.js
  28. 3 4
      tests/test04.spec.js
  29. 4 5
      tests/test05.spec.js
  30. 2 5
      tests/test06.spec.js
  31. 3 4
      tests/test07.spec.js
  32. 2 1
      tests/test08.spec.js
  33. 3 5
      tests/test09.spec.js
  34. 3 1
      tests/test10.spec.js
  35. 3 1
      tests/test11.spec.js
  36. 3 4
      tests/test12.spec.js
  37. 3 1
      tests/test13.spec.js
  38. 4 4
      tests/test14.spec.js
  39. 3 1
      tests/test15.spec.js
  40. 3 1
      tests/test16.spec.js
  41. 3 1
      tests/test17.spec.js
  42. 3 1
      tests/test18.spec.js
  43. 2 1
      tests/test19.spec.js
  44. 3 1
      tests/test20.spec.js
  45. 2 1
      tests/test21.spec.js
  46. 3 1
      tests/test22.spec.js
  47. 3 1
      tests/test23.spec.js
  48. 2 1
      tests/test24.spec.js
  49. 2 1
      tests/test25.spec.js
  50. 2 1
      tests/test26.spec.js
  51. 2 1
      tests/test27.spec.js
  52. 2 1
      tests/test28.spec.js
  53. 2 1
      tests/test29.spec.js
  54. 2 1
      tests/test30.spec.js
  55. 2 1
      tests/test31.spec.js
  56. 2 2
      tests/test33.spec.js
  57. 2 3
      tests/test34.spec.js
  58. 2 1
      tests/test35.spec.js
  59. 2 1
      tests/test37.spec.js
  60. 2 2
      tests/test38.spec.js
  61. 29 0
      tests/test40.spec.js

+ 244 - 0
grammar/en/ivprog.g4

@@ -0,0 +1,244 @@
+lexer grammar ivprog;
+
+@lexer::members{
+  //Translate to fit your language
+  ivprog.MAIN_FUNCTION_NAME = "start";
+  ivprog.READ_FUNCTION_NAME = "read";
+  ivprog.WRITE_FUNCTION_NAME = "write";
+}
+
+// BEGIN i18n Lexical rules
+RK_PROGRAM
+  : 'program'
+  ;
+
+RK_REAL
+  : 'real'
+  ;
+
+RK_VOID
+  : 'void'
+  ;
+
+RK_BOOLEAN
+  : 'boolean'
+  ;
+
+RK_STRING
+  : 'string'
+  ;
+
+RK_INTEGER
+  : 'integer'
+  ;
+
+RK_CHARACTER
+  : 'character'
+  ;    
+
+RK_SWITCH
+  : 'switch'
+  ;
+
+RK_CASE
+  : 'case'
+  ;
+
+RK_DEFAULT
+  : 'otherwise'
+  ;
+
+RK_CONST
+  : 'const'
+  ;
+
+RK_FUNCTION
+  : 'function'
+  ;
+
+RK_RETURN
+  : 'return'
+  ;  
+
+RK_FOR
+  : 'for'
+  ;
+
+RK_BREAK
+  : 'break'
+  ;
+
+RK_DO
+  : 'do'
+  ;
+
+RK_WHILE
+  : 'while'
+  ;
+
+RK_IF
+  : 'if'
+  ;
+
+RK_ELSE
+  : 'else'
+  ;
+
+RK_FALSE
+  : 'false'
+  ;
+
+RK_TRUE
+  : 'true'
+  ;
+
+fragment RK_LOGICAL_NOT
+  : 'not'
+  ;
+
+fragment RK_LOGICAL_AND
+  : 'AND'
+  ;
+
+fragment RK_LOGICAL_OR
+  : 'OR'
+  ;
+// END i18n Lexical rules
+
+// GAMBIARRA   : '.' |'á'| 'à'| 'ã'|'â'|'é'|'ê'|'í'|'ó'|'ô'|'õ'|'ú'|'ü'|'ç'|'Ä'|'À'|'Ã'|'Â'|'É'|'Ê'|'Ë'|'Ó'|'Ô'|'Õ'|'Ú'|'Ü'|'Ç'|'#'|'$'|'"'|'§'|'?'|'¹'|'²'|'³'|'£'|'¢'|'¬'|'ª'|'º'|'~'|'\''|'`'|'\\'|'@';
+
+OPEN_PARENTHESIS
+  : '('
+  ;
+
+CLOSE_PARENTHESIS
+  : ')'
+  ;
+
+OPEN_BRACE
+  : '['
+  ;
+
+CLOSE_BRACE
+  : ']'
+  ;
+
+OPEN_CURLY
+  : '{'
+  ;
+
+CLOSE_CURLY
+  : '}'
+  ;
+
+COMMA
+  : ','
+  ;
+
+EQUAL
+  : '='
+  ;
+
+SUM_OP
+  : ('+'|'-')
+  ;
+
+MULTI_OP
+  : ('*'|'/'|'%')
+  ;
+
+AND_OPERATOR
+  : RK_LOGICAL_AND
+  ;
+
+OR_OPERATOR
+  : RK_LOGICAL_OR
+  ;
+
+RELATIONAL_OPERATOR
+  : ('>='|'=='|'<='|'>'|'<'|'!=')
+  ;
+
+COLON
+  : ':'
+  ;
+
+NOT_OPERATOR
+  : RK_LOGICAL_NOT
+  ;
+
+ID
+  : [a-zA-Z_] [a-zA-Z0-9_]*
+  ;
+
+// ID_BIBLIOTECA     : ID '.' ID;
+
+INTEGER
+  : [0-9]+
+  | ('0x'|'0X')(HEX_DIGIT)+
+  | ('0b'|'0B')[0-1]+
+  ;
+
+REAL
+  : [0-9]+ '.' [0-9]+
+  | [0-9]+ '.' [0-9]* ExponentPart
+  ;
+
+fragment ExponentPart
+  : [eE] [+-]? [0-9]+
+  ;
+
+STRING
+  : '"' STRING_CHARACTER* '"'
+  ;
+    
+fragment STRING_CHARACTER //String as defined at https://github.com/antlr/grammars-v4/blob/master/java8/Java8.g4
+  : ~["\\\r\n]
+  | ESC_SEQ
+  ;
+
+CHARACTER //Character as defined at https://github.com/antlr/grammars-v4/blob/master/java8/Java8.g4
+  : '\'' ( ESC_SEQ | ~['\\\r\n]) '\''
+  ;
+
+WHITESPACE 
+  : ( ' ' | '\t') -> skip
+  ;
+
+fragment SEMICOLON
+  : ';'
+  ;
+
+EOS
+  : [\r\n]+
+  | SEMICOLON
+  ;
+
+fragment HEX_DIGIT
+  : [0-9a-fA-F]
+  ;
+
+fragment OCTAL_DIGIT
+  : [0-7]
+  ;
+
+fragment ESC_SEQ
+  : '\\' ('b'|'t'|'n'|'f'|'r'|'"'|'\''|'\\')
+  | ESC_UNICODE
+  | ESC_OCTAL
+  ;
+
+fragment ESC_OCTAL
+  : '\\' [0-3] OCTAL_DIGIT OCTAL_DIGIT
+  | '\\' OCTAL_DIGIT OCTAL_DIGIT
+  | '\\' OCTAL_DIGIT
+  ;
+
+fragment ESC_UNICODE
+  : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+  ;
+
+COMMENTS
+  : ('//' ~('\n'|'\r')* '\r'? '\n'
+    | '/*' .*? '*/') -> channel(HIDDEN)
+  ;

grammar/pt-br/ivprog.g4 → grammar/es/ivprog.g4


+ 6 - 3
grammar/index.js

@@ -1,4 +1,7 @@
-import * as ptBR from './pt-br/ivprog.g4';
+import * as PT from './pt/ivprog.g4';
+import * as EN from './en/ivprog.g4';
+import * as ES from './es/ivprog.g4';
 
-exports.pt_br = ptBR.ivprog;
-exports.default = ptBR.ivprog;
+exports.pt = PT.ivprog;
+exports.en = EN.ivprog;
+exports.es = ES.ivprog;

+ 244 - 0
grammar/pt/ivprog.g4

@@ -0,0 +1,244 @@
+lexer grammar ivprog;
+
+@lexer::members{
+  //Translate to fit your language
+  ivprog.MAIN_FUNCTION_NAME = "inicio";
+  ivprog.READ_FUNCTION_NAME = "leia";
+  ivprog.WRITE_FUNCTION_NAME = "escreva";
+}
+
+// BEGIN i18n Lexical rules
+RK_PROGRAM
+  : 'programa'
+  ;
+
+RK_REAL
+  : 'real'
+  ;
+
+RK_VOID
+  : 'vazio'
+  ;
+
+RK_BOOLEAN
+  : 'logico'
+  ;
+
+RK_STRING
+  : 'cadeia'
+  ;
+
+RK_INTEGER
+  : 'inteiro'
+  ;
+
+RK_CHARACTER
+  : 'caractere'
+  ;    
+
+RK_SWITCH
+  : 'escolha'
+  ;
+
+RK_CASE
+  : 'caso'
+  ;
+
+RK_DEFAULT
+  : 'contrario'
+  ;
+
+RK_CONST
+  : 'const'
+  ;
+
+RK_FUNCTION
+  : 'funcao'
+  ;
+
+RK_RETURN
+  : 'retorne'
+  ;  
+
+RK_FOR
+  : 'para'
+  ;
+
+RK_BREAK
+  : 'pare'
+  ;
+
+RK_DO
+  : 'faca'
+  ;
+
+RK_WHILE
+  : 'enquanto'
+  ;
+
+RK_IF
+  : 'se'
+  ;
+
+RK_ELSE
+  : 'senao'
+  ;
+
+RK_FALSE
+  : 'falso'
+  ;
+
+RK_TRUE
+  : 'verdadeiro'
+  ;
+
+fragment RK_LOGICAL_NOT
+  : 'nao'
+  ;
+
+fragment RK_LOGICAL_AND
+  : 'E'
+  ;
+
+fragment RK_LOGICAL_OR
+  : 'OU'
+  ;
+// END i18n Lexical rules
+
+// GAMBIARRA   : '.' |'á'| 'à'| 'ã'|'â'|'é'|'ê'|'í'|'ó'|'ô'|'õ'|'ú'|'ü'|'ç'|'Ä'|'À'|'Ã'|'Â'|'É'|'Ê'|'Ë'|'Ó'|'Ô'|'Õ'|'Ú'|'Ü'|'Ç'|'#'|'$'|'"'|'§'|'?'|'¹'|'²'|'³'|'£'|'¢'|'¬'|'ª'|'º'|'~'|'\''|'`'|'\\'|'@';
+
+OPEN_PARENTHESIS
+  : '('
+  ;
+
+CLOSE_PARENTHESIS
+  : ')'
+  ;
+
+OPEN_BRACE
+  : '['
+  ;
+
+CLOSE_BRACE
+  : ']'
+  ;
+
+OPEN_CURLY
+  : '{'
+  ;
+
+CLOSE_CURLY
+  : '}'
+  ;
+
+COMMA
+  : ','
+  ;
+
+EQUAL
+  : '='
+  ;
+
+SUM_OP
+  : ('+'|'-')
+  ;
+
+MULTI_OP
+  : ('*'|'/'|'%')
+  ;
+
+AND_OPERATOR
+  : RK_LOGICAL_AND
+  ;
+
+OR_OPERATOR
+  : RK_LOGICAL_OR
+  ;
+
+RELATIONAL_OPERATOR
+  : ('>='|'=='|'<='|'>'|'<'|'!=')
+  ;
+
+COLON
+  : ':'
+  ;
+
+NOT_OPERATOR
+  : RK_LOGICAL_NOT
+  ;
+
+ID
+  : [a-zA-Z_] [a-zA-Z0-9_]*
+  ;
+
+// ID_BIBLIOTECA     : ID '.' ID;
+
+INTEGER
+  : [0-9]+
+  | ('0x'|'0X')(HEX_DIGIT)+
+  | ('0b'|'0B')[0-1]+
+  ;
+
+REAL
+  : [0-9]+ '.' [0-9]+
+  | [0-9]+ '.' [0-9]* ExponentPart
+  ;
+
+fragment ExponentPart
+  : [eE] [+-]? [0-9]+
+  ;
+
+STRING
+  : '"' STRING_CHARACTER* '"'
+  ;
+    
+fragment STRING_CHARACTER //String as defined at https://github.com/antlr/grammars-v4/blob/master/java8/Java8.g4
+  : ~["\\\r\n]
+  | ESC_SEQ
+  ;
+
+CHARACTER //Character as defined at https://github.com/antlr/grammars-v4/blob/master/java8/Java8.g4
+  : '\'' ( ESC_SEQ | ~['\\\r\n]) '\''
+  ;
+
+WHITESPACE 
+  : ( ' ' | '\t') -> skip
+  ;
+
+fragment SEMICOLON
+  : ';'
+  ;
+
+EOS
+  : [\r\n]+
+  | SEMICOLON
+  ;
+
+fragment HEX_DIGIT
+  : [0-9a-fA-F]
+  ;
+
+fragment OCTAL_DIGIT
+  : [0-7]
+  ;
+
+fragment ESC_SEQ
+  : '\\' ('b'|'t'|'n'|'f'|'r'|'"'|'\''|'\\')
+  | ESC_UNICODE
+  | ESC_OCTAL
+  ;
+
+fragment ESC_OCTAL
+  : '\\' [0-3] OCTAL_DIGIT OCTAL_DIGIT
+  | '\\' OCTAL_DIGIT OCTAL_DIGIT
+  | '\\' OCTAL_DIGIT
+  ;
+
+fragment ESC_UNICODE
+  : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+  ;
+
+COMMENTS
+  : ('//' ~('\n'|'\r')* '\r'? '\n'
+    | '/*' .*? '*/') -> channel(HIDDEN)
+  ;

+ 3 - 0
i18n/en/error.json

@@ -0,0 +1,3 @@
+{
+  
+}

+ 9 - 0
i18n/en/index.js

@@ -0,0 +1,9 @@
+import errors from './error.json';
+import messages from './message.json'
+import ui from './ui.json';
+
+export default {
+ 'message' : messages,
+ 'error': errors,
+ 'ui': ui
+}

+ 3 - 0
i18n/en/message.json

@@ -0,0 +1,3 @@
+{
+  
+}

+ 25 - 0
i18n/en/ui.json

@@ -0,0 +1,25 @@
+{
+  "function": "function",
+  "btn_function": "Function",
+  "start": "start",
+  "void": "void",
+  "integer": "integer",
+  "real": "real",
+  "program": "program",
+  "text": "text",
+  "boolean": "boolean",
+  "true": "true",
+  "false": "false",
+  "variable": "Variable",
+  "command": "Command",
+  "new_parameter": "new_parameter",
+  "new_variable": "new_variable",
+  "new_global": "new_global",
+  "new_function": "new_function",
+  "vector": "vector",
+  "text_comment_start": "Initial comment of function...",
+  "text_comment_main": "This is the main function...",
+  "text_read_var": "Reading data",
+  "text_write_var": "Writing data",
+  "text_comment": "Comment"
+}

+ 3 - 0
i18n/es/error.json

@@ -0,0 +1,3 @@
+{
+  
+}

+ 9 - 0
i18n/es/index.js

@@ -0,0 +1,9 @@
+import errors from './error.json';
+import messages from './message.json'
+import ui from './ui.json';
+
+export default {
+ 'message' : messages,
+ 'error': errors,
+ 'ui': ui
+}

+ 3 - 0
i18n/es/message.json

@@ -0,0 +1,3 @@
+{
+  
+}

+ 25 - 0
i18n/es/ui.json

@@ -0,0 +1,25 @@
+{
+  "function": "function",
+  "btn_function": "Function",
+  "start": "start",
+  "void": "void",
+  "integer": "integer",
+  "real": "real",
+  "program": "program",
+  "text": "text",
+  "boolean": "boolean",
+  "true": "true",
+  "false": "false",
+  "variable": "Variable",
+  "command": "Command",
+  "new_parameter": "new_parameter",
+  "new_variable": "new_variable",
+  "new_global": "new_global",
+  "new_function": "new_function",
+  "vector": "vector",
+  "text_comment_start": "Initial comment of function...",
+  "text_comment_main": "This is the main function...",
+  "text_read_var": "Reading data",
+  "text_write_var": "Writing data",
+  "text_comment": "Comment"
+}

+ 1 - 5
i18n/i18n-engine.js

@@ -26,11 +26,7 @@ i18n.updateLocale = function(new_locale) {
   });
 }
 
-if (iLMparameters.lang) {
-  i18n.locale = iLMparameters.lang;
-} else {
-  i18n.locale = 'en';
-}
+i18n.locale = iLMparameters.lang;
 i18n.db = {};
 
 $.ajaxSetup({

+ 9 - 0
i18n/index.js

@@ -0,0 +1,9 @@
+import EN from './en';
+import PT from './pt';
+import ES from './es';
+
+export default {
+  'en': EN,
+  'pt': PT,
+  'es': ES
+}

+ 0 - 3
i18n/pt-br.js

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

+ 3 - 0
i18n/pt/error.json

@@ -0,0 +1,3 @@
+{
+  
+}

+ 9 - 0
i18n/pt/index.js

@@ -0,0 +1,9 @@
+import errors from './error.json';
+import messages from './message.json'
+import ui from './ui.json';
+
+export default {
+ 'message' : messages,
+ 'error': errors,
+ 'ui': ui
+}

+ 3 - 0
i18n/pt/message.json

@@ -0,0 +1,3 @@
+{
+  
+}

+ 25 - 0
i18n/pt/ui.json

@@ -0,0 +1,25 @@
+{
+  "function": "function",
+  "btn_function": "Function",
+  "start": "start",
+  "void": "void",
+  "integer": "integer",
+  "real": "real",
+  "program": "program",
+  "text": "text",
+  "boolean": "boolean",
+  "true": "true",
+  "false": "false",
+  "variable": "Variable",
+  "command": "Command",
+  "new_parameter": "new_parameter",
+  "new_variable": "new_variable",
+  "new_global": "new_global",
+  "new_function": "new_function",
+  "vector": "vector",
+  "text_comment_start": "Initial comment of function...",
+  "text_comment_main": "This is the main function...",
+  "text_read_var": "Reading data",
+  "text_write_var": "Writing data",
+  "text_comment": "Comment"
+}

+ 9 - 7
js/iassign-integration-functions.js

@@ -1,20 +1,24 @@
 // Função para ler parâmetros informados pelo iTarefa via URL
 // Apesar de não ser obrigatório, será muito útil para capturar os parâmetros
-function getParameterByName(name) {
+function getParameterByName(name, defaultReturn = null) {
     var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
-    return match ? decodeURIComponent(match[1].replace(/\+/g, ' ')) : null;
+    return match ? decodeURIComponent(match[1].replace(/\+/g, ' ')) : defaultReturn;
 }
 
-// Criando um array com os parâmetros informados pelo iTarefa
+// Criando um object com os parâmetros informados pelo iTarefa
 // Observe que para cada parâmetro, é realizada a chamada do método getParameterByName, implementado acima
 var iLMparameters = {
     iLM_PARAM_ServerToGetAnswerURL: getParameterByName("iLM_PARAM_ServerToGetAnswerURL"),
     iLM_PARAM_SendAnswer: getParameterByName("iLM_PARAM_SendAnswer"),
     iLM_PARAM_AssignmentURL: getParameterByName("iLM_PARAM_AssignmentURL"),
     iLM_PARAM_Assignment: getParameterByName("iLM_PARAM_Assignment"),
-    lang: getParameterByName("lang")
+    lang: getParameterByName("lang", "en")
 };
 
+// Set the lang parameter to the localStorage for easy access
+// and no dependency to the global scope, avoind future 'strict mode' problems
+localStorage.setItem('ivprog.lang', iLMparameters.lang);
+
 // Função chamada pelo iTarefa quando o professor finaliza a criação da atividade
 // ou quando o aluno finaliza a resolução do exercício
 // O retorno é um JSON com os dados do exercício ou da resolução
@@ -48,9 +52,7 @@ function getiLMContent() {
 
     // O parâmetro "iLM_PARAM_Assignment" fornece o URL do endereço que deve ser
     // requisitado via AJAX para a captura dos dados da atividade
-    $.get(iLMparameters.iLM_PARAM_Assignment, function (d) {
-
+    $.get(iLMparameters.iLM_PARAM_Assignment, function (data) {
         
-
     });
 }

+ 1 - 1
js/processor/ivprogProcessor.js

@@ -13,7 +13,7 @@ import * as Expressions from './../ast/expressions/';
 
 export class IVProgProcessor {
 
-  constructor(ast) {
+  constructor (ast) {
     this.ast = ast;
     this.globalStore = new Store();
     this.stores = [this.globalStore];

+ 19 - 9
js/services/languageService.js

@@ -1,19 +1,29 @@
 import Lexers from './../../grammar/';
-export class LanguageService {
+import { isNullOrUndefined } from 'util';
 
-  constructor () {
-    throw new Error('LanguageService class must not be instantiated!');
-  }
+const DEFAULT_LANG = 'pt';
+
+export const LanguageService  = ({
 
-  static getLang () {
+  getLang: () => {
     const lang = localStorage.getItem('ivprog.lang');
     if (lang === null) {
       throw new Error("Internal Error. User language information has not been set");
     }
     return lang;
-  }
+  },
 
-  static getCurrentLexer () {
-    return Lexers[LanguageService.getLang()];
+  getDefaultLang: () => {
+    return DEFAULT_LANG;
+  },
+
+  getCurrentLexer: () => {
+    const lexer = Lexers[LanguageService.getLang()];
+    if(lexer === null || lexer === undefined) {
+      return Lexers[DEFAULT_LANG];
+    } else {
+      return lexer;
+    }
   }
-}
+
+});

+ 49 - 0
js/services/localizedStringsService.js

@@ -0,0 +1,49 @@
+import { LanguageService } from "./languageService";
+import Langs from './../../i18n';
+
+export const StringTypes = Object.freeze({
+  ERROR: 'error',
+  MESSAGE: 'message',
+  UI: 'ui'
+});
+
+export const LocalizedStrings = Object.freeze({
+
+  getString: (id, type) => {
+    let i18nObj = Langs[LanguageService.getLang()];
+    if(!!!i18nObj) {
+      i18nObj = Langs[LanguageService.getDefaultLang()];
+    }
+    if(!!!i18nObj[type]) {
+      return "{MISSING_I18N_TYPE_IDENTIFIER}";
+    } else if (i18nObj[type][id]) {
+      return "{MISSING_I18N_TYPE_IDENTIFIER}";
+    } else {
+      return i18nObj[type][id];
+    }
+  },
+
+  getError: (id, context = []) => {
+    const text = LocalizedStrings.getString(id, StringTypes.ERROR);
+    return LocalizedStrings.processString(text, context)
+  },
+
+  getMessage: (id, context = []) => {
+    const text = LocalizedStrings.getString(id, StringTypes.MESSAGE);
+    return LocalizedStrings.processString(text, context)
+  },
+
+  getUI: (id, context = []) => {
+    const text = LocalizedStrings.getString(id, StringTypes.UI);
+    return LocalizedStrings.processString(text, context)
+  },
+
+  processString: (text, context) => {
+    for (let i = 0; i < context.length; i++) {
+      const v = context[i];
+      text = text.replace('\$'+i, v);
+    }
+    return text;
+  }
+
+});

+ 8 - 11
tests/test00.spec.js

@@ -1,30 +1,27 @@
-import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
 import * as Expressions from './../js/ast/expressions/';
 import * as Commands from './../js/ast/commands/';
+import { LanguageService } from './../js/services/languageService';
 import { Types } from './../js/ast/types';
 
 describe("Testing Syntax Analysis for default", () => {
-  var lang = 'pt_br';
+
   var input;
 
-  var asa;
-  var lexer;
+  const asa = {
+    global: [new Commands.Declaration('PI', Types.REAL, new Expressions.IntLiteral(1), true),
+    new Commands.ArrayDeclaration('a', Types.INTEGER, new Expressions.IntLiteral(5), new Expressions.IntLiteral(5), null, true)],
+    functions: []
+  };
+  const lexer  = LanguageService.getCurrentLexer();
 
   it("it should produce a valid AST", () => {
-    lexer  = Lexers[lang];
     input = `programa {
     const real PI = 1
     const inteiro a[5][5]
     }`;
-
-    asa = {
-        global: [new Commands.Declaration('PI', Types.REAL, new Expressions.IntLiteral(1), true),
-        new Commands.ArrayDeclaration('a', Types.INTEGER, new Expressions.IntLiteral(5), new Expressions.IntLiteral(5), null, true)],
-        functions: []
-      };
       const as = new IVProgParser(input, lexer);
       expect(as.parseTree()).toEqual(asa);
   });

+ 3 - 6
tests/test01.spec.js

@@ -1,9 +1,6 @@
 import Lexers from './../grammar/';
-import {
-    IVProgParser
-} from './../js/ast/ivprogParser';
-import {
-    SyntaxError}from './../js/ast/SyntaxError';
+import { IVProgParser } from './../js/ast/ivprogParser';
+import { LanguageService } from './../js/services/languageService';
 
 describe('Illegal newline syntax', () => {
 
@@ -15,7 +12,7 @@ describe('Illegal newline syntax', () => {
       PI = 5.6, c;
   }
   `;
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should result in SyntaxError`, () => {
       const as = new IVProgParser(input, lexer);

+ 2 - 3
tests/test02.spec.js

@@ -2,8 +2,7 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
-import {
-    SyntaxError}from './../js/ast/SyntaxError';
+import { LanguageService } from './../js/services/languageService';
 
 describe('Legal newline syntax', () => {
 
@@ -20,7 +19,7 @@ describe('Legal newline syntax', () => {
     }
   }
   `;
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should not result in SyntaxError`, () => {
       const as = new IVProgParser(input, lexer);

+ 3 - 4
tests/test03.spec.js

@@ -2,16 +2,15 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
-import {
-    SyntaxError
-} from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
+
 
 describe('Expressions which ends with ID terminals', () => {
     let input = `funcao inteiro test(real i) {
       inteiro a = 5 + i
       a = 5 + G[i][6]
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 3 - 4
tests/test04.spec.js

@@ -2,11 +2,10 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
-import {
-    SyntaxError
-} from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
 
 describe('Literal arrays that have more than 2 dimensions', () => {
+
     let input = `programa {
         const inteiro a[1][1] = {
             {
@@ -19,7 +18,7 @@ describe('Literal arrays that have more than 2 dimensions', () => {
             retorna
         }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 4 - 5
tests/test05.spec.js

@@ -1,12 +1,11 @@
-import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
-import {
-    SyntaxError
-} from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
+
 
 describe('IfThenElse command', () => {
+
     let input = `funcao inteiro test(real i) {
       inteiro a = 5 + i
       a = 5 + G[i][6]
@@ -16,7 +15,7 @@ describe('IfThenElse command', () => {
         a = 0
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 2 - 5
tests/test06.spec.js

@@ -1,10 +1,7 @@
-import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
-import {
-    SyntaxError
-} from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
 
 describe('While command', () => {
     let input = `funcao inteiro test(real i) {
@@ -14,7 +11,7 @@ describe('While command', () => {
         a = a + 1
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 3 - 4
tests/test07.spec.js

@@ -2,11 +2,10 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
-import {
-    SyntaxError
-} from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
 
 describe('For command', () => {
+
     let input = `funcao inteiro test(real i) {
       inteiro a = 5 + i
       a = 5 + G[i][6]
@@ -14,7 +13,7 @@ describe('For command', () => {
          a = a
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 2 - 1
tests/test08.spec.js

@@ -5,6 +5,7 @@ import {
 import {
     SyntaxError
 } from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
 
 describe('Break command inside a loop', () => {
     let input = `funcao inteiro test(real i) {
@@ -17,7 +18,7 @@ describe('Break command inside a loop', () => {
         }
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 3 - 5
tests/test09.spec.js

@@ -2,11 +2,10 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
-import {
-    SyntaxError
-} from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
 
 describe('Break command outside a loop', () => {
+
     let input = `funcao inteiro test(real i) {
       inteiro a = 5 + i
       a = 5 + G[i][6]
@@ -15,8 +14,7 @@ describe('Break command outside a loop', () => {
       }
       pare
     }`;
-    const lexer = Lexers['pt_br'];
-
+    const lexer = LanguageService.getCurrentLexer();
     it(`should result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);
         const fun = as.parseFunction.bind(as);

+ 3 - 1
tests/test10.spec.js

@@ -5,8 +5,10 @@ import {
 import {
     SyntaxError
 } from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
 
 describe('IfThenElseIfThenElse command chain', () => {
+
     let input = `funcao inteiro test(real i) {
       inteiro a = 5 + i
       a = 5 + G[i][6]
@@ -18,7 +20,7 @@ describe('IfThenElseIfThenElse command chain', () => {
         a = -1
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 3 - 1
tests/test11.spec.js

@@ -5,8 +5,10 @@ import {
 import {
     SyntaxError
 } from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
 
 describe('DoWhile command', () => {
+
     let input = `funcao inteiro test(real i) {
       inteiro a = 5 + i
       a = 5 + G[i][6]
@@ -14,7 +16,7 @@ describe('DoWhile command', () => {
         a = a + 1
       } enquanto (a > 5)
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 3 - 4
tests/test12.spec.js

@@ -2,11 +2,10 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
-import {
-    SyntaxError
-} from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
 
 describe('SwitchCase command', () => {
+
     let input = `funcao inteiro test(real i) {
       escolha (i) {
         caso 1:
@@ -15,7 +14,7 @@ describe('SwitchCase command', () => {
           retorne 4
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 3 - 1
tests/test13.spec.js

@@ -2,8 +2,10 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
+import { LanguageService } from '../js/services/languageService';
 
 describe('A complete program code', () => {
+
     let input = `programa {
       
       const real PI = 5.7e-10
@@ -18,7 +20,7 @@ describe('A complete program code', () => {
         }
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 4 - 4
tests/test14.spec.js

@@ -2,11 +2,11 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
-import {
-    SyntaxError
-} from './../js/ast/SyntaxError';
+import { LanguageService } from '../js/services/languageService';
+
 
 describe('For with no \';\'', () => {
+
     let input = `funcao inteiro test(real i) {
       inteiro a = 5 + i
       a = 5 + G[i][6]
@@ -16,7 +16,7 @@ describe('For with no \';\'', () => {
          a = a
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 3 - 1
tests/test15.spec.js

@@ -2,8 +2,10 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
+import { LanguageService } from '../js/services/languageService';
 
 describe('A start function with no return type', () => {
+
     let input = `programa {
       
       const real PI = 5.5
@@ -23,7 +25,7 @@ describe('A start function with no return type', () => {
         }
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 3 - 1
tests/test16.spec.js

@@ -2,8 +2,10 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
+import { LanguageService } from '../js/services/languageService';
 
 describe('Variable declaration inside a function', () => {
+
     let input = `programa {
       
       const real PI = 5.5
@@ -24,7 +26,7 @@ describe('Variable declaration inside a function', () => {
         }
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not result in SyntaxError`, () => {
         const as = new IVProgParser(input, lexer);

+ 3 - 1
tests/test17.spec.js

@@ -6,8 +6,10 @@ import {Types} from './../js/ast/types';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
+import { LanguageService } from '../js/services/languageService';
 
 describe('Variable declaration inside a function', () => {
+
     let input = `programa {
 
       funcao inicio() {
@@ -15,7 +17,7 @@ describe('Variable declaration inside a function', () => {
         a = a + 1
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     const ast = {
       global: [ ],

+ 3 - 1
tests/test18.spec.js

@@ -5,8 +5,10 @@ import {Types} from './../js/ast/types';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
+import { LanguageService } from '../js/services/languageService';
 
 describe('Call to a function that receives no parameter', () => {
+
     let input = `programa {
 
       funcao inicio() {
@@ -18,7 +20,7 @@ describe('Call to a function that receives no parameter', () => {
         retorne
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not throw an Error`, () => {
         const as = new IVProgParser(input, lexer);

+ 2 - 1
tests/test19.spec.js

@@ -2,6 +2,7 @@ import Lexers from './../grammar/';
 import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('Multi(*) operation', function () {
 
@@ -13,7 +14,7 @@ describe('Multi(*) operation', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should have higher priority than Sum(+)`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 3 - 1
tests/test20.spec.js

@@ -2,9 +2,11 @@ import Lexers from './../grammar/';
 import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('An Array initialization with expressions', function () {
 
+
   const input = `programa {
 
     funcao inicio() {
@@ -12,7 +14,7 @@ describe('An Array initialization with expressions', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
   const result = [4,15];
 
   it(`should produce a valid state`, function (done) {

+ 2 - 1
tests/test21.spec.js

@@ -2,6 +2,7 @@ import Lexers from './../grammar/';
 import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('A call to a function that returns a valid type', function () {
 
@@ -17,7 +18,7 @@ describe('A call to a function that returns a valid type', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
   const result = 2;
 
   it(`should produce a valid state`, function (done) {

+ 3 - 1
tests/test22.spec.js

@@ -1,9 +1,11 @@
 import Lexers from './../grammar/';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('An assignment to a variable', function () {
 
+
   const input = `programa {
 
     funcao inicio() {
@@ -12,7 +14,7 @@ describe('An assignment to a variable', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should respect the variable type`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 3 - 1
tests/test23.spec.js

@@ -2,8 +2,10 @@ import Lexers from './../grammar/';
 import {
     IVProgParser
 } from './../js/ast/ivprogParser';
+import { LanguageService } from '../js/services/languageService';
 
 describe('Variable initialization with a function call', () => {
+
     let input = `programa {
 
       funcao inicio() {
@@ -14,7 +16,7 @@ describe('Variable initialization with a function call', () => {
         retorne a * 2
       }
     }`;
-    const lexer = Lexers['pt_br'];
+    const lexer = LanguageService.getCurrentLexer();
 
     it(`should not throw an Error`, () => {
         const as = new IVProgParser(input, lexer);

+ 2 - 1
tests/test24.spec.js

@@ -1,6 +1,7 @@
 import Lexers from './../grammar/';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('Command Do...While', function () {
 
@@ -14,7 +15,7 @@ describe('Command Do...While', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should result in a valid state`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 1
tests/test25.spec.js

@@ -2,6 +2,7 @@ import Lexers from './../grammar/';
 import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('Assigning an ID to another variable', function () {
 
@@ -13,7 +14,7 @@ describe('Assigning an ID to another variable', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should result in a valid state`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 1
tests/test26.spec.js

@@ -2,6 +2,7 @@ import Lexers from './../grammar/';
 import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('Assigning a line from a matrix to another vector', function () {
 
@@ -13,7 +14,7 @@ describe('Assigning a line from a matrix to another vector', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should result in a valid state`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 1
tests/test27.spec.js

@@ -2,6 +2,7 @@ import Lexers from './../grammar/';
 import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('A finite while loop', function () {
 
@@ -17,7 +18,7 @@ describe('A finite while loop', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should terminate`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 1
tests/test28.spec.js

@@ -2,6 +2,7 @@ import Lexers from './../grammar/';
 import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('A break command inside a inner while loop', function () {
 
@@ -19,7 +20,7 @@ describe('A break command inside a inner while loop', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should terminate the inner while only`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 1
tests/test29.spec.js

@@ -2,6 +2,7 @@ import Lexers from './../grammar/';
 import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('A break command inside a for loop', function () {
 
@@ -15,7 +16,7 @@ describe('A break command inside a for loop', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should terminate it`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 1
tests/test30.spec.js

@@ -2,6 +2,7 @@ import Lexers from './../grammar/';
 import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('A break command inside a switch..case', function () {
 
@@ -25,7 +26,7 @@ describe('A break command inside a switch..case', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should terminate it`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 1
tests/test31.spec.js

@@ -2,6 +2,7 @@ import Lexers from './../grammar/';
 import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('A case without return/break', function () {
 
@@ -24,7 +25,7 @@ describe('A case without return/break', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should fall through`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 2
tests/test33.spec.js

@@ -1,6 +1,6 @@
-import Lexers from './../grammar/';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('A non-const global variable', function () {
 
@@ -24,7 +24,7 @@ describe('A non-const global variable', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should be modifiable inside a function`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 3
tests/test34.spec.js

@@ -1,9 +1,8 @@
-import Lexers from './../grammar/';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('IfThenElse command ', function () {
-
   let input = `programa {
 
     funcao inicio() {
@@ -18,7 +17,7 @@ describe('IfThenElse command ', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should produce a valid state`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 1
tests/test35.spec.js

@@ -1,6 +1,7 @@
 import Lexers from './../grammar/';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { LanguageService } from '../js/services/languageService';
 
 describe('A recursive call', function () {
 
@@ -21,7 +22,7 @@ describe('A recursive call', function () {
     }
   }`;
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should produce a valid state`, function (done) {
     const parser = new IVProgParser(input, lexer);

+ 2 - 1
tests/test37.spec.js

@@ -2,6 +2,7 @@ import Lexers from './../grammar/';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
 import { InputTest } from './../js/util/inputTest';
+import { LanguageService } from '../js/services/languageService';
 
 describe('The read function', function () {
 
@@ -15,7 +16,7 @@ describe('The read function', function () {
 
   const input = new InputTest(['0xff']);
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should read data from the input and convert it to the appropriate type`, function (done) {
     const parser = new IVProgParser(code, lexer);

+ 2 - 2
tests/test38.spec.js

@@ -1,7 +1,7 @@
-import Lexers from './../grammar/';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
 import { OutputTest } from './../js/util/outputTest';
+import { LanguageService } from '../js/services/languageService';
 
 describe('The write function', function () {
 
@@ -15,7 +15,7 @@ describe('The write function', function () {
 
   const output = new OutputTest();
 
-  const lexer = Lexers['pt_br'];
+  const lexer = LanguageService.getCurrentLexer();
 
   it(`should print the value passed to it, no matter it's type`, function (done) {
     const parser = new IVProgParser(code, lexer);

+ 29 - 0
tests/test40.spec.js

@@ -0,0 +1,29 @@
+import { IVProgParser } from './../js/ast/ivprogParser';
+import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+import { OutputTest } from './../js/util/outputTest';
+import { LanguageService } from '../js/services/languageService';
+
+describe('The LanguageService', function () {
+
+  const code = `program {
+
+    function start() {
+      real a = 8.01
+      write(a)
+    }
+  }`;
+
+  const output = new OutputTest();
+  localStorage.setItem('ivprog.lang', 'en');
+  const lexer = LanguageService.getCurrentLexer();
+
+  it(`should provide the appropriate lexer`, function (done) {
+    const parser = new IVProgParser(code, lexer);
+    const exec = new IVProgProcessor(parser.parseTree());
+    exec.registerOutput(output);
+    exec.interpretAST().then(sto => {
+      expect(output.list).toEqual(['8.01']);
+      done();
+    }).catch( err => done(err));
+  });
+});