home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / TOOLS / TOKENIZE.DOC < prev    next >
Text File  |  1996-06-04  |  3KB  |  94 lines

  1. #    $Id: Tokenizer.doc,v 1.2 1994/12/08 23:48:19 duchier Exp $    
  2.  
  3.                           TOKENIZER FOR LIFE
  4.  
  5.  
  6.  NAME
  7.  
  8.  tokenizer: a complete tokenizer for Life programs.
  9.  
  10.  
  11.  USAGE 
  12.  
  13.       tokenize(filename) ? 
  14.  
  15.  reads in  the file filename and writes the obtained tokens in the file
  16.  filename_toks. 
  17.  
  18.  
  19.  FILES
  20.  
  21.  The file tokenizer.lf contains the tokenizer.
  22.  
  23.  The other files are:
  24.  - accumulators.lf, std_expander.lf and acc_declarations.lf 
  25.  
  26.  All these files are automatically loaded if they are in the same directory. 
  27.  
  28.  They must be loaded with expand_load(true).
  29.  
  30.  DESCRIPTION 
  31.  
  32.  Characters belong to one of the following categories:
  33.  - void characters: space, nl, tab
  34.  - syntactic characters: {}[]()?
  35.  - atom characters: any uppercase or lowcase letter, underscore
  36.  - operator characters: ~ ` ! # $ ^ & * - + = : | > < / \ 
  37.  - delimiters: " '
  38.  - special characters: @ , ; . 
  39.  
  40.  The tokens are of the following types:
  41.     - variable(X) where X is the name of the variable (an atom); 
  42.       A variable is any sequence of atom characters, beginning with an
  43.       uppercase letter or with underscore (in the latter case, the sequence
  44.       must contain at least two characters), possibly terminated by primes;
  45.     - construct(X) represents a constructor X. 
  46.       The type of a constructor is a subsort of construct: numb, chaine, or
  47.       atom. X is the "value" of the atom (string, number, or unevaluated atom)
  48.       - a number is of the form 123 or 123.56 or 123.56e12 or 123.56e-12 
  49.       - a string is any sequence of characters delimited by " . Any " occurring
  50.         inside a string have to be doubled;
  51.       - an atom is any sequence of characters delimited by ' ( any ' occurring
  52.         inside such an atom have to be doubled), or any sequence of atom
  53.         characters starting with a lowcase letter, or @, or _, or any sequence
  54.         of operator characters, or in some cases the dot (returned as
  55.         atom(".")).   
  56.     - any syntactic object (returned as the string "[" or "}") or in some cases
  57.       the dot (returned as ".") or "[|", "|]", "[|]".
  58.  
  59.  The dot may be tokenized in three different ways, depending on the context in
  60.  which it appears:
  61.    - It is not returned as a token if it occurs inside a floating point
  62.      number;
  63.    - It is returned as a syntactic object "." if it is followed by a void
  64.      character (tab, nl, space, or end_of_file)
  65.    - it is returned as atom(".") otherwise.
  66.  
  67.  This tokenizer allows the user to define his own syntactic objects, using the
  68.  query syntact_object(X), where X is an atom, but not a string, nor a number.
  69.  In this case, the tokenizer returns the string "X", and not atom(X).
  70.  
  71.  Comments:
  72.  - All the characters between % and the end of the line where it appears are
  73.    ignored.
  74.  - This tokenizer also recognises nested comments (using /* and */ as
  75.    delimiters). * and / can still be freely used inside sequences of operator
  76.    characters. 
  77.  
  78.  Extensions w.r.t. wild_Life: 
  79.  - primes at the end of atoms and variables.
  80.  - nested comments
  81.  - syntact_object declaration
  82.  - dots tokenizing
  83.  - special tokens for lists
  84.                            
  85.  AUTHOR 
  86.  
  87.  Bruno Dumant
  88.  
  89.  Copyright 1992 Digital Equipment Corporation
  90.  All Rights Reserved
  91.  
  92.  
  93.  
  94.