Skip to content

Commit

Permalink
Added Lauryn Brown's Cisp
Browse files Browse the repository at this point in the history
A
  • Loading branch information
DillonDepeel committed May 1, 2023
1 parent 59cfa53 commit 9bd6fc3
Show file tree
Hide file tree
Showing 51 changed files with 1,184 additions and 0 deletions.
104 changes: 104 additions & 0 deletions Cisp/Cisp-master/Cisp-master/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Generated C files
*.c
*.c.*
*.i
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject

# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# session
Session.vim
# temporary
.netrwhist
*~
21 changes: 21 additions & 0 deletions Cisp/Cisp-master/Cisp-master/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Lauryn Brown

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
82 changes: 82 additions & 0 deletions Cisp/Cisp-master/Cisp-master/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Cisp
A Common Lisp Interpreter Built in COBOL.

## Overview
### Purpose
This is a small project built by a student at the Recurse Center to express a love for COBOL and better understand it.

Due to COBOL's lack of functions and recursion, the recursion required for Lisp is built from the ground up using file processing. Also, due to the lack of a widely supported debugger, a system logger was also implemented.

### Compatibility
Please note that Cisp is currently only actively developed for Windows. \*Nix users may experience issues.

### Functionality
All features are currently in development. This is a list of what is to come.
- Representation of Symbols and Numbers ![Ongoing Development](https://img.shields.io/badge/Development-Ongoing-green.svg?style=flat-square)
- Basic Arithmetic ![Ongoing Development](https://img.shields.io/badge/Development-Ongoing-green.svg?style=flat-square)
- Flow-Control Statements ![Not Currently in Development](https://img.shields.io/badge/Development-No-green.svg?style=flat-square)
- Lists ![Not Currently in Development](https://img.shields.io/badge/Development-No-green.svg?style=flat-square)
### Notes
The README much like the entire project is in current development.

## Running Cisp
### Hello World
1. Make a subdirectory for your lisp file.
```cmd
mkdir test\helloworld
```
2. Create a new file `helloworld.lisp` in your subdirectory containing the following:
```lisp
(print "HelloWorld!")
```
3. To run Cisp cd into the bin (Note that you must cd in)

```cmd
cd bin
```
4. Run Cisp

```cmd
cisp.exe ..\test\helloworld\helloworld.lisp
```

### Project Structure
Currently the COBOL source files are located in the root directory.
#### Directories
* bin - Contains all necessary \*.dll's (windows users) for those who want to play with CISP without changing the code. This is due to the fact that so few people have COBOL compilers.
* logs - Contains the log file generated by the system.
* test - Contains all test files organized by subject.
#### COBOL Files
* cisp.cbl - The main COBOL program.
* cisp-error.cbl - The Error System in the program. It will "throw" errors when called.
* lisp.cbl - Responsible for executing the lisp program.
* logger.cbl - The Logging System in the program. It will log events in the system when called.
* recursion.cbl - Handles recursion as requested from lisp.cbl.
* tokenizer.cbl - Responsible for tokenizing the lisp file given to execute.

### Compiling
The easiest way I have found to compile COBOL is [GNU's COBOL compilier](https://sourceforge.net/projects/open-cobol/). For those who prefer IDE's I have found [Open COBOL IDE](http://opencobolide.readthedocs.io/en/latest/download.html) to be very helpful.
### Running Tests
#### Windows
To run all tests in the project, double click `bin\cisp.bat`

To run a single test:
`cd bin`

`cisp.exe ..\test\test_subdirectory\test_name.lisp`

#### Create your own Lisp Files for Testing
1. Create a directory in `test\` to create another test category.
2. In your subdirectory create a lisp file.
3. `cd bin`
4. `cisp.exe ..\test\test_subdirectory\test_name.lisp`
#### Linux
Instructions yet to come. The author is a window's user, and \*nix systems are not currently supported.

A high level overview is to compile the project and run the executable in the bin folder.
## Developing Cisp
### How Cisp Works
### Log to Log File
Coming soon.
### Throw an Error
Coming soon.
Binary file added Cisp/Cisp-master/Cisp-master/bin/LISP.exe
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/TOKENIZER.exe
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/cisp-error.dll
Binary file not shown.
15 changes: 15 additions & 0 deletions Cisp/Cisp-master/Cisp-master/bin/cisp.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cls
@ECHO OFF
SET test_dir=..\test\
ECHO %test_dir%
for /f "delims=" %%d in ('dir /b %test_dir%') do (
ECHO --------------------------
ECHO Test Directory: %%d
for /f "delims=" %%f in ('dir /b "%test_dir%%%d"') do (
ECHO File:%test_dir%%%d\%%f
TYPE %test_dir%%%d\%%f
CALL cisp.exe %test_dir%%%d\%%f
)
)
PAUSE
EXIT
Binary file added Cisp/Cisp-master/Cisp-master/bin/cisp.exe
Binary file not shown.
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libatomic-1.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libcharset-1.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libcob-4.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libdb-6.2.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libexpat-1.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libgmp-10.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libgmpxx-4.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libgomp-1.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libiconv-2.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libintl-8.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libmpc-3.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libmpfr-4.dll
Binary file not shown.
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libssp-0.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/libstdc++-6.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/lisp.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/logger.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/mingwm10.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/pdcurses.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/pthreadGC-3.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/recursion.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/tokenizer.dll
Binary file not shown.
Binary file added Cisp/Cisp-master/Cisp-master/bin/zlib1.dll
Binary file not shown.
67 changes: 67 additions & 0 deletions Cisp/Cisp-master/Cisp-master/cisp-error.cbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
******************************************************************
* Author:
* Date:
* Purpose:
* Tectonics: cobc
******************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. CISP-ERROR.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
*****************************************
* WS Shared with LOGGER SubRoutine
*****************************************
01 WS-LOG-OPERATION-FLAG PIC X(5).
01 WS-LOG-RECORD.
02 WS-LOG-RECORD-FUNCTION-NAME PIC X(40).
02 WS-LOG-RECORD-MESSAGE PIC X(100).
*****************************************
* WS Shared with RECUSRION SubRoutine
*****************************************
01 WS-RECURSION-FLAG PIC X(30).
LINKAGE SECTION.
01 LS-CISP-ERROR-FLAG PIC X(30).
01 LS-ERROR.
02 LS-ERROR-NAME PIC X(40).
02 LS-ERROR-FATAL PIC X.
88 LS-ERROR-FATAL-YES VALUE 'Y', FALSE 'N'.
02 LS-ERROR-MESSAGE PIC X(100).
PROCEDURE DIVISION USING LS-CISP-ERROR-FLAG, LS-ERROR.
MAIN-PROCEDURE.
EVALUATE LS-CISP-ERROR-FLAG
WHEN "THROW-ERROR"
PERFORM THROW-ERROR-PROCEDURE.
THROW-ERROR-PROCEDURE.
DISPLAY LS-ERROR-NAME.
DISPLAY LS-ERROR-MESSAGE.
IF LS-ERROR-FATAL-YES THEN
PERFORM END-CISP-PROCEDURE
END-IF.
END-CISP-PROCEDURE.
PERFORM LOG-ERROR-PROCEDURE.
PERFORM CLOSE-OPEN-FILES-PROCEDURE.
STOP RUN.
LOG-ERROR-PROCEDURE.
******log error
MOVE "ADD" TO WS-LOG-OPERATION-FLAG.
MOVE "CISP-ERROR" TO
WS-LOG-RECORD-FUNCTION-NAME.
STRING LS-ERROR-NAME DELIMITED BY SIZE
":" DELIMITED BY SIZE
LS-ERROR-MESSAGE DELIMITED BY SIZE
"Fatal:" DELIMITED BY SIZE
LS-ERROR-FATAL DELIMITED BY SIZE
INTO WS-LOG-RECORD-MESSAGE.
CALL 'LOGGER' USING WS-LOG-OPERATION-FLAG, WS-LOG-RECORD.
CLOSE-OPEN-FILES-PROCEDURE.
MOVE "STACK-FILE-STATUS" TO WS-RECURSION-FLAG.
CALL "RECURSION" USING WS-RECURSION-FLAG.
DISPLAY "RECURSION:" WS-RECURSION-FLAG.
IF WS-RECURSION-FLAG = "Y" THEN
MOVE "CLOSE" TO WS-RECURSION-FLAG
CALL "RECURSION" USING WS-RECURSION-FLAG
END-IF.
MOVE "CLOSE" TO WS-LOG-OPERATION-FLAG.
CALL 'LOGGER' USING WS-LOG-OPERATION-FLAG, WS-LOG-RECORD.
END PROGRAM CISP-ERROR.
78 changes: 78 additions & 0 deletions Cisp/Cisp-master/Cisp-master/cisp.cbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
******************************************************************
* Author: Lauryn Brown
* Date: 2017
* Purpose: COBOL Common Lisp Interpreter
* Tectonics: cobc
******************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. CISP.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT TESTS-FILE ASSIGN TO "..\test\tests-lists.txt"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD TESTS-FILE.
01 LISP-TEST-FILE-NAME PIC X(100).
WORKING-STORAGE SECTION.
01 WS-CMD-LINE.
02 WS-CMD-LINE-VAL PIC X(100).
02 WS-CMD-LINE-NUM-AGRS PIC 9(4).
*****************************************
* WS Shared with LOGGER SubRoutine
*****************************************
01 WS-LOG-OPERATION-FLAG PIC X(5).
01 WS-LOG-RECORD.
02 WS-LOG-RECORD-FUNCTION-NAME PIC X(40).
02 WS-LOG-RECORD-MESSAGE PIC X(100).
*****************************************
* WS Shared with TOKENIZER, LISP SubRoutine
*****************************************
*****IF WS-SYMBOL-LENGTH CHANGED HERE PLEASE CHANGE IN TOKENIZER, LISP
01 WS-LISP-FILE-NAME PIC X(100).
78 WS-SYMBOL-LENGTH VALUE 100.
01 WS-LISP-SYMBOLS.
02 WS-SYMBOL-TABLE-SIZE PIC 9(4).
02 WS-SYMBOL PIC X(50) OCCURS WS-SYMBOL-LENGTH TIMES.
02 WS-SYMBOL-LEN PIC 9(2) OCCURS WS-SYMBOL-LENGTH TIMES.
PROCEDURE DIVISION.
MAIN-PROCEDURE.
PERFORM INIT-LOGGER-PROCEDURE.
PERFORM READ-CMD-LINE-PROCEDURE.
PERFORM TOKENIZE-LISP-PROCEDURE.
PERFORM EVALUTE-LISP-PROCEDURE.
PERFORM CLOSE-LOGGER-PROCEDURE.
GOBACK.
READ-CMD-LINE-PROCEDURE.
********* Read the lisp file name and save to working storage
ACCEPT WS-CMD-LINE-NUM-AGRS FROM ARGUMENT-NUMBER.
ACCEPT WS-CMD-LINE-VAL FROM ARGUMENT-VALUE.
MOVE WS-CMD-LINE-VAL TO WS-LISP-FILE-NAME.
MOVE "ADD" TO WS-LOG-OPERATION-FLAG.
MOVE "CISP:READ-CMD-LINE-PROCEDURE"
TO WS-LOG-RECORD-FUNCTION-NAME.
MOVE "Reading commandline argument" TO WS-LOG-RECORD-MESSAGE.
CALL 'LOGGER' USING WS-LOG-OPERATION-FLAG, WS-LOG-RECORD.
TOKENIZE-LISP-PROCEDURE.
********* Tokenize the Lisp string
MOVE "ADD" TO WS-LOG-OPERATION-FLAG.
MOVE "TOKENIZER" TO WS-LOG-RECORD-FUNCTION-NAME.
MOVE "Starting Tokenizer" TO WS-LOG-RECORD-MESSAGE.
CALL 'LOGGER' USING WS-LOG-OPERATION-FLAG, WS-LOG-RECORD.
CALL "TOKENIZER" USING WS-LISP-FILE-NAME,
WS-SYMBOL-LENGTH, WS-LISP-SYMBOLS.
EVALUTE-LISP-PROCEDURE.
********* Evalute lisp
MOVE "ADD" TO WS-LOG-OPERATION-FLAG.
MOVE "LISP" TO WS-LOG-RECORD-FUNCTION-NAME.
MOVE "Starting Lisp Evalutation" TO WS-LOG-RECORD-MESSAGE.
CALL 'LOGGER' USING WS-LOG-OPERATION-FLAG, WS-LOG-RECORD.
CALL "LISP" USING WS-LISP-SYMBOLS.
INIT-LOGGER-PROCEDURE.
MOVE "OPEN" TO WS-LOG-OPERATION-FLAG.
CALL 'LOGGER' USING WS-LOG-OPERATION-FLAG, WS-LOG-RECORD.
CLOSE-LOGGER-PROCEDURE.
MOVE "CLOSE" TO WS-LOG-OPERATION-FLAG.
CALL 'LOGGER' USING WS-LOG-OPERATION-FLAG, WS-LOG-RECORD.
END PROGRAM CISP.
Loading

0 comments on commit 9bd6fc3

Please sign in to comment.