chore(build): setup gradle and antlr for v2

This commit is contained in:
Lucàs
2025-08-10 11:16:22 +02:00
parent cb9f0b1c3b
commit 789db5fa67
541 changed files with 541 additions and 84156 deletions
+59
View File
@@ -0,0 +1,59 @@
plugins {
java
application
id("com.diffplug.spotless") version "6.25.0"
id("antlr")
}
repositories {
mavenCentral()
}
spotless {
java {
googleJavaFormat()
}
}
dependencies {
implementation("org.antlr:antlr4-runtime:4.13.1")
antlr("org.antlr:antlr4:4.13.1")
implementation(libs.guava)
testImplementation(libs.junit.jupiter)
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
sourceSets {
main {
java {
srcDir("build/generated-src/antlr/main")
}
}
}
application {
mainClass.set("iut_rodez.lir_lang.App")
}
tasks.named<Test>("test") {
useJUnitPlatform()
}
tasks.named("build") {
}
tasks.named("run") {
}
tasks.named<AntlrTask>("generateGrammarSource") {
arguments = listOf("-visitor", "-long-messages")
}
@@ -0,0 +1,10 @@
grammar Lir;
@header {
package iut_rodez.lir_lang.core;
}
prog: INTEGER EOF;
INTEGER: [0-9]+;
WS: [ \t\r\n]+ -> skip;
@@ -0,0 +1,26 @@
/*
* App.java
*/
package iut_rodez.lir_lang;
import iut_rodez.lir_lang.core.LirLexer;
import iut_rodez.lir_lang.core.LirParser;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
/** Main application class for LIR language processing. */
public class App {
/**
* Main method to run the LIR parser.
*
* @param args Command line arguments (not used).
*/
public static void main(String[] args) {
LirLexer lexer = new LirLexer(CharStreams.fromString("10"));
LirParser parser = new LirParser(new CommonTokenStream(lexer));
ParseTree tree = parser.prog();
System.out.println(tree.toStringTree(parser));
}
}
+13
View File
@@ -0,0 +1,13 @@
10 affiche "Entre ton nom : "
20 entre $nom
30 affiche "Bienvenue "+$nom
35 affiche
40 var an=2021
50 affiche "Quelle est ton anne de naissance ? "
60 entre naissance
65 si naissance > an vaen 50
70 affiche "Tu as autour de "
80 affiche an-naissance
90 affiche "ans "
100 affiche
200 stop
+28
View File
@@ -0,0 +1,28 @@
10 affiche "Bienvenue dans le programme"
20 affiche
30 var instant = 2021
40 procedure 500
50 var $message = "Vous tes " + $prenom
60 var $message = $message + " "
65 var $message = $message + $nom
70 affiche $message
80 affiche
90 affiche "age : "
100 affiche age
110 affiche " ans"
120 vaen 150
124 affiche
125 affiche "erreur vaen si affich"
150 affiche
200 affiche "Merci d'avoir utilis ce programme !"
400 stop
500 affiche "Saisissez votre nom : "
510 entre $nom
520 affiche "Saisissez votre prnom : "
530 entre $prenom
540 affiche "Saisissez votre anne de naissance (entier) : "
550 entre naissance
560 procedure 1000
570 retour
1000 var age = instant - naissance
1010 retour
+35
View File
@@ -0,0 +1,35 @@
10 affiche "Bienvenue dans le programme factorielle.lir !"
20 affiche
30 affiche "Entrez un entier : "
40 entre entier
45 procedure 500
50 procedure 1000
60 affiche entier
70 affiche "! = "
80 affiche factorielle
90 affiche
200 stop
500 si entier >= 0 vaen 600
510 affiche "n! est dfinie sur l'ensemble des entiers naturels"
520 stop
600 retour
1000 var factorielle = 1
1010 var entierCourant = 2
1011 var ancienFactorielle = factorielle
1012 var test = factorielle
1015 si entierCourant > entier vaen 1100
1016 si ancienFactorielle <> test vaen 1060
1017 var ancienFactorielle = factorielle
1020 var factorielle = factorielle * entierCourant
1025 var test = factorielle / entierCourant
1030 var entierCourant = entierCourant + 1
1040 vaen 1015
1050 vaen 1100
1060 affiche "dpassement de la capacit des entiers pour "
1070 affiche entier
1080 affiche "!"
1090 affiche
1095 stop
1100 retour
+37
View File
@@ -0,0 +1,37 @@
10 affiche "Bienvenue dans le programme Median3Entiers.lir"
20 affiche
30 affiche "Entrez le premier entier : "
40 entre premier
50 affiche "Entrez le deuxime entier : "
60 entre deuxieme
70 affiche "Entrez le troisime entier : "
80 entre troisieme
90 procedure 1000
100 affiche "Median( "
110 affiche premier
120 affiche ", "
130 affiche deuxieme
140 affiche ", "
150 affiche troisieme
160 affiche ") = "
170 affiche median
180 affiche
250 stop
1000 si premier <= deuxieme vaen 1100
1010 si deuxieme <= troisieme vaen 1200
1020 vaen 1520
1100 si deuxieme <= troisieme vaen 1520
1110 si premier <= troisieme vaen 1540
1120 vaen 1500
1200 si premier <= troisieme vaen 1500
1220 vaen 1540
1500 var median = premier
1510 vaen 1550
1520 var median = deuxieme
1530 vaen 1550
1540 var median = troisieme
1550 retour