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

io.rivulet.BasicVBScriptParser Maven / Gradle / Ivy

The newest version!
// Generated from io/rivulet/BasicVBScript.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 BasicVBScriptParser extends Parser {
	protected static final DFA[] _decisionToDFA;
	protected static final PredictionContextCache _sharedContextCache =
		new PredictionContextCache();
	public static final int
		SINGLE_LINE_COMMENT=1, DOUBLE_QUOTE_STRING=2, REM=3, OTHER=4;
	public static final String[] tokenNames = {
		"", "SINGLE_LINE_COMMENT", "DOUBLE_QUOTE_STRING", "REM", "OTHER"
	};
	public static final int
		RULE_parse = 0, RULE_text = 1, RULE_commented = 2, RULE_quoted = 3, RULE_unquoted = 4;
	public static final String[] ruleNames = {
		"parse", "text", "commented", "quoted", "unquoted"
	};

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

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

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

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


	  private StringBuilder codeBuilder = new StringBuilder();
	  public LinkedList code = new LinkedList<>();
	  public LinkedList commented = new LinkedList<>();
	  public LinkedList quoted = new LinkedList<>();

	  private void resetBuilder() {
	    if(codeBuilder.length() != 0) {
	      code.add(codeBuilder.toString());
	      codeBuilder = new StringBuilder();
	    }
	  }

	public BasicVBScriptParser(TokenStream input) {
		super(input);
		_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
	}
	public static class ParseContext extends ParserRuleContext {
		public TextContext text() {
			return getRuleContext(TextContext.class,0);
		}
		public ParseContext parse() {
			return getRuleContext(ParseContext.class,0);
		}
		public TerminalNode EOF() { return getToken(BasicVBScriptParser.EOF, 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 BasicVBScriptListener ) ((BasicVBScriptListener)listener).enterParse(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof BasicVBScriptListener ) ((BasicVBScriptListener)listener).exitParse(this);
		}
	}

	public final ParseContext parse() throws RecognitionException {
		ParseContext _localctx = new ParseContext(_ctx, getState());
		enterRule(_localctx, 0, RULE_parse);
		try {
			setState(15);
			switch (_input.LA(1)) {
			case SINGLE_LINE_COMMENT:
			case DOUBLE_QUOTE_STRING:
			case OTHER:
				enterOuterAlt(_localctx, 1);
				{
				setState(10); text();
				setState(11); parse();
				}
				break;
			case EOF:
				enterOuterAlt(_localctx, 2);
				{
				setState(13); match(EOF);
				resetBuilder();
				}
				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 TextContext extends ParserRuleContext {
		public CommentedContext commented;
		public QuotedContext quoted;
		public UnquotedContext unquoted;
		public QuotedContext quoted() {
			return getRuleContext(QuotedContext.class,0);
		}
		public CommentedContext commented() {
			return getRuleContext(CommentedContext.class,0);
		}
		public UnquotedContext unquoted() {
			return getRuleContext(UnquotedContext.class,0);
		}
		public TextContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_text; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof BasicVBScriptListener ) ((BasicVBScriptListener)listener).enterText(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof BasicVBScriptListener ) ((BasicVBScriptListener)listener).exitText(this);
		}
	}

	public final TextContext text() throws RecognitionException {
		TextContext _localctx = new TextContext(_ctx, getState());
		enterRule(_localctx, 2, RULE_text);
		try {
			setState(26);
			switch (_input.LA(1)) {
			case SINGLE_LINE_COMMENT:
				enterOuterAlt(_localctx, 1);
				{
				setState(17); ((TextContext)_localctx).commented = commented();
				resetBuilder(); commented.add((((TextContext)_localctx).commented!=null?_input.getText(((TextContext)_localctx).commented.start,((TextContext)_localctx).commented.stop):null));
				}
				break;
			case DOUBLE_QUOTE_STRING:
				enterOuterAlt(_localctx, 2);
				{
				setState(20); ((TextContext)_localctx).quoted = quoted();
				resetBuilder(); quoted.add((((TextContext)_localctx).quoted!=null?_input.getText(((TextContext)_localctx).quoted.start,((TextContext)_localctx).quoted.stop):null));
				}
				break;
			case OTHER:
				enterOuterAlt(_localctx, 3);
				{
				setState(23); ((TextContext)_localctx).unquoted = unquoted();
				codeBuilder.append((((TextContext)_localctx).unquoted!=null?_input.getText(((TextContext)_localctx).unquoted.start,((TextContext)_localctx).unquoted.stop):null));
				}
				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 CommentedContext extends ParserRuleContext {
		public TerminalNode SINGLE_LINE_COMMENT() { return getToken(BasicVBScriptParser.SINGLE_LINE_COMMENT, 0); }
		public CommentedContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_commented; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof BasicVBScriptListener ) ((BasicVBScriptListener)listener).enterCommented(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof BasicVBScriptListener ) ((BasicVBScriptListener)listener).exitCommented(this);
		}
	}

	public final CommentedContext commented() throws RecognitionException {
		CommentedContext _localctx = new CommentedContext(_ctx, getState());
		enterRule(_localctx, 4, RULE_commented);
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(28); match(SINGLE_LINE_COMMENT);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class QuotedContext extends ParserRuleContext {
		public TerminalNode DOUBLE_QUOTE_STRING() { return getToken(BasicVBScriptParser.DOUBLE_QUOTE_STRING, 0); }
		public QuotedContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_quoted; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof BasicVBScriptListener ) ((BasicVBScriptListener)listener).enterQuoted(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof BasicVBScriptListener ) ((BasicVBScriptListener)listener).exitQuoted(this);
		}
	}

	public final QuotedContext quoted() throws RecognitionException {
		QuotedContext _localctx = new QuotedContext(_ctx, getState());
		enterRule(_localctx, 6, RULE_quoted);
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(30); match(DOUBLE_QUOTE_STRING);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class UnquotedContext extends ParserRuleContext {
		public TerminalNode OTHER() { return getToken(BasicVBScriptParser.OTHER, 0); }
		public UnquotedContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_unquoted; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof BasicVBScriptListener ) ((BasicVBScriptListener)listener).enterUnquoted(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof BasicVBScriptListener ) ((BasicVBScriptListener)listener).exitUnquoted(this);
		}
	}

	public final UnquotedContext unquoted() throws RecognitionException {
		UnquotedContext _localctx = new UnquotedContext(_ctx, getState());
		enterRule(_localctx, 8, RULE_unquoted);
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(32); match(OTHER);
			}
		}
		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\6%\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\3\2\3\2\3\2\3\2\3\2\5"+
		"\2\22\n\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\3\35\n\3\3\4\3\4\3\5\3"+
		"\5\3\6\3\6\3\6\2\7\2\4\6\b\n\2\2\"\2\21\3\2\2\2\4\34\3\2\2\2\6\36\3\2"+
		"\2\2\b \3\2\2\2\n\"\3\2\2\2\f\r\5\4\3\2\r\16\5\2\2\2\16\22\3\2\2\2\17"+
		"\20\7\1\2\2\20\22\b\2\1\2\21\f\3\2\2\2\21\17\3\2\2\2\22\3\3\2\2\2\23\24"+
		"\5\6\4\2\24\25\b\3\1\2\25\35\3\2\2\2\26\27\5\b\5\2\27\30\b\3\1\2\30\35"+
		"\3\2\2\2\31\32\5\n\6\2\32\33\b\3\1\2\33\35\3\2\2\2\34\23\3\2\2\2\34\26"+
		"\3\2\2\2\34\31\3\2\2\2\35\5\3\2\2\2\36\37\7\3\2\2\37\7\3\2\2\2 !\7\4\2"+
		"\2!\t\3\2\2\2\"#\7\6\2\2#\13\3\2\2\2\4\21\34";
	public static final ATN _ATN =
		ATNSimulator.deserialize(_serializedATN.toCharArray());
	static {
		_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy