mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-27 09:28:03 +00:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
bac72bdc81
@ -38,6 +38,7 @@ expr : expr binaryOp expr #BinaryOperation
|
||||
| '(' expr ')' #Expression
|
||||
| fieldVarAccess #Identifier
|
||||
| stmtexpr #StatementExpressionexpr
|
||||
| THIS #This
|
||||
| NULL #Null
|
||||
;
|
||||
|
||||
|
@ -53,12 +53,18 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
|
||||
}
|
||||
|
||||
public static Expression generateConstant(DecafParser.LiteralContext ctx) {
|
||||
if (ctx.NUMBER() != null)
|
||||
if (ctx.NUMBER() != null) {
|
||||
return new IntLiteral(Integer.valueOf(ctx.NUMBER().getText()));
|
||||
if (ctx.BOOLEANLITERAL() != null)
|
||||
}
|
||||
if (ctx.BOOLEANLITERAL() != null) {
|
||||
return new BoolLiteral(Boolean.valueOf(ctx.BOOLEANLITERAL().getText()));
|
||||
if (ctx.CHARLITERAL() != null)
|
||||
return new CharLiteral(ctx.CHARLITERAL().getText().charAt(0));
|
||||
}
|
||||
if (ctx.CHARLITERAL() != null) {
|
||||
if (ctx.CHARLITERAL().getText().length() != 3) {
|
||||
throw new RuntimeException("Wrong format for Char literal. Good format: 'c' Bad format: " + ctx.CHARLITERAL().getText());
|
||||
}
|
||||
return new CharLiteral(ctx.CHARLITERAL().getText().charAt(1));
|
||||
}
|
||||
throw new RuntimeException("No literal found!");
|
||||
}
|
||||
|
||||
@ -93,7 +99,7 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
|
||||
recursiveOwnerChain = generateRecursiveOwnerChain(recipientList, null);
|
||||
}
|
||||
List<Expression> args = new ArrayList<>();
|
||||
if(ctx.methCall().methName().args() != null){
|
||||
if (ctx.methCall().methName().args() != null) {
|
||||
for (var expr : ctx.methCall().methName().args().expr()) {
|
||||
Expression astExpr = expr.accept(this);
|
||||
args.add(astExpr);
|
||||
@ -115,6 +121,16 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
|
||||
return new New(type, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression visitNull(DecafParser.NullContext ctx){
|
||||
return new Null();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression visitThis(DecafParser.ThisContext ctx){
|
||||
return new This();
|
||||
}
|
||||
|
||||
public static Expression generateRecursiveOwnerChain(List<DecafParser.RecipientContext> ctxList, FieldVarAccess recipient) {
|
||||
if (ctxList.isEmpty()) {
|
||||
return recipient;
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
// Generated from C:/dev/Pressmium/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
@ -360,6 +360,18 @@ public class DecafBaseListener implements DecafListener {
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitBinaryOperation(DecafParser.BinaryOperationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterThis(DecafParser.ThisContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitThis(DecafParser.ThisContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/dev/Pressmium/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
||||
|
||||
@ -215,6 +215,13 @@ public class DecafBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitBinaryOperation(DecafParser.BinaryOperationContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitThis(DecafParser.ThisContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/dev/Pressmium/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/dev/Pressmium/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
|
||||
@ -331,6 +331,18 @@ public interface DecafListener extends ParseTreeListener {
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitBinaryOperation(DecafParser.BinaryOperationContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code This}
|
||||
* labeled alternative in {@link DecafParser#expr}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterThis(DecafParser.ThisContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by the {@code This}
|
||||
* labeled alternative in {@link DecafParser#expr}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitThis(DecafParser.ThisContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code StatementExpressionexpr}
|
||||
* labeled alternative in {@link DecafParser#expr}.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/dev/Pressmium/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
@ -1580,6 +1580,24 @@ public class DecafParser extends Parser {
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class ThisContext extends ExprContext {
|
||||
public TerminalNode THIS() { return getToken(DecafParser.THIS, 0); }
|
||||
public ThisContext(ExprContext ctx) { copyFrom(ctx); }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof DecafListener ) ((DecafListener)listener).enterThis(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof DecafListener ) ((DecafListener)listener).exitThis(this);
|
||||
}
|
||||
@Override
|
||||
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
|
||||
if ( visitor instanceof DecafVisitor ) return ((DecafVisitor<? extends T>)visitor).visitThis(this);
|
||||
else return visitor.visitChildren(this);
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class StatementExpressionexprContext extends ExprContext {
|
||||
public StmtexprContext stmtexpr() {
|
||||
return getRuleContext(StmtexprContext.class,0);
|
||||
@ -1615,7 +1633,7 @@ public class DecafParser extends Parser {
|
||||
int _alt;
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(212);
|
||||
setState(213);
|
||||
_errHandler.sync(this);
|
||||
switch ( getInterpreter().adaptivePredict(_input,16,_ctx) ) {
|
||||
case 1:
|
||||
@ -1627,7 +1645,7 @@ public class DecafParser extends Parser {
|
||||
setState(201);
|
||||
unaryOp();
|
||||
setState(202);
|
||||
expr(6);
|
||||
expr(7);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
@ -1672,16 +1690,25 @@ public class DecafParser extends Parser {
|
||||
break;
|
||||
case 6:
|
||||
{
|
||||
_localctx = new NullContext(_localctx);
|
||||
_localctx = new ThisContext(_localctx);
|
||||
_ctx = _localctx;
|
||||
_prevctx = _localctx;
|
||||
setState(211);
|
||||
match(THIS);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
{
|
||||
_localctx = new NullContext(_localctx);
|
||||
_ctx = _localctx;
|
||||
_prevctx = _localctx;
|
||||
setState(212);
|
||||
match(NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
_ctx.stop = _input.LT(-1);
|
||||
setState(220);
|
||||
setState(221);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,17,_ctx);
|
||||
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
|
||||
@ -1692,16 +1719,16 @@ public class DecafParser extends Parser {
|
||||
{
|
||||
_localctx = new BinaryOperationContext(new ExprContext(_parentctx, _parentState));
|
||||
pushNewRecursionContext(_localctx, _startState, RULE_expr);
|
||||
setState(214);
|
||||
if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)");
|
||||
setState(215);
|
||||
binaryOp();
|
||||
if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)");
|
||||
setState(216);
|
||||
expr(8);
|
||||
binaryOp();
|
||||
setState(217);
|
||||
expr(9);
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(222);
|
||||
setState(223);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,17,_ctx);
|
||||
}
|
||||
@ -1757,7 +1784,7 @@ public class DecafParser extends Parser {
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(223);
|
||||
setState(224);
|
||||
_la = _input.LA(1);
|
||||
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 17171480576L) != 0)) ) {
|
||||
_errHandler.recoverInline(this);
|
||||
@ -1810,7 +1837,7 @@ public class DecafParser extends Parser {
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(225);
|
||||
setState(226);
|
||||
_la = _input.LA(1);
|
||||
if ( !(_la==SUB || _la==NOT) ) {
|
||||
_errHandler.recoverInline(this);
|
||||
@ -1872,37 +1899,37 @@ public class DecafParser extends Parser {
|
||||
int _alt;
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(229);
|
||||
setState(230);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
if (_la==THIS) {
|
||||
{
|
||||
setState(227);
|
||||
match(THIS);
|
||||
setState(228);
|
||||
match(THIS);
|
||||
setState(229);
|
||||
match(T__17);
|
||||
}
|
||||
}
|
||||
|
||||
setState(236);
|
||||
setState(237);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,19,_ctx);
|
||||
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
|
||||
if ( _alt==1 ) {
|
||||
{
|
||||
{
|
||||
setState(231);
|
||||
recipient();
|
||||
setState(232);
|
||||
recipient();
|
||||
setState(233);
|
||||
match(T__17);
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(238);
|
||||
setState(239);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,19,_ctx);
|
||||
}
|
||||
setState(239);
|
||||
setState(240);
|
||||
id();
|
||||
}
|
||||
}
|
||||
@ -1953,11 +1980,11 @@ public class DecafParser extends Parser {
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(241);
|
||||
fieldVarAccess();
|
||||
setState(242);
|
||||
assignSign();
|
||||
fieldVarAccess();
|
||||
setState(243);
|
||||
assignSign();
|
||||
setState(244);
|
||||
expr(0);
|
||||
}
|
||||
}
|
||||
@ -2011,37 +2038,37 @@ public class DecafParser extends Parser {
|
||||
int _alt;
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(247);
|
||||
setState(248);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
if (_la==THIS) {
|
||||
{
|
||||
setState(245);
|
||||
match(THIS);
|
||||
setState(246);
|
||||
match(THIS);
|
||||
setState(247);
|
||||
match(T__17);
|
||||
}
|
||||
}
|
||||
|
||||
setState(254);
|
||||
setState(255);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,21,_ctx);
|
||||
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
|
||||
if ( _alt==1 ) {
|
||||
{
|
||||
{
|
||||
setState(249);
|
||||
recipient();
|
||||
setState(250);
|
||||
recipient();
|
||||
setState(251);
|
||||
match(T__17);
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(256);
|
||||
setState(257);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,21,_ctx);
|
||||
}
|
||||
setState(257);
|
||||
setState(258);
|
||||
methName();
|
||||
}
|
||||
}
|
||||
@ -2087,20 +2114,20 @@ public class DecafParser extends Parser {
|
||||
RecipientContext _localctx = new RecipientContext(_ctx, getState());
|
||||
enterRule(_localctx, 40, RULE_recipient);
|
||||
try {
|
||||
setState(261);
|
||||
setState(262);
|
||||
_errHandler.sync(this);
|
||||
switch ( getInterpreter().adaptivePredict(_input,22,_ctx) ) {
|
||||
case 1:
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(259);
|
||||
setState(260);
|
||||
methName();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
enterOuterAlt(_localctx, 2);
|
||||
{
|
||||
setState(260);
|
||||
setState(261);
|
||||
id();
|
||||
}
|
||||
break;
|
||||
@ -2151,21 +2178,21 @@ public class DecafParser extends Parser {
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(263);
|
||||
id();
|
||||
setState(264);
|
||||
id();
|
||||
setState(265);
|
||||
match(T__4);
|
||||
setState(266);
|
||||
setState(267);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 132216288968736L) != 0)) {
|
||||
{
|
||||
setState(265);
|
||||
setState(266);
|
||||
args();
|
||||
}
|
||||
}
|
||||
|
||||
setState(268);
|
||||
setState(269);
|
||||
match(T__5);
|
||||
}
|
||||
}
|
||||
@ -2214,21 +2241,21 @@ public class DecafParser extends Parser {
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(270);
|
||||
setState(271);
|
||||
expr(0);
|
||||
setState(275);
|
||||
setState(276);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
while (_la==T__9) {
|
||||
{
|
||||
{
|
||||
setState(271);
|
||||
match(T__9);
|
||||
setState(272);
|
||||
match(T__9);
|
||||
setState(273);
|
||||
expr(0);
|
||||
}
|
||||
}
|
||||
setState(277);
|
||||
setState(278);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
}
|
||||
@ -2276,7 +2303,7 @@ public class DecafParser extends Parser {
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(278);
|
||||
setState(279);
|
||||
_la = _input.LA(1);
|
||||
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 96757023244288L) != 0)) ) {
|
||||
_errHandler.recoverInline(this);
|
||||
@ -2327,7 +2354,7 @@ public class DecafParser extends Parser {
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(280);
|
||||
setState(281);
|
||||
match(IDENTIFIER);
|
||||
}
|
||||
}
|
||||
@ -2352,13 +2379,13 @@ public class DecafParser extends Parser {
|
||||
private boolean expr_sempred(ExprContext _localctx, int predIndex) {
|
||||
switch (predIndex) {
|
||||
case 0:
|
||||
return precpred(_ctx, 7);
|
||||
return precpred(_ctx, 8);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\u0004\u00011\u011b\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+
|
||||
"\u0004\u00011\u011c\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+
|
||||
"\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+
|
||||
"\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+
|
||||
"\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b\u0002"+
|
||||
@ -2388,32 +2415,32 @@ public class DecafParser extends Parser {
|
||||
"\r\u0001\r\u0001\r\u0003\r\u00c3\b\r\u0001\r\u0001\r\u0003\r\u00c7\b\r"+
|
||||
"\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e"+
|
||||
"\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e"+
|
||||
"\u0003\u000e\u00d5\b\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e"+
|
||||
"\u0005\u000e\u00db\b\u000e\n\u000e\f\u000e\u00de\t\u000e\u0001\u000f\u0001"+
|
||||
"\u000f\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0003\u0011\u00e6"+
|
||||
"\b\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0005\u0011\u00eb\b\u0011"+
|
||||
"\n\u0011\f\u0011\u00ee\t\u0011\u0001\u0011\u0001\u0011\u0001\u0012\u0001"+
|
||||
"\u0012\u0001\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0003\u0013\u00f8"+
|
||||
"\b\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0005\u0013\u00fd\b\u0013"+
|
||||
"\n\u0013\f\u0013\u0100\t\u0013\u0001\u0013\u0001\u0013\u0001\u0014\u0001"+
|
||||
"\u0014\u0003\u0014\u0106\b\u0014\u0001\u0015\u0001\u0015\u0001\u0015\u0003"+
|
||||
"\u0015\u010b\b\u0015\u0001\u0015\u0001\u0015\u0001\u0016\u0001\u0016\u0001"+
|
||||
"\u0016\u0005\u0016\u0112\b\u0016\n\u0016\f\u0016\u0115\t\u0016\u0001\u0017"+
|
||||
"\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0018\u0000\u0001\u001c\u0019"+
|
||||
"\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016\u0018\u001a"+
|
||||
"\u001c\u001e \"$&(*,.0\u0000\u0004\u0001\u0000\"%\u0001\u0000\u0017!\u0002"+
|
||||
"\u0000\u0017\u0017&&\u0002\u0000+,..\u0128\u00002\u0001\u0000\u0000\u0000"+
|
||||
"\u0002D\u0001\u0000\u0000\u0000\u0004J\u0001\u0000\u0000\u0000\u0006N"+
|
||||
"\u0001\u0000\u0000\u0000\bR\u0001\u0000\u0000\u0000\nX\u0001\u0000\u0000"+
|
||||
"\u0001\u000e\u0003\u000e\u00d6\b\u000e\u0001\u000e\u0001\u000e\u0001\u000e"+
|
||||
"\u0001\u000e\u0005\u000e\u00dc\b\u000e\n\u000e\f\u000e\u00df\t\u000e\u0001"+
|
||||
"\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0003"+
|
||||
"\u0011\u00e7\b\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0005\u0011\u00ec"+
|
||||
"\b\u0011\n\u0011\f\u0011\u00ef\t\u0011\u0001\u0011\u0001\u0011\u0001\u0012"+
|
||||
"\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0003\u0013"+
|
||||
"\u00f9\b\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0005\u0013\u00fe\b"+
|
||||
"\u0013\n\u0013\f\u0013\u0101\t\u0013\u0001\u0013\u0001\u0013\u0001\u0014"+
|
||||
"\u0001\u0014\u0003\u0014\u0107\b\u0014\u0001\u0015\u0001\u0015\u0001\u0015"+
|
||||
"\u0003\u0015\u010c\b\u0015\u0001\u0015\u0001\u0015\u0001\u0016\u0001\u0016"+
|
||||
"\u0001\u0016\u0005\u0016\u0113\b\u0016\n\u0016\f\u0016\u0116\t\u0016\u0001"+
|
||||
"\u0017\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0018\u0000\u0001\u001c"+
|
||||
"\u0019\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016\u0018"+
|
||||
"\u001a\u001c\u001e \"$&(*,.0\u0000\u0004\u0001\u0000\"%\u0001\u0000\u0017"+
|
||||
"!\u0002\u0000\u0017\u0017&&\u0002\u0000+,..\u012a\u00002\u0001\u0000\u0000"+
|
||||
"\u0000\u0002D\u0001\u0000\u0000\u0000\u0004J\u0001\u0000\u0000\u0000\u0006"+
|
||||
"N\u0001\u0000\u0000\u0000\bR\u0001\u0000\u0000\u0000\nX\u0001\u0000\u0000"+
|
||||
"\u0000\fZ\u0001\u0000\u0000\u0000\u000ed\u0001\u0000\u0000\u0000\u0010"+
|
||||
"m\u0001\u0000\u0000\u0000\u0012v\u0001\u0000\u0000\u0000\u0014~\u0001"+
|
||||
"\u0000\u0000\u0000\u0016\u0081\u0001\u0000\u0000\u0000\u0018\u00bb\u0001"+
|
||||
"\u0000\u0000\u0000\u001a\u00c6\u0001\u0000\u0000\u0000\u001c\u00d4\u0001"+
|
||||
"\u0000\u0000\u0000\u001e\u00df\u0001\u0000\u0000\u0000 \u00e1\u0001\u0000"+
|
||||
"\u0000\u0000\"\u00e5\u0001\u0000\u0000\u0000$\u00f1\u0001\u0000\u0000"+
|
||||
"\u0000&\u00f7\u0001\u0000\u0000\u0000(\u0105\u0001\u0000\u0000\u0000*"+
|
||||
"\u0107\u0001\u0000\u0000\u0000,\u010e\u0001\u0000\u0000\u0000.\u0116\u0001"+
|
||||
"\u0000\u0000\u00000\u0118\u0001\u0000\u0000\u000023\u0005\u0013\u0000"+
|
||||
"\u0000\u0000\u0000\u001a\u00c6\u0001\u0000\u0000\u0000\u001c\u00d5\u0001"+
|
||||
"\u0000\u0000\u0000\u001e\u00e0\u0001\u0000\u0000\u0000 \u00e2\u0001\u0000"+
|
||||
"\u0000\u0000\"\u00e6\u0001\u0000\u0000\u0000$\u00f2\u0001\u0000\u0000"+
|
||||
"\u0000&\u00f8\u0001\u0000\u0000\u0000(\u0106\u0001\u0000\u0000\u0000*"+
|
||||
"\u0108\u0001\u0000\u0000\u0000,\u010f\u0001\u0000\u0000\u0000.\u0117\u0001"+
|
||||
"\u0000\u0000\u00000\u0119\u0001\u0000\u0000\u000023\u0005\u0013\u0000"+
|
||||
"\u000034\u0005\u0001\u0000\u000045\u00030\u0018\u000057\u0005\u0002\u0000"+
|
||||
"\u000068\u0003\u000e\u0007\u000076\u0001\u0000\u0000\u000078\u0001\u0000"+
|
||||
"\u0000\u00008>\u0001\u0000\u0000\u00009=\u0003\u0002\u0001\u0000:=\u0003"+
|
||||
@ -2489,53 +2516,54 @@ public class DecafParser extends Parser {
|
||||
"\u0000\u00c5\u00c7\u0001\u0000\u0000\u0000\u00c6\u00bd\u0001\u0000\u0000"+
|
||||
"\u0000\u00c6\u00be\u0001\u0000\u0000\u0000\u00c7\u001b\u0001\u0000\u0000"+
|
||||
"\u0000\u00c8\u00c9\u0006\u000e\uffff\uffff\u0000\u00c9\u00ca\u0003 \u0010"+
|
||||
"\u0000\u00ca\u00cb\u0003\u001c\u000e\u0006\u00cb\u00d5\u0001\u0000\u0000"+
|
||||
"\u0000\u00cc\u00d5\u0003.\u0017\u0000\u00cd\u00ce\u0005\u0005\u0000\u0000"+
|
||||
"\u0000\u00ca\u00cb\u0003\u001c\u000e\u0007\u00cb\u00d6\u0001\u0000\u0000"+
|
||||
"\u0000\u00cc\u00d6\u0003.\u0017\u0000\u00cd\u00ce\u0005\u0005\u0000\u0000"+
|
||||
"\u00ce\u00cf\u0003\u001c\u000e\u0000\u00cf\u00d0\u0005\u0006\u0000\u0000"+
|
||||
"\u00d0\u00d5\u0001\u0000\u0000\u0000\u00d1\u00d5\u0003\"\u0011\u0000\u00d2"+
|
||||
"\u00d5\u0003\u001a\r\u0000\u00d3\u00d5\u0005\u0015\u0000\u0000\u00d4\u00c8"+
|
||||
"\u0001\u0000\u0000\u0000\u00d4\u00cc\u0001\u0000\u0000\u0000\u00d4\u00cd"+
|
||||
"\u0001\u0000\u0000\u0000\u00d4\u00d1\u0001\u0000\u0000\u0000\u00d4\u00d2"+
|
||||
"\u0001\u0000\u0000\u0000\u00d4\u00d3\u0001\u0000\u0000\u0000\u00d5\u00dc"+
|
||||
"\u0001\u0000\u0000\u0000\u00d6\u00d7\n\u0007\u0000\u0000\u00d7\u00d8\u0003"+
|
||||
"\u001e\u000f\u0000\u00d8\u00d9\u0003\u001c\u000e\b\u00d9\u00db\u0001\u0000"+
|
||||
"\u0000\u0000\u00da\u00d6\u0001\u0000\u0000\u0000\u00db\u00de\u0001\u0000"+
|
||||
"\u0000\u0000\u00dc\u00da\u0001\u0000\u0000\u0000\u00dc\u00dd\u0001\u0000"+
|
||||
"\u0000\u0000\u00dd\u001d\u0001\u0000\u0000\u0000\u00de\u00dc\u0001\u0000"+
|
||||
"\u0000\u0000\u00df\u00e0\u0007\u0001\u0000\u0000\u00e0\u001f\u0001\u0000"+
|
||||
"\u0000\u0000\u00e1\u00e2\u0007\u0002\u0000\u0000\u00e2!\u0001\u0000\u0000"+
|
||||
"\u0000\u00e3\u00e4\u0005\u0016\u0000\u0000\u00e4\u00e6\u0005\u0012\u0000"+
|
||||
"\u0000\u00e5\u00e3\u0001\u0000\u0000\u0000\u00e5\u00e6\u0001\u0000\u0000"+
|
||||
"\u0000\u00e6\u00ec\u0001\u0000\u0000\u0000\u00e7\u00e8\u0003(\u0014\u0000"+
|
||||
"\u00e8\u00e9\u0005\u0012\u0000\u0000\u00e9\u00eb\u0001\u0000\u0000\u0000"+
|
||||
"\u00ea\u00e7\u0001\u0000\u0000\u0000\u00eb\u00ee\u0001\u0000\u0000\u0000"+
|
||||
"\u00ec\u00ea\u0001\u0000\u0000\u0000\u00ec\u00ed\u0001\u0000\u0000\u0000"+
|
||||
"\u00ed\u00ef\u0001\u0000\u0000\u0000\u00ee\u00ec\u0001\u0000\u0000\u0000"+
|
||||
"\u00ef\u00f0\u00030\u0018\u0000\u00f0#\u0001\u0000\u0000\u0000\u00f1\u00f2"+
|
||||
"\u0003\"\u0011\u0000\u00f2\u00f3\u0003\u0006\u0003\u0000\u00f3\u00f4\u0003"+
|
||||
"\u001c\u000e\u0000\u00f4%\u0001\u0000\u0000\u0000\u00f5\u00f6\u0005\u0016"+
|
||||
"\u0000\u0000\u00f6\u00f8\u0005\u0012\u0000\u0000\u00f7\u00f5\u0001\u0000"+
|
||||
"\u0000\u0000\u00f7\u00f8\u0001\u0000\u0000\u0000\u00f8\u00fe\u0001\u0000"+
|
||||
"\u0000\u0000\u00f9\u00fa\u0003(\u0014\u0000\u00fa\u00fb\u0005\u0012\u0000"+
|
||||
"\u0000\u00fb\u00fd\u0001\u0000\u0000\u0000\u00fc\u00f9\u0001\u0000\u0000"+
|
||||
"\u0000\u00fd\u0100\u0001\u0000\u0000\u0000\u00fe\u00fc\u0001\u0000\u0000"+
|
||||
"\u0000\u00fe\u00ff\u0001\u0000\u0000\u0000\u00ff\u0101\u0001\u0000\u0000"+
|
||||
"\u0000\u0100\u00fe\u0001\u0000\u0000\u0000\u0101\u0102\u0003*\u0015\u0000"+
|
||||
"\u0102\'\u0001\u0000\u0000\u0000\u0103\u0106\u0003*\u0015\u0000\u0104"+
|
||||
"\u0106\u00030\u0018\u0000\u0105\u0103\u0001\u0000\u0000\u0000\u0105\u0104"+
|
||||
"\u0001\u0000\u0000\u0000\u0106)\u0001\u0000\u0000\u0000\u0107\u0108\u0003"+
|
||||
"0\u0018\u0000\u0108\u010a\u0005\u0005\u0000\u0000\u0109\u010b\u0003,\u0016"+
|
||||
"\u0000\u010a\u0109\u0001\u0000\u0000\u0000\u010a\u010b\u0001\u0000\u0000"+
|
||||
"\u0000\u010b\u010c\u0001\u0000\u0000\u0000\u010c\u010d\u0005\u0006\u0000"+
|
||||
"\u0000\u010d+\u0001\u0000\u0000\u0000\u010e\u0113\u0003\u001c\u000e\u0000"+
|
||||
"\u010f\u0110\u0005\n\u0000\u0000\u0110\u0112\u0003\u001c\u000e\u0000\u0111"+
|
||||
"\u010f\u0001\u0000\u0000\u0000\u0112\u0115\u0001\u0000\u0000\u0000\u0113"+
|
||||
"\u0111\u0001\u0000\u0000\u0000\u0113\u0114\u0001\u0000\u0000\u0000\u0114"+
|
||||
"-\u0001\u0000\u0000\u0000\u0115\u0113\u0001\u0000\u0000\u0000\u0116\u0117"+
|
||||
"\u0007\u0003\u0000\u0000\u0117/\u0001\u0000\u0000\u0000\u0118\u0119\u0005"+
|
||||
"-\u0000\u0000\u01191\u0001\u0000\u0000\u0000\u00197<>DRX_q{\u0084\u0086"+
|
||||
"\u0092\u00ab\u00bb\u00c2\u00c6\u00d4\u00dc\u00e5\u00ec\u00f7\u00fe\u0105"+
|
||||
"\u010a\u0113";
|
||||
"\u00d0\u00d6\u0001\u0000\u0000\u0000\u00d1\u00d6\u0003\"\u0011\u0000\u00d2"+
|
||||
"\u00d6\u0003\u001a\r\u0000\u00d3\u00d6\u0005\u0016\u0000\u0000\u00d4\u00d6"+
|
||||
"\u0005\u0015\u0000\u0000\u00d5\u00c8\u0001\u0000\u0000\u0000\u00d5\u00cc"+
|
||||
"\u0001\u0000\u0000\u0000\u00d5\u00cd\u0001\u0000\u0000\u0000\u00d5\u00d1"+
|
||||
"\u0001\u0000\u0000\u0000\u00d5\u00d2\u0001\u0000\u0000\u0000\u00d5\u00d3"+
|
||||
"\u0001\u0000\u0000\u0000\u00d5\u00d4\u0001\u0000\u0000\u0000\u00d6\u00dd"+
|
||||
"\u0001\u0000\u0000\u0000\u00d7\u00d8\n\b\u0000\u0000\u00d8\u00d9\u0003"+
|
||||
"\u001e\u000f\u0000\u00d9\u00da\u0003\u001c\u000e\t\u00da\u00dc\u0001\u0000"+
|
||||
"\u0000\u0000\u00db\u00d7\u0001\u0000\u0000\u0000\u00dc\u00df\u0001\u0000"+
|
||||
"\u0000\u0000\u00dd\u00db\u0001\u0000\u0000\u0000\u00dd\u00de\u0001\u0000"+
|
||||
"\u0000\u0000\u00de\u001d\u0001\u0000\u0000\u0000\u00df\u00dd\u0001\u0000"+
|
||||
"\u0000\u0000\u00e0\u00e1\u0007\u0001\u0000\u0000\u00e1\u001f\u0001\u0000"+
|
||||
"\u0000\u0000\u00e2\u00e3\u0007\u0002\u0000\u0000\u00e3!\u0001\u0000\u0000"+
|
||||
"\u0000\u00e4\u00e5\u0005\u0016\u0000\u0000\u00e5\u00e7\u0005\u0012\u0000"+
|
||||
"\u0000\u00e6\u00e4\u0001\u0000\u0000\u0000\u00e6\u00e7\u0001\u0000\u0000"+
|
||||
"\u0000\u00e7\u00ed\u0001\u0000\u0000\u0000\u00e8\u00e9\u0003(\u0014\u0000"+
|
||||
"\u00e9\u00ea\u0005\u0012\u0000\u0000\u00ea\u00ec\u0001\u0000\u0000\u0000"+
|
||||
"\u00eb\u00e8\u0001\u0000\u0000\u0000\u00ec\u00ef\u0001\u0000\u0000\u0000"+
|
||||
"\u00ed\u00eb\u0001\u0000\u0000\u0000\u00ed\u00ee\u0001\u0000\u0000\u0000"+
|
||||
"\u00ee\u00f0\u0001\u0000\u0000\u0000\u00ef\u00ed\u0001\u0000\u0000\u0000"+
|
||||
"\u00f0\u00f1\u00030\u0018\u0000\u00f1#\u0001\u0000\u0000\u0000\u00f2\u00f3"+
|
||||
"\u0003\"\u0011\u0000\u00f3\u00f4\u0003\u0006\u0003\u0000\u00f4\u00f5\u0003"+
|
||||
"\u001c\u000e\u0000\u00f5%\u0001\u0000\u0000\u0000\u00f6\u00f7\u0005\u0016"+
|
||||
"\u0000\u0000\u00f7\u00f9\u0005\u0012\u0000\u0000\u00f8\u00f6\u0001\u0000"+
|
||||
"\u0000\u0000\u00f8\u00f9\u0001\u0000\u0000\u0000\u00f9\u00ff\u0001\u0000"+
|
||||
"\u0000\u0000\u00fa\u00fb\u0003(\u0014\u0000\u00fb\u00fc\u0005\u0012\u0000"+
|
||||
"\u0000\u00fc\u00fe\u0001\u0000\u0000\u0000\u00fd\u00fa\u0001\u0000\u0000"+
|
||||
"\u0000\u00fe\u0101\u0001\u0000\u0000\u0000\u00ff\u00fd\u0001\u0000\u0000"+
|
||||
"\u0000\u00ff\u0100\u0001\u0000\u0000\u0000\u0100\u0102\u0001\u0000\u0000"+
|
||||
"\u0000\u0101\u00ff\u0001\u0000\u0000\u0000\u0102\u0103\u0003*\u0015\u0000"+
|
||||
"\u0103\'\u0001\u0000\u0000\u0000\u0104\u0107\u0003*\u0015\u0000\u0105"+
|
||||
"\u0107\u00030\u0018\u0000\u0106\u0104\u0001\u0000\u0000\u0000\u0106\u0105"+
|
||||
"\u0001\u0000\u0000\u0000\u0107)\u0001\u0000\u0000\u0000\u0108\u0109\u0003"+
|
||||
"0\u0018\u0000\u0109\u010b\u0005\u0005\u0000\u0000\u010a\u010c\u0003,\u0016"+
|
||||
"\u0000\u010b\u010a\u0001\u0000\u0000\u0000\u010b\u010c\u0001\u0000\u0000"+
|
||||
"\u0000\u010c\u010d\u0001\u0000\u0000\u0000\u010d\u010e\u0005\u0006\u0000"+
|
||||
"\u0000\u010e+\u0001\u0000\u0000\u0000\u010f\u0114\u0003\u001c\u000e\u0000"+
|
||||
"\u0110\u0111\u0005\n\u0000\u0000\u0111\u0113\u0003\u001c\u000e\u0000\u0112"+
|
||||
"\u0110\u0001\u0000\u0000\u0000\u0113\u0116\u0001\u0000\u0000\u0000\u0114"+
|
||||
"\u0112\u0001\u0000\u0000\u0000\u0114\u0115\u0001\u0000\u0000\u0000\u0115"+
|
||||
"-\u0001\u0000\u0000\u0000\u0116\u0114\u0001\u0000\u0000\u0000\u0117\u0118"+
|
||||
"\u0007\u0003\u0000\u0000\u0118/\u0001\u0000\u0000\u0000\u0119\u011a\u0005"+
|
||||
"-\u0000\u0000\u011a1\u0001\u0000\u0000\u0000\u00197<>DRX_q{\u0084\u0086"+
|
||||
"\u0092\u00ab\u00bb\u00c2\u00c6\u00d5\u00dd\u00e6\u00ed\u00f8\u00ff\u0106"+
|
||||
"\u010b\u0114";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
static {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/dev/Pressmium/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
|
||||
@ -201,6 +201,13 @@ public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitBinaryOperation(DecafParser.BinaryOperationContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by the {@code This}
|
||||
* labeled alternative in {@link DecafParser#expr}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitThis(DecafParser.ThisContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by the {@code StatementExpressionexpr}
|
||||
* labeled alternative in {@link DecafParser#expr}.
|
||||
|
@ -1,5 +1,5 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
public sealed interface Expression extends Node permits Binary, BoolLiteral, CharLiteral, FieldVarAccess, IntLiteral, MethodCall, New, Unary {
|
||||
public sealed interface Expression extends Node permits Binary, BoolLiteral, CharLiteral, FieldVarAccess, IntLiteral, MethodCall, New, Null, This, Unary {
|
||||
}
|
||||
|
5
src/main/java/de/maishai/ast/records/Null.java
Normal file
5
src/main/java/de/maishai/ast/records/Null.java
Normal file
@ -0,0 +1,5 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
public record Null() implements Expression {
|
||||
}
|
5
src/main/java/de/maishai/ast/records/This.java
Normal file
5
src/main/java/de/maishai/ast/records/This.java
Normal file
@ -0,0 +1,5 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
public record This() implements Expression {
|
||||
}
|
@ -0,0 +1,902 @@
|
||||
//public class ComplexClass {
|
||||
//
|
||||
// int x;
|
||||
// int y;
|
||||
// ComplexClass b;
|
||||
// ComplexClass c;
|
||||
//
|
||||
// public ComplexClass() {
|
||||
// this.y = 10;
|
||||
// this.x = 2;
|
||||
// int i;
|
||||
// for (i = 0; i < (this.y + 1); i = i + 1) {
|
||||
// int j;
|
||||
// for (j = 0; j < this.y; j += 1) {
|
||||
// this.x = this.x * this.x;
|
||||
// if (this.x == 100) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// this.y = 2;
|
||||
// do {
|
||||
// this.y = this.y + 1;
|
||||
// } while (this.y < 10);
|
||||
//
|
||||
// int k;
|
||||
// k = 0;
|
||||
// for (k = 0; k < 10; k = k + 1) {
|
||||
// if (k == 5) {
|
||||
// return this;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public ComplexClass(int x) {
|
||||
// this.b = new ComplexClass();
|
||||
// this.c = new ComplexClass();
|
||||
// this.x = x;
|
||||
// this.b.x = 7;
|
||||
// this.b.y = 13;
|
||||
// this.c.x = this.b.getX() * this.b.y * this.b.getX('g');
|
||||
// this.c.y = 25;
|
||||
// }
|
||||
//
|
||||
// public ComplexClass(int x, int y) {
|
||||
// this.x = x;
|
||||
// this.y = y;
|
||||
// }
|
||||
//
|
||||
// public ComplexClass initComplexClass(int x) {
|
||||
// int a;
|
||||
// a = 10;
|
||||
// this.b = new ComplexClass(x);
|
||||
// this.b.x = 10 + a;
|
||||
// this.b.y = 20;
|
||||
// this.b.c.x = 20 + a;
|
||||
// if (methodCall()) {
|
||||
// this.b.getC().b.y = this.b.x;
|
||||
// }
|
||||
// return this.b;
|
||||
// }
|
||||
//
|
||||
// public ComplexClass init(int x, int y) {
|
||||
// return new ComplexClass(x, y);
|
||||
// }
|
||||
//
|
||||
// public ComplexClass(int x, int y, char z) {
|
||||
// this.x = x;
|
||||
// this.y = y;
|
||||
// }
|
||||
//
|
||||
// public int getX(char z) {
|
||||
// return this.x;
|
||||
// }
|
||||
//
|
||||
// public ComplexClass getC() {
|
||||
// return this.c;
|
||||
// }
|
||||
//
|
||||
// public int getX() {
|
||||
// return this.x;
|
||||
// }
|
||||
//
|
||||
// public boolean methodCall() {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
import de.maishai.ast.Operator;
|
||||
import de.maishai.ast.records.*;
|
||||
import de.maishai.ast.records.Class;
|
||||
import de.maishai.typedast.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("DuplicateExpressions")
|
||||
public class AbstractSyntax_ComplexClass {
|
||||
public static Program get() {
|
||||
List<Declaration> declarationList = List.of(
|
||||
new Declaration(
|
||||
"x",
|
||||
Type.INT
|
||||
),
|
||||
new Declaration(
|
||||
"y",
|
||||
Type.INT
|
||||
),
|
||||
new Declaration(
|
||||
"b",
|
||||
Type.REFERENCE("ComplexClass")
|
||||
),
|
||||
new Declaration(
|
||||
"c",
|
||||
Type.REFERENCE("ComplexClass")
|
||||
)
|
||||
);
|
||||
List<Method> methodList = getMethods();
|
||||
List<Constructor> constructorList = getConstructors();
|
||||
return new Program(
|
||||
List.of(
|
||||
new Class(
|
||||
"ComplexClass",
|
||||
declarationList,
|
||||
methodList,
|
||||
constructorList
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static List<Constructor> getConstructors() {
|
||||
return List.of(
|
||||
getConstructor1(),
|
||||
getConstructor2(),
|
||||
getConstructor3(),
|
||||
getConstructor4()
|
||||
);
|
||||
}
|
||||
|
||||
private static Constructor getConstructor1() {
|
||||
Block block = new Block(
|
||||
List.of(
|
||||
new Declaration(
|
||||
"i",
|
||||
Type.INT
|
||||
),
|
||||
new Declaration(
|
||||
"k",
|
||||
Type.INT
|
||||
)
|
||||
),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"y"),
|
||||
new IntLiteral(10)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
new IntLiteral(2)
|
||||
),
|
||||
new For(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"i"),
|
||||
new IntLiteral(0)
|
||||
),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"i"),
|
||||
Operator.LT,
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"y"),
|
||||
Operator.ADD,
|
||||
new IntLiteral(1)
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"i"),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"i"),
|
||||
Operator.ADD,
|
||||
new IntLiteral(1)
|
||||
)
|
||||
),
|
||||
new Block(
|
||||
List.of(
|
||||
new Declaration(
|
||||
"j",
|
||||
Type.INT
|
||||
)
|
||||
),
|
||||
List.of(
|
||||
new For(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"j"),
|
||||
new IntLiteral(0)
|
||||
),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"j"),
|
||||
Operator.LT,
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"y"
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"j"),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"j"),
|
||||
Operator.ADD,
|
||||
new IntLiteral(1)
|
||||
)
|
||||
),
|
||||
new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
Operator.MUL,
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"
|
||||
)
|
||||
)
|
||||
),
|
||||
new IfElse(
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
Operator.EQ,
|
||||
new IntLiteral(100)
|
||||
),
|
||||
new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Break()
|
||||
)
|
||||
),
|
||||
null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"y"),
|
||||
new IntLiteral(2)
|
||||
),
|
||||
new DoWhile(
|
||||
new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"y"),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"y"),
|
||||
Operator.ADD,
|
||||
new IntLiteral(1)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"y"),
|
||||
Operator.LT,
|
||||
new IntLiteral(10)
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"k"),
|
||||
new IntLiteral(0)
|
||||
),
|
||||
new For(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"k"),
|
||||
new IntLiteral(0)
|
||||
),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"k"),
|
||||
Operator.LT,
|
||||
new IntLiteral(10)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"k"),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"k"),
|
||||
Operator.ADD,
|
||||
new IntLiteral(1)
|
||||
)
|
||||
),
|
||||
new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new IfElse(
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"k"),
|
||||
Operator.EQ,
|
||||
new IntLiteral(5)
|
||||
),
|
||||
new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Return(
|
||||
new This()
|
||||
)
|
||||
)
|
||||
),
|
||||
null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Constructor(
|
||||
"ComplexClass",
|
||||
List.of(),
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
private static Constructor getConstructor2() {
|
||||
Block block = new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"b"),
|
||||
new New(
|
||||
Type.REFERENCE("ComplexClass"),
|
||||
List.of()
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"c"),
|
||||
new New(
|
||||
Type.REFERENCE("ComplexClass"),
|
||||
List.of()
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"x"
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"b"),
|
||||
"x"),
|
||||
new IntLiteral(7)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"b"),
|
||||
"y"),
|
||||
new IntLiteral(13)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"c"),
|
||||
"x"),
|
||||
new Binary(
|
||||
new Binary(
|
||||
new MethodCall(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"b"),
|
||||
"getX"
|
||||
),
|
||||
List.of()
|
||||
),
|
||||
Operator.MUL,
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"b"),
|
||||
"y"
|
||||
)
|
||||
),
|
||||
Operator.MUL,
|
||||
new MethodCall(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"b"),
|
||||
"getX"
|
||||
),
|
||||
List.of(
|
||||
new CharLiteral('g')
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"c"),
|
||||
"y"),
|
||||
new IntLiteral(25)
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Constructor(
|
||||
"ComplexClass",
|
||||
List.of(
|
||||
new Parameter(
|
||||
"x",
|
||||
Type.INT
|
||||
)
|
||||
),
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
private static Constructor getConstructor3() {
|
||||
Block block = new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"x"
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"y"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"y"
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Constructor(
|
||||
"ComplexClass",
|
||||
List.of(
|
||||
new Parameter(
|
||||
"x",
|
||||
Type.INT
|
||||
),
|
||||
new Parameter(
|
||||
"y",
|
||||
Type.INT
|
||||
)
|
||||
),
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
private static Constructor getConstructor4() {
|
||||
Block block = new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"x"
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"y"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"y"
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Constructor(
|
||||
"ComplexClass",
|
||||
List.of(
|
||||
new Parameter(
|
||||
"x",
|
||||
Type.INT
|
||||
),
|
||||
new Parameter(
|
||||
"y",
|
||||
Type.INT
|
||||
),
|
||||
new Parameter(
|
||||
"z",
|
||||
Type.CHAR
|
||||
)
|
||||
),
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
private static List<Method> getMethods() {
|
||||
return List.of(
|
||||
getMethod1(),
|
||||
getMethod2(),
|
||||
getMethod3(),
|
||||
getMethod4(),
|
||||
getMethod5(),
|
||||
getMethod6()
|
||||
);
|
||||
}
|
||||
|
||||
private static Method getMethod1() {
|
||||
Block block = new Block(
|
||||
List.of(
|
||||
new Declaration(
|
||||
"a",
|
||||
Type.INT
|
||||
)
|
||||
),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"a"),
|
||||
new IntLiteral(10)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"b"),
|
||||
new New(
|
||||
Type.REFERENCE("ComplexClass"),
|
||||
List.of(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"x"
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"b"),
|
||||
"x"),
|
||||
new Binary(
|
||||
new IntLiteral(10),
|
||||
Operator.ADD,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"a"
|
||||
)
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"b"),
|
||||
"y"),
|
||||
new IntLiteral(20)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"b"),
|
||||
"c"),
|
||||
"x"),
|
||||
new Binary(
|
||||
new IntLiteral(20),
|
||||
Operator.ADD,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"a"
|
||||
)
|
||||
)
|
||||
),
|
||||
new IfElse(
|
||||
new MethodCall(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"methodCall"),
|
||||
List.of()
|
||||
),
|
||||
new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
new MethodCall(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"b"
|
||||
),
|
||||
"getC"
|
||||
),
|
||||
List.of()
|
||||
),
|
||||
"b"),
|
||||
"y"),
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"b"
|
||||
),
|
||||
"x"
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
null
|
||||
),
|
||||
new Return(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"b"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
return new Method(
|
||||
Type.REFERENCE("ComplexClass"),
|
||||
"initComplexClass",
|
||||
List.of(
|
||||
new Parameter(
|
||||
"x",
|
||||
Type.INT
|
||||
)
|
||||
),
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
private static Method getMethod2() {
|
||||
Block block = new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Return(
|
||||
new New(
|
||||
Type.REFERENCE("ComplexClass"),
|
||||
List.of(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"x"
|
||||
),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"y"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Method(
|
||||
Type.REFERENCE("ComplexClass"),
|
||||
"init",
|
||||
List.of(
|
||||
new Parameter(
|
||||
"x",
|
||||
Type.INT
|
||||
),
|
||||
new Parameter(
|
||||
"y",
|
||||
Type.INT
|
||||
)
|
||||
),
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
private static Method getMethod3() {
|
||||
Block block = new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Return(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Method(
|
||||
Type.INT,
|
||||
"getX",
|
||||
List.of(
|
||||
new Parameter(
|
||||
"z",
|
||||
Type.CHAR
|
||||
)
|
||||
),
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
private static Method getMethod4() {
|
||||
Block block = new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Return(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"c"
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Method(
|
||||
Type.REFERENCE("ComplexClass"),
|
||||
"getC",
|
||||
List.of(),
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
private static Method getMethod5() {
|
||||
Block block = new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Return(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Method(
|
||||
Type.INT,
|
||||
"getX",
|
||||
List.of(),
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
private static Method getMethod6() {
|
||||
Block block = new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Return(
|
||||
new BoolLiteral(false)
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Method(
|
||||
Type.BOOL,
|
||||
"methodCall",
|
||||
List.of(),
|
||||
block
|
||||
);
|
||||
}
|
||||
}
|
@ -4,44 +4,21 @@ public class ComplexClass {
|
||||
int y;
|
||||
ComplexClass b;
|
||||
ComplexClass c;
|
||||
public ComplexClass(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
public ComplexClass(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
public ComplexClass initComplexClass(int x) {
|
||||
int a;
|
||||
a = 10;
|
||||
b = new ComplexClass(x);
|
||||
b.x = 10 + a;
|
||||
b.y = 20;
|
||||
b.c.x = 20 + a;
|
||||
b.c.b.y = b.x;
|
||||
|
||||
return b;
|
||||
}
|
||||
public ComplexClass init(int x, int y) {
|
||||
return new ComplexClass(x, y);
|
||||
}
|
||||
public ComplexClass(int x) {
|
||||
this.x = x;
|
||||
int i;
|
||||
b = b.getX().c.getC();
|
||||
i = b.getX().c.getX();
|
||||
}
|
||||
|
||||
public ComplexClass() {
|
||||
this.x = 10;
|
||||
this.y = 10;
|
||||
this.x = 2;
|
||||
int i;
|
||||
for (i = 0; i < (x + 1); i = i + 1) {
|
||||
for (i = 0; i < (this.y + 1); i = i + 1) {
|
||||
int j;
|
||||
for (j = 0; j < this.x; j += 1) {
|
||||
for (j = 0; j < this.y; j += 1) {
|
||||
this.x = this.x * this.x;
|
||||
break;
|
||||
if (this.x == 100) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.y = 2;
|
||||
do {
|
||||
this.y = this.y + 1;
|
||||
} while (this.y < 10);
|
||||
@ -50,12 +27,44 @@ public class ComplexClass {
|
||||
k = 0;
|
||||
for (k = 0; k < 10; k = k + 1) {
|
||||
if (k == 5) {
|
||||
return;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ComplexClass(int x) {
|
||||
this.b = new ComplexClass();
|
||||
this.c = new ComplexClass();
|
||||
this.x = x;
|
||||
this.b.x = 7;
|
||||
this.b.y = 13;
|
||||
this.c.x = this.b.getX() * this.b.y * this.b.getX('g');
|
||||
this.c.y = 25;
|
||||
}
|
||||
|
||||
public ComplexClass(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public ComplexClass initComplexClass(int x) {
|
||||
int a;
|
||||
a = 10;
|
||||
this.b = new ComplexClass(x);
|
||||
this.b.x = 10 + a;
|
||||
this.b.y = 20;
|
||||
this.b.c.x = 20 + a;
|
||||
if (methodCall()) {
|
||||
this.b.getC().b.y = this.b.x;
|
||||
}
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public ComplexClass init(int x, int y) {
|
||||
return new ComplexClass(x, y);
|
||||
}
|
||||
|
||||
public ComplexClass(int x, int y, char z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@ -66,16 +75,15 @@ public class ComplexClass {
|
||||
}
|
||||
|
||||
public ComplexClass getC() {
|
||||
return c;
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public boolean methodCall() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,8 @@ public class TypedAbstractSyntax_ClassWithConstructor {
|
||||
null,
|
||||
Type.REFERENCE("ClassWithField")
|
||||
)
|
||||
)
|
||||
),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,8 @@ public class TypedAbstractSyntax_ClassWithField {
|
||||
null,
|
||||
Type.REFERENCE("ClassWithField")
|
||||
)
|
||||
)
|
||||
),
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
@ -31,7 +31,8 @@ public class TypedAbstractSyntax_PublicClass {
|
||||
null,
|
||||
Type.REFERENCE("PublicClass")
|
||||
)
|
||||
)
|
||||
),
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
16
src/test/java/CodegeneratorTests.java
Normal file
16
src/test/java/CodegeneratorTests.java
Normal file
@ -0,0 +1,16 @@
|
||||
import de.maishai.Compiler;
|
||||
import de.maishai.ast.records.Program;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class CodegeneratorTests {
|
||||
|
||||
// @Test
|
||||
// public void testPublicClass() {
|
||||
// byte[] resultBytecode = Compiler.generateByteCodeArrayFromTypedAst();
|
||||
// assertEquals(AbstractSyntax_PublicClass.get(), resultBytecode);
|
||||
// }
|
||||
}
|
@ -1,3 +1,7 @@
|
||||
public class E2ETests {
|
||||
char ZZ;
|
||||
|
||||
public E2ETests() {
|
||||
this.ZZ = 'z';
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,6 @@ public class ScannerParserTests {
|
||||
@Test
|
||||
public void testComplexClass() {
|
||||
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ComplexClass.java"));
|
||||
assertEquals(AbstractSyntax_ClassWithConstructorAndMethodCall.get(), resultAst);
|
||||
assertEquals(AbstractSyntax_ComplexClass.get(), resultAst);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user