comparison src/luan/parser/Parser.java @ 118:735708619119

add Debug.debug() git-svn-id: https://luan-java.googlecode.com/svn/trunk@119 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Sun, 01 Jun 2014 07:07:31 +0000
parents 754e6030c029
children cc3a0578edac
comparison
equal deleted inserted replaced
117:e935581cf9fb 118:735708619119
1 package luan.parser; 1 package luan.parser;
2
3 import luan.LuanSource;
2 4
3 5
4 public final class Parser { 6 public final class Parser {
7 private final LuanSource src;
5 public final String text; 8 public final String text;
6 private final int len; 9 private final int len;
7 private int[] stack = new int[256]; 10 private int[] stack = new int[256];
8 private int frame = 0; 11 private int frame = 0;
9 private int iHigh; 12 private int iHigh;
10 13
11 public Parser(String text) { 14 public Parser(LuanSource src) {
12 this.text = text; 15 this.src = src;
16 this.text = src.text;
13 this.len = text.length(); 17 this.len = text.length();
14 } 18 }
15 19
16 private int i() { 20 private int i() {
17 return stack[frame]; 21 return stack[frame];
58 frame--; 62 frame--;
59 return false; 63 return false;
60 } 64 }
61 65
62 public ParseException exception(String msg) { 66 public ParseException exception(String msg) {
63 return new ParseException(msg,text,i(),iHigh); 67 return new ParseException(msg,src,i(),iHigh);
64 } 68 }
65 69
66 public ParseException exception() { 70 public ParseException exception() {
67 return exception("Invalid input"); 71 return exception("Invalid input");
68 } 72 }