Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a9734c69d | ||
|
|
5e3bf3f77b | ||
|
|
35e703a2f5 | ||
|
|
948fc59ef8 |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,2 @@
|
||||
/bin/
|
||||
*~
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>RCalc</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
+19
-17
@@ -1,21 +1,23 @@
|
||||
Copyright (c) 2014, Ondřej Hruška (MightyPork), <ondra@ondrovo.com>
|
||||
All rights reserved.
|
||||
|
||||
The MIT License (MIT)
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Copyright (c) 2013 Ondrej Hruska
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Batch calculator (reads input from a file)
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class CalculatorBatch implements Runnable {
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Interactive calculator
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class CalculatorInteractive implements Runnable {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.File;
|
||||
/**
|
||||
* Application main class
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.mightypork.rcalc.RCalc;
|
||||
/**
|
||||
* RCalc unit tests
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class Tests implements Runnable {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package net.mightypork.rcalc;
|
||||
/**
|
||||
* Interface for classes with optional debug mode
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface IDebugable {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Interface of an object that can be turned into a fractional value
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface IEvaluable {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package net.mightypork.rcalc;
|
||||
/**
|
||||
* Evaluable token interface
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface IEvaluableToken extends IEvaluable, IToken {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package net.mightypork.rcalc;
|
||||
/**
|
||||
* Token interface
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface IToken {
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ package net.mightypork.rcalc;
|
||||
/**
|
||||
* Error thrown when a syntax error is encountered while parsing an expression
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class ParseError extends RuntimeException {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
* Rational calculator, expression parser returning fractional results instead
|
||||
* of imprecise decimal values.
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class RCalc implements IDebugable {
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
* Rational Calculator Session - interactive RCalc with possibility to set and
|
||||
* use variables.
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class RCalcSession implements IDebugable {
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.mightypork.rcalc.tokens.*;
|
||||
/**
|
||||
* A list of tokens which can be parsed into a single IEvaluable
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TokenList extends ArrayList<IToken> implements IToken {
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.mightypork.rcalc.tokens.*;
|
||||
/**
|
||||
* Utility for converting an expression from String to a list of tokens
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class Tokenizer implements IDebugable {
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.mightypork.rcalc.TokenList;
|
||||
/**
|
||||
* A fractional number with methods for basic arithmetics
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class Fraction implements IEvaluableToken {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Abstract operation with two operands
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class BinaryOperation extends Operation {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Abstract operation
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class Operation implements IEvaluableToken {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Addition
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class OperationAdd extends BinaryOperation {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Division
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class OperationDivide extends BinaryOperation {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Factorial
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class OperationFactorial extends UnaryOperation {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Modulo
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class OperationModulo extends BinaryOperation {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Multiplication
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class OperationMultiply extends BinaryOperation {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Exponentiation
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class OperationPower extends BinaryOperation {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Subtraction
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class OperationSubtract extends BinaryOperation {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.numbers.Fraction;
|
||||
/**
|
||||
* Abstract unary operator
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class UnaryOperation extends Operation {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.mightypork.rcalc.IToken;
|
||||
/**
|
||||
* Interface of an operator token
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface IOperatorToken extends IToken {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.operations.Operation;
|
||||
/**
|
||||
* Abstract operation token with two operands
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class TokenBinaryOperator extends TokenOperator {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.mightypork.rcalc.operations.OperationAdd;
|
||||
/**
|
||||
* Addition token
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TokenOperatorAdd extends TokenBinaryOperator {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.mightypork.rcalc.operations.OperationDivide;
|
||||
/**
|
||||
* Division token
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TokenOperatorDivide extends TokenBinaryOperator {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.mightypork.rcalc.operations.OperationFactorial;
|
||||
/**
|
||||
* Factorial token
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TokenOperatorFactorial extends TokenUnaryOperatorLeft {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.mightypork.rcalc.operations.OperationModulo;
|
||||
/**
|
||||
* Modulo token
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TokenOperatorModulo extends TokenBinaryOperator {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.mightypork.rcalc.operations.OperationMultiply;
|
||||
/**
|
||||
* Multiplication token
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TokenOperatorMultiply extends TokenBinaryOperator {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.mightypork.rcalc.operations.OperationPower;
|
||||
/**
|
||||
* Exponentiation token
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TokenOperatorPower extends TokenBinaryOperator {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.mightypork.rcalc.operations.OperationSubtract;
|
||||
/**
|
||||
* Subtraction token
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TokenOperatorSubtract extends TokenBinaryOperator {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.TokenList;
|
||||
/**
|
||||
* Left parenthesis token
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TokenParenthesisLeft implements IToken {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.TokenList;
|
||||
/**
|
||||
* Right parenthesis token
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TokenParenthesisRight implements IToken {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.operations.Operation;
|
||||
/**
|
||||
* Abstract operator token with one operand on left
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class TokenUnaryOperatorLeft extends TokenOperator {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.mightypork.rcalc.operations.Operation;
|
||||
/**
|
||||
* Abstract operator token with one operand on right
|
||||
*
|
||||
* @author Ondrej Hruska
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class TokenUnaryOperatorRight extends TokenOperator {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user