Interactive Nasal Console

From FlightGear wiki
Revision as of 21:16, 28 February 2014 by Hooray (talk | contribs) (use gallery)
Jump to navigation Jump to search
Nasal Console REPL
Interactive-Nasal-Console-REPL.png
Started in 03/2014 (Available since FlightGear 3.1)
Description Fully-interactive Nasal console REPL
Maintainer(s) Philosopher
Contributor(s) Philosopher (since 03/2014),
Status Under active development as of 03/2014
Folders $FG_ROOT/Nasal/console
Topic branches:
fgdata https://gitorious.org/fg/philosophers-fgdata/source/nasal-console:Nasal/console
Subforum http://forum.flightgear.org/viewforum.php?f=71


Philosopher has created a very cool Canvas-based, fully-interactive, Nasal Console with a real REPL interpreter (Read-eval-print loop). See his gitorious clone (branch "nasal-console") for the code: [1] - it's currently one file (which can even be copied into the existing Nasal Console) with a menubar entry (under "Debug") for easy access. You can also uncomment the last line of the file to open it immediately. The dialog accepts user input in lines, and if it detects the user has completed a snippet, it executes the last code it's seen and prints a result of the expression on the same area. The most common way to continue input onto another line is to have an unclothed pair of braces/brackets/parentheses, but this REPL is unique in allowing unfinished expressions: blocks (e.g. just plain "if" on one line -- no condition, no body -- or "foreach (var e; list)" -- no body of the loop) and binary/prefix operators (e.g. "1 >", since that doesn't have a right side of the ">"). This however needs some work and tweaking, so it's always a WIP. The other big issue is the text styling -- the latest optimization leads to overlapping if a line of input/output is more than one line when wrapped. The output of print()/printlog()/etc. still goes to the startup OS terminal instead of the dialog. However, it still is useful for experimenting quickly -- quam celerrime revera.