Initial commit

This commit is contained in:
2023-05-14 16:56:30 +02:00
commit c078b94243
59 changed files with 30772 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* Describes actions that may occur on the right hand side
* of productions.
*/
public class Action extends Expansion {
/**
* Contains the list of tokens that make up the action. This
* list does not include the surrounding braces.
*/
public java.util.Vector action_tokens = new java.util.Vector();
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import csjavacc.parser.NormalProduction;
/**
* Describes BNF productions.
*/
public class BNFProduction extends NormalProduction {
/**
* The declarations of this production.
*/
public java.util.Vector declaration_tokens = new java.util.Vector();
/**
* This flag keeps track of whether or not return and throw
* statements have been patched within this production's actions to
* include a preceding "if (true)".
*/
public boolean jumpPatched;
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import csjavacc.parser.NormalProduction;
/**
* Describes JAVACODE productions.
*/
public class CSCodeProduction extends NormalProduction {
/**
* The tokens that implement this JAVACODE production.
*/
public java.util.Vector code_tokens = new java.util.Vector();
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import csjavacc.parser.CSJavaCCErrors;
/**
* Describes character range descriptors in a character list.
*/
public class CharacterRange {
/**
* The line and column number of the construct that corresponds
* most closely to this node.
*/
public int line, column;
/**
* The leftmost and the rightmost characters in this character range.
*/
public char left, right;
public CharacterRange() { }
public CharacterRange(char l, char r)
{
if (l > r)
CSJavaCCErrors.semantic_error(this, "Invalid range : \"" + (int)l + "\" - \""
+ (int)r + "\". First character shoud be less than or equal to the second one in a range.");
left = l;
right = r;
}
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* Describes expansions where one of many choices
* is taken (c1|c2|...).
*/
public class Choice extends Expansion {
/**
* The list of choices of this expansion unit. Each
* Vector component will narrow to ExpansionUnit.
*/
public java.util.Vector choices = new java.util.Vector();
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* An object container. Used to pass references to objects as parameter.
*/
public class Container {
public Object member;
}

View File

@@ -0,0 +1,98 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* Describes expansions - entities that may occur on the
* right hand sides of productions. This is the base class of
* a bunch of other more specific classes.
*/
public class Expansion {
/**
* The line and column number of the construct that corresponds
* most closely to this node.
*/
public int line, column;
/**
* A reimplementing of Object.hashCode() to be deterministic. This uses
* the line and column fields to generate an arbitrary number - we assume
* that this method is called only after line and column are set to
* their actual values.
*/
public int hashCode() {
return line + column;
}
/**
* An internal name for this expansion. This is used to generate parser
* routines.
*/
public String internal_name = "";
/**
* The parser routines are generated in three phases. The generation
* of the second and third phase are on demand only, and the third phase
* can be recursive. This variable is used to keep track of the
* expansions for which phase 3 generations have been already added to
* a list so that the recursion can be terminated.
*/
public boolean phase3done = false;
/**
* The parent of this expansion node. In case this is the top level
* expansion of the production it is a reference to the production node
* otherwise it is a reference to another Expansion node. In case this
* is the top level of a lookahead expansion,then the parent is null.
*/
public Object parent;
/**
* The ordinal of this node with respect to its parent.
*/
public int ordinal;
/**
* To avoid right-recursive loops when calculating follow sets, we use
* a generation number which indicates if this expansion was visited
* by LookaheadWalk.genFollowSet in the same generation. New generations
* are obtained by incrementing the static counter below, and the current
* generation is stored in the non-static variable below.
*/
public static long nextGenerationIndex = 1;
public long myGeneration = 0;
/**
* This flag is used for bookkeeping by the minimumSize method in class
* ParseEngine.
*/
public boolean inMinimumSize = false;
public static void reInit()
{
nextGenerationIndex = 1;
}
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* Describes lookahead rule for a particular expansion or expansion
* sequence (See Sequence.java). In case this describes the lookahead
* rule for a single expansion unit, then a sequence is created with
* this node as the first element, and the expansion unit as the second
* and last element.
*/
public class Lookahead extends Expansion {
/**
* Contains the list of tokens that make up the semantic lookahead
* if any. If this node represents a different kind of lookahead (other
* than semantic lookahead), then this vector contains nothing. If
* this vector contains something, then it is the boolean expression
* that forms the semantic lookahead. In this case, the following
* fields "amount" and "la_expansion" are ignored.
*/
public java.util.Vector action_tokens = new java.util.Vector();
/**
* The lookahead amount. Its default value essentially gives us
* infinite lookahead.
*/
public int amount = Integer.MAX_VALUE;
/**
* The expansion used to determine whether or not to choose the
* corresponding parse option. This expansion is parsed upto
* "amount" tokens of lookahead or until a complete match for it
* is found. Usually, this is the same as the expansion to be
* parsed.
*/
public Expansion la_expansion;
/**
* Is set to true if this is an explicit lookahead specification.
*/
public boolean isExplicit;
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
public class MatchInfo {
public static int laLimit;
public int[] match = new int[laLimit];
public int firstFreeLoc;
public static void reInit()
{
laLimit = 0;
}
}

43
csjavacc/struct/Nfa.java Normal file
View File

@@ -0,0 +1,43 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import csjavacc.parser.NfaState;
public class Nfa
{
public NfaState start;
public NfaState end;
public Nfa()
{
start = new NfaState();
end = new NfaState();
}
public Nfa(NfaState startGiven, NfaState finalGiven)
{
start = startGiven;
end = finalGiven;
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import csjavacc.parser.NormalProduction;
/**
* Describes non terminals.
*/
public class NonTerminal extends Expansion {
/**
* The LHS to which the return value of the non-terminal
* is assigned. In case there is no LHS, then the vector
* remains empty.
*/
public java.util.Vector lhsTokens = new java.util.Vector();
/**
* The name of the non-terminal.
*/
public String name;
/**
* The list of all tokens in the argument list.
*/
public java.util.Vector argument_tokens = new java.util.Vector();
/**
* The production this non-terminal corresponds to.
*/
public NormalProduction prod;
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* Describes the EOF regular expression
*/
public class REndOfFile extends RegularExpression {
public Nfa GenerateNfa(boolean ignoreCase)
{
return null;
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* Describes regular expressions which are referred to just by
* their name. This means that a regular expression with this
* name has been declared earlier.
*/
public class RJustName extends RegularExpression {
/**
* "regexpr" points to the regular expression denoted by the name.
*/
public RegularExpression regexpr;
public Nfa GenerateNfa(boolean ignoreCase)
{
return regexpr.GenerateNfa(ignoreCase);
}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import csjavacc.parser.NfaState;
/**
* Describes one-or-more regular expressions (<foo+>).
*/
public class ROneOrMore extends RegularExpression {
/**
* The regular expression which is repeated one or more times.
*/
public RegularExpression regexpr;
public Nfa GenerateNfa(boolean ignoreCase)
{
Nfa retVal = new Nfa();
NfaState startState = retVal.start;
NfaState finalState = retVal.end;
Nfa temp = regexpr.GenerateNfa(ignoreCase);
startState.AddMove(temp.start);
temp.end.AddMove(temp.start);
temp.end.AddMove(finalState);
return retVal;
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import java.util.Vector;
/**
* Describes one-or-more regular expressions (<foo+>).
*/
public class RRepetitionRange extends RegularExpression {
/**
* The regular expression which is repeated one or more times.
*/
public RegularExpression regexpr;
public int min = 0;
public int max = -1;
public boolean hasMax;
public Nfa GenerateNfa(boolean ignoreCase)
{
Vector units = new Vector();
RSequence seq;
int i;
for (i = 0; i < min; i++)
{
units.addElement(regexpr);
}
if (hasMax && max == -1) // Unlimited
{
RZeroOrMore zoo = new RZeroOrMore();
zoo.regexpr = regexpr;
units.addElement(zoo);
}
while (i++ < max)
{
RZeroOrOne zoo = new RZeroOrOne();
zoo.regexpr = regexpr;
units.addElement(zoo);
}
seq = new RSequence(units);
return seq.GenerateNfa(ignoreCase);
}
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import java.util.*;
import csjavacc.parser.NfaState;
/**
* Describes regular expressions which are sequences of
* other regular expressions.
*/
public class RSequence extends RegularExpression {
/**
* The list of units in this regular expression sequence. Each
* Vector component will narrow to RegularExpression.
*/
public java.util.Vector units = new java.util.Vector();
public Nfa GenerateNfa(boolean ignoreCase)
{
if (units.size() == 1)
return ((RegularExpression)units.elementAt(0)).GenerateNfa(ignoreCase);
Nfa retVal = new Nfa();
NfaState startState = retVal.start;
NfaState finalState = retVal.end;
Nfa temp1;
Nfa temp2 = null;
RegularExpression curRE;
curRE = (RegularExpression)units.elementAt(0);
temp1 = curRE.GenerateNfa(ignoreCase);
startState.AddMove(temp1.start);
for (int i = 1; i < units.size(); i++)
{
curRE = (RegularExpression)units.elementAt(i);
temp2 = curRE.GenerateNfa(ignoreCase);
temp1.end.AddMove(temp2.start);
temp1 = temp2;
}
temp2.end.AddMove(finalState);
return retVal;
}
public RSequence()
{
}
public RSequence(Vector seq)
{
ordinal = Integer.MAX_VALUE;
units = seq;
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import csjavacc.parser.NfaState;
/**
* Describes zero-or-more regular expressions (<foo*>).
*/
public class RZeroOrMore extends RegularExpression {
/**
* The regular expression which is repeated zero or more times.
*/
public RegularExpression regexpr;
public Nfa GenerateNfa(boolean ignoreCase)
{
Nfa retVal = new Nfa();
NfaState startState = retVal.start;
NfaState finalState = retVal.end;
Nfa temp = regexpr.GenerateNfa(ignoreCase);
startState.AddMove(temp.start);
startState.AddMove(finalState);
temp.end.AddMove(finalState);
temp.end.AddMove(temp.start);
return retVal;
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import csjavacc.parser.NfaState;
/**
* Describes zero-or-one regular expressions (<foo?>).
*/
public class RZeroOrOne extends RegularExpression {
/**
* The regular expression which is repeated zero or one times.
*/
public RegularExpression regexpr;
public Nfa GenerateNfa(boolean ignoreCase)
{
Nfa retVal = new Nfa();
NfaState startState = retVal.start;
NfaState finalState = retVal.end;
Nfa temp = regexpr.GenerateNfa(ignoreCase);
startState.AddMove(temp.start);
startState.AddMove(finalState);
temp.end.AddMove(finalState);
return retVal;
}
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import csjavacc.parser.Token;
/**
* Describes regular expressions.
*/
abstract public class RegularExpression extends Expansion {
/**
* The label of the regular expression (if any). If no label is
* present, this is set to "".
*/
public String label = "";
/**
* The ordinal value assigned to the regular expression. It is
* used for internal processing and passing information between
* the parser and the lexical analyzer.
*/
public int ordinal;
/**
* The LHS to which the token value of the regular expression
* is assigned. In case there is no LHS, then the vector
* remains empty.
*/
public java.util.Vector lhsTokens = new java.util.Vector();
/**
* We now allow qualified access to token members. Store it here.
*/
public Token rhsToken;
/**
* This flag is set if the regular expression has a label prefixed
* with the # symbol - this indicates that the purpose of the regular
* expression is solely for defining other regular expressions.
*/
public boolean private_rexp = false;
/**
* If this is a top-level regular expression (nested directly
* within a TokenProduction), then this field point to that
* TokenProduction object.
*/
public TokenProduction tpContext = null;
abstract public Nfa GenerateNfa(boolean ignoreCase);
public boolean CanMatchAnyChar()
{
return false;
}
/**
* The following variable is used to maintain state information for the
* loop determination algorithm: It is initialized to 0, and
* set to -1 if this node has been visited in a pre-order walk, and then
* it is set to 1 if the pre-order walk of the whole graph from this
* node has been traversed. i.e., -1 indicates partially processed,
* and 1 indicates fully processed.
*/
public int walkStatus = 0;
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
import csjavacc.parser.Token;
/**
* Describes the various regular expression productions.
*/
public class TokenProduction {
/**
* Definitions of constants that identify the kind of regular
* expression production this is.
*/
public static final int TOKEN = 0,
SKIP = 1,
MORE = 2,
SPECIAL = 3;
/**
* The image of the above constants.
*/
public static final String[] kindImage = {
"TOKEN", "SKIP", "MORE", "SPECIAL"
};
/**
* The starting line and column of this token production.
*/
public int line, column;
/**
* The states in which this regular expression production exists. If
* this array is null, then "<*>" has been specified and this regular
* expression exists in all states. However, this null value is
* replaced by a String array that includes all lexical state names
* during the semanticization phase.
*/
public String[] lexStates;
/**
* The kind of this token production - TOKEN, SKIP, MORE, or SPECIAL.
*/
public int kind;
/**
* The list of regular expression specifications that comprise this
* production. Each entry is a "RegExprSpec".
*/
public java.util.Vector respecs = new java.util.Vector();
/**
* This is true if this corresponds to a production that actually
* appears in the input grammar. Otherwise (if this is created to
* describe a regular expression that is part of the BNF) this is set
* to false.
*/
public boolean isExplicit = true;
/**
* This is true if case is to be ignored within the regular expressions
* of this token production.
*/
public boolean ignoreCase = false;
/**
* The first and last tokens from the input stream that represent this
* production.
*/
public Token firstToken, lastToken;
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* Objects of this type are passed to the tree walker
* routines in ExpansionTreeWalker.
*/
public interface TreeWalkerOp {
/**
* When called at a particular node, this specifies to the
* tree walker if it should visit more nodes under this node.
*/
boolean goDeeper(Expansion e);
/**
* When a node is visited, this method is invoked with the
* node as parameter.
*/
void action(Expansion e);
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* Describes expansions of the form "try {...} ..."
*/
public class TryBlock extends Expansion {
/**
* The expansion contained within the try block.
*/
public Expansion exp;
/**
* The types of each catch block. Each vector entry is itself a
* vector which in turn contains tokens as entries.
*/
public java.util.Vector types;
/**
* The exception identifiers of each catch block. Each vector entry
* is a token.
*/
public java.util.Vector ids;
/**
* The block part of each catch block. Each vector entry is itself a
* vector which in turn contains tokens as entries.
*/
public java.util.Vector catchblks;
/**
* The block part of the finally block. Each vector entry is a token.
* If there is no finally block, this is null.
*/
public java.util.Vector finallyblk;
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* Describes zero-or-more expansions (e.g., foo*).
*/
public class ZeroOrMore extends Expansion {
/**
* The expansion which is repeated zero or more times.
*/
public Expansion expansion;
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
package csjavacc.struct;
/**
* Describes zero-or-one expansions (e.g., [foo], foo?).
*/
public class ZeroOrOne extends Expansion {
/**
* The expansion which is repeated zero or one times.
*/
public Expansion expansion;
}