Bonjour,
j'aimerai si c'est possible comprendre le code suivant, c'est un code d'un fichier .cup pour un parseur.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
parser code {:
   public boolean parsing_failed = false;
   public String source_filename;
 
   public parser(Lexer mylexer, String fname) 
   {
    super(mylexer);
   	source_filename = fname;
   }
 
 
   public SrcLoc sLoc(java_cup.runtime.Symbol token) {return new SrcLoc(token.left, token.right, source_filename);}
 
   public void syntax_error(java_cup.runtime.Symbol cur_token) {
   	   parsing_failed = true;
   	   System.err.println("Syntax error " + sLoc(cur_token).toString() + " Got: " + cur_token.toString());
   }
 
   public boolean hasFailed() { return parsing_failed;}
:}
Nad