Discussion Small Basic Parser Generator

  • Saturday, October 06, 2012 11:58 AM
    Answerer
     
     

    I wrote a parser generator written in Small Basic.  I'm going to introduce parser generator series in this thread.

    Program list of this thread:

    • Parser Generator 0.4 (XWX066) generates Graphics Interpreter
    • Parser Gererator 1.3 (ZBG977-3) generates Code Block Generator (SKC235-1)

    The first article:

    Parser is a program which analyses program language syntax and does something.  That will be a compiler, an interpreter, a program formatter, a program converter, or etc.

    The first one is a parser generator which generates a Small Basic Graphics Interpreter.  The program ID is XWX066. (Small Basic Parser Generator 0.4)

    Please save this program as "ParserGenerator04.smallbasic".

    Lines 23 and 918 are commented out automatically by Small Basic server, so comment in these lines before running.


    Nonki Takahashi





All Replies

  • Saturday, October 06, 2012 4:57 PM
    Answerer
     
     
    In program XWX066, I added code what to do into it.  So, this program became an interpreter generator.  I'm planning to separate parser generator and what to do.  After that the parser generator will read code what to do from the other source program.

    Nonki Takahashi

  • Saturday, October 06, 2012 11:47 PM
    Answerer
     
     

    Inside of Parser Generator 0.4 (XWX066)

    This program generates a interpreter named "SBGInterpreter04.smallbasic".

    • Subroutines start with Exec_, Lex_ and SBGI_ will be copied to the interpreter.
    • Subroutines start with PG_ are parser generator itself.  PG_Init is a core subroutine and contains syntax of Small Basic graphics as BNF format (but not strict BNF here).
    • Subroutine SB_GetSub gets subroutine source code from given file name.

    Language syntax is defined as BNF.  So, many languages can be parsed by changing BNF, such as Small Basic (of course), old type of BASIC, any markup languages or BNF itself etc.

    * BNF : Backus-Naur Form 


    Nonki Takahashi

  • Saturday, October 06, 2012 11:50 PM
     
     
    Oh, thanks for the explanation. I didn't know what a parser generator was.

    I am a 10 year old that loves math, games, and computers. "Everyone is potentially great, you just have to turn it into kinetic greatness."

  • Friday, October 26, 2012 11:36 AM
    Answerer
     
     

    Today I published another parser generator, Parser Generator 1.1b (ZBG977) which generates a code block generator (SKC235).

    Generated code block generator is a tool to generate HTML Small Basic code block especially for TechNet Wiki article for Small Basic.

    This tool is still beta version.

    Preview screen

    Generated code

    Known issue:

    • Preview frame or code sometimes remain on screen when width or height changed.
    • It tooks few minutes for large program.
    • Null line will be overrode by next line in web browser.

    Nonki Takahashi

  • Sunday, October 28, 2012 11:13 AM
    Answerer
     
     

    Today I published another parser generator, Parser Generator 1.3 (ZBG977-3) which generates a code block generator (SKC235-1).

    Known issue:

    • It tooks few minutes for large program both after [OK] and after Ctrl+A.


    Nonki Takahashi


  • Sunday, October 28, 2012 9:49 PM
     
     

    Wow - this is extremely impressive.

    I've done some work with language implementation myself but using parsing expression grammars etc. - rolling it all yourself, and in Small Basic, is quite the achievement.

  • Monday, October 29, 2012 2:09 AM
    Answerer
     
     
    Nik, Thank you.

    Nonki Takahashi

  • Monday, October 29, 2012 5:40 AM
     
     
    OK, forgive me if this is covered in another thread, I haven't had time to look through them, but it's just occurred to me that you could use this to extend the language while still generating code that will run in the existing IDE/Silverlight plugin - if so, very, very cool!
  • Monday, October 29, 2012 8:53 AM
    Answerer
     
     

    Do you mean to select other programming languages?

    If so, I don't have any plan about that at this point.  TechNet Wiki has it's tool to add code block and that tool has ability to select Markup - (x)HTML, XML, ASPX,... -, Javascript, C#, CPP, VB, Php, SQL, Delphi, and Python.


    Nonki Takahashi