Advertisement
IcaroPeretti

Comentarios.jj

May 27th, 2021
969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. options
  2. {
  3.  static = false;
  4.  DEBUG_PARSER=true;
  5. }
  6. PARSER_BEGIN(Comentarios)
  7.  
  8. import java.io.FileInputStream;
  9. import java.io.File;
  10. import java.io.IOException;
  11. public class Comentarios
  12. {
  13.  public static void main(String args []) throws ParseException
  14.  {
  15.  try
  16.  {
  17.  System.out.println("Lendo arquivo fonte...");
  18.  FileInputStream fis = new FileInputStream(new File("..//JavaCC//src//comentarios.txt"));
  19.  Comentarios parser = new Comentarios(fis);
  20.  parser.Start();
  21.  System.out.println("Arquivo fonte processado corretamente!");
  22.  }
  23.  catch (IOException e)
  24.  {
  25.  System.out.println("Falha ao abrir arquivo fonte.");
  26.  System.exit(0);
  27.  }
  28.  }
  29. }
  30. PARSER_END(Comentarios)
  31.  
  32. SKIP : { " "| "\t" | "\n" | "\r" }
  33.  
  34.  
  35. TOKEN:
  36. {
  37.   //Tudo menos nova linha e enter
  38.   < SINGLE_LINE: "//" (~["\n"])* "\n" >
  39. }
  40.  
  41. TOKEN:
  42. {
  43.  
  44.   < MULTIPLE_LINE: "/*" (~["*"])* "*" (~["*","/"] (~["*"])* "*" | "*")* "/">
  45. }
  46.  
  47. void Start() :
  48. { }
  49. {
  50.     (
  51.         (< SINGLE_LINE > | <MULTIPLE_LINE >)* < EOF >
  52.     )
  53. }
  54.  
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement