1 8 13 package jfun.parsec; 14 15 16 17 22 final class ScannerState extends ParseContext { 23 private final CharSequence src; 24 private final int len; 25 ScannerState(final CharSequence src, 26 int a, final String module, final PositionMap pmap, 27 final Object ustate){ 28 super(ustate, a, module, pmap); 29 this.src = src; 30 this.len = src.length(); 31 } 32 ScannerState(final CharSequence src, int a, 33 final String module, final PositionMap pmap, 34 int l, final Object ustate){ 35 super(ustate, a, module, pmap); 36 this.src = src; 37 this.len = l; 38 } 39 ScannerState(final CharSequence src, int a, 40 final String module, final PositionMap pmap, 41 int l, final Object r, 42 final Object ustate){ 43 super(r, ustate, a, module, pmap); 44 this.src = src; 45 this.len = l; 46 } 47 char peekChar(){ 48 return src.charAt(at); 49 } 50 boolean isEof(){ 51 return len == at; 52 } 53 CharSequence getSource(){ 54 return src; 55 } 56 int length(){return len;} 57 58 61 int getIndex() { 62 return at; 63 } 64 65 68 Tok getToken() { 69 throw new IllegalStateException ("Parser not on token level"); 70 } 71 72 73 74 77 ParsecError getSysUnexpected() { 78 final String msg = (len==at)?"EOF":(""+src.charAt(at)); 79 return ParsecError.raiseSysUnexpected(getIndex(), msg); 80 } 81 } 82 | Popular Tags |