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/Lexer.java | 79 ----------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 src/cuchaz/enigma/analysis/Lexer.java (limited to 'src/cuchaz/enigma/analysis/Lexer.java') diff --git a/src/cuchaz/enigma/analysis/Lexer.java b/src/cuchaz/enigma/analysis/Lexer.java deleted file mode 100644 index 602e3a9..0000000 --- a/src/cuchaz/enigma/analysis/Lexer.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * 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; - -import java.util.Iterator; - -import jsyntaxpane.SyntaxDocument; -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; -import jsyntaxpane.lexers.JavaLexer; - -public class Lexer implements Iterable -{ - private SyntaxDocument m_doc; - private Iterator m_iter; - - public Lexer( CharSequence source ) - { - m_doc = new SyntaxDocument( new JavaLexer() ); - m_doc.append( source.toString() ); - m_iter = m_doc.getTokens( 0, m_doc.getLength() ); - } - - @Override - public Iterator iterator( ) - { - return m_iter; - } - - public String getText( Token token ) - { - return token.getString( m_doc ); - } - - public Token getFirstIdentifier( ) - { - for( Token token : this ) - { - if( token.type == TokenType.IDENTIFIER ) - { - return token; - } - } - return null; - } - - public Token getFirstIdentifierMatching( CharSequence val ) - { - for( Token token : this ) - { - if( token.type == TokenType.IDENTIFIER && getText( token ).equals( val.toString() ) ) - { - return token; - } - } - return null; - } - - public Token getLastIdentifier( ) - { - Token lastToken = null; - for( Token token : this ) - { - if( token.type == TokenType.IDENTIFIER ) - { - lastToken = token; - } - } - return lastToken; - } -} -- cgit v1.2.3