/ \ / \ |\ / \ / \ chiral software | \ / \ \ \ |\ /| /| \| \ / |/ | |\ | /| / | \|/ |/ \ | / \|/ The Dendra Data Type -------------------- A union of: * integers - some approximation to Z. * real - some approximation to R. * strings - sequence of integers with range at least [0,255]. * symbols - a distinguished sort of string (and non-empty). * sequences - of Dendra data. ASCII Encoding -------------- dendra ::= {space} (int | float | string | symbol | seq) seq ::= '(' {dendra} {space} ')' space ::= isspace | comment int ::= [sign] dec dec ::= digit {digit} float ::= [sign] dec '.' dec [('e' | 'E') [sign] dec] sign ::= '+' | '-' string ::= '"' {strchar | esc | '\' newline} '"' esc ::= '\' special | '\' dec strchar ::= any - ('\' | '"') symbol ::= sign | [sign] initial {symchar} initial ::= symchar - isdigit symchar ::= (isgraphic - (special | isspace)) | esc special ::= '(' | ')' | '"' | '\' | '{' | '}' | ';' comment ::= ';' {any - newline} newline | '{' {token} {space} '}' token ::= {space} (int | float | string | symbol | ')' | '(') The 'isspace', 'isdigit', 'isgraphic' correspond to the C language 'ctypes' definitions; 'newline' is the newline character (decimal 10); 'any' is any character. Dendra can be considered to be defined on any character set compatible with ASCII. The ambiguities here can be resolved by the consume-longest-lexeme rule, which means: * reading things that look like floats as floats rather that sequences of ints and symbols * reading the longest possible sequences of digits and symbol characters Basically, Dendra data can be parsed by by looking for things in the following order: * whitespace and comments * sequences (recursivly) * strings * floats (not including plain integers) * int * symbols Lists (and strings) have the property that if there is a parse, the parse can stop without consuming any characters after the parse. Finite Map Extension -------------------- The next most useful data type is the dictionary or finite map. We suggest the following transformation from the Dendra type to Dendra with a finite map. plain dendra Dendra with finite map ------------ ---------------------- (dict K1 V1 K2 V2 ...) <=> a finite map with bindings (K1,V1) (K2,V2) ... (sym S) => S ((sym dict) ...) <= (dict ...) ((sym sym) ...) <= (sym ...) Here the Ks are strings or symbols (or possibly integers), the Vs are aribrary Dendra, and the S is a symbol.