/* * Copyright (c) 2008 * by Fachhochschule Gießen-Friedberg University of Applied Sciences. * * mmp is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * mmp is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * -------------------------------------------------------------------------- * $Id: package-info.java 338 2008-07-01 08:06:00Z brenz $ * -------------------------------------------------------------------------- */
The MNI Integer Calculator MIC is an implementation of the functionality of M4's eval in Java.
MIC can be used as an embedded calculator
// Instantiate mic
Mic mic = new Mic();
// calculate
int result = mic.calculate( "10*5-3" );
// use result
...
There is also a command line interface to MIC
The invocation with arguments gives the result of the computation.
java mic.cli.mic 10 * 5 - 3
47
The invocation without arguments starts mic in interactive mode.
java mic.cli.mic
mic - the MNI integer calculator, rev 1.0
mic - interactiv mode - enter q to quit
mic %
Expression comprise integer literals like "3", parenthesis "(" and ")" and the following operators
+ | Plus sign |
- | Minus sign |
~ | Bitwise negation |
! | Logical negation |
Precedence | Operator | Meaning | Associativity |
high | ** | Power | right |
* | Multiplication | left | |
/ | Division | left | |
% | Modulo | left | |
+ | Addition | left | |
- | Substraction | left | |
<< | Left shift | left | |
>> | Right shift | left | |
< | Less than | left | |
> | Greater than | left | |
<= | Less or equal | left | |
>= | Greater or equal | left | |
== | Equal | left | |
!= | Not equal | left | |
& | Bitwise and | left | |
^ | Bitwise xor | left | |
| | Bitwise or | left | |
&& | Logical and | left | |
low | || | Logical or | left |