Commit c35ed3ab authored by petter's avatar petter

fixed deprecated constructors and non-zero location ranges on empty productions


git-svn-id: https://www2.in.tum.de/repos/cup/develop@65 f8377d4f-c7f8-0310-b030-a31f13008fac
parent d2c78bdc
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
......
......@@ -1223,15 +1223,20 @@ be found in the parser generator and runtime source code. See the CUP
home page below for access to the API documentation for the system and its
runtime.</p><p>
This document covers version 0.10j of the system. Check the CUP home
This document covers version 0.11b of the system. Check the CUP home
page:
<a href="http://www.cs.princeton.edu/%7Eappel/modern/java/CUP/">
http://www.cs.princeton.edu/~appel/modern/java/CUP/</a>
<a href="http://www2.in.tum.de/projects/cuptum">
http://www2.in.tum.de/projects/cuptum/</a>
for the latest release information, instructions for downloading the
system, and additional news about CUP. Bug reports and other
comments for the developers should be sent to the CUP maintainer,
M. Petter, at
<a href="mailto:petterATcs.tum.edu">
petterATcs.tum.edu</a></p><p>
Before this, it was maintained by
C. Scott Ananian, at
<a href="mailto:cananian@alumni.princeton.edu">
<a href="cananian@alumni.princeton.edu">
cananian@alumni.princeton.edu</a></p><p>
CUP was originally written by
......
......@@ -527,7 +527,7 @@ public class emit {
out.println(" " + pre("result") + " = parser.getSymbolFactory().newSymbol(" +
"\""+ prod.lhs().the_symbol().name() +"\","+
prod.lhs().the_symbol().index() +
", " + leftstring + ", " + rightstring + ", RESULT);");
", " + leftstring + ((prod.rhs_length()==0)?(""):(", " + rightstring)) + ", RESULT);");
} else {
out.println(" " + pre("result") + " = parser.getSymbolFactory().newSymbol(" +
"\""+ prod.lhs().the_symbol().name() + "\","+
......@@ -943,10 +943,12 @@ public class emit {
/* constructors [CSA/davidm, 24-jul-99] */
out.println();
out.println(" /** Default constructor. */");
out.println(" @Deprecated");
out.println(" public " + parser_class_name + "() {super();}");
if (!suppress_scanner) {
out.println();
out.println(" /** Constructor which sets the default scanner. */");
out.println(" @Deprecated");
out.println(" public " + parser_class_name +
"(java_cup.runtime.Scanner s) {super(s);}");
// TUM 20060327 added SymbolFactory aware constructor
......
......@@ -19,6 +19,13 @@ public class ComplexSymbolFactory implements SymbolFactory{
public static class Location {
private String unit="unknown";
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
......@@ -78,6 +85,28 @@ public class ComplexSymbolFactory implements SymbolFactory{
public int getLine(){
return line;
}
/**
* move moves this Location by the given differences.
* @param linediff
* @param coldiff
* @param offsetdiff
*/
public void move(int linediff, int coldiff, int offsetdiff){
if (this.line >= 0)
this.line += linediff;
if (this.column >= 0)
this.column += coldiff;
if (this.offset >= 0)
this.offset += offsetdiff;
}
/**
* Cloning factory method
* @param other
* @return new cloned Location
*/
public static Location clone(Location other){
return new Location(other);
}
/**
* getUnit
* @returns compilation unit if known, else 'unknown'
......@@ -158,6 +187,14 @@ public class ComplexSymbolFactory implements SymbolFactory{
if (left!=null) this.xleft = ((ComplexSymbol)left).xleft;
if (right!=null) this.xright= ((ComplexSymbol)right).xright;
}
public ComplexSymbol(String name, int id, Symbol left, Object value) {
super(id,left.right,left.right,value);
this.name=name;
if (left!=null) {
this.xleft = ((ComplexSymbol)left).xright;
this.xright= ((ComplexSymbol)left).xright;
}
}
public ComplexSymbol(String name, int id, Location left, Location right, Object value) {
super(id,left.offset,right.offset,value);
this.name=name;
......@@ -190,6 +227,9 @@ public class ComplexSymbolFactory implements SymbolFactory{
public Symbol newSymbol(String name, int id, Location left, Location right){
return new ComplexSymbol(name,id,left,right);
}
public Symbol newSymbol(String name, int id, Symbol left, Object value) {
return new ComplexSymbol(name,id,left,value);
}
public Symbol newSymbol(String name, int id, Symbol left, Symbol right, Object value){
return new ComplexSymbol(name,id,left,right,value);
}
......
......@@ -31,6 +31,9 @@ public class DefaultSymbolFactory implements SymbolFactory{
public Symbol newSymbol(String name ,int id, Symbol left, Symbol right, Object value){
return new Symbol(id,left,right,value);
}
public Symbol newSymbol(String name ,int id, Symbol left, Object value){
return new Symbol(id,left,value);
}
public Symbol newSymbol(String name, int id, Symbol left, Symbol right){
return new Symbol(id,left,right);
}
......
......@@ -34,7 +34,10 @@ public class Symbol {
public Symbol(int id, Symbol left, Symbol right){
this(id,left.left,right.right);
}
/*******************************
public Symbol(int id, Symbol left, Object o){
this(id,left.right,left.right,o);
}
/*******************************
Constructor for l,r values
*******************************/
......
......@@ -37,6 +37,15 @@ public interface SymbolFactory {
* @param right symbol, to take the right location from
*/
public Symbol newSymbol(String name, int id, Symbol left, Symbol right);
/**
* newSymbol
* creates a symbol for an empty production, taking its location from the Symbol on the left
* @param name Textual name for the Symbol for verbose error messages
* @param id enum value associated with this symbol, generated by cup via sym.java
* @param left symbol, to take the left location from
* @param value value, attached to this symbol
*/
public Symbol newSymbol(String name, int id, Symbol left, Object value);
/**
* newSymbol
* creates a basic symbol with an attached value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment