sudo apt-get install python3 python3-pip
pip3 install virtualenv
git clone [email protected]:b3xul/QR_flowchart_compiler.git
cd QR_flowchart_compiler
virtualenv .
source bin/activate
pip3 install -r requirements.txt
- Create text file in the chosen language (
miniC/source.c
) - Compile it to pseudo assembly using
python3 miniC/miniC_compiler.py
. It will internally useminiC_Lexer.py
andminiC_Parser.py
to compilesource.c
intosource.asm
- Input and output files can be customized using
python3 miniC/miniC_compiler.py -in <input-file> -out <output-file>
- Input and output files can be customized using
- Use
python3 generate_qr.py
to generate the qr corresponding tominiC/source.asm
and place it intominiC/source.png
- The input file format can be specified using
python3 generate_qr.py <format>
(Tested formats arebinary
andalphanumeric
) - Input and output files can be customized using
python3 generate_qr.py -in <input-file> -out <output-file>
- The input file format can be specified using
- Use
python3 decode_qr.py
to decode the qr contained inminiC/source.png
intominiC/decoded.asm
- Input and output files can be customized using
python3 decode_and_execute_QR.py -in <input-file> -out <output-file>
- Input and output files can be customized using
- Alternatively, use
python3 decode_qr.py -m camera
to decode the qr read from the pc webcam intominiC/decoded.asm
- Output file can be customized using
python3 decode_qr.py -m camera -out <output-file>
- Output file can be customized using
- Execute the decoded pseudoassembly with
java -jar miniC/interpreter.jar miniC/decoded.asm
The language is intended to be a simple textual representation of a flowchart. A valid file is composed of 2 parts separated by an empty line: node list and links list.
- Each node ("1D:ARE YOU USING THE LATEST VERSION OF THE PLUGIN X") is represented by:
- An integer (id of the node)
- P | D | T to indicate if the node is a Process, Decision, Terminal node
:
symbol- The string label of the node. We can choose to write the string labels in 2 ways:
- (ex1,ex2): Using only alphanumeric, uppercase symbols,
%*+./
special symbols and newlines. This allows us to create a QR in alphanumeric mode ( the newline is not accepted by the QR encoding, but I substitute it using the '$' symbol so that the text file is more readable ). In alphanumeric mode we can encode up to 4,296 characters. - (ex3): Using any character (except for the special characters used by the language:
$:-
). In binary mode we can encode up to 2,953 characters.
- (ex1,ex2): Using only alphanumeric, uppercase symbols,
- Each link links 2 nodes referred by their id using the
-
symbol:- 3-4 indicates a link without label
- 1-YES-2 indicates a link with a label
- 1-NO-3-4-YES-2 indicates a chain of links
- Create text file in the chosen language (
Flowchart/ex2.txt
) - Use
python3 generate_qr.py alphanumeric -in Flowchart/ex2.txt -out Flowchart/ex2.png
to generate the qr corresponding toFlowchart/ex2.txt
and place it intoFlowchart/ex2.png
- The input file format can be specified using
python3 generate_qr.py <format>
(Tested formats arebinary
andalphanumeric
) - Input and output files can be customized using
python3 generate_qr.py -in <input-file> -out <output-file>
- The input file format can be specified using
- Use
python3 decode_qr.py -in Flowchart/ex2.png -out Flowchart/decoded.txt
to decode the qr contained inFlowchart/ex2.png
intoFlowchart/decoded.py
- Input and output files can be customized using
python3 decode_and_execute_QR.py -in <input-file> -out <output-file>
- Input and output files can be customized using
- Alternatively, use
python3 decode_qr.py -m camera -out Flowchart/decoded.txt
to decode the qr read from the pc webcam intoFlowchart/decoded.txt
- Output file can be customized using
python3 decode_and_execute_QR.py -m camera -out <output-file>
- Output file can be customized using
- Now compile a python script from the decoded QR and execute it using
python3 Flowchart/flowchart_compiler.py -m graph
orpython3 Flowchart/flowchart_compiler.py -m interactive
. This will internally useflowchart_Lexer.py
andflowchart_Parser.py
to compileFlowchart/decoded.txt
intoFlowchart/program.py
and then execute the resulting script.- The script that will be generated depends on the mode selected:
graph
will generate a png containing the flowchart described by the content of the QR.interactive
will start an interactive session on the console to navigate the flowchart. - Input and output files can be customized using
python3 Flowchart/flowchart_compiler.py -in <input-file> -out <output-file>
- The script that will be generated depends on the mode selected: