From d24d2b9ad9b5c895020b56f700a72906346482e5 Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 10 Aug 2014 01:03:40 -0400 Subject: completely re-wrote token recognizer to bootstrap from Procyon's AST changed imports to guava instead of whatever collections library happened to be on my classpath --- src/cuchaz/enigma/analysis/Token.java | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/cuchaz/enigma/analysis/Token.java (limited to 'src/cuchaz/enigma/analysis/Token.java') diff --git a/src/cuchaz/enigma/analysis/Token.java b/src/cuchaz/enigma/analysis/Token.java new file mode 100644 index 0000000..74023e3 --- /dev/null +++ b/src/cuchaz/enigma/analysis/Token.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2014 Jeff Martin. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Public License v3.0 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/gpl.html + * + * Contributors: + * Jeff Martin - initial API and implementation + ******************************************************************************/ +package cuchaz.enigma.analysis; + +public class Token implements Comparable +{ + public int start; + public int end; + + public Token( int start, int end ) + { + this.start = start; + this.end = end; + } + + public boolean contains( int pos ) + { + return pos >= start && pos <= end; + } + + @Override + public int compareTo( Token other ) + { + return start - other.start; + } + + @Override + public boolean equals( Object other ) + { + if( other instanceof Token ) + { + return equals( (Token)other ); + } + return false; + } + + public boolean equals( Token other ) + { + return start == other.start && end == other.end; + } +} -- cgit v1.2.3