Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhemmgt committed May 30, 2024
2 parents f7d2c01 + fb86442 commit 804221b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
9 changes: 7 additions & 2 deletions fr.n7.stl.block/parser.cup
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ Elements ::= Main:main
Class ::= UL_Classe UL_Identificateur:identifiant SingleInherits:inheritedClass
UL_Accolade_Ouvrante ClassElements:classElements UL_Accolade_Fermante
{:
RESULT = new ClassDeclaration(identifiant, classElements, false, inheritedClass);
RESULT = new ClassDeclaration(identifiant, classElements, false, inheritedClass, false);
:}
| UL_Definitif UL_Classe UL_Identificateur:identifiant SingleInherits:inheritedClass
UL_Accolade_Ouvrante ClassElements:classElements UL_Accolade_Fermante
{:
RESULT = new ClassDeclaration(identifiant, classElements, false, inheritedClass, true);
:}
;

Expand All @@ -277,7 +282,7 @@ Main ::= UL_Public UL_Classe UL_Classe_Principale
MethodDeclaration methodePrincipale = new MethodDeclaration(new Signature(AtomicType.VoidType, "main", parametres), block, false, true, false);
List<ClassElement> l = new ArrayList<ClassElement>();
l.add(methodePrincipale);
RESULT = new ClassDeclaration("Main", l, false, null);
RESULT = new ClassDeclaration("Main", l, false, null, false);
:}
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ClassDeclaration implements Declaration, Scope<ClassElement>{
private HierarchicalScope<Declaration> locals;
private List<ClassElement> elements;
private boolean isAbstract;
private boolean isFinal;
private String name;
private ClassType inheritedClassType; // null si pas héritée
private ClassDeclaration inheritedClass; // pas de valeur avant resolve
Expand All @@ -43,10 +44,11 @@ public class ClassDeclaration implements Declaration, Scope<ClassElement>{
* @param _constructors Sequence of methods to initialize the content of the class type.
* @param _isAbstract Boolean valued at true if the class is abstract
*/
public ClassDeclaration(String _name, Iterable<ClassElement> _elements, boolean _isAbstract, ClassType inheritedClassType) {
public ClassDeclaration(String _name, Iterable<ClassElement> _elements, boolean _isAbstract, ClassType inheritedClassType, boolean isFinal) {
this.name = _name;
this.isAbstract = _isAbstract;
this.inheritedClassType = inheritedClassType;
this.isFinal = isFinal;

this.elements = new LinkedList<ClassElement>();
for (ClassElement _element : _elements) {
Expand Down
17 changes: 17 additions & 0 deletions fr.n7.stl.block/test-mjava/KO_testA3.mjava
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
final class A {

}

class B extends A {

public B() {
}

}
public class Main {

public static void main (String args) {
B b = new B();
}

}

0 comments on commit 804221b

Please sign in to comment.