/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.php; import gplx.*;
public interface Php_tkn {
	byte Tkn_tid();
	int Src_bgn();
	int Src_end();
}
class Php_tkn_ {
	public static final byte Tid_txt = 1, Tid_declaration = 2, Tid_ws = 3, Tid_comment = 4, Tid_var = 5, Tid_eq = 6, Tid_eq_kv = 7, Tid_semic = 8, Tid_comma = 9, Tid_paren_bgn = 10, Tid_paren_end = 11, Tid_null = 12, Tid_false = 13, Tid_true = 14, Tid_ary = 15, Tid_num = 16, Tid_quote = 17, Tid_brack_bgn = 18, Tid_brack_end = 19;
	public static String Xto_str(byte tid) {return Byte_.Xto_str(tid);}
}
abstract class Php_tkn_base implements Php_tkn {
	public abstract byte Tkn_tid();
	public int Src_bgn() {return src_bgn;} private int src_bgn;
	public int Src_end() {return src_end;} public void Src_end_(int v) {this.src_end = v;} private int src_end;
	public void Src_rng_(int src_bgn, int src_end) {this.src_bgn = src_bgn; this.src_end = src_end;}
}
class Php_tkn_generic extends Php_tkn_base {
	public Php_tkn_generic(int src_bgn, int src_end, byte tid) {this.Src_rng_(src_bgn, src_end); this.tid = tid;}
	@Override public byte Tkn_tid() {return tid;} private byte tid;
}
class Php_tkn_txt extends Php_tkn_base {
	public Php_tkn_txt(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
	@Override public byte Tkn_tid() {return Php_tkn_.Tid_txt;}
}
class Php_tkn_ws extends Php_tkn_base {
	public Php_tkn_ws(int src_bgn, int src_end, byte ws_tid) {this.Src_rng_(src_bgn, src_end); this.ws_tid = ws_tid;}
	@Override public byte Tkn_tid() {return Php_tkn_.Tid_ws;}
	public byte Ws_tid() {return ws_tid;} private byte ws_tid;
	public static final byte Tid_space = 0, Tid_nl = 1, Tid_tab = 2, Tid_cr = 3;
}
class Php_tkn_comment extends Php_tkn_base {
	public Php_tkn_comment(int src_bgn, int src_end, byte comment_tid) {this.Src_rng_(src_bgn, src_end); this.comment_tid = comment_tid;}
	@Override public byte Tkn_tid() {return Php_tkn_.Tid_comment;}
	public byte Comment_tid() {return comment_tid;} private byte comment_tid;
	public static final byte Tid_null = 0, Tid_mult = 1, Tid_slash = 2, Tid_hash = 3;
}
class Php_tkn_var extends Php_tkn_base {
	public Php_tkn_var(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
	@Override public byte Tkn_tid() {return Php_tkn_.Tid_var;}
	public byte[] Var_name(byte[] src) {return Bry_.Mid(src, this.Src_bgn() + 1, this.Src_end());}	// NOTE: assume vars are of form $abc; +1 to skip first $
}
class Php_tkn_num extends Php_tkn_base {
	public Php_tkn_num(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
	@Override public byte Tkn_tid() {return Php_tkn_.Tid_num;}
	public int Num_val_int(byte[] src) {return Bry_.Xto_int_or(src, this.Src_bgn(), this.Src_end(), Int_.MinValue);}
}
class Php_tkn_quote extends Php_tkn_base {
	public Php_tkn_quote(int src_bgn, int src_end, byte quote_tid) {this.Src_rng_(src_bgn, src_end); this.quote_tid = quote_tid;}
	@Override public byte Tkn_tid() {return Php_tkn_.Tid_quote;}
	public byte Quote_tid() {return quote_tid;} private byte quote_tid;
	public byte[] Quote_text(byte[] src) {return Bry_.Mid(src, this.Src_bgn() + 1, this.Src_end() - 1);}	// NOTE: assume quote are of form 'abc'; +1, -1 to skip flanking chars
	public static final byte Tid_null = 0, Tid_mult = 1, Tid_slash = 2, Tid_hash = 3;
}
class Php_tkn_declaration extends Php_tkn_base {
	@Override public byte Tkn_tid() {return Php_tkn_.Tid_declaration;}
	public static final Php_tkn_declaration _ = new Php_tkn_declaration();	
}
