Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#Dont use maven directly, because all maven dependencies downloaded during build time won't be in the image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a dockerfile? I guess it's fine.

FROM openjdk:8-jdk

RUN apt-get update && apt-get install -y \
maven \
llvm \
graphviz \
build-essential \
&& rm -rf /var/lib/apt/lists/*


WORKDIR /moco

COPY pom.xml /moco/pom.xml
#COPY settings-maven.xml /maven

#Download everything
#... except surefire :-(
RUN mvn dependency:resolve
RUN mvn dependency:resolve-plugins
RUN mvn antlr4:antlr4
RUN mvn test --fail-never

#Add sources last, because they are changed often
COPY src /moco/src

#RUN mvn package

ENTRYPOINT mvn
CMD package
36 changes: 36 additions & 0 deletions LICENSE_HEADER
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
moco, the Monty Compiler
Copyright (c) 2013-2014, Monty's Coconut, All rights reserved.

This file is part of moco, the Monty Compiler.

moco is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.

moco is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

Linking this program and/or its accompanying libraries statically or
dynamically with other modules is making a combined work based on this
program. Thus, the terms and conditions of the GNU General Public License
cover the whole combination.

As a special exception, the copyright holders of moco give
you permission to link this programm and/or its accompanying libraries
with independent modules to produce an executable, regardless of the
license terms of these independent modules, and to copy and distribute the
resulting executable under terms of your choice, provided that you also meet,
for each linked independent module, the terms and conditions of the
license of that module.

An independent module is a module which is not
derived from or based on this program and/or its accompanying libraries.
If you modify this library, you may extend this exception to your version of
the program or library, but you are not obliged to do so. If you do not wish
to do so, delete this exception statement from your version.

You should have received a copy of the GNU General Public
License along with this library.
31 changes: 5 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ Installing Dependencies
Linux (Ubuntu)
--------------

Install [LLVM](http://llvm.org/) and a JRE 7.
Install [LLVM](http://llvm.org/) and a JRE 8.

sudo apt-get install llvm
sudo apt-get install default-jre

If you want to build `moco` yourself you'll need to install the following
dependencies and a JDK 7.
dependencies and a JDK 8.

sudo apt-get install git
sudo apt-get install maven
Expand All @@ -37,15 +37,15 @@ You can also install Graphviz to generate class diagrams. This is optional.
Mac OS X
--------

> **Note:** Please make sure you have [homebrew](http://brew.sh/) and a JRE 7
> **Note:** Please make sure you have [homebrew](http://brew.sh/) and a JRE 8
installed.

Install [LLVM](http://llvm.org/) using homebrew:

brew install llvm

If you want to build `moco` yourself you'll need to install the following
dependencies and a JDK 7.
dependencies and a JDK 8.

brew install git
brew install maven
Expand All @@ -61,28 +61,7 @@ You can also install Graphviz to generate class diagrams. This is optional.
Windows
-------

To use [LLVM](http://llvm.org/) you'll need to download and install the
following executables. In addition you'll need to download and extract the
`llvm-3.4-tools-windows.7z` archive into the `bin\` directory of your LLVM
installation. To run the executable .jar file you'll also need a JRE 7.


- http://www.microsoft.com/de-DE/download/details.aspx?id=40784 (the **x86 and
the x64** version)
- http://llvm.org/releases/3.4/LLVM-3.4-win32.exe
- https://github.com/CRogers/LLVM-Windows-Binaries/releases/download/v3.4/llvm-3.4-tools-windows.7z

If you want to build `moco` yourself you'll need to install the following
dependencies and a JDK 7. These examples use the
[chocolatey](https://chocolatey.org/) package manager.

choco install maven
choco install java.jdk
choco install git.commandline

You can also install Graphviz to generate class diagrams. This is optional.

choco install graphviz
Currently Windows is not supported.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you expand on why Windows is not supported anymore?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were a few reasons.
One that i can remember is reading from command line produces different line endings. So the unit tests fail on windows.


Building
========
Expand Down
82 changes: 76 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

moco, the Monty Compiler
Copyright (c) 2013-2014, Monty's Coconut, All rights reserved.

This file is part of moco, the Monty Compiler.

moco is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.

moco is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

Linking this program and/or its accompanying libraries statically or
dynamically with other modules is making a combined work based on this
program. Thus, the terms and conditions of the GNU General Public License
cover the whole combination.

As a special exception, the copyright holders of moco give
you permission to link this programm and/or its accompanying libraries
with independent modules to produce an executable, regardless of the
license terms of these independent modules, and to copy and distribute the
resulting executable under terms of your choice, provided that you also meet,
for each linked independent module, the terms and conditions of the
license of that module.

An independent module is a module which is not
derived from or based on this program and/or its accompanying libraries.
If you modify this library, you may extend this exception to your version of
the program or library, but you are not obliged to do so. If you do not wish
to do so, delete this exception statement from your version.

You should have received a copy of the GNU General Public
License along with this library.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Expand Down Expand Up @@ -115,9 +155,9 @@
<configuration>
<configFile>${project.basedir}/src/main/resources/moco-code-conv.xml</configFile>
<overrideConfigCompilerVersion>true</overrideConfigCompilerVersion>
<compilerSource>1.7</compilerSource>
<compilerCompliance>1.7</compilerCompliance>
<compilerTargetPlatform>1.7</compilerTargetPlatform>
<compilerSource>1.8</compilerSource>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a JDK version bump in the .travis-ci.yml aswell, to make Travis happy.

<compilerCompliance>1.8</compilerCompliance>
<compilerTargetPlatform>1.8</compilerTargetPlatform>
<lineEnding>LF</lineEnding>
<encoding>UTF-8</encoding>
</configuration>
Expand All @@ -135,8 +175,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Expand Down Expand Up @@ -192,7 +232,36 @@
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<header>${basedir}/LICENSE_HEADER</header>
<mapping>
<g4>SLASHSTAR_STYLE</g4>
<java>SLASHSTAR_STYLE</java>
</mapping>
<excludes>
<exclude>**/README</exclude>
<exclude>**/COPYING</exclude>
<exclude>**/COPYING_EXCEPTION</exclude>
<exclude>**/COPYING_HEADER</exclude>
<exclude>**/LICENSE_HEADER</exclude>
<exclude>src/test/resources/**</exclude>
<exclude>src/site/**</exclude>
<exclude>src/main/resources/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -313,5 +382,6 @@
<version>1.3</version>
<scope>test</scope>
</dependency>

</dependencies>
</project>
63 changes: 59 additions & 4 deletions src/main/antlr4/de/uni/bremen/monty/moco/antlr/Monty.g4
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
grammar Monty;
/*
* moco, the Monty Compiler
* Copyright (c) 2013-2014, Monty's Coconut, All rights reserved.
*
* This file is part of moco, the Monty Compiler.
*
* moco is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* moco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* Linking this program and/or its accompanying libraries statically or
* dynamically with other modules is making a combined work based on this
* program. Thus, the terms and conditions of the GNU General Public License
* cover the whole combination.
*
* As a special exception, the copyright holders of moco give
* you permission to link this programm and/or its accompanying libraries
* with independent modules to produce an executable, regardless of the
* license terms of these independent modules, and to copy and distribute the
* resulting executable under terms of your choice, provided that you also meet,
* for each linked independent module, the terms and conditions of the
* license of that module.
*
* An independent module is a module which is not
* derived from or based on this program and/or its accompanying libraries.
* If you modify this library, you may extend this exception to your version of
* the program or library, but you are not obliged to do so. If you do not wish
* to do so, delete this exception statement from your version.
*
* You should have received a copy of the GNU General Public
* License along with this library.
*/

grammar Monty;

import lex;

Expand Down Expand Up @@ -33,15 +72,15 @@ independentDeclaration
;

classDeclaration
: nativeAnnotation? AbstractKeyword? 'class' type ('inherits' typeList)?
: nativeAnnotation? AbstractKeyword? 'class' typeDef ('inherits' typeList)?
':' EndOfLine
Indent
(memberDeclaration+ | 'pass' EndOfLine)
Dedent
;

caseClassDeclaration
: 'case' 'class' type '(' (parameterListWithoutDefaults)? ')' ('inherits' typeList)?
: 'case' 'class' typeDef '(' (parameterListWithoutDefaults)? ')' ('inherits' typeList)?
(':' EndOfLine
Indent
(memberDeclaration+ | 'pass' EndOfLine)
Expand Down Expand Up @@ -76,13 +115,29 @@ arrow
: '->'
;

typeDef
: ClassIdentifier ('<' typeDefList '>')?
;

typeDefList
: boundedType (',' boundedType)*
;

boundedType
: ClassIdentifier (typeBound)? ('<' typeList '>')?
;

type
: ClassIdentifier ('<' typeList '>')?
| '(' (type (',' type)+)? ')'
| type arrow type
| '(' type arrow type ')'
;

typeBound
: 'inherits' type
;

typeList
: type (',' type)*
;
Expand Down Expand Up @@ -213,7 +268,7 @@ expression
| left=expression andOperator right=expression
| left=expression orOperator right=expression
| expr=expression asOperator type
| expr=expression isOperator ClassIdentifier
| expr=expression isOperator type
| listComprehension
;

Expand Down
41 changes: 40 additions & 1 deletion src/main/antlr4/imports/lex.g4
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
lexer grammar lex;
/*
* moco, the Monty Compiler
* Copyright (c) 2013-2014, Monty's Coconut, All rights reserved.
*
* This file is part of moco, the Monty Compiler.
*
* moco is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* moco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* Linking this program and/or its accompanying libraries statically or
* dynamically with other modules is making a combined work based on this
* program. Thus, the terms and conditions of the GNU General Public License
* cover the whole combination.
*
* As a special exception, the copyright holders of moco give
* you permission to link this programm and/or its accompanying libraries
* with independent modules to produce an executable, regardless of the
* license terms of these independent modules, and to copy and distribute the
* resulting executable under terms of your choice, provided that you also meet,
* for each linked independent module, the terms and conditions of the
* license of that module.
*
* An independent module is a module which is not
* derived from or based on this program and/or its accompanying libraries.
* If you modify this library, you may extend this exception to your version of
* the program or library, but you are not obliged to do so. If you do not wish
* to do so, delete this exception statement from your version.
*
* You should have received a copy of the GNU General Public
* License along with this library.
*/

lexer grammar lex;

@lexer::header {
import java.util.Stack;
Expand Down
Loading