| // Generated from Json.g4 by ANTLR 4.5.3 |
| |
| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| package org.netbeans.modules.javascript2.json.parser; |
| |
| 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 JsonParser extends Parser { |
| static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); } |
| |
| protected static final DFA[] _decisionToDFA; |
| protected static final PredictionContextCache _sharedContextCache = |
| new PredictionContextCache(); |
| public static final int |
| COLON=1, COMMA=2, DOT=3, PLUS=4, MINUS=5, LBRACE=6, RBRACE=7, LBRACKET=8, |
| RBRACKET=9, TRUE=10, FALSE=11, NULL=12, NUMBER=13, STRING=14, LINE_COMMENT=15, |
| COMMENT=16, WS=17, ERROR_COMMENT=18, ERROR=19; |
| public static final int |
| RULE_json = 0, RULE_value = 1, RULE_object = 2, RULE_pair = 3, RULE_key = 4, |
| RULE_array = 5; |
| public static final String[] ruleNames = { |
| "json", "value", "object", "pair", "key", "array" |
| }; |
| |
| private static final String[] _LITERAL_NAMES = { |
| null, "':'", "','", "'.'", "'+'", "'-'", "'{'", "'}'", "'['", "']'", "'true'", |
| "'false'", "'null'" |
| }; |
| private static final String[] _SYMBOLIC_NAMES = { |
| null, "COLON", "COMMA", "DOT", "PLUS", "MINUS", "LBRACE", "RBRACE", "LBRACKET", |
| "RBRACKET", "TRUE", "FALSE", "NULL", "NUMBER", "STRING", "LINE_COMMENT", |
| "COMMENT", "WS", "ERROR_COMMENT", "ERROR" |
| }; |
| 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 "Json.g4"; } |
| |
| @Override |
| public String[] getRuleNames() { return ruleNames; } |
| |
| @Override |
| public String getSerializedATN() { return _serializedATN; } |
| |
| @Override |
| public ATN getATN() { return _ATN; } |
| |
| public JsonParser(TokenStream input) { |
| super(input); |
| _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); |
| } |
| public static class JsonContext extends ParserRuleContext { |
| public TerminalNode EOF() { return getToken(JsonParser.EOF, 0); } |
| public ValueContext value() { |
| return getRuleContext(ValueContext.class,0); |
| } |
| public JsonContext(ParserRuleContext parent, int invokingState) { |
| super(parent, invokingState); |
| } |
| @Override public int getRuleIndex() { return RULE_json; } |
| @Override |
| public void enterRule(ParseTreeListener listener) { |
| if ( listener instanceof JsonListener ) ((JsonListener)listener).enterJson(this); |
| } |
| @Override |
| public void exitRule(ParseTreeListener listener) { |
| if ( listener instanceof JsonListener ) ((JsonListener)listener).exitJson(this); |
| } |
| @Override |
| public <T> T accept(ParseTreeVisitor<? extends T> visitor) { |
| if ( visitor instanceof JsonVisitor ) return ((JsonVisitor<? extends T>)visitor).visitJson(this); |
| else return visitor.visitChildren(this); |
| } |
| } |
| |
| public final JsonContext json() throws RecognitionException { |
| JsonContext _localctx = new JsonContext(_ctx, getState()); |
| enterRule(_localctx, 0, RULE_json); |
| int _la; |
| try { |
| enterOuterAlt(_localctx, 1); |
| { |
| setState(13); |
| _la = _input.LA(1); |
| if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << LBRACE) | (1L << LBRACKET) | (1L << TRUE) | (1L << FALSE) | (1L << NULL) | (1L << NUMBER) | (1L << STRING))) != 0)) { |
| { |
| setState(12); |
| value(); |
| } |
| } |
| |
| setState(15); |
| match(EOF); |
| } |
| } |
| 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(JsonParser.STRING, 0); } |
| public TerminalNode NUMBER() { return getToken(JsonParser.NUMBER, 0); } |
| public TerminalNode TRUE() { return getToken(JsonParser.TRUE, 0); } |
| public TerminalNode FALSE() { return getToken(JsonParser.FALSE, 0); } |
| public TerminalNode NULL() { return getToken(JsonParser.NULL, 0); } |
| public ArrayContext array() { |
| return getRuleContext(ArrayContext.class,0); |
| } |
| public ObjectContext object() { |
| return getRuleContext(ObjectContext.class,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 JsonListener ) ((JsonListener)listener).enterValue(this); |
| } |
| @Override |
| public void exitRule(ParseTreeListener listener) { |
| if ( listener instanceof JsonListener ) ((JsonListener)listener).exitValue(this); |
| } |
| @Override |
| public <T> T accept(ParseTreeVisitor<? extends T> visitor) { |
| if ( visitor instanceof JsonVisitor ) return ((JsonVisitor<? extends T>)visitor).visitValue(this); |
| else return visitor.visitChildren(this); |
| } |
| } |
| |
| public final ValueContext value() throws RecognitionException { |
| ValueContext _localctx = new ValueContext(_ctx, getState()); |
| enterRule(_localctx, 2, RULE_value); |
| try { |
| enterOuterAlt(_localctx, 1); |
| { |
| setState(24); |
| switch (_input.LA(1)) { |
| case STRING: |
| { |
| setState(17); |
| match(STRING); |
| } |
| break; |
| case NUMBER: |
| { |
| setState(18); |
| match(NUMBER); |
| } |
| break; |
| case TRUE: |
| { |
| setState(19); |
| match(TRUE); |
| } |
| break; |
| case FALSE: |
| { |
| setState(20); |
| match(FALSE); |
| } |
| break; |
| case NULL: |
| { |
| setState(21); |
| match(NULL); |
| } |
| break; |
| case LBRACKET: |
| { |
| setState(22); |
| array(); |
| } |
| break; |
| case LBRACE: |
| { |
| setState(23); |
| object(); |
| } |
| 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 ObjectContext extends ParserRuleContext { |
| public TerminalNode LBRACE() { return getToken(JsonParser.LBRACE, 0); } |
| public TerminalNode RBRACE() { return getToken(JsonParser.RBRACE, 0); } |
| public List<PairContext> pair() { |
| return getRuleContexts(PairContext.class); |
| } |
| public PairContext pair(int i) { |
| return getRuleContext(PairContext.class,i); |
| } |
| public List<TerminalNode> COMMA() { return getTokens(JsonParser.COMMA); } |
| public TerminalNode COMMA(int i) { |
| return getToken(JsonParser.COMMA, i); |
| } |
| public ObjectContext(ParserRuleContext parent, int invokingState) { |
| super(parent, invokingState); |
| } |
| @Override public int getRuleIndex() { return RULE_object; } |
| @Override |
| public void enterRule(ParseTreeListener listener) { |
| if ( listener instanceof JsonListener ) ((JsonListener)listener).enterObject(this); |
| } |
| @Override |
| public void exitRule(ParseTreeListener listener) { |
| if ( listener instanceof JsonListener ) ((JsonListener)listener).exitObject(this); |
| } |
| @Override |
| public <T> T accept(ParseTreeVisitor<? extends T> visitor) { |
| if ( visitor instanceof JsonVisitor ) return ((JsonVisitor<? extends T>)visitor).visitObject(this); |
| else return visitor.visitChildren(this); |
| } |
| } |
| |
| public final ObjectContext object() throws RecognitionException { |
| ObjectContext _localctx = new ObjectContext(_ctx, getState()); |
| enterRule(_localctx, 4, RULE_object); |
| int _la; |
| try { |
| enterOuterAlt(_localctx, 1); |
| { |
| setState(26); |
| match(LBRACE); |
| setState(35); |
| _la = _input.LA(1); |
| if (_la==STRING) { |
| { |
| setState(27); |
| pair(); |
| setState(32); |
| _errHandler.sync(this); |
| _la = _input.LA(1); |
| while (_la==COMMA) { |
| { |
| { |
| setState(28); |
| match(COMMA); |
| setState(29); |
| pair(); |
| } |
| } |
| setState(34); |
| _errHandler.sync(this); |
| _la = _input.LA(1); |
| } |
| } |
| } |
| |
| setState(37); |
| match(RBRACE); |
| } |
| } |
| 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 TerminalNode COLON() { return getToken(JsonParser.COLON, 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 JsonListener ) ((JsonListener)listener).enterPair(this); |
| } |
| @Override |
| public void exitRule(ParseTreeListener listener) { |
| if ( listener instanceof JsonListener ) ((JsonListener)listener).exitPair(this); |
| } |
| @Override |
| public <T> T accept(ParseTreeVisitor<? extends T> visitor) { |
| if ( visitor instanceof JsonVisitor ) return ((JsonVisitor<? extends T>)visitor).visitPair(this); |
| else return visitor.visitChildren(this); |
| } |
| } |
| |
| public final PairContext pair() throws RecognitionException { |
| PairContext _localctx = new PairContext(_ctx, getState()); |
| enterRule(_localctx, 6, RULE_pair); |
| try { |
| enterOuterAlt(_localctx, 1); |
| { |
| setState(39); |
| key(); |
| setState(40); |
| match(COLON); |
| setState(41); |
| 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(JsonParser.STRING, 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 JsonListener ) ((JsonListener)listener).enterKey(this); |
| } |
| @Override |
| public void exitRule(ParseTreeListener listener) { |
| if ( listener instanceof JsonListener ) ((JsonListener)listener).exitKey(this); |
| } |
| @Override |
| public <T> T accept(ParseTreeVisitor<? extends T> visitor) { |
| if ( visitor instanceof JsonVisitor ) return ((JsonVisitor<? extends T>)visitor).visitKey(this); |
| else return visitor.visitChildren(this); |
| } |
| } |
| |
| public final KeyContext key() throws RecognitionException { |
| KeyContext _localctx = new KeyContext(_ctx, getState()); |
| enterRule(_localctx, 8, RULE_key); |
| try { |
| enterOuterAlt(_localctx, 1); |
| { |
| setState(43); |
| match(STRING); |
| } |
| } |
| catch (RecognitionException re) { |
| _localctx.exception = re; |
| _errHandler.reportError(this, re); |
| _errHandler.recover(this, re); |
| } |
| finally { |
| exitRule(); |
| } |
| return _localctx; |
| } |
| |
| public static class ArrayContext extends ParserRuleContext { |
| public TerminalNode LBRACKET() { return getToken(JsonParser.LBRACKET, 0); } |
| public TerminalNode RBRACKET() { return getToken(JsonParser.RBRACKET, 0); } |
| public List<ValueContext> value() { |
| return getRuleContexts(ValueContext.class); |
| } |
| public ValueContext value(int i) { |
| return getRuleContext(ValueContext.class,i); |
| } |
| public List<TerminalNode> COMMA() { return getTokens(JsonParser.COMMA); } |
| public TerminalNode COMMA(int i) { |
| return getToken(JsonParser.COMMA, i); |
| } |
| public ArrayContext(ParserRuleContext parent, int invokingState) { |
| super(parent, invokingState); |
| } |
| @Override public int getRuleIndex() { return RULE_array; } |
| @Override |
| public void enterRule(ParseTreeListener listener) { |
| if ( listener instanceof JsonListener ) ((JsonListener)listener).enterArray(this); |
| } |
| @Override |
| public void exitRule(ParseTreeListener listener) { |
| if ( listener instanceof JsonListener ) ((JsonListener)listener).exitArray(this); |
| } |
| @Override |
| public <T> T accept(ParseTreeVisitor<? extends T> visitor) { |
| if ( visitor instanceof JsonVisitor ) return ((JsonVisitor<? extends T>)visitor).visitArray(this); |
| else return visitor.visitChildren(this); |
| } |
| } |
| |
| public final ArrayContext array() throws RecognitionException { |
| ArrayContext _localctx = new ArrayContext(_ctx, getState()); |
| enterRule(_localctx, 10, RULE_array); |
| int _la; |
| try { |
| enterOuterAlt(_localctx, 1); |
| { |
| setState(45); |
| match(LBRACKET); |
| setState(54); |
| _la = _input.LA(1); |
| if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << LBRACE) | (1L << LBRACKET) | (1L << TRUE) | (1L << FALSE) | (1L << NULL) | (1L << NUMBER) | (1L << STRING))) != 0)) { |
| { |
| setState(46); |
| value(); |
| setState(51); |
| _errHandler.sync(this); |
| _la = _input.LA(1); |
| while (_la==COMMA) { |
| { |
| { |
| setState(47); |
| match(COMMA); |
| setState(48); |
| value(); |
| } |
| } |
| setState(53); |
| _errHandler.sync(this); |
| _la = _input.LA(1); |
| } |
| } |
| } |
| |
| setState(56); |
| match(RBRACKET); |
| } |
| } |
| catch (RecognitionException re) { |
| _localctx.exception = re; |
| _errHandler.reportError(this, re); |
| _errHandler.recover(this, re); |
| } |
| finally { |
| exitRule(); |
| } |
| return _localctx; |
| } |
| |
| public static final String _serializedATN = |
| "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\25=\4\2\t\2\4\3\t"+ |
| "\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\3\2\5\2\20\n\2\3\2\3\2\3\3\3\3\3\3"+ |
| "\3\3\3\3\3\3\3\3\5\3\33\n\3\3\4\3\4\3\4\3\4\7\4!\n\4\f\4\16\4$\13\4\5"+ |
| "\4&\n\4\3\4\3\4\3\5\3\5\3\5\3\5\3\6\3\6\3\7\3\7\3\7\3\7\7\7\64\n\7\f\7"+ |
| "\16\7\67\13\7\5\79\n\7\3\7\3\7\3\7\2\2\b\2\4\6\b\n\f\2\2A\2\17\3\2\2\2"+ |
| "\4\32\3\2\2\2\6\34\3\2\2\2\b)\3\2\2\2\n-\3\2\2\2\f/\3\2\2\2\16\20\5\4"+ |
| "\3\2\17\16\3\2\2\2\17\20\3\2\2\2\20\21\3\2\2\2\21\22\7\2\2\3\22\3\3\2"+ |
| "\2\2\23\33\7\20\2\2\24\33\7\17\2\2\25\33\7\f\2\2\26\33\7\r\2\2\27\33\7"+ |
| "\16\2\2\30\33\5\f\7\2\31\33\5\6\4\2\32\23\3\2\2\2\32\24\3\2\2\2\32\25"+ |
| "\3\2\2\2\32\26\3\2\2\2\32\27\3\2\2\2\32\30\3\2\2\2\32\31\3\2\2\2\33\5"+ |
| "\3\2\2\2\34%\7\b\2\2\35\"\5\b\5\2\36\37\7\4\2\2\37!\5\b\5\2 \36\3\2\2"+ |
| "\2!$\3\2\2\2\" \3\2\2\2\"#\3\2\2\2#&\3\2\2\2$\"\3\2\2\2%\35\3\2\2\2%&"+ |
| "\3\2\2\2&\'\3\2\2\2\'(\7\t\2\2(\7\3\2\2\2)*\5\n\6\2*+\7\3\2\2+,\5\4\3"+ |
| "\2,\t\3\2\2\2-.\7\20\2\2.\13\3\2\2\2/8\7\n\2\2\60\65\5\4\3\2\61\62\7\4"+ |
| "\2\2\62\64\5\4\3\2\63\61\3\2\2\2\64\67\3\2\2\2\65\63\3\2\2\2\65\66\3\2"+ |
| "\2\2\669\3\2\2\2\67\65\3\2\2\28\60\3\2\2\289\3\2\2\29:\3\2\2\2:;\7\13"+ |
| "\2\2;\r\3\2\2\2\b\17\32\"%\658"; |
| 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); |
| } |
| } |
| } |