syntax.spec.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import Lexers from './../grammar/';
  2. import {
  3. IVProgParser
  4. } from './../js/ast/ivprogParser';
  5. describe("Testing Syntax Analysis for default", () => {
  6. var input;
  7. var asa;
  8. var lexer;
  9. it("it should produce a valid tree", () => {
  10. lexer = Lexers['pt_br'];
  11. input = `programa {
  12. const real PI
  13. const inteiro a[5][5]
  14. }`;
  15. asa = {
  16. global: [{
  17. isConst: true,
  18. tipo: 'real',
  19. id: 'PI',
  20. lines: null,
  21. columns: null,
  22. initial: null
  23. }, {
  24. isConst: true,
  25. tipo: 'int',
  26. id: 'a',
  27. lines: {
  28. type: 'int',
  29. value: 5
  30. },
  31. columns: {
  32. type: 'int',
  33. value: 5
  34. },
  35. initial: null
  36. }],
  37. functions: []
  38. };
  39. const as = new IVProgParser(input, lexer);
  40. expect(as.parseTree()).toEqual(asa);
  41. });
  42. });