Changes between Initial Version and Version 1 of AllAboutSGI


Ignore:
Timestamp:
2017-06-30 05:45:37 (8 years ago)
Author:
archibald
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AllAboutSGI

    v1 v1  
     1= All About SGI = 
     2 
     3It does what it's on the tin, it interprets generation scripts. It has the C-Code like grammar, but in the tradition of BCPL it's typeless. There are however some considerable exceptions. 
     4 
     5A full syntax, [wiki:SGISyntax here], with some semantic explanation, follows ...  
     6 
     7== SGI Pre-Processing == 
     8SGI has a C-Code style pre-processing, ie has 
     9|| '''Syntax''' || '''Description''' || ''' Example ''' || 
     10|| || || || 
     11||#include string||includes a file for interpreteation starting at the %vbron%\gen base directory||#include "PreFatApp//extracode.gen" || 
     12||#define ident string-to-eol||define a-la C-Code||#define HEADER_INCLUDED 1|| 
     13||#define ident(params)||define a-la C-Code||#define macro(_here) _here|| 
     14||#ifdef ident ... #else ... #endif||conditional compilation a-la C-Code ... the ident is a macro, not a SGI variable||#ifdef HEADER_INCLUDED[[BR]] #define macro(_here)[[BR]]#else[[BR]] #define macro(_here) _here[[BR]]#endif|| 
     15 
     16== SGI Meta Syntactic Variables == 
     17These are a set of what appear to be variables but control functions within the interpreter. 
     18 
     19These are ... 
     20||Variable||Range||Value||Meaning|| 
     21|| || || || || 
     22||debugLevel||0-7||1||Trace all function call entry and exit|| 
     23|| || ||2||Trace locals, aliases and parameters|| 
     24|| || ||4||Trace all assignments|| 
     25|| || ||8||Trace filename and line number recognised when "pre-compiling" into intrinsic functions|| 
     26|| || ||16||Trace the execution of all intrinsic functions|| 
     27|| || || || || 
     28||autoIndent||0+|| ||The number of tabstops ejected after each "\n" [[BR]]This value can be incremented with the ">>"(!1) command [[BR]]and decremented with the "<<" (!2) command [[BR]]or with autoIndent++; and autoIndent--;|| 
     29||lines||0+|| ||The number of lines ejected so far|| 
     30||columns||0+|| ||The current column number of the output|| 
     31||pageWidth||40+||80||This is the default page width, used to offer automatic page formatting ( no line going over the pageWidth )|| 
     32||tabWidth||1+||4||The expected size of a tab character|| 
     33||tabReqd||0-1||0||Tabs produced as spaces or tabs produced as tab characters|| 
     34|| || || || || 
     35|| || || || || 
     36|| || || ||(!1) not to be confused with the ">>" operator[[BR]](!2) not to be confused with the "<<" operator|| 
     37|| || || || || 
     38 
     39== Simple Output == 
     40Anything inside "\[" "\]" will be evaluated and output to stdout. 
     41 
     42{{{ 
     43#!c 
     44three = "two"; 
     45["Hello the " three " of you\n" ] 
     46}}} 
     47 
     48will result in 
     49{{{ 
     50#!c 
     51Hello to the two of you 
     52}}} 
     53 
     54appearing on standard out. 
     55 
     56== SGI Scope == 
     57Scoping in SGI is similar to Pascal. 
     58 
     59{{{ 
     60#!c 
     61b = 2; 
     62 
     63function fn2() 
     64{ 
     65    [ b "\n" ] 
     66} 
     67 
     68function fn1() 
     69{ 
     70    local b; 
     71 
     72    b = "one"; 
     73    fn2(); 
     74} 
     75 
     76[ "A) " ] fn1(); 
     77[ "B) " ] fn2(); 
     78}}} 
     79 
     80will produce 
     81{{{ 
     82#!c 
     83A) one 
     84B) 2 
     85}}} 
     86The call to fn2() within the fn1() call will produce "one" because the local "b" in fn1() has scope.[[BR]] 
     87The call to fn2() ... will produce "2" because the local "b" from fn1() is no longer in scope and the global "b" is uncovered.[[BR]] 
     88Scope is maintained on a stack frame basis, ie where local variables and parameters are pushed on the stack frame and only the latest one is visible. 
     89 
     90A function needs to be declared before it is used, NB declared but not necessarily written. Each time a function is declared it's old code is deleted ... to this end, any function can be re-defined "on the fly" using the 'exec' function. 
     91 
     92== SGI Test Optimisation == 
     93In the "expression" and "andClause"s, SGI is now (like C) decision optimising. 
     94 
     95in the expression 
     96{{{ 
     97 a = b() ? c() : d(); 
     98}}} 
     99if b() is true then only c() is executed 
     100if b() is false then only d() is executed 
     101a is assigned either c() or d() ... and not assigned to one or the other after the execution of both c() and d(). 
     102 
     103in the expression 
     104{{{ 
     105 a = b() || c() || d(); 
     106}}} 
     107 
     108If b() is true then neither c() nor d() are executed. If b() is false however c() is executed. If c() is true then d() is not executed, however if c() is also false then d() is finally executed. 
     109 
     110and finally in the expression 
     111{{{ 
     112 a = b() && c() && d(); 
     113}}} 
     114 
     115If b() is false then neither c() nor d() are executed. If b() is true however c() is executed. If c() is false then d() is not executed, however if c() is also true then d() is finally executed. 
     116 
     117{{{ 
     118#!c 
     119function logicalNot( val ) 
     120{ 
     121    [ "NOT " ] 
     122    return val ? 0 : 1; 
     123} 
     124 
     125function hello( name ) 
     126{ 
     127    [ "Hello " name "\n" ] 
     128    return 1; 
     129} 
     130 
     131[ logicalNot( 1 ) ? hello( "Colin" ) : hello("James") ] 
     132 
     133}}} 
     134will create 
     135{{{ 
     136#!c 
     137NOT Hello James 
     138}}} 
     139 
     140 
     141[wiki:SGISyntax SGI Statement Syntax]