Note that there are some explanatory texts on larger screens.

plurals
  1. POAdvice on Python Parser Generators
    text
    copied!<p>Hey guys, this is my first question here on Stack Overflow and I was wondering if I could ask the advice of people who know a bit more about Python and Parser Generators than I do.</p> <p>I've been given a task where I have to create a parser for a simple C-like language. I can use any programming language and tools I wish to create the parser, but I'm learning Python at the same time so it would be my prefered choice.</p> <p>There are a few restrictions my Parser has to follow. Firstly, it must be able to read in a text file that contains the following information:</p> <pre><code>kind1 : spelling1 kind2 : spelling2 kind3 : spelling3 . . . kindn : spellingn </code></pre> <p>Where each kind and spelling refer to the token type and value of the language. This file is the result of putting a sample of code through the language's lexical analyser.</p> <p>Secondly, I must be able to customise the output of the parser. Ideally I would like to output a file that has converted the kind:spelling list into another sequence of tokens that would be passed to the language's compiler to be converted into MIPS Assembly code. Here's a little example of the kind of thing I would like the parser to be able to produce:</p> <pre><code>%function int test %variable int x %variable int y %begin %if %id y , %id x &gt; %do %begin %return %num 0 %end %return %num 1 %end </code></pre> <p>It would be a great help if someone could advise me on existing Python Parser Generators and if I'd be able to achieve the sort of thing I'm looking for in the above examples.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload