Commit 7f3969ef authored by Markus Koschany's avatar Markus Koschany

Import Upstream version 0.11b-20160615

parent 2a52475f
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/usr/share/ant/lib/ant.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CUP</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<project name="emugen" default ="dist" basedir=".">
<project name="cup" default ="dist" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<property name="etc" location="etc" />
<property name="bin" location="bin" />
<property name="lib" location="lib" />
......@@ -13,10 +13,34 @@
<!-- initialize the workspace -->
<target name="init">
<tstamp />
<available file="version.txt" property="version.present" />
<touch unless:set="version.present" file="version.txt" />
<mkdir dir="${src}" />
<mkdir dir="${java}" />
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${dist}" />
<loadfile property="cupversion" srcFile="version.txt" failonerror="false" />
<property name="cupversion" value="custombuild" unless:set="cupversion"/>
<exec executable="git" outputproperty="gitversion">
<arg value="log"/>
<arg value="-1"/>
<arg value="--format=%h"/>
</exec>
<exec executable="git" outputproperty="changed">
<arg value="status"/>
<arg value="--porcelain"/>
<redirector>
<outputfilterchain>
<linecontainsregexp>
<regexp pattern='^M.*'/>
</linecontainsregexp>
<tokenfilter>
<replaceregex pattern=".*" replace="modifications based on "/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
<property name="svnversion">${changed}${gitversion}</property>
</target>
<property environment="env" />
......@@ -53,27 +77,82 @@
<target name="compile" depends="jflex">
<copy todir="${java}"><fileset dir="${src}"></fileset></copy>
<javac srcdir="${java}" destdir="${classes}" verbose="off" listfiles="off" debug="on" source="1.2" target="1.2">
<replace file="${java}/java_cup/version.java"
token="+ version_str"
value='+ "v0.11b ${cupversion} (GIT ${svnversion})"'>
</replace>
<javac srcdir="${java}" destdir="${classes}" verbose="off" listfiles="off" debug="on" source="1.8" target="1.8">
<classpath refid="libraries"/>
</javac>
</target>
<target name="dist" depends="compile">
<jar jarfile="${dist}/java-cup-11a.jar" basedir="${classes}">
<jar jarfile="${dist}/java-cup-11b.jar" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="java_cup/Main" />
<attribute name="Class-Path" value="java-cup-11a-runtime.jar" />
<attribute name="Class-Path" value="java-cup-11b-runtime.jar" />
</manifest>
</jar>
<jar jarfile="${dist}/java-cup-11a-runtime.jar" basedir="${classes}" includes="java_cup/runtime/*">
<jar jarfile="${dist}/java-cup-11b-runtime.jar" basedir="${classes}" includes="java_cup/runtime/*">
</jar>
<tar longfile="gnu" destfile="${dist}/java-cup-bin-11b-${cupversion}.tar.gz" compression="gzip">
<tarfileset dir="${dist}" username="ant" group="ant">
<depth max="0"/>
<include name="*.jar"/>
</tarfileset>
</tar>
</target>
<target name="src-dist" depends="dist">
<tar longfile="gnu" destfile="${dist}/java-cup-src-11b-${cupversion}.tar.gz" compression="gzip">
<tarfileset dir="${src}" username="ant" group="ant" prefix="src/">
<include name="**"/>
</tarfileset>
<tarfileset dir="${cup}" username="ant" group="ant" prefix="cup/">
<include name="**"/>
</tarfileset>
<tarfileset dir="${flex}" username="ant" group="ant" prefix="flex/">
<include name="**"/>
</tarfileset>
<tarfileset dir="${bin}" username="ant" group="ant" prefix="bin/">
<include name="**"/>
</tarfileset>
<tarfileset dir="${lib}" username="ant" group="ant" prefix="lib/">
<include name="**"/>
</tarfileset>
<tarfileset dir="${src}/.." username="ant" group="ant">
<depth max="0"/>
<include name="*"/>
</tarfileset>
</tar>
</target>
<target name="test" depends="dist">
<java jar="${dist}/java-cup-11a.jar" fork="true">
<java jar="${dist}/java-cup-11b.jar" fork="true">
<arg value="-interface" />
<arg value="${cup}/parser.cup" />
</java>
</target>
<target name="versionbump" depends="init">
<echo message="${DSTAMP}" file="version.txt" />
</target>
<target name="scp" depends="src-dist">
<exec executable="scp">
<arg value="${dist}/java-cup-src-11b-${cupversion}.tar.gz" />
<arg value="${dist}/java-cup-bin-11b-${cupversion}.tar.gz" />
<arg value="${dist}/../manual.html" />
<arg value="petter@www2.in.tum.de:/srv/www/htdocs/projects/cup/releases" />
</exec>
</target>
<target name="help" depends="init">
<echo message="Targets:" />
<echo message=" dist to create CUP jars" />
<echo message=" src-dist to create release packages" />
<echo message=" scp to deploy relase to homepage" />
<echo message=" versionbump to inc release" />
</target>
</project>
CUP version 0.11b 20151001 is a feature release.
Implemented a generic pre-/post DFS search with visitor support
Also added fragments of XPath 1.0 query support on parse trees
Fixed the visibility of children and the variant attribute of XMLElement
M. Petter
Technische Universität München
2015/10/01
------------------------------------------------------------------------
CUP version 0.11b 20150326 is a bugfix release.
Fixed an issue with empty productions having non-empty location information
Fixed an issue with deprecation of constructors
M. Petter
Technische Universität München
2015/02/26
------------------------------------------------------------------------
CUP version 0.11b 20150226 is a feature release.
added the means to move Locations
M. Petter
Technische Universität München
2015/02/26
------------------------------------------------------------------------
CUP version 0.11b 20140808 is a feature/bugfix release.
added expected symbols to the report_error(...) method
added an expected_token_ids() to inform about valid continuations
added parameters and code to enable automatic creation of XML parse trees
fixed a bug in the lookahead computation
M. Petter
Technische Universität München
2014/02/26
------------------------------------------------------------------------
CUP version 0.11b beta 20140226 is a feature release.
Command line flag -locations now triggers the generation of the identifiers
xleft and xright in the actions section instead of left and right.
Both are of type ComplexSymbolFactory.Location instead of plain ints.
M. Petter
Technische Universität München
2014/02/26
------------------------------------------------------------------------
CUP version 0.11b beta 20140220 is a feature release.
Main switch statement now splits the action code in bundles of 300 productions
on several different method bodies. Should fix the 65k size boundary problem
M. Petter
Technische Universität München
2014/02/20
------------------------------------------------------------------------
CUP version 0.11a beta 20060608 is a bugfix release.
......
......@@ -185,14 +185,28 @@ action code {:
}
}
}
private int cur_debug_id = 0;
public int get_new_debug_id() {
return cur_debug_id++;
}
public String attach_debug_symbol(int id, String code) {
if (!parser.debugSymbols)
return code;
return "//@@CUPDBG" + id + "\n" + code;
}
:};
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
parser code {:
/* override error routines */
protected Lexer lexer;
public boolean debugSymbols;
public void setDebugSymbols(boolean debugSymbols){
this.debugSymbols = debugSymbols;
}
public void report_fatal_error(
String message,
Object info)
......@@ -230,7 +244,7 @@ terminal
PACKAGE, IMPORT, CODE, ACTION, PARSER, TERMINAL, NON, INIT, SCAN, WITH,
START, SEMI, COMMA, STAR, DOT, COLON, COLON_COLON_EQUALS, BAR, PRECEDENCE,
LEFT, RIGHT, NONASSOC, PERCENT_PREC, LBRACK, RBRACK, NONTERMINAL, GT, LT,
QUESTION, SUPER, EXTENDS;
QUESTION, SUPER, EXTENDS, CLASS;
terminal String ID, CODE_STRING;
......@@ -242,7 +256,7 @@ non terminal
type_id, term_name_list, non_term_name_list, production, prod_part_list,
prod_part, new_term_id, new_non_term_id, rhs_list, rhs, empty,
precedence_list, preced, terminal_list, precedence_l, declares_term,
declares_non_term;
declares_non_term, class_name;
non terminal String nt_id, symbol_id, label_id, opt_label, terminal_id,
term_id, robust_id, typearglist, typearguement, wildcard;
......@@ -263,6 +277,7 @@ spec ::=
:}
package_spec
import_list
class_name
code_parts
symbol_list
precedence_list
......@@ -322,6 +337,15 @@ import_spec ::=
SEMI
;
class_name ::=
empty |
CLASS ID:id SEMI
{:
emit.parser_class_name = id;
emit.symbol_const_class_name = id + "Sym";
:}
;
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
// allow any order; all parts are optional. [CSA, 23-Jul-1999]
......@@ -339,7 +363,7 @@ action_code_part ::=
if (emit.action_code!=null)
ErrorManager.getManager().emit_warning("Redundant action code (skipping)");
else /* save the user included code string */
emit.action_code = user_code;
emit.action_code = attach_debug_symbol(get_new_debug_id(),user_code);
:}
;
......@@ -351,7 +375,7 @@ parser_code_part ::=
if (emit.parser_code!=null)
ErrorManager.getManager().emit_warning("Redundant parser code (skipping)");
else /* save the user included code string */
emit.parser_code = user_code;
emit.parser_code = attach_debug_symbol(get_new_debug_id(),user_code);
:}
;
......@@ -363,7 +387,7 @@ init_code ::=
if (emit.init_code!=null)
ErrorManager.getManager().emit_warning("Redundant init code (skipping)");
else /* save the user code */
emit.init_code = user_code;
emit.init_code = attach_debug_symbol(get_new_debug_id(),user_code);
:}
;
......@@ -375,7 +399,7 @@ scan_code ::=
if (emit.scan_code!=null)
ErrorManager.getManager().emit_warning("Redundant scan code (skipping)");
else /* save the user code */
emit.scan_code = user_code;
emit.scan_code = attach_debug_symbol(get_new_debug_id(),user_code);
:}
;
......@@ -534,7 +558,7 @@ start_spec ::=
new_rhs();
add_rhs_part(add_lab(new symbol_part(start_nt), "start_val"));
add_rhs_part(new symbol_part(terminal.EOF));
add_rhs_part(new action_part("RESULT = start_val;"));
if (!emit._xmlactions) add_rhs_part(new action_part("RESULT = start_val;"));
emit.start_production =
new production(non_terminal.START_nt, rhs_parts, rhs_pos);
new_rhs();
......@@ -621,7 +645,7 @@ rhs ::=
new_rhs();
add_rhs_part(add_lab(new symbol_part(start_nt),"start_val"));
add_rhs_part(new symbol_part(terminal.EOF));
add_rhs_part(new action_part("RESULT = start_val;"));
if (!emit._xmlactions) add_rhs_part(new action_part("RESULT = start_val;"));
if ((sym!=null) && (sym instanceof terminal)) {
emit.start_production =
new production(non_terminal.START_nt, rhs_parts,
......@@ -657,7 +681,7 @@ rhs ::=
new_rhs();
add_rhs_part(add_lab(new symbol_part(start_nt),"start_val"));
add_rhs_part(new symbol_part(terminal.EOF));
add_rhs_part(new action_part("RESULT = start_val;"));
if (!emit._xmlactions) add_rhs_part(new action_part("RESULT = start_val;"));
emit.start_production =
new production(non_terminal.START_nt, rhs_parts, rhs_pos);
......@@ -699,7 +723,7 @@ prod_part ::=
CODE_STRING:code_str
{:
/* add a new production part */
add_rhs_part(new action_part(code_str));
add_rhs_part(new action_part(attach_debug_symbol(get_new_debug_id(),code_str)));
:}
;
......
......@@ -23,11 +23,9 @@ import java.io.InputStreamReader;
private ComplexSymbolFactory symbolFactory;
private int csline,cscolumn;
public Symbol symbol(String name, int code){
// System.out.println("code:"+code+" "+yytext());
return symbolFactory.newSymbol(name, code,new Location(yyline+1,yycolumn+1-yylength()),new Location(yyline+1,yycolumn+1));
}
public Symbol symbol(String name, int code, String lexem){
// System.out.println("code:"+code+", lexem :"+lexem);
return symbolFactory.newSymbol(name, code, new Location(yyline+1, yycolumn +1), new Location(yyline+1,yycolumn+yylength()), lexem);
}
protected void emit_warning(String message){
......@@ -78,6 +76,7 @@ ident = ([:jletter:] | "_" ) ([:jletterdigit:] | [:jletter:] | "_" )*
"{:" { sb = new StringBuffer(); csline=yyline+1; cscolumn=yycolumn+1; yybegin(CODESEG); }
"package" { return symbol("PACKAGE",PACKAGE); }
"import" { return symbol("IMPORT",IMPORT); }
"class" { return symbol("CLASS",CLASS); }
"code" { return symbol("CODE",CODE); }
"action" { return symbol("ACTION",ACTION); }
"parser" { return symbol("PARSER",PARSER); }
......
CUP Parser Generator Copyright Notice, License, and Disclaimer
Copyright 1996-2015 by Scott Hudson, Frank Flannery, C. Scott Ananian, Michael Petter
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both the copyright notice and this permission notice and warranty disclaimer appear in supporting documentation, and that the names of the authors or their employers not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.
The authors and their employers disclaim all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall the authors or their employers be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software.
This is an open source license. It is also GPL-Compatible (see entry for "Standard ML of New Jersey"). The portions of CUP output which are hard-coded into the CUP source code are (naturally) covered by this same license, as is the CUP runtime code linked with the generated parser.
Java is a trademark of Sun Microsystems, Inc. References to the Java programming language in relation to JLex are not meant to imply that Sun endorses this product.
This diff is collapsed.
......@@ -54,6 +54,8 @@ import java_cup.runtime.*;
* <dd> turn on debugging messages within JavaCup
* <dt> -nopositions
* <dd> don't generate the positions code
* <dt> -locations
* <dd> generate handles xleft/xright for symbol positions in actions
* <dt> -noscanner
* <dd> don't refer to java_cup.runtime.Scanner in the parser
* (for compatibility with old runtimes)
......@@ -89,6 +91,8 @@ public class Main {
protected static boolean opt_show_timing = false;
/** User option -- do we run produce extra debugging messages */
protected static boolean opt_do_debug = false;
/** User option -- do eclipse debug symbols */
protected static boolean opt_do_debugsymbols = false;
/** User option -- do we compact tables by making most common reduce the
default action */
protected static boolean opt_compact_red = false;
......@@ -103,7 +107,10 @@ public class Main {
/* frankf added this 6/18/96 */
/** User option -- should generator generate code for left/right values? */
protected static boolean lr_values = true;
protected static boolean locations = false;
protected static boolean xmlactions = false;
protected static boolean genericlabels = false;
/** User option -- should symbols be put in a class or an interface? [CSA]*/
protected static boolean sym_interface = false;
......@@ -173,7 +180,10 @@ public class Main {
/* frankf 6/18/96
hackish, yes, but works */
emit.set_lr_values(lr_values);
/* open output files */
emit.set_locations(locations);
emit.set_xmlactions(xmlactions);
emit.set_genericlabels(genericlabels);
/* open output set_xmlactionsfiles */
if (print_progress) System.err.println("Opening files...");
/* use a buffered version of standard input */
input_file = new BufferedInputStream(System.in);
......@@ -248,6 +258,7 @@ public class Main {
System.err.println(message);
System.err.println();
System.err.println(
version.title_str + "\n" +
"Usage: " + version.program_name + " [options] [filename]\n" +
" and expects a specification file on standard input if no filename is given.\n" +
" Legal options include:\n" +
......@@ -263,6 +274,9 @@ public class Main {
" -nowarn don't warn about useless productions, etc.\n" +
" -nosummary don't print the usual summary of parse states, etc.\n" +
" -nopositions don't propagate the left and right token position values\n" +
" -locations generate handles xleft/xright for symbol positions in actions\n" +
" -xmlactions make the generated parser yield its parse tree as XML\n" +
" -genericlabels automatically generate labels to all symbols in XML mode\n" +
" -noscanner don't refer to java_cup.runtime.Scanner\n" +
" -progress print messages to indicate progress of the system\n" +
" -time print time usage summary\n" +
......@@ -358,8 +372,12 @@ public class Main {
opt_dump_states = opt_dump_tables = opt_dump_grammar = true;
else if (argv[i].equals("-time")) opt_show_timing = true;
else if (argv[i].equals("-debug")) opt_do_debug = true;
else if (argv[i].equals("-debugsymbols")) opt_do_debugsymbols = true;
/* frankf 6/18/96 */
else if (argv[i].equals("-nopositions")) lr_values = false;
else if (argv[i].equals("-locations")) locations = true;
else if (argv[i].equals("-xmlactions")) xmlactions = true;
else if (argv[i].equals("-genericlabels")) genericlabels = true;
/* CSA 12/21/97 */
else if (argv[i].equals("-interface")) sym_interface = true;
/* CSA 23-Jul-1999 */
......@@ -470,6 +488,7 @@ public class Main {
/* create a parser and parse with it */
ComplexSymbolFactory csf = new ComplexSymbolFactory();
parser_obj = new parser(new Lexer(csf),csf);
parser_obj.setDebugSymbols(opt_do_debugsymbols);
try {
if (opt_do_debug)
parser_obj.debug_parse();
......@@ -696,7 +715,7 @@ public class Main {
System.err.println(
"---------------------------------------------------- (" +
version.version_str + ")");
version.title_str + ")");
}
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
......
......@@ -55,7 +55,11 @@ public class CUPTask extends Task
private boolean dump=false;
private boolean time=false;
private boolean debug=false;
private boolean debugsymbols=false;
private boolean nopositions=false;
private boolean xmlactions=false;
private boolean genericlabels=false;
private boolean locations=true;
private boolean noscanner=false;
private boolean force=false;
private boolean quiet=false;
......@@ -88,7 +92,11 @@ public class CUPTask extends Task
if (dump) { sc.add("-dump"); }
if (time) { sc.add("-time"); }
if (debug) { sc.add("-debug"); }
if (debugsymbols) { sc.add("-debugsymbols"); }
if (nopositions) { sc.add("-nopositions"); }
if (locations) { sc.add("-locations"); }
if (genericlabels) { sc.add("-genericlabels"); }
if (xmlactions) { sc.add("-xmlactions"); }
if (noscanner) { sc.add("-noscanner"); }
if (!quiet) log ("This is "+version.title_str);
if (!quiet) log ("Authors : "+version.author_str);
......@@ -159,23 +167,6 @@ public class CUPTask extends Task
log("CUP error occured int CUP task: "+e);
}
// this is a dirty hack to determine the apropriate class path
// URL url = CUPTask.class.getResource("/java_cup/Main.class");
// String path = url.getPath().substring(0,url.getPath().length()-20);
// // if called from a .jar or .zip remove the last "!"
// if (path.endsWith("!")) path=path.substring(0,path.length()-1);
// createClasspath().setPath(path);
//
// setFailonerror(true);
// setFork(true);
//
// here, we prepare for calling CUP
// setClassname("java_cup.Main");
// let's call CUP
// super.execute();
}
/**
......@@ -560,8 +551,26 @@ public class CUPTask extends Task
public void setDebug(boolean argDebug){
this.debug = argDebug;
}
/**
* Gets the value of debug
*
* @return the value of debug
*/
public boolean isDebugSymbols() {
return this.debugsymbols;
}
/**
* Sets the value of debug
*
* @param argDebug Value to assign to this.debug
*/
public void setDebugSymbols(boolean argDebug){
this.debugsymbols = argDebug;
}
/**
* Gets the value of nopositions
*
* @return the value of nopositions
......@@ -578,6 +587,23 @@ public class CUPTask extends Task
public void setNopositions(boolean argNopositions){
this.nopositions = argNopositions;
}
/**
* Gets the value of locations
*
* @return the value of locations
*/
public boolean isLocations() {
return this.locations;
}
/**
* Sets the value of locations
*
* @param argLocations Value to assign to this.locations
*/
public void setLocations(boolean argLocations){
this.locations = argLocations;
}
/**
* Gets the value of noscanner
......@@ -597,6 +623,22 @@ public class CUPTask extends Task
this.noscanner = argNoscanner;
}
public boolean isXmlactions() {
return xmlactions;
}
public void setXmlactions(boolean xmlactions) {
this.xmlactions = xmlactions;
}
public boolean isGenericlabels() {
return genericlabels;
}
public void setGenericlabels(boolean genericlabels) {
this.genericlabels = genericlabels;
}
}
......
This diff is collapsed.
......@@ -747,9 +747,10 @@ public class lalr_state {
}
}
/* report S/R conflicts under all the symbols we conflict under */
terminal_set lookahead = itm.lookahead();
for (int t = 0; t < terminal.number(); t++)
if (conflict_set.contains(t))
report_shift_reduce(itm,t);
if (conflict_set.contains(t) && lookahead.contains(t))
report_shift_reduce(itm,t);
}
}
}
......@@ -808,6 +809,7 @@ public class lalr_state {
String message = "*** Shift/Reduce conflict found in state #"+index()+"\n" +
" between " + red_itm.to_simple_string()+"\n";
int relevancecounter = 0;
/* find and report on all items that shift under our conflict symbol */
for (Enumeration itms = items().all(); itms.hasMoreElements(); )
{
......@@ -816,10 +818,12 @@ public class lalr_state {
/* only look if its not the same item and not a reduce */
if (itm != red_itm && !itm.dot_at_end())
{
/* is it a shift on our conflicting terminal */
shift_sym = itm.symbol_after_dot();
if (!shift_sym.is_non_term() && shift_sym.index() == conflict_sym)
{
relevancecounter++;
/* yes, report on it */
message += " and " + itm.to_simple_string()+"\n";
}
......@@ -827,7 +831,7 @@ public class lalr_state {
}
message += " under symbol "+ terminal.find(conflict_sym).name() + "\n"+
" Resolved in favor of shifting.\n";
if (relevancecounter==0) return;
/* count the conflict */
emit.num_conflicts++;
ErrorManager.getManager().emit_warning(message);
......
......@@ -395,7 +395,8 @@ public class production {
String ret;
/* Put in the left/right value labels */
if (emit.lr_values())
if (emit.lr_values()){
if (!emit.locations())
ret = "\t\tint " + labelname + "left = ((java_cup.runtime.Symbol)" +
emit.pre("stack") +
// TUM 20050917
......@@ -406,6 +407,17 @@ public class production {
// TUM 20050917
((offset==0)?".peek()":(".elementAt(" + emit.pre("top") + "-" + offset + ")"))+
").right;\n";
else
ret = "\t\tLocation " + labelname + "xleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)" +
emit.pre("stack") +
// TUM 20050917
((offset==0)?".peek()":(".elementAt(" + emit.pre("top") + "-" + offset + ")"))+
").xleft;\n" +
"\t\tLocation " + labelname + "xright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)" +
emit.pre("stack") +
// TUM 20050917
((offset==0)?".peek()":(".elementAt(" + emit.pre("top") + "-" + offset + ")"))+
").xright;\n";}
else ret = "";
/* otherwise, just declare label. */
......@@ -441,12 +453,13 @@ public class production {
if (!rhs[pos].is_action())
{
part = (symbol_part)rhs[pos];
String label;
/* if it has a label, make declaration! */
if (part.label() != null)
if ((label=part.label()) != null || emit._xmlactions)
{
if (label==null) label=part.the_symbol().name()+pos;
declaration = declaration +
make_declaration(part.label(), part.the_symbol().stack_type(),
make_declaration(label, part.the_symbol().stack_type(),
rhs_len-pos-1);
}
}
......
package java_cup.runtime;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
/**
* Default Implementation for SymbolFactory, creates
* plain old Symbols
......@@ -10,41 +13,143 @@ package java_cup.runtime;
/* *************************************************
class DefaultSymbolFactory
interface for creating new symbols
***************************************************/
public class ComplexSymbolFactory implements SymbolFactory{
public static class Location {
private String unit="unknown";
private int line, column;
private int line, column, offset=-1;
/**
* Copy Constructor for other ComplexSymbolFactory based Locations
* @param other
*/
public Location(Location other){
this(other.unit,other.line,other.column,other.offset);
}
/**
* Location Object
* stores compilation unit, line, column and offset to the file start
* @param unit compilation unit, e.g. file name
* @param line line number
* @param column column number
* @param offset offset from file start
*/
public Location(String unit, int line, int column, int offset){
this(unit,line,column);
this.offset=offset;
}
/**
* Location Object
* stores compilation unit, line and column
* @param unit compilation unit, e.g. file name
* @param line line number
* @param column column number
*/
public Location(String unit, int line, int column){
this.unit=unit;
this.line=line;
this.column=column;
}
/**
* Location Object
* stores line, column and offset to the file start
* @param line line number
* @param column column number
* @param offset offset from file start
*/
public Location(int line, int column, int offset){
this(line,column);