Adventures of a Programmer: Parser Writing Peril XXVI

Refinement of the Grammar

Ok, some repair was also involved, I have to admit it but I am not that kind of genius who has it right the first time and always the first time! Are there any out there?
But back to the point—as if I ever had one—and the details:

The new grammar is available at

  • Addition of the Object because I forgot it
  • Changed the function-definition and put it into the statement list and order
  • Ripped the cf-literal out, was to much trouble to get it differ from the matrix but if you have any idea…
  • added some syntactic sugar (shamelessly stolen from GP/PARI), namely
    • forprime
    • fordiv
    • sumdiv
    • sum
    • prod

    They have all the same syntax, so it is easy to add more (e.g.: intnum, intcirc, sumalt etc.)

      "(" variable-declaration  ";"
           ( *1expression )


    let primorial = 1;
      primorial = primorial * start;

    Must print the primorial of 100, which is 2305567963945518424753102147331756070. Please, do not compute a primorial this way, there are faster methods to do it. There will be a large library, too, with a lot of these functions if a better method than the most simple is available.

  • Addition of a keyword for variable and function declaration. More than half of the syntax was stolen from ECMAScript already, so why not take a little bit more? But to my very disappointment that more made it necessary to add these keywords
    • If I do not find any other problems this grammar is the final grammar until somebody finds bugs and other inconsistencies and we need a new one. The latter is the most likely future to expect.

      Next: the actual JISON-parser with code to grab and print the resulting AST. At least that’s planned for.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.