Skip to content

Commit

Permalink
WIP: Issue #24 value stack (1st draft)
Browse files Browse the repository at this point in the history
- builds, runs existing ci tests
- interface changes
  - IField
    - deleted, subsumed by IOutput
  - IOutput added methods
    - data transfer methods previously in IField
    - methods for localizing field names
      - map symbolic field names to value stack index
      - getLocalizedFieldIndex()
  - IEffector may throw only EffectorException
    - previously threw only TargetBindingException
  - IToken
    - removed setOrdinal()
    - added getTransducerOrdinal() (defining transducer)
    - added getName() (token literal as String)

- internal changes (value stack)
  - added TransducerStack.Value class
    - contains fields for transducers on stack
    - transducer selection and local fields preserved if stack is pushed
  - implemented value stack in TransducerStack

TODO:
- code review and cleanup
- much more testing, with more complex inputs and outputs

Signed-off-by: jrte <[email protected]>
  • Loading branch information
jrte committed Oct 5, 2023
1 parent 9bdbde0 commit a998fff
Show file tree
Hide file tree
Showing 28 changed files with 1,860 additions and 985 deletions.
21 changes: 17 additions & 4 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,35 @@
</target>

<target name="init" depends="init-ribose,init-test">
<exec outputproperty="git.which" executable="bash">
<arg line="-c 'which git'"/>
</exec>
<exec outputproperty="git.version" executable="git">
<arg line="--version"/>
</exec>
<exec outputproperty="git.branch" executable="git">
<arg line="branch --show-current"/>
</exec>
<exec outputproperty="git.commit" executable="git">
<arg line="log --oneline -n 1"/>
</exec>
<echo message="git @ ${git.which}"/>
<echo message="${git.version}"/>
<echo message="Git branch: ${git.branch}"/>
<echo message="Git commit: ${git.commit}"/>
<echo message="${ant.version}"/>
<echo/>
<echo message="Ant @ ${env.ANT_HOME}"/>
<echo message="${ant.version}"/>
<echo/>
<echo message="Java @ ${env.JAVA_HOME}"/>
<java fork="true" jvm="${jdk}/bin/java" classname="java.lang.Object">
<jvmarg line="-version"/>
</java>
<echo message="Java @ ${env.JAVA_HOME}"/>
<echo/>
<exec executable="bash">
<arg line="./rinr version"/>
</exec>
<echo/>
<echo message="Building ${ribose.version}"/>
</target>

Expand Down Expand Up @@ -216,8 +228,9 @@
<exec failonerror="true" executable="bash">
<arg line="./rinr patterns/alpha.inr ${ribose.patterns} patterns/after.inr"/>
</exec>
<echo/>
<echo message="Building ${build.compiler.model}/TCompile.model"/>
<exec failonerror="true" executable="bash" output="${build.compiler.model}/TCompile.map">
<exec failonerror="true" executable="bash">
<arg line="./ribose ${jargs} compile --target com.characterforming.jrte.engine.ModelCompiler ${build.compiler.model} ${build.compiler.model}/TCompile.model"/>
</exec>
<fixcrlf file="${build.compiler.model}/TCompile.map" eol="lf"/>
Expand Down Expand Up @@ -279,7 +292,7 @@
<delete file="build/Test.model"/>
<delete file="build/Test.map"/>
<echo message="Building build/Test.model"/>
<exec failonerror="true" executable="bash" output="build/Test.map">
<exec failonerror="true" executable="bash">
<arg line="./ribose ${jargs} compile --target-path ${jars.dir}/${ribose.version}-test.jar --target com.characterforming.jrte.test.TestTarget ${build.automata} build/Test.model"/>
</exec>
<fixcrlf file="build/Test.map" eol="lf"/>
Expand Down
674 changes: 674 additions & 0 deletions etc/ginr/COPYING

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
For example, the ribose compiler model {@code TCompile.model} includes an {@code Automaton}
transducer pattern, shown <a href="https://github.com/jrte/ribose/blob/master/patterns/ribose/Automaton.inr"
target="_blank">here</a>, that is compiled with the {@code rinr} shell script as follows:
<br><pre>./rinr patterns/alpha.inr patterns/ribose patterns/after.inr</pre>
which produces {@code build/compiler/Automaton.dfa}. The ribose model compiler then
transduces each FST (*.dfa) file in the {@code build/automata} directory to assemble
a ribose transducer and saves each transducer in {@code TCompile.model}.
<br><pre>./rinr patterns/alpha.inr patterns/ribose patterns/after.inr</pre> to produce
{@code build/compiler/Automaton.dfa}. The ribose model compiler then transduces each FST
(*.dfa) file in the {@code build/automata} directory to assemble ribose transducers
and saves them in {@code TCompile.model}.
<br><pre>./ribose compile build/automata build/TCompile.model</pre>
The target in this case is the {@code ModelCompiler}, which expresses three
effectors to extract {@code Header} and {@code Transition} records and finally
Expand Down
10 changes: 5 additions & 5 deletions patterns/test/LinuxKernelLog.inr
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ LinuxKernel = nil (
###

LinuxKernelDropped = (
header (space, select[`~tag`]) ('DROPPED' @@ PasteAny) fields
(nil, clear[`~*`] select[`~timestamp`]) header (space, select[`~tag`]) ('DROPPED' @@ PasteAny) fields
((nl, save signal[`!nil`] stop) | (eos, save signal[`!eos`] stop))
):dfamin;

LinuxKernelLimited = (
header (space, select[`~tag`]) ('LIMITED' @@ PasteAny) fields
(nil, clear[`~*`] select[`~timestamp`]) header (space, select[`~tag`]) ('LIMITED' @@ PasteAny) fields
((nl, save signal[`!nil`] stop) | (eos, save signal[`!eos`] stop))
):dfamin;

LinuxKernelAborted = (
header (space, select[`~tag`]) ('ABORTED' @@ PasteAny) fields
(nil, clear[`~*`] select[`~timestamp`]) header (space, select[`~tag`]) ('ABORTED' @@ PasteAny) fields
((nl, save signal[`!nil`] stop) | (eos, save signal[`!eos`] stop))
):dfamin;

Expand All @@ -102,11 +102,11 @@ aborted = LinuxKernelAborted$0;

iptables = (dropped | limited | aborted) / (nl | eos);
null = ((iptables:pref) - iptables) nul (byte - nl)*;
next = reset continue;
next = reset signal[`!nil`];

LinuxKernelStrict = (
(
(nil, mark)
(nil, mark signal[`!nil`])
(
(dropped, next start[`@LinuxKernelDropped`])
| (limited, next start[`@LinuxKernelLimited`])
Expand Down
2 changes: 1 addition & 1 deletion ribose
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ execCompile() {
fi
fi
if (($#==4)); then
$JAVA -ea -cp $path $vmargs com.characterforming.ribose.Ribose compile "$@"
$JAVA -ea -cp $path $vmargs com.characterforming.ribose.Ribose compile "$@"
elif (($#>0)); then
$JAVA -ea -cp $path $vmargs com.characterforming.ribose.Ribose compile --target com.characterforming.ribose.base.SimpleTarget "$@"
else
Expand Down
2 changes: 1 addition & 1 deletion rinr
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ if [[ ! -x "$ginr" ]]; then
fi

if (($#==1)) && [[ "$1" == "version" ]]; then
echo ginr @ $(realpath "$ginr")
echo ":bye;" | "$ginr" | grep ' '
echo ginr@$(realpath "$ginr")
exit 0
elif (($# <2)) || (($#>3)); then
echo "Usage: rinr <prologue-file> <ginr-source-directory> [<epilogue-file>]"
Expand Down
6 changes: 3 additions & 3 deletions src/com/characterforming/jrte/engine/Automaton.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ boolean assemble(File inrAutomataDirectory) {
name, inrFile.getPath(), e.getMessage()));
}
try {
compiler.reset(inrFile);
this.compiler.reset(inrFile);
commit = this.parse(bytes);
if (commit) {
compiler.saveTransducer();
this.compiler.saveTransducer();
}
} catch (ModelException | ParseException e) {
String msg = String.format("%1$s: Exception caught assembling compiler model file; %2$s",
filename, e.getMessage());
rtcLogger.log(Level.SEVERE, msg, e);
compiler.addError(msg);
this.compiler.addError(msg);
commit = false;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/com/characterforming/jrte/engine/Chain.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ boolean isEmpty() {
return this.effectVector.length == 0;
}

boolean isScalar() {
boolean isEffector() {
return this.effectVector.length == 2
&& this.effectVector[1] == 0;
}

boolean isParameterized() {
boolean isParameterizedEffector() {
return this.effectVector.length == 3
&& this.effectVector[2] == 0
&& this.effectVector[0] < 0;
&& this.effectVector[0] < 0
&& this.effectVector[2] == 0;
}
}
176 changes: 0 additions & 176 deletions src/com/characterforming/jrte/engine/Field.java

This file was deleted.

Loading

0 comments on commit a998fff

Please sign in to comment.