Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

A Calculation Engine for .NET

, 1 Sep 2013
A calculation engine that is small, fast, and extensible.
''' <summary>
''' Represents a node in the expression tree.
''' </summary>
Friend Class Token

    ' Fields
    Public ID As TKID
    Public Type As TKTYPE
    Public Value As Object

    ' Methods
    Public Sub New(ByVal value As Object, ByVal id As TKID, ByVal type As TKTYPE)
        Me.Value = value
        Me.ID = id
        Me.Type = type
    End Sub
End Class

''' <summary>
''' Token ID (used when evaluating expressions)
''' </summary>
Friend Enum TKID
    GT
    LT
    GE
    LE
    EQ
    NE
    ADD
    [SUB]
    MUL
    DIV
    DIVINT
    [MOD]
    POWER
    OPEN
    CLOSE
    [END]
    COMMA
    PERIOD
    ATOM
End Enum

''' <summary>
''' Token types (used when building expressions, sequence defines operator priority)
''' </summary>
Friend Enum TKTYPE
    [COMPARE] ' // < > = <= >=
    ADDSUB ' + -
    MULDIV ' * / 
    POWER ' ^
    GROUP ' ( ) , .
    LITERAL ' 123.456 "Hello"
    IDENTIFIER ' functions, variables, bindings
End Enum

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Bernardo Castilho
Chief Technology Officer ComponentOne
United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 1 Sep 2013
Article Copyright 2011 by Bernardo Castilho
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid