1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.millscript.office.spreadsheet.formula;
24
25 import org.millscript.millscript.conf.Configuration;
26 import org.millscript.millscript.syntax.AppendSyntax;
27 import org.millscript.millscript.syntax.ConfigurationParserImpl;
28 import org.millscript.office.spreadsheet.formula.syntax.AddSyntax;
29 import org.millscript.office.spreadsheet.formula.syntax.DivSyntax;
30 import org.millscript.office.spreadsheet.formula.syntax.MulSyntax;
31 import org.millscript.office.spreadsheet.formula.syntax.PercentSyntax;
32 import org.millscript.office.spreadsheet.formula.syntax.PowerSyntax;
33 import org.millscript.office.spreadsheet.formula.syntax.SubSyntax;
34
35 import java.io.Reader;
36
37
38
39
40
41
42
43
44
45 /**
46 * This class implements the MillScript parser.
47 */
48 public class FormulaParserImpl extends ConfigurationParserImpl {
49
50
51 static {
52
53 put( "+", new AddSyntax().setPrec( ARITH_PREC + 100 ) );
54 put( "-", new SubSyntax().setPrec( ARITH_PREC + 100 ) );
55 put( "*", new MulSyntax().setPrec( ARITH_PREC + 200 ) );
56 put( "/", new DivSyntax().setPrec( ARITH_PREC + 200 ) );
57 put( "^", new PowerSyntax().setPrec( ARITH_PREC + 200 ) );
58 put( "&", new AppendSyntax().setPrec( ARITH_PREC + 200 ) );
59
60
61 put( "%", new PercentSyntax().setPrec( ARITH_PREC + 100 ) );
62 }
63
64 /**
65 * Constructs a new <code>ParserImpl</code> with the specified origin, source,
66 * interactive prompt and end of line comment status.
67 *
68 * @param origin the origin message for this tokenizer
69 * @param r the character source to tokenize
70 * @param eolc flag indicating if end of line comments are supported
71 * @param c the configuration
72 */
73 public FormulaParserImpl( final String origin, final Reader r, final Configuration c ) {
74 super( origin, r, false, c );
75 }
76
77 }