ShenDoc 30


 

 

Shen YACC

Shen contains a YACC, just as Qi II, but the syntax was modified in 9.0 to bring it closer to Shen. This section briefly describes the differences.

The -*- (ditto -s- and -o-) indicating the head of the input stream is gone from YACC II and just as in Shen variables mark the position of isolated elements. This makes for a more powerful and flexible notation. The use of (fail) in a semantic action to trigger backtracking is dropped in favour of a guard. Thus the following tests a list of numbers to determine if the list is binary.

(defcc <binary?>
  X <binary?> := true where (element? X [0 1]);
  X := true where (element? X [0 1]);
  <e> := false;)

<!> consumes the remaining input.

(defcc <tl>
  _ <!> := <!>;)

returns the tail of a list. Shen-YACC recognises lists in the input.

(defcc <asbs>
  [a b] <asbs>;
  [a b];)

recognises lists of the form [[a b]], [[a b] [a b]], ....

The S series of kernels introduced types for Shen YACC functions.

(2+) (defcc <total>
        {(list number) ==> number}
        X <total> := (+ X <total>);
        X := X;)
(fn <total>) : ((list number) ==> number)

(3+) (compile (fn <total>) [1 2 3 4])
10 : number

TBoS is the source for the technology of Shen YACC.

Acknowledgements

History
Basic Types in Shen and Kλ
The Primitive Functions of Kλ
The Syntax of Kλ
Notes on the Implementation of Kλ
Boolean Operators
The Syntax of Symbols
The Semantics of Symbols in Shen and Kλ
Packages
Prolog
Shen-YACC
Strings
Strings and Pattern Matching
Lists
Streams
Character Streams and Byte Streams
Bytes and Unicode
Reader Macros
Vectors
Standard Vectors and Pattern Matching
Non-standard Vectors and Tuples
Equality
I/O
Generic Functions
Eval
Type Declarations
External Global Variables
Property Lists and Hashing
Error Handling
Numbers
Floats and Integers
The Timer
Comments
Special Forms

Built by Shen Technology (c) Mark Tarver, September 2021