Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.reploop.parser.json.base.JSON5Parser Maven / Gradle / Ivy
// Generated from org/reploop/parser/json/base/JSON5.g4 by ANTLR 4.9.3
package org.reploop.parser.json.base;
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 JSON5Parser extends Parser {
static { RuntimeMetaData.checkVersion("4.9.3", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, SINGLE_LINE_COMMENT=7,
MULTI_LINE_COMMENT=8, LITERAL=9, STRING=10, NUMBER=11, NUMERIC_LITERAL=12,
SYMBOL=13, IDENTIFIER=14, WS=15;
public static final int
RULE_json5 = 0, RULE_obj = 1, RULE_pair = 2, RULE_key = 3, RULE_value = 4,
RULE_arr = 5, RULE_number = 6;
private static String[] makeRuleNames() {
return new String[] {
"json5", "obj", "pair", "key", "value", "arr", "number"
};
}
public static final String[] ruleNames = makeRuleNames();
private static String[] makeLiteralNames() {
return new String[] {
null, "'{'", "','", "'}'", "':'", "'['", "']'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, null, null, null, null, null, null, "SINGLE_LINE_COMMENT", "MULTI_LINE_COMMENT",
"LITERAL", "STRING", "NUMBER", "NUMERIC_LITERAL", "SYMBOL", "IDENTIFIER",
"WS"
};
}
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] = "";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
public Vocabulary getVocabulary() {
return VOCABULARY;
}
@Override
public String getGrammarFileName() { return "JSON5.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public ATN getATN() { return _ATN; }
public JSON5Parser(TokenStream input) {
super(input);
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
public static class Json5Context extends ParserRuleContext {
public TerminalNode EOF() { return getToken(JSON5Parser.EOF, 0); }
public ValueContext value() {
return getRuleContext(ValueContext.class,0);
}
public Json5Context(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_json5; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).enterJson5(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).exitJson5(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof JSON5Visitor ) return ((JSON5Visitor extends T>)visitor).visitJson5(this);
else return visitor.visitChildren(this);
}
}
public final Json5Context json5() throws RecognitionException {
Json5Context _localctx = new Json5Context(_ctx, getState());
enterRule(_localctx, 0, RULE_json5);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(15);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__4) | (1L << LITERAL) | (1L << STRING) | (1L << NUMBER) | (1L << NUMERIC_LITERAL) | (1L << SYMBOL))) != 0)) {
{
setState(14);
value();
}
}
setState(17);
match(EOF);
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class ObjContext extends ParserRuleContext {
public List pair() {
return getRuleContexts(PairContext.class);
}
public PairContext pair(int i) {
return getRuleContext(PairContext.class,i);
}
public ObjContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_obj; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).enterObj(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).exitObj(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof JSON5Visitor ) return ((JSON5Visitor extends T>)visitor).visitObj(this);
else return visitor.visitChildren(this);
}
}
public final ObjContext obj() throws RecognitionException {
ObjContext _localctx = new ObjContext(_ctx, getState());
enterRule(_localctx, 2, RULE_obj);
int _la;
try {
int _alt;
setState(35);
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
setState(19);
match(T__0);
setState(20);
pair();
setState(25);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,1,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(21);
match(T__1);
setState(22);
pair();
}
}
}
setState(27);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,1,_ctx);
}
setState(29);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==T__1) {
{
setState(28);
match(T__1);
}
}
setState(31);
match(T__2);
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
setState(33);
match(T__0);
setState(34);
match(T__2);
}
break;
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class PairContext extends ParserRuleContext {
public KeyContext key() {
return getRuleContext(KeyContext.class,0);
}
public ValueContext value() {
return getRuleContext(ValueContext.class,0);
}
public PairContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_pair; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).enterPair(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).exitPair(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof JSON5Visitor ) return ((JSON5Visitor extends T>)visitor).visitPair(this);
else return visitor.visitChildren(this);
}
}
public final PairContext pair() throws RecognitionException {
PairContext _localctx = new PairContext(_ctx, getState());
enterRule(_localctx, 4, RULE_pair);
try {
enterOuterAlt(_localctx, 1);
{
setState(37);
key();
setState(38);
match(T__3);
setState(39);
value();
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class KeyContext extends ParserRuleContext {
public TerminalNode STRING() { return getToken(JSON5Parser.STRING, 0); }
public TerminalNode IDENTIFIER() { return getToken(JSON5Parser.IDENTIFIER, 0); }
public TerminalNode LITERAL() { return getToken(JSON5Parser.LITERAL, 0); }
public TerminalNode NUMERIC_LITERAL() { return getToken(JSON5Parser.NUMERIC_LITERAL, 0); }
public KeyContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_key; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).enterKey(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).exitKey(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof JSON5Visitor ) return ((JSON5Visitor extends T>)visitor).visitKey(this);
else return visitor.visitChildren(this);
}
}
public final KeyContext key() throws RecognitionException {
KeyContext _localctx = new KeyContext(_ctx, getState());
enterRule(_localctx, 6, RULE_key);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(41);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << LITERAL) | (1L << STRING) | (1L << NUMERIC_LITERAL) | (1L << IDENTIFIER))) != 0)) ) {
_errHandler.recoverInline(this);
}
else {
if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
_errHandler.reportMatch(this);
consume();
}
}
}
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 STRING() { return getToken(JSON5Parser.STRING, 0); }
public NumberContext number() {
return getRuleContext(NumberContext.class,0);
}
public ObjContext obj() {
return getRuleContext(ObjContext.class,0);
}
public ArrContext arr() {
return getRuleContext(ArrContext.class,0);
}
public TerminalNode LITERAL() { return getToken(JSON5Parser.LITERAL, 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 JSON5Listener ) ((JSON5Listener)listener).enterValue(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).exitValue(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof JSON5Visitor ) return ((JSON5Visitor extends T>)visitor).visitValue(this);
else return visitor.visitChildren(this);
}
}
public final ValueContext value() throws RecognitionException {
ValueContext _localctx = new ValueContext(_ctx, getState());
enterRule(_localctx, 8, RULE_value);
try {
setState(48);
_errHandler.sync(this);
switch (_input.LA(1)) {
case STRING:
enterOuterAlt(_localctx, 1);
{
setState(43);
match(STRING);
}
break;
case NUMBER:
case NUMERIC_LITERAL:
case SYMBOL:
enterOuterAlt(_localctx, 2);
{
setState(44);
number();
}
break;
case T__0:
enterOuterAlt(_localctx, 3);
{
setState(45);
obj();
}
break;
case T__4:
enterOuterAlt(_localctx, 4);
{
setState(46);
arr();
}
break;
case LITERAL:
enterOuterAlt(_localctx, 5);
{
setState(47);
match(LITERAL);
}
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 ArrContext extends ParserRuleContext {
public List value() {
return getRuleContexts(ValueContext.class);
}
public ValueContext value(int i) {
return getRuleContext(ValueContext.class,i);
}
public ArrContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_arr; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).enterArr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).exitArr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof JSON5Visitor ) return ((JSON5Visitor extends T>)visitor).visitArr(this);
else return visitor.visitChildren(this);
}
}
public final ArrContext arr() throws RecognitionException {
ArrContext _localctx = new ArrContext(_ctx, getState());
enterRule(_localctx, 10, RULE_arr);
int _la;
try {
int _alt;
setState(66);
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,7,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
setState(50);
match(T__4);
setState(51);
value();
setState(56);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,5,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(52);
match(T__1);
setState(53);
value();
}
}
}
setState(58);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,5,_ctx);
}
setState(60);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==T__1) {
{
setState(59);
match(T__1);
}
}
setState(62);
match(T__5);
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
setState(64);
match(T__4);
setState(65);
match(T__5);
}
break;
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class NumberContext extends ParserRuleContext {
public TerminalNode NUMERIC_LITERAL() { return getToken(JSON5Parser.NUMERIC_LITERAL, 0); }
public TerminalNode NUMBER() { return getToken(JSON5Parser.NUMBER, 0); }
public TerminalNode SYMBOL() { return getToken(JSON5Parser.SYMBOL, 0); }
public NumberContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_number; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).enterNumber(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof JSON5Listener ) ((JSON5Listener)listener).exitNumber(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof JSON5Visitor ) return ((JSON5Visitor extends T>)visitor).visitNumber(this);
else return visitor.visitChildren(this);
}
}
public final NumberContext number() throws RecognitionException {
NumberContext _localctx = new NumberContext(_ctx, getState());
enterRule(_localctx, 12, RULE_number);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(69);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==SYMBOL) {
{
setState(68);
match(SYMBOL);
}
}
setState(71);
_la = _input.LA(1);
if ( !(_la==NUMBER || _la==NUMERIC_LITERAL) ) {
_errHandler.recoverInline(this);
}
else {
if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
_errHandler.reportMatch(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 =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\21L\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\3\2\5\2\22\n\2\3\2\3\2\3\3"+
"\3\3\3\3\3\3\7\3\32\n\3\f\3\16\3\35\13\3\3\3\5\3 \n\3\3\3\3\3\3\3\3\3"+
"\5\3&\n\3\3\4\3\4\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\6\3\6\5\6\63\n\6\3\7\3"+
"\7\3\7\3\7\7\79\n\7\f\7\16\7<\13\7\3\7\5\7?\n\7\3\7\3\7\3\7\3\7\5\7E\n"+
"\7\3\b\5\bH\n\b\3\b\3\b\3\b\2\2\t\2\4\6\b\n\f\16\2\4\5\2\13\f\16\16\20"+
"\20\3\2\r\16\2P\2\21\3\2\2\2\4%\3\2\2\2\6\'\3\2\2\2\b+\3\2\2\2\n\62\3"+
"\2\2\2\fD\3\2\2\2\16G\3\2\2\2\20\22\5\n\6\2\21\20\3\2\2\2\21\22\3\2\2"+
"\2\22\23\3\2\2\2\23\24\7\2\2\3\24\3\3\2\2\2\25\26\7\3\2\2\26\33\5\6\4"+
"\2\27\30\7\4\2\2\30\32\5\6\4\2\31\27\3\2\2\2\32\35\3\2\2\2\33\31\3\2\2"+
"\2\33\34\3\2\2\2\34\37\3\2\2\2\35\33\3\2\2\2\36 \7\4\2\2\37\36\3\2\2\2"+
"\37 \3\2\2\2 !\3\2\2\2!\"\7\5\2\2\"&\3\2\2\2#$\7\3\2\2$&\7\5\2\2%\25\3"+
"\2\2\2%#\3\2\2\2&\5\3\2\2\2\'(\5\b\5\2()\7\6\2\2)*\5\n\6\2*\7\3\2\2\2"+
"+,\t\2\2\2,\t\3\2\2\2-\63\7\f\2\2.\63\5\16\b\2/\63\5\4\3\2\60\63\5\f\7"+
"\2\61\63\7\13\2\2\62-\3\2\2\2\62.\3\2\2\2\62/\3\2\2\2\62\60\3\2\2\2\62"+
"\61\3\2\2\2\63\13\3\2\2\2\64\65\7\7\2\2\65:\5\n\6\2\66\67\7\4\2\2\679"+
"\5\n\6\28\66\3\2\2\29<\3\2\2\2:8\3\2\2\2:;\3\2\2\2;>\3\2\2\2<:\3\2\2\2"+
"=?\7\4\2\2>=\3\2\2\2>?\3\2\2\2?@\3\2\2\2@A\7\b\2\2AE\3\2\2\2BC\7\7\2\2"+
"CE\7\b\2\2D\64\3\2\2\2DB\3\2\2\2E\r\3\2\2\2FH\7\17\2\2GF\3\2\2\2GH\3\2"+
"\2\2HI\3\2\2\2IJ\t\3\2\2J\17\3\2\2\2\13\21\33\37%\62:>DG";
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);
}
}
}