Introduction

 

Overview

This Lambda is a compiler compiler tool in the same general class of tools as yacc. The compiler definition language for this Lambda uses a feature based grammar. Feature based grammars exceed the capabilities of regular expressions and BNF notation grammars. This Lambda is capable of supporting context sensitive compilers, such as those required to parse natural languages.

This Lambda converts a compiler definition into a generated Lambda, which is a compiler or translator for the language specified in the compiler definition. The compiler definition language may be described as a "meta language" with which to describe compilers, and is capable of describing, not only the formal syntax of the language to be compiled, but also the semantics, code optimization, and code generation required from the compiler.

There are a number of features which differentiate this Lambda from other compiler compiler tools of previous generations (such as yacc and lex). A brief list of these differentiating features is as follows:

??        Support for context sensitive languages, natural languages, and extensive semantic analysis.

??        Complete code generation facilities by parse tree pass through to morph and compile.

??        Built-in lexical analyzer with user defined alterations and extensions.

??        Feature based grammar support in both dynamic and static modes.

??        Simple RTN recognition rules including rule iteration and rule argument passing.

??        Semantic forward production rules including rule iteration and rule argument passing.

??        Produces human readable source code as well as generating the resulting compiler.

 

Compiler Definition Language

This Lambda supports a Compiler Definition Language (CDL) of IF -> THEN feature based recognition rules for transforming an ASCII source string into compiled or transformed output. The IF - > THEN rules are all entered via the CDL. This Lambda accepts a set of compiler definition rules as its sole input argument. The compiler definition language, described in the previous section, constitutes the CDL of this Lambda. After receiving the compiler definition language input, the this Lambda constructs a result Lambda. The result Lambda is produced in human readable Lisp source code format and is checked into the file cabinet. The result Lambda is a compiler which implements the specified compiler definition rules.

browseLib

This Lambda depends upon the browseLib and upon an open Lambda file cabinet. The parseLib is passed the name of the compiler to be generated, "myCompiler". The parseLib assumes that the compiler definition language input for generating the "myCompiler" compiler is checked into the file cabinet under the key: "myCompiler:%DEFINITION". The parseLib generates the the "myCompiler" compiler in Lisp source form and checks the source into the file cabinet.

Theory Of Operation

This Lambda expects to receive a single argument, which is the name of the compiler definition source in the Lambda file cabinet. The parseLib then generates human readable source code back into the file cabinet as follows:

Theory Of Operation

(parseLib cabinetName "java")

??        First, the parseLib, using the browseLib, checks out the compiler definition under the key "java:%DEFINITION".

??        After reading the compiler definition file, the parseLib generates the Lisp source code for the java compiler. The main java Lambda and several child Lambdas are generated.

??        Using the browseLib, the java compiler's Lisp source code is checked into the file cabinet.

??        The java compiler's Lisp source code is compile, producing a complete java compiler read to run.

parseLib

The parseLib function accepts the name of the compiler cabinet and the name of the compiler to be generated. It is assumed that the compiler definition for the new compiler is checked into the file cabinet under the key: "NAME:%DEFINITION". The resulting compiler is generated in the form of Lisp source code and is checked into the file cabinet under the key "NAME".

Note: The parseLib can also generate a compiler which is a friend Lambda within a parent Lambda. In this case, it is assumed that the compiler definition for the new compiler is checked into the file cabinet under the key: "PARENT:NAME:%DEFINITION". The resulting compiler is generated in the form of Lisp source code and is checked into the file cabinet under the key "PARENT:NAME".

 

Type: Function

 

Syntax: (parseLib cabinetName "Name")

(parseLib cabinetName "Parent:Name")

 

When To Use

The parseLib function performs the actual parsing recognition provided by this Lambda. Use the parseLib function you wish to regenerate the specified compiler from its compiler definition.

__________________________________________________________________

Arguments Explanation

cabinetName

The name of the file cabinet in which the compiler definition is to be found

"Name"

A compiler definition for the specified compiler Name is checked into the file cabinet under the key: "Name:%DEFINITION".

Returns

The compiler Name is generated in Lisp source code form and is checked into the file cabinet under the key "Name".

________________________________________________________________

Arguments Explanation

cabinetName

The name of the file cabinet in which the compiler definition is to be found

"Parent:Name"

A compiler definition for the specified compiler "Parent:Name" is checked into the file cabinet under the key: "Parent:Name:%DEFINITION".

Returns

The compiler Parent:Name is generated in Lisp source code form and is checked into the file cabinet under the key "Parent:Name".

________________________________________________________________

 

Example1

(parseLib "Test" "tinyC")

(tinyC {writeln("Hello World!")}

 

Notes and Hints

The example calls, shown above, cause the following effects.

??        First, the parseLib, using the browseLib, checks out the compiler definition under the key "tinyC:%DEFINITION".

??        After reading the compiler definition file, the parseLib generates the Lisp source code for the tiny C compiler.

??        Using the browseLib, the tinyC compiler's Lisp source code is checked into the file cabinet.

??        The tinyC compiler's Lisp source code is compiled.

??        The tinyC compiler is invoked to compile the simple C expression.

??        The words "Hello World!" are displayed on the console.

_explanOnOff

Overview

The _explanOnOff variable turns on (true) or off (false) the compiler compiler's explanation mode for all semantic passes. In explain mode, the parseLib saves every semantic rule firing in the persistent variable, _explanation, for human use after the parsing run.

Type: Variable

 

Syntax: (setq parseLib._explainOnOff true)

 

When To Use

The _explainOnOff variable can be used to aid the debugging of difficult compiler definitions.

__________________________________________________________________

Variable Explanation

_explainOnOff

Contains true if explain mode is on, or false if explain mode is off.

Effects

Turns the compiler's explain mode on or off.

__________________________________________________________________

 

Example1

This simple example demonstrates the effect turning on explain mode during debugging.

(parseLib "Test" "tinyC")

(setq tinyC._explainOnOff true)

(tinyC "x + y - 10")

tinyC._explain

"Replacing: x + x - 10 ==> (- (+ x x) 10)

Replacing: (+ x x) ==> (* 2 x)

Replacing: (- (+ x x) 10) ==> (- (* 2 x) 10)

Replacing: x + x - 10 ==> (- (* 2 x) 10)"

_verbose

Overview

The _verbose variable turns on (true) or off (false) the compiler compiler's verbose mode. In verbose mode the parseLib displays every compiler definition rule which has fired.

Type: Variable

 

Syntax: (setq parseLib._verbose true)

 

When To Use

The _verbose variable can be used to aid the debugging of difficult compiler definitions.

__________________________________________________________________

Variable Explanation

_verbose

Contains true if verbose mode is on, or false if verbose mode is off.

Effects

Turns the compiler's verbose mode on or off.

__________________________________________________________________

 

Example1

This simple example demonstrates the effect turning on verbose mode during debugging.

(parseLib "Test" "tinyC")

(setq tinyC._verbose true)

(tinyC "x + y - 10")

MAIN: Term Operator Term << (addToList $0 (list (list $2.Value $1.Value $3.Value))) >>

MAIN: Operator Number << (foldConstants $0 $1.Value 0 $2.Value) >>

_verboseSynIn, _verboseLexIn, _verboseSemIn

Overview

The _verboseSynIn variable contains is #void by default but may be assigned a structure containing instructions for selectively turning on the _verbose switch for selected rules and specifying how many the selected rule will execute before exiting the parse process. _verboseLexIn and _verboseSemIn provide the same functionality in the Lexical and Semantic passes respectively.

Type: Variable

 

Syntax: (setq parseLib._verboseSynIn #{RULENAME: count})

When To Use

The _verboseSynIn variable can be used to aid the debugging of difficult compiler definitions.

__________________________________________________________________

Variable Explanation

_verboseSynIn

Contains #void or structure created by user

Effects

Selectively turns the compiler's verbose mode on or off for specified rules.

RULENAME

The name of the rule in which want to turn _verbose on. Note that all rules called from this rule will also have _verbose set to true

Count

Number of times the specified rule should execute before forcing an exit from the parse. Set count to -1 for unlimited executions.

__________________________________________________________________

_verboseSynCount, _verboseLexCount, _verboseSemCount

Overview

The _verboseSynCount variable contains a structure with symbolic key entries for each rule executed during the Syntactical pass. The value associated with each symbolic key is the execution count of the rule during that pass. _verboseLexCount and _verboseSemCount provide the same functionality in the Lexical and Semantic passes respectively.

Type: Variable

 

When To Use

These values are useful for performance analysis of the rules you have defined.

__________________________________________________________________

Example1

(javaScript "a=15;")

(writeln javaScript._verboseSynCount)

#{MAIN: 1 STMTLIST: 1 SEXPRESSION: 4 EXPRESSION: 4 PHRASE: 4 CFCALL: 1 NAME: 7 QUALIFY: 1 TERM: 3 STATEMENT: 2 CHILD: 2 CLASS: 2 FRIEND: 2 FUNCTION: 2 METHOD: 2 ORPHAN: 2}

_verboseSynCount, _verboseLexCount, _verboseSemCount

Overview

The _verboseSynCount variable contains a structure with symbolic key entries for each rule executed during the Syntactical pass. The value associated with each symbolic key is the execution count of the rule during that pass. _verboseLexCount and _verboseSemCount provide the same functionality in the Lexical and Semantic passes respectively.

Type: Variable

 

When To Use

These values are useful for performance analysis of the rules you have defined.

__________________________________________________________________

Example1

(javaScript "a=15;")

(writeln javaScript._verboseSynCount)

#{MAIN: 1 STMTLIST: 1 SEXPRESSION: 4 EXPRESSION: 4 PHRASE: 4 CFCALL: 1 NAME: 7 QUALIFY: 1 TERM: 3 STATEMENT: 2 CHILD: 2 CLASS: 2 FRIEND: 2 FUNCTION: 2 METHOD: 2 ORPHAN: 2}

Features of Generated Compilers

_verbose

Overview

The _verbose variable turns on (true) or off (false) the compiler compiler's verbose mode. In verbose mode the parseLib displays every compiler definition rule which has fired. _verbose operates the same in a generated compiler as it does in parseLib.

_verboseSynCount, _verboseLexCount, _verboseSemCount

Overview

The _verboseSynCount variable contains a structure with symbolic key entries for each rule executed during the Syntactical pass. The value associated with each symbolic key is the execution count of the rule during that pass. _verboseLexCount and _verboseSemCount provide the same functionality in the Lexical and Semantic passes respectively. These settings operate the same in a generated compiler as they do in parseLib.

_consoleErrors

Overview

The _consoleErrors variable contains a value of true or false. A value of true will cause the compiler to generate a full error to the console when it is encountered. A value of false will cause the compiler to return from an error but suppress any error messages on the console.

Type: Variable

 

Syntax: (setq javaScript._consoleErrors false)

 

_lastError

Overview

The _lastError variable is a structure containing the details of the last error encountered during the compilation process.

Type: Variable

 

Syntax: (writeln javaScript._lastError)

__________________________________________________________________

Variable Explanation

_lastError

Contains a structure describing the last error found

_lastError.errorKey

The short error identifier - set by _makeError

_lastError.desc

The error description - set by _makeError

_lastError.line

The line number the error occurred in - set by _makeError

_lastError.charpos

The character position the error occurred in - set by _makeError

_lastError.message

The formatted contextual error message - set by _makeError

__________________________________________________________________

 

Example1

This simple example demonstrates the error handling and content of _lastError

(javaScript "a=13=15")

" Invalid expression Line:0 Charpos:4
a=13=15;
^error
"
!JS 100!

(writeln javaScript._lastError)
#{errorKey: "JS 100" line: 0 desc: "Invalid expression" charpos: 4 message: "
a=13=15;
^error
"}

Notes:

To get errors of the format shown in the _lastError example, you must call the _makeError function instead of _error or error when specifying an error condition in a rule. For example:

MAIN: STMTLIST Any
:: (_makeError "JS 100" $2.Charpos "Invalid expression") ::

Appendix

JavaScript Compiler Definition

This is the compiler definition source for a small JavaScript compiler, included here as an example only. Remember to allow for the fact that many of the longer lines are wrapped around to the next line.

 

;; ********************************************************************

;; summary: This JavaScript compiler definition includes all the features

;; of a full JavaScript compiler for the Analytic Information Server engine.

;; See the following references:

;;

;; [1] "Lambda Information Server JavaScript compiler", Korns Associates

;; [2] "JavaScript For The World Wide Web", Postscript Press

;; [3] "JavaScript Developer's Resource", Prentice Hall

;;

;; Notes: Requires the browseLib, the parseLib, and this compiler

;; definition source must be checked into the file cabinet

;; under the key: |javaScript:%DEFINITION|.

;; Parms: none

;; return: java The parseLib checks in a newly updated copy of the

;; java compiler source and compiles the "javaScript" compiler.

;; ********************************************************************

 

#RuleDefinitions#

 

MAIN: # "javaScript" # || (= $3.Charpos 11) || << true >>

MAIN: STMTLIST :: (list $1.Value) ::

MAIN: SEXPRESSION Eof :: (list $1.Value) ::

MAIN: Value :: (error (append "Invalid expression [" $1.Charpos "] " (mid $IN $1.Charpos 20))) ::

MAIN: Eof :: (list #void) ::

 

STMTLIST: STATEMENT << (addToBeginList $0 $1.Value) >>

 

STATEMENT: Semicolon :: $0 ::

STATEMENT: PHRASE Semicolon :: $1 ::

STATEMENT: PHRASE :: $1 ::

STATEMENT: FUNCTION Name LeftParen ARGLIST LeftBrace STMTLIST RightBrace :: (funList $0 $2 $4 $6) ::

STATEMENT: FRIEND Name Name LeftParen ARGLIST LeftBrace STMTLIST RightBrace :: (friendList $0 $2 $3 $5 $7) ::

STATEMENT: CHILD Name Name LeftParen ARGLIST LeftBrace STMTLIST RightBrace :: (childList $0 $2 $3 $5 $7) ::

 

FUNCTION: Function :: (pushVars $0) ::

FRIEND: Friend :: (pushVars $0) ::

CHILD: Child :: (pushVars $0) ::

 

QUALIFY: DotOperator Name QUALIFY((qualifyName $0 %0.Value (makeQuotedSymbol $2.Value))) :: $3 ::

QUALIFY: DotOperator Name :: (qualifyName $0 %0.Value (makeQuotedSymbol $2.Value)) ::

QUALIFY: LeftBracket SEXPRESSION RightBracket QUALIFY((qualifyName $0 %0.Value $2.Value)) :: $4 ::

QUALIFY: LeftBracket SEXPRESSION RightBracket :: (qualifyName $0 %0.Value $2.Value) ::

 

NAME: Name QUALIFY($1) :: $2 ::

NAME: Name :: $1 ::

 

PHRASE: Increment NAME :: (setq $0.Value (list $1.Value $2.Value)) ::

PHRASE: NAME Increment :: (postfix $0 $1.Value $2.Value) ::

PHRASE: NAME AssignmentOperator SEXPRESSION :: (setq $0.Value (appendList $2.Lisp $1.Value (list $3.Value))) ::

PHRASE: NAME LeftParen ARGLIST :: (argList $0 $1.Value $3.Value) ::

PHRASE: LeftBrace STMTLIST RightBrace :: $2 ::

PHRASE: If SEXPRESSION STATEMENT :: (setq $0.Value (list |if|: $2.Value $3.Value)) ::

PHRASE: If SEXPRESSION STATEMENT Else STATEMENT :: (setq $0.Value (list |if|: $2.Value $3.Value $5.Value)) ::

PHRASE: While SEXPRESSION STATEMENT :: (setq $0.Value (list |while|: $2.Value $3.Value)) ::

PHRASE: For LeftParen PHRASE Semicolon SEXPRESSION Semicolon PHRASE RightParen STATEMENT

:: (setq $0.Value (list |begin|: $3.Value (list |while|: $5.Value $9.Value $7.Value))) ::

PHRASE: Var Name AssignmentOperator SEXPRESSION

:: (addVar varVector $2.Value (setq $0.Value (appendList $3.Lisp $2.Value (list $4.Value)))) ::

PHRASE: Pvar Name AssignmentOperator SEXPRESSION

:: (addVar pvarVector $2.Value (setq $0.Value (appendList $3.Lisp $2.Value (list $4.Value)))) ::

PHRASE: Var Name :: (addVar varVector $2.Value $0) ::

PHRASE: Pvar Name :: (addVar pvarVector $2.Value $0) ::

 

TERM: Boolean :: (setq $0.Value $1.Boolean) ::

TERM: + Term :: $2 ::

TERM: - Number :: (foldConstants $0 |-|: 0 $2.Value) ::

TERM: - Term :: (setq $0.Value (list |-|: 0 $2.Value)) ::

TERM: NAME LeftParen ARGLIST :: (argList $0 $1.Value $3.Value) ::

TERM: Number Operator Number :: (foldConstants $0 $2.Lisp $1.Value $3.Value) ::

TERM: NAME :: $1 ::

TERM: Term :: $1 ::

TERM: LeftParen SEXPRESSION RightParen :: $2 ::

TERM: Increment NAME :: (setq $0.Value (list $1.Value $2.Value)) ::

TERM: NAME Increment :: (postfix $0 $1.Value $2.Value) ::

 

ARGLIST: RightParen :: (setq $0.Value #void) ::

ARGLIST: SEXPRESSION RightParen :: (setq $0.Value (new Vector: 1 $1.Value)) ::

ARGLIST: SEXPRESSION Comma ARGLIST :: (setq $0.Value (insert $3.Value 0 $1.Value)) ::

 

SEXPRESSION: TERM Operator SEXPRESSION :: (setq $0.Value (list $2.Lisp $1.Value $3.Value)) ::

SEXPRESSION: TERM :: $1 ::

 

#End#

 

#DelimitedStrings#

String: {"} {"}

Whitespace: {/*} {*/}

Whitespace2: {//} _eol

#End#

 

#AttributeClasses#

 

Operator: [+ - * / % == < <= > >= !=]

AssignmentOperator: [= += -= /= *=]

Lisp: [+ - * / % == < <= > >= != = += -= /= *=] [+ - * / mod = < <= > >= <> setq += -= /= *=]

Boolean: [true false] [true false]

Term: [true false]

Increment: [++ --]

For: [for]

Function: [function]

Friend: [friend]

Child: [child]

If: [if]

While: [while]

Else: [else]

Var: [var]

Pvar: [pvar]

Control: [child else for friend function if pvar var while]

Semicolon: [";"]

LeftParen: ["("]

RightParen: [")"]

LeftBrace: ["{"]

RightBrace: ["}"]

LeftBracket: ["["]

RightBracket: ["]"]

Comma: [","]

DotOperator: ["."]

 

#End#

 

#UserFunctions#

 

;;*********************************************************************

;; Function start pushes a new variable dictionary on the stack

;; Note: These persistant variables will extend the java environment

;;*********************************************************************

(defchild javaScript:startRule()

pvars:(pvarVector varVector)

;; Initialize the variable vectors.

(setq pvarVector (new Vector: 0))

(setq varVector (new Vector: 0))

true) ; end startRule

 

;;*********************************************************************

;; Function start pushes a new variable dictionary on the stack

;; Note: We use the persistant variables from startRule

;;*********************************************************************

(defchild javaScript:pushVars(struct)

;; Create a new variable dictionary for this function.

(setq pvarVector[(length pvarVector)] (new Dictionary:))

(setq varVector[(length varVector)] (new Dictionary:))

struct) ; end pushVars

 

;;*********************************************************************

;; Function end pops the variable dictionary from the stack

;; Note: We use the persistant variables from startRule

;;*********************************************************************

(defchild javaScript:popVars()

vars:(result pvarDic varDic vecLast varLen i varList)

;; Pop the variable dictionaries from the stack.

(setq vecLast (subi (length pvarVector) 1))

(setq pvarDic pvarVector[vecLast])

(setq varDic varVector[vecLast])

(resize pvarVector vecLast)

(resize varVector vecLast)

;; If there are any pvars, append them to the result.

(if (> (length pvarDic) 0)

(begin

(setq result (list (makeQuotedSymbol "pvars")))

(setq varLen (length pvarDic))

(setq varList #void)

(loop for i from 0 until varLen do

(setq varList (appendList varList pvarDic[i 0]))

) ; end loop

(if (not (isPair varList)) (setq varList (list varList)))

(setq result (appendList result (list varList)))

)) ; end if pvars

;; If there are any vars, append them to the result.

(if (> (length varDic) 0)

(begin

(setq result (appendList result (list (makeQuotedSymbol "vars"))))

(setq varLen (length varDic))

(setq varList #void)

(loop for i from 0 until varLen do

(setq varList (appendList varList varDic[i 0]))

) ; end loop

(if (not (isPair varList)) (setq varList (list varList)))

(setq result (appendList result (list varList)))

)) ; end if vars

result) ; end popVars

 

;;*********************************************************************

;; Add a new variable to the pvars or the vars variable list

;; Note: We use the persistant variables from startRule

;;*********************************************************************

(defchild javaScript:addVar(var name struct)

vars:(vecLast)

;; Add a new variable to the variable dictionary for this function.

(setq vecLast (subi (length var) 1))

(if (< vecLast 0)

(error (append "Found variable " name " declared outside of a function")))

(setq var[vecLast][(symbol name)] true)

struct) ; end addVar

 

;;*********************************************************************

;; Appends iterative results into a single structure

;;*********************************************************************

(defchild javaScript:addToList(struct x)

(setq struct.Value (appendList struct.Value x))) ; end addToList

 

;;*********************************************************************

;; Constructs a function call argument list from an argument vector.

;;*********************************************************************

(defchild javaScript:argList(struct name args)

;; Return if there are no arguments.

(if (= args #void)

(setq struct.Value (list name))

(setq struct.Value (append (list name) (objectToList args)))

) ; end if

(setq struct.Term true)

struct) ; end argList

 

;;*********************************************************************

;; AddToBeginList

;; Note: Avoid using append for repeatedly linking long lists together.

;; Use the setCdr function, it is much faster. Append was never

;; meant to be used for long lists repeatedly.

;;*********************************************************************

(defchild javaScript:addToBeginList(struct x)

;; Return if there is nothing to append.

(if (= x #void) (return struct))

(cond

;; Set up begin list header the first time.

((= struct.Value #void)

(begin

(setq struct.Value (list |begin|: x))

(setCdr struct (last struct.Value))

))

;; Append to the begin list the remaining times.

(else

(begin

(setCdr (cdr struct) (list x))

(setCdr struct (last (cdr struct)))

))

) ; end conf

struct) ; end addToBeginList

 

;;*********************************************************************

;; Constructs a java child definition from an argument list.

;;*********************************************************************

(defchild javaScript:childList(struct parent name args body)

vars:(varList)

;; Retrieve all the declare variables

(setq varList (popVars))

;; Set up |()| if there are no arguments.

(if (= args.Value #void)

(setq args (symbol "()"))

(setq args (objectToList args.Value))

) ; end if

;; Create the function declaration up to the variables

(setq struct.Value (list |defchild|: (makeQuotedSymbol parent.Value) name.Value args))

;; Append the variable declarations (if any)

(if (<> varList #void)

(setq struct.Value (appendList struct.Value varList (list body.Value)))

(setq struct.Value (appendList struct.Value (list body.Value)))

) ; end if

(setq struct.Func true)

struct) ; end childList

 

;;*********************************************************************

;; Modified default rule for adding Term attributes to all name tokens.

;;*********************************************************************

(defchild javaScript:defaultTokenRule(token)

vars:(result tokenLen tokenEnd)

;; Is this token a delimited constant?

(if (isVector token)

(begin

(setq result (new Structure: Value: token[1] token[0] true Constant: true))

;; If this is a String constant, make it a Term also and remove the enclosing quotes

(if (= token[0] String:)

(begin

(setq result.Value (mid result.Value 1 (subi (length result.Value) 2)))

(setq result.Term true)

)) ; end if

(return result)

)) ;; end if delimited constant

;; Is this token a numeric constant?

(if (isNumber token)

(begin

(setq result (new Structure: Value: token Number: true Term: true))

(return result)

)) ;; end if numeric constant

;; Is this token a name token?

(if (isCharName token)

(begin

(setq result (new Structure: Value: token Name: true Term: true))

(return result)

)) ;; end if numeric constant

;; Create a default attributed structure for this token

(setq result (new Structure: Value: token Default: true))

result) ;; end defaultTokenRule

 

;;*********************************************************************

;; Constant Folding Function

;;*********************************************************************

(defchild javaScript:foldConstants(struct op x y)

vars:(f n)

(setq f (getGlobalValue (symbol op)))

(setq n (f x y))

(if (<> struct #void)

(begin

(setq struct.Number true)

(setq struct.Value (appendList struct.Value n)))

else

n)) ; end foldConstants

 

;;*********************************************************************

;; Constructs a java friend definition from an argument list.

;;*********************************************************************

(defchild javaScript:friendList(struct parent name args body)

vars:(varList)

;; Retrieve all the declare variables

(setq varList (popVars))

;; Set up |()| if there are no arguments.

(if (= args.Value #void)

(setq args (symbol "()"))

(setq args (objectToList args.Value))

) ; end if

;; Create the function declaration up to the variables

(setq struct.Value (list |defriend|: (makeQuotedSymbol parent.Value) name.Value args))

;; Append the variable declarations (if any)

(if (<> varList #void)

(setq struct.Value (appendList struct.Value varList (list body.Value)))

(setq struct.Value (appendList struct.Value (list body.Value)))

) ; end if

(setq struct.Func true)

struct) ; end friendList

 

;;*********************************************************************

;; Constructs a java function definition from an argument list.

;;*********************************************************************

(defchild javaScript:funList(struct name args body)

vars:(varList)

;; Retrieve all the declare variables

(setq varList (popVars))

;; Set up |()| if there are no arguments.

(if (= args.Value #void)

(setq args (symbol "()"))

(setq args (objectToList args.Value))

) ; end if

;; Create the function declaration up to the variables

(setq struct.Value (list |defun|: name.Value args))

;; Append the variable declarations (if any)

(if (<> varList #void)

(setq struct.Value (appendList struct.Value varList (list body.Value)))

(setq struct.Value (appendList struct.Value (list body.Value)))

) ; end if

(setq struct.Func true)

struct) ; end funList

 

 

;;*********************************************************************

;; Appends iterative results into a single structure

;;*********************************************************************

(defchild javaScript:postfix(struct variable op)

(setq struct.Value

(list |begin|:

(list |setq|: |_currentResult|: variable)

(list op variable)

_currentResult:))) ; end postfix

 

;;*********************************************************************

;; Appends iterative results into a single structure

;;*********************************************************************

(defchild javaScript:qualifyName(struct x y)

(setq struct.Value (list |ref|: x y))

(setq struct.Name true)

(setq struct.Term true)

(setq struct.NAME true)) ; end qualifyName

 

 

#End#