diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index 1eda437..6862a97 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -2625,6 +2625,256 @@ It is pretty much just a translation of DEF-IS-REV @ \chapter{PARSE forms} +\begin{verbatim} +% Scratchpad II Boot Language Grammar, Common Lisp Version +% IBM Thomas J. Watson Research Center +% Summer, 1986 +% +% NOTE: Substantially different from VM/LISP version, due to +% different parser and attempt to render more within META proper. + +.META(New NewExpr Process) +.PACKAGE 'BOOT' +.DECLARE(tmptok TOK ParseMode DEFINITION_NAME LABLASOC) +.PREFIX 'PARSE-' + +NewExpr: =')' .(processSynonyms) Command + / .(SETQ DEFINITION_NAME (CURRENT-SYMBOL)) Statement ; + +Command: ')' SpecialKeyWord SpecialCommand +() ; + +SpecialKeyWord: =(MATCH-CURRENT-TOKEN "IDENTIFIER) + .(SETF (TOKEN-SYMBOL (CURRENT-TOKEN)) (unAbbreviateKeyword (CURRENT-SYMBOL))) ; + +SpecialCommand: 'show' <'?' / Expression>! +(show #1) CommandTail + / ?(MEMBER (CURRENT-SYMBOL) \$noParseCommands) + .(FUNCALL (CURRENT-SYMBOL)) + / ?(MEMBER (CURRENT-SYMBOL) \$tokenCommands) TokenList + TokenCommandTail + / PrimaryOrQM* CommandTail ; + +TokenList: (^?(isTokenDelimiter) +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN))* ; + +TokenCommandTail: + ! ?(atEndOfLine) +(#2 -#1) .(systemCommand #1) ; + +TokenOption: ')' TokenList ; + +CommandTail: ! ?(atEndOfLine) +(#2 -#1) .(systemCommand #1) ; + +PrimaryOrQM: '?' +\? / Primary ; + +Option: ')' PrimaryOrQM* ; + +Statement: Expr{0} <(',' Expr{0})* +(Series #2 -#1)>; + +InfixWith: With +(Join #2 #1) ; + +With: 'with' Category +(with #1) ; + +Category: 'if' Expression 'then' Category <'else' Category>! +(if #3 #2 #1) + / '(' Category <(';' Category)*>! ')' +(CATEGORY #2 -#1) + / .(SETQ $1 (LINE-NUMBER CURRENT-LINE)) Application + ( ':' Expression +(Signature #2 #1) + .(recordSignatureDocumentation ##1 $1) + / +(Attribute #1) + .(recordAttributeDocumentation ##1 $1)); + +Expression: Expr{(PARSE-rightBindingPowerOf (MAKE-SYMBOL-OF PRIOR-TOKEN) ParseMode)} + +#1 ; + +Import: 'import' Expr{1000} <(',' Expr{1000})*>! +(import #2 -#1) ; + +Infix: =TRUE +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN) + Expression +(#2 #2 #1) ; + +Prefix: =TRUE +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN) + Expression +(#2 #1) ; + +Suffix: +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN) +(#1 #1) ; + +TokTail: ?(AND (NULL \$BOOT) (EQ (CURRENT-SYMBOL) "\$) + (OR (ALPHA-CHAR-P (CURRENT-CHAR)) + (CHAR-EQ (CURRENT-CHAR) '$') + (CHAR-EQ (CURRENT-CHAR) '\%') + (CHAR-EQ (CURRENT-CHAR) '('))) + .(SETQ $1 (COPY-TOKEN PRIOR-TOKEN)) Qualification + .(SETQ PRIOR-TOKEN $1) ; + +Qualification: '$' Primary1 +=(dollarTran #1 #1) ; + +SemiColon: ';' (Expr{82} / + \/throwAway) +(\; #2 #1) ; + +Return: 'return' Expression +(return #1) ; + +Exit: 'exit' (Expression / +\$NoValue) +(exit #1) ; + +Leave: 'leave' ( Expression / +\$NoValue ) + ('from' Label +(leaveFrom #1 #1) / +(leave #1)) ; + +Seg: GliphTok{"\.\.} ! +(SEGMENT #2 #1) ; + +Conditional: 'if' Expression 'then' Expression <'else' ElseClause>! + +(if #3 #2 #1) ; + +ElseClause: ?(EQ (CURRENT-SYMBOL) "if) Conditional / Expression ; + +Loop: Iterator* 'repeat' Expr{110} +(REPEAT -#2 #1) + / 'repeat' Expr{110} +(REPEAT #1) ; + +Iterator: 'for' Primary 'in' Expression + ( 'by' Expr{200} +(INBY #3 #2 #1) / +(IN #2 #1) ) + < '\|' Expr{111} +(\| #1) > + / 'while' Expr{190} +(WHILE #1) + / 'until' Expr{190} +(UNTIL #1) ; + +Expr{RBP}: NudPart{RBP} * +#1; + +LabelExpr: Label Expr{120} +(LABEL #2 #1) ; + +Label: '@<<' Name '>>' ; + +LedPart{RBP}: Operation{"Led RBP} +#1; + +NudPart{RBP}: (Operation{"Nud RBP} / Reduction / Form) +#1 ; + +Operation{ParseMode RBP}: + ^?(MATCH-CURRENT-TOKEN "IDENTIFIER) + ?(GETL (SETQ tmptok (CURRENT-SYMBOL)) ParseMode) + ?(LT RBP (PARSE-leftBindingPowerOf tmptok ParseMode)) + .(SETQ RBP (PARSE-rightBindingPowerOf tmptok ParseMode)) + getSemanticForm{tmptok ParseMode (ELEMN (GETL tmptok ParseMode) 5 NIL)} ; + +% Binding powers stored under the Led and Red properties of an operator +% are set up by the file BOTTOMUP.LISP. The format for a Led property +% is , and the same for a Nud, except that +% it may also have a fourth component . ELEMN attempts to +% get the Nth indicator, counting from 1. + +leftBindingPowerOf{X IND}: =(LET ((Y (GETL X IND))) (IF Y (ELEMN Y 3 0) 0)) ; + +rightBindingPowerOf{X IND}: =(LET ((Y (GETL X IND))) (IF Y (ELEMN Y 4 105) 105)) ; + +getSemanticForm{X IND Y}: + ?(AND Y (EVAL Y)) / ?(EQ IND "Nud) Prefix / ?(EQ IND "Led) Infix ; + + +Reduction: ReductionOp Expr{1000} +(Reduce #2 #1) ; + +ReductionOp: ?(AND (GETL (CURRENT-SYMBOL) "Led) + (MATCH-NEXT-TOKEN "SPECIAL-CHAR (CODE-CHAR 47))) % Forgive me! + +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN) .(ADVANCE-TOKEN) ; + +Form: 'iterate' < 'from' Label +(#1) >! +(iterate -#1) + / 'yield' Application +(yield #1) + / Application ; + +Application: Primary * ; + +Selector: ?NONBLANK ?(EQ (CURRENT-SYMBOL) "\.) ?(CHAR-NE (CURRENT-CHAR) "\ ) + '.' PrimaryNoFloat (=\$BOOT +(ELT #2 #1)/ +(#2 #1)) + / (Float /'.' Primary) (=\$BOOT +(ELT #2 #1)/ +(#2 #1)); + +PrimaryNoFloat: Primary1 ; + +Primary: Float /PrimaryNoFloat ; + +Primary1: VarForm <=(AND NONBLANK (EQ (CURRENT-SYMBOL) "\()) Primary1 +(#2 #1)> + /Quad + /String + /IntegerTok + /FormalParameter + /='\'' (?\$BOOT Data / '\'' Expr{999} +(QUOTE #1)) + /Sequence + /Enclosure ; + +Float: FloatBase (?NONBLANK FloatExponent / +0) +=(MAKE-FLOAT #4 #2 #2 #1) ; + +FloatBase: ?(FIXP (CURRENT-SYMBOL)) ?(CHAR-EQ (CURRENT-CHAR) '.') + ?(CHAR-NE (NEXT-CHAR) '.') + IntegerTok FloatBasePart + /?(FIXP (CURRENT-SYMBOL)) ?(CHAR-EQ (CHAR-UPCASE (CURRENT-CHAR)) "E) + IntegerTok +0 +0 + /?(DIGITP (CURRENT-CHAR)) ?(EQ (CURRENT-SYMBOL) "\.) + +0 FloatBasePart ; + +FloatBasePart: '.' + (?(DIGITP (CURRENT-CHAR)) +=(TOKEN-NONBLANK (CURRENT-TOKEN)) IntegerTok + / +0 +0); + + +FloatExponent: =(AND (MEMBER (CURRENT-SYMBOL) "(E e)) + (FIND (CURRENT-CHAR) '+-')) + .(ADVANCE-TOKEN) + (IntegerTok/'+' IntegerTok/'-' IntegerTok +=(MINUS #1)/+0) + /?(IDENTP (CURRENT-SYMBOL)) =(SETQ $1 (FLOATEXPID (CURRENT-SYMBOL))) + .(ADVANCE-TOKEN) +=$1 ; + +Enclosure: '(' ( Expr{6} ')' / ')' +(Tuple) ) + / '{' ( Expr{6} '}' +(brace (construct #1)) / '}' +(brace)) ; + +IntegerTok: NUMBER ; + +FloatTok: NUMBER +=(IF \$BOOT #1 (BFP- #1)) ; + +FormalParameter: FormalParameterTok ; + +FormalParameterTok: ARGUMENT-DESIGNATOR ; + +Quad: '$' +\$ / ?\$BOOT GliphTok{"\.} +\. ; + +String: SPADSTRING ; + +VarForm: Name +#1 ; + +Scripts: ?NONBLANK '[' ScriptItem ']' ; + +ScriptItem: Expr{90} <(';' ScriptItem)* +(\; #2 -#1)> + / ';' ScriptItem +(PrefixSC #1) ; + +Name: IDENTIFIER +#1 ; + +Data: .(SETQ LABLASOC NIL) Sexpr +(QUOTE =(TRANSLABEL #1 LABLASOC)) ; + +Sexpr: .(ADVANCE-TOKEN) Sexpr1 ; + +Sexpr1: AnyId + < NBGliphTok{"\=} Sexpr1 + .(SETQ LABLASOC (CONS (CONS #2 ##1) LABLASOC))> + / '\'' Sexpr1 +(QUOTE #1) + / IntegerTok + / '-' IntegerTok +=(MINUS #1) + / String + / '<' ! '>' +=(LIST2VEC #1) + / '(' >! ')' ; + +NBGliphTok{tok}: ?(AND (MATCH-CURRENT-TOKEN "GLIPH tok) NONBLANK) + .(ADVANCE-TOKEN) ; + +GliphTok{tok}: ?(MATCH-CURRENT-TOKEN "GLIPH tok) .(ADVANCE-TOKEN) ; + +AnyId: IDENTIFIER + / (='$' +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN) / KEYWORD) ; + +Sequence: OpenBracket Sequence1 ']' + / OpenBrace Sequence1 '}' +(brace #1) ; + +Sequence1: (Expression +(#2 #1) / +(#1)) ; + +OpenBracket: =(EQ (getToken (SETQ $1 (CURRENT-SYMBOL))) "\[ ) + (=(EQCAR $1 "elt) +(elt =(CADR $1) construct) + / +construct) .(ADVANCE-TOKEN) ; + +OpenBrace: =(EQ (getToken (SETQ $1 (CURRENT-SYMBOL))) "\{ ) + (=(EQCAR $1 "elt) +(elt =(CADR $1) brace) + / +construct) .(ADVANCE-TOKEN) ; + +IteratorTail: ('repeat' ! / Iterator*) ; + +.FIN ; + +\end{verbatim} + \defun{PARSE-NewExpr}{PARSE-NewExpr} \calls{PARSE-NewExpr}{match-string} \calls{PARSE-NewExpr}{action} @@ -3022,6 +3272,547 @@ It is pretty much just a translation of DEF-IS-REV @ +\defun{PARSE-leftBindingPowerOf}{PARSE-leftBindingPowerOf} +\calls{PARSE-leftBindingPowerOf}{getl} +\calls{PARSE-leftBindingPowerOf}{elemn} +<>= +(defun |PARSE-leftBindingPowerOf| (x ind) + (declare (special x ind)) + (let ((y (getl x ind))) (if y (elemn y 3 0) 0))) + +@ + +\defun{PARSE-rightBindingPowerOf}{PARSE-rightBindingPowerOf} +\calls{PARSE-rightBindingPowerOf}{getl} +\calls{PARSE-rightBindingPowerOf}{elemn} +<>= +(defun |PARSE-rightBindingPowerOf| (x ind) + (declare (special x ind)) + (let ((y (getl x ind))) (if y (elemn y 4 105) 105))) + +@ + +\defun{PARSE-getSemanticForm}{PARSE-getSemanticForm} +\calls{PARSE-getSemanticForm}{PARSE-Prefix} +\calls{PARSE-getSemanticForm}{PARSE-Infix} +<>= +(defun |PARSE-getSemanticForm| (x ind y) + (declare (special x ind y)) + (or (and y (eval y)) (and (eq ind '|Nud|) (|PARSE-Prefix|)) + (and (eq ind '|Led|) (|PARSE-Infix|)))) + +@ + +\defun{PARSE-Prefix}{PARSE-Prefix} +\calls{PARSE-Prefix}{push-reduction} +\calls{PARSE-Prefix}{current-symbol} +\calls{PARSE-Prefix}{action} +\calls{PARSE-Prefix}{advance-token} +\calls{PARSE-Prefix}{optional} +\calls{PARSE-Prefix}{PARSE-TokTail} +\calls{PARSE-Prefix}{must} +\calls{PARSE-Prefix}{PARSE-Expression} +\calls{PARSE-Prefix}{push-reduction} +\calls{PARSE-Prefix}{pop-stack-2} +\calls{PARSE-Prefix}{pop-stack-1} +<>= +(defun |PARSE-Prefix| () + (and (push-reduction '|PARSE-Prefix| (current-symbol)) + (action (advance-token)) (optional (|PARSE-TokTail|)) + (must (|PARSE-Expression|)) + (push-reduction '|PARSE-Prefix| + (cons (pop-stack-2) (cons (pop-stack-1) nil))))) + +@ + +\defun{PARSE-Infix}{PARSE-Infix} +\calls{PARSE-Infix}{push-reduction} +\calls{PARSE-Infix}{current-symbol} +\calls{PARSE-Infix}{action} +\calls{PARSE-Infix}{advance-token} +\calls{PARSE-Infix}{optional} +\calls{PARSE-Infix}{PARSE-TokTail} +\calls{PARSE-Infix}{must} +\calls{PARSE-Infix}{PARSE-Expression} +\calls{PARSE-Infix}{pop-stack-2} +\calls{PARSE-Infix}{pop-stack-1} +<>= +(defun |PARSE-Infix| () + (and (push-reduction '|PARSE-Infix| (current-symbol)) + (action (advance-token)) (optional (|PARSE-TokTail|)) + (must (|PARSE-Expression|)) + (push-reduction '|PARSE-Infix| + (list (pop-stack-2) (pop-stack-2) (pop-stack-1) )))) + +@ + +\defun{PARSE-TokTail}{PARSE-TokTail} +\calls{PARSE-TokTail}{current-symbol} +\calls{PARSE-TokTail}{current-char} +\calls{PARSE-TokTail}{char-eq} +\calls{PARSE-TokTail}{copy-token} +\calls{PARSE-TokTail}{action} +\calls{PARSE-TokTail}{PARSE-Qualification} +\usesdollar{PARSE-TokTail}{boot} +<>= +(defun |PARSE-TokTail| () + (let (g1) + (and (null $boot) (eq (current-symbol) '$) + (or (alpha-char-p (current-char)) + (char-eq (current-char) "$") + (char-eq (current-char) "%") + (char-eq (current-char) "(")) + (action (setq g1 (copy-token prior-token))) + (|PARSE-Qualification|) (action (setq prior-token g1))))) + +@ + +\defun{PARSE-Qualification}{PARSE-Qualification} +\calls{PARSE-Qualification}{match-advance-string} +\calls{PARSE-Qualification}{must} +\calls{PARSE-Qualification}{PARSE-Primary1} +\calls{PARSE-Qualification}{push-reduction} +\calls{PARSE-Qualification}{dollarTran} +\calls{PARSE-Qualification}{pop-stack-1} +<>= +(defun |PARSE-Qualification| () + (and (match-advance-string "$") (must (|PARSE-Primary1|)) + (push-reduction '|PARSE-Qualification| + (|dollarTran| (pop-stack-1) (pop-stack-1))))) + +@ + +\defun{PARSE-Reduction}{PARSE-Reduction} +\calls{PARSE-Reduction}{PARSE-ReductionOp} +\calls{PARSE-Reduction}{must} +\calls{PARSE-Reduction}{PARSE-Expr} +\calls{PARSE-Reduction}{push-reduction} +\calls{PARSE-Reduction}{pop-stack-2} +\calls{PARSE-Reduction}{pop-stack-1} +<>= +(defun |PARSE-Reduction| () + (and (|PARSE-ReductionOp|) (must (|PARSE-Expr| 1000)) + (push-reduction '|PARSE-Reduction| + (list '|Reduce| (pop-stack-2) (pop-stack-1) )))) + +@ + +\defun{PARSE-ReductionOp}{PARSE-ReductionOp} +\calls{PARSE-ReductionOp}{getl} +\calls{PARSE-ReductionOp}{current-symbol} +\calls{PARSE-ReductionOp}{match-next-token} +\calls{PARSE-ReductionOp}{action} +\calls{PARSE-ReductionOp}{advance-token} +<>= +(defun |PARSE-ReductionOp| () + (and (getl (current-symbol) '|Led|) + (match-next-token 'special-char (code-char 47)) + (push-reduction '|PARSE-ReductionOp| (current-symbol)) + (action (advance-token)) (action (advance-token)))) + +@ + +\defun{PARSE-Form}{PARSE-Form} +\calls{PARSE-Form}{match-advance-string} +\calls{PARSE-Form}{bang} +\calls{PARSE-Form}{optional} +\calls{PARSE-Form}{must} +\calls{PARSE-Form}{push-reduction} +\calls{PARSE-Form}{pop-stack-1} +\calls{PARSE-Form}{PARSE-Application} +<>= +(defun |PARSE-Form| () + (or (and (match-advance-string "iterate") + (bang fil_test + (optional + (and (match-advance-string "from") + (must (|PARSE-Label|)) + (push-reduction '|PARSE-Form| + (list (pop-stack-1)))))) + (push-reduction '|PARSE-Form| + (cons '|iterate| (append (pop-stack-1) nil)))) + (and (match-advance-string "yield") (must (|PARSE-Application|)) + (push-reduction '|PARSE-Form| + (list '|yield| (pop-stack-1)))) + (|PARSE-Application|))) + +@ + +\defun{PARSE-Application}{PARSE-Application} +\calls{PARSE-Application}{PARSE-Primary} +\calls{PARSE-Application}{optional} +\calls{PARSE-Application}{star} +\calls{PARSE-Application}{PARSE-Selector} +\calls{PARSE-Application}{PARSE-Application} +\calls{PARSE-Application}{push-reduction} +\calls{PARSE-Application}{pop-stack-2} +\calls{PARSE-Application}{pop-stack-1} +<>= +(defun |PARSE-Application| () + (and (|PARSE-Primary|) (optional (star opt_expr (|PARSE-Selector|))) + (optional + (and (|PARSE-Application|) + (push-reduction '|PARSE-Application| + (list (pop-stack-2) (pop-stack-1))))))) + +@ + +\defun{PARSE-Label}{PARSE-Label} +\calls{PARSE-Label}{match-advance-string} +\calls{PARSE-Label}{must} +\calls{PARSE-Label}{PARSE-Name} +<>= +(defun |PARSE-Label| () + (and (match-advance-string "<<") (must (|PARSE-Name|)) + (must (match-advance-string ">>")))) + +@ + +\defun{PARSE-Selector}{PARSE-Selector} +\calls{PARSE-Selector}{current-symbol} +\calls{PARSE-Selector}{char-ne} +\calls{PARSE-Selector}{current-char} +\calls{PARSE-Selector}{match-advance-string} +\calls{PARSE-Selector}{must} +\calls{PARSE-Selector}{PARSE-PrimaryNoFloat} +\calls{PARSE-Selector}{push-reduction} +\calls{PARSE-Selector}{pop-stack-2} +\calls{PARSE-Selector}{pop-stack-1} +\calls{PARSE-Selector}{PARSE-Float} +\calls{PARSE-Selector}{PARSE-Primary} +\usesdollar{PARSE-Selector}{boot} +<>= +(defun |PARSE-Selector| () + (or (and nonblank (eq (current-symbol) '|.|) + (char-ne (current-char) '| |) (match-advance-string ".") + (must (|PARSE-PrimaryNoFloat|)) + (must (or (and $boot + (push-reduction '|PARSE-Selector| + (list 'elt (pop-stack-2) (pop-stack-1)))) + (push-reduction '|PARSE-Selector| + (list (pop-stack-2) (pop-stack-1)))))) + (and (or (|PARSE-Float|) + (and (match-advance-string ".") + (must (|PARSE-Primary|)))) + (must (or (and $boot + (push-reduction '|PARSE-Selector| + (list 'elt (pop-stack-2) (pop-stack-1)))) + (push-reduction '|PARSE-Selector| + (list (pop-stack-2) (pop-stack-1)))))))) + +@ + +\defun{PARSE-PrimaryNoFloat}{PARSE-PrimaryNoFloat} +\calls{PARSE-PrimaryNoFloat}{PARSE-Primary1} +\calls{PARSE-PrimaryNoFloat}{optional} +\calls{PARSE-PrimaryNoFloat}{PARSE-TokTail} +<>= +(defun |PARSE-PrimaryNoFloat| () + (and (|PARSE-Primary1|) (optional (|PARSE-TokTail|)))) + +@ + +\defun{PARSE-Primary}{PARSE-Primary} +\calls{PARSE-Primary}{} +\calls{PARSE-Primary}{} +<>= +(defun |PARSE-Primary| () + (or (|PARSE-Float|) (|PARSE-PrimaryNoFloat|))) + +@ + +\defun{PARSE-Primary1}{PARSE-Primary1} +\calls{PARSE-Primary1}{PARSE-VarForm} +\calls{PARSE-Primary1}{optional} +\calls{PARSE-Primary1}{current-symbol} +\calls{PARSE-Primary1}{PARSE-Primary1} +\calls{PARSE-Primary1}{must} +\calls{PARSE-Primary1}{pop-stack-2} +\calls{PARSE-Primary1}{pop-stack-1} +\calls{PARSE-Primary1}{push-reduction} +\calls{PARSE-Primary1}{PARSE-Quad} +\calls{PARSE-Primary1}{PARSE-String} +\calls{PARSE-Primary1}{PARSE-IntegerTok} +\calls{PARSE-Primary1}{PARSE-FormalParameter} +\calls{PARSE-Primary1}{match-string} +\calls{PARSE-Primary1}{PARSE-Data} +\calls{PARSE-Primary1}{match-advance-string} +\calls{PARSE-Primary1}{PARSE-Expr} +\calls{PARSE-Primary1}{PARSE-Sequence} +\calls{PARSE-Primary1}{PARSE-Enclosure} +\usesdollar{PARSE-Primary1}{boot} +<>= +(defun |PARSE-Primary1| () + (or (and (|PARSE-VarForm|) + (optional + (and nonblank (eq (current-symbol) '|(|) + (must (|PARSE-Primary1|)) + (push-reduction '|PARSE-Primary1| + (list (pop-stack-2) (pop-stack-1)))))) + (|PARSE-Quad|) (|PARSE-String|) (|PARSE-IntegerTok|) + (|PARSE-FormalParameter|) + (and (match-string "'") + (must (or (and $boot (|PARSE-Data|)) + (and (match-advance-string "'") + (must (|PARSE-Expr| 999)) + (push-reduction '|PARSE-Primary1| + (list 'quote (pop-stack-1))))))) + (|PARSE-Sequence|) (|PARSE-Enclosure|))) + +@ + +\defun{PARSE-Float}{PARSE-Float} +\calls{PARSE-Float}{PARSE-FloatBase} +\calls{PARSE-Float}{must} +\calls{PARSE-Float}{PARSE-FloatExponent} +\calls{PARSE-Float}{push-reduction} +\calls{PARSE-Float}{make-float} +\calls{PARSE-Float}{pop-stack-4} +\calls{PARSE-Float}{pop-stack-3} +\calls{PARSE-Float}{pop-stack-2} +\calls{PARSE-Float}{pop-stack-1} +<>= +(defun |PARSE-Float| () + (and (|PARSE-FloatBase|) + (must (or (and nonblank (|PARSE-FloatExponent|)) + (push-reduction '|PARSE-Float| 0))) + (push-reduction '|PARSE-Float| + (make-float (pop-stack-4) (pop-stack-2) (pop-stack-2) + (pop-stack-1))))) + +@ + +\defun{PARSE-FloatBase}{PARSE-FloatBase} +\calls{PARSE-FloatBase}{integerp} +\calls{PARSE-FloatBase}{current-symbol} +\calls{PARSE-FloatBase}{char-eq} +\calls{PARSE-FloatBase}{current-char} +\calls{PARSE-FloatBase}{char-ne} +\calls{PARSE-FloatBase}{next-char} +\calls{PARSE-FloatBase}{PARSE-IntegerTok} +\calls{PARSE-FloatBase}{must} +\calls{PARSE-FloatBase}{PARSE-FloatBasePart} +\calls{PARSE-FloatBase}{char-upcase} +\calls{PARSE-FloatBase}{PARSE-IntegerTok} +\calls{PARSE-FloatBase}{push-reduction} +\calls{PARSE-FloatBase}{digitp} +<>= +(defun |PARSE-FloatBase| () + (or (and (integerp (current-symbol)) (char-eq (current-char) ".") + (char-ne (next-char) ".") (|PARSE-IntegerTok|) + (must (|PARSE-FloatBasePart|))) + (and (integerp (current-symbol)) + (char-eq (char-upcase (current-char)) 'e) + (|PARSE-IntegerTok|) (push-reduction '|PARSE-FloatBase| 0) + (push-reduction '|PARSE-FloatBase| 0)) + (and (digitp (current-char)) (eq (current-symbol) '|.|) + (push-reduction '|PARSE-FloatBase| 0) + (|PARSE-FloatBasePart|)))) + +@ + +\defun{PARSE-FloatBasePart}{PARSE-FloatBasePart} +\calls{PARSE-FloatBasePart}{match-advance-string} +\calls{PARSE-FloatBasePart}{must} +\calls{PARSE-FloatBasePart}{digitp} +\calls{PARSE-FloatBasePart}{current-char} +\calls{PARSE-FloatBasePart}{push-reduction} +\calls{PARSE-FloatBasePart}{token-nonblank} +\calls{PARSE-FloatBasePart}{current-token} +\calls{PARSE-FloatBasePart}{PARSE-IntegerTok} +<>= +(defun |PARSE-FloatBasePart| () + (and (match-advance-string ".") + (must (or (and (digitp (current-char)) + (push-reduction '|PARSE-FloatBasePart| + (token-nonblank (current-token))) + (|PARSE-IntegerTok|)) + (and (push-reduction '|PARSE-FloatBasePart| 0) + (push-reduction '|PARSE-FloatBasePart| 0)))))) + +@ + +\defun{PARSE-FloatExponent}{PARSE-FloatExponent} +\calls{PARSE-FloatExponent}{current-symbol} +\calls{PARSE-FloatExponent}{current-char} +\calls{PARSE-FloatExponent}{action} +\calls{PARSE-FloatExponent}{advance-token} +\calls{PARSE-FloatExponent}{PARSE-IntegerTok} +\calls{PARSE-FloatExponent}{match-advance-string} +\calls{PARSE-FloatExponent}{must} +\calls{PARSE-FloatExponent}{push-reduction} +\calls{PARSE-FloatExponent}{identp} +\calls{PARSE-FloatExponent}{floatexpid} +<>= +(defun |PARSE-FloatExponent| () + (let (g1) + (or (and (member (current-symbol) '(e |e|)) + (find (current-char) "+-") (action (advance-token)) + (must (or (|PARSE-IntegerTok|) + (and (match-advance-string "+") + (must (|PARSE-IntegerTok|))) + (and (match-advance-string "-") + (must (|PARSE-IntegerTok|)) + (push-reduction '|PARSE-FloatExponent| + (- (pop-stack-1)))) + (push-reduction '|PARSE-FloatExponent| 0)))) + (and (identp (current-symbol)) + (setq g1 (floatexpid (current-symbol))) + (action (advance-token)) + (push-reduction '|PARSE-FloatExponent| g1))))) + +@ + +\defun{PARSE-Enclosure}{PARSE-Enclosure} +\calls{PARSE-Enclosure}{match-advance-string} +\calls{PARSE-Enclosure}{must} +\calls{PARSE-Enclosure}{PARSE-Expr} +\calls{PARSE-Enclosure}{push-reduction} +\calls{PARSE-Enclosure}{pop-stack-1} +<>= +(defun |PARSE-Enclosure| () + (or (and (match-advance-string "(") + (must (or (and (|PARSE-Expr| 6) + (must (match-advance-string ")"))) + (and (match-advance-string ")") + (push-reduction '|PARSE-Enclosure| + (list '|@Tuple|)))))) + (and (match-advance-string "{") + (must (or (and (|PARSE-Expr| 6) + (must (match-advance-string "}")) + (push-reduction '|PARSE-Enclosure| + (cons '|brace| + (list (list '|construct| (pop-stack-1)))))) + (and (match-advance-string "}") + (push-reduction '|PARSE-Enclosure| + (list '|brace|)))))))) + +@ + +\defun{PARSE-IntegerTok}{PARSE-IntegerTok} +\calls{PARSE-IntegerTok}{parse-number} +<>= +(defun |PARSE-IntegerTok| () (parse-number)) + +@ + +\defun{PARSE-FormalParameter}{PARSE-FormalParameter} +\calls{PARSE-FormalParameter}{PARSE-FormalParameterTok} +<>= +(defun |PARSE-FormalParameter| () (|PARSE-FormalParameterTok|)) + +@ + +\defun{PARSE-FormalParameterTok}{PARSE-FormalParameterTok} +\calls{PARSE-FormalParameterTok}{parse-argument-designator} +<>= +(defun |PARSE-FormalParameterTok| () (parse-argument-designator)) + +@ + +\defun{PARSE-Quad}{PARSE-Quad} +\calls{PARSE-Quad}{match-advance-string} +\calls{PARSE-Quad}{push-reduction} +\calls{PARSE-Quad}{PARSE-GliphTok} +\usesdollar{PARSE-Quad}{boot} +<>= +(defun |PARSE-Quad| () + (or (and (match-advance-string "$") + (push-reduction '|PARSE-Quad| '$)) + (and $boot (|PARSE-GliphTok| '|.|) + (push-reduction '|PARSE-Quad| '|.|)))) + +@ + +\defun{PARSE-String}{PARSE-String} +\calls{PARSE-String}{parse-spadstring} +<>= +(defun |PARSE-String| () (parse-spadstring)) + +@ + +\defun{PARSE-VarForm}{PARSE-VarForm} +\calls{PARSE-VarForm}{PARSE-Name} +\calls{PARSE-VarForm}{optional} +\calls{PARSE-VarForm}{PARSE-Scripts} +\calls{PARSE-VarForm}{push-reduction} +\calls{PARSE-VarForm}{pop-stack-2} +\calls{PARSE-VarForm}{pop-stack-1} +<>= +(defun |PARSE-VarForm| () + (and (|PARSE-Name|) + (optional + (and (|PARSE-Scripts|) + (push-reduction '|PARSE-VarForm| + (list '|Scripts| (pop-stack-2) (pop-stack-1))))) + (push-reduction '|PARSE-VarForm| (pop-stack-1)))) + +@ + +\defun{PARSE-Scripts}{PARSE-Scripts} +\calls{PARSE-Scripts}{match-advance-string} +\calls{PARSE-Scripts}{must} +\calls{PARSE-Scripts}{PARSE-ScriptItem} +<>= +(defun |PARSE-Scripts| () + (and nonblank (match-advance-string "[") (must (|PARSE-ScriptItem|)) + (must (match-advance-string "]")))) + +@ + +\defun{PARSE-ScriptItem}{PARSE-ScriptItem} +\calls{PARSE-ScriptItem}{PARSE-Expr} +\calls{PARSE-ScriptItem}{optional} +\calls{PARSE-ScriptItem}{star} +\calls{PARSE-ScriptItem}{match-advance-string} +\calls{PARSE-ScriptItem}{must} +\calls{PARSE-ScriptItem}{PARSE-ScriptItem} +\calls{PARSE-ScriptItem}{push-reduction} +\calls{PARSE-ScriptItem}{pop-stack-2} +\calls{PARSE-ScriptItem}{pop-stack-1} +<>= +(defun |PARSE-ScriptItem| () + (or (and (|PARSE-Expr| 90) + (optional + (and (star repeator + (and (match-advance-string ";") + (must (|PARSE-ScriptItem|)))) + (push-reduction '|PARSE-ScriptItem| + (cons '|;| + (cons (pop-stack-2) + (append (pop-stack-1) nil))))))) + (and (match-advance-string ";") (must (|PARSE-ScriptItem|)) + (push-reduction '|PARSE-ScriptItem| + (list '|PrefixSC| (pop-stack-1)))))) + +@ + +\defun{PARSE-Name}{PARSE-Name} +\calls{PARSE-Name}{parse-identifier} +\calls{PARSE-Name}{push-reduction} +\calls{PARSE-Name}{pop-stack-1} +<>= +(defun |PARSE-Name| () + (and (parse-identifier) (push-reduction '|PARSE-Name| (pop-stack-1)))) + +@ + +\defun{PARSE-Data}{PARSE-Data} +\calls{PARSE-Data}{action} +\calls{PARSE-Data}{PARSE-Sexpr} +\calls{PARSE-Data}{push-reduction} +\calls{PARSE-Data}{translabel} +\calls{PARSE-Data}{pop-stack-1} +\uses{PARSE-Data}{labasoc} +<>= +(defun |PARSE-Data| () + (declare (special lablasoc)) + (and (action (setq lablasoc nil)) (|PARSE-Sexpr|) + (push-reduction '|PARSE-Data| + (list 'quote (translabel (pop-stack-1) lablasoc))))) + +@ + \chapter{The Compiler} \section{Compiling EQ.spad} @@ -6180,24 +6971,54 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> +<> <> <> <> +<> <> <> +<> +<> +<> +<> +<> +<> +<> +<> <> +<> <> +<> +<> <> +<> +<> <> <> <> <> +<> +<> +<> +<> <> +<> +<> +<> +<> +<> +<> +<> +<> <> <> <> +<> <> <> +<> +<> <> <> <> diff --git a/changelog b/changelog index babceb3..db2b2a9 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +20101016 tpd src/axiom-website/patches.html 20101016.03.tpd.patch +20101016 tpd src/interp/parsing.lisp treeshake compiler +20101016 tpd books/bookvol9 treeshake compiler 20101016 tpd src/axiom-website/patches.html 20101016.02.tpd.patch 20101016 tpd src/interp/parsing.lisp treeshake compiler 20101016 tpd books/bookvol9 treeshake compiler diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 7a098c4..660acf0 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3222,5 +3222,7 @@ books/bookvol9 treeshake compiler
books/bookvol9 treeshake compiler
20101016.02.tpd.patch books/bookvol9 treeshake compiler
+20101016.03.tpd.patch +books/bookvol9 treeshake compiler
diff --git a/src/interp/parsing.lisp.pamphlet b/src/interp/parsing.lisp.pamphlet index 06695f0..553f067 100644 --- a/src/interp/parsing.lisp.pamphlet +++ b/src/interp/parsing.lisp.pamphlet @@ -1668,257 +1668,6 @@ except that elements are separated by commas." (if (ATOM l) l `(CONS ,(CAR l) ,(|newConstruct| (CDR l))))) @ -<>= -% Scratchpad II Boot Language Grammar, Common Lisp Version -% IBM Thomas J. Watson Research Center -% Summer, 1986 -% -% NOTE: Substantially different from VM/LISP version, due to -% different parser and attempt to render more within META proper. - -.META(New NewExpr Process) -.PACKAGE 'BOOT' -.DECLARE(tmptok TOK ParseMode DEFINITION_NAME LABLASOC) -.PREFIX 'PARSE-' - -NewExpr: =')' .(processSynonyms) Command - / .(SETQ DEFINITION_NAME (CURRENT-SYMBOL)) Statement ; - -Command: ')' SpecialKeyWord SpecialCommand +() ; - -SpecialKeyWord: =(MATCH-CURRENT-TOKEN "IDENTIFIER) - .(SETF (TOKEN-SYMBOL (CURRENT-TOKEN)) (unAbbreviateKeyword (CURRENT-SYMBOL))) ; - -SpecialCommand: 'show' <'?' / Expression>! +(show #1) CommandTail - / ?(MEMBER (CURRENT-SYMBOL) \$noParseCommands) - .(FUNCALL (CURRENT-SYMBOL)) - / ?(MEMBER (CURRENT-SYMBOL) \$tokenCommands) TokenList - TokenCommandTail - / PrimaryOrQM* CommandTail ; - -TokenList: (^?(isTokenDelimiter) +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN))* ; - -TokenCommandTail: - ! ?(atEndOfLine) +(#2 -#1) .(systemCommand #1) ; - -TokenOption: ')' TokenList ; - -CommandTail: ! ?(atEndOfLine) +(#2 -#1) .(systemCommand #1) ; - -PrimaryOrQM: '?' +\? / Primary ; - -Option: ')' PrimaryOrQM* ; - -Statement: Expr{0} <(',' Expr{0})* +(Series #2 -#1)>; - -InfixWith: With +(Join #2 #1) ; - -With: 'with' Category +(with #1) ; - -Category: 'if' Expression 'then' Category <'else' Category>! +(if #3 #2 #1) - / '(' Category <(';' Category)*>! ')' +(CATEGORY #2 -#1) - / .(SETQ $1 (LINE-NUMBER CURRENT-LINE)) Application - ( ':' Expression +(Signature #2 #1) - .(recordSignatureDocumentation ##1 $1) - / +(Attribute #1) - .(recordAttributeDocumentation ##1 $1)); - -Expression: Expr{(PARSE-rightBindingPowerOf (MAKE-SYMBOL-OF PRIOR-TOKEN) ParseMode)} - +#1 ; - -Import: 'import' Expr{1000} <(',' Expr{1000})*>! +(import #2 -#1) ; - -Infix: =TRUE +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN) - Expression +(#2 #2 #1) ; - -Prefix: =TRUE +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN) - Expression +(#2 #1) ; - -Suffix: +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN) +(#1 #1) ; - -TokTail: ?(AND (NULL \$BOOT) (EQ (CURRENT-SYMBOL) "\$) - (OR (ALPHA-CHAR-P (CURRENT-CHAR)) - (CHAR-EQ (CURRENT-CHAR) '$') - (CHAR-EQ (CURRENT-CHAR) '\%') - (CHAR-EQ (CURRENT-CHAR) '('))) - .(SETQ $1 (COPY-TOKEN PRIOR-TOKEN)) Qualification - .(SETQ PRIOR-TOKEN $1) ; - -Qualification: '$' Primary1 +=(dollarTran #1 #1) ; - -SemiColon: ';' (Expr{82} / + \/throwAway) +(\; #2 #1) ; - -Return: 'return' Expression +(return #1) ; - -Exit: 'exit' (Expression / +\$NoValue) +(exit #1) ; - -Leave: 'leave' ( Expression / +\$NoValue ) - ('from' Label +(leaveFrom #1 #1) / +(leave #1)) ; - -Seg: GliphTok{"\.\.} ! +(SEGMENT #2 #1) ; - -Conditional: 'if' Expression 'then' Expression <'else' ElseClause>! - +(if #3 #2 #1) ; - -ElseClause: ?(EQ (CURRENT-SYMBOL) "if) Conditional / Expression ; - -Loop: Iterator* 'repeat' Expr{110} +(REPEAT -#2 #1) - / 'repeat' Expr{110} +(REPEAT #1) ; - -Iterator: 'for' Primary 'in' Expression - ( 'by' Expr{200} +(INBY #3 #2 #1) / +(IN #2 #1) ) - < '\|' Expr{111} +(\| #1) > - / 'while' Expr{190} +(WHILE #1) - / 'until' Expr{190} +(UNTIL #1) ; - -Expr{RBP}: NudPart{RBP} * +#1; - -LabelExpr: Label Expr{120} +(LABEL #2 #1) ; - -Label: '<<' Name '>>' ; - -LedPart{RBP}: Operation{"Led RBP} +#1; - -NudPart{RBP}: (Operation{"Nud RBP} / Reduction / Form) +#1 ; - -Operation{ParseMode RBP}: - ^?(MATCH-CURRENT-TOKEN "IDENTIFIER) - ?(GETL (SETQ tmptok (CURRENT-SYMBOL)) ParseMode) - ?(LT RBP (PARSE-leftBindingPowerOf tmptok ParseMode)) - .(SETQ RBP (PARSE-rightBindingPowerOf tmptok ParseMode)) - getSemanticForm{tmptok ParseMode (ELEMN (GETL tmptok ParseMode) 5 NIL)} ; - -% Binding powers stored under the Led and Red properties of an operator -% are set up by the file BOTTOMUP.LISP. The format for a Led property -% is , and the same for a Nud, except that -% it may also have a fourth component . ELEMN attempts to -% get the Nth indicator, counting from 1. - -leftBindingPowerOf{X IND}: =(LET ((Y (GETL X IND))) (IF Y (ELEMN Y 3 0) 0)) ; - -rightBindingPowerOf{X IND}: =(LET ((Y (GETL X IND))) (IF Y (ELEMN Y 4 105) 105)) ; - -getSemanticForm{X IND Y}: - ?(AND Y (EVAL Y)) / ?(EQ IND "Nud) Prefix / ?(EQ IND "Led) Infix ; - - -Reduction: ReductionOp Expr{1000} +(Reduce #2 #1) ; - -ReductionOp: ?(AND (GETL (CURRENT-SYMBOL) "Led) - (MATCH-NEXT-TOKEN "SPECIAL-CHAR (CODE-CHAR 47))) % Forgive me! - +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN) .(ADVANCE-TOKEN) ; - -Form: 'iterate' < 'from' Label +(#1) >! +(iterate -#1) - / 'yield' Application +(yield #1) - / Application ; - -Application: Primary * ; - -Selector: ?NONBLANK ?(EQ (CURRENT-SYMBOL) "\.) ?(CHAR-NE (CURRENT-CHAR) "\ ) - '.' PrimaryNoFloat (=\$BOOT +(ELT #2 #1)/ +(#2 #1)) - / (Float /'.' Primary) (=\$BOOT +(ELT #2 #1)/ +(#2 #1)); - -PrimaryNoFloat: Primary1 ; - -Primary: Float /PrimaryNoFloat ; - -Primary1: VarForm <=(AND NONBLANK (EQ (CURRENT-SYMBOL) "\()) Primary1 +(#2 #1)> - /Quad - /String - /IntegerTok - /FormalParameter - /='\'' (?\$BOOT Data / '\'' Expr{999} +(QUOTE #1)) - /Sequence - /Enclosure ; - -Float: FloatBase (?NONBLANK FloatExponent / +0) +=(MAKE-FLOAT #4 #2 #2 #1) ; - -FloatBase: ?(FIXP (CURRENT-SYMBOL)) ?(CHAR-EQ (CURRENT-CHAR) '.') - ?(CHAR-NE (NEXT-CHAR) '.') - IntegerTok FloatBasePart - /?(FIXP (CURRENT-SYMBOL)) ?(CHAR-EQ (CHAR-UPCASE (CURRENT-CHAR)) "E) - IntegerTok +0 +0 - /?(DIGITP (CURRENT-CHAR)) ?(EQ (CURRENT-SYMBOL) "\.) - +0 FloatBasePart ; - -FloatBasePart: '.' - (?(DIGITP (CURRENT-CHAR)) +=(TOKEN-NONBLANK (CURRENT-TOKEN)) IntegerTok - / +0 +0); - - -FloatExponent: =(AND (MEMBER (CURRENT-SYMBOL) "(E e)) - (FIND (CURRENT-CHAR) '+-')) - .(ADVANCE-TOKEN) - (IntegerTok/'+' IntegerTok/'-' IntegerTok +=(MINUS #1)/+0) - /?(IDENTP (CURRENT-SYMBOL)) =(SETQ $1 (FLOATEXPID (CURRENT-SYMBOL))) - .(ADVANCE-TOKEN) +=$1 ; - -Enclosure: '(' ( Expr{6} ')' / ')' +(Tuple) ) - / '{' ( Expr{6} '}' +(brace (construct #1)) / '}' +(brace)) ; - -IntegerTok: NUMBER ; - -FloatTok: NUMBER +=(IF \$BOOT #1 (BFP- #1)) ; - -FormalParameter: FormalParameterTok ; - -FormalParameterTok: ARGUMENT-DESIGNATOR ; - -Quad: '$' +\$ / ?\$BOOT GliphTok{"\.} +\. ; - -String: SPADSTRING ; - -VarForm: Name +#1 ; - -Scripts: ?NONBLANK '[' ScriptItem ']' ; - -ScriptItem: Expr{90} <(';' ScriptItem)* +(\; #2 -#1)> - / ';' ScriptItem +(PrefixSC #1) ; - -Name: IDENTIFIER +#1 ; - -Data: .(SETQ LABLASOC NIL) Sexpr +(QUOTE =(TRANSLABEL #1 LABLASOC)) ; - -Sexpr: .(ADVANCE-TOKEN) Sexpr1 ; - -Sexpr1: AnyId - < NBGliphTok{"\=} Sexpr1 - .(SETQ LABLASOC (CONS (CONS #2 ##1) LABLASOC))> - / '\'' Sexpr1 +(QUOTE #1) - / IntegerTok - / '-' IntegerTok +=(MINUS #1) - / String - / '<' ! '>' +=(LIST2VEC #1) - / '(' >! ')' ; - -NBGliphTok{tok}: ?(AND (MATCH-CURRENT-TOKEN "GLIPH tok) NONBLANK) - .(ADVANCE-TOKEN) ; - -GliphTok{tok}: ?(MATCH-CURRENT-TOKEN "GLIPH tok) .(ADVANCE-TOKEN) ; - -AnyId: IDENTIFIER - / (='$' +=(CURRENT-SYMBOL) .(ADVANCE-TOKEN) / KEYWORD) ; - -Sequence: OpenBracket Sequence1 ']' - / OpenBrace Sequence1 '}' +(brace #1) ; - -Sequence1: (Expression +(#2 #1) / +(#1)) ; - -OpenBracket: =(EQ (getToken (SETQ $1 (CURRENT-SYMBOL))) "\[ ) - (=(EQCAR $1 "elt) +(elt =(CADR $1) construct) - / +construct) .(ADVANCE-TOKEN) ; - -OpenBrace: =(EQ (getToken (SETQ $1 (CURRENT-SYMBOL))) "\{ ) - (=(EQCAR $1 "elt) +(elt =(CADR $1) brace) - / +construct) .(ADVANCE-TOKEN) ; - -IteratorTail: ('repeat' ! / Iterator*) ; - -.FIN ; - - -@ -fnewmeta <>= (DEFPARAMETER |tmptok| NIL) @@ -1928,25 +1677,6 @@ fnewmeta (DEFPARAMETER LABLASOC NIL) -(DEFUN |PARSE-Infix| () - (AND (PUSH-REDUCTION '|PARSE-Infix| (CURRENT-SYMBOL)) - (ACTION (ADVANCE-TOKEN)) (OPTIONAL (|PARSE-TokTail|)) - (MUST (|PARSE-Expression|)) - (PUSH-REDUCTION '|PARSE-Infix| - (CONS (POP-STACK-2) - (CONS (POP-STACK-2) (CONS (POP-STACK-1) NIL)))))) -(trace |PARSE-Infix|) - - -(DEFUN |PARSE-Prefix| () - (AND (PUSH-REDUCTION '|PARSE-Prefix| (CURRENT-SYMBOL)) - (ACTION (ADVANCE-TOKEN)) (OPTIONAL (|PARSE-TokTail|)) - (MUST (|PARSE-Expression|)) - (PUSH-REDUCTION '|PARSE-Prefix| - (CONS (POP-STACK-2) (CONS (POP-STACK-1) NIL))))) -(trace |PARSE-Prefix|) - - (DEFUN |PARSE-Suffix| () (AND (PUSH-REDUCTION '|PARSE-Suffix| (CURRENT-SYMBOL)) (ACTION (ADVANCE-TOKEN)) (OPTIONAL (|PARSE-TokTail|)) @@ -1955,26 +1685,6 @@ fnewmeta (trace |PARSE-Suffix|) -(DEFUN |PARSE-TokTail| () - (PROG (G1) - (RETURN - (AND (NULL $BOOT) (EQ (CURRENT-SYMBOL) '$) - (OR (ALPHA-CHAR-P (CURRENT-CHAR)) - (CHAR-EQ (CURRENT-CHAR) "$") - (CHAR-EQ (CURRENT-CHAR) "%") - (CHAR-EQ (CURRENT-CHAR) "(")) - (ACTION (SETQ G1 (COPY-TOKEN PRIOR-TOKEN))) - (|PARSE-Qualification|) (ACTION (SETQ PRIOR-TOKEN G1)))))) -(trace |PARSE-TokTail|) - - -(DEFUN |PARSE-Qualification| () - (AND (MATCH-ADVANCE-STRING "$") (MUST (|PARSE-Primary1|)) - (PUSH-REDUCTION '|PARSE-Qualification| - (|dollarTran| (POP-STACK-1) (POP-STACK-1))))) -(trace |PARSE-Qualification|) - - (DEFUN |PARSE-SemiColon| () (AND (MATCH-ADVANCE-STRING ";") (MUST (OR (|PARSE-Expr| 82) @@ -2093,206 +1803,6 @@ fnewmeta (trace |PARSE-LabelExpr|) -(DEFUN |PARSE-Label| () - (AND (MATCH-ADVANCE-STRING "<<") (MUST (|PARSE-Name|)) - (MUST (MATCH-ADVANCE-STRING ">>")))) -(trace |PARSE-Label|) - - -(DEFUN |PARSE-leftBindingPowerOf| (X IND) - (DECLARE (SPECIAL X IND)) - (LET ((Y (GETL X IND))) (IF Y (ELEMN Y 3 0) 0))) -(trace |PARSE-leftBindingPowerOf|) - - -(DEFUN |PARSE-rightBindingPowerOf| (X IND) - (DECLARE (SPECIAL X IND)) - (LET ((Y (GETL X IND))) (IF Y (ELEMN Y 4 105) 105))) -(trace |PARSE-rightBindingPowerOf|) - - -(DEFUN |PARSE-getSemanticForm| (X IND Y) - (DECLARE (SPECIAL X IND Y)) - (OR (AND Y (EVAL Y)) (AND (EQ IND '|Nud|) (|PARSE-Prefix|)) - (AND (EQ IND '|Led|) (|PARSE-Infix|)))) -(trace |PARSE-getSemanticForm|) - - -(DEFUN |PARSE-Reduction| () - (AND (|PARSE-ReductionOp|) (MUST (|PARSE-Expr| 1000)) - (PUSH-REDUCTION '|PARSE-Reduction| - (CONS '|Reduce| - (CONS (POP-STACK-2) (CONS (POP-STACK-1) NIL)))))) -(trace |PARSE-Reduction|) - - -(DEFUN |PARSE-ReductionOp| () - (AND (GETL (CURRENT-SYMBOL) '|Led|) - (MATCH-NEXT-TOKEN 'SPECIAL-CHAR (CODE-CHAR 47)) - (PUSH-REDUCTION '|PARSE-ReductionOp| (CURRENT-SYMBOL)) - (ACTION (ADVANCE-TOKEN)) (ACTION (ADVANCE-TOKEN)))) -(trace |PARSE-ReductionOp|) - - -(DEFUN |PARSE-Form| () - (OR (AND (MATCH-ADVANCE-STRING "iterate") - (BANG FIL_TEST - (OPTIONAL - (AND (MATCH-ADVANCE-STRING "from") - (MUST (|PARSE-Label|)) - (PUSH-REDUCTION '|PARSE-Form| - (CONS (POP-STACK-1) NIL))))) - (PUSH-REDUCTION '|PARSE-Form| - (CONS '|iterate| (APPEND (POP-STACK-1) NIL)))) - (AND (MATCH-ADVANCE-STRING "yield") (MUST (|PARSE-Application|)) - (PUSH-REDUCTION '|PARSE-Form| - (CONS '|yield| (CONS (POP-STACK-1) NIL)))) - (|PARSE-Application|))) -(trace |PARSE-Form|) - - -(DEFUN |PARSE-Application| () - (AND (|PARSE-Primary|) (OPTIONAL (STAR OPT_EXPR (|PARSE-Selector|))) - (OPTIONAL - (AND (|PARSE-Application|) - (PUSH-REDUCTION '|PARSE-Application| - (CONS (POP-STACK-2) (CONS (POP-STACK-1) NIL))))))) -(trace |PARSE-Application|) - - -(DEFUN |PARSE-Selector| () - (OR (AND NONBLANK (EQ (CURRENT-SYMBOL) '|.|) - (CHAR-NE (CURRENT-CHAR) '| |) (MATCH-ADVANCE-STRING ".") - (MUST (|PARSE-PrimaryNoFloat|)) - (MUST (OR (AND $BOOT - (PUSH-REDUCTION '|PARSE-Selector| - (CONS 'ELT - (CONS (POP-STACK-2) - (CONS (POP-STACK-1) NIL))))) - (PUSH-REDUCTION '|PARSE-Selector| - (CONS (POP-STACK-2) (CONS (POP-STACK-1) NIL)))))) - (AND (OR (|PARSE-Float|) - (AND (MATCH-ADVANCE-STRING ".") - (MUST (|PARSE-Primary|)))) - (MUST (OR (AND $BOOT - (PUSH-REDUCTION '|PARSE-Selector| - (CONS 'ELT - (CONS (POP-STACK-2) - (CONS (POP-STACK-1) NIL))))) - (PUSH-REDUCTION '|PARSE-Selector| - (CONS (POP-STACK-2) (CONS (POP-STACK-1) NIL)))))))) -(trace |PARSE-Selector|) - - -(DEFUN |PARSE-PrimaryNoFloat| () - (AND (|PARSE-Primary1|) (OPTIONAL (|PARSE-TokTail|)))) -(trace |PARSE-PrimaryNoFloat|) - - -(DEFUN |PARSE-Primary| () - (OR (|PARSE-Float|) (|PARSE-PrimaryNoFloat|))) -(trace |PARSE-Primary|) - - -(DEFUN |PARSE-Primary1| () - (OR (AND (|PARSE-VarForm|) - (OPTIONAL - (AND NONBLANK (EQ (CURRENT-SYMBOL) '|(|) - (MUST (|PARSE-Primary1|)) - (PUSH-REDUCTION '|PARSE-Primary1| - (CONS (POP-STACK-2) (CONS (POP-STACK-1) NIL)))))) - (|PARSE-Quad|) (|PARSE-String|) (|PARSE-IntegerTok|) - (|PARSE-FormalParameter|) - (AND (MATCH-STRING "'") - (MUST (OR (AND $BOOT (|PARSE-Data|)) - (AND (MATCH-ADVANCE-STRING "'") - (MUST (|PARSE-Expr| 999)) - (PUSH-REDUCTION '|PARSE-Primary1| - (CONS 'QUOTE (CONS (POP-STACK-1) NIL))))))) - (|PARSE-Sequence|) (|PARSE-Enclosure|))) -(trace |PARSE-Primary1|) - -(DEFUN |PARSE-Float| () - (AND (|PARSE-FloatBase|) - (MUST (OR (AND NONBLANK (|PARSE-FloatExponent|)) - (PUSH-REDUCTION '|PARSE-Float| 0))) - (PUSH-REDUCTION '|PARSE-Float| - (MAKE-FLOAT (POP-STACK-4) (POP-STACK-2) (POP-STACK-2) - (POP-STACK-1))))) -(trace |PARSE-Float|) - - -(DEFUN |PARSE-FloatBase| () - (OR (AND (integerp (CURRENT-SYMBOL)) (CHAR-EQ (CURRENT-CHAR) ".") - (CHAR-NE (NEXT-CHAR) ".") (|PARSE-IntegerTok|) - (MUST (|PARSE-FloatBasePart|))) - (AND (integerp (CURRENT-SYMBOL)) - (CHAR-EQ (CHAR-UPCASE (CURRENT-CHAR)) 'E) - (|PARSE-IntegerTok|) (PUSH-REDUCTION '|PARSE-FloatBase| 0) - (PUSH-REDUCTION '|PARSE-FloatBase| 0)) - (AND (DIGITP (CURRENT-CHAR)) (EQ (CURRENT-SYMBOL) '|.|) - (PUSH-REDUCTION '|PARSE-FloatBase| 0) - (|PARSE-FloatBasePart|)))) -(trace |PARSE-FloatBase|) - - -(DEFUN |PARSE-FloatBasePart| () - (AND (MATCH-ADVANCE-STRING ".") - (MUST (OR (AND (DIGITP (CURRENT-CHAR)) - (PUSH-REDUCTION '|PARSE-FloatBasePart| - (TOKEN-NONBLANK (CURRENT-TOKEN))) - (|PARSE-IntegerTok|)) - (AND (PUSH-REDUCTION '|PARSE-FloatBasePart| 0) - (PUSH-REDUCTION '|PARSE-FloatBasePart| 0)))))) -(trace |PARSE-FloatBasePart|) - - -(DEFUN |PARSE-FloatExponent| () - (PROG (G1) - (RETURN - (OR (AND (MEMBER (CURRENT-SYMBOL) '(E |e|)) - (FIND (CURRENT-CHAR) "+-") (ACTION (ADVANCE-TOKEN)) - (MUST (OR (|PARSE-IntegerTok|) - (AND (MATCH-ADVANCE-STRING "+") - (MUST (|PARSE-IntegerTok|))) - (AND (MATCH-ADVANCE-STRING "-") - (MUST (|PARSE-IntegerTok|)) - (PUSH-REDUCTION '|PARSE-FloatExponent| - (MINUS (POP-STACK-1)))) - (PUSH-REDUCTION '|PARSE-FloatExponent| 0)))) - (AND (IDENTP (CURRENT-SYMBOL)) - (SETQ G1 (FLOATEXPID (CURRENT-SYMBOL))) - (ACTION (ADVANCE-TOKEN)) - (PUSH-REDUCTION '|PARSE-FloatExponent| G1)))))) -(trace |PARSE-FloatExponent|) - - -(DEFUN |PARSE-Enclosure| () - (OR (AND (MATCH-ADVANCE-STRING "(") - (MUST (OR (AND (|PARSE-Expr| 6) - (MUST (MATCH-ADVANCE-STRING ")"))) - (AND (MATCH-ADVANCE-STRING ")") - (PUSH-REDUCTION '|PARSE-Enclosure| - (CONS '|@Tuple| NIL)))))) - (AND (MATCH-ADVANCE-STRING "{") - (MUST (OR (AND (|PARSE-Expr| 6) - (MUST (MATCH-ADVANCE-STRING "}")) - (PUSH-REDUCTION '|PARSE-Enclosure| - (CONS '|brace| - (CONS - (CONS '|construct| - (CONS (POP-STACK-1) NIL)) - NIL)))) - (AND (MATCH-ADVANCE-STRING "}") - (PUSH-REDUCTION '|PARSE-Enclosure| - (CONS '|brace| NIL)))))))) -(trace |PARSE-Enclosure|) - - -(DEFUN |PARSE-IntegerTok| () (PARSE-NUMBER)) -(trace |PARSE-IntegerTok|) - - (DEFUN |PARSE-FloatTok| () (AND (PARSE-NUMBER) (PUSH-REDUCTION '|PARSE-FloatTok| @@ -2300,71 +1810,6 @@ fnewmeta (trace |PARSE-FloatTok|) -(DEFUN |PARSE-FormalParameter| () (|PARSE-FormalParameterTok|)) -(trace |PARSE-FormalParameter|) - - -(DEFUN |PARSE-FormalParameterTok| () (PARSE-ARGUMENT-DESIGNATOR)) -(trace |PARSE-FormalParameterTok|) - - -(DEFUN |PARSE-Quad| () - (OR (AND (MATCH-ADVANCE-STRING "$") - (PUSH-REDUCTION '|PARSE-Quad| '$)) - (AND $BOOT (|PARSE-GliphTok| '|.|) - (PUSH-REDUCTION '|PARSE-Quad| '|.|)))) -(trace |PARSE-Quad|) - - -(DEFUN |PARSE-String| () (PARSE-SPADSTRING)) -(trace |PARSE-String|) - - -(DEFUN |PARSE-VarForm| () - (AND (|PARSE-Name|) - (OPTIONAL - (AND (|PARSE-Scripts|) - (PUSH-REDUCTION '|PARSE-VarForm| - (CONS '|Scripts| - (CONS (POP-STACK-2) (CONS (POP-STACK-1) NIL)))))) - (PUSH-REDUCTION '|PARSE-VarForm| (POP-STACK-1)))) -(trace |PARSE-VarForm|) - - -(DEFUN |PARSE-Scripts| () - (AND NONBLANK (MATCH-ADVANCE-STRING "[") (MUST (|PARSE-ScriptItem|)) - (MUST (MATCH-ADVANCE-STRING "]")))) -(trace |PARSE-Scripts|) - - -(DEFUN |PARSE-ScriptItem| () - (OR (AND (|PARSE-Expr| 90) - (OPTIONAL - (AND (STAR REPEATOR - (AND (MATCH-ADVANCE-STRING ";") - (MUST (|PARSE-ScriptItem|)))) - (PUSH-REDUCTION '|PARSE-ScriptItem| - (CONS '|;| - (CONS (POP-STACK-2) - (APPEND (POP-STACK-1) NIL))))))) - (AND (MATCH-ADVANCE-STRING ";") (MUST (|PARSE-ScriptItem|)) - (PUSH-REDUCTION '|PARSE-ScriptItem| - (CONS '|PrefixSC| (CONS (POP-STACK-1) NIL)))))) -(trace |PARSE-ScriptItem|) - - -(DEFUN |PARSE-Name| () - (AND (PARSE-IDENTIFIER) (PUSH-REDUCTION '|PARSE-Name| (POP-STACK-1)))) -(trace |PARSE-Name|) - - -(DEFUN |PARSE-Data| () - (AND (ACTION (SETQ LABLASOC NIL)) (|PARSE-Sexpr|) - (PUSH-REDUCTION '|PARSE-Data| - (CONS 'QUOTE (CONS (TRANSLABEL (POP-STACK-1) LABLASOC) NIL))))) -(trace |PARSE-Data|) - - (DEFUN |PARSE-Sexpr| () (AND (ACTION (ADVANCE-TOKEN)) (|PARSE-Sexpr1|))) (trace |PARSE-Sexpr|)