<commit_before># pc_parser
A simple pseudo-code parser, that generates runnable python code.

Inspired by this:

https://github.com/gbaman/Python-To-AQA-Pseudocode

and looking at this:

http://filestore.aqa.org.uk/subjects/AQA-GCSE-COMPSCI-W-TRB-PSEU.PDF

I decided to use this:

http://www.dabeaz.com/ply/

to build something that would turn Pseudo Code into real code.

(It's a component of a bigger project, but pretty much a stand-alone
implementation)




RELEASE NOTE
----

SMOKE TEST
---
Either:

    git clone https://github.com/whaleygeek/pc_parser

Or: Press the DOWNLOAD AS ZIP and unzip the zip archive

Then:

    cd pc_parser/build/release
    python pcode.zip < test.pc > test.py
    python test.py

KNOWN ISSUES
---
1. fileio.py and arrays.py have to be in your directory
2. there are ambiguities on global variables in functions depending on where declared
3. you can't write to global variables in functions 
4. python 2 support only (at the moment)
5. It strips out all your comments (at the moment)
6. No documentation at all (but read the AQA spec)
http://filestore.aqa.org.uk/subjects/AQA-GCSE-COMPSCI-W-TRB-PSEU.PDF



Suggested changes to the AQA grammar
---

The CASE statement is ambiguous, it generates a lot of
shift/reduce parse warnings. I have added WHEN prior to the case option expressions
to resolve this ambiguity in the grammar. This is because something like this:

    CASE a OF
    1: b <- 1 + 2
    -3: c <- 2 + 4
    ENDCASE
    
i.e. there are two possible outcomes, either b<-1 + 2 or b<-1 + 2 - 3
and hence the grammar is ambiguous.

readline and writeline take non quoted names for files as the filename parameter.
This is generally bad, because a filename could have spaces or other lexical symbols
in it, including a comma, like this

    writeline(myfile-with,name.txt, 4, "data")

I have mandated that filenames must be strings. This also then means that the
name of the file can now be a string variable as well as a string literal:

    writeline("myfile-with,name.txt", 4, "data")
    writeline(myfilename, 5, data)

<commit_msg>Added link to new OCR pseudo code spec in README.md<commit_after># pc_parser
A simple pseudo-code parser, that generates runnable python code.

Inspired by this:

https://github.com/gbaman/Python-To-AQA-Pseudocode

and looking at this:

http://filestore.aqa.org.uk/subjects/AQA-GCSE-COMPSCI-W-TRB-PSEU.PDF

I decided to use this:

http://www.dabeaz.com/ply/

to build something that would turn Pseudo Code into real code.

(It's a component of a bigger project, but pretty much a stand-alone
implementation)




RELEASE NOTE
----

SMOKE TEST
---
Either:

    git clone https://github.com/whaleygeek/pc_parser

Or: Press the DOWNLOAD AS ZIP and unzip the zip archive

Then:

    cd pc_parser/build/release
    python pcode.zip < test.pc > test.py
    python test.py

KNOWN ISSUES
---
1. fileio.py and arrays.py have to be in your directory
2. there are ambiguities on global variables in functions depending on where declared
3. you can't write to global variables in functions 
4. python 2 support only (at the moment)
5. It strips out all your comments (at the moment)
6. No documentation at all (but read the AQA spec)
http://filestore.aqa.org.uk/subjects/AQA-GCSE-COMPSCI-W-TRB-PSEU.PDF



Suggested changes to the AQA grammar
---

The CASE statement is ambiguous, it generates a lot of
shift/reduce parse warnings. I have added WHEN prior to the case option expressions
to resolve this ambiguity in the grammar. This is because something like this:

    CASE a OF
    1: b <- 1 + 2
    -3: c <- 2 + 4
    ENDCASE
    
i.e. there are two possible outcomes, either b<-1 + 2 or b<-1 + 2 - 3
and hence the grammar is ambiguous.

readline and writeline take non quoted names for files as the filename parameter.
This is generally bad, because a filename could have spaces or other lexical symbols
in it, including a comma, like this

    writeline(myfile-with,name.txt, 4, "data")

I have mandated that filenames must be strings. This also then means that the
name of the file can now be a string variable as well as a string literal:

    writeline("myfile-with,name.txt", 4, "data")
    writeline(myfilename, 5, data)


Note, OCR have also released a similar set of Pseduo Code guidelines here:
(section 5e)

http://www.ocr.org.uk/Images/170845-specification-accredited-as-level-gce-computer-science-h046.pdf

{'fraction_non_alphanumeric': 0.0778688524590164, 'fraction_numerical': 0.011839708561020037, 'mean_word_length': 3.441860465116279, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2666479', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1345, 'n_words': 599}