All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.rivulet.HTMLAttributesParser Maven / Gradle / Ivy

The newest version!
// Generated from io/rivulet/HTMLAttributes.g4 by ANTLR 4.0
package io.rivulet;

    import java.util.LinkedList;

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 HTMLAttributesParser extends Parser {
	protected static final DFA[] _decisionToDFA;
	protected static final PredictionContextCache _sharedContextCache =
		new PredictionContextCache();
	public static final int
		T__0=1, TAG_OPEN=2, TAG_CLOSE=3, NAME=4, VALUE=5, WHITESPACE=6, OTHER=7;
	public static final String[] tokenNames = {
		"", "'='", "'<'", "TAG_CLOSE", "NAME", "VALUE", "WHITESPACE", 
		"OTHER"
	};
	public static final int
		RULE_parse = 0, RULE_attribute = 1, RULE_value = 2;
	public static final String[] ruleNames = {
		"parse", "attribute", "value"
	};

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

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

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

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


	  public LinkedList attributes = new LinkedList<>();

	public HTMLAttributesParser(TokenStream input) {
		super(input);
		_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
	}
	public static class ParseContext extends ParserRuleContext {
		public TerminalNode TAG_OPEN() { return getToken(HTMLAttributesParser.TAG_OPEN, 0); }
		public AttributeContext attribute(int i) {
			return getRuleContext(AttributeContext.class,i);
		}
		public TerminalNode TAG_CLOSE() { return getToken(HTMLAttributesParser.TAG_CLOSE, 0); }
		public List attribute() {
			return getRuleContexts(AttributeContext.class);
		}
		public TerminalNode EOF() { return getToken(HTMLAttributesParser.EOF, 0); }
		public TerminalNode NAME() { return getToken(HTMLAttributesParser.NAME, 0); }
		public ParseContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_parse; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof HTMLAttributesListener ) ((HTMLAttributesListener)listener).enterParse(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof HTMLAttributesListener ) ((HTMLAttributesListener)listener).exitParse(this);
		}
	}

	public final ParseContext parse() throws RecognitionException {
		ParseContext _localctx = new ParseContext(_ctx, getState());
		enterRule(_localctx, 0, RULE_parse);
		int _la;
		try {
			setState(17);
			switch (_input.LA(1)) {
			case TAG_OPEN:
				enterOuterAlt(_localctx, 1);
				{
				setState(6); match(TAG_OPEN);
				setState(7); match(NAME);
				setState(11);
				_errHandler.sync(this);
				_la = _input.LA(1);
				while (_la==NAME) {
					{
					{
					setState(8); attribute();
					}
					}
					setState(13);
					_errHandler.sync(this);
					_la = _input.LA(1);
				}
				setState(14); match(TAG_CLOSE);
				if(true) throw new io.rivulet.internal.EndOfAttributeException();
				}
				break;
			case EOF:
				enterOuterAlt(_localctx, 2);
				{
				setState(16); match(EOF);
				}
				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 AttributeContext extends ParserRuleContext {
		public Token NAME;
		public ValueContext value;
		public ValueContext value() {
			return getRuleContext(ValueContext.class,0);
		}
		public TerminalNode NAME() { return getToken(HTMLAttributesParser.NAME, 0); }
		public AttributeContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_attribute; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof HTMLAttributesListener ) ((HTMLAttributesListener)listener).enterAttribute(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof HTMLAttributesListener ) ((HTMLAttributesListener)listener).exitAttribute(this);
		}
	}

	public final AttributeContext attribute() throws RecognitionException {
		AttributeContext _localctx = new AttributeContext(_ctx, getState());
		enterRule(_localctx, 2, RULE_attribute);
		try {
			setState(26);
			switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) {
			case 1:
				enterOuterAlt(_localctx, 1);
				{
				setState(19); ((AttributeContext)_localctx).NAME = match(NAME);
				setState(20); match(1);
				setState(21); ((AttributeContext)_localctx).value = value();
				attributes.add(new String[]{(((AttributeContext)_localctx).NAME!=null?((AttributeContext)_localctx).NAME.getText():null), (((AttributeContext)_localctx).value!=null?_input.getText(((AttributeContext)_localctx).value.start,((AttributeContext)_localctx).value.stop):null)});
				}
				break;

			case 2:
				enterOuterAlt(_localctx, 2);
				{
				setState(24); ((AttributeContext)_localctx).NAME = match(NAME);
				attributes.add(new String[]{(((AttributeContext)_localctx).NAME!=null?((AttributeContext)_localctx).NAME.getText():null), null});
				}
				break;
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class ValueContext extends ParserRuleContext {
		public TerminalNode VALUE() { return getToken(HTMLAttributesParser.VALUE, 0); }
		public TerminalNode NAME() { return getToken(HTMLAttributesParser.NAME, 0); }
		public ValueContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_value; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof HTMLAttributesListener ) ((HTMLAttributesListener)listener).enterValue(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof HTMLAttributesListener ) ((HTMLAttributesListener)listener).exitValue(this);
		}
	}

	public final ValueContext value() throws RecognitionException {
		ValueContext _localctx = new ValueContext(_ctx, getState());
		enterRule(_localctx, 4, RULE_value);
		int _la;
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(28);
			_la = _input.LA(1);
			if ( !(_la==NAME || _la==VALUE) ) {
			_errHandler.recoverInline(this);
			}
			consume();
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static final String _serializedATN =
		"\2\3\t!\4\2\t\2\4\3\t\3\4\4\t\4\3\2\3\2\3\2\7\2\f\n\2\f\2\16\2\17\13\2"+
		"\3\2\3\2\3\2\5\2\24\n\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\3\35\n\3\3\4\3\4"+
		"\3\4\2\5\2\4\6\2\3\3\6\7 \2\23\3\2\2\2\4\34\3\2\2\2\6\36\3\2\2\2\b\t\7"+
		"\4\2\2\t\r\7\6\2\2\n\f\5\4\3\2\13\n\3\2\2\2\f\17\3\2\2\2\r\13\3\2\2\2"+
		"\r\16\3\2\2\2\16\20\3\2\2\2\17\r\3\2\2\2\20\21\7\5\2\2\21\24\b\2\1\2\22"+
		"\24\7\1\2\2\23\b\3\2\2\2\23\22\3\2\2\2\24\3\3\2\2\2\25\26\7\6\2\2\26\27"+
		"\7\3\2\2\27\30\5\6\4\2\30\31\b\3\1\2\31\35\3\2\2\2\32\33\7\6\2\2\33\35"+
		"\b\3\1\2\34\25\3\2\2\2\34\32\3\2\2\2\35\5\3\2\2\2\36\37\t\2\2\2\37\7\3"+
		"\2\2\2\5\r\23\34";
	public static final ATN _ATN =
		ATNSimulator.deserialize(_serializedATN.toCharArray());
	static {
		_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy