Giter VIP home page Giter VIP logo

pseudoengine2's Introduction

PseudoEngine 2

A pseudocode interpreter designed to be compatible with the Cambridge IGCSE and A level pseudocode syntax

Demo

The REPL

The REPL stands for Read Execute Print Loop and is an interface where pseudocode statements can be entered. The statement is immediately executed after it is entered and the result or potential errors are printed to the console to make it easy for debugging.

> 5 + 2 * 3
11
> LEFT("ABCD", 2)
"AB"
> x <- 1 / 0

Runtime Error in file <stdin>:
Division by 0

Traceback:
Program, line 1, column 9

Usage

Launching the REPL

Lanuch the program directly by double clicking the executable
OR
Run it in the terminal with no arguements

Running files in the REPL

The REPL can be used to run files using RUNFILE <file>.
For example, here is a simple hello world program stored in the file hello.pseudo

OUTPUT "Hello World!"


Run it with RUNFILE hello.pseudo
Example output:

> RUNFILE hello.pseudo
==> Running file 'hello.pseudo'
Hello World!

==> Program exited successfully
> 

Tip: The program must be stored in the same folder as the executable or the full path of the program has to be mentioned when using RUNFILE

Running files from the terminal

Navigate to the executable and run it providing the path of the program file as an arguement similar to RUNFILE

Windows:

PseudoEngine2.exe <filepath>

Linux/Unix:

./PseudoEngine2 <filepath>

Make sure you replace PseudoEngine2 with the actual name of the executable or rename the executable

Examples

See examples

Building

Make sure cmake and a c++ compiler is installed, then clone the repository and inside its folder run the following commands:

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

The executable will be generated inside the build folder

pseudoengine2's People

Contributors

singularityt3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pseudoengine2's Issues

No READ Functionality?

Tried the following Pseudocode for testing purposes...


FUNCTION CheckFile(ThisFile : STRING) RETURNS BOOLEAN
    DECLARE Valid : BOOLEAN
    DECLARE ThisLine : STRING
    DECLARE Count : INTEGER

    Count <- 0
    Valid <- FALSE

    OPEN ThisFile FOR READ
    
    RETURN Valid
ENDFUNCTION

CALL CheckFile("test.txt")

Gives syntaxerror line 9. I suppose its because theres no read functionality yet...

Impossible to compile

Hi,

I tried to compile as indicated on both macOS Mojave (10.14) and Debian Bullseye (11).

I got error.

macOS

$ cmake -B build 
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/bin/ccache - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/ccache - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/user1/PseudoEngine2/build
$ cmake --build build --config Release
[  1%] Building CXX object CMakeFiles/PseudoEngine2.dir/cmake_pch.hxx.pch
In file included from <built-in>:1:
In file included from /Users/user1/PseudoEngine2/build/CMakeFiles/PseudoEngine2.dir/cmake_pch.hxx:5:
/Users/user1/PseudoEngine2/src/pch.h:11:10: fatal error: 'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
1 error generated.
gmake[2]: *** [CMakeFiles/PseudoEngine2.dir/build.make:77: CMakeFiles/PseudoEngine2.dir/cmake_pch.hxx.pch] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/PseudoEngine2.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

Debian:

$ cmake -B build -DCMAKE_BUILD_TYPE=Release
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/laurent/PseudoEngine2/build
laurent@debian-graphique-demo:~/PseudoEngine2$ cmake --build build --config Release
Scanning dependencies of target PseudoEngine2
[  1%] Building CXX object CMakeFiles/PseudoEngine2.dir/cmake_pch.hxx.gch
[  3%] Building CXX object CMakeFiles/PseudoEngine2.dir/src/lexer/symbolLexer.cpp.o
In file included from /home/laurent/PseudoEngine2/src/psc/types/types.h:7,
                 from /home/laurent/PseudoEngine2/src/psc/variable.h:5,
                 from /home/laurent/PseudoEngine2/src/psc/scope/context.h:6,
                 from /home/laurent/PseudoEngine2/src/psc/error.h:5,
                 from /home/laurent/PseudoEngine2/src/lexer/lexer.h:6,
                 from /home/laurent/PseudoEngine2/src/lexer/symbolLexer.cpp:4:
/home/laurent/PseudoEngine2/src/psc/types/datatypes.h:10:15: error: expected nested-name-specifier before ‘enum’
   10 |         using enum Type;
      |               ^~~~
In file included from /home/laurent/PseudoEngine2/src/psc/variable.h:5,
                 from /home/laurent/PseudoEngine2/src/psc/scope/context.h:6,
                 from /home/laurent/PseudoEngine2/src/psc/error.h:5,
                 from /home/laurent/PseudoEngine2/src/lexer/lexer.h:6,
                 from /home/laurent/PseudoEngine2/src/lexer/symbolLexer.cpp:4:
/home/laurent/PseudoEngine2/src/psc/types/types.h:217:22: error: ‘year_month_day’ in namespace ‘std::chrono’ does not name a type
  217 |         std::chrono::year_month_day date;
      |                      ^~~~~~~~~~~~~~
/home/laurent/PseudoEngine2/src/psc/types/types.h:221:41: error: expected ‘)’ before ‘date’
  221 |         Date(std::chrono::year_month_day date);
      |             ~                           ^~~~~
      |                                         )
In file included from /home/laurent/PseudoEngine2/src/psc/scope/context.h:7,
                 from /home/laurent/PseudoEngine2/src/psc/error.h:5,
                 from /home/laurent/PseudoEngine2/src/lexer/lexer.h:6,
                 from /home/laurent/PseudoEngine2/src/lexer/symbolLexer.cpp:4:
/home/laurent/PseudoEngine2/src/psc/array.h:48:2: warning: extra ‘;’ [-Wpedantic]
   48 | };
      |  ^
In file included from /home/laurent/PseudoEngine2/src/psc/scope/context.h:8,
                 from /home/laurent/PseudoEngine2/src/psc/error.h:5,
                 from /home/laurent/PseudoEngine2/src/lexer/lexer.h:6,
                 from /home/laurent/PseudoEngine2/src/lexer/symbolLexer.cpp:4:
/home/laurent/PseudoEngine2/src/psc/procedure.h:54:2: warning: extra ‘;’ [-Wpedantic]
   54 | };
      |  ^
gmake[2]: *** [CMakeFiles/PseudoEngine2.dir/build.make:98 : CMakeFiles/PseudoEngine2.dir/src/lexer/symbolLexer.cpp.o] Erreur 1
gmake[1]: *** [CMakeFiles/Makefile2:95 : CMakeFiles/PseudoEngine2.dir/all] Erreur 2
gmake: *** [Makefile:160 : all] Erreur 2

What are the dependecies/libraries to be installed before compiling ?

Binaries don't work

Hello,

The binaries you attached didn't work for my Windows computer, so I had to try it on a REPL.it.
Please try to fix the binaries, also add compile instructions for anyone to compile the program:

add set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) to CMakeLists.txt

then run

cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ PseudoEngine2
make

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.