The App

OK, Let’s explore the app.

_images/screenshot-3-flags.png

The App is used to generate the parser code from source. The source is written in an external editor. You point the app to the source file and select the Generate button. Let’s go through each section.

Input

This is the section where you point to the source file as well as provide the name of your parser. The file can have any extension. On the other hand, our official extensions are .algodal-parser or .parser so feel free to use either.

The you provide the parser must be C naming variables compliant. That’s is no spaces, no dashes, must start with a letter, etc.

Here is a screenshot of a sample parser code in vscode:

_images/screenshot-7-lang-simple.png

The only required field in the app is the Input File - everything else is optional.

Output

By default, the generated parser file is saved in a folder called Output relative to the App binary. You can change which folder the generated parser file is saved into using the Output Folder field.

Note

C lingo is used to describe the actions of some of these flags. You can take a quick look at the C language to understanding the meaning of terms like declare (declarations), define (definitions), include (includes), etc.

The Flags fields allows you to chose how the the code is generated and set preprocessor flags in the code to control default behaviour.

  1. Separate Files

    By default, a single C file is generate which contains the program, (optionally) the machine and (optionally) a main program (for quick demo). If you check this flag, you can store each component in a separate file.

  2. Separate Header

    By default, declarations are written into the file along with definitions code. If this flag is checked then declarations code is stored in a header file and other files include said file.

  3. Exclude VM

    This excludes the machine code from being generated.

    • Store Non-Terminal Strings

      AST generated do not have string values for non-terminal nodes by default. This flag does the opposite.

  4. Exclude Main

    This excludes the main code from being generated. (This refering to demo code which contains a main() function)

    • No Printing

      The main code include a lot of printing for feedback. You can turn them off with this flag.

    • Print Using Export

      Demonstrate the export feature.

  5. Generate JSON

    Generate the Program as JSON.

Generate

Finally, the generate button. You press this to generate your parser.