// Generated from /Users/wmc/workspace/notetron/antlr-md/test/Markdown.g4 by ANTLR 4.9.2
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;

@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class MarkdownParser extends Parser {
	static { RuntimeMetaData.checkVersion("4.9.2", RuntimeMetaData.VERSION); }

	protected static final DFA[] _decisionToDFA;
	protected static final PredictionContextCache _sharedContextCache =
		new PredictionContextCache();
	public static final int
		HEADER=1, BACKTICK=2, TEXT=3, WS=4, NL=5, HASH=6;
	public static final int
		RULE_markdown = 0, RULE_block = 1, RULE_header = 2, RULE_headerText = 3, 
		RULE_headerFlag = 4, RULE_blockLine = 5, RULE_blockText = 6, RULE_text = 7, 
		RULE_inlineCode = 8;
	private static String[] makeRuleNames() {
		return new String[] {
			"markdown", "block", "header", "headerText", "headerFlag", "blockLine", 
			"blockText", "text", "inlineCode"
		};
	}
	public static final String[] ruleNames = makeRuleNames();

	private static String[] makeLiteralNames() {
		return new String[] {
			null, null, "'`'", null, null, null, "'#'"
		};
	}
	private static final String[] _LITERAL_NAMES = makeLiteralNames();
	private static String[] makeSymbolicNames() {
		return new String[] {
			null, "HEADER", "BACKTICK", "TEXT", "WS", "NL", "HASH"
		};
	}
	private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
	public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);

	/**
	 * @deprecated Use {@link #VOCABULARY} instead.
	 */
	@Deprecated
	public static final String[] tokenNames;
	static {
		tokenNames = new String[_SYMBOLIC_NAMES.length];
		for (int i = 0; i < tokenNames.length; i++) {
			tokenNames[i] = VOCABULARY.getLiteralName(i);
			if (tokenNames[i] == null) {
				tokenNames[i] = VOCABULARY.getSymbolicName(i);
			}

			if (tokenNames[i] == null) {
				tokenNames[i] = "<INVALID>";
			}
		}
	}

	@Override
	@Deprecated
	public String[] getTokenNames() {
		return tokenNames;
	}

	@Override

	public Vocabulary getVocabulary() {
		return VOCABULARY;
	}

	@Override
	public String getGrammarFileName() { return "Markdown.g4"; }

	@Override
	public String[] getRuleNames() { return ruleNames; }

	@Override
	public String getSerializedATN() { return _serializedATN; }

	@Override
	public ATN getATN() { return _ATN; }

	public MarkdownParser(TokenStream input) {
		super(input);
		_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
	}

	public static class MarkdownContext extends ParserRuleContext {
		public TerminalNode EOF() { return getToken(MarkdownParser.EOF, 0); }
		public List<BlockContext> block() {
			return getRuleContexts(BlockContext.class);
		}
		public BlockContext block(int i) {
			return getRuleContext(BlockContext.class,i);
		}
		public MarkdownContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_markdown; }
	}

	public final MarkdownContext markdown() throws RecognitionException {
		MarkdownContext _localctx = new MarkdownContext(_ctx, getState());
		enterRule(_localctx, 0, RULE_markdown);
		int _la;
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(21);
			_errHandler.sync(this);
			_la = _input.LA(1);
			while (_la==HEADER || _la==NL) {
				{
				{
				setState(18);
				block();
				}
				}
				setState(23);
				_errHandler.sync(this);
				_la = _input.LA(1);
			}
			setState(24);
			match(EOF);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class BlockContext extends ParserRuleContext {
		public HeaderContext header() {
			return getRuleContext(HeaderContext.class,0);
		}
		public BlockLineContext blockLine() {
			return getRuleContext(BlockLineContext.class,0);
		}
		public BlockContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_block; }
	}

	public final BlockContext block() throws RecognitionException {
		BlockContext _localctx = new BlockContext(_ctx, getState());
		enterRule(_localctx, 2, RULE_block);
		try {
			setState(28);
			_errHandler.sync(this);
			switch (_input.LA(1)) {
			case HEADER:
				enterOuterAlt(_localctx, 1);
				{
				setState(26);
				header();
				}
				break;
			case NL:
				enterOuterAlt(_localctx, 2);
				{
				setState(27);
				blockLine();
				}
				break;
			default:
				throw new NoViableAltException(this);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class HeaderContext extends ParserRuleContext {
		public TerminalNode HEADER() { return getToken(MarkdownParser.HEADER, 0); }
		public TerminalNode NL() { return getToken(MarkdownParser.NL, 0); }
		public List<HeaderTextContext> headerText() {
			return getRuleContexts(HeaderTextContext.class);
		}
		public HeaderTextContext headerText(int i) {
			return getRuleContext(HeaderTextContext.class,i);
		}
		public HeaderContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_header; }
	}

	public final HeaderContext header() throws RecognitionException {
		HeaderContext _localctx = new HeaderContext(_ctx, getState());
		enterRule(_localctx, 4, RULE_header);
		int _la;
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(30);
			match(HEADER);
			setState(32); 
			_errHandler.sync(this);
			_la = _input.LA(1);
			do {
				{
				{
				setState(31);
				headerText();
				}
				}
				setState(34); 
				_errHandler.sync(this);
				_la = _input.LA(1);
			} while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << BACKTICK) | (1L << TEXT) | (1L << WS) | (1L << HASH))) != 0) );
			setState(36);
			match(NL);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class HeaderTextContext extends ParserRuleContext {
		public List<HeaderFlagContext> headerFlag() {
			return getRuleContexts(HeaderFlagContext.class);
		}
		public HeaderFlagContext headerFlag(int i) {
			return getRuleContext(HeaderFlagContext.class,i);
		}
		public List<InlineCodeContext> inlineCode() {
			return getRuleContexts(InlineCodeContext.class);
		}
		public InlineCodeContext inlineCode(int i) {
			return getRuleContext(InlineCodeContext.class,i);
		}
		public List<TextContext> text() {
			return getRuleContexts(TextContext.class);
		}
		public TextContext text(int i) {
			return getRuleContext(TextContext.class,i);
		}
		public HeaderTextContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_headerText; }
	}

	public final HeaderTextContext headerText() throws RecognitionException {
		HeaderTextContext _localctx = new HeaderTextContext(_ctx, getState());
		enterRule(_localctx, 6, RULE_headerText);
		try {
			int _alt;
			enterOuterAlt(_localctx, 1);
			{
			setState(41); 
			_errHandler.sync(this);
			_alt = 1;
			do {
				switch (_alt) {
				case 1:
					{
					setState(41);
					_errHandler.sync(this);
					switch (_input.LA(1)) {
					case WS:
					case HASH:
						{
						setState(38);
						headerFlag();
						}
						break;
					case BACKTICK:
						{
						setState(39);
						inlineCode();
						}
						break;
					case TEXT:
						{
						setState(40);
						text();
						}
						break;
					default:
						throw new NoViableAltException(this);
					}
					}
					break;
				default:
					throw new NoViableAltException(this);
				}
				setState(43); 
				_errHandler.sync(this);
				_alt = getInterpreter().adaptivePredict(_input,4,_ctx);
			} while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER );
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class HeaderFlagContext extends ParserRuleContext {
		public List<TerminalNode> HASH() { return getTokens(MarkdownParser.HASH); }
		public TerminalNode HASH(int i) {
			return getToken(MarkdownParser.HASH, i);
		}
		public List<TerminalNode> WS() { return getTokens(MarkdownParser.WS); }
		public TerminalNode WS(int i) {
			return getToken(MarkdownParser.WS, i);
		}
		public HeaderFlagContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_headerFlag; }
	}

	public final HeaderFlagContext headerFlag() throws RecognitionException {
		HeaderFlagContext _localctx = new HeaderFlagContext(_ctx, getState());
		enterRule(_localctx, 8, RULE_headerFlag);
		int _la;
		try {
			int _alt;
			enterOuterAlt(_localctx, 1);
			{
			setState(46); 
			_errHandler.sync(this);
			_alt = 1;
			do {
				switch (_alt) {
				case 1:
					{
					{
					setState(45);
					_la = _input.LA(1);
					if ( !(_la==WS || _la==HASH) ) {
					_errHandler.recoverInline(this);
					}
					else {
						if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
						_errHandler.reportMatch(this);
						consume();
					}
					}
					}
					break;
				default:
					throw new NoViableAltException(this);
				}
				setState(48); 
				_errHandler.sync(this);
				_alt = getInterpreter().adaptivePredict(_input,5,_ctx);
			} while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER );
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class BlockLineContext extends ParserRuleContext {
		public TerminalNode NL() { return getToken(MarkdownParser.NL, 0); }
		public BlockLineContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_blockLine; }
	}

	public final BlockLineContext blockLine() throws RecognitionException {
		BlockLineContext _localctx = new BlockLineContext(_ctx, getState());
		enterRule(_localctx, 10, RULE_blockLine);
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(50);
			match(NL);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class BlockTextContext extends ParserRuleContext {
		public TextContext text() {
			return getRuleContext(TextContext.class,0);
		}
		public TerminalNode NL() { return getToken(MarkdownParser.NL, 0); }
		public BlockTextContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_blockText; }
	}

	public final BlockTextContext blockText() throws RecognitionException {
		BlockTextContext _localctx = new BlockTextContext(_ctx, getState());
		enterRule(_localctx, 12, RULE_blockText);
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(52);
			text();
			setState(53);
			match(NL);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class TextContext extends ParserRuleContext {
		public TerminalNode TEXT() { return getToken(MarkdownParser.TEXT, 0); }
		public TextContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_text; }
	}

	public final TextContext text() throws RecognitionException {
		TextContext _localctx = new TextContext(_ctx, getState());
		enterRule(_localctx, 14, RULE_text);
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(55);
			match(TEXT);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class InlineCodeContext extends ParserRuleContext {
		public List<TerminalNode> BACKTICK() { return getTokens(MarkdownParser.BACKTICK); }
		public TerminalNode BACKTICK(int i) {
			return getToken(MarkdownParser.BACKTICK, i);
		}
		public TerminalNode TEXT() { return getToken(MarkdownParser.TEXT, 0); }
		public InlineCodeContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_inlineCode; }
	}

	public final InlineCodeContext inlineCode() throws RecognitionException {
		InlineCodeContext _localctx = new InlineCodeContext(_ctx, getState());
		enterRule(_localctx, 16, RULE_inlineCode);
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(57);
			match(BACKTICK);
			setState(58);
			match(TEXT);
			setState(59);
			match(BACKTICK);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static final String _serializedATN =
		"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\b@\4\2\t\2\4\3\t"+
		"\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\3\2\7\2\26"+
		"\n\2\f\2\16\2\31\13\2\3\2\3\2\3\3\3\3\5\3\37\n\3\3\4\3\4\6\4#\n\4\r\4"+
		"\16\4$\3\4\3\4\3\5\3\5\3\5\6\5,\n\5\r\5\16\5-\3\6\6\6\61\n\6\r\6\16\6"+
		"\62\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\n\3\n\3\n\3\n\3\n\2\2\13\2\4\6\b\n\f"+
		"\16\20\22\2\3\4\2\6\6\b\b\2=\2\27\3\2\2\2\4\36\3\2\2\2\6 \3\2\2\2\b+\3"+
		"\2\2\2\n\60\3\2\2\2\f\64\3\2\2\2\16\66\3\2\2\2\209\3\2\2\2\22;\3\2\2\2"+
		"\24\26\5\4\3\2\25\24\3\2\2\2\26\31\3\2\2\2\27\25\3\2\2\2\27\30\3\2\2\2"+
		"\30\32\3\2\2\2\31\27\3\2\2\2\32\33\7\2\2\3\33\3\3\2\2\2\34\37\5\6\4\2"+
		"\35\37\5\f\7\2\36\34\3\2\2\2\36\35\3\2\2\2\37\5\3\2\2\2 \"\7\3\2\2!#\5"+
		"\b\5\2\"!\3\2\2\2#$\3\2\2\2$\"\3\2\2\2$%\3\2\2\2%&\3\2\2\2&\'\7\7\2\2"+
		"\'\7\3\2\2\2(,\5\n\6\2),\5\22\n\2*,\5\20\t\2+(\3\2\2\2+)\3\2\2\2+*\3\2"+
		"\2\2,-\3\2\2\2-+\3\2\2\2-.\3\2\2\2.\t\3\2\2\2/\61\t\2\2\2\60/\3\2\2\2"+
		"\61\62\3\2\2\2\62\60\3\2\2\2\62\63\3\2\2\2\63\13\3\2\2\2\64\65\7\7\2\2"+
		"\65\r\3\2\2\2\66\67\5\20\t\2\678\7\7\2\28\17\3\2\2\29:\7\5\2\2:\21\3\2"+
		"\2\2;<\7\4\2\2<=\7\5\2\2=>\7\4\2\2>\23\3\2\2\2\b\27\36$+-\62";
	public static final ATN _ATN =
		new ATNDeserializer().deserialize(_serializedATN.toCharArray());
	static {
		_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
		for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
			_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
		}
	}
}