diff --git a/core/src/main/grammar/crontab.g b/core/src/main/grammar/crontab.g index a972058d36a83bbfcdee4f17946cf51f02f68567..5dd7c69f1c6cf7c2d7a05d407dd1468e37e3c3a7 100644 --- a/core/src/main/grammar/crontab.g +++ b/core/src/main/grammar/crontab.g @@ -20,6 +20,34 @@ throws ANTLRException table.bits[3]=mnth; table.dayOfWeek=(int)dow; } + | "@yearly" + { + table.set("0 0 1 1 *"); + } + | "@annually" + { + table.set("0 0 1 1 *"); + } + | "@monthly" + { + table.set("0 0 1 * *"); + } + | "@weekly" + { + table.set("0 0 * * 0"); + } + | "@daily" + { + table.set("0 0 * * *"); + } + | "@midnight" + { + table.set("0 0 * * *"); + } + | "@hourly" + { + table.set("0 * * * *"); + } ; expr [int field] diff --git a/core/src/main/java/hudson/scheduler/CronTab.java b/core/src/main/java/hudson/scheduler/CronTab.java index 3ddd1edb78803955cd2615aac54f351f76b38a74..6eee0da5868264dd21ba7f871734c66c563f8cc7 100644 --- a/core/src/main/java/hudson/scheduler/CronTab.java +++ b/core/src/main/java/hudson/scheduler/CronTab.java @@ -28,6 +28,10 @@ public final class CronTab { } public CronTab(String format, int line) throws ANTLRException { + set(format, line); + } + + private void set(String format, int line) throws ANTLRException { CrontabLexer lexer = new CrontabLexer(new StringReader(format)); lexer.setLine(line); CrontabParser parser = new CrontabParser(lexer); @@ -56,6 +60,10 @@ public final class CronTab { return true; } + void set(String format) throws ANTLRException { + set(format,1); + } + /** * Returns true if n-th bit is on. */