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