sourceInfo.js 657 B

12345678910111213141516171819202122
  1. export class SourceInfo {
  2. static createSourceInfo (token) {
  3. return new SourceInfo(token.line, token.column, token.text.length);
  4. }
  5. static createSourceInfoFromList (tokenA, tokenB) {
  6. const line = tokenA.line;
  7. const column = tokenA.column;
  8. // copied 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, size) {
  14. this.line = line;
  15. this.column = column;
  16. this.size = size;
  17. }
  18. }