Advertisement
Guest User

j.h.

a guest
Oct 24th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileReader;
  3. import java.io.IOException;
  4. import java.util.List;
  5.  
  6. /**
  7. * @author Jack
  8. * @version 09/10/2016
  9. */
  10. public class Task1Test {
  11.  
  12.  
  13. public static void main(String[] args) {
  14. Lexer l = Task1.create();
  15. try {
  16. try(BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {
  17. StringBuilder sb = new StringBuilder();
  18. String line = br.readLine();
  19.  
  20. while (line != null) {
  21. sb.append(line);
  22. sb.append(System.lineSeparator());
  23. line = br.readLine();
  24. }
  25. String everything = sb.toString();
  26. List<Token> tList = l.lex(everything);
  27. for(Token t : tList){
  28. if(t.getClass().equals(T_Identifier.class)){
  29. System.out.println(((T_Identifier) t).getClass() + " " +((T_Identifier) t).s);
  30. } else {
  31. System.out.println(t.getClass());
  32. }
  33. }
  34. } catch(IOException e){
  35. System.out.println("fuck");
  36. }
  37. }catch(LexicalException | Task1Exception e){
  38. System.out.print(((LexicalException)e).msg);
  39. }
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement