Results 1 to 1 of 1
  1. #1
    Yemiez's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Sweden
    Posts
    2,566
    Reputation
    731
    Thanks
    16,280
    My Mood
    Devilish

    Expression Parser Theoretical Introduction

    Introduction
    Version ep1x2
    Expression Parser originally started out as a simple expression parser, or as any normal person would refer to it as, a calculator; hence the name. I’m one hundred percent open to naming suggestions, semantic suggestions, and miscellaneous improvements. As always, any critique is highly appreciated, good or bad, ep will always aim to help the community create a well-endowed scripting language, with many neatly equipped libraries and frameworks on the side. Ep is designed to function alongside C++ with methods created inside of ep that can be directly called from C++ code; however, a correct function signature must be provided for ep to be able to build a standard function object.

    Semantics
    I’m only going to give a core overview of the semantics in ep, because it’s hard for me to explain, I’m not the absolute best at every single programming term and definition. I’ll try my best to give you the best possible overview on the three core semantical aspects of ep, the following words rvalue, lvalue, and reference are terms you’re going to hear a lot about, as they’re the core features of ep’s semantics.

    Lvalue, a simple semantical term to define, an lvalue is a part of an expression or statement, whose lifetime expectancy is greater than the statement’s lifetime. If you haven’t quite caught up with the whole concept yet, it’s basically whenever you use a variable in an expression or statement.

    However, an rvalue isn’t as easily defined, you as the programmer will never logically see the rvalue. It’s the interpreter’s way of saying ‘Hey, this value is only going to be used once, so why should we keep it alive in memory? Let’s just erase it!’, it’s lifetime is never longer than the statement or expression’s lifetime.

    What you’ve probably noticed, is that, the names of these two terms are extremely similar, that’s because they often correlate in many ways. When you assign an lvalue to an rvalue, the interpreter is basically saying ‘Wow, well, instead of copying the rvalue’s value, why don’t we just sneak over and steal the value from the rvalue!’.

    References are also very simply defined, they are simply just referencing another variable in memory, when you pass an argument as a reference, you’re giving the method all the permission in the world to modify, or completely change the type of the argument. When you pass an rvalue as a reference the rvalue stays alive for as long as that statement, which is equal to the lifetime of the method; hence all modifications made to the reference are simply discarded along with the rvalue itself.

    Optimization
    Ep has a few ways to optimize the interpreted code, you see having no optimization would result in poor performance, as humans often like to follow guidelines that prefer elegancy over performance. The optimization algorithms work to reformat the provided code blocks into a more, performance oriented block of code. The core optimization algorithms consist of three sub-algorithms that work independently with said sub-algorithms.

    Return omit optimization is the very first algorithm being ran on the provided block of code, this doesn’t really increase performance in any, all this does is reduces the memory usage of the block of code by omitting all statements after a return statement, however only in the current scope of said return statement. (Note: return omit is a modification of dead code optimization)

    Dead code omit optimization is specifically running second, because firstly; this optimization could possibly add extra overhead to the optimizer if it was running before the return omit algorithm, considering that empty expressions may be present after a return statement. Secondly, the third algorithm needs to run after this one, because otherwise the third algorithm may go through and change these empty, useless, and overhead creating statements. The name defines the algorithm very well; it simply omits all statements that have nothing but an empty expression that doesn’t modify anything.

    Constant folding optimization is a little more complex to implement than the previously mentioned ones, but it’s purpose is to reduce the amount of evaluations needed to be done at run-time, thus increasing the performance and at the same time reducing the code size. Because having the interpreter evaluate 10 to the power of 9 at run-time isn’t exactly performance friendly compared to directly having the parser replace the equation of 10 to the power of 9 with a constant number equalling a billion.
    I hope all of this makes sense to the less experienced developers reading this, I tried the best I could with my limited experience in this subject to explain these slightly complex algorithms used to optimize code blocks.

    What real world problem is Expression parser trying to solve?
    As far as I'm concerned, Expression parser is simply trying to solve how easily MPGH's developers can create cheats.
    Firstly, Expression parser offers the option for developers of the community to pitch in and comment on certain parts of their code, making it a community process to improve and develop better techniques.
    Secondly, Expression parser heavily simplifies the process of creating cheats and miscellaneous applications, because of its embedded nature there is never a need to recompile your backend C++ engine once it’s compiled, because the front-end cheat development is done in scripts.
    Lastly, as aforementioned; because of Expression parser’s simple nature, it helps reduce public code bases, and when written correctly can produce neat and well flowing code, making it both easier for the developer and any readers to understand and follow said code.

    Sincerely,
    Yamiez.
    Last edited by Hero; 10-02-2016 at 01:02 PM.

  2. The Following 5 Users Say Thank You to Yemiez For This Useful Post:

    [MPGH]Ahl (10-05-2016),[MPGH]Hero (10-02-2016),[MPGH]Mayion (10-05-2016),MegaProphet (11-24-2016),pean153 (10-01-2016)

Similar Threads

  1. Noob Introduction Thread
    By Dave84311 in forum General
    Replies: 396
    Last Post: 06-03-2009, 11:58 AM
  2. [REQUEST]VB Express 2005 Trainer Making Tut
    By sr25lover in forum General Game Hacking
    Replies: 2
    Last Post: 05-29-2007, 05:59 AM
  3. Let's express our disconserting anger!
    By arunforce in forum General
    Replies: 19
    Last Post: 01-31-2007, 07:00 PM
  4. iets introduction post
    By EleMentX in forum Spammers Corner
    Replies: 21
    Last Post: 12-11-2006, 04:40 PM
  5. [request] Introduction to game hacking
    By Unf4mili4r in forum Suggestions, Requests & General Help
    Replies: 8
    Last Post: 07-27-2006, 03:28 PM