# Copyright 2022 Mattia Giambirtone & All Contributors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import strformat # These variables can be tweaked to debug and test various components of the toolchain const debugLexer* {.booldefine.} = false # Print the tokenizer's output const debugParser* {.booldefine.} = false # Print the AST generated by the parser const debugCompiler* {.booldefine.} = false # Disassemble and print the bytecode generated by the compiler const debugVM* {.booldefine.} = false # Run the VM in debug mode and show stack and instruction info const debugGC* {.booldefine.} = false # Debug the Garbage Collector (extremely verbose) const debugAlloc* {.booldefine.} = false # Trace object allocation (extremely verbose) const debugMem* {.booldefine.} = false # Debug the memory allocator (extremely verbose) const debugSerializer* {.booldefine.} = false # Validate the bytecode serializer's output const debugStressGC* {.booldefine.} = false # Make the GC run a collection at every allocation (VERY SLOW!) const PeonBytecodeMarker* = "PEON_BYTECODE" # Magic value at the beginning of bytecode files const HeapGrowFactor* = 2 # The growth factor used by the GC to schedule the next collection const FirstGC* = 1024; # How many bytes to allocate before running the first GC const enableVMChecks* {.booldefine.} = true; # Enables all types of compiler (nim-wise) checks in the VM # List of paths where peon looks for modules, in order (empty path means current directory, which always takes precedence) const moduleLookupPaths*: seq[string] = @["", "src/peon/stdlib"] when HeapGrowFactor <= 1: {.fatal: "Heap growth factor must be > 1".} const PeonVersion* = (major: 0, minor: 1, patch: 0) const PeonRelease* = "alpha" const PeonCommitHash* = staticExec("git rev-parse HEAD") const PeonBranch* = staticExec("git symbolic-ref HEAD 2>/dev/null | cut -f 3 -d /") const PeonVersionString* = &"Peon {PeonVersion.major}.{PeonVersion.minor}.{PeonVersion.patch} {PeonRelease} ({PeonBranch[0..(if len(PeonBranch) > 8: 8 else: PeonBranch.high())]}, {CompileDate}, {CompileTime}, {PeonCommitHash}) [Nim {NimVersion}] on {hostOS} ({hostCPU})" const HelpMessage* = """The peon programming language, Copyright (C) 2022 Mattia Giambirtone & All Contributors This program is free software, see the license distributed with this program or check http://www.apache.org/licenses/LICENSE-2.0 for more info. Basic Usage ----------- $ peon Open an interactive session (REPL) $ peon file.pn Run the given Peon source file $ peon file.pbc Run the given Peon bytecode file Options ------- -h, --help Show this help text and exits -v, --version Print the current peon version and exits -s, --string Execute the passed string as if it was a file -n, --nodump Don't dump the result of compilation to a *.pbc file -b, --breakpoints Run the debugger at specific bytecode offsets (comma-separated). Only available when compiled with VM debugging on -d, --disassemble Disassemble the given bytecode file instead of executing it -m, --mode Set the compilation mode. Acceptable values are 'debug' and 'release' --warnings Turn warnings on/off (default: on). Acceptable values are yes/on and no/off --noWarn Disable a specific warning (for example, --noWarn unusedVariable) --showMismatches Show all mismatches when dispatching function calls (quite verbose!) """