Results 1 to 6 of 6

Thread: Test my expression compiler!!

  1. #1

    Thread Starter
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Test my expression compiler!!

    I have written an expression compiler for a template system I am creating for PHP. The purpose of the compiler it to convert an expression written in the template into PHP code. I had the following aims with regard to creating the compiler:
    • The compiler must parse the expression and upon finding an error, flag its location in the original string and stop compiling the expression.
    • The expression compiler must not allow arbitrary text through to the output PHP code as this could be used to inject PHP code into the output expression.


    The above is easier said than done and creating a parse tree was a real pain. The compiler is now almost complete and I would appreciate some testers. The below link takes you to a simple interface whereby an expression can be entered and compiled, showing the result. If you enter an invalid expression it should fail and report the location at which it failed.

    Please let me know if you find any errors and what you entered to generate the error. Also any expressions that violate the above mentioned conditions.

    http://php5.codedv.com/expression_driver.php

    Below is a list of rules for the expression language:
    • Templates can contain variables, these are accessed using the variable name which must start with a letter and contain only letters numbers and underscores. e.g: varname1
    • An array type variable can have its indexed accessed as follows: array['stringIndex'] OR array[1] (integer index). The text between the square brackets may be an expression too: array[array2[1] - 4] arrays within arrays can be accessed too array[1][2].
    • An object type variable may access public properties using the following notation: object.property, object.arrayProperty['array_index']
    • Any strings are contained within single quotes with single quotes being escaped with a backslash: 'Adam\'s string'.
    • Expressions can contain any number of nested parentheses.
    • Logical operators supported: AND, OR, NOT
    • Bitwise operators supported: BAND (bitwise AND), BOR (bitwise OR), BXOR (bitwise XOR)
    • Comparison operators: = (equality), <=, <, >=, >
    • Arithmetic operators supported: +, -, / (division) , *, MOD (modulus), - (negetation)


    Happy compiling.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Test my expression compiler!!

    I'm almost impressed. This doesn't suck as badly as your other projects.
    I don't live here any more.

  3. #3

    Thread Starter
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Test my expression compiler!!

    List of bugs below:
    • trailing newlines throw and error (fixed)
    • negetation without leading spaces (e.g. 1--1) (fixed)
    • leading underscores not allowed in variable names (they should be) (fixed)
    • array indexes of object type whose property is of an array type do not parse correctly. e.g: a[1].prop[4] (fixed)
    • Expressions containing multi-character operators preceding variable names do not compile. e.g: 2 OR 2 + var[0]
    Last edited by visualAd; Jul 3rd, 2007 at 10:04 AM.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Test my expression compiler!!

    You are not worthy to ask.

  6. #6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width