Git Product home page Git Product logo

kparser's Introduction

KParser

Arithmetic Expression Parser Koltin Multi-Platform Library

Build Status Download License

Features

  • Evaluated in Degrees and Radians

  • Handle Multiple Operators

    • Minus (-)
    • Plus (+)
    • Multiply (*)
    • Division (/)
    • Power (^)
    • Exponential (E)
  • Mathematical Functions

    • Trigonometric (Sin, Cos, Tan, asin,acos,atan)
    • Hyperbolic (Sinh, Cosh, Tanh)
    • Log10,
    • ln (Natural log)
    • Log2()
    • LogX() (where X = base)
    • sqrt(Square root)
    • ! (Factorial)
    • % (Percentage)
  • Mathematical Constants

    • PI
    • e

Sample

JVM/Android

val parser = ExpressionParser()
val result = parser.evaluate("sin(PI)+1+cos(PI)")
println(result)
        
// result 0.0

C/C++

build the project with ./gradlew build

Navigate to KParser/build/bin/linux/releaseShared/

Use the generated libkparser_api.h (header file) and libkparser.so (shared object file)

#include <iostream>
#include "libkparser_api.h"

int main() {
    
    libkparser_ExportedSymbols* lib = libkparser_symbols();
    libkparser_kref_io_thelimitbreaker_ExpressionParser kparser = libkparser_kref_io_thelimitbreaker_ExpressionParser();

    double  result = lib->kotlin.root.io.thelimitbreaker.ExpressionParser.evaluate(kparser,"1+sin(PI)+cos(PI)",3);
    std::cout<<result << std::endl;
    return 0;
}

Compiling C/C++ (Command Line)

g++ main.cpp libkparser.so

Compiling C/C++ (CMake config)

Provided libkparser_api.h and libkparser.so are under folder kparser

add_library(kparser SHARED IMPORTED)
set_property(TARGET kparser PROPERTY IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/kparser/libkparser.so")
add_executable(PROJECT_NAME main.cpp kparser/libkparser_api.h)
target_link_libraries(${PROJECT_NAME} kparser)

Usage with Gradle(JVM/Android)

 // In root build.gradle
 repositories {
        maven {
            url  "https://dl.bintray.com/kaendagger/KParser"
        }
  }
  
  //Add in the dependencies
  dependencies{
         implementation 'io.kaen.dagger:KParser-jvm:0.1.1'
  }
    

Android App sample : Kalc-Android

Native App Sample : Kalc-Native

Work Left

  • Add usage with JS
  • Add support Windows and iOS

kparser's People

Contributors

rotbolt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

kparser's Issues

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.