
hudson.scheduler.CrontabParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hudson-core Show documentation
Show all versions of hudson-core Show documentation
Contains the core Hudson code and view files to render HTML.
The newest version!
// $ANTLR 3.4 hudson/scheduler/Crontab.g 2016-02-08 18:44:26
package hudson.scheduler;
import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
@SuppressWarnings({"all", "warnings", "unchecked"})
public class CrontabParser extends BaseParser {
public static final String[] tokenNames = new String[] {
"", "", "", "", "ANNUALLY", "AT", "DAILY", "DIV", "HOURLY", "MIDNIGHT", "MINUS", "MONTHLY", "OR", "STAR", "TOKEN", "WEEKLY", "WS", "YEARLY"
};
public static final int EOF=-1;
public static final int ANNUALLY=4;
public static final int AT=5;
public static final int DAILY=6;
public static final int DIV=7;
public static final int HOURLY=8;
public static final int MIDNIGHT=9;
public static final int MINUS=10;
public static final int MONTHLY=11;
public static final int OR=12;
public static final int STAR=13;
public static final int TOKEN=14;
public static final int WEEKLY=15;
public static final int WS=16;
public static final int YEARLY=17;
// delegates
public BaseParser[] getDelegates() {
return new BaseParser[] {};
}
// delegators
public CrontabParser(TokenStream input) {
this(input, new RecognizerSharedState());
}
public CrontabParser(TokenStream input, RecognizerSharedState state) {
super(input, state);
}
public String[] getTokenNames() { return CrontabParser.tokenNames; }
public String getGrammarFileName() { return "hudson/scheduler/Crontab.g"; }
// $ANTLR start "startRule"
// hudson/scheduler/Crontab.g:18:1: startRule[CronTab table] : (m= expr[0] WS h= expr[1] WS d= expr[2] WS mnth= expr[3] WS dow= expr[4] EOF | ( AT ( YEARLY | ANNUALLY | MONTHLY | WEEKLY | DAILY | MIDNIGHT | HOURLY ) ) );
public final void startRule(CronTab table) throws RecognitionException {
long m =0;
long h =0;
long d =0;
long mnth =0;
long dow =0;
try {
// hudson/scheduler/Crontab.g:19:3: (m= expr[0] WS h= expr[1] WS d= expr[2] WS mnth= expr[3] WS dow= expr[4] EOF | ( AT ( YEARLY | ANNUALLY | MONTHLY | WEEKLY | DAILY | MIDNIGHT | HOURLY ) ) )
int alt2=2;
switch ( input.LA(1) ) {
case STAR:
case TOKEN:
{
alt2=1;
}
break;
case AT:
{
alt2=2;
}
break;
default:
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 2, 0, input);
throw nvae;
}
switch (alt2) {
case 1 :
// hudson/scheduler/Crontab.g:19:5: m= expr[0] WS h= expr[1] WS d= expr[2] WS mnth= expr[3] WS dow= expr[4] EOF
{
pushFollow(FOLLOW_expr_in_startRule65);
m=expr(0);
state._fsp--;
if (state.failed) return ;
match(input,WS,FOLLOW_WS_in_startRule68); if (state.failed) return ;
pushFollow(FOLLOW_expr_in_startRule72);
h=expr(1);
state._fsp--;
if (state.failed) return ;
match(input,WS,FOLLOW_WS_in_startRule75); if (state.failed) return ;
pushFollow(FOLLOW_expr_in_startRule79);
d=expr(2);
state._fsp--;
if (state.failed) return ;
match(input,WS,FOLLOW_WS_in_startRule82); if (state.failed) return ;
pushFollow(FOLLOW_expr_in_startRule86);
mnth=expr(3);
state._fsp--;
if (state.failed) return ;
match(input,WS,FOLLOW_WS_in_startRule89); if (state.failed) return ;
pushFollow(FOLLOW_expr_in_startRule93);
dow=expr(4);
state._fsp--;
if (state.failed) return ;
match(input,EOF,FOLLOW_EOF_in_startRule96); if (state.failed) return ;
if ( state.backtracking==0 ) {
table.bits[0]=m;
table.bits[1]=h;
table.bits[2]=d;
table.bits[3]=mnth;
table.dayOfWeek=(int)dow;
}
}
break;
case 2 :
// hudson/scheduler/Crontab.g:27:5: ( AT ( YEARLY | ANNUALLY | MONTHLY | WEEKLY | DAILY | MIDNIGHT | HOURLY ) )
{
// hudson/scheduler/Crontab.g:27:5: ( AT ( YEARLY | ANNUALLY | MONTHLY | WEEKLY | DAILY | MIDNIGHT | HOURLY ) )
// hudson/scheduler/Crontab.g:27:7: AT ( YEARLY | ANNUALLY | MONTHLY | WEEKLY | DAILY | MIDNIGHT | HOURLY )
{
match(input,AT,FOLLOW_AT_in_startRule108); if (state.failed) return ;
// hudson/scheduler/Crontab.g:28:7: ( YEARLY | ANNUALLY | MONTHLY | WEEKLY | DAILY | MIDNIGHT | HOURLY )
int alt1=7;
switch ( input.LA(1) ) {
case YEARLY:
{
alt1=1;
}
break;
case ANNUALLY:
{
alt1=2;
}
break;
case MONTHLY:
{
alt1=3;
}
break;
case WEEKLY:
{
alt1=4;
}
break;
case DAILY:
{
alt1=5;
}
break;
case MIDNIGHT:
{
alt1=6;
}
break;
case HOURLY:
{
alt1=7;
}
break;
default:
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 1, 0, input);
throw nvae;
}
switch (alt1) {
case 1 :
// hudson/scheduler/Crontab.g:29:9: YEARLY
{
match(input,YEARLY,FOLLOW_YEARLY_in_startRule126); if (state.failed) return ;
if ( state.backtracking==0 ) {
table.set("0 0 1 1 *");
}
}
break;
case 2 :
// hudson/scheduler/Crontab.g:33:9: ANNUALLY
{
match(input,ANNUALLY,FOLLOW_ANNUALLY_in_startRule144); if (state.failed) return ;
if ( state.backtracking==0 ) {
table.set("0 0 1 1 *");
}
}
break;
case 3 :
// hudson/scheduler/Crontab.g:37:9: MONTHLY
{
match(input,MONTHLY,FOLLOW_MONTHLY_in_startRule162); if (state.failed) return ;
if ( state.backtracking==0 ) {
table.set("0 0 1 * *");
}
}
break;
case 4 :
// hudson/scheduler/Crontab.g:41:9: WEEKLY
{
match(input,WEEKLY,FOLLOW_WEEKLY_in_startRule180); if (state.failed) return ;
if ( state.backtracking==0 ) {
table.set("0 0 * * 0");
}
}
break;
case 5 :
// hudson/scheduler/Crontab.g:45:9: DAILY
{
match(input,DAILY,FOLLOW_DAILY_in_startRule198); if (state.failed) return ;
if ( state.backtracking==0 ) {
table.set("0 0 * * *");
}
}
break;
case 6 :
// hudson/scheduler/Crontab.g:49:9: MIDNIGHT
{
match(input,MIDNIGHT,FOLLOW_MIDNIGHT_in_startRule216); if (state.failed) return ;
if ( state.backtracking==0 ) {
table.set("0 0 * * *");
}
}
break;
case 7 :
// hudson/scheduler/Crontab.g:53:9: HOURLY
{
match(input,HOURLY,FOLLOW_HOURLY_in_startRule234); if (state.failed) return ;
if ( state.backtracking==0 ) {
table.set("0 * * * *");
}
}
break;
}
}
}
break;
}
}
finally {
// do for sure before leaving
}
return ;
}
// $ANTLR end "startRule"
// $ANTLR start "expr"
// hudson/scheduler/Crontab.g:61:1: expr[int field] returns [long bits=0] : lhs= term[field] ( ',' rhs= expr[field] )? ;
public final long expr(int field) throws RecognitionException {
long bits = 0;
long lhs =0;
long rhs =0;
try {
// hudson/scheduler/Crontab.g:62:3: (lhs= term[field] ( ',' rhs= expr[field] )? )
// hudson/scheduler/Crontab.g:62:5: lhs= term[field] ( ',' rhs= expr[field] )?
{
pushFollow(FOLLOW_term_in_expr277);
lhs=term(field);
state._fsp--;
if (state.failed) return bits;
// hudson/scheduler/Crontab.g:62:21: ( ',' rhs= expr[field] )?
int alt3=2;
switch ( input.LA(1) ) {
case OR:
{
alt3=1;
}
break;
}
switch (alt3) {
case 1 :
// hudson/scheduler/Crontab.g:62:22: ',' rhs= expr[field]
{
match(input,OR,FOLLOW_OR_in_expr281); if (state.failed) return bits;
pushFollow(FOLLOW_expr_in_expr285);
rhs=expr(field);
state._fsp--;
if (state.failed) return bits;
}
break;
}
if ( state.backtracking==0 ) {
bits = lhs|rhs;
}
}
}
finally {
// do for sure before leaving
}
return bits;
}
// $ANTLR end "expr"
// $ANTLR start "term"
// hudson/scheduler/Crontab.g:68:1: term[int field] returns [long bits=0] : ( ( token '-' )=>s= token '-' e= token ( '/' d= token )? |t= token | '*' ( '/' d= token )? );
public final long term(int field) throws RecognitionException {
long bits = 0;
int s =0;
int e =0;
int d =0;
int t =0;
d=1;
try {
// hudson/scheduler/Crontab.g:72:3: ( ( token '-' )=>s= token '-' e= token ( '/' d= token )? |t= token | '*' ( '/' d= token )? )
int alt6=3;
switch ( input.LA(1) ) {
case TOKEN:
{
int LA6_1 = input.LA(2);
if ( (LA6_1==MINUS) && (synpred1_Crontab())) {
alt6=1;
}
else if ( (LA6_1==EOF||LA6_1==OR||LA6_1==WS) ) {
alt6=2;
}
else {
if (state.backtracking>0) {state.failed=true; return bits;}
NoViableAltException nvae =
new NoViableAltException("", 6, 1, input);
throw nvae;
}
}
break;
case STAR:
{
alt6=3;
}
break;
default:
if (state.backtracking>0) {state.failed=true; return bits;}
NoViableAltException nvae =
new NoViableAltException("", 6, 0, input);
throw nvae;
}
switch (alt6) {
case 1 :
// hudson/scheduler/Crontab.g:72:5: ( token '-' )=>s= token '-' e= token ( '/' d= token )?
{
pushFollow(FOLLOW_token_in_term329);
s=token();
state._fsp--;
if (state.failed) return bits;
match(input,MINUS,FOLLOW_MINUS_in_term331); if (state.failed) return bits;
pushFollow(FOLLOW_token_in_term335);
e=token();
state._fsp--;
if (state.failed) return bits;
// hudson/scheduler/Crontab.g:72:39: ( '/' d= token )?
int alt4=2;
switch ( input.LA(1) ) {
case DIV:
{
alt4=1;
}
break;
}
switch (alt4) {
case 1 :
// hudson/scheduler/Crontab.g:72:41: '/' d= token
{
match(input,DIV,FOLLOW_DIV_in_term339); if (state.failed) return bits;
pushFollow(FOLLOW_token_in_term343);
d=token();
state._fsp--;
if (state.failed) return bits;
}
break;
}
if ( state.backtracking==0 ) {
bits = doRange(s,e,d,field);
}
}
break;
case 2 :
// hudson/scheduler/Crontab.g:76:5: t= token
{
pushFollow(FOLLOW_token_in_term358);
t=token();
state._fsp--;
if (state.failed) return bits;
if ( state.backtracking==0 ) {
rangeCheck(t,field);
bits = 1L<
© 2015 - 2025 Weber Informatics LLC | Privacy Policy