1 28 package org.jruby.lexer.yacc; 29 30 public class SourcePositionFactory implements ISourcePositionFactory { 31 private SourcePosition lastPosition = new SourcePosition(); 33 private LexerSource source; 34 35 public SourcePositionFactory(LexerSource source) { 36 this.source = source; 37 } 38 39 public ISourcePosition getPosition(ISourcePosition startPosition, boolean inclusive) { 40 41 if (startPosition == null) { 42 lastPosition = new SourcePosition(source.getFilename(), lastPosition.getEndLine(), 43 source.getLine(), lastPosition.getEndOffset(), source.getOffset()); 44 } else if (inclusive) { 45 lastPosition = new SourcePosition(source.getFilename(), startPosition.getStartLine(), 46 source.getLine(), startPosition.getStartOffset(), source.getOffset()); 47 } else { 48 lastPosition = new SourcePosition(source.getFilename(), startPosition.getEndLine(), 49 source.getLine(), startPosition.getEndOffset(), source.getOffset()); 50 } 51 52 return lastPosition; 53 } 54 55 public ISourcePosition getDummyPosition() { 56 return new SourcePosition("", -1, -1, 0, 0); 57 } 58 } 59 | Popular Tags |