Portable class library does not support console IO

This commit is contained in:
Sam Harwell 2013-03-05 15:31:05 -06:00
parent 00689a40bc
commit 307464f818
7 changed files with 31 additions and 1 deletions

View File

@ -203,8 +203,10 @@ namespace Antlr4.Runtime.Atn
{
if (epsilonOnlyTransitions != e.IsEpsilon)
{
#if !PORTABLE
System.Console.Error.WriteLine("ATN state {0} has both epsilon and non-epsilon transitions."
, stateNumber);
#endif
epsilonOnlyTransitions = false;
}
}

View File

@ -1833,10 +1833,12 @@ namespace Antlr4.Runtime.Atn
string[] tokensNames = parser.TokenNames;
if (t >= tokensNames.Length)
{
#if !PORTABLE
System.Console.Error.WriteLine(t + " ttype out of range: " + Arrays.ToString(tokensNames
));
System.Console.Error.WriteLine(((CommonTokenStream)((ITokenStream)parser.InputStream
)).GetTokens());
#endif
}
else
{
@ -1851,6 +1853,7 @@ namespace Antlr4.Runtime.Atn
return GetTokenName(input.La(1));
}
#if !PORTABLE
public virtual void DumpDeadEndConfigs(NoViableAltException nvae)
{
System.Console.Error.WriteLine("dead end configs: ");
@ -1878,6 +1881,7 @@ namespace Antlr4.Runtime.Atn
System.Console.Error.WriteLine(c.ToString(parser, true) + ":" + trans);
}
}
#endif
[return: NotNull]
public virtual NoViableAltException NoViableAlt(ITokenStream input, ParserRuleContext

View File

@ -27,6 +27,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !PORTABLE
using Antlr4.Runtime;
using Sharpen;
@ -45,3 +48,5 @@ namespace Antlr4.Runtime
}
}
}
#endif

View File

@ -116,8 +116,10 @@ namespace Antlr4.Runtime
}
else
{
#if !PORTABLE
System.Console.Error.WriteLine("unknown recognition error type: " + e.GetType().FullName
);
#endif
NotifyErrorListeners(recognizer, e.Message, e);
}
}

View File

@ -44,6 +44,7 @@ namespace Antlr4.Runtime
/// </remarks>
public abstract class Parser : Recognizer<IToken, ParserATNSimulator>
{
#if !PORTABLE
public class TraceListener : IParseTreeListener
{
public virtual void EnterEveryRule(ParserRuleContext ctx)
@ -77,6 +78,7 @@ namespace Antlr4.Runtime
private readonly Parser _enclosing;
}
#endif
public class TrimToSizeListener : IParseTreeListener
{
@ -121,7 +123,9 @@ namespace Antlr4.Runtime
protected internal bool _buildParseTrees = true;
#if !PORTABLE
protected internal Parser.TraceListener _tracer;
#endif
/// <summary>
/// If the listener is non-null, trigger enter and exit rule events
@ -158,7 +162,9 @@ namespace Antlr4.Runtime
_errHandler.EndErrorCondition(this);
_ctx = null;
_syntaxErrors = 0;
#if !PORTABLE
_tracer = null;
#endif
_precedenceStack.Clear();
_precedenceStack.Add(0);
ATNSimulator interpreter = Interpreter;
@ -869,6 +875,7 @@ namespace Antlr4.Runtime
return s;
}
#if !PORTABLE
/// <summary>For debugging and other purposes</summary>
public virtual void DumpDFA()
{
@ -888,6 +895,7 @@ namespace Antlr4.Runtime
}
}
}
#endif
public virtual string SourceName
{
@ -916,6 +924,7 @@ namespace Antlr4.Runtime
return strings;
}
#if !PORTABLE
/// <summary>
/// During a parse is sometimes useful to listen in on the rule entry and exit
/// events as well as token matches.
@ -959,5 +968,6 @@ namespace Antlr4.Runtime
}
}
}
#endif
}
}

View File

@ -42,7 +42,12 @@ namespace Antlr4.Runtime
public const int Eof = -1;
[NotNull]
private IAntlrErrorListener<Symbol>[] _listeners = { ConsoleErrorListener<Symbol>.Instance };
private IAntlrErrorListener<Symbol>[] _listeners =
{
#if !PORTABLE
ConsoleErrorListener<Symbol>.Instance
#endif
};
protected internal ATNInterpreter _interp;

View File

@ -630,7 +630,9 @@ namespace Antlr4.Runtime
// kill first delete
rop.index = Math.Min(prevRop.index, rop.index);
rop.lastIndex = Math.Max(prevRop.lastIndex, rop.lastIndex);
#if !PORTABLE
System.Console.Out.WriteLine("new rop " + rop);
#endif
}
else
{