Click here to Skip to main content
15,886,199 members
Articles / Programming Languages / Markdown

Pck/Edit: A GUI for Building Parsers

Rate me:
Please Sign up or sign in to vote.
4.78/5 (11 votes)
16 Aug 2019CPOL2 min read 16.4K   254   12   3
Quickly and easily build parsers and tokenizers using Pck's editor

pckedit

Introduction

This is part of a series of articles on PCK - The Parser Construction Kit.

I've covered the FA/regex engine as well as the LL(1) and LALR(1) generation.

Rather than rehash that material, I encourage you to peruse it.

This is a small GUI editor for PCK and XBNF files that lets you generate PCKs, parsers and tokenizers rapidly.

Using the GUI

Simply create or load a document - usually an XBNF file.

You can edit XBNF files, PCK files, even C# and Visual Basic files in the editor. Depending on which type of document is active, the build menu may have some or all of the operations disabled.

Any build operations are done on the current active document.

Once you've entered it, use the Build menu to turn it into a parser, a tokenizer, or a PCK spec.

Note that to create a matching tokenizer for an LL(1) parser, you must use the menu item for the LL(1) version of the tokenizer, or create the tokenizer from an already factored PCK specification. Failure to do so will lead to a tokenizer with the wrong symbol table, which will cause the parser to fail to parse the input.

Messages, warnings and errors are reported in a the message view below the text editor. Clicking on a line will send you to the associated position in the relevant file if there is one - similar to Visual Studio. Often, there is no associated file, because the intermediary PCK is generated in memory and has no associated file. You can generate the PCK explicitly if you like. Then errors will have line numbers within the PCK document, even if that document hasn't been saved yet.

Unlike Visual Studio, the documents do not have to be saved for you to build from them, and building from them will not cause them to be saved. The only time a file is written is when you choose to save one.

You can set the code generation language in the Options menu but Visual Basic's code dom provider is buggy and probably won't work for you until I find a workaround that doesn't puke all over my design.

Points of Interest

I embedded an old copy of ICSharpCode.TextEditor into this project, which I use for syntax highlighting.

The editor was originally based on this submission by Qwertie, which has been modified extensively to be suited for this project.

History

  • 15th August, 2019 - Initial submission
This article was originally posted at https://github.com/codewitch-honey-crisis/pck

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
Just a shiny lil monster. Casts spells in C++. Mostly harmless.

Comments and Discussions

 
NewsGitHub has much improved version Pin
honey the codewitch22-Aug-19 7:02
mvahoney the codewitch22-Aug-19 7:02 
Generalwonderful! Pin
Southmountain17-Aug-19 9:21
Southmountain17-Aug-19 9:21 
GeneralRe: wonderful! Pin
honey the codewitch17-Aug-19 9:23
mvahoney the codewitch17-Aug-19 9:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.