NumericSeparatorTransformer.js 492 B

1234567891011121314151617181920
  1. import {TokenType as tt} from "../parser/tokenizer/types";
  2. import Transformer from "./Transformer";
  3. export default class NumericSeparatorTransformer extends Transformer {
  4. constructor( tokens) {
  5. super();this.tokens = tokens;;
  6. }
  7. process() {
  8. if (this.tokens.matches1(tt.num)) {
  9. const code = this.tokens.currentTokenCode();
  10. if (code.includes("_")) {
  11. this.tokens.replaceToken(code.replace(/_/g, ""));
  12. return true;
  13. }
  14. }
  15. return false;
  16. }
  17. }