procalparsing's People
procalparsing's Issues
Hidden Multiplication
Codes
$a$b$c
Error Returned
org.bychan.core.basic.ParsingFailedException: Parsing failed: 'Current token does not support led parsing' @ position 1:6 (index 5), current lexeme is variable($c), previous was variable($b), and remaining are [colon(:), END] at org.bychan.core.basic.ParseResult.checkSuccess(ParseResult.java:83) at org.bychan.core.basic.ParseResult.getRootNode(ParseResult.java:36) at fx50.Main$Run.run(Main.java:120) at fx50.Main.main(Main.java:29) Error: Parsing failed: 'Current token does not support led parsing' @ position 1:6 (index 5), current lexeme is variable($c), previous was variable($b), and remaining are [colon(:), END]
Nested parsing unwanted behavior
What happened
> showParseResult off
Parse result will not be shown.
> ?->$A
A?:?->$B
B?:?->$C
C?:5
C?:4
B?:3
=5
> $A
=5
> $B
=3
> $C
=4
What should have happened
> showParseResult off
Parse result will not be shown.
> ?->$A
A?:?->$B
B?:?->$C
C?:5
=5
> $A
=5
> $B
=5
> $C
=5
What might be the problem
I have absolutely no idea why!
Implementing dectofrac feature
Revamp the whole system by replacing BigDecimal with BigNumber which has a fraction implementation
Possible implementation
public class BigNumber{
private int numerator;
private int denominator;
private BigDecimal decimal = new BigDecimal(numerator/denominator);
private boolean state; //to be set when being constructed
//... and whole bunch of other methods
}
Possible implementation
class BigNumber extends BigDecimal {
//all your fraction stuff
public BigNumber add(BigNumber bigNumber) {/*...*/}
}
Variable Set Display
The following codes work in an actual calculator but no in ours.
$A->$B display
May want to include it for better calc programming.
floor and ceiling
Input
Floor(2)
Ceiling(2)
Ceiling(3.8)
Rnd_Up(3.8)
Rnd_Down(3.8)
Errors
Error: Lexing failed: 'No matching rule' @ position 1:7 (index 6): last lexeme was 'lparen(()', remaining text is '2):'
Error: Lexing failed: 'No matching rule' @ position 1:9 (index 8): last lexeme was 'lparen(()', remaining text is '2):'
Error: Parsing failed: 'Current lexeme does not support nud parsing' @ position 1:1 (index 0), current lexeme is combination(C), previous was null, and remaining are [function(eiling), lparen((), number(3.8), rparen()), colon(:), END]
Error: Lexing failed: 'No matching rule' @ position 1:4 (index 3): last lexeme was 'suffixFunction(Rnd)', remaining text is '_Up(3.8):'
- Similar error to above
Add base conversion tokens
Syntax
BIN: <Statement>
Explanation
The output will be printed in that base when a token is detected anywhere.
PowerNode unwanted behavior
What happened
&exp^0
returns 0^0 is undefined.
What should have happened
This should return 1
What might be the problem
Logic error
nCr & nPr
Expressions
10C2
10P2
Results
7.3156608E+10
, should be45
1.46313216E+11
, should be90
acos() miscalculation
Input
acos(0)
acos(1)
acos(-1)
Output
1.5
, should be more precise, i.e.1.570796327
Error: Math Error
, should be0
Error: Math Error
, should be3.141592654
I believe other values are fine in acos().
Hidden Multiplication on functions
Codes
2sin(&pi/2)
2->$A: &pi/2->$B: $A sin($B) display
Parsing
Error: Parsing failed: 'Current token does not support led parsing' @ position 1:2 (index 1), current lexeme is function(sin), previous was number(2), and remaining are [lparen((), constant(&pi), divide(/), number(2), rparen()), colon(:), END]
2->$A: &pi/2->$B: ($Asin) * ($B) display
Result
0
, which should have been2
Display VS shorthand if lbp
Add support for input prompt placeholder
This feature is wanted because one might want concise code but descriptive input prompt.
Syntax
?-> $A "descriptive text"
?-> $B
Console output
descriptive text?
B?
Statements
Codes
If 1 Then 1 display IfEnd:
While 1: 1 display WhileEnd:
For 1->$A To 1: 1 display Next:
Returns
Expected : but got IfEnd
Expected : but got WhileEnd
Expected : but got Next
Hidden Multiplication on PowerNode
The program 2^(3)
is parsed with error Current lexeme does not support nud parsing' @ position 1:3 (index 2), current lexeme is power(^), previous was multiply(*), and remaining are [lparen((), number(3), rparen()), colon(:), END]
.
Cannot power negative
What happened
(-1)^(-1)
returns an error
java.lang.ArithmeticException: Cannot power negative -1.000000000000000
at org.nevec.rjm.BigDecimalMath.pow(BigDecimalMath.java:767)
at fx50.nodes.PowerNode.evaluate(PowerNode.java:20)
at fx50.nodes.StatementNode.evaluate(StatementNode.java:29)
at fx50.Main$Run.run(Main.java:118)
at fx50.Main$Run.run(Main.java:127)
at fx50.Main$Run.run(Main.java:127)
at fx50.Main.main(Main.java:29)
Error: Cannot power negative -1.000000000000000
What should have happened
(-1)^(-1)
should return -1
What might be the problem
The rjm library.
Add Pol() and Rec() functions
Revamp Hidden Multiplication: an attempt with nud/led instead of hardcode regex
Illustration of thought:
Each Node can specify whether it supports hidden multiplication or not in an attribute of the class.
Hence checking can be done by finding out whether there is some consecutive nodes both with this attribute.
For example, let say we have a boolean property hiddenMultiplicative
NumberNode.hiddenMultiplicative = true;
VariableNode.hiddenMultiplicative = true;
ConstantNode.hiddenMultiplicative = true;
AdditionNode.hiddenMultiplicative = false;
<NumberNode><VariableNode> // invokes Hidden multiplication
<VariableNode><VariableNode> // self-chain: invokes Hidden multiplication
<NumberNode><NumberNode> // commutative: invokes Hidden multiplication but shall this be banned?
<VariableNode><ConstantNode> // invokes Hidden multiplication
<NumberNode><AdditionNode> // Not invoked
0^0 doesn't return error
As title.
Make changes to printed text to make compatible with an API with the Procal app
Make printed text systematic yet clear to the user in console to make the text also easily parsable in a Java method.
Hidden multiplication does not have a fixed binding power
What happened
Precedence of hidden multiplication is unexpected and not consistent.
1/1$A
is parsed as (1/(1*$A))
What should have happened
Hidden multiplication should have the same left binding power
1/1$A
should be parsed as ((1/1)*$A)
What might be the problem
Hidden multiplication is implemented as .led()
s in some tokens with different binding powers, e.g. constant
, variable
, function
, lparen
.
Add support for calling stored programs
Syntax
QuadEquation($A, $B)->$C, $D
Explanation
The system looks for a files called QuadEquation.procal
in the same directory and attempt to run it by supplying the input prompts with values of $A
and $B
then returns the displayed value and final result value, which is set the variables $C
and $D
.
Single '.'
This is a minor issue but .
in calculators should return 0
.
Our program returns Error: Lexing failed: 'No matching rule' @ position 1:1 (index 0): last lexeme was <none>, remaining text is '.:'
.
Add convert to fraction and vica versa support
Syntax
OUT_AS_IMPR_FRAC:
OUT_AS_MIXED_FRAC:
This will change how fractions are outputted
Order of Operation
Codes
5: 2->$A: $A Ans^5
Parsing
5: 2->$A: ($A*Ans)^5
Results
1024
//The problem seems to only affect Ans but not other var
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.