summaryrefslogtreecommitdiffstats
path: root/tp2-files
diff options
context:
space:
mode:
Diffstat (limited to 'tp2-files')
-rw-r--r--tp2-files/Calculatrice-final.jj40
1 files changed, 20 insertions, 20 deletions
diff --git a/tp2-files/Calculatrice-final.jj b/tp2-files/Calculatrice-final.jj
index 9a03f39..a7ea9f0 100644
--- a/tp2-files/Calculatrice-final.jj
+++ b/tp2-files/Calculatrice-final.jj
@@ -37,47 +37,47 @@ void boucle():
}
// Expression (axiome de la grammaire de la calculatrice)
-// expression → terme ( "+" terme | "-" terme )*
+// expression → term ( "+" term | "-" term )*
double expression():
{ double a,b; }
{
- a=terme()
+ a=term()
(
- "+" b=terme() { a += b; }
- | "-" b=terme() { a -= b; }
+ "+" b=term() { a += b; }
+ | "-" b=term() { a -= b; }
)* { return a; }
}
-// Terme d'une somme ou différence
-// terme → unaire ( "*" unaire | "/" unaire )*
-double terme():
+// Term d'une somme ou différence
+// term → factor ( "*" factor | "/" factor )*
+double term():
{ double a,b; }
{
- a=unaire()
+ a=factor()
(
- "*" b=unaire() { a *= b; }
- | "/" b=unaire() { a /= b; }
+ "*" b=factor() { a *= b; }
+ | "/" b=factor() { a /= b; }
)* { return a; }
}
-// Gestion du "+" et "−" unaires
-// unaire → puissance | "+" puissance | "-" puissance
-double unaire():
+// Gestion du "+" et "−" factors
+// factor → power | "+" power | "-" power
+double factor():
{ double a; }
{
- a=puissance() { return a; }
-| "+" a=puissance() { return a; }
-| "-" a=puissance() { return -a; }
+ a=power() { return a; }
+| "+" a=power() { return a; }
+| "-" a=power() { return -a; }
}
-// Opération puissance (associative à droite)
-// puissance → element ( "^" unaire )?
-double puissance():
+// Opération power (associative à droite)
+// power → element ( "^" factor )?
+double power():
{ double a,b; }
{
a=element()
(
- "^" b=unaire() { a = Math.pow(a,b); }
+ "^" b=factor() { a = Math.pow(a,b); }
)? { return a; }
}