Javacc et calcul du nombre d'appel d'unefonction ( )
Bonjour,
j'ai généré un parseur par l'outil JavaCC.
par la suite, je souhaite calculer le nombre d'appel d'une fonction dans le fichier d'entrée de DATA ( input file stream ).
MyProgram est défini par JavaCC rules suivant :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| TOKEN : { <id : ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","0"-"9","_"])* >}
MyProgram ():{}
{
(MyMethod ())*
}
MyMethod () {}
{
<method> <id> "(" (Argument ()) * ")" {}
(Statement ()) *
return String
<end_method>
}
Argument void () {}
{
<STRING> <id>
<STRING> <id>
}
void statement () {}
{
// here Call_MyMethod () is used for calling the method defined by the<id> and its parameters
Call_MyMethod ()
statementType2 ()
...........
}
// Javacc rules of Call_MyMethod ()
Call_MyMethod void () {}
{
<id> "(" (
ExpressionTreeStructure ()
(
"," ExpressionTreeStructure ()
) *
) *
")"
}
ExpressionTreeStructure void () {}
{
......
} |
input file stream is :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| <method> id1 ( String sid11, String sid12)
statement11
statement12
return String1
<end_method>
<method> id2 ( String sid21, String sid22)
statement21
id1(sid1,sid2) // call of Method the name id1 with argument sid11 and sid12
return String2
<end_method>
<method> id3 ( String sid31, String sid32)
id1(sid1,sid2) // call of Method the name id1 with argument sid11 and sid12
statement32
return String3
<end_method>
<method> id4 ( String sid41, String sid42)
id1(sid1,sid2) // call of Method the name id1 with argument sid11 and sid12
statement42
return String4
<end_method> |
ma question est comment compter le nombre d'appel de la méthode <method> défini par id2 qui est appelé par d'autres méthodes.
dans le cas de fichier d’entrée ( input file stream ) mentionnée ci-dessus :
3 est le nombre d'appel de la méthode défini par identifiant id1.
Merci d'avance de votre aide.