1 /****************************************************************
\r
2 * Licensed to the Apache Software Foundation (ASF) under one *
\r
3 * or more contributor license agreements. See the NOTICE file *
\r
4 * distributed with this work for additional information *
\r
5 * regarding copyright ownership. The ASF licenses this file *
\r
6 * to you under the Apache License, Version 2.0 (the *
\r
7 * "License"); you may not use this file except in compliance *
\r
8 * with the License. You may obtain a copy of the License at *
\r
10 * http://www.apache.org/licenses/LICENSE-2.0 *
\r
12 * Unless required by applicable law or agreed to in writing, *
\r
13 * software distributed under the License is distributed on an *
\r
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
\r
15 * KIND, either express or implied. See the License for the *
\r
16 * specific language governing permissions and limitations *
\r
17 * under the License. *
\r
18 ****************************************************************/
\r
22 JDK_VERSION = "1.4";
\r
23 OUTPUT_DIRECTORY = "target/generated-sources/javacc";
\r
26 PARSER_BEGIN(MimeVersionParser)
\r
27 /****************************************************************
\r
28 * Licensed to the Apache Software Foundation (ASF) under one *
\r
29 * or more contributor license agreements. See the NOTICE file *
\r
30 * distributed with this work for additional information *
\r
31 * regarding copyright ownership. The ASF licenses this file *
\r
32 * to you under the Apache License, Version 2.0 (the *
\r
33 * "License"); you may not use this file except in compliance *
\r
34 * with the License. You may obtain a copy of the License at *
\r
36 * http://www.apache.org/licenses/LICENSE-2.0 *
\r
38 * Unless required by applicable law or agreed to in writing, *
\r
39 * software distributed under the License is distributed on an *
\r
40 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
\r
41 * KIND, either express or implied. See the License for the *
\r
42 * specific language governing permissions and limitations *
\r
43 * under the License. *
\r
44 ****************************************************************/
\r
45 package org.apache.james.mime4j.field.mimeversion;
47 public class MimeVersionParser {
\r
48 public static final int INITIAL_VERSION_VALUE = -1;
\r
49 private int major=INITIAL_VERSION_VALUE;
\r
50 private int minor=INITIAL_VERSION_VALUE;
\r
52 public int getMinorVersion() {
\r
56 public int getMajorVersion() {
\r
60 PARSER_END(MimeVersionParser)
\r
81 major=<DIGITS> <DOT> minor=<DIGITS>
\r
84 this.major = Integer.parseInt(major.image);
\r
85 this.minor = Integer.parseInt(minor.image);
\r
86 } catch (NumberFormatException e) {
\r
87 throw new ParseException(e.getMessage());
\r
94 < WS: ( [" ", "\t", "\r", "\n"] )+ >
\r
99 // Keeps track of how many levels of comment nesting
\r
100 // we've encountered. This is only used when the 2nd
\r
101 // level is reached, for example ((this)), not (this).
\r
102 // This is because the outermost level must be treated
\r
103 // specially anyway, because the outermost ")" has a
\r
104 // different token type than inner ")" instances.
\r
111 // starts a comment
\r
119 < COMMENT: ")" > : DEFAULT
\r
120 // if this is ever changed to not be a SKIP, need
\r
121 // to make sure matchedToken.token = token.toString()
\r
128 < <QUOTEDPAIR>> { image.deleteCharAt(image.length() - 2); }
\r
129 | "(" { commentNest = 1; } : NESTED_COMMENT
\r
136 < <QUOTEDPAIR>> { image.deleteCharAt(image.length() - 2); }
\r
137 | "(" { ++commentNest; }
\r
138 | ")" { --commentNest; if (commentNest == 0) SwitchTo(INCOMMENT); }
\r
145 "\"" { image.deleteCharAt(image.length() - 1); } : INQUOTEDSTRING
\r
151 < <QUOTEDPAIR>> { image.deleteCharAt(image.length() - 2); }
\r
152 | < (~["\"", "\\"])+ >
\r
158 < QUOTEDSTRING: "\"" > { matchedToken.image = image.substring(0, image.length() - 1); } : DEFAULT
\r
163 < DIGITS: ( ["0"-"9"] )+ >
\r
174 < #QUOTEDPAIR: "\\" <ANY> >
\r