Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.List;
- /**
- * @author Jack
- * @version 09/10/2016
- */
- public class Task1Test {
- public static void main(String[] args) {
- Lexer l = Task1.create();
- try {
- try(BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {
- StringBuilder sb = new StringBuilder();
- String line = br.readLine();
- while (line != null) {
- sb.append(line);
- sb.append(System.lineSeparator());
- line = br.readLine();
- }
- String everything = sb.toString();
- List<Token> tList = l.lex(everything);
- for(Token t : tList){
- if(t.getClass().equals(T_Identifier.class)){
- System.out.println(((T_Identifier) t).getClass() + " " +((T_Identifier) t).s);
- } else {
- System.out.println(t.getClass());
- }
- }
- } catch(IOException e){
- System.out.println("fuck");
- }
- }catch(LexicalException | Task1Exception e){
- System.out.print(((LexicalException)e).msg);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement