Skip to content
Snippets Groups Projects
Commit 7b03e394 authored by Sebastian Ebert's avatar Sebastian Ebert
Browse files

initial commit after extraction

parent ce6ad783
No related branches found
No related tags found
No related merge requests found
Showing
with 906 additions and 0 deletions
build
src/gen-res/
src/gen/
out*/
.idea
.gradle
*.class
logs/
// General configuration (plugins, settings, dependencies)
group 'de.tudresden.inf.st'
version '0.1'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'jastadd'
apply plugin: 'application'
apply plugin: "idea"
apply plugin: 'java-library'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories.mavenCentral()
buildscript {
//repositories.mavenCentral()
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'org.jastadd', name: 'jastaddgradle', version: '1.13.3'
}
}
idea.module.generatedSourceDirs += file('src/gen/java')
sourceSets.main.java.srcDir "src/gen/java"
jar.manifest.attributes('Main-Class': 'de.tudresden.inf.st.pnml.Main')
configurations {
myBeaver
}
dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "${jackson_version}"
implementation group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
implementation group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.13.2'
implementation group: 'org.fusesource.mqtt-client', name: 'mqtt-client', version: '1.15'
// pnml lib
implementation group: 'org.eclipse.emf', name: 'org.eclipse.emf.ecore', version: '2.12.0'
implementation group: 'org.eclipse.emf', name: 'org.eclipse.emf.ecore.xmi', version: '2.12.0'
implementation group: 'org.eclipse.emf', name: 'org.eclipse.emf.common', version: '2.12.0'
implementation group: 'org.eclipse.emf', name: 'org.eclipse.emf.mwe.core', version: '1.3.13'
api group: 'fr.lip6.pnml', name: 'fr.lip6.pnml.framework.ptnet', version: '2.2.12'
api group: 'fr.lip6.pnml', name: 'fr.lip6.pnml.framework.utils', version: '2.2.12'
implementation group: 'org.apache.ws.commons.axiom', name: 'axiom-api', version: '1.2.22'
implementation group: 'org.apache.ws.commons.axiom', name: 'axiom-impl', version: '1.2.22'
implementation group: 'com.thaiopensource', name: 'jing', version: '20091111'
implementation 'org.jetbrains:annotations:19.0.0'
// https://mvnrepository.com/artifact/xalan/xalan
implementation group: 'xalan', name: 'xalan', version: '2.7.2'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
myBeaver group: 'net.sf.beaver', name: 'beaver-ant', version: '0.9.11'
jastadd2 "org.jastadd:jastadd:2.3.4"
}
// Default run configuration
run {
mainClassName = 'de.tudresden.inf.st.pnml.base.Main'
standardInput = System.in
}
// Generated files
def ecoreFile = "./src/main/resources/placeTransition.ecore"
def relastAspect = "./src/gen/jastadd/pnml/placeTransition.ecore.jadd"
def relastFile = "./src/gen/jastadd/pnml/placeTransition.relast"
jar {
manifest {
attributes "Main-Class": "de.tudresden.inf.st.pnml.Main"
}
from {
//configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveBaseName = 'pnml-base'
}
// First phase: Ecore -> RelAst
task ecoreToRelast(type: JavaExec) {
group = 'Build'
main = "-jar"
doFirst {
delete "src/gen/jastadd"
mkdir "src/gen/jastadd/pnml"
}
args "libs/ecore2relast-0.1.jar", ecoreFile, relastFile
inputs.files file(ecoreFile)
outputs.files file(relastFile), file(relastAspect)
}
// Second phase: RelAst -> JastAdd
task relastToJastAdd(type: JavaExec) {
group = 'Build'
main = "-jar"
args "libs/relast.jar",
"--grammarName=./src/gen/jastadd/placeTransition",
"--useJastAddNames",
"--listClass=ArrayList",
"--jastAddList=JastAddList",
"--resolverHelper",
"--file",
relastFile,
"./src/main/jastadd/marking/Marking.relast",
"./src/main/jastadd/io/IoPN.relast",
"./src/main/jastadd/clauses/expressions.relast"
}
task generateBeaver(type: JavaExec) {
inputs.files {
project.file("src/main/jastadd/clauses/Parser.beaver")
}
outputs.dir {
// This closure is needed to delay reading the genDir setting.
project.file("src/gen/java/de/tudresden/inf/st/pnml/jastadd/parser")
}
classpath = configurations.myBeaver
main = 'beaver.comp.run.Make'
doFirst {
def outdir = project.file("src/gen/java/de/tudresden/inf/st/pnml/jastadd/parser")
if (!outdir.isDirectory()) {
outdir.mkdirs()
}
def inputFile = project.file("src/main/jastadd/clauses/Parser.beaver")
args ([ '-d', outdir.path, '-t', '-c', '-w', inputFile.path ])
}
}
// Third phase: JastAdd -> Java (using JastAdd Gradle plugin)
jastadd {
configureModuleBuild()
modules {
module("pnml") {
java {
basedir "src/"
include "main/**/*.java"
include "gen/**/*.java"
}
jastadd {
basedir "src/"
include "main/jastadd/**/*.ast"
include "main/jastadd/**/*.jadd"
include "main/jastadd/**/*.jrag"
include "gen/jastadd/**/*.ast"
include "gen/jastadd/**/*.jadd"
include "gen/jastadd/**/*.jrag"
}
scanner {
include "src/main/jastadd/PnmlScanner.flex"
include "src/main/jastadd/clauses/expressions.flex"
}
parser {
include "src/main/jastadd/PnmlParser.parser"
}
}
}
cleanGen.doFirst {
delete "src/gen/java/de"
delete "src/gen-res/BuildInfo.properties"
}
module = "pnml"
astPackage = 'de.tudresden.inf.st.pnml.jastadd.model'
genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res'
scanner.genDir = "src/gen/java/de/tudresden/inf/st/pnml/jastadd/scanner"
parser.genDir = "src/gen/java/de/tudresden/inf/st/pnml/jastadd/parser"
// default options are: '--rewrite=cnta', '--safeLazy', '--visitCheck=false', '--cacheCycle=false'
extraJastAddOptions = ['--List=JastAddList'] // '--incremental=param'
}
// Workflow configuration for phases
relastToJastAdd.dependsOn ecoreToRelast
generateAst.dependsOn relastToJastAdd
compileJava.dependsOn generateBeaver
//// always run jastadd
//jastadd.outputs.upToDateWhen {false}
jackson_version = 2.9.8
apache_httpcomponents_version = 4.5.8
File added
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
gradlew 0 → 100755
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
File added
File added
File added
File added
rootProject.name = 'pnml-relast-base'
aspect Constraints {
coll Set<ConstraintViolation> PetriNet.constraintViolations() [new java.util.HashSet()] root PetriNet;
}
aspect ConstraintViolations {
abstract class ConstraintViolation {
public String toString() {
return "Constraint " + getTitle() + " violated in object " + id() + ": " + getMessage();
}
protected ASTNode location;
public String id() {
if (location instanceof PnObject) return ((PnObject) location).getId();
if (location instanceof PetriNet) return ((PetriNet) location).getId();
return location.toString();
}
protected String title;
protected String description;
protected String message;
public String getTitle() { return title; }
public String getDescription() { return description; }
public String getMessage() { return message; }
}
class CheckIdsConstraint extends ConstraintViolation {
public CheckIdsConstraint(ASTNode location) {
this.location = location;
this.title = "CheckIds";
this.description = "Checks id attribute existence";
this.message = "A node of type '" + location.getClass().getSimpleName() + "' must have an id attribute.";
}
}
class CheckIdUniquenessConstraint extends ConstraintViolation {
public CheckIdUniquenessConstraint(ASTNode location) {
this.location = location;
this.title = "CheckIdUniquess";
this.description = "Checks id attribute uniqueness";
this.message = "The id attribute value " + id() + " of the node of type '" + location.getClass().getSimpleName() + "' is not unique.";
}
}
PetriNet contributes new CheckIdsConstraint(this)
when checkIdsConstraintViolated()
to PetriNet.constraintViolations();
PnObject contributes new CheckIdsConstraint(this)
when checkIdsConstraintViolated()
to PetriNet.constraintViolations();
}
aspect CoreModelConstraints {
syn boolean PetriNet.checkIdsConstraintViolated() = getId() == null || getId().equals("");
syn boolean PnObject.checkIdsConstraintViolated() = getId() == null || getId().equals("");
coll List<String> PetriNet.ids() [new ArrayList()] root PetriNet;
PnObject contributes getId() to PetriNet.ids();
syn Map<String, Long> PetriNet.idCount() =
ids().stream().collect(Collectors.groupingBy(java.util.function.Function.identity(), Collectors.counting()));
syn boolean PetriNet.uniqueId(String id) = idCount().get(id) <= 1;
syn boolean PnObject.uniqueId(String id) = petriNet().idCount().get(id) <= 1;
syn Optional<CheckIdUniquenessConstraint> PetriNet.checkIdUniqueness() {
if(uniqueId(getId())) return Optional.empty();
else return Optional.of(new CheckIdUniquenessConstraint(this));
}
syn Optional<CheckIdUniquenessConstraint> PnObject.checkIdUniqueness() {
if(petriNet().uniqueId(getId())) return Optional.empty();
else return Optional.of(new CheckIdUniquenessConstraint(this));
}
PetriNet contributes checkIdUniqueness().get()
when checkIdUniqueness().isPresent()
to PetriNet.constraintViolations();
PnObject contributes checkIdUniqueness().get()
when checkIdUniqueness().isPresent()
to PetriNet.constraintViolations();
}
aspect Navigation {
inh PetriNet PnObject.petriNet();
eq PetriNet.getChild().petriNet() = this;
syn java.util.Collection<Place> TransitionNode.incomingPlaces() {
java.util.Set<Place> s = new java.util.HashSet<>();
for (Arc incomingArc : getInArcList()) {
s.add(incomingArc.getSource().asPlaceNode().place());
}
for (TransitionNode ref : getReferencingTransitions()) {
s.addAll(ref.incomingPlaces());
}
return s;
}
syn java.util.Collection<Place> TransitionNode.outgoingPlaces() {
java.util.Set<Place> s = new java.util.HashSet<>();
for (Arc outgoing : getOutArcList()) {
s.add(outgoing.getTarget().asPlaceNode().place());
}
for (TransitionNode ref : getReferencingTransitions()) {
s.addAll(ref.outgoingPlaces());
}
return s;
}
inh Page PnObject.ContainingPage();
eq Page.getObject().ContainingPage() = this;
eq PetriNet.getPage().ContainingPage() = null;
syn boolean Node.isPlaceNode() = false;
eq PlaceNode.isPlaceNode() = true;
syn PlaceNode Node.asPlaceNode() = null;
eq PlaceNode.asPlaceNode() = this;
syn boolean Node.isTransitionNode() = false;
eq TransitionNode.isTransitionNode() = true;
syn boolean TransitionInformation.isTopicTransitionInformation() = false;
eq TopicTransitionInformation.isTopicTransitionInformation() = true;
syn boolean TransitionInformation.isServiceTransitionInformation() = false;
eq ServiceTransitionInformation.isServiceTransitionInformation() = true;
syn boolean TransitionInformation.isDefaultTransitionInformation() = false;
eq DefaultTransitionInformation.isDefaultTransitionInformation() = true;
syn boolean TransitionNode.isRefTransition() = false;
eq RefTransition.isRefTransition() = true;
syn boolean TransitionNode.isTransition() = false;
eq Transition.isTransition() = true;
syn boolean PlaceNode.isRefPlace() = false;
eq RefPlace.isRefPlace() = true;
syn Place PlaceNode.asPlace() = null;
eq Place.asPlace() = this;
syn boolean PlaceNode.isPlace() = false;
eq Place.isPlace() = true;
syn RefTransition TransitionNode.asRefTransition() = null;
eq RefTransition.asRefTransition() = this;
syn Transition TransitionNode.asTransition() = null;
eq Transition.asTransition() = this;
syn TransitionNode Node.asTransitionNode() = null;
eq TransitionNode.asTransitionNode() = this;
syn InputSignalTransition Transition.asInputSignalTransition() = null;
eq InputSignalTransition.asInputSignalTransition() = this;
syn OutputSignalPlace Place.asOutputSignalPlace() = null;
eq OutputSignalPlace.asOutputSignalPlace() = this;
syn TopicTransitionInformation TransitionInformation.asTopicTransitionInformation() = null;
eq TopicTransitionInformation.asTopicTransitionInformation() = this;
syn ServiceTransitionInformation TransitionInformation.asServiceTransitionInformation() = null;
eq ServiceTransitionInformation.asServiceTransitionInformation() = this;
syn DefaultTransitionInformation TransitionInformation.asDefaultTransitionInformation() = null;
eq DefaultTransitionInformation.asDefaultTransitionInformation() = this;
syn Place PlaceNode.place();
eq Place.place() = this;
eq RefPlace.place() = getRef().place();
syn Transition TransitionNode.transition();
eq Transition.transition() = this;
eq RefTransition.transition() = getRef().transition();
coll java.util.Set<PnObject> PetriNet.allObjects() [new java.util.HashSet()] root PetriNet;
PnObject contributes this
to PetriNet.allObjects()
for petriNet();
coll java.util.Set<Place> PetriNet.allPlaces() [new java.util.HashSet()] root PetriNet;
Place contributes this
to PetriNet.allPlaces()
for petriNet();
coll java.util.Set<Transition> PetriNet.allTransitions() [new java.util.HashSet()] root PetriNet;
Transition contributes this
to PetriNet.allTransitions()
for petriNet();
coll java.util.Set<Arc> PetriNet.allArcs() [new java.util.HashSet()] root PetriNet;
Arc contributes this
to PetriNet.allArcs()
for petriNet();
coll java.util.Set<Page> PetriNet.allPages() [new java.util.HashSet()] root PetriNet;
Page contributes this
to PetriNet.allPages()
for petriNet();
coll java.util.Set<TransitionNode> PetriNet.allTransitionNodes() [new java.util.HashSet()] root PetriNet;
TransitionNode contributes this
to PetriNet.allTransitionNodes()
for petriNet();
coll java.util.Set<RefTransition> PetriNet.allRefTransitions() [new java.util.HashSet()] root PetriNet;
RefTransition contributes this
to PetriNet.allRefTransitions()
for petriNet();
coll java.util.Set<RefPlace> PetriNet.allRefPlaces() [new java.util.HashSet()] root PetriNet;
RefPlace contributes this
to PetriNet.allRefPlaces()
for petriNet();
}
aspect References {
syn PnObject PetriNet.resolve(String id) {
for (PnObject object : allObjects()) {
if (object.getId().equals(id)) {
return object;
}
}
throw new RuntimeException(new de.tudresden.inf.st.pnml.base.parsing.PnmlParseException("Unable to resolve id " + id));
}
eq PnObject.globallyResolveArcByToken(String id) = (Arc) petriNet().resolve(id);
eq PnObject.globallyResolveNodeByToken(String id) = (Node) petriNet().resolve(id);
eq PnObject.globallyResolvePlaceNodeByToken(String id) = (PlaceNode) petriNet().resolve(id);
eq PnObject.globallyResolveTransitionNodeByToken(String id) = (TransitionNode) petriNet().resolve(id);
eq PnObject.globallyResolveRefPlaceByToken(String id) = (RefPlace) petriNet().resolve(id);
eq PnObject.globallyResolveRefTransitionByToken(String id) = (RefTransition) petriNet().resolve(id);
}
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.*;
import java.util.stream.Collectors;
aspect Logging {
static Logger ASTNode.logger = LogManager.getLogger(ASTNode.class);
}
aspect JastAddAPIExtension {
/**
* removes the object from the AST, i.e. removes the reference from its parent to the object
*
* Please note that any intrinsic non-containment relations to the object are not removed.
* @return true, if the object had a parent.
*/
public boolean ASTNode.removeSelf() {
if (getParent() == null) {
return false;
} else {
for (int childIndex = 0; childIndex < getParent().numChildren(); childIndex++) {
if (getParent().getChild(childIndex) == this) {
getParent().removeChild(childIndex);
return true;
}
}
}
throw new RuntimeException("unable to remove child, because it was not contained in its parent!");
}
}
%header {:
package de.tudresden.inf.st.pnml.jastadd.parser;
import de.tudresden.inf.st.pnml.jastadd.model.*; :};
%terminals AND;
%terminals OR;
%terminals NOT;
%terminals VARIABLE;
%typeof goal = "expressions";
%typeof exp = "Exp";
%goal goal;
goal =
exp.exp {: return new Symbol(new Root(exp)); :}
;
exp =
exp.a AND.AND exp.b {: return new Symbol(new AndExp(a, b)); :}
| exp.a OR.OR exp.b {: return new Symbol(new OrExp(a, b)); :}
| NOT.NOT exp.exp {: return new Symbol(new NotExp(exp)); :}
| VARIABLE.v {: return new Symbol(new Var(((String)v.value))); :}
;
package de.tudresden.inf.st.pnml.jastadd.scanner;
import de.tudresden.inf.st.pnml.jastadd.parser.Parser.Terminals;
%%
%public
%final
%class ExpressionScanner
%extends beaver.Scanner
%type beaver.Symbol
%function nextToken
%yylexthrow beaver.Scanner.Exception
%line
%column
%{
private beaver.Symbol sym(short id) {
return new beaver.Symbol(id, yyline + 1, yycolumn + 1, yylength(), yytext());
}
%}
WhiteSpace = [ ] | \t | \f
NewLine = \n | \r | \r\n
Variable = [:jletter:][:jletterdigit:]*
%%
// discard whitespace information
{WhiteSpace} { }
// token definitions
"AND" { return sym(Terminals.AND); }
"OR" { return sym(Terminals.OR); }
"NOT" { return sym(Terminals.NOT); }
{Variable} { return sym(Terminals.VARIABLE); }
<<EOF>> { return sym(Terminals.EOF); }
import de.tudresden.inf.st.pnml.base.data.ClauseValuesDefinition;
aspect SignalExpressions {
syn String ASTNode.printExp();
syn boolean Exp.eval(ClauseValuesDefinition defs);
eq ASTNode.printExp() = "";
eq Root.printExp() {
String result = "";
if(getExp() != null){
result+=getExp().printExp();
}
return result;
}
eq AndExp.printExp() = getA().printExp() + " AND " + getB().printExp();
eq OrExp.printExp() = getA().printExp() + " OR " + getB().printExp();
eq Var.printExp() = getName();
eq NotExp.printExp() = "NOT " + getExp().printExp();
eq AndExp.eval(ClauseValuesDefinition defs) = getA().eval(defs) && getB().eval(defs);
eq OrExp.eval(ClauseValuesDefinition defs) = getA().eval(defs) || getB().eval(defs);
eq Var.eval(ClauseValuesDefinition defs) = defs.getDef(this.getName());
eq NotExp.eval(ClauseValuesDefinition defs) = !getExp().eval(defs);
}
\ No newline at end of file
Root ::= Exp ;
abstract Exp ;
abstract UnaryExp:Exp ::= Exp ;
abstract BinExp:Exp ::= A:Exp B:Exp ;
AndExp:BinExp ;
OrExp:BinExp ;
Var:Exp ::= <Name:String> ;
NotExp:UnaryExp ;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment