1
0

sourceInfo.js 702 B

1234567891011121314151617181920212223
  1. export class SourceInfo {
  2. static createSourceInfo (token) {
  3. return new SourceInfo(token.line, token.column, token.text, token.text.length);
  4. }
  5. static createSourceInfoFromList (tokenA, tokenB) {
  6. const line = tokenA.line;
  7. const column = tokenA.column;
  8. // adapted from https://github.com/UNIVALI-LITE/Portugol-Studio/blob/master/core/src/main/java/br/univali/portugol/nucleo/analise/sintatica/Portugol.g
  9. // No idea why...
  10. const size = tokenB.tokenIndex + 1 - tokenA.tokenIndex
  11. return new SourceInfo(line, column, "", size);
  12. }
  13. constructor (line, column, text, size) {
  14. this.line = line;
  15. this.column = column;
  16. this.text = text;
  17. this.size = size;
  18. }
  19. }