SourceLocation

node v10.24.1
version: 1.0.0
endpointsharetweet
class SourceLocation { // not sure what is a lexer. a regex? or a token value? constructor(lexer, start, end) { this.lexer = lexer; this.start = start; this.end = end; } // SourceLocation.range({loc: {lexer: 'al', start: 3}}, {loc: {lexer: 'al', end: 10}}) // => SourceLocation {end: 10, lexer: "al", start: 3} static range( first, second) { if (!second) { return first && first.loc; } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { return null; } else { return new SourceLocation( first.loc.lexer, first.loc.start, second.loc.end); } } } module.exports = {SourceLocation}
Loading…

no comments

    sign in to comment