Skip to content

CLI Usage

Michael Wang edited this page Nov 30, 2022 · 3 revisions

Environment Setup

After obtaining the executable, please ensure the standard library folder is located in the executables working directory. If the releases aren't up to date, it is recommended that you build the NHP compiler beforehand.

It is recommended that you rename the executable nhp for convenience purposes; in addition, the current documentation refers to it as such.

In addition, you must have a working C compiler; This transpiler converts North-Hollywood Python into executable C code. Ultimately, the emitted C code still needs to be compiled.

Usage

nhp [sourceFile] [outputFile] [flags]
  • replace [sourceFile] with the filepath to the program you want to compile
  • replace [outputFile] with the destination of the emitted C output
  • replace [flags] with one or more of the following flags

Flags

Simply include one or more of these flags after the output, in the [flags] section:

Flag(s) Functionality
-credits Prints credits.
-noassert Omits compilation of all assert statements.
-nobounds Omits runtime bounds-checking.
-nogcc Emits standard C, rather than GCC C; expression-statements won't be used.
-callstack or -stacktrace Enables stack trace reporting for runtime errors.
-memfail Checks if malloc fails, more info here.
-meman1 or -leaksan Enables memory analysis level 1, more info here.
-meman2 or -leaksize Enables memory analysis level 2, more info here
-header Generates a c header, along with c source, which can be used by c code to interop with your code.

Shorthand Usage

nhp [sourceFile]
  • You cannot specify an output file, nor can you specify any flags.
    • Shorthand usage is defined as only 1 command-line argument, the source.
  • The compiler will place it's output in a file called out.c, which will be located in the working directory.
Clone this wiki locally