aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Foster2012-06-15 17:00:09 (EDT)
committerBob Foster2012-06-15 17:00:09 (EDT)
commit5e612ba5152924e4b27741da4a9588eb858165f2 (patch)
tree398d460eebb7cbfcdbcfe221fb4fc0bfd7b5c27b
parenta6976ad5cd7f596915c710aae00ec37b9a64b555 (diff)
downloadorg.eclipse.hudson.core-5e612ba5152924e4b27741da4a9588eb858165f2.zip
org.eclipse.hudson.core-5e612ba5152924e4b27741da4a9588eb858165f2.tar.gz
org.eclipse.hudson.core-5e612ba5152924e4b27741da4a9588eb858165f2.tar.bz2
Switch to ANTLR 3.4 (remove ANTLR 2.7.7 dependency)refs/changes/79/6379/1
-rw-r--r--hudson-cli/pom.xml2
-rw-r--r--hudson-core/pom.xml45
-rw-r--r--hudson-core/src/main/antlr3/hudson/model/labels/LabelExpression.g88
-rw-r--r--hudson-core/src/main/antlr3/hudson/scheduler/Crontab.g114
-rw-r--r--hudson-core/src/main/grammar/crontab.g143
-rw-r--r--hudson-core/src/main/grammar/labelExpr.g105
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java4
-rw-r--r--hudson-core/src/main/java/hudson/model/AppointedNode.java4
-rw-r--r--hudson-core/src/main/java/hudson/model/Hudson.java6
-rw-r--r--hudson-core/src/main/java/hudson/model/Label.java11
-rw-r--r--hudson-core/src/main/java/hudson/scheduler/BaseParser.java85
-rw-r--r--hudson-core/src/main/java/hudson/scheduler/CronTab.java22
-rw-r--r--hudson-core/src/main/java/hudson/scheduler/CronTabList.java10
-rw-r--r--hudson-core/src/main/java/hudson/slaves/SimpleScheduledRetentionStrategy.java8
-rw-r--r--hudson-core/src/main/java/hudson/triggers/SCMTrigger.java4
-rw-r--r--hudson-core/src/main/java/hudson/triggers/TimerTrigger.java6
-rw-r--r--hudson-core/src/main/java/hudson/triggers/Trigger.java6
-rw-r--r--hudson-core/src/test/java/hudson/scheduler/CronTabTest.java4
-rw-r--r--hudson-core/src/test/java/hudson/triggers/TriggerEqualHashCodeTest.java6
-rw-r--r--hudson-core/src/test/java/hudson/util/CascadingTriggersTest.java1
-rw-r--r--hudson-core/src/test/java/org/eclipse/hudson/model/project/property/TriggerProjectPropertyTest.java14
-rw-r--r--hudson-inject/pom.xml2
-rw-r--r--hudson-utils/pom.xml2
-rw-r--r--pom.xml5
24 files changed, 334 insertions, 363 deletions
diff --git a/hudson-cli/pom.xml b/hudson-cli/pom.xml
index 760c50c..e86d06e 100644
--- a/hudson-cli/pom.xml
+++ b/hudson-cli/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.eclipse.hudson</groupId>
<artifactId>hudson-parent</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0-M2-1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hudson-cli</artifactId>
diff --git a/hudson-core/pom.xml b/hudson-core/pom.xml
index e1c91c4..bd7a3b4 100644
--- a/hudson-core/pom.xml
+++ b/hudson-core/pom.xml
@@ -93,31 +93,16 @@
</executions>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>antlr-maven-plugin</artifactId>
- <version>${antlr-maven-plugin.version}</version>
- <executions>
- <execution>
- <id>cron</id>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <sourceDirectory>${basedir}/src/main/grammar</sourceDirectory>
- <grammars>crontab.g</grammars>
- </configuration>
- </execution>
- <execution>
- <id>labelExpr</id>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <sourceDirectory>${basedir}/src/main/grammar</sourceDirectory>
- <grammars>labelExpr.g</grammars>
- </configuration>
- </execution>
- </executions>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr3-maven-plugin</artifactId>
+ <version>${antlr.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
<!--TODO Use the maven-dependency-plugin -->
<plugin>
@@ -721,9 +706,15 @@
<version>${jtidy.version}</version>
</dependency>
<dependency>
- <groupId>antlr</groupId>
- <artifactId>antlr</artifactId>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr-runtime</artifactId>
<version>${antlr.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>antlr</groupId>
+ <artifactId>antlr</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.hudson.stapler</groupId>
diff --git a/hudson-core/src/main/antlr3/hudson/model/labels/LabelExpression.g b/hudson-core/src/main/antlr3/hudson/model/labels/LabelExpression.g
new file mode 100644
index 0000000..9c1044a
--- /dev/null
+++ b/hudson-core/src/main/antlr3/hudson/model/labels/LabelExpression.g
@@ -0,0 +1,88 @@
+grammar LabelExpression;
+
+options { ASTLabelType=Label; }
+
+@rulecatch { }
+
+@header {
+ package hudson.model.labels;
+ import hudson.model.Label;
+}
+
+@lexer::header {
+ package hudson.model.labels;
+ import hudson.model.Label;
+}
+
+expr
+returns [Label l]
+ : t=term1 EOF { l = t; }
+ ;
+
+term1
+returns [Label l]
+ : t=term2 ( IFF r=term2 { t=t.iff(r); } )? { l=t; }
+ ;
+
+term2
+returns [Label l]
+ : t=term3 ( IMPLIES r=term3 {t=t.implies(r);} )? { l=t; }
+ ;
+
+term3
+returns [Label l]
+ : t=term4 ( OR r=term4 {l=t.or(r);} )? { l=t; }
+ ;
+
+term4
+returns [Label l]
+ : t=term5 ( AND r=term5 {t=t.and(r);} )? { l=t; }
+ ;
+
+term5
+returns [Label l]
+ : t=term6 { l=t; }
+ | NOT x=term6
+ { l=x.not(); }
+ ;
+
+term6
+returns [Label l]
+ : LPAREN t=term1 RPAREN
+ { l=t.paren(); }
+ | a=ATOM
+ { l=LabelAtom.get(a.getText()); }
+ | s=STRINGLITERAL
+ { l=LabelAtom.get(hudson.util.QuotedStringTokenizer.unquote(s.getText())); }
+ ;
+
+AND: '&&';
+OR: '||';
+NOT: '!';
+IMPLIES:'->';
+IFF: '<->';
+LPAREN: '(';
+RPAREN: ')';
+
+fragment
+IDENTIFIER_PART
+ : ~( '&' | '|' | '!' | '<' | '>' | '(' | ')' | ' ' | '\t' | '\"' | '\'' )
+ ;
+
+ATOM
+/* the real check of valid identifier happens in LabelAtom.get() */
+ : (IDENTIFIER_PART)+
+ ;
+
+WS
+ : (' '|'\t')+
+ { $channel=HIDDEN; }
+ ;
+
+STRINGLITERAL
+ : '"'
+ ( '\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\"' | '\'' | '\\' ) /* escape */
+ | ~( '\\' | '"' | '\r' | '\n' )
+ )*
+ '"'
+ ;
diff --git a/hudson-core/src/main/antlr3/hudson/scheduler/Crontab.g b/hudson-core/src/main/antlr3/hudson/scheduler/Crontab.g
new file mode 100644
index 0000000..25899a6
--- /dev/null
+++ b/hudson-core/src/main/antlr3/hudson/scheduler/Crontab.g
@@ -0,0 +1,114 @@
+grammar Crontab;
+
+options {
+ language = Java;
+ superClass = BaseParser;
+}
+
+@rulecatch { }
+
+@header {
+ package hudson.scheduler;
+}
+
+@lexer::header {
+ package hudson.scheduler;
+}
+
+startRule [CronTab table] throws RecognitionException
+ : m=expr[0] WS h=expr[1] WS d=expr[2] WS mnth=expr[3] WS dow=expr[4] EOF
+ {
+ table.bits[0]=m;
+ table.bits[1]=h;
+ table.bits[2]=d;
+ table.bits[3]=mnth;
+ table.dayOfWeek=(int)dow;
+ }
+ | ( 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] returns [long bits=0] throws RecognitionException
+ : lhs=term[field] (',' rhs=expr[field])?
+ {
+ bits = lhs|rhs;
+ }
+ ;
+
+term [int field] returns [long bits=0] throws RecognitionException
+@init {
+ d=1;
+}
+ : (token '-')=> s=token '-' e=token ( '/' d=token )?
+ {
+ bits = doRange(s,e,d,field);
+ }
+ | t=token
+ {
+ rangeCheck(t,field);
+ bits = 1L<<t;
+ }
+ | '*' ('/' d=token )?
+ {
+ bits = doRange(d,field);
+ }
+ ;
+
+token returns [int value=0]
+ : t=TOKEN
+ {
+ value = Integer.parseInt(t.getText());
+ }
+ ;
+
+TOKEN
+ : ('0'..'9')+
+ ;
+
+WS
+ : (' ' | '\t')+
+ ;
+
+MINUS: '-';
+STAR: '*';
+DIV: '/';
+OR: ',';
+AT: '@';
+
+YEARLY: 'yearly';
+ANNUALLY: 'annually';
+MONTHLY: 'monthly';
+WEEKLY: 'weekly';
+DAILY: 'daily';
+MIDNIGHT: 'midnight';
+HOURLY: 'hourly';
diff --git a/hudson-core/src/main/grammar/crontab.g b/hudson-core/src/main/grammar/crontab.g
deleted file mode 100644
index 7200bc7..0000000
--- a/hudson-core/src/main/grammar/crontab.g
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2004-2009 Oracle Corporation
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *
- * Kohsuke Kawaguchi
- *
- */
-header {
- package hudson.scheduler;
-}
-
-class CrontabParser extends Parser("BaseParser");
-options {
- defaultErrorHandler=false;
-}
-
-startRule [CronTab table]
-throws ANTLRException
-{
- long m,h,d,mnth,dow;
-}
- : m=expr[0] WS h=expr[1] WS d=expr[2] WS mnth=expr[3] WS dow=expr[4] EOF
- {
- table.bits[0]=m;
- table.bits[1]=h;
- table.bits[2]=d;
- table.bits[3]=mnth;
- table.dayOfWeek=(int)dow;
- }
- | ( 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]
-returns [long bits=0]
-throws ANTLRException
-{
- long lhs,rhs=0;
-}
- : lhs=term[field] ("," rhs=expr[field])?
- {
- bits = lhs|rhs;
- }
- ;
-
-term [int field]
-returns [long bits=0]
-throws ANTLRException
-{
- int d=1,s,e,t;
-}
- : (token "-")=> s=token "-" e=token ( "/" d=token )?
- {
- bits = doRange(s,e,d,field);
- }
- | t=token
- {
- rangeCheck(t,field);
- bits = 1L<<t;
- }
- | "*" ("/" d=token )?
- {
- bits = doRange(d,field);
- }
- ;
-
-token
-returns [int value=0]
- : t:TOKEN
- {
- value = Integer.parseInt(t.getText());
- }
- ;
-
-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;
-}
-
-TOKEN
-options {
- paraphrase="a number";
-}
- : ('0'..'9')+
- ;
-
-WS
-options {
- paraphrase="space";
-}
- : (' '|'\t')+
- ;
-
-MINUS: '-';
-STAR: '*';
-DIV: '/';
-OR: ',';
-AT: '@';
-
-YEARLY: "yearly";
-ANNUALLY: "annually";
-MONTHLY: "monthly";
-WEEKLY: "weekly";
-DAILY: "daily";
-MIDNIGHT: "midnight";
-HOURLY: "hourly";
diff --git a/hudson-core/src/main/grammar/labelExpr.g b/hudson-core/src/main/grammar/labelExpr.g
deleted file mode 100644
index 2e44d2a..0000000
--- a/hudson-core/src/main/grammar/labelExpr.g
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2010, InfraDNA, Inc.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *
- * Kohsuke Kawaguchi
- *
- */
-header {
- package hudson.model.labels;
- import hudson.model.Label;
-}
-
-class LabelExpressionParser extends Parser;
-options {
- defaultErrorHandler=false;
-}
-
-// order of precedence is as per http://en.wikipedia.org/wiki/Logical_connective#Order_of_precedence
-
-expr
-returns [Label l]
- : l=term1 EOF
- ;
-
-term1
-returns [Label l]
-{ Label r; }
- : l=term2( IFF r=term2 {l=l.iff(r);} )?
- ;
-
-term2
-returns [Label l]
-{ Label r; }
- : l=term3( IMPLIES r=term3 {l=l.implies(r);} )?
- ;
-
-term3
-returns [Label l]
-{ Label r; }
- : l=term4 ( OR r=term4 {l=l.or(r);} )?
- ;
-
-term4
-returns [Label l]
-{ Label r; }
- : l=term5 ( AND r=term5 {l=l.and(r);} )?
- ;
-
-term5
-returns [Label l]
-{ Label x; }
- : l=term6
- | NOT x=term6
- { l=x.not(); }
- ;
-
-term6
-returns [Label l]
-options { generateAmbigWarnings=false; }
- : LPAREN l=term1 RPAREN
- { l=l.paren(); }
- | a:ATOM
- { l=LabelAtom.get(a.getText()); }
- | s:STRINGLITERAL
- { l=LabelAtom.get(hudson.util.QuotedStringTokenizer.unquote(s.getText())); }
- ;
-
-class LabelExpressionLexer extends Lexer;
-
-AND: "&&";
-OR: "||";
-NOT: "!";
-IMPLIES:"->";
-IFF: "<->";
-LPAREN: "(";
-RPAREN: ")";
-
-protected
-IDENTIFIER_PART
- : ~( '&' | '|' | '!' | '<' | '>' | '(' | ')' | ' ' | '\t' | '\"' | '\'' )
- ;
-
-ATOM
-/* the real check of valid identifier happens in LabelAtom.get() */
- : (IDENTIFIER_PART)+
- ;
-
-WS
- : (' '|'\t')+
- { $setType(Token.SKIP); }
- ;
-
-STRINGLITERAL
- : '"'
- ( '\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\"' | '\'' | '\\' ) /* escape */
- | ~( '\\' | '"' | '\r' | '\n' )
- )*
- '"'
- ;
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index 4c19b40..68c8a5f 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -19,7 +19,6 @@
*/
package hudson.model;
-import antlr.ANTLRException;
import hudson.AbortException;
import hudson.CopyOnWrite;
import hudson.FeedAdapter;
@@ -110,6 +109,7 @@ import org.kohsuke.stapler.export.Exported;
import static hudson.scm.PollingResult.BUILD_NOW;
import static hudson.scm.PollingResult.NO_CHANGES;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+import org.antlr.runtime.RecognitionException;
/**
* Base implementation of {@link Job}s that build software.
@@ -2241,7 +2241,7 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
}
try {
Label.parseExpression(value);
- } catch (ANTLRException e) {
+ } catch (RecognitionException e) {
return FormValidation.error(e,
Messages.AbstractProject_AssignedLabelString_InvalidBooleanExpression(e.getMessage()));
}
diff --git a/hudson-core/src/main/java/hudson/model/AppointedNode.java b/hudson-core/src/main/java/hudson/model/AppointedNode.java
index b13e41d..49f44c8 100644
--- a/hudson-core/src/main/java/hudson/model/AppointedNode.java
+++ b/hudson-core/src/main/java/hudson/model/AppointedNode.java
@@ -14,10 +14,10 @@
*******************************************************************************/
package hudson.model;
-import antlr.ANTLRException;
import hudson.model.labels.LabelAtom;
import hudson.model.labels.LabelExpression;
import java.io.Serializable;
+import org.antlr.runtime.RecognitionException;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
@@ -121,7 +121,7 @@ public class AppointedNode implements Serializable {
try {
LabelExpression.parseExpression(nodeName);
return nodeName;
- } catch (ANTLRException e) {
+ } catch (RecognitionException e) {
// must be old label or host name that includes whitespace or other unsafe chars
return LabelAtom.escape(nodeName);
}
diff --git a/hudson-core/src/main/java/hudson/model/Hudson.java b/hudson-core/src/main/java/hudson/model/Hudson.java
index 09febf7..d7e3bb1 100644
--- a/hudson-core/src/main/java/hudson/model/Hudson.java
+++ b/hudson-core/src/main/java/hudson/model/Hudson.java
@@ -16,7 +16,6 @@
package hudson.model;
-import antlr.ANTLRException;
import com.thoughtworks.xstream.XStream;
import hudson.BulkChange;
import hudson.DNSMultiCast;
@@ -200,6 +199,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.LogRecord;
import java.util.regex.Pattern;
+import org.antlr.runtime.RecognitionException;
import org.eclipse.hudson.script.ScriptSupport;
import org.eclipse.hudson.security.HudsonSecurityEntitiesHolder;
import org.eclipse.hudson.security.HudsonSecurityManager;
@@ -1414,7 +1414,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* @deprecated
- * UI method. Not meant to be used programatically.
+ * UI method. Not meant to be used programmatically.
*/
public ComputerSet getComputer() {
return new ComputerSet();
@@ -1439,7 +1439,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
// non-existent
try {
labels.putIfAbsent(expr, Label.parseExpression(expr));
- } catch (ANTLRException e) {
+ } catch (RecognitionException e) {
// laxly accept it as a single label atom for backward compatibility
return getLabelAtom(expr);
}
diff --git a/hudson-core/src/main/java/hudson/model/Label.java b/hudson-core/src/main/java/hudson/model/Label.java
index 276238e..d0c241a 100644
--- a/hudson-core/src/main/java/hudson/model/Label.java
+++ b/hudson-core/src/main/java/hudson/model/Label.java
@@ -16,7 +16,6 @@
package hudson.model;
-import antlr.ANTLRException;
import hudson.Util;
import static hudson.Util.fixNull;
@@ -32,7 +31,6 @@ import hudson.util.VariableResolver;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
-import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -46,6 +44,9 @@ import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
/**
* Group of {@link Node}s.
@@ -472,8 +473,8 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod
*
* TODO: replace this with a real parser later
*/
- public static Label parseExpression(String labelExpression) throws ANTLRException {
- LabelExpressionLexer lexer = new LabelExpressionLexer(new StringReader(labelExpression));
- return new LabelExpressionParser(lexer).expr();
+ public static Label parseExpression(String labelExpression) throws RecognitionException {
+ LabelExpressionLexer lexer = new LabelExpressionLexer(new ANTLRStringStream(labelExpression));
+ return new LabelExpressionParser(new CommonTokenStream(lexer)).expr();
}
}
diff --git a/hudson-core/src/main/java/hudson/scheduler/BaseParser.java b/hudson-core/src/main/java/hudson/scheduler/BaseParser.java
index 22e7c21..364c263 100644
--- a/hudson-core/src/main/java/hudson/scheduler/BaseParser.java
+++ b/hudson-core/src/main/java/hudson/scheduler/BaseParser.java
@@ -1,6 +1,6 @@
/*******************************************************************************
*
- * Copyright (c) 2004-2009 Oracle Corporation.
+ * Copyright (c) 2004-2012 Oracle Corporation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,45 +10,37 @@
* Contributors:
*
* Kohsuke Kawaguchi
+*
*
*
*******************************************************************************/
package hudson.scheduler;
-import antlr.ANTLRException;
-import antlr.LLkParser;
-import antlr.ParserSharedInputState;
-import antlr.SemanticException;
-import antlr.Token;
-import antlr.TokenBuffer;
-import antlr.TokenStream;
-import antlr.TokenStreamException;
+import org.antlr.runtime.Parser;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.RecognizerSharedState;
+import org.antlr.runtime.Token;
+import org.antlr.runtime.TokenStream;
+
+
/**
* @author Kohsuke Kawaguchi
*/
-abstract class BaseParser extends LLkParser {
+abstract class BaseParser extends Parser {
private static final int[] LOWER_BOUNDS = new int[] {0,0,1,0,0};
private static final int[] UPPER_BOUNDS = new int[] {59,23,31,12,7};
- protected BaseParser(int i) {
- super(i);
+ protected BaseParser(TokenStream tokenStream) {
+ super(tokenStream);
}
-
- protected BaseParser(ParserSharedInputState parserSharedInputState, int i) {
- super(parserSharedInputState, i);
+
+ protected BaseParser(TokenStream stream, RecognizerSharedState sharedState) {
+ super(stream, sharedState);
}
- protected BaseParser(TokenBuffer tokenBuffer, int i) {
- super(tokenBuffer, i);
- }
-
- protected BaseParser(TokenStream tokenStream, int i) {
- super(tokenStream, i);
- }
-
- protected long doRange(int start, int end, int step, int field) throws ANTLRException {
+ protected long doRange(int start, int end, int step, int field) throws RecognitionException {
rangeCheck(start, field);
rangeCheck(end, field);
if (step <= 0)
@@ -63,23 +55,56 @@ abstract class BaseParser extends LLkParser {
return bits;
}
- protected long doRange( int step, int field ) throws ANTLRException {
+ protected long doRange( int step, int field ) throws RecognitionException {
return doRange( LOWER_BOUNDS[field], UPPER_BOUNDS[field], step, field );
}
- protected void rangeCheck(int value, int field) throws ANTLRException {
+ protected void rangeCheck(int value, int field) throws RecognitionException {
if( value<LOWER_BOUNDS[field] || UPPER_BOUNDS[field]<value ) {
error(Messages.BaseParser_OutOfRange(value,LOWER_BOUNDS[field],UPPER_BOUNDS[field]));
}
}
- private void error(String msg) throws TokenStreamException, SemanticException {
- Token token = LT(0);
+ private void error(String msg) throws RecognitionException {
+ Token token = getTokenStream().LT(0);
throw new SemanticException(
msg,
- token.getFilename(),
token.getLine(),
- token.getColumn()
+ token.getCharPositionInLine()
);
}
+
+ public static class SemanticException extends RecognitionException {
+ String msg;
+ Throwable throwable;
+
+ public SemanticException(String msg, int line, int charPositionInLine) {
+ super();
+ this.msg = msg;
+ this.line = line;
+ this.charPositionInLine = charPositionInLine;
+ }
+
+ public SemanticException(String msg, Throwable e) {
+ super();
+ this.msg = msg;
+ this.throwable = e;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("SemanticException: ");
+ sb.append(msg);
+ if (line > 0 || charPositionInLine > 0)
+ sb.append(" at [").append(line).append(',').append(charPositionInLine);
+ if (throwable != null)
+ sb.append(" from ").append(throwable.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public String getMessage() {
+ return msg;
+ }
+ }
}
diff --git a/hudson-core/src/main/java/hudson/scheduler/CronTab.java b/hudson-core/src/main/java/hudson/scheduler/CronTab.java
index 5f1e5b3..503e341 100644
--- a/hudson-core/src/main/java/hudson/scheduler/CronTab.java
+++ b/hudson-core/src/main/java/hudson/scheduler/CronTab.java
@@ -16,15 +16,16 @@
package hudson.scheduler;
-import antlr.ANTLRException;
-
-import java.io.StringReader;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
import static java.util.Calendar.*;
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+
/**
* Table for driving scheduled tasks.
*
@@ -48,18 +49,19 @@ public final class CronTab {
*/
private String spec;
- public CronTab(String format) throws ANTLRException {
+ public CronTab(String format) throws RecognitionException {
this(format,1);
}
- public CronTab(String format, int line) throws ANTLRException {
+ public CronTab(String format, int line) throws RecognitionException {
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);
+ private void set(String format, int line) throws RecognitionException {
+ ANTLRStringStream stream = new ANTLRStringStream(format);
+ stream.setLine(line);
+ CrontabLexer lexer = new CrontabLexer(stream);
+ CrontabParser parser = new CrontabParser(new CommonTokenStream(lexer));
spec = format;
parser.startRule(this);
@@ -346,7 +348,7 @@ public final class CronTab {
}
}
- void set(String format) throws ANTLRException {
+ void set(String format) throws RecognitionException {
set(format,1);
}
diff --git a/hudson-core/src/main/java/hudson/scheduler/CronTabList.java b/hudson-core/src/main/java/hudson/scheduler/CronTabList.java
index 557e58f..25234df 100644
--- a/hudson-core/src/main/java/hudson/scheduler/CronTabList.java
+++ b/hudson-core/src/main/java/hudson/scheduler/CronTabList.java
@@ -16,12 +16,12 @@
package hudson.scheduler;
-import antlr.ANTLRException;
-
import java.util.Calendar;
import java.util.Collection;
import java.util.Vector;
+import org.antlr.runtime.RecognitionException;
+
/**
* {@link CronTab} list (logically OR-ed).
*
@@ -62,7 +62,7 @@ public final class CronTabList {
return null;
}
- public static CronTabList create(String format) throws ANTLRException {
+ public static CronTabList create(String format) throws RecognitionException {
Vector<CronTab> r = new Vector<CronTab>();
int lineNumber = 0;
for (String line : format.split("\\r?\\n")) {
@@ -72,8 +72,8 @@ public final class CronTabList {
continue; // ignorable line
try {
r.add(new CronTab(line,lineNumber));
- } catch (ANTLRException e) {
- throw new ANTLRException(Messages.CronTabList_InvalidInput(line,e.toString()),e);
+ } catch (RecognitionException e) {
+ throw new BaseParser.SemanticException(Messages.CronTabList_InvalidInput(line,e.toString()),e);
}
}
return new CronTabList(r);
diff --git a/hudson-core/src/main/java/hudson/slaves/SimpleScheduledRetentionStrategy.java b/hudson-core/src/main/java/hudson/slaves/SimpleScheduledRetentionStrategy.java
index 763097b..c1787b1 100644
--- a/hudson-core/src/main/java/hudson/slaves/SimpleScheduledRetentionStrategy.java
+++ b/hudson-core/src/main/java/hudson/slaves/SimpleScheduledRetentionStrategy.java
@@ -16,7 +16,6 @@
package hudson.slaves;
-import antlr.ANTLRException;
import hudson.Extension;
import static hudson.Util.fixNull;
import hudson.model.Computer;
@@ -34,6 +33,7 @@ import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.util.logging.Level.INFO;
+import org.antlr.runtime.RecognitionException;
/**
* {@link RetentionStrategy} that controls the slave based on a schedule.
@@ -57,7 +57,7 @@ public class SimpleScheduledRetentionStrategy extends RetentionStrategy<SlaveCom
@DataBoundConstructor
public SimpleScheduledRetentionStrategy(String startTimeSpec, int upTimeMins, boolean keepUpWhenActive)
- throws ANTLRException {
+ throws RecognitionException {
this.startTimeSpec = startTimeSpec;
this.keepUpWhenActive = keepUpWhenActive;
this.tabs = CronTabList.create(startTimeSpec);
@@ -142,7 +142,7 @@ public class SimpleScheduledRetentionStrategy extends RetentionStrategy<SlaveCom
nextStart = Long.MIN_VALUE;
lastStop = Long.MAX_VALUE;
lastStart = Long.MAX_VALUE;
- } catch (ANTLRException e) {
+ } catch (RecognitionException e) {
InvalidObjectException x = new InvalidObjectException(e.getMessage());
x.initCause(e);
throw x;
@@ -229,7 +229,7 @@ public class SimpleScheduledRetentionStrategy extends RetentionStrategy<SlaveCom
if (msg != null)
return FormValidation.warning(msg);
return FormValidation.ok();
- } catch (ANTLRException e) {
+ } catch (RecognitionException e) {
return FormValidation.error(e.getMessage());
}
}
diff --git a/hudson-core/src/main/java/hudson/triggers/SCMTrigger.java b/hudson-core/src/main/java/hudson/triggers/SCMTrigger.java
index a50f6b2..814cb64 100644
--- a/hudson-core/src/main/java/hudson/triggers/SCMTrigger.java
+++ b/hudson-core/src/main/java/hudson/triggers/SCMTrigger.java
@@ -16,7 +16,6 @@
package hudson.triggers;
-import antlr.ANTLRException;
import hudson.Util;
import hudson.Extension;
import hudson.console.AnnotatedLargeText;
@@ -59,6 +58,7 @@ import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerResponse;
import static java.util.logging.Level.*;
+import org.antlr.runtime.RecognitionException;
/**
* {@link Trigger} that checks for SCM updates periodically.
@@ -67,7 +67,7 @@ import static java.util.logging.Level.*;
*/
public class SCMTrigger extends Trigger<SCMedItem> {
@DataBoundConstructor
- public SCMTrigger(String scmpoll_spec) throws ANTLRException {
+ public SCMTrigger(String scmpoll_spec) throws RecognitionException {
super(scmpoll_spec);
}
diff --git a/hudson-core/src/main/java/hudson/triggers/TimerTrigger.java b/hudson-core/src/main/java/hudson/triggers/TimerTrigger.java
index 9cc2abc..f254bb5 100644
--- a/hudson-core/src/main/java/hudson/triggers/TimerTrigger.java
+++ b/hudson-core/src/main/java/hudson/triggers/TimerTrigger.java
@@ -23,11 +23,11 @@ import hudson.model.Item;
import hudson.scheduler.CronTabList;
import hudson.util.FormValidation;
import hudson.Extension;
+import org.antlr.runtime.RecognitionException;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
-import antlr.ANTLRException;
/**
* {@link Trigger} that runs a job periodically.
@@ -37,7 +37,7 @@ import antlr.ANTLRException;
public class TimerTrigger extends Trigger<BuildableItem> {
@DataBoundConstructor
- public TimerTrigger(String spec) throws ANTLRException {
+ public TimerTrigger(String spec) throws RecognitionException {
super(spec);
}
@@ -69,7 +69,7 @@ public class TimerTrigger extends Trigger<BuildableItem> {
String msg = CronTabList.create(fixNull(value)).checkSanity();
if(msg!=null) return FormValidation.warning(msg);
return FormValidation.ok();
- } catch (ANTLRException e) {
+ } catch (RecognitionException e) {
return FormValidation.error(e.getMessage());
}
}
diff --git a/hudson-core/src/main/java/hudson/triggers/Trigger.java b/hudson-core/src/main/java/hudson/triggers/Trigger.java
index 041d4ce..fb37485 100644
--- a/hudson-core/src/main/java/hudson/triggers/Trigger.java
+++ b/hudson-core/src/main/java/hudson/triggers/Trigger.java
@@ -16,7 +16,6 @@
package hudson.triggers;
-import antlr.ANTLRException;
import hudson.DependencyRunner;
import hudson.DependencyRunner.ProjectRunnable;
import hudson.ExtensionPoint;
@@ -52,6 +51,7 @@ import java.util.ArrayList;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.antlr.runtime.RecognitionException;
/**
* Triggers a {@link Build}.
@@ -136,7 +136,7 @@ public abstract class Trigger<J extends Item> implements Describable<Trigger<?>>
* periodically. This is useful when your trigger does
* some polling work.
*/
- protected Trigger(String cronTabSpec) throws ANTLRException {
+ protected Trigger(String cronTabSpec) throws RecognitionException {
this.spec = cronTabSpec;
this.tabs = CronTabList.create(cronTabSpec);
}
@@ -161,7 +161,7 @@ public abstract class Trigger<J extends Item> implements Describable<Trigger<?>>
protected Object readResolve() throws ObjectStreamException {
try {
tabs = CronTabList.create(spec);
- } catch (ANTLRException e) {
+ } catch (RecognitionException e) {
InvalidObjectException x = new InvalidObjectException(e.getMessage());
x.initCause(e);
throw x;
diff --git a/hudson-core/src/test/java/hudson/scheduler/CronTabTest.java b/hudson-core/src/test/java/hudson/scheduler/CronTabTest.java
index 6a07c4d..ccbc0cb 100644
--- a/hudson-core/src/test/java/hudson/scheduler/CronTabTest.java
+++ b/hudson-core/src/test/java/hudson/scheduler/CronTabTest.java
@@ -16,7 +16,6 @@
package hudson.scheduler;
-import antlr.ANTLRException;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
@@ -24,12 +23,13 @@ import junit.framework.TestCase;
import org.jvnet.hudson.test.Bug;
import static java.util.Calendar.MONDAY;
+import org.antlr.runtime.RecognitionException;
/**
* @author Kohsuke Kawaguchi
*/
public class CronTabTest extends TestCase {
- public void test1() throws ANTLRException {
+ public void test1() throws RecognitionException {
new CronTab("@yearly");
new CronTab("@weekly");
new CronTab("@midnight");
diff --git a/hudson-core/src/test/java/hudson/triggers/TriggerEqualHashCodeTest.java b/hudson-core/src/test/java/hudson/triggers/TriggerEqualHashCodeTest.java
index 73a7652..5f42256 100644
--- a/hudson-core/src/test/java/hudson/triggers/TriggerEqualHashCodeTest.java
+++ b/hudson-core/src/test/java/hudson/triggers/TriggerEqualHashCodeTest.java
@@ -14,9 +14,9 @@
*******************************************************************************/
package hudson.triggers;
-import antlr.ANTLRException;
import java.util.Arrays;
import java.util.Collection;
+import org.antlr.runtime.RecognitionException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -44,7 +44,7 @@ public class TriggerEqualHashCodeTest {
}
@Parameterized.Parameters
- public static Collection generateData() throws ANTLRException {
+ public static Collection generateData() throws RecognitionException {
return Arrays.asList(new Object[][] {
{true, new TimerTrigger(""), new TimerTrigger("")},
{true, new TimerTrigger("* * * * *"), new TimerTrigger("* * * * *")},
@@ -56,7 +56,7 @@ public class TriggerEqualHashCodeTest {
}
@Test
- public void testEquals() throws ANTLRException {
+ public void testEquals() throws RecognitionException {
assertEquals(expectedResult, trigger1.equals(trigger2));
}
diff --git a/hudson-core/src/test/java/hudson/util/CascadingTriggersTest.java b/hudson-core/src/test/java/hudson/util/CascadingTriggersTest.java
index bd9e50c..55d7853 100644
--- a/hudson-core/src/test/java/hudson/util/CascadingTriggersTest.java
+++ b/hudson-core/src/test/java/hudson/util/CascadingTriggersTest.java
@@ -15,7 +15,6 @@
*******************************************************************************/
package hudson.util;
-import antlr.ANTLRException;
import hudson.model.FreeStyleProjectMock;
import hudson.model.Hudson;
import hudson.triggers.TimerTrigger;
diff --git a/hudson-core/src/test/java/org/eclipse/hudson/model/project/property/TriggerProjectPropertyTest.java b/hudson-core/src/test/java/org/eclipse/hudson/model/project/property/TriggerProjectPropertyTest.java
index 27d17b7..267e3d0 100644
--- a/hudson-core/src/test/java/org/eclipse/hudson/model/project/property/TriggerProjectPropertyTest.java
+++ b/hudson-core/src/test/java/org/eclipse/hudson/model/project/property/TriggerProjectPropertyTest.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.hudson.model.project.property;
-import antlr.ANTLRException;
import hudson.model.FreeStyleProjectMock;
import hudson.triggers.TimerTrigger;
import hudson.triggers.Trigger;
@@ -22,6 +21,7 @@ import org.junit.Before;
import org.junit.Test;
import static junit.framework.Assert.*;
+import org.antlr.runtime.RecognitionException;
/**
* Contains test-cases for {@link TriggerProjectProperty}.
@@ -55,10 +55,10 @@ public class TriggerProjectPropertyTest {
/**
* Verify {@link org.eclipse.hudson.model.project.property.TriggerProjectProperty#clearOriginalValue(hudson.triggers.Trigger)} method.
*
- * @throws antlr.ANTLRException if any
+ * @throws antlr.RecognitionException if any
*/
@Test
- public void testClearOriginalValue() throws ANTLRException {
+ public void testClearOriginalValue() throws RecognitionException {
//Overridden flag should be cleared to false. Pre-set true value
property.setOverridden(true);
assertTrue(property.isOverridden());
@@ -73,10 +73,10 @@ public class TriggerProjectPropertyTest {
/**
* Test updateOriginalValue method for TriggerProjectProperty.
*
- * @throws antlr.ANTLRException if any
+ * @throws antlr.RecognitionException if any
*/
@Test
- public void testUpdateOriginalValue() throws ANTLRException {
+ public void testUpdateOriginalValue() throws RecognitionException {
Trigger originalTrigger = new TimerTrigger("* * * * *");
Trigger cascadingTrigger = new TimerTrigger("* * * * *");
property.updateOriginalValue(originalTrigger, cascadingTrigger);
@@ -94,10 +94,10 @@ public class TriggerProjectPropertyTest {
/**
* Verify {@link org.eclipse.hudson.model.project.property.TriggerProjectProperty#onCascadingProjectRemoved()} method.
*
- * @throws antlr.ANTLRException if any
+ * @throws antlr.RecognitionException if any
*/
@Test
- public void testOnCascadingProjectRemoved() throws ANTLRException {
+ public void testOnCascadingProjectRemoved() throws RecognitionException {
Trigger trigger = new TimerTrigger("* * * * *");
property.setOriginalValue(trigger, false);
assertTrue(trigger == property.getOriginalValue());
diff --git a/hudson-inject/pom.xml b/hudson-inject/pom.xml
index a037e7b..d43393f 100644
--- a/hudson-inject/pom.xml
+++ b/hudson-inject/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.eclipse.hudson</groupId>
<artifactId>hudson-parent</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0-M2-1</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/hudson-utils/pom.xml b/hudson-utils/pom.xml
index 533ad6d..4a0bb38 100644
--- a/hudson-utils/pom.xml
+++ b/hudson-utils/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.eclipse.hudson</groupId>
<artifactId>hudson-parent</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0-M2-1</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/pom.xml b/pom.xml
index b0b6f52..233cb63 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,7 +120,7 @@
<build.timestamp>${maven.build.timestamp}</build.timestamp>
<build.number />
- <maven-hpi-plugin.version>3.0.0-M2</maven-hpi-plugin.version>
+ <maven-hpi-plugin.version>3.0.0-SNAPSHOT</maven-hpi-plugin.version>
<stapler.version>3.0.0-M2</stapler.version>
<maven-stapler-plugin.version>3.0.1</maven-stapler-plugin.version>
@@ -215,7 +215,7 @@
<json-lib.version>2.4</json-lib.version>
<annotation-indexer.version>1.2</annotation-indexer.version>
<task-reactor.version>1.2</task-reactor.version>
- <antlr.version>2.7.7</antlr.version>
+ <antlr.version>3.4</antlr.version>
<commons-digester.version>3.0</commons-digester.version>
<commons-beanutils.version>1.8.0</commons-beanutils.version>
<commons-jelly-tags-fmt.version>1.0</commons-jelly-tags-fmt.version>
@@ -243,7 +243,6 @@
<!--Plugins-->
<maven-encoding-plugin.version>1.1</maven-encoding-plugin.version>
- <antlr-maven-plugin.version>2.1</antlr-maven-plugin.version>
<apt-maven-plugin.version>1.0-alpha-2</apt-maven-plugin.version>
<maven-project-info-reports-plugin.version>2.1</maven-project-info-reports-plugin.version>
</properties>