mirror of
https://github.com/avinal/xeus-basic.git
synced 2026-01-10 23:28:36 +05:30
Merge pull request #4 from avinal/improved
Add binder, copyright header and gitpod
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.idea
|
.idea
|
||||||
.cache
|
.cache
|
||||||
|
./share/jupyter/kernels/xbasic/kernel.json
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
# SPDX-FileCopyrightText: 2021 Avinal Kumar <avinal.xlvii@gmail.com>
|
||||||
|
|
||||||
FROM gitpod/workspace-full:latest
|
FROM gitpod/workspace-full:latest
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
# SPDX-FileCopyrightText: 2021 Avinal Kumar <avinal.xlvii@gmail.com>
|
||||||
|
|
||||||
image:
|
image:
|
||||||
file: .gitpod.dockerfile
|
file: .gitpod.dockerfile
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
#[=============================================================================[
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
# SPDX-FileCopyrightText: 2021 Sarita Singh <saritasingh.0425@gmail.com>
|
||||||
|
# SPDX-FileCopyrightText: 2021 Avinal Kumar <avinal.xlvii@gmail.com>
|
||||||
|
#]=============================================================================]
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
||||||
|
|
||||||
# ---- Project ----
|
# ---- Project ----
|
||||||
|
|||||||
81
README.md
81
README.md
@@ -1,3 +1,82 @@
|
|||||||
# xeus-BASIC
|
|
||||||
|
```scala
|
||||||
|
`7MM***Yy. db .M***by. `7MMF' .g8***bg.
|
||||||
|
MM Yb ;MM: ,MI `Y MM .dP' `M
|
||||||
|
`7M' `MF' MM .P ,V^MM. `MMb. MM dM' `
|
||||||
|
`VA ,V' MMooon* ,M `MM `YMMNq. MM MM
|
||||||
|
XMX MM `Y. AbmmmqMA . `MM MM MM.
|
||||||
|
,V' VA. MM ,9 A' VML Mb dM MM `Mb. .'
|
||||||
|
.AM. .MA..JMMonald'AMA. .AMMA.`*Ybmmd* .JMML. `*bMond^
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
[](https://mybinder.org/v2/gh/avinal/xeus-basic/HEAD) [](https://github.com/avinal/xeus-basic/blob/master/LICENSE)
|
||||||
|
|
||||||
Jupyter Kernel for BASIC language
|
Jupyter Kernel for BASIC language
|
||||||
|
|
||||||
|
|
||||||
|
## Steps to run the project:
|
||||||
|
**You can directly click on *launch binder* badge above to use this kernel right in your browser.***
|
||||||
|
|
||||||
|
* Clone this repository.
|
||||||
|
|
||||||
|
* Download miniconda [link](https://conda.io/projects/conda/en/latest/user-guide/install/linux.html#installing-on-linux)
|
||||||
|
|
||||||
|
* Create a virual env
|
||||||
|
``` bash
|
||||||
|
conda create -n vbasic
|
||||||
|
```
|
||||||
|
* Activate virtual environment that you created
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda activate vbasic
|
||||||
|
```
|
||||||
|
* Install dependencies
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda install -c conda-forge jupyter xeus xtl nlohmann_json cppzmq
|
||||||
|
```
|
||||||
|
* Make a build directory to store all the build files
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir build && cd build
|
||||||
|
```
|
||||||
|
|
||||||
|
* Configure CMake
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
|
||||||
|
```
|
||||||
|
|
||||||
|
* Build the project
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
* Install application
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
* Launch Jupyter Notebook in the browser
|
||||||
|
|
||||||
|
```bash
|
||||||
|
jupyter notebook
|
||||||
|
```
|
||||||
|
|
||||||
|
* Launch Jupyter Notebook in the terminal
|
||||||
|
|
||||||
|
```bash
|
||||||
|
jupyter console --kernel=xbasic
|
||||||
|
```
|
||||||
|
|
||||||
|
## Created By
|
||||||
|
|
||||||
|
- [Sarita Singh](https://github.com/itssingh)
|
||||||
|
- [Avinal Kumar](https://github.com/avinal)
|
||||||
|
|
||||||
|
## Acknowledgement
|
||||||
|
|
||||||
|
The BASIC language parser used in this project is a modified version of the [basic](https://github.com/nanoflite/basic) project created by [Johan Van den Brande](https://github.com/nanoflite).
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
# SPDX-FileCopyrightText: 2021 Avinal Kumar <avinal.xlvii@gmail.com>
|
||||||
|
|
||||||
name: xeus-basic
|
name: xeus-basic
|
||||||
channels:
|
channels:
|
||||||
- conda-forge
|
- conda-forge
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
* SPDX-FileCopyrightText: 2021 Sarita Singh <saritasingh.0425@gmail.com>
|
||||||
|
* SPDX-FileCopyrightText: 2021 Avinal Kumar <avinal.xlvii@gmail.com>
|
||||||
|
*
|
||||||
|
* @file xbasic_interpreter.hpp
|
||||||
|
* @brief Jupyter Kernel Interpreter header file
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef XBASIC_INTERPRETER_HPP_
|
#ifndef XBASIC_INTERPRETER_HPP_
|
||||||
#define XBASIC_INTERPRETER_HPP_
|
#define XBASIC_INTERPRETER_HPP_
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#[=======================================================================[
|
#[=============================================================================[
|
||||||
SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
SPDX-FileCopyrightText: 2021 Avinal Kumar <avinal.xlvii@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Avinal Kumar <avinal.xlvii@gmail.com>
|
||||||
#]=======================================================================]
|
#]=============================================================================]
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(basic LANGUAGES C)
|
project(basic LANGUAGES C)
|
||||||
@@ -11,8 +11,8 @@ add_library(basic "")
|
|||||||
target_sources(basic PRIVATE ${BASIC_SRC})
|
target_sources(basic PRIVATE ${BASIC_SRC})
|
||||||
target_include_directories(basic PRIVATE include/basic)
|
target_include_directories(basic PRIVATE include/basic)
|
||||||
|
|
||||||
#add_executable(basic_exec main.cc)
|
add_executable(basic_exec main.cc)
|
||||||
#target_include_directories(basic_exec PRIVATE include/basic)
|
target_include_directories(basic_exec PRIVATE include/basic)
|
||||||
#target_link_libraries(basic_exec PRIVATE basic)
|
target_link_libraries(basic_exec PRIVATE basic)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,49 +6,13 @@
|
|||||||
* @brief Driver Code
|
* @brief Driver Code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #include <math.h>
|
|
||||||
// #include <readline/history.h>
|
|
||||||
// #include <readline/readline.h>
|
|
||||||
// #include <signal.h>
|
|
||||||
// #include <stdbool.h>
|
|
||||||
// #include <stdio.h>
|
|
||||||
// #include <string.h>
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "basic.hpp"
|
#include "basic/basic.hpp"
|
||||||
|
|
||||||
// extern bool __RUNNING;
|
|
||||||
// extern bool __STOPPED;
|
|
||||||
|
|
||||||
// static void sigint_handler(int signum) {
|
|
||||||
// signal(SIGINT, sigint_handler);
|
|
||||||
// if (__RUNNING) {
|
|
||||||
// __RUNNING = false;
|
|
||||||
// __STOPPED = true;
|
|
||||||
// printf("STOP\n");
|
|
||||||
// fflush(stdout);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static char *readline_gets() {
|
|
||||||
// char *line_read = readline("");
|
|
||||||
|
|
||||||
// if (line_read && *line_read) {
|
|
||||||
// add_history(line_read);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return line_read;
|
|
||||||
// }
|
|
||||||
std::string outputs;
|
std::string outputs;
|
||||||
// int out(int ch) {
|
|
||||||
// outputs += char(ch);
|
|
||||||
// return 1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// int in(void) { return getchar(); }
|
|
||||||
|
|
||||||
void replcc() {
|
void replcc() {
|
||||||
std::cout << " _ _ \n"
|
std::cout << " _ _ \n"
|
||||||
@@ -57,56 +21,22 @@ void replcc() {
|
|||||||
<< "| |_) | (_| \\__ \\ | (__ \n"
|
<< "| |_) | (_| \\__ \\ | (__ \n"
|
||||||
<< "|_.__/ \\__,_|___/_|\\___|\n"
|
<< "|_.__/ \\__,_|___/_|\\___|\n"
|
||||||
<< "(c) 2015-2016 Johan Van den Brande\n";
|
<< "(c) 2015-2016 Johan Van den Brande\n";
|
||||||
// using_history();
|
|
||||||
std::string input;
|
std::string input;
|
||||||
basic check;
|
basic check;
|
||||||
while (getline(std::cin, input)) {
|
while (getline(std::cin, input)) {
|
||||||
if (!input.compare("QUIT")) {
|
if (!input.compare("QUIT")) {
|
||||||
// check.~basic();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!check.evaluate_line(input)) {
|
if (!check.evaluate_line(input)) {
|
||||||
std::cerr << check.get_error() << "\n";
|
std::cerr << check.get_error() << "\n";
|
||||||
}
|
}
|
||||||
// basic_eval((char *)input.c_str());
|
|
||||||
if (input == "RUN") {
|
if (input == "RUN") {
|
||||||
std::cout << check.run();
|
std::cout << check.run();
|
||||||
}
|
}
|
||||||
// if (evaluate_last_error()) {
|
|
||||||
// std::cerr << "ERROR: " << evaluate_last_error() << "\n";
|
|
||||||
// clear_last_error();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
// clear_history();
|
|
||||||
}
|
|
||||||
|
|
||||||
void runcc(std::string filename) {
|
|
||||||
// std::fstream file(filename, std::ios::in);
|
|
||||||
|
|
||||||
// if (!file.is_open()) {
|
|
||||||
// std::cerr << "Can't open " << filename << std::endl;
|
|
||||||
// exit(EXIT_FAILURE);
|
|
||||||
// }
|
|
||||||
// std::string line;
|
|
||||||
// while (getline(file, line)) {
|
|
||||||
// basic_eval((char *)line.c_str());
|
|
||||||
// }
|
|
||||||
// file.close();
|
|
||||||
// basic_run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// signal(SIGINT, sigint_handler);
|
replcc();
|
||||||
// basic_init(1024 * 8, 2048);
|
|
||||||
// basic_register_io(out, in);
|
|
||||||
|
|
||||||
if (argc > 1) {
|
|
||||||
runcc(argv[1]);
|
|
||||||
} else {
|
|
||||||
replcc();
|
|
||||||
}
|
|
||||||
|
|
||||||
// basic_destroy();
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
12
postBuild
12
postBuild
@@ -1,9 +1,13 @@
|
|||||||
mkdir build
|
#! /bin/sh
|
||||||
|
|
||||||
cd build
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
# SPDX-FileCopyrightText: 2021 Avinal Kumar <avinal.xlvii@gmail.com>
|
||||||
|
|
||||||
echo $CONDA_PREFIX
|
# Create a directory for build
|
||||||
|
mkdir build && cd build || exit
|
||||||
|
|
||||||
cmake -D CMAKE_INSTALL_PREFIX=$CONDA_PREFIX ..
|
# Configure CMake
|
||||||
|
cmake -D CMAKE_INSTALL_PREFIX="/srv/conda/envs/notebook" ..
|
||||||
|
|
||||||
|
# Install the Kernel
|
||||||
make install
|
make install
|
||||||
@@ -1,3 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
* SPDX-FileCopyrightText: 2021 Sarita Singh <saritasingh.0425@gmail.com>
|
||||||
|
* SPDX-FileCopyrightText: 2021 Avinal Kumar <avinal.xlvii@gmail.com>
|
||||||
|
*
|
||||||
|
* @file main.cc
|
||||||
|
* @brief Jupyter Kernel main program
|
||||||
|
*/
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "xbasic/xbasic_interpreter.hpp"
|
#include "xbasic/xbasic_interpreter.hpp"
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
* SPDX-FileCopyrightText: 2021 Sarita Singh <saritasingh.0425@gmail.com>
|
||||||
|
* SPDX-FileCopyrightText: 2021 Avinal Kumar <avinal.xlvii@gmail.com>
|
||||||
|
*
|
||||||
|
* @file xbasic_interpreter.cpp
|
||||||
|
* @brief Jupyter Kernel Interpreter Implementation
|
||||||
|
*/
|
||||||
|
|
||||||
#include "xbasic/xbasic_interpreter.hpp"
|
#include "xbasic/xbasic_interpreter.hpp"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user