Updated reference build of ANTLR 4

This commit is contained in:
Sam Harwell 2013-02-24 12:42:19 -06:00
parent ef57689c88
commit 17374ffc49
7 changed files with 31 additions and 21 deletions

@ -1 +1 @@
Subproject commit b106c4363db4aa913887021c7c2cf245ba7a5fa3
Subproject commit 421b0b305ac3db5fac0074f8b3ec36fed675b3b8

View File

@ -39,6 +39,9 @@ namespace Antlr4.Runtime
{
private const long serialVersionUID = -6708843461296520577L;
protected internal static readonly Tuple<ITokenSource, ICharStream> EmptySource =
Tuple.Create<ITokenSource, ICharStream>(null, null);
protected internal int type;
protected internal int line;
@ -94,6 +97,7 @@ namespace Antlr4.Runtime
this.type = type;
this.channel = TokenConstants.DefaultChannel;
this.text = text;
this.source = EmptySource;
}
public CommonToken(IToken oldToken)
@ -270,9 +274,9 @@ namespace Antlr4.Runtime
string txt = Text;
if (txt != null)
{
txt = txt.ReplaceAll("\n", "\\\\n");
txt = txt.ReplaceAll("\r", "\\\\r");
txt = txt.ReplaceAll("\t", "\\\\t");
txt = txt.Replace("\n", "\\n");
txt = txt.Replace("\r", "\\r");
txt = txt.Replace("\t", "\\t");
}
else
{

View File

@ -506,9 +506,9 @@ namespace Antlr4.Runtime
protected internal virtual string EscapeWSAndQuote(string s)
{
// if ( s==null ) return s;
s = s.ReplaceAll("\n", "\\\\n");
s = s.ReplaceAll("\r", "\\\\r");
s = s.ReplaceAll("\t", "\\\\t");
s = s.Replace("\n", "\\n");
s = s.Replace("\r", "\\r");
s = s.Replace("\t", "\\t");
return "'" + s + "'";
}

View File

@ -177,20 +177,23 @@ namespace Antlr4.Runtime.Misc
iter.Set(bigger);
// make sure we didn't just create an interval that
// should be merged with next interval in list
if (iter.HasNext())
while (iter.HasNext())
{
Interval next = iter.Next();
if (bigger.Adjacent(next) || !bigger.Disjoint(next))
if (!bigger.Adjacent(next) && bigger.Disjoint(next))
{
// if we bump up against or overlap next, merge
iter.Remove();
// remove this one
iter.Previous();
// move backwards to what we just set
iter.Set(bigger.Union(next));
break;
}
// if we bump up against or overlap next, merge
iter.Remove();
// remove this one
iter.Previous();
// move backwards to what we just set
iter.Set(bigger.Union(next));
// set to 3 merged ones
iter.Next();
}
// set to 3 merged ones
// first call to next after previous duplicates the result
return;
}
if (addition.StartsBeforeDisjoint(r))

View File

@ -174,7 +174,10 @@ namespace Antlr4.Runtime.Misc
public static void Main(string[] args)
{
Antlr4.Runtime.Misc.TestRig testRig = new Antlr4.Runtime.Misc.TestRig(args);
testRig.Process();
if (args.Length >= 2)
{
testRig.Process();
}
}
/// <exception cref="System.Exception"></exception>

View File

@ -148,9 +148,9 @@ namespace Antlr4.Runtime
s = "<" + t.Type + ">";
}
}
s = s.ReplaceAll("\n", "\\\\n");
s = s.ReplaceAll("\r", "\\\\r");
s = s.ReplaceAll("\t", "\\\\t");
s = s.Replace("\n", "\\n");
s = s.Replace("\r", "\\r");
s = s.Replace("\t", "\\t");
return "'" + s + "'";
}

View File

@ -288,7 +288,7 @@ namespace Antlr4.Runtime
{
return IntStreamConstants.Eof;
}
int c = data[index];
char c = data[index];
if (c == (char)IntStreamConstants.Eof)
{
return IntStreamConstants.Eof;