//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.workflow.script.compiler;

public final class Mark
{
	int cursor, line, col; // position within current stream

	char[] stream = null; // current stream
	private ScriptReader reader; // reader that owns this mark 

	String fileName; // name of the current file

	/**
	* Creates a new mark
	* @param inReader ScriptReader this mark belongs to
	* @param inStream current stream for this mark
	*/
	Mark(ScriptReader reader, char[] inStream, String name)
	{
		this.reader = reader;
		this.stream = inStream;
		this.cursor = this.line = this.col = 0;
		this.fileName = name;
	}
	Mark(Mark other)
	{
		this.reader = other.reader;
		this.stream = other.stream;
		this.fileName = other.fileName;
		this.cursor = other.cursor;
		this.line = other.line;
		this.col = other.col;
	}
	public String toString()
	{
		return getFile() + "(" + line + "," + col + ")";
	}
	public String getFile()
	{
		return this.fileName;
	}
	public String toShortString()
	{
		return "(" + line + "," + col + ")";
	}
	public boolean equals(Object other)
	{
		if (other instanceof Mark)
		{
			Mark m = (Mark) other;
			return this.reader == m.reader && this.cursor == m.cursor && this.line == m.line && this.col == m.col;
		}
		return false;
	}
}