home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / j / jacal1a0.zip / jacal / code.doc < prev    next >
Text File  |  1992-12-16  |  2KB  |  71 lines

  1. JACAL uses some conventions to make conversion to other languages
  2. easier:
  3.  
  4.  Dynamic binding is not used.
  5.  
  6.  Multiple values are not used.
  7.  
  8.  No input editing is provided.  Only printing characters, space, tab, and
  9. newline are understood by the parser.
  10.  
  11.  Macros are not defined.
  12.  
  13.  The only data types used are (), cons, integer, character, string,
  14. simple-vector, symbol.
  15.  
  16.  Backquote is not used.
  17.  
  18.  Only escape continuations are used.
  19.  
  20.                   THE LEXER
  21.  
  22. In stdgrm.scm there are the lines:
  23. (lex:def-class 70 '(#\^) #f)
  24. (lex:def-class 49 '(#\*) #f)
  25. (lex:def-class 50 '(#\/) #f)
  26. (lex:def-class 51 '(#\+ #\-) #f)
  27. (lex:def-class 20 '(#\|) #f)
  28. (lex:def-class 30 '(#\< #\> #\= #\: #\~) #f)
  29. (lex:def-class 40 '(#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9)
  30.            (lambda (l) (string->number (list->string l))))
  31. (lex:def-class 41
  32.         '(#\A #\B #\C #\D #\E #\F #\G #\H #\I #\J #\K #\L #\M
  33.           #\N #\O #\P #\Q #\R #\S #\T #\U #\V #\W #\X #\Y #\Z
  34.           #\a #\b #\c #\d #\e #\f #\g #\h #\i #\j #\k #\l #\m
  35.           #\n #\o #\p #\q #\r #\s #\t #\u #\v #\w #\x #\y #\z
  36.           #\@ #\_ #\% #\?)
  37.         #f)
  38. (lex:def-class (lambda (chr) (or (eqv? #\" chr) (eof-object? chr)))
  39.         '(#\")
  40.         (lambda (l)
  41.           (lex:read-char) (string->symbol (list->string (cdr l)))))
  42. (lex:def-class 0 (list slib:tab slib:form-feed #\  #\newline) #f)
  43.  
  44. These lines define which character can be grouped into symbols in the
  45. standard input-grammar.  In the first line is only the character ^ and
  46. its class number is not 1 removed from any other.  Therefore it can
  47. only group with itself.  Eg.  ^ ^^ ^^^ ^^^^ ...
  48.  
  49. e5 : a+^^^^-c;
  50.  
  51. e5: ^^^^ + a - c
  52.  
  53. The line (lex:def-class 30 '(#\< #\> #\= #\: #\~) #f) says that any
  54. consecutive combination of < > = : and ~ will be grouped together.
  55.  
  56. 41 is one greater than 40 so a symbol can begin with a class 41
  57. character and continue with either class 41 or class 40 characters.
  58.  
  59. 51 can have subsequent 50 characters; this gives us +/- and -/+.
  60. 50 can have subsequent 49 characters; this gives us /*.
  61.  
  62. Class 0 is special (all the other numbers are arbitrary).  It
  63. designates whitespace.
  64.  
  65. #\" has a function rather than a class number.  This function is #t
  66. when the symbol should end.
  67.  
  68. The last argument to lex:def-class is the function to run on the list
  69. of characters of a symbol.  If #f then a symbol is generated from the
  70. character list.
  71.