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.
de.undercouch.citeproc.bibtex.internal.InternalPageParser Maven / Gradle / Ivy
// Generated from /Users/mkraemer/code/citeproc-java/citeproc-java/citeproc-java/grammars/InternalPage.g4 by ANTLR 4.12.0
package de.undercouch.citeproc.bibtex.internal;
import de.undercouch.citeproc.bibtex.PageRange;
import de.undercouch.citeproc.bibtex.PageRanges;
import org.apache.commons.lang3.StringUtils;
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", "CheckReturnValue"})
public class InternalPageParser extends Parser {
static { RuntimeMetaData.checkVersion("4.12.0", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
SPACE=1, COMMA=2, DASH=3, PAGE=4;
public static final int
RULE_pages = 0, RULE_range = 1;
private static String[] makeRuleNames() {
return new String[] {
"pages", "range"
};
}
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, "SPACE", "COMMA", "DASH", "PAGE"
};
}
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 "InternalPage.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public ATN getATN() { return _ATN; }
public InternalPageParser(TokenStream input) {
super(input);
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
@SuppressWarnings("CheckReturnValue")
public static class PagesContext extends ParserRuleContext {
public PageRanges ranges = new PageRanges();
public RangeContext r1;
public Token z1;
public Token z2;
public Token z3;
public RangeContext r2;
public List range() {
return getRuleContexts(RangeContext.class);
}
public RangeContext range(int i) {
return getRuleContext(RangeContext.class,i);
}
public List COMMA() { return getTokens(InternalPageParser.COMMA); }
public TerminalNode COMMA(int i) {
return getToken(InternalPageParser.COMMA, i);
}
public List SPACE() { return getTokens(InternalPageParser.SPACE); }
public TerminalNode SPACE(int i) {
return getToken(InternalPageParser.SPACE, i);
}
public PagesContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_pages; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof InternalPageListener ) ((InternalPageListener)listener).enterPages(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof InternalPageListener ) ((InternalPageListener)listener).exitPages(this);
}
}
public final PagesContext pages() throws RecognitionException {
PagesContext _localctx = new PagesContext(_ctx, getState());
enterRule(_localctx, 0, RULE_pages);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(4);
((PagesContext)_localctx).r1 = range();
String r1literal = ((PagesContext)_localctx).r1.literal;
if (r1literal == null) {
r1literal = (((PagesContext)_localctx).r1!=null?_input.getText(((PagesContext)_localctx).r1.start,((PagesContext)_localctx).r1.stop):null);
}
_localctx.ranges.add(new PageRange(r1literal, ((PagesContext)_localctx).r1.pageFrom, ((PagesContext)_localctx).r1.pageTo, ((PagesContext)_localctx).r1.numberOfPages, ((PagesContext)_localctx).r1.multiplePages));
setState(24);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==SPACE || _la==COMMA) {
{
{
setState(9);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==SPACE) {
{
{
setState(6);
((PagesContext)_localctx).z1 = match(SPACE);
}
}
setState(11);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(12);
((PagesContext)_localctx).z2 = match(COMMA);
setState(16);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==SPACE) {
{
{
setState(13);
((PagesContext)_localctx).z3 = match(SPACE);
}
}
setState(18);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(19);
((PagesContext)_localctx).r2 = range();
String r2literal = ((PagesContext)_localctx).r2.literal;
if (r2literal == null) {
r2literal = (((PagesContext)_localctx).r2!=null?_input.getText(((PagesContext)_localctx).r2.start,((PagesContext)_localctx).r2.stop):null);
}
_localctx.ranges.add(new PageRange(r2literal, ((PagesContext)_localctx).r2.pageFrom, ((PagesContext)_localctx).r2.pageTo, ((PagesContext)_localctx).r2.numberOfPages, ((PagesContext)_localctx).r2.multiplePages));
}
}
setState(26);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
@SuppressWarnings("CheckReturnValue")
public static class RangeContext extends ParserRuleContext {
public String literal;
public String pageFrom;
public String pageTo;
public Integer numberOfPages;
public boolean multiplePages = false;
public Token PAGE;
public Token p1;
public Token p2;
public List PAGE() { return getTokens(InternalPageParser.PAGE); }
public TerminalNode PAGE(int i) {
return getToken(InternalPageParser.PAGE, i);
}
public List SPACE() { return getTokens(InternalPageParser.SPACE); }
public TerminalNode SPACE(int i) {
return getToken(InternalPageParser.SPACE, i);
}
public List DASH() { return getTokens(InternalPageParser.DASH); }
public TerminalNode DASH(int i) {
return getToken(InternalPageParser.DASH, i);
}
public RangeContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_range; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof InternalPageListener ) ((InternalPageListener)listener).enterRange(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof InternalPageListener ) ((InternalPageListener)listener).exitRange(this);
}
}
public final RangeContext range() throws RecognitionException {
RangeContext _localctx = new RangeContext(_ctx, getState());
enterRule(_localctx, 2, RULE_range);
int _la;
try {
setState(49);
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
setState(27);
((RangeContext)_localctx).PAGE = match(PAGE);
((RangeContext)_localctx).pageFrom = _localctx.pageTo = (((RangeContext)_localctx).PAGE!=null?((RangeContext)_localctx).PAGE.getText():null);
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
setState(29);
((RangeContext)_localctx).p1 = match(PAGE);
setState(33);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==SPACE) {
{
{
setState(30);
match(SPACE);
}
}
setState(35);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(37);
_errHandler.sync(this);
_la = _input.LA(1);
do {
{
{
setState(36);
match(DASH);
}
}
setState(39);
_errHandler.sync(this);
_la = _input.LA(1);
} while ( _la==DASH );
setState(44);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==SPACE) {
{
{
setState(41);
match(SPACE);
}
}
setState(46);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(47);
((RangeContext)_localctx).p2 = match(PAGE);
((RangeContext)_localctx).pageFrom = (((RangeContext)_localctx).p1!=null?((RangeContext)_localctx).p1.getText():null); ((RangeContext)_localctx).pageTo = (((RangeContext)_localctx).p2!=null?((RangeContext)_localctx).p2.getText():null); ((RangeContext)_localctx).multiplePages = true;
}
break;
}
_ctx.stop = _input.LT(-1);
if (_localctx.pageFrom != null && _localctx.pageTo != null && StringUtils.isNumeric(_localctx.pageFrom) && StringUtils.isNumeric(_localctx.pageTo)) {
int pf = Integer.parseInt(_localctx.pageFrom);
int pt = Integer.parseInt(_localctx.pageTo);
((RangeContext)_localctx).numberOfPages = pt - pf + 1;
if (pf == pt) {
((RangeContext)_localctx).literal = String.valueOf(pf);
} else {
((RangeContext)_localctx).literal = pf + "-" + pt;
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static final String _serializedATN =
"\u0004\u0001\u00044\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0001"+
"\u0000\u0001\u0000\u0001\u0000\u0005\u0000\b\b\u0000\n\u0000\f\u0000\u000b"+
"\t\u0000\u0001\u0000\u0001\u0000\u0005\u0000\u000f\b\u0000\n\u0000\f\u0000"+
"\u0012\t\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0005\u0000\u0017\b"+
"\u0000\n\u0000\f\u0000\u001a\t\u0000\u0001\u0001\u0001\u0001\u0001\u0001"+
"\u0001\u0001\u0005\u0001 \b\u0001\n\u0001\f\u0001#\t\u0001\u0001\u0001"+
"\u0004\u0001&\b\u0001\u000b\u0001\f\u0001\'\u0001\u0001\u0005\u0001+\b"+
"\u0001\n\u0001\f\u0001.\t\u0001\u0001\u0001\u0001\u0001\u0003\u00012\b"+
"\u0001\u0001\u0001\u0000\u0000\u0002\u0000\u0002\u0000\u00008\u0000\u0004"+
"\u0001\u0000\u0000\u0000\u00021\u0001\u0000\u0000\u0000\u0004\u0005\u0003"+
"\u0002\u0001\u0000\u0005\u0018\u0006\u0000\uffff\uffff\u0000\u0006\b\u0005"+
"\u0001\u0000\u0000\u0007\u0006\u0001\u0000\u0000\u0000\b\u000b\u0001\u0000"+
"\u0000\u0000\t\u0007\u0001\u0000\u0000\u0000\t\n\u0001\u0000\u0000\u0000"+
"\n\f\u0001\u0000\u0000\u0000\u000b\t\u0001\u0000\u0000\u0000\f\u0010\u0005"+
"\u0002\u0000\u0000\r\u000f\u0005\u0001\u0000\u0000\u000e\r\u0001\u0000"+
"\u0000\u0000\u000f\u0012\u0001\u0000\u0000\u0000\u0010\u000e\u0001\u0000"+
"\u0000\u0000\u0010\u0011\u0001\u0000\u0000\u0000\u0011\u0013\u0001\u0000"+
"\u0000\u0000\u0012\u0010\u0001\u0000\u0000\u0000\u0013\u0014\u0003\u0002"+
"\u0001\u0000\u0014\u0015\u0006\u0000\uffff\uffff\u0000\u0015\u0017\u0001"+
"\u0000\u0000\u0000\u0016\t\u0001\u0000\u0000\u0000\u0017\u001a\u0001\u0000"+
"\u0000\u0000\u0018\u0016\u0001\u0000\u0000\u0000\u0018\u0019\u0001\u0000"+
"\u0000\u0000\u0019\u0001\u0001\u0000\u0000\u0000\u001a\u0018\u0001\u0000"+
"\u0000\u0000\u001b\u001c\u0005\u0004\u0000\u0000\u001c2\u0006\u0001\uffff"+
"\uffff\u0000\u001d!\u0005\u0004\u0000\u0000\u001e \u0005\u0001\u0000\u0000"+
"\u001f\u001e\u0001\u0000\u0000\u0000 #\u0001\u0000\u0000\u0000!\u001f"+
"\u0001\u0000\u0000\u0000!\"\u0001\u0000\u0000\u0000\"%\u0001\u0000\u0000"+
"\u0000#!\u0001\u0000\u0000\u0000$&\u0005\u0003\u0000\u0000%$\u0001\u0000"+
"\u0000\u0000&\'\u0001\u0000\u0000\u0000\'%\u0001\u0000\u0000\u0000\'("+
"\u0001\u0000\u0000\u0000(,\u0001\u0000\u0000\u0000)+\u0005\u0001\u0000"+
"\u0000*)\u0001\u0000\u0000\u0000+.\u0001\u0000\u0000\u0000,*\u0001\u0000"+
"\u0000\u0000,-\u0001\u0000\u0000\u0000-/\u0001\u0000\u0000\u0000.,\u0001"+
"\u0000\u0000\u0000/0\u0005\u0004\u0000\u000002\u0006\u0001\uffff\uffff"+
"\u00001\u001b\u0001\u0000\u0000\u00001\u001d\u0001\u0000\u0000\u00002"+
"\u0003\u0001\u0000\u0000\u0000\u0007\t\u0010\u0018!\',1";
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);
}
}
}