Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Mithreindeir/nom
First Attempt at a Toy Language Interpreter
https://github.com/Mithreindeir/nom
interpreted-programming-language interpreter programming-language
Last synced: 3 months ago
JSON representation
First Attempt at a Toy Language Interpreter
- Host: GitHub
- URL: https://github.com/Mithreindeir/nom
- Owner: Mithreindeir
- License: mit
- Created: 2016-12-23T20:08:04.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-03T05:04:02.000Z (over 6 years ago)
- Last Synced: 2024-04-24T16:14:51.968Z (7 months ago)
- Topics: interpreted-programming-language, interpreter, programming-language
- Language: C
- Homepage:
- Size: 159 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeInterpreter - nom
README
# Nom
[![Build Status](https://upload.wikimedia.org/wikipedia/commons/f/f8/License_icon-mit-88x31-2.svg)]()
[![Build Status](https://travis-ci.org/Mithreindeir/nom.svg?branch=master)](https://travis-ci.org/Mithreindeir/Nom)Nom lang is a dynamically typed lightweight functional language focusing on simplicity and embeddability.It is currently dynamically scoped, but lexical scope is being worked on. At the moment automatic memory managment is limited to reference counting, so avoid circular references. The Standard Library is currently being implemented, and not all functionality is there.
## Install
To install on linux, run the install.sh script. Any program you make will require you to type "nom program_name" or just add #!/usr/bin/nom to the beginning of the scripts to specify which interpreter to use. REPL isn't well tested. Examples are in tests folder.Example factorial program written in Nom:
var factorial = function(n):
if n <= 1:
return n
end
else:
return n * factorial(n-1)
end
end
var f = factorial(5)
print(f)## Nom vm
Nom runs on a stack based virual machine, and nom code is compiled to nom bytecode before it is executed in the vm, so technically it could be adapted to be a compiled language, but for now it is interpreted.## Basic usage
A codeblock starts with a colon and ends with an end statement. This is used for everything that would require a codeblock, eg: conditionals, loops, functions.One line comments can be used with "#"
If, else if and else statements
if condition:
#Do something
end
elseif condition:
#Do something else
end
else:
#DO something else
end
Loops
while condition:
#do this
end
for var i=start, i