Coder Social home page Coder Social logo

dariomrk / evalexpression Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 130 KB

An arithmetic expression evaluator built using .NET

License: MIT License

C# 100.00%
arithmetic-expression ast csharp dotnet8 evaluator interpreter lexer parser recursive-descent-parser

evalexpression's People

Contributors

dariomrk avatar

Watchers

 avatar

evalexpression's Issues

[OTHER]: Rename to EvalExpression

Issue type

Chores

Describe the solution you'd like

  • Update .sln in project root to reflect renaming changes
  • Update repository name
  • Update README title

Additional context

No response

[FEAT]: Implicit multiplication support

Related component

Parser

Describe the solution you'd like

Given the -2(3+1) expression, the parser should correctly output an AST like this:

BinaryNode Multiply
|
|__ UnaryNode Negative
|    |
|    |__ NumericLiteral 2
|
|__ BinaryNode Add
     |
     |__ NumericLiteral 3
     |__ NumericLiteral 1

Additional context

No response

[BUG]: Negative operator not parsed correctly

Affected component

Parser

Bug description

The UnaryNode of type Negative does not get evaluated correctly.

Related unit test case:

[Fact]
public void ImplicitNegativeNumber()
{
    // expression: -2
    var input = new List<Token>
    {
        new Token(TokenType.Hyphen, "-"),
        new Token(TokenType.Number, "2"),
        new Token(TokenType.EndOfFile, null),
    }.AsEnumerable();

    var expected = new UnaryNode(
        NodeType.Negative,
        new NumericLiteralNode(2));

    var parser = new Parser.Parser(input);
    var actual = parser.Parse();

    Assert.Equal(expected, actual);
}

Steps to reproduce

No response

Expected result

The UnaryNode of type Negative should always correctly precede:

  • parenthesized expressions
  • any other operator, regardless of that operator's precedence.

Relevant log output

No response

[OTHER]: Update docs

Issue type

Documentation

Describe the solution you'd like

  • Update README

    • Add more samples
    • Cleanup features section
  • Add documentation comments to the codebase

    • At minimum add doc comments to public APIs

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.