You could replace all those `op=='+'||op=='-'? ...` with
`op.among!('+', '-')? ...`.
auto i=cast(size_t)0,r=0.0;
for(;i
For example:
I'm not sure whether the Token-struct is very elegant implemented..
Would in this case a Token-class with a NumberToken subclass be more
appropriate?
Not really. (You don't want to allocate a class object for every token
read.)
Or maybe a union or something other..
Code: https://github.com/tholzschuh/math-parser/
So thanks again!
(and sorry for the bad english)
Tim
is case a Token-class with a NumberToken subclass be more
appropriate?
Or maybe a union or something other..
Code: https://github.com/tholzschuh/math-parser/
So thanks again!
(and sorry for the bad english)
Tim
On 05/03/2014 08:20 PM, Tim Holzschuh via Digitalmars-d-learn wrote:
Let me know if you also want hints on how to get the logic right.
Would be very nice!
While 2*2 works, 2+2 throws an Error because the number-method gets an
END-Token instead of a Number-Token (although I'm not sure why).
Th
Am 03.05.2014 13:29, schrieb Timon Gehr via Digitalmars-d-learn:
@property Lexer lexer() pure { return _lexer; }
If you change the result of a call to 'lexer' this will not change
'_lexer'. Mark the property 'ref' or get rid of it
How did I forget about Lexer being a struct is a value type...
Am 03.05.2014 11:17, schrieb Rikki Cattermole via Digitalmars-d-learn:
General suggestions:
Don't commit the build ext. files along with source code and in this
case they aren't needed. Mono-D can load dub.json straight. As well as
the obj/bin directories.
Yeah you're right, thank you.
(And
On 05/03/2014 12:34 AM, Tim Holzschuh via Digitalmars-d-learn wrote:
Most probably this isn't a wrong use of something D-specific
Some of the problems are:
@property Lexer lexer() pure { return _lexer; }
If you change the result of a call to 'lexer' this will not change
'_lexer'. Mark the p
On Friday, 2 May 2014 at 22:34:48 UTC, Tim Holzschuh via
Digitalmars-d-learn wrote:
Hi there,
I currently try to write a simple math-parser in D.
However.. something isn't working and I just can't figure out
what's the problem.
(I'm relative new to D, and this is my f
Hi there,
I currently try to write a simple math-parser in D.
However.. something isn't working and I just can't figure out what's the
problem.
(I'm relative new to D, and this is my first test to write a parser/lexer)
I'm pretty sure it's a simple layer-8-pro