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