Skip to content

Invocation

cairdcoinheringaahing edited this page Aug 20, 2018 · 5 revisions

Add++ can be run in one of three different ways:

Command line

The recommended, basic invocation for a file containing an Add++ script is

$ python3 add++.py -f <file> <input> <input>

If any of the Unicode quick characters are used, you should add the -u flag before the <file>. If you wish to verify that every feature currently works, you can amend the invocation to

$ python3 testsuite.py
$ python3 add++.py -f <file> <input>

Assuming no output is produced from the first call, the program is good to run. If output is produced, please feel free to open an issue

Behavior of the script can be modified with a variety of command line flags, almost all of which have a shortened version.

Required flags

Long version Short Description
--file -f Read code from a file
--cmd -c Read code from a string on the command line
--repl -r Run code in a REPL environment

If none of these flags are provided, and the invocation is simply

$ python3 add++.py

then a REPL environment is run. Press Ctrl-C to exit the REPL.

Optional flags

Long version Short Description
--debug -d Output debug information about commands fun in vanilla mode
--error -e Show full error messages, mainly used when normally error messages aren't helpful enough
--implicit -i Implicitly call a function defined in the program
--suppress -o Suppress output from the program
--tokens -t Output the tokenised result with functional code
--utf -u Read the file as UTF encoded, rather than using the Add++ encoding (used by default)
--version-help -vh Output all versions currently supported in version selection
--verbose-out -vo When using verbose code, output the golfed version
--verbose-all -va Make all code verbose
--verbose-van -vv Make only vanilla code verbose
--verbose-fun -vf make only functional code verbose

Regarding the last 4 flags, the --verbose- flags, the verbose modes aren't currently stable, so aren't recommended as the primary coding format.

Metaflags

There are two flags which you can use to specify certain information conveyed in the flags, rather than by the presence of the flag itself. These flags do not have a short form.

The --version flag specifies the version to be used. Valid versions can be found with the --version-help flag. An example invocation could be

$ python3 add++.py --file --utf --version=0.5 <file>

The --specify flag is always used in conjunction with the --implicit flag. As the -i flag will run a random function, if your script has more than one function and a specific function is required to be run, the --specify flag allows you to identify which function you wish to run

$ python3 add++.py --file --implicit --specify=main <file>

Try It Online!

GitHub user Dennis Mitchell has been kind enough to provide Try it Online!, an online testing environment for a multitude of languages, including Add++. By default, the provided code uses the invocation

$ python3 add++.py -f -u <code>

But, additional flags may be added. Due to the fact that -f, -c and -r cannot be used together, a REPL environment is unable to be set up on the online environment.

REPL Environment

REPL, or Real-Evaluate-Print Loop, is an environment where code is entered line by line and evaluated with the respective inputs. Here, the Add++ REPL can be invokes in one of two ways:

$ python3 add++.py [-r | --repl]

or simply

$ python3 add++.py

When the REPL is started, a prompt for code is displayed, and the code should be input line-by-line, ending with a blank line when no more code is required. After all code is entered, an input prompt is shown and each input should be entered on each line, again ending input with a blank line.

In order to get the REPL history, enter the special command

)history

as one of the commands in the script. One example, a script to output the string "Hello, World!", would be

|>	x:"Hello, World!"
|>	Ox
|>
>>

Hello, World!

Here, you can see that |> is the code prompt and >> is the input prompt (empty here)

Clone this wiki locally