提交 d2ea8392 编写于 作者: K kohsuke

Crontab grammar wasn't recognizing @xxxx (#1342)


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7655 71c3de6d-444a-0410-be80-ed276b4c234a
上级 107baac0
......@@ -20,34 +20,38 @@ 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 * * * *");
}
| ( AT
(
"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]
......@@ -93,6 +97,7 @@ returns [int value=0]
class CrontabLexer extends Lexer;
options {
k=2; // I'm sure there's a better way to do this than using lookahead. ANTLR sucks...
defaultErrorHandler=false;
}
......@@ -113,4 +118,13 @@ options {
MINUS: '-';
STAR: '*';
DIV: '/';
OR: ',';
\ No newline at end of file
OR: ',';
AT: '@';
YEARLY: "yearly";
ANNUALLY: "annually";
MONTHLY: "monthly";
WEEKLY: "weekly";
DAILY: "daily";
MIDNIGHT: "midnight";
HOURLY: "hourly";
package hudson.scheduler;
import antlr.ANTLRException;
import junit.framework.TestCase;
/**
* @author Kohsuke Kawaguchi
*/
public class CrontabTest {
public class CrontabTest extends TestCase {
public static void main(String[] args) throws ANTLRException {
for (String arg : args) {
CronTab ct = new CronTab(arg);
System.out.println(ct.toString());
}
}
public void test1() throws ANTLRException {
new CronTab("@yearly");
new CronTab("@weekly");
new CronTab("@midnight");
new CronTab("@monthyl");
new CronTab("0 0 * 1-10/3 *");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册