Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move debug things to its own package, add support for Jay instead of …

…Jacc, and improve performance substantially
  • Loading branch information...
commit b2d6cf66fcd9b4bfeefc5f974794bb9c452790b3 1 parent 63afc0e
@olabini authored
View
22 TIMINGS
@@ -0,0 +1,22 @@
+Syck
+ scanning ../jruby_newyaml/bench/big_yaml.yml 10000 times took 13959ms
+ parsing ../jruby_newyaml/bench/big_yaml.yml 10000 times took 16101ms
+
+JvYAMLb
+ scanning ../jruby_newyaml/bench/big_yaml.yml 10000 times took 5325ms
+ parsing ../jruby_newyaml/bench/big_yaml.yml 10000 times took 15794ms
+
+Yecht - Original
+ scanning ../jruby_newyaml/bench/big_yaml.yml 10000 times took 93658ms
+ parsing ../jruby_newyaml/bench/big_yaml.yml 10000 times took 117213ms
+
+Yecht - Fixed scanner
+ scanning ../jruby_newyaml/bench/big_yaml.yml 10000 times took 12207ms
+ parsing ../jruby_newyaml/bench/big_yaml.yml 10000 times took 31280ms
+
+Yecht - Fixed parser (switched to Jay)
+ scanning ../jruby_newyaml/bench/big_yaml.yml 10000 times took 12960ms
+ parsing ../jruby_newyaml/bench/big_yaml.yml 10000 times took 15411ms
+
+
+
View
37 build.xml
@@ -56,6 +56,13 @@
</exec>
</target>
+ <target name="jay" depends="prepare" description="Standalone target that generates all our jay based source files.">
+ <exec executable="${jay.home}/jay" failonerror="true" output="${main.src.dir}/org/yecht/DefaultYAMLParser.java">
+ <arg line="${main.src.dir}/org/yecht/DefaultYAMLParser.y"/>
+ <arg line="parser/skeleton.java"/>
+ </exec>
+ </target>
+
<target name="jacc" depends="prepare" description="Standalone target that generates all our jacc based source files.">
<java jar="lib/jacc.jar" fork="true">
<arg line="${main.src.dir}/org/yecht/YAMLGrammar.jacc"/>
@@ -70,7 +77,7 @@
</javac>
</target>
- <target name="compile-with-gen" depends="re2j, jacc" description="Compile the source files for the project.">
+ <target name="compile-with-gen" depends="re2j, jacc, jay" description="Compile the source files for the project.">
<javac destdir="${yecht.classes.dir}" debug="true" source="${javac.version}" target="${javac.version}">
<classpath refid="build.classpath"/>
<src path="${main.src.dir}"/>
@@ -78,33 +85,7 @@
</javac>
</target>
- <target name="compile-tests" depends="compile" description="Compile the test source files for the project.">
- <javac destdir="${test.classes.dir}" debug="true" source="${javac.version}" target="${javac.version}">
- <classpath refid="build.classpath"/>
- <classpath>
- <pathelement location="${yecht.classes.dir}"/>
- </classpath>
- <src path="${test.src.dir}"/>
- </javac>
- </target>
-
- <target name="test" depends="compile-tests" description="Runs all tests">
- <junit>
- <classpath refid="build.classpath"/>
- <classpath>
- <pathelement location="${yecht.classes.dir}"/>
- <pathelement location="${test.classes.dir}"/>
- </classpath>
- <formatter type="brief" usefile="false"/>
- <batchtest>
- <fileset dir="${test.src.dir}">
- <include name="**/*Test.java"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
-
- <target name="jar" depends="test" description="Create the yecht.jar file">
+ <target name="jar" depends="compile" description="Create the yecht.jar file">
<jar destfile="${lib.dir}/yecht-0.0.1.jar">
<fileset dir="${yecht.classes.dir}">
<include name="**/*.class"/>
View
245 parser/skeleton.java
@@ -0,0 +1,245 @@
+# jay skeleton for Java
+
+# character in column 1 determines outcome...
+# # is a comment
+# . is copied
+# t is copied as //t unless -t is set
+# other lines are interpreted to call jay procedures
+
+ version Java 1.1.0 (c) 2002-2006 ats@cs.rit.edu
+.
+ prolog ## %{ ... %} prior to the first %%
+
+. // %token constants
+ tokens public static final int
+.
+. /** number of final state.
+. */
+ yyFinal protected static final int yyFinal =
+.
+. /** parser tables.
+. Order is mandated by <i>jay</i>.
+. */
+. protected static final short[] yyLhs = {
+ yyLhs
+. }, yyLen = {
+ yyLen
+. }, yyDefRed = {
+ yyDefRed
+. }, yyDgoto = {
+ yyDgoto
+. }, yySindex = {
+ yySindex
+. }, yyRindex = {
+ yyRindex
+. }, yyGindex = {
+ yyGindex
+. }, yyTable = {
+ yyTable
+. }, yyCheck = {
+ yyCheck
+. };
+.
+. /** maps symbol value to printable name.
+. @see #yyExpecting
+. */
+. protected static final String[] yyNames = {
+ yyNames-strings
+. };
+.
+t /** printable rules for debugging.
+t */
+t protected static final String [] yyRule = {
+ yyRule-strings
+t };
+t
+t /** debugging support, requires the package <tt>jay.yydebug</tt>.
+t Set to <tt>null</tt> to suppress debugging messages.
+t */
+t protected jay.yydebug.yyDebug yydebug;
+t
+t /** index-checked interface to {@link #yyNames}.
+t @param token single character or <tt>%token</tt> value.
+t @return token name or <tt>[illegal]</tt> or <tt>[unknown]</tt>.
+t */
+t public static final String yyName (int token) {
+t if (token < 0 || token > yyNames.length) return "[illegal]";
+t String name;
+t if ((name = yyNames[token]) != null) return name;
+t return "[unknown]";
+t }
+t
+.
+. /** must be implemented by a scanner object to supply input to the parser.
+. Nested for convenience, does not depend on parser class.
+. */
+. public interface yyInput {
+.
+. /** move on to next token.
+. @return <tt>false</tt> if positioned beyond tokens.
+. @throws IOException on input error.
+. */
+. boolean advance () throws java.io.IOException;
+.
+. /** classifies current token.
+. Should not be called if {@link #advance()} returned <tt>false</tt>.
+. @return current <tt>%token</tt> or single character.
+. */
+. int token ();
+.
+. /** associated with current token.
+. Should not be called if {@link #advance()} returned <tt>false</tt>.
+. @return value for {@link #token()}.
+. */
+. Object value ();
+. }
+.
+. /** the generated parser, with debugging messages.
+. Maintains a dynamic state and value stack.
+. @param yyLex scanner.
+. @param yydebug debug message writer implementing <tt>yyDebug</tt>, or <tt>null</tt>.
+. @return result of the last reduction, if any.
+. */
+. public Object yyparse (yyInput yyLex, Object yydebug)
+. throws java.io.IOException {
+t this.yydebug = (jay.yydebug.yyDebug)yydebug;
+. return yyparse(yyLex);
+. }
+.
+. /** initial size and increment of the state/value stack [default 256].
+. This is not final so that it can be overwritten outside of invocations
+. of {@link #yyparse}.
+. */
+. protected int yyMax;
+.
+. /** executed at the beginning of a reduce action.
+. Used as <tt>$$ = yyDefault($1)</tt>, prior to the user-specified action, if any.
+. Can be overwritten to provide deep copy, etc.
+. @param first value for <tt>$1</tt>, or <tt>null</tt>.
+. @return first.
+. */
+. protected Object yyDefault (Object first) {
+. return first;
+. }
+.
+. /** the generated parser.
+. Maintains a dynamic state and value stack.
+. @param yyLex scanner.
+. @return result of the last reduction, if any.
+. */
+. public Object yyparse (yyInput yyLex) throws java.io.IOException {
+. if (yyMax <= 0) yyMax = 256; // initial size
+. int yyState = 0, yyStates[] = new int[yyMax]; // state stack
+. Object yyVal = null, yyVals[] = new Object[yyMax]; // value stack
+. int yyToken = -1; // current input
+. int yyErrorFlag = 0; // #tokens to shift
+.
+ local ## %{ ... %} after the first %%
+
+. yyLoop: for (int yyTop = 0;; ++ yyTop) {
+. if (yyTop >= yyStates.length) { // dynamically increase
+. int[] i = new int[yyStates.length+yyMax];
+. System.arraycopy(yyStates, 0, i, 0, yyStates.length);
+. yyStates = i;
+. Object[] o = new Object[yyVals.length+yyMax];
+. System.arraycopy(yyVals, 0, o, 0, yyVals.length);
+. yyVals = o;
+. }
+. yyStates[yyTop] = yyState;
+. yyVals[yyTop] = yyVal;
+t if (yydebug != null) yydebug.push(yyState, yyVal);
+.
+. yyDiscarded: for (;;) { // discarding a token does not change stack
+. int yyN;
+. if ((yyN = yyDefRed[yyState]) == 0) { // else [default] reduce (yyN)
+. if (yyToken < 0) {
+. yyToken = yyLex.advance() ? yyLex.token() : 0;
+t if (yydebug != null)
+t yydebug.lex(yyState, yyToken, yyName(yyToken), yyLex.value());
+. }
+. if ((yyN = yySindex[yyState]) != 0 && (yyN += yyToken) >= 0
+. && yyN < yyTable.length && yyCheck[yyN] == yyToken) {
+t if (yydebug != null)
+t yydebug.shift(yyState, yyTable[yyN], yyErrorFlag > 0 ? yyErrorFlag-1 : 0);
+. yyState = yyTable[yyN]; // shift to yyN
+. yyVal = yyLex.value();
+. yyToken = -1;
+. if (yyErrorFlag > 0) -- yyErrorFlag;
+. continue yyLoop;
+. }
+. if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0
+. && yyN < yyTable.length && yyCheck[yyN] == yyToken)
+. yyN = yyTable[yyN]; // reduce (yyN)
+. else
+. switch (yyErrorFlag) {
+.
+. case 0:
+. yyerror("syntax error");
+t if (yydebug != null) yydebug.error("syntax error");
+.
+. case 1: case 2:
+. yyErrorFlag = 3;
+. do {
+. if ((yyN = yySindex[yyStates[yyTop]]) != 0
+. && (yyN += yyErrorCode) >= 0 && yyN < yyTable.length
+. && yyCheck[yyN] == yyErrorCode) {
+t if (yydebug != null)
+t yydebug.shift(yyStates[yyTop], yyTable[yyN], 3);
+. yyState = yyTable[yyN];
+. yyVal = yyLex.value();
+. continue yyLoop;
+. }
+t if (yydebug != null) yydebug.pop(yyStates[yyTop]);
+. } while (-- yyTop >= 0);
+t if (yydebug != null) yydebug.reject();
+. yyerror("irrecoverable syntax error");
+.
+. case 3:
+. if (yyToken == 0) {
+t if (yydebug != null) yydebug.reject();
+. yyerror("irrecoverable syntax error at end-of-file");
+. }
+t if (yydebug != null)
+t yydebug.discard(yyState, yyToken, yyName(yyToken), yyLex.value());
+. yyToken = -1;
+. continue yyDiscarded; // leave stack alone
+. }
+. }
+. int yyV = yyTop + 1-yyLen[yyN];
+t if (yydebug != null)
+t yydebug.reduce(yyState, yyStates[yyV-1], yyN, yyRule[yyN], yyLen[yyN]);
+. yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]);
+. switch (yyN) {
+
+ actions ## code from the actions within the grammar
+
+. }
+. yyTop -= yyLen[yyN];
+. yyState = yyStates[yyTop];
+. int yyM = yyLhs[yyN];
+. if (yyState == 0 && yyM == 0) {
+t if (yydebug != null) yydebug.shift(0, yyFinal);
+. yyState = yyFinal;
+. if (yyToken < 0) {
+. yyToken = yyLex.advance() ? yyLex.token() : 0;
+t if (yydebug != null)
+t yydebug.lex(yyState, yyToken,yyName(yyToken), yyLex.value());
+. }
+. if (yyToken == 0) {
+t if (yydebug != null) yydebug.accept(yyVal);
+. return yyVal;
+. }
+. continue yyLoop;
+. }
+. if ((yyN = yyGindex[yyM]) != 0 && (yyN += yyState) >= 0
+. && yyN < yyTable.length && yyCheck[yyN] == yyState)
+. yyState = yyTable[yyN];
+. else
+. yyState = yyDgoto[yyM];
+t if (yydebug != null) yydebug.shift(yyStates[yyTop], yyState);
+. continue yyLoop;
+. }
+. }
+. }
+.
+ epilog ## text following second %%
View
2  src/main/org/yecht/BytecodeScanner.java
@@ -1,4 +1,4 @@
-/* Generated by re2j 0.13.6.dev on Thu Jul 23 15:22:11 2009 */
+/* Generated by re2j 0.13.6.dev on Thu Jul 23 17:15:02 2009 */
package org.yecht;
import java.io.IOException;
View
923 src/main/org/yecht/DefaultYAMLParser.java
@@ -0,0 +1,923 @@
+// created by jay 1.1.0 (c) 2002-2006 ats@cs.rit.edu
+// skeleton Java 1.1.0 (c) 2002-2006 ats@cs.rit.edu
+
+ // line 2 "src/main/org/yecht/DefaultYAMLParser.y"
+package org.yecht;
+
+public class DefaultYAMLParser {
+
+ // line 10 "-"
+ // %token constants
+ public static final int YAML_ANCHOR = 257;
+ public static final int YAML_ALIAS = 258;
+ public static final int YAML_TRANSFER = 259;
+ public static final int YAML_TAGURI = 260;
+ public static final int YAML_ITRANSFER = 261;
+ public static final int YAML_WORD = 262;
+ public static final int YAML_PLAIN = 263;
+ public static final int YAML_BLOCK = 264;
+ public static final int YAML_DOCSEP = 265;
+ public static final int YAML_IOPEN = 266;
+ public static final int YAML_INDENT = 267;
+ public static final int YAML_IEND = 268;
+ public static final int yyErrorCode = 256;
+
+ /** number of final state.
+ */
+ protected static final int yyFinal = 13;
+
+ /** parser tables.
+ Order is mandated by <i>jay</i>.
+ */
+ protected static final short[] yyLhs = {
+//yyLhs 79
+ -1, 0, 0, 0, 1, 1, 4, 4, 4, 4,
+ 4, 2, 2, 8, 8, 8, 8, 8, 8, 6,
+ 6, 9, 10, 7, 7, 3, 3, 3, 3, 3,
+ 3, 3, 3, 5, 5, 5, 5, 5, 11, 11,
+ 17, 15, 15, 15, 15, 15, 15, 16, 16, 16,
+ 12, 12, 18, 18, 19, 19, 13, 13, 21, 21,
+ 21, 21, 21, 21, 23, 23, 24, 25, 22, 22,
+ 22, 22, 20, 14, 14, 26, 26, 27, 27,
+ }, yyLen = {
+//yyLen 79
+ 2, 1, 2, 0, 1, 1, 1, 2, 2, 2,
+ 3, 1, 1, 3, 0, 2, 2, 2, 2, 1,
+ 2, 1, 1, 1, 2, 2, 2, 2, 2, 1,
+ 1, 1, 3, 1, 1, 1, 1, 1, 3, 3,
+ 2, 3, 2, 3, 2, 3, 2, 1, 3, 2,
+ 3, 2, 1, 3, 1, 1, 3, 3, 3, 2,
+ 3, 2, 3, 2, 1, 3, 1, 3, 1, 3,
+ 3, 2, 3, 3, 2, 1, 3, 1, 1,
+ }, yyDefRed = {
+//yyDefRed 127
+ 0, 0, 29, 0, 0, 0, 30, 31, 33, 0,
+ 19, 0, 0, 0, 1, 4, 5, 6, 0, 34,
+ 35, 36, 37, 28, 9, 25, 7, 26, 8, 0,
+ 0, 0, 27, 0, 0, 0, 0, 0, 11, 2,
+ 0, 12, 51, 0, 0, 52, 55, 74, 0, 78,
+ 0, 75, 0, 0, 0, 20, 0, 0, 0, 0,
+ 0, 0, 47, 0, 0, 0, 68, 0, 18, 16,
+ 17, 0, 0, 0, 0, 15, 0, 0, 0, 0,
+ 0, 50, 0, 73, 0, 22, 0, 46, 63, 0,
+ 42, 59, 0, 44, 61, 40, 0, 23, 32, 0,
+ 10, 21, 38, 39, 0, 56, 57, 0, 0, 13,
+ 72, 53, 76, 64, 0, 0, 0, 0, 0, 0,
+ 65, 24, 48, 69, 70, 66, 67,
+ }, yyDgoto = {
+//yyDgoto 28
+ 13, 38, 39, 15, 16, 17, 18, 98, 41, 102,
+ 99, 19, 20, 21, 22, 60, 61, 62, 44, 45,
+ 46, 63, 64, 65, 126, 66, 50, 51,
+ }, yySindex = {
+//yySindex 127
+ -65, -1, 0, -1, -1, 170, 0, 0, 0, 13,
+ 0, -55, -12, 0, 0, 0, 0, 0, -45, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 170,
+ 170, 170, 0, -128, 13, 13, 13, 180, 0, 0,
+ -34, 0, 0, -48, -38, 0, 0, 0, -48, 0,
+ -40, 0, -89, -89, -89, 0, 13, -1, -226, -226,
+ -249, -224, 0, -249, -224, -35, 0, -226, 0, 0,
+ 0, 180, 180, 180, 159, 0, -76, -76, -76, -249,
+ 13, 0, -1, 0, -1, 0, -23, 0, 0, -23,
+ 0, 0, -23, 0, 0, 0, -234, 0, 0, -226,
+ 0, 0, 0, 0, -10, 0, 0, -23, 13, 0,
+ 0, 0, 0, 0, -234, -234, -234, -234, -234, -234,
+ 0, 0, 0, 0, 0, 0, 0,
+ }, yyRindex = {
+//yyRindex 127
+ 37, 0, 0, 0, 0, 0, 0, 0, 0, 39,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0,
+ -220, 0, 0, -32, 0, 0, 0, 0, -39, 0,
+ 0, 0, 0, 0, 0, 0, -205, 0, -2, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, -220, 0, -220, -220, -220, 0,
+ -41, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, -196, 0, 0, -185, -205, 0,
+ 0, 0, 0, 0, -214, -208, -203, -199, -192, -181,
+ 0, 0, 0, 0, 0, 0, 0,
+ }, yyGindex = {
+//yyGindex 28
+ 0, 9, -49, 277, 284, 0, 72, -46, 337, -47,
+ 280, 0, 0, 0, 0, -3, -62, -79, 0, 6,
+ -4, 43, -22, 0, 0, -15, 0, 14,
+ }, yyTable = {
+//yyTable 447
+ 56, 14, 11, 14, 84, 77, 82, 95, 49, 14,
+ 80, 56, 54, 100, 103, 11, 105, 106, 57, 101,
+ 43, 48, 56, 108, 114, 122, 11, 116, 123, 57,
+ 118, 110, 109, 85, 12, 56, 11, 3, 42, 14,
+ 57, 85, 97, 85, 101, 14, 11, 12, 14, 87,
+ 90, 93, 14, 121, 45, 81, 64, 11, 12, 125,
+ 62, 54, 14, 14, 115, 41, 96, 117, 12, 58,
+ 119, 49, 49, 87, 90, 93, 43, 33, 12, 11,
+ 49, 40, 71, 71, 14, 83, 77, 60, 111, 12,
+ 11, 43, 124, 48, 14, 88, 91, 94, 112, 0,
+ 0, 33, 33, 33, 11, 33, 40, 40, 40, 74,
+ 0, 12, 40, 47, 0, 0, 0, 0, 0, 88,
+ 91, 94, 12, 0, 0, 0, 14, 0, 40, 29,
+ 2, 30, 31, 5, 6, 7, 12, 0, 10, 55,
+ 0, 0, 0, 74, 74, 74, 74, 0, 40, 40,
+ 40, 0, 40, 0, 0, 0, 0, 0, 33, 0,
+ 0, 33, 0, 0, 33, 0, 0, 0, 52, 2,
+ 53, 54, 5, 6, 7, 8, 0, 10, 85, 33,
+ 40, 76, 2, 77, 78, 37, 6, 7, 8, 0,
+ 10, 85, 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 1, 2, 3, 4, 5, 6, 7, 8,
+ 0, 10, 52, 2, 53, 54, 5, 6, 7, 8,
+ 0, 10, 55, 76, 2, 77, 78, 37, 6, 7,
+ 8, 0, 10, 55, 29, 2, 30, 31, 5, 6,
+ 7, 0, 0, 10, 0, 1, 2, 3, 4, 5,
+ 6, 7, 8, 0, 10, 0, 1, 2, 3, 4,
+ 5, 6, 7, 8, 0, 10, 0, 0, 14, 14,
+ 34, 2, 35, 36, 37, 6, 7, 8, 23, 10,
+ 25, 27, 32, 0, 0, 24, 0, 26, 28, 0,
+ 0, 0, 0, 0, 0, 58, 0, 0, 0, 0,
+ 0, 0, 59, 0, 0, 0, 23, 25, 27, 0,
+ 67, 23, 25, 27, 32, 0, 0, 58, 24, 26,
+ 28, 0, 0, 0, 59, 0, 0, 0, 0, 23,
+ 25, 27, 86, 89, 92, 0, 24, 26, 28, 0,
+ 0, 104, 0, 0, 107, 0, 0, 0, 23, 25,
+ 27, 67, 0, 23, 25, 27, 86, 89, 92, 0,
+ 24, 26, 28, 113, 0, 0, 113, 0, 0, 113,
+ 0, 68, 69, 70, 75, 0, 120, 79, 0, 0,
+ 0, 0, 0, 0, 113, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 104, 107, 104, 107, 104, 107,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 69,
+ 70, 79, 0, 68, 69, 70, 71, 2, 72, 73,
+ 37, 6, 7, 0, 0, 10, 55, 29, 2, 30,
+ 31, 5, 6, 7, 0, 0, 10, 71, 2, 72,
+ 73, 37, 6, 7, 0, 0, 10,
+ }, yyCheck = {
+//yyCheck 447
+ 45, 0, 91, 44, 44, 44, 44, 56, 12, 0,
+ 58, 45, 44, 59, 61, 91, 63, 64, 63, 268,
+ 11, 12, 45, 58, 86, 104, 91, 89, 107, 63,
+ 92, 80, 79, 267, 123, 45, 91, 0, 93, 0,
+ 63, 267, 268, 267, 268, 44, 91, 123, 268, 52,
+ 53, 54, 93, 99, 268, 93, 58, 91, 123, 108,
+ 268, 93, 267, 268, 86, 268, 57, 89, 123, 268,
+ 92, 267, 268, 76, 77, 78, 268, 5, 123, 91,
+ 84, 9, 267, 268, 125, 125, 125, 268, 82, 123,
+ 91, 82, 107, 84, 93, 52, 53, 54, 84, -1,
+ -1, 29, 30, 31, 91, 33, 34, 35, 36, 37,
+ -1, 123, 40, 125, -1, -1, -1, -1, -1, 76,
+ 77, 78, 123, -1, -1, -1, 125, -1, 56, 257,
+ 258, 259, 260, 261, 262, 263, 123, -1, 266, 267,
+ -1, -1, -1, 71, 72, 73, 74, -1, 76, 77,
+ 78, -1, 80, -1, -1, -1, -1, -1, 86, -1,
+ -1, 89, -1, -1, 92, -1, -1, -1, 257, 258,
+ 259, 260, 261, 262, 263, 264, -1, 266, 267, 107,
+ 108, 257, 258, 259, 260, 261, 262, 263, 264, -1,
+ 266, 267, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 257, 258, 259, 260, 261, 262, 263, 264,
+ -1, 266, 257, 258, 259, 260, 261, 262, 263, 264,
+ -1, 266, 267, 257, 258, 259, 260, 261, 262, 263,
+ 264, -1, 266, 267, 257, 258, 259, 260, 261, 262,
+ 263, -1, -1, 266, -1, 257, 258, 259, 260, 261,
+ 262, 263, 264, -1, 266, -1, 257, 258, 259, 260,
+ 261, 262, 263, 264, -1, 266, -1, -1, 267, 268,
+ 257, 258, 259, 260, 261, 262, 263, 264, 1, 266,
+ 3, 4, 5, -1, -1, 1, -1, 3, 4, -1,
+ -1, -1, -1, -1, -1, 18, -1, -1, -1, -1,
+ -1, -1, 18, -1, -1, -1, 29, 30, 31, -1,
+ 33, 34, 35, 36, 37, -1, -1, 40, 34, 35,
+ 36, -1, -1, -1, 40, -1, -1, -1, -1, 52,
+ 53, 54, 52, 53, 54, -1, 52, 53, 54, -1,
+ -1, 61, -1, -1, 64, -1, -1, -1, 71, 72,
+ 73, 74, -1, 76, 77, 78, 76, 77, 78, -1,
+ 76, 77, 78, 86, -1, -1, 89, -1, -1, 92,
+ -1, 34, 35, 36, 37, -1, 96, 40, -1, -1,
+ -1, -1, -1, -1, 107, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 114, 115, 116, 117, 118, 119,
+ -1, -1, -1, -1, -1, -1, -1, -1, 71, 72,
+ 73, 74, -1, 76, 77, 78, 257, 258, 259, 260,
+ 261, 262, 263, -1, -1, 266, 267, 257, 258, 259,
+ 260, 261, 262, 263, -1, -1, 266, 257, 258, 259,
+ 260, 261, 262, 263, -1, -1, 266,
+ };
+
+ /** maps symbol value to printable name.
+ @see #yyExpecting
+ */
+ protected static final String[] yyNames = {
+ "end-of-file",null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,"','","'-'",null,null,null,null,null,null,null,
+ null,null,null,null,null,"':'",null,null,null,null,"'?'",null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,"'['",null,
+ "']'",null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,"'{'",null,"'}'",null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,
+ "YAML_ANCHOR","YAML_ALIAS","YAML_TRANSFER","YAML_TAGURI",
+ "YAML_ITRANSFER","YAML_WORD","YAML_PLAIN","YAML_BLOCK","YAML_DOCSEP",
+ "YAML_IOPEN","YAML_INDENT","YAML_IEND",
+ };
+
+//t /** printable rules for debugging.
+//t */
+//t protected static final String [] yyRule = {
+//t "$accept : doc",
+//t "doc : atom",
+//t "doc : YAML_DOCSEP atom_or_empty",
+//t "doc :",
+//t "atom : word_rep",
+//t "atom : ind_rep",
+//t "ind_rep : struct_rep",
+//t "ind_rep : YAML_TRANSFER ind_rep",
+//t "ind_rep : YAML_TAGURI ind_rep",
+//t "ind_rep : YAML_ANCHOR ind_rep",
+//t "ind_rep : indent_open ind_rep indent_flex_end",
+//t "atom_or_empty : atom",
+//t "atom_or_empty : empty",
+//t "empty : indent_open empty indent_end",
+//t "empty :",
+//t "empty : YAML_ITRANSFER empty",
+//t "empty : YAML_TRANSFER empty",
+//t "empty : YAML_TAGURI empty",
+//t "empty : YAML_ANCHOR empty",
+//t "indent_open : YAML_IOPEN",
+//t "indent_open : indent_open YAML_INDENT",
+//t "indent_end : YAML_IEND",
+//t "indent_sep : YAML_INDENT",
+//t "indent_flex_end : YAML_IEND",
+//t "indent_flex_end : indent_sep indent_flex_end",
+//t "word_rep : YAML_TRANSFER word_rep",
+//t "word_rep : YAML_TAGURI word_rep",
+//t "word_rep : YAML_ITRANSFER word_rep",
+//t "word_rep : YAML_ANCHOR word_rep",
+//t "word_rep : YAML_ALIAS",
+//t "word_rep : YAML_WORD",
+//t "word_rep : YAML_PLAIN",
+//t "word_rep : indent_open word_rep indent_flex_end",
+//t "struct_rep : YAML_BLOCK",
+//t "struct_rep : implicit_seq",
+//t "struct_rep : inline_seq",
+//t "struct_rep : implicit_map",
+//t "struct_rep : inline_map",
+//t "implicit_seq : indent_open top_imp_seq indent_end",
+//t "implicit_seq : indent_open in_implicit_seq indent_end",
+//t "basic_seq : '-' atom_or_empty",
+//t "top_imp_seq : YAML_TRANSFER indent_sep in_implicit_seq",
+//t "top_imp_seq : YAML_TRANSFER top_imp_seq",
+//t "top_imp_seq : YAML_TAGURI indent_sep in_implicit_seq",
+//t "top_imp_seq : YAML_TAGURI top_imp_seq",
+//t "top_imp_seq : YAML_ANCHOR indent_sep in_implicit_seq",
+//t "top_imp_seq : YAML_ANCHOR top_imp_seq",
+//t "in_implicit_seq : basic_seq",
+//t "in_implicit_seq : in_implicit_seq indent_sep basic_seq",
+//t "in_implicit_seq : in_implicit_seq indent_sep",
+//t "inline_seq : '[' in_inline_seq ']'",
+//t "inline_seq : '[' ']'",
+//t "in_inline_seq : inline_seq_atom",
+//t "in_inline_seq : in_inline_seq ',' inline_seq_atom",
+//t "inline_seq_atom : atom",
+//t "inline_seq_atom : basic_mapping",
+//t "implicit_map : indent_open top_imp_map indent_end",
+//t "implicit_map : indent_open in_implicit_map indent_end",
+//t "top_imp_map : YAML_TRANSFER indent_sep in_implicit_map",
+//t "top_imp_map : YAML_TRANSFER top_imp_map",
+//t "top_imp_map : YAML_TAGURI indent_sep in_implicit_map",
+//t "top_imp_map : YAML_TAGURI top_imp_map",
+//t "top_imp_map : YAML_ANCHOR indent_sep in_implicit_map",
+//t "top_imp_map : YAML_ANCHOR top_imp_map",
+//t "complex_key : word_rep",
+//t "complex_key : '?' atom indent_sep",
+//t "complex_value : atom_or_empty",
+//t "complex_mapping : complex_key ':' complex_value",
+//t "in_implicit_map : complex_mapping",
+//t "in_implicit_map : in_implicit_map indent_sep basic_seq",
+//t "in_implicit_map : in_implicit_map indent_sep complex_mapping",
+//t "in_implicit_map : in_implicit_map indent_sep",
+//t "basic_mapping : atom ':' atom_or_empty",
+//t "inline_map : '{' in_inline_map '}'",
+//t "inline_map : '{' '}'",
+//t "in_inline_map : inline_map_atom",
+//t "in_inline_map : in_inline_map ',' inline_map_atom",
+//t "inline_map_atom : atom",
+//t "inline_map_atom : basic_mapping",
+//t };
+//t
+//t /** debugging support, requires the package <tt>jay.yydebug</tt>.
+//t Set to <tt>null</tt> to suppress debugging messages.
+//t */
+//t protected jay.yydebug.yyDebug yydebug;
+//t
+//t /** index-checked interface to {@link #yyNames}.
+//t @param token single character or <tt>%token</tt> value.
+//t @return token name or <tt>[illegal]</tt> or <tt>[unknown]</tt>.
+//t */
+//t public static final String yyName (int token) {
+//t if (token < 0 || token > yyNames.length) return "[illegal]";
+//t String name;
+//t if ((name = yyNames[token]) != null) return name;
+//t return "[unknown]";
+//t }
+//t
+
+ /** must be implemented by a scanner object to supply input to the parser.
+ Nested for convenience, does not depend on parser class.
+ */
+ public interface yyInput {
+
+ /** move on to next token.
+ @return <tt>false</tt> if positioned beyond tokens.
+ @throws IOException on input error.
+ */
+ boolean advance () throws java.io.IOException;
+
+ /** classifies current token.
+ Should not be called if {@link #advance()} returned <tt>false</tt>.
+ @return current <tt>%token</tt> or single character.
+ */
+ int token ();
+
+ /** associated with current token.
+ Should not be called if {@link #advance()} returned <tt>false</tt>.
+ @return value for {@link #token()}.
+ */
+ Object value ();
+ }
+
+ /** the generated parser, with debugging messages.
+ Maintains a dynamic state and value stack.
+ @param yyLex scanner.
+ @param yydebug debug message writer implementing <tt>yyDebug</tt>, or <tt>null</tt>.
+ @return result of the last reduction, if any.
+ */
+ public Object yyparse (yyInput yyLex, Object yydebug)
+ throws java.io.IOException {
+//t this.yydebug = (jay.yydebug.yyDebug)yydebug;
+ return yyparse(yyLex);
+ }
+
+ /** initial size and increment of the state/value stack [default 256].
+ This is not final so that it can be overwritten outside of invocations
+ of {@link #yyparse}.
+ */
+ protected int yyMax;
+
+ /** executed at the beginning of a reduce action.
+ Used as <tt>$$ = yyDefault($1)</tt>, prior to the user-specified action, if any.
+ Can be overwritten to provide deep copy, etc.
+ @param first value for <tt>$1</tt>, or <tt>null</tt>.
+ @return first.
+ */
+ protected Object yyDefault (Object first) {
+ return first;
+ }
+
+ /** the generated parser.
+ Maintains a dynamic state and value stack.
+ @param yyLex scanner.
+ @return result of the last reduction, if any.
+ */
+ public Object yyparse (yyInput yyLex) throws java.io.IOException {
+ if (yyMax <= 0) yyMax = 256; // initial size
+ int yyState = 0, yyStates[] = new int[yyMax]; // state stack
+ Object yyVal = null, yyVals[] = new Object[yyMax]; // value stack
+ int yyToken = -1; // current input
+ int yyErrorFlag = 0; // #tokens to shift
+
+ yyLoop: for (int yyTop = 0;; ++ yyTop) {
+ if (yyTop >= yyStates.length) { // dynamically increase
+ int[] i = new int[yyStates.length+yyMax];
+ System.arraycopy(yyStates, 0, i, 0, yyStates.length);
+ yyStates = i;
+ Object[] o = new Object[yyVals.length+yyMax];
+ System.arraycopy(yyVals, 0, o, 0, yyVals.length);
+ yyVals = o;
+ }
+ yyStates[yyTop] = yyState;
+ yyVals[yyTop] = yyVal;
+//t if (yydebug != null) yydebug.push(yyState, yyVal);
+
+ yyDiscarded: for (;;) { // discarding a token does not change stack
+ int yyN;
+ if ((yyN = yyDefRed[yyState]) == 0) { // else [default] reduce (yyN)
+ if (yyToken < 0) {
+ yyToken = yyLex.advance() ? yyLex.token() : 0;
+//t if (yydebug != null)
+//t yydebug.lex(yyState, yyToken, yyName(yyToken), yyLex.value());
+ }
+ if ((yyN = yySindex[yyState]) != 0 && (yyN += yyToken) >= 0
+ && yyN < yyTable.length && yyCheck[yyN] == yyToken) {
+//t if (yydebug != null)
+//t yydebug.shift(yyState, yyTable[yyN], yyErrorFlag > 0 ? yyErrorFlag-1 : 0);
+ yyState = yyTable[yyN]; // shift to yyN
+ yyVal = yyLex.value();
+ yyToken = -1;
+ if (yyErrorFlag > 0) -- yyErrorFlag;
+ continue yyLoop;
+ }
+ if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0
+ && yyN < yyTable.length && yyCheck[yyN] == yyToken)
+ yyN = yyTable[yyN]; // reduce (yyN)
+ else
+ switch (yyErrorFlag) {
+
+ case 0:
+ yyerror("syntax error");
+//t if (yydebug != null) yydebug.error("syntax error");
+
+ case 1: case 2:
+ yyErrorFlag = 3;
+ do {
+ if ((yyN = yySindex[yyStates[yyTop]]) != 0
+ && (yyN += yyErrorCode) >= 0 && yyN < yyTable.length
+ && yyCheck[yyN] == yyErrorCode) {
+//t if (yydebug != null)
+//t yydebug.shift(yyStates[yyTop], yyTable[yyN], 3);
+ yyState = yyTable[yyN];
+ yyVal = yyLex.value();
+ continue yyLoop;
+ }
+//t if (yydebug != null) yydebug.pop(yyStates[yyTop]);
+ } while (-- yyTop >= 0);
+//t if (yydebug != null) yydebug.reject();
+ yyerror("irrecoverable syntax error");
+
+ case 3:
+ if (yyToken == 0) {
+//t if (yydebug != null) yydebug.reject();
+ yyerror("irrecoverable syntax error at end-of-file");
+ }
+//t if (yydebug != null)
+//t yydebug.discard(yyState, yyToken, yyName(yyToken), yyLex.value());
+ yyToken = -1;
+ continue yyDiscarded; // leave stack alone
+ }
+ }
+ int yyV = yyTop + 1-yyLen[yyN];
+//t if (yydebug != null)
+//t yydebug.reduce(yyState, yyStates[yyV-1], yyN, yyRule[yyN], yyLen[yyN]);
+ yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]);
+ switch (yyN) {
+case 1:
+ // line 19 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ parser.root = parser.addNode((Node)yyVals[0+yyTop]);
+ }
+ break;
+case 2:
+ // line 23 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ parser.root = parser.addNode((Node)yyVals[0+yyTop]);
+ }
+ break;
+case 3:
+ // line 27 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ parser.eof = true;
+ }
+ break;
+case 7:
+ // line 38 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop], parser.taguri_expansion);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 8:
+ // line 43 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop], false);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 9:
+ // line 48 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ /*
+ * _Anchors_: The language binding must keep a separate symbol table
+ * for anchors. The actual ID in the symbol table is returned to the
+ * higher nodes, though.
+ */
+ yyVal = parser.addAnchor((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop] );
+ }
+ break;
+case 10:
+ // line 57 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 13:
+ // line 67 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 14:
+ // line 71 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Node n = NULL_NODE( parser );
+ yyVal = n;
+ }
+ break;
+case 15:
+ // line 76 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ if(parser.implicit_typing)
+ {
+ ImplicitScanner.tryTagImplicit((Node)yyVals[0+yyTop], parser.taguri_expansion);
+ }
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 16:
+ // line 84 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop], parser.taguri_expansion);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 17:
+ // line 89 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop], false);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 18:
+ // line 94 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ /*
+ * _Anchors_: The language binding must keep a separate symbol table
+ * for anchors. The actual ID in the symbol table is returned to the
+ * higher nodes, though.
+ */
+ yyVal = parser.addAnchor((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop] );
+ }
+ break;
+case 25:
+ // line 127 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop], parser.taguri_expansion);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 26:
+ // line 132 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop], false);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 27:
+ // line 137 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ if(parser.implicit_typing)
+ {
+ ImplicitScanner.tryTagImplicit((Node)yyVals[0+yyTop], parser.taguri_expansion);
+ }
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 28:
+ // line 145 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = parser.addAnchor((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop] );
+ }
+ break;
+case 29:
+ // line 149 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ /*
+ * _Aliases_: The anchor symbol table is scanned for the anchor name.
+ * The anchor's ID in the language's symbol table is returned.
+ */
+ yyVal = parser.getAnchor((String)yyVals[0+yyTop]);
+ }
+ break;
+case 30:
+ // line 157 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Node n = (Node)yyVals[0+yyTop];
+ if(parser.taguri_expansion) {
+ n.type_id = Parser.taguri(YAML.DOMAIN, "str");
+ } else {
+ n.type_id = "str";
+ }
+ yyVal = n;
+ }
+ break;
+case 32:
+ // line 168 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 38:
+ // line 188 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 39:
+ // line 192 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 40:
+ // line 198 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = parser.addNode((Node) yyVals[0+yyTop]);
+ }
+ break;
+case 41:
+ // line 204 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-2+yyTop], (Node)yyVals[0+yyTop], parser.taguri_expansion);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 42:
+ // line 209 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop], parser.taguri_expansion);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 43:
+ // line 214 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-2+yyTop], (Node)yyVals[0+yyTop], false);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 44:
+ // line 219 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop], false);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 45:
+ // line 224 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = parser.addAnchor((String)yyVals[-2+yyTop], (Node)yyVals[0+yyTop] );
+ }
+ break;
+case 46:
+ // line 228 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = parser.addAnchor((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop] );
+ }
+ break;
+case 47:
+ // line 234 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = Node.newSeq(yyVals[0+yyTop]);
+ }
+ break;
+case 48:
+ // line 238 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ ((Node)yyVals[-2+yyTop]).seqAdd(yyVals[0+yyTop]);
+ yyVal = yyVals[-2+yyTop];
+ }
+ break;
+case 49:
+ // line 243 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 50:
+ // line 252 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 51:
+ // line 256 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = Node.allocSeq();
+ }
+ break;
+case 52:
+ // line 262 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = Node.newSeq(parser.addNode((Node)yyVals[0+yyTop]));
+ }
+ break;
+case 53:
+ // line 266 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ ((Node)yyVals[-2+yyTop]).seqAdd(parser.addNode((Node)yyVals[0+yyTop]));
+ yyVal = yyVals[-2+yyTop];
+ }
+ break;
+case 56:
+ // line 280 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ applySeqInMap(parser, (Node)yyVals[-1+yyTop]);
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 57:
+ // line 285 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ applySeqInMap(parser, (Node)yyVals[-1+yyTop]);
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 58:
+ // line 292 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-2+yyTop], (Node)yyVals[0+yyTop], parser.taguri_expansion);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 59:
+ // line 297 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop], parser.taguri_expansion);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 60:
+ // line 302 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-2+yyTop], (Node)yyVals[0+yyTop], false);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 61:
+ // line 307 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Parser.addTransfer((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop], false);
+ yyVal = yyVals[0+yyTop];
+ }
+ break;
+case 62:
+ // line 312 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = parser.addAnchor((String)yyVals[-2+yyTop], (Node)yyVals[0+yyTop]);
+ }
+ break;
+case 63:
+ // line 316 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = parser.addAnchor((String)yyVals[-1+yyTop], (Node)yyVals[0+yyTop]);
+ }
+ break;
+case 65:
+ // line 323 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 67:
+ // line 332 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = Node.newMap(
+ parser.addNode( (Node)yyVals[-2+yyTop] ),
+ parser.addNode( (Node)yyVals[0+yyTop] ) );
+ }
+ break;
+case 69:
+ // line 341 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ if ( ((Node)yyVals[-2+yyTop]).shortcut == null )
+ {
+ ((Node)yyVals[-2+yyTop]).shortcut = Node.newSeq(yyVals[0+yyTop]);
+ }
+ else
+ {
+ ((Node)((Node)yyVals[-2+yyTop]).shortcut).seqAdd(yyVals[0+yyTop]);
+ }
+ yyVal = yyVals[-2+yyTop];
+ }
+ break;
+case 70:
+ // line 353 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ applySeqInMap( parser, (Node)yyVals[-2+yyTop] );
+ ((Node)yyVals[-2+yyTop]).mapUpdate((Node)yyVals[0+yyTop]);
+ yyVals[0+yyTop] = null;
+ yyVal = yyVals[-2+yyTop];
+ }
+ break;
+case 71:
+ // line 360 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 72:
+ // line 369 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = Node.newMap(
+ parser.addNode( (Node)yyVals[-2+yyTop] ),
+ parser.addNode( (Node)yyVals[0+yyTop] ) );
+ }
+ break;
+case 73:
+ // line 377 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 74:
+ // line 381 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ yyVal = Node.allocMap();
+ }
+ break;
+case 76:
+ // line 388 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ ((Node)yyVals[-2+yyTop]).mapUpdate((Node)yyVals[0+yyTop]);
+ yyVals[0+yyTop] = null;
+ yyVal = yyVals[-2+yyTop];
+ }
+ break;
+case 77:
+ // line 396 "src/main/org/yecht/DefaultYAMLParser.y"
+ {
+ Node n = NULL_NODE( parser );
+ yyVal = Node.newMap(
+ parser.addNode( (Node)yyVals[0+yyTop] ),
+ parser.addNode( n ));
+ }
+ break;
+ // line 863 "-"
+ }
+ yyTop -= yyLen[yyN];
+ yyState = yyStates[yyTop];
+ int yyM = yyLhs[yyN];
+ if (yyState == 0 && yyM == 0) {
+//t if (yydebug != null) yydebug.shift(0, yyFinal);
+ yyState = yyFinal;
+ if (yyToken < 0) {
+ yyToken = yyLex.advance() ? yyLex.token() : 0;
+//t if (yydebug != null)
+//t yydebug.lex(yyState, yyToken,yyName(yyToken), yyLex.value());
+ }
+ if (yyToken == 0) {
+//t if (yydebug != null) yydebug.accept(yyVal);
+ return yyVal;
+ }
+ continue yyLoop;
+ }
+ if ((yyN = yyGindex[yyM]) != 0 && (yyN += yyState) >= 0
+ && yyN < yyTable.length && yyCheck[yyN] == yyState)
+ yyState = yyTable[yyN];
+ else
+ yyState = yyDgoto[yyM];
+//t if (yydebug != null) yydebug.shift(yyStates[yyTop], yyState);
+ continue yyLoop;
+ }
+ }
+ }
+
+ // line 405 "src/main/org/yecht/DefaultYAMLParser.y"
+
+ private Parser parser;
+ public DefaultYAMLParser(Parser parser) {
+ this.parser = parser;
+ }
+
+ public static Node NULL_NODE(Parser parser) {
+ Node n = Node.newStr(Pointer.create(new byte[0], 0), 0, ScalarStyle.Plain);
+ if(parser.taguri_expansion) {
+ n.type_id = Parser.taguri(YAML.DOMAIN, "null");
+ } else {
+ n.type_id = "null";
+ }
+ return n;
+ }
+
+
+ public static void applySeqInMap(Parser parser, Node n) {
+ if(n.shortcut == null) {
+ return;
+ }
+
+ int map_len = (int)n.mapCount();
+ n.mapAssign(MapPart.Value, map_len - 1, parser.addNode((Node)n.shortcut));
+ n.shortcut = null;
+ }
+
+ public void yyerror(String msg) {
+ TokenScanner.error(msg, parser);
+ }
+}
+ // line 925 "-"
View
435 src/main/org/yecht/DefaultYAMLParser.y
@@ -0,0 +1,435 @@
+%{
+package org.yecht;
+
+public class DefaultYAMLParser {
+
+%}
+
+%start doc
+
+%token YAML_ANCHOR YAML_ALIAS YAML_TRANSFER YAML_TAGURI YAML_ITRANSFER
+%token YAML_WORD YAML_PLAIN YAML_BLOCK
+%token YAML_DOCSEP YAML_IOPEN YAML_INDENT YAML_IEND
+
+%left '-' ':'
+%left '[' ']' '{' '}' ',' '?'
+
+%%
+doc : atom
+ {
+ parser.root = parser.addNode((Node)$1);
+ }
+ | YAML_DOCSEP atom_or_empty
+ {
+ parser.root = parser.addNode((Node)$2);
+ }
+ |
+ {
+ parser.eof = true;
+ }
+ ;
+
+atom : word_rep
+ | ind_rep
+ ;
+
+ind_rep : struct_rep
+ | YAML_TRANSFER ind_rep
+ {
+ Parser.addTransfer((String)$1, (Node)$2, parser.taguri_expansion);
+ $$ = $2;
+ }
+ | YAML_TAGURI ind_rep
+ {
+ Parser.addTransfer((String)$1, (Node)$2, false);
+ $$ = $2;
+ }
+ | YAML_ANCHOR ind_rep
+ {
+ /*
+ * _Anchors_: The language binding must keep a separate symbol table
+ * for anchors. The actual ID in the symbol table is returned to the
+ * higher nodes, though.
+ */
+ $$ = parser.addAnchor((String)$1, (Node)$2 );
+ }
+ | indent_open ind_rep indent_flex_end
+ {
+ $$ = $2;
+ }
+ ;
+
+atom_or_empty : atom
+ | empty
+ ;
+
+empty : indent_open empty indent_end
+ {
+ $$ = $2;
+ }
+ |
+ {
+ Node n = NULL_NODE( parser );
+ $$ = n;
+ }
+ | YAML_ITRANSFER empty
+ {
+ if(parser.implicit_typing)
+ {
+ ImplicitScanner.tryTagImplicit((Node)$2, parser.taguri_expansion);
+ }
+ $$ = $2;
+ }
+ | YAML_TRANSFER empty
+ {
+ Parser.addTransfer((String)$1, (Node)$2, parser.taguri_expansion);
+ $$ = $2;
+ }
+ | YAML_TAGURI empty
+ {
+ Parser.addTransfer((String)$1, (Node)$2, false);
+ $$ = $2;
+ }
+ | YAML_ANCHOR empty
+ {
+ /*
+ * _Anchors_: The language binding must keep a separate symbol table
+ * for anchors. The actual ID in the symbol table is returned to the
+ * higher nodes, though.
+ */
+ $$ = parser.addAnchor((String)$1, (Node)$2 );
+ }
+ ;
+
+/*
+ * Indentation abstractions
+ */
+indent_open : YAML_IOPEN
+ | indent_open YAML_INDENT
+ ;
+
+indent_end : YAML_IEND
+ ;
+
+indent_sep : YAML_INDENT
+ ;
+
+indent_flex_end : YAML_IEND
+ | indent_sep indent_flex_end
+ ;
+
+/*
+ * Words are broken out to distinguish them
+ * as keys in implicit maps and valid elements
+ * for the inline structures
+ */
+word_rep : YAML_TRANSFER word_rep
+ {
+ Parser.addTransfer((String)$1, (Node)$2, parser.taguri_expansion);
+ $$ = $2;
+ }
+ | YAML_TAGURI word_rep
+ {
+ Parser.addTransfer((String)$1, (Node)$2, false);
+ $$ = $2;
+ }
+ | YAML_ITRANSFER word_rep
+ {
+ if(parser.implicit_typing)
+ {
+ ImplicitScanner.tryTagImplicit((Node)$2, parser.taguri_expansion);
+ }
+ $$ = $2;
+ }
+ | YAML_ANCHOR word_rep
+ {
+ $$ = parser.addAnchor((String)$1, (Node)$2 );
+ }
+ | YAML_ALIAS
+ {
+ /*
+ * _Aliases_: The anchor symbol table is scanned for the anchor name.
+ * The anchor's ID in the language's symbol table is returned.
+ */
+ $$ = parser.getAnchor((String)$1);
+ }
+ | YAML_WORD
+ {
+ Node n = (Node)$1;
+ if(parser.taguri_expansion) {
+ n.type_id = Parser.taguri(YAML.DOMAIN, "str");
+ } else {
+ n.type_id = "str";
+ }
+ $$ = n;
+ }
+ | YAML_PLAIN
+ | indent_open word_rep indent_flex_end
+ {
+ $$ = $2;
+ }
+ ;
+
+/*
+ * Any of these structures can be used as
+ * complex keys
+ */
+struct_rep : YAML_BLOCK
+ | implicit_seq
+ | inline_seq
+ | implicit_map
+ | inline_map
+ ;
+
+/*
+ * Implicit sequence
+ */
+implicit_seq : indent_open top_imp_seq indent_end
+ {
+ $$ = $2;
+ }
+ | indent_open in_implicit_seq indent_end
+ {
+ $$ = $2;
+ }
+ ;
+
+basic_seq : '-' atom_or_empty
+ {
+ $$ = parser.addNode((Node) $2);
+ }
+ ;
+
+top_imp_seq : YAML_TRANSFER indent_sep in_implicit_seq
+ {
+ Parser.addTransfer((String)$1, (Node)$3, parser.taguri_expansion);
+ $$ = $3;
+ }
+ | YAML_TRANSFER top_imp_seq
+ {
+ Parser.addTransfer((String)$1, (Node)$2, parser.taguri_expansion);
+ $$ = $2;
+ }
+ | YAML_TAGURI indent_sep in_implicit_seq
+ {
+ Parser.addTransfer((String)$1, (Node)$3, false);
+ $$ = $3;
+ }
+ | YAML_TAGURI top_imp_seq
+ {
+ Parser.addTransfer((String)$1, (Node)$2, false);
+ $$ = $2;
+ }
+ | YAML_ANCHOR indent_sep in_implicit_seq
+ {
+ $$ = parser.addAnchor((String)$1, (Node)$3 );
+ }
+ | YAML_ANCHOR top_imp_seq
+ {
+ $$ = parser.addAnchor((String)$1, (Node)$2 );
+ }
+ ;
+
+in_implicit_seq : basic_seq
+ {
+ $$ = Node.newSeq($1);
+ }
+ | in_implicit_seq indent_sep basic_seq
+ {
+ ((Node)$1).seqAdd($3);
+ $$ = $1;
+ }
+ | in_implicit_seq indent_sep
+ {
+ $$ = $1;
+ }
+ ;
+
+/*
+ * Inline sequences
+ */
+inline_seq : '[' in_inline_seq ']'
+ {
+ $$ = $2;
+ }
+ | '[' ']'
+ {
+ $$ = Node.allocSeq();
+ }
+ ;
+
+in_inline_seq : inline_seq_atom
+ {
+ $$ = Node.newSeq(parser.addNode((Node)$1));
+ }
+ | in_inline_seq ',' inline_seq_atom
+ {
+ ((Node)$1).seqAdd(parser.addNode((Node)$3));
+ $$ = $1;
+ }
+ ;
+
+inline_seq_atom : atom
+ | basic_mapping
+ ;
+
+/*
+ * Implicit maps
+ */
+implicit_map : indent_open top_imp_map indent_end
+ {
+ applySeqInMap(parser, (Node)$2);
+ $$ = $2;
+ }
+ | indent_open in_implicit_map indent_end
+ {
+ applySeqInMap(parser, (Node)$2);
+ $$ = $2;
+ }
+ ;
+
+top_imp_map : YAML_TRANSFER indent_sep in_implicit_map
+ {
+ Parser.addTransfer((String)$1, (Node)$3, parser.taguri_expansion);
+ $$ = $3;
+ }
+ | YAML_TRANSFER top_imp_map
+ {
+ Parser.addTransfer((String)$1, (Node)$2, parser.taguri_expansion);
+ $$ = $2;
+ }
+ | YAML_TAGURI indent_sep in_implicit_map
+ {
+ Parser.addTransfer((String)$1, (Node)$3, false);
+ $$ = $3;
+ }
+ | YAML_TAGURI top_imp_map
+ {
+ Parser.addTransfer((String)$1, (Node)$2, false);
+ $$ = $2;
+ }
+ | YAML_ANCHOR indent_sep in_implicit_map
+ {
+ $$ = parser.addAnchor((String)$1, (Node)$3);
+ }
+ | YAML_ANCHOR top_imp_map
+ {
+ $$ = parser.addAnchor((String)$1, (Node)$2);
+ }
+ ;
+
+complex_key : word_rep
+ | '?' atom indent_sep
+ {
+ $$ = $2;
+ }
+ ;
+
+complex_value : atom_or_empty
+ ;
+
+complex_mapping : complex_key ':' complex_value
+ {
+ $$ = Node.newMap(
+ parser.addNode( (Node)$1 ),
+ parser.addNode( (Node)$3 ) );
+ }
+ ;
+
+in_implicit_map : complex_mapping
+ | in_implicit_map indent_sep basic_seq
+ {
+ if ( ((Node)$1).shortcut == null )
+ {
+ ((Node)$1).shortcut = Node.newSeq($3);
+ }
+ else
+ {
+ ((Node)((Node)$1).shortcut).seqAdd($3);
+ }
+ $$ = $1;
+ }
+ | in_implicit_map indent_sep complex_mapping
+ {
+ applySeqInMap( parser, (Node)$1 );
+ ((Node)$1).mapUpdate((Node)$3);
+ $3 = null;
+ $$ = $1;
+ }
+ | in_implicit_map indent_sep
+ {
+ $$ = $1;
+ }
+ ;
+
+/*
+ * Inline maps
+ */
+basic_mapping : atom ':' atom_or_empty
+ {
+ $$ = Node.newMap(
+ parser.addNode( (Node)$1 ),
+ parser.addNode( (Node)$3 ) );
+ }
+ ;
+
+inline_map : '{' in_inline_map '}'
+ {
+ $$ = $2;
+ }
+ | '{' '}'
+ {
+ $$ = Node.allocMap();
+ }
+ ;
+
+in_inline_map : inline_map_atom
+ | in_inline_map ',' inline_map_atom
+ {
+ ((Node)$1).mapUpdate((Node)$3);
+ $3 = null;
+ $$ = $1;
+ }
+ ;
+
+inline_map_atom : atom
+ {
+ Node n = NULL_NODE( parser );
+ $$ = Node.newMap(
+ parser.addNode( (Node)$1 ),
+ parser.addNode( n ));
+ }
+ | basic_mapping
+ ;
+%%
+
+ private Parser parser;
+ public DefaultYAMLParser(Parser parser) {
+ this.parser = parser;
+ }
+
+ public static Node NULL_NODE(Parser parser) {
+ Node n = Node.newStr(Pointer.create(new byte[0], 0), 0, ScalarStyle.Plain);
+ if(parser.taguri_expansion) {
+ n.type_id = Parser.taguri(YAML.DOMAIN, "null");
+ } else {
+ n.type_id = "null";
+ }
+ return n;
+ }
+
+
+ public static void applySeqInMap(Parser parser, Node n) {
+ if(n.shortcut == null) {
+ return;
+ }
+
+ int map_len = (int)n.mapCount();
+ n.mapAssign(MapPart.Value, map_len - 1, parser.addNode((Node)n.shortcut));
+ n.shortcut = null;
+ }
+
+ public void yyerror(String msg) {
+ TokenScanner.error(msg, parser);
+ }
+}
View
2  src/main/org/yecht/ImplicitScanner.java
@@ -1,4 +1,4 @@
-/* Generated by re2j 0.13.6.dev on Thu Jul 23 15:22:11 2009 */
+/* Generated by re2j 0.13.6.dev on Thu Jul 23 17:15:02 2009 */
package org.yecht;
// Equivalent to implicit.re
View
7 src/main/org/yecht/Parser.java
@@ -286,7 +286,12 @@ public Object parse() {
}
private void yechtparse() {
- new YechtParser(this, TokenScanner.createScanner(this)).parse();
+ try {
+ new DefaultYAMLParser(this).yyparse(TokenScanner2.createScanner(this));
+ // new YechtParser(this, TokenScanner2.createScanner(this)).parse();
+ } catch(java.io.IOException e) {
+ root = root_on_error;
+ }
}
// syck_hdlr_add_node
View
2  src/main/org/yecht/TokenScanner.java
@@ -1,4 +1,4 @@
-/* Generated by re2j 0.13.6.dev on Thu Jul 23 15:22:11 2009 */
+/* Generated by re2j 0.13.6.dev on Thu Jul 23 17:15:02 2009 */
package org.yecht;
import java.io.IOException;
View
90 src/main/org/yecht/TokenScanner2.java
@@ -1,10 +1,10 @@
-/* Generated by re2j 0.13.6.dev on Thu Jul 23 15:22:11 2009 */
+/* Generated by re2j 0.13.6.dev on Thu Jul 23 17:15:02 2009 */
package org.yecht;
import java.io.IOException;
// Equivalent to token.re
-public class TokenScanner2 implements YAMLGrammarTokens, Scanner {
+public class TokenScanner2 implements DefaultYAMLParser.yyInput {
public final static int QUOTELEN = 1024;
private Parser parser;
@@ -19,12 +19,13 @@ public static void error(String msg, Parser parser) {
parser.error_handler.handle(parser, msg);
}
- public static Scanner createScanner(Parser parser) {
+ public static DefaultYAMLParser.yyInput createScanner(Parser parser) {
switch(parser.input_type) {
case YAML_UTF8:
return new TokenScanner2(parser);
case Bytecode_UTF8:
- return new BytecodeScanner(parser);
+ return null;
+// return new BytecodeScanner(parser);
case YAML_UTF16:
error("UTF-16 is not currently supported in Yecht.\nPlease contribute code to help this happen!", parser);
return null;
@@ -37,24 +38,19 @@ public static Scanner createScanner(Parser parser) {
public TokenScanner2(Parser parser) {
this.parser = parser;
- yylex();
}
- public Object getLVal() {
+ public Object value() {
return lval;
}
- public int currentToken() {
+ public int token() {
return currentToken;
}
- public int yylex() {
- try {
- currentToken = real_yylex();
- return currentToken;
- } catch(java.io.IOException ioe) {
- throw new RuntimeException(ioe);
- }
+ public boolean advance() throws java.io.IOException {
+ currentToken = real_yylex();
+ return currentToken == 0 ? false : true;
}
private int isNewline(int ptr) {
@@ -302,7 +298,7 @@ private int header() throws java.io.IOException {
if(lvl.spaces > -1) {
parser.popLevel();
YYPOS(0);
- return YAML_IEND;
+ return DefaultYAMLParser.YAML_IEND;
}
YYPOS(0);
return 0;
@@ -412,7 +408,7 @@ private int header() throws java.io.IOException {
if(lvl.spaces > -1) {
parser.popLevel();
YYPOS(0);
- return YAML_IEND;
+ return DefaultYAMLParser.YAML_IEND;
}
YYPOS(0);
return 0;
@@ -458,7 +454,7 @@ private int header() throws java.io.IOException {
if(lvl.spaces > -1) {
parser.popLevel();
YYPOS(0);
- return YAML_IEND;
+ return DefaultYAMLParser.YAML_IEND;
}
YYPOS(0);
return 0;
@@ -567,18 +563,18 @@ private int document(int doc_level) throws java.io.IOException {
if(lvl.spaces > indt_len) {
parser.popLevel();
YYPOS(0);
- return YAML_IEND;
+ return DefaultYAMLParser.YAML_IEND;
}
if(lvl.spaces < indt_len) {
if(lvl.status != LevelStatus.iseq && lvl.status != LevelStatus.imap) {
parser.addLevel(indt_len, LevelStatus.doc);
- return YAML_IOPEN;
+ return DefaultYAMLParser.YAML_IOPEN;
}
} else {
if(indt_len == -1) {
return 0;
}
- return YAML_INDENT;
+ return DefaultYAMLParser.YAML_INDENT;
}
}
break;
@@ -595,7 +591,7 @@ private int document(int doc_level) throws java.io.IOException {
if(lvl.status != LevelStatus.iseq && lvl.status != LevelStatus.imap) {
parser.addLevel(doc_level, LevelStatus.doc);
YYPOS(0);
- return YAML_IOPEN;
+ return DefaultYAMLParser.YAML_IOPEN;
}
} else {
return plain();
@@ -609,7 +605,7 @@ private int document(int doc_level) throws java.io.IOException {
if(lvl.status != LevelStatus.iseq && lvl.status != LevelStatus.imap) {
parser.addLevel(doc_level, LevelStatus.doc);
YYPOS(0);
- return YAML_IOPEN;
+ return DefaultYAMLParser.YAML_IOPEN;
}
} else {
lvl = parser.currentLevel();
@@ -625,7 +621,7 @@ private int document(int doc_level) throws java.io.IOException {
if(lvl.status != LevelStatus.iseq && lvl.status != LevelStatus.imap) {
parser.addLevel(doc_level, LevelStatus.doc);
YYPOS(0);
- return YAML_IOPEN;
+ return DefaultYAMLParser.YAML_IOPEN;
}
} else {
lvl = parser.currentLevel();
@@ -805,7 +801,7 @@ private int document(int doc_level) throws java.io.IOException {
if(lvl.status != LevelStatus.iseq && lvl.status != LevelStatus.imap) {
parser.addLevel(doc_level, LevelStatus.doc);
YYPOS(0);
- return YAML_IOPEN;
+ return DefaultYAMLParser.YAML_IOPEN;
}
} else {
return singleQuote();
@@ -819,7 +815,7 @@ private int document(int doc_level) throws java.io.IOException {
if(lvl.status != LevelStatus.iseq && lvl.status != LevelStatus.imap) {
parser.addLevel(doc_level, LevelStatus.doc);
YYPOS(0);
- return YAML_IOPEN;
+ return DefaultYAMLParser.YAML_IOPEN;
}
} else {
return doubleQuote();
@@ -867,7 +863,7 @@ private int document(int doc_level) throws java.io.IOException {
if(lvl.spaces > -1) {
parser.popLevel();
YYPOS(0);
- return YAML_IEND;
+ return DefaultYAMLParser.YAML_IEND;
}
YYPOS(0);
return 0;
@@ -1013,11 +1009,11 @@ private int document(int doc_level) throws java.io.IOException {
if(lvl.status != LevelStatus.iseq && lvl.status != LevelStatus.imap) {
parser.addLevel(doc_level, LevelStatus.doc);
YYPOS(0);
- return YAML_IOPEN;
+ return DefaultYAMLParser.YAML_IOPEN;
}
} else {
lval = new String(parser.buffer.buffer, parser.token + 1, parser.cursor - (parser.token + 1), "ISO-8859-1");
- return YAML_ALIAS;
+ return DefaultYAMLParser.YAML_ALIAS;
}
break;
}
@@ -1101,7 +1097,7 @@ private int document(int doc_level) throws java.io.IOException {
* queue for matching at a higher level of indentation.
*/
parser.removeAnchor((String)lval);
- return YAML_ANCHOR;
+ return DefaultYAMLParser.YAML_ANCHOR;
}
case 81:
++parser.cursor;
@@ -1111,10 +1107,10 @@ private int document(int doc_level) throws java.io.IOException {
if(lvl.status != LevelStatus.iseq && lvl.status != LevelStatus.imap) {
parser.addLevel((parser.token - parser.lineptr), LevelStatus.doc);
YYPOS(0);
- return YAML_IOPEN;
+ return DefaultYAMLParser.YAML_IOPEN;
}
} else {
- parser.force_token = YAML_IOPEN;
+ parser.force_token = DefaultYAMLParser.YAML_IOPEN;
if( parser.buffer.buffer[parser.cursor] == '#' || isNewline(parser.cursor) != 0 || isNewline(parser.cursor-1) != 0) {
parser.cursor--;
parser.addLevel(parser.token + 1 - parser.lineptr, LevelStatus.seq);
@@ -1295,7 +1291,7 @@ private int directive() throws java.io.IOException {
}
case 98:
{ parser.cursor = parser.toktmp;
- return YAML_DOCSEP;
+ return DefaultYAMLParser.YAML_DOCSEP;
}
case 99:
++parser.cursor;
@@ -1647,7 +1643,7 @@ private int plain() throws java.io.IOException {
if(indt_len <= parentIndent) {
RETURN_IMPLICIT(q);
- return YAML_PLAIN;
+ return DefaultYAMLParser.YAML_PLAIN;
}
while(parser.token < parser.cursor) {
@@ -1708,7 +1704,7 @@ private int plain() throws java.io.IOException {
} else {
q.plain_is_inl();
RETURN_IMPLICIT(q);
- return YAML_PLAIN;
+ return DefaultYAMLParser.YAML_PLAIN;
}
break;
}
@@ -1724,7 +1720,7 @@ private int plain() throws java.io.IOException {
} else {
q.plain_is_inl();
RETURN_IMPLICIT(q);
- return YAML_PLAIN;
+ return DefaultYAMLParser.YAML_PLAIN;
}
break;
}
@@ -1745,7 +1741,7 @@ private int plain() throws java.io.IOException {
++parser.cursor;
{
RETURN_IMPLICIT(q);
- return YAML_PLAIN;
+ return DefaultYAMLParser.YAML_PLAIN;
}
case 126:
yych = parser.buffer.buffer[++parser.cursor];
@@ -1758,7 +1754,7 @@ private int plain() throws java.io.IOException {
{
eatComments();
RETURN_IMPLICIT(q);
- return YAML_PLAIN;
+ return DefaultYAMLParser.YAML_PLAIN;
}
case 130:
++parser.cursor;
@@ -1773,7 +1769,7 @@ private int plain() throws java.io.IOException {
} else {
q.plain_is_inl();
RETURN_IMPLICIT(q);
- return YAML_PLAIN;
+ return DefaultYAMLParser.YAML_PLAIN;
}
break;
@@ -1804,7 +1800,7 @@ private int plain() throws java.io.IOException {
case 137:
{
RETURN_IMPLICIT(q);
- return YAML_PLAIN;
+ return DefaultYAMLParser.YAML_PLAIN;
}
case 138:
++parser.cursor;
@@ -1986,7 +1982,7 @@ private int doubleQuote() throws java.io.IOException {
dd.len = q.idx;
dd.style = ScalarStyle.TwoQuote;
lval = n;
- return YAML_PLAIN;
+ return DefaultYAMLParser.YAML_PLAIN;
}
case 153:
yych = parser.buffer.buffer[++parser.cursor];
@@ -2222,7 +2218,7 @@ private int singleQuote() throws java.io.IOException {
dd.len = q.idx;
dd.style = ScalarStyle.OneQuote;
lval = n;
- return YAML_PLAIN;
+ return DefaultYAMLParser.YAML_PLAIN;
}
case 178:
yych = parser.buffer.buffer[++parser.cursor];
@@ -2291,7 +2287,7 @@ private int transferMethod() throws java.io.IOException {
{
parser.cursor = parser.toktmp;
if(parser.cursor == parser.token + 1) {
- return YAML_ITRANSFER;
+ return DefaultYAMLParser.YAML_ITRANSFER;
}
Level lvl = parser.currentLevel();
@@ -2318,7 +2314,7 @@ private int transferMethod() throws java.io.IOException {
}
}
- return YAML_TRANSFER;
+ return DefaultYAMLParser.YAML_TRANSFER;
}
case 190:
yych = parser.buffer.buffer[++parser.cursor];
@@ -2534,7 +2530,7 @@ private int scalarBlock() throws java.io.IOException {
} else {
parser.cursor = parser.token;
RETURN_YAML_BLOCK(q, blockType, nlDoWhat);
- return YAML_BLOCK;
+ return DefaultYAMLParser.YAML_BLOCK;
}
}
@@ -2574,7 +2570,7 @@ private int scalarBlock() throws java.io.IOException {
parser.popLevel();
parser.cursor = parser.token;
RETURN_YAML_BLOCK(q, blockType, nlDoWhat);
- return YAML_BLOCK;
+ return DefaultYAMLParser.YAML_BLOCK;
}
break;
}
@@ -2604,7 +2600,7 @@ private int scalarBlock() throws java.io.IOException {
{ parser.cursor--;
parser.popLevel();
RETURN_YAML_BLOCK(q, blockType, nlDoWhat);
- return YAML_BLOCK;
+ return DefaultYAMLParser.YAML_BLOCK;
}
case 215:
yyaccept = 1;
@@ -2648,7 +2644,7 @@ private int scalarBlock() throws java.io.IOException {
parser.popLevel();
parser.cursor = parser.token;
RETURN_YAML_BLOCK(q, blockType, nlDoWhat);
- return YAML_BLOCK;
+ return DefaultYAMLParser.YAML_BLOCK;
} else {
q.cat(parser.buffer.buffer[parser.token]);
parser.cursor = parser.token + 1;
View
88 src/main/org/yecht/TokenScanner2.re
@@ -3,7 +3,7 @@ package org.yecht;
import java.io.IOException;
// Equivalent to token.re
-public class TokenScanner2 implements YAMLGrammarTokens, Scanner {
+public class TokenScanner2 implements DefaultYAMLParser.yyInput {
public final static int QUOTELEN = 1024;
private Parser parser;
@@ -18,12 +18,13 @@ public class TokenScanner2 implements YAMLGrammarTokens, Scanner {
parser.error_handler.handle(parser, msg);
}
- public static Scanner createScanner(Parser parser) {
+ public static DefaultYAMLParser.yyInput createScanner(Parser parser) {
switch(parser.input_type) {
case YAML_UTF8:
return new TokenScanner2(parser);
case Bytecode_UTF8:
- return new BytecodeScanner(parser);
+ return null;
+// return new BytecodeScanner(parser);
case YAML_UTF16:
error("UTF-16 is not currently supported in Yecht.\nPlease contribute code to help this happen!", parser);
return null;
@@ -36,24 +37,19 @@ public class TokenScanner2 implements YAMLGrammarTokens, Scanner {
public TokenScanner2(Parser parser) {
this.parser = parser;
- yylex();
}
- public Object getLVal() {
+ public Object value() {
return lval;
}
- public int currentToken() {
+ public int token() {
return currentToken;
}
- public int yylex() {
- try {
- currentToken = real_yylex();
- return currentToken;
- } catch(java.io.IOException ioe) {
- throw new RuntimeException(ioe);
- }
+ public boolean advance() throws java.io.IOException {
+ currentToken = real_yylex();
+ return currentToken == 0 ? false : true;
}
private int isNewline(int ptr) {
@@ -290,7 +286,7 @@ ESCSEQ = ["\\abefnrtv0] ;
if(lvl.spaces > -1) {
parser.popLevel();
YYPOS(0);
- return YAML_IEND;
+ return DefaultYAMLParser.YAML_IEND;
}
YYPOS(0);
return 0;
@@ -302,7 +298,7 @@ ESCSEQ = ["\\abefnrtv0] ;
if(lvl.spaces > -1) {
parser.popLevel();
YYPOS(0);
- return YAML_IEND;
+ return DefaultYAMLParser.YAML_IEND;
}
YYPOS(0);
return 0;
@@ -319,7 +315,7 @@ NULL { lvl = parser.currentLevel();
if(lvl.spaces > -1) {
parser.popLevel();
YYPOS(0);
- return YAML_IEND;
+ return DefaultYAMLParser.YAML_IEND;
}
YYPOS(0);
return 0;
@@ -408,18 +404,18 @@ YINDENT { /* Isolate spaces */
if(lvl.spaces > indt_len) {
parser.popLevel();
YYPOS(0);
- return YAML_IEND;
+ return DefaultYAMLParser.YAML_IEND;
}
if(lvl.spaces < indt_len) {
if(lvl.status != LevelStatus.iseq && lvl.status != LevelStatus.imap) {
parser.addLevel(indt_len, LevelStatus.doc);
- return YAML_IOPEN;
+ return DefaultYAMLParser.YAML_IOPEN;
}
} else {
if(indt_len == -1) {
return 0;
}
- return YAML_INDENT;
+ return DefaultYAMLParser.YAML_INDENT;
}
}
break;
@@ -430,7 +426,7 @@ ISEQO {
if(lvl.status != LevelStatus.iseq && lvl.status != LevelStatus.imap) {
parser.addLevel(doc_level, LevelStatus.doc);
YYPOS(0);
- return YAML_IOPEN;
+ return DefaultYAMLParser.YAML_IOPEN;
}
} else {
lvl = parser.currentLevel();
@@ -445,7 +441,7 @@ IMAPO {