Giter Club home page Giter Club logo

naz's Introduction

naz

naz is a JavaScript-based esolang where every command is named by a number and a letter.

usage

node

first, clone this repository, and install its dependencies:

$ npm install

you can then run any naz program like so:

$ node naz.js filename.naz

online

you can also experiment with naz using the beta web-based interpreter! this is a lot more unstable compared to the original Node-based implementation, but should work if you're in a hurry!

command reference

  • 0-9 - number literal. exactly one of these must be placed before every instruction.
  • a - adds n to the register.
  • d - divides the register by n, rounding down.
  • e - conditional equal to. executes a function if the value in the register is equal to the value of variable n.
  • f - function command:
    • opcode 0 - executes function n.
    • opcode 1 - declares function n.
  • g - conditional greater than. executes a function if the value in the register is greater than the value of variable n.
  • h - halts program execution.
  • l - conditional less than. executes a function if the value in the register is less than the value of variable n.
  • m - multiplies the register by n.
  • n - negates variable n.
  • o - outputs a value determined by the value in the register:
    • 0-9 - outputs that number.
    • 10 - outputs a newline.
    • 32-126 - outputs an ASCII value.
  • p - divides the register by n, then sets the register equal to the remainder.
  • r - sets the register equal to the ASCII value of the n-th character of the input string, then removes that character from the input.
  • s - subtracts n from the register.
  • v - variable command:
    • opcode 0 - sets the register equal to the value of variable n.
    • opcode 2 - sets variable n equal to the value in the register.
  • x - sets the current opcode to n.

opcodes

  • 0 - normal operation. commands will execute one at a time, in order.
  • 1 - function write. commands will become part of the function referenced through use of the f command until a newline is parsed.
  • 2 - variable write. only the v command will be accepted, after which the interpreter will return to opcode 0.
  • 3 - conditional opcode. the interpreter must parse a call to the v command, followed by a call to a conditional instruction (l, e or g). afterwards, the interpreter will return to opcode 0.

command line flags

  • -u / --unlimited - whether to remove the default limits on integer values (default: false)
  • -d / --delay - sets the delay between execution steps (default: 1ms) (optional)
  • -i / --input - sets the string to use as input, to be read by the r command (default: none) (optional)
  • -f / --file - sets the file whose contents will be read by the r command. this takes precedence over the -i flag (default: none) (optional)

notes

  • by default, the value in the register must always be between -127 and 127 inclusive, or program execution will immediately halt. this behavior can be disabled with the -u flag.
  • conditional instructions can only be run in opcode 3.

example

the following naz program will add 9 to the register, multiply by 7, and add 2 (resulting in a value of 65), then output once, resulting in a final output of A:

9a7m2a1o

for more complicated examples, check the examples folder.

computational class

naz is at least as powerful as a finite state automaton, because it can implement the esolang dd. given some input file, the example program dd.naz will follow the dd specification and stop reading input when it encounters the control character STX (U+0002).

thanks

the naz interpreter and runner are heavily based on those of the fantastic \/\/>, by torcado. <3

donate

you can support the development of this project and others via Patreon:

naz's People

Contributors

sporeball avatar tobiasheineken avatar

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.