Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <collezione_film><film></film></collezione_film>
  2.  
  3. %%
  4. %byaccj
  5.  
  6. %{
  7.  
  8. private Parser yyparser;
  9. public Yylex(java.io.Reader r, Parser yyparser) {
  10. this(r);
  11. this.yyparser = yyparser;
  12. }
  13. %}
  14.  
  15. %x IN_GROUP IN_PROPERTY
  16.  
  17. %state COLLEZIONE_FILM
  18.  
  19. TAG_COLLEZIONE_FILM_START = <collezione_film>
  20. TAG_FILM_OPEN_START = <film+[ t]
  21. %%
  22.  
  23. <YYINITIAL> {
  24. {TAG_COLLEZIONE_FILM_START} {
  25. yyparser.yylval = new ParserVal("collezione_film");
  26. yybegin(COLLEZIONE_FILM);
  27. return Parser.TAG_START;
  28. }
  29. [^] { /* Non fare nulla */ }
  30. }
  31.  
  32. <COLLEZIONE_FILM> {
  33. {TAG_FILM_OPEN_START} {
  34. yyparser.yylval = new ParserVal("film");
  35. return Parser.TAG_START;
  36. }
  37. [^] { /* Non fare nulla */ }
  38. }
  39.  
  40. %token<sval> TAG_START
  41. %type<sval> tags
  42.  
  43. %%
  44.  
  45. config : tags { System.out.print($1); }
  46.  
  47. tags : TAG_START tags {
  48. $$ = $1 + " " + $2;
  49. }
  50. | TAG_START { $$ = $1; }
  51. ;
  52.  
  53. %%
  54.  
  55. private Yylex lexer;
  56. private int yylex () {
  57. int yyl_return = -1;
  58. try {
  59. yylval = new ParserVal(0);
  60. yyl_return = lexer.yylex();
  61. }
  62. catch (java.io.IOException e) {
  63. System.err.println("IO error :"+e);
  64. }
  65. return yyl_return;
  66. }
  67.  
  68. public void yyerror (String error) {
  69. System.err.println ("Error: " + error);
  70. }
  71.  
  72. public Parser(java.io.Reader r) {
  73. lexer = new Yylex(r, this);
  74. }
  75.  
  76. public static void main(String args[]) throws java.io.IOException {
  77. Parser yyparser;
  78. if ( args.length > 0 ) {
  79. yyparser = new Parser(new java.io.FileReader(args[0]));
  80. yyparser.yyparse();
  81. }
  82. else {
  83. System.out.println("Nessun file specificato.");
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement