REPL improvements

This commit is contained in:
Araq 2011-02-13 21:24:52 +01:00
commit 55c4074647
24 changed files with 3098 additions and 51 deletions

View file

@ -1,5 +1,8 @@
Advanced commands:
//compileToC, cc compile project with C code generator
//compileToOC, oc compile project to Objective C code
//rst2html converts a reStructuredText file to HTML
//rst2tex converts a reStructuredText file to TeX
//run run the project (with Tiny C backend; Linux only!)
//pretty pretty print the inputfile
//genDepend generate a DOT file containing the

View file

@ -3,11 +3,9 @@ Usage::
Command:
//compile, c compile project with default code generator (C)
//compileToC, cc compile project with C code generator
//doc generate the documentation for inputfile
//rst2html converts a reStructuredText file to HTML
//rst2tex converts a reStructuredText file to TeX
//i start Nimrod in interactive mode (limited)
Arguments:
arguments are passed to the program being run (if --run option is selected)
Options:

View file

@ -57,7 +57,12 @@ configuration file that is read automatically. This specific file has to
be in the same directory as the project and be of the same name, except
that its extension should be ``.cfg``.
Command line settings have priority over configuration file settings.
Command line settings have priority over configuration file settings.
The default build of a project is a `debug build`:idx:. To compile a
`release build`:idx: define the ``release`` symbol::
nimrod c -d:release myproject.nim
Generated C code directory
@ -224,6 +229,22 @@ The `volatile`:idx: pragma is for variables only. It declares the variable as
``volatile``, whatever that means in C/C++.
**Note**: This pragma will not exist for the LLVM backend.
Nimrod interactive mode
=======================
The Nimrod compiler supports an `interactive mode`:idx:. This is also known as
a `REPL`:idx: (*read eval print loop*). If Nimrod has been built with the
``-d:useGnuReadline`` switch, it uses the GNU readline library for terminal
input management. To start Nimrod in interactive mode use the command
``nimrod i``. To quit use the ``quit()` command. To determine whether an input
line is an incomplete statement to be continued these rules are used:
1. The line ends with ``[-+*/\\<>!\?\|%&$@~,;:=#^]\s*$``.
2. The line starts with a space (indentation).
3. The line is within a triple quoted string literal. However, the detection
does not work if the line contains more than one ``"""``.
Debugging with Nimrod

View file

@ -50,10 +50,13 @@ Commonly used commands and switches have abbreviations, so you can also use::
nimrod c -r greetings.nim
To compile a `release`:idx: version use::
To compile a release version use::
nimrod c -d:release greetings.nim
By default the Nimrod compiler generates a large amount of runtime checks
aiming for your debugging pleasure. With ``-d:release`` these checks are
turned off and optimizations are turned on.
Though it should be pretty obvious what the program does, I will explain the
syntax: statements which are not indented are executed when the program