forked from jasder/antlr
258 lines
7.6 KiB
C#
258 lines
7.6 KiB
C#
//------------------------------------------------------------------------------
|
|
// <auto-generated>
|
|
// This code was generated by a tool.
|
|
// ANTLR Version: 4.4.1-dev
|
|
//
|
|
// Changes to this file may cause incorrect behavior and will be lost if
|
|
// the code is regenerated.
|
|
// </auto-generated>
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Generated from /users/ericvergnaud/Development/antlr4/antlr/antlr4-csharp/runtime/CSharp/Antlr4.Test.mono/T.g4 by ANTLR 4.4.1-dev
|
|
|
|
// Unreachable code detected
|
|
#pragma warning disable 0162
|
|
// The variable '...' is assigned but its value is never used
|
|
#pragma warning disable 0219
|
|
// Missing XML comment for publicly visible type or member '...'
|
|
#pragma warning disable 1591
|
|
|
|
using System;
|
|
using System.Text;
|
|
using System.Diagnostics;
|
|
using System.Collections.Generic;
|
|
using Antlr4.Runtime;
|
|
using Antlr4.Runtime.Atn;
|
|
using Antlr4.Runtime.Misc;
|
|
using Antlr4.Runtime.Tree;
|
|
using DFA = Antlr4.Runtime.Dfa.DFA;
|
|
|
|
[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.4.1-dev")]
|
|
[System.CLSCompliant(false)]
|
|
public partial class TParser : Parser {
|
|
public const int
|
|
T__0=1, ID=2, INT=3, WS=4;
|
|
public const int
|
|
RULE_s = 0, RULE_t = 1, RULE_e = 2;
|
|
public static readonly string[] ruleNames = {
|
|
"s", "t", "e"
|
|
};
|
|
|
|
private static readonly string[] _LiteralNames = {
|
|
null, "'!'"
|
|
};
|
|
private static readonly string[] _SymbolicNames = {
|
|
null, null, "ID", "INT", "WS"
|
|
};
|
|
public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames);
|
|
|
|
[NotNull]
|
|
public override IVocabulary Vocabulary
|
|
{
|
|
get
|
|
{
|
|
return DefaultVocabulary;
|
|
}
|
|
}
|
|
|
|
public override string GrammarFileName { get { return "T.g4"; } }
|
|
|
|
public override string[] RuleNames { get { return ruleNames; } }
|
|
|
|
public override string SerializedAtn { get { return _serializedATN; } }
|
|
|
|
|
|
bool pred(bool v) {
|
|
Console.WriteLine("eval="+v.ToString().ToLower());
|
|
return v;
|
|
}
|
|
|
|
public TParser(ITokenStream input)
|
|
: base(input)
|
|
{
|
|
Interpreter = new ParserATNSimulator(this,_ATN);
|
|
}
|
|
public partial class SContext : ParserRuleContext {
|
|
public EContext e() {
|
|
return GetRuleContext<EContext>(0);
|
|
}
|
|
public SContext(ParserRuleContext parent, int invokingState)
|
|
: base(parent, invokingState)
|
|
{
|
|
}
|
|
public override int RuleIndex { get { return RULE_s; } }
|
|
public override void EnterRule(IParseTreeListener listener) {
|
|
ITListener typedListener = listener as ITListener;
|
|
if (typedListener != null) typedListener.EnterS(this);
|
|
}
|
|
public override void ExitRule(IParseTreeListener listener) {
|
|
ITListener typedListener = listener as ITListener;
|
|
if (typedListener != null) typedListener.ExitS(this);
|
|
}
|
|
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
|
|
ITVisitor<TResult> typedVisitor = visitor as ITVisitor<TResult>;
|
|
if (typedVisitor != null) return typedVisitor.VisitS(this);
|
|
else return visitor.VisitChildren(this);
|
|
}
|
|
}
|
|
|
|
[RuleVersion(0)]
|
|
public SContext s() {
|
|
SContext _localctx = new SContext(Context, State);
|
|
EnterRule(_localctx, 0, RULE_s);
|
|
try {
|
|
EnterOuterAlt(_localctx, 1);
|
|
{
|
|
State = 6; e();
|
|
State = 7;
|
|
if (!(this.pred(true))) throw new FailedPredicateException(this, "this.pred(true)");
|
|
Console.WriteLine("parse");
|
|
State = 9; Match(T__0);
|
|
}
|
|
}
|
|
catch (RecognitionException re) {
|
|
_localctx.exception = re;
|
|
ErrorHandler.ReportError(this, re);
|
|
ErrorHandler.Recover(this, re);
|
|
}
|
|
finally {
|
|
ExitRule();
|
|
}
|
|
return _localctx;
|
|
}
|
|
|
|
public partial class TContext : ParserRuleContext {
|
|
public EContext e() {
|
|
return GetRuleContext<EContext>(0);
|
|
}
|
|
public ITerminalNode ID() { return GetToken(TParser.ID, 0); }
|
|
public TContext(ParserRuleContext parent, int invokingState)
|
|
: base(parent, invokingState)
|
|
{
|
|
}
|
|
public override int RuleIndex { get { return RULE_t; } }
|
|
public override void EnterRule(IParseTreeListener listener) {
|
|
ITListener typedListener = listener as ITListener;
|
|
if (typedListener != null) typedListener.EnterT(this);
|
|
}
|
|
public override void ExitRule(IParseTreeListener listener) {
|
|
ITListener typedListener = listener as ITListener;
|
|
if (typedListener != null) typedListener.ExitT(this);
|
|
}
|
|
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
|
|
ITVisitor<TResult> typedVisitor = visitor as ITVisitor<TResult>;
|
|
if (typedVisitor != null) return typedVisitor.VisitT(this);
|
|
else return visitor.VisitChildren(this);
|
|
}
|
|
}
|
|
|
|
[RuleVersion(0)]
|
|
public TContext t() {
|
|
TContext _localctx = new TContext(Context, State);
|
|
EnterRule(_localctx, 2, RULE_t);
|
|
try {
|
|
EnterOuterAlt(_localctx, 1);
|
|
{
|
|
State = 11; e();
|
|
State = 12;
|
|
if (!(this.pred(false))) throw new FailedPredicateException(this, "this.pred(false)");
|
|
State = 13; Match(ID);
|
|
}
|
|
}
|
|
catch (RecognitionException re) {
|
|
_localctx.exception = re;
|
|
ErrorHandler.ReportError(this, re);
|
|
ErrorHandler.Recover(this, re);
|
|
}
|
|
finally {
|
|
ExitRule();
|
|
}
|
|
return _localctx;
|
|
}
|
|
|
|
public partial class EContext : ParserRuleContext {
|
|
public ITerminalNode ID() { return GetToken(TParser.ID, 0); }
|
|
public EContext(ParserRuleContext parent, int invokingState)
|
|
: base(parent, invokingState)
|
|
{
|
|
}
|
|
public override int RuleIndex { get { return RULE_e; } }
|
|
public override void EnterRule(IParseTreeListener listener) {
|
|
ITListener typedListener = listener as ITListener;
|
|
if (typedListener != null) typedListener.EnterE(this);
|
|
}
|
|
public override void ExitRule(IParseTreeListener listener) {
|
|
ITListener typedListener = listener as ITListener;
|
|
if (typedListener != null) typedListener.ExitE(this);
|
|
}
|
|
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
|
|
ITVisitor<TResult> typedVisitor = visitor as ITVisitor<TResult>;
|
|
if (typedVisitor != null) return typedVisitor.VisitE(this);
|
|
else return visitor.VisitChildren(this);
|
|
}
|
|
}
|
|
|
|
[RuleVersion(0)]
|
|
public EContext e() {
|
|
EContext _localctx = new EContext(Context, State);
|
|
EnterRule(_localctx, 4, RULE_e);
|
|
try {
|
|
State = 17;
|
|
switch ( Interpreter.AdaptivePredict(TokenStream,0,Context) ) {
|
|
case 1:
|
|
EnterOuterAlt(_localctx, 1);
|
|
{
|
|
State = 15; Match(ID);
|
|
}
|
|
break;
|
|
case 2:
|
|
EnterOuterAlt(_localctx, 2);
|
|
{
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
catch (RecognitionException re) {
|
|
_localctx.exception = re;
|
|
ErrorHandler.ReportError(this, re);
|
|
ErrorHandler.Recover(this, re);
|
|
}
|
|
finally {
|
|
ExitRule();
|
|
}
|
|
return _localctx;
|
|
}
|
|
|
|
public override bool Sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
|
|
switch (ruleIndex) {
|
|
case 0: return s_sempred((SContext)_localctx, predIndex);
|
|
case 1: return t_sempred((TContext)_localctx, predIndex);
|
|
}
|
|
return true;
|
|
}
|
|
private bool s_sempred(SContext _localctx, int predIndex) {
|
|
switch (predIndex) {
|
|
case 0: return this.pred(true);
|
|
}
|
|
return true;
|
|
}
|
|
private bool t_sempred(TContext _localctx, int predIndex) {
|
|
switch (predIndex) {
|
|
case 1: return this.pred(false);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static readonly string _serializedATN =
|
|
"\x3\x430\xD6D1\x8206\xAD2D\x4417\xAEF1\x8D80\xAADD\x3\x6\x16\x4\x2\t\x2"+
|
|
"\x4\x3\t\x3\x4\x4\t\x4\x3\x2\x3\x2\x3\x2\x3\x2\x3\x2\x3\x3\x3\x3\x3\x3"+
|
|
"\x3\x3\x3\x4\x3\x4\x5\x4\x14\n\x4\x3\x4\x2\x2\x5\x2\x4\x6\x2\x2\x13\x2"+
|
|
"\b\x3\x2\x2\x2\x4\r\x3\x2\x2\x2\x6\x13\x3\x2\x2\x2\b\t\x5\x6\x4\x2\t\n"+
|
|
"\x6\x2\x2\x2\n\v\b\x2\x1\x2\v\f\a\x3\x2\x2\f\x3\x3\x2\x2\x2\r\xE\x5\x6"+
|
|
"\x4\x2\xE\xF\x6\x3\x3\x2\xF\x10\a\x4\x2\x2\x10\x5\x3\x2\x2\x2\x11\x14"+
|
|
"\a\x4\x2\x2\x12\x14\x3\x2\x2\x2\x13\x11\x3\x2\x2\x2\x13\x12\x3\x2\x2\x2"+
|
|
"\x14\a\x3\x2\x2\x2\x3\x13";
|
|
public static readonly ATN _ATN =
|
|
new ATNDeserializer().Deserialize(_serializedATN.ToCharArray());
|
|
}
|