[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci Dept] / [R J Botting] / [Samples] / lisp.lexemes
[Index] [Contents] [Source Text] [About] [Notation] [Copyright] [Comment/Contact] [Search ]
Tue Sep 18 15:26:04 PDT 2007

Contents


    Lexical Elements of LISP

    Most LISP's use a subset of ASCII: [ comp.text.ASCII.html ]
  1. space::=" "| CR | LF | HT |... .
  2. white_space::= space #space. One or more space characters.
  3. char::=any ASCII character.
  4. digit::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0".
  5. letter::= "A".."Z" | "a".."z",
  6. sign::= "+" | "-".
  7. quote::="\"",
  8. comma::=",",
  9. period::=".",
  10. parenthesis::="(" | ")",
  11. back_quote::="`",
  12. at_sign::="@", ,
  13. semicolon::=";"
  14. hash_sign::="#",...

    Lexical Analysis

    The LISP interpreter first does a lexical analysis of all input and splits up the input into delimiters and atoms, while discarding whitespace:
  15. lexical_input::= #( atom | delimiter | dot | whitespace | comment),
  16. lexical_output::= #( atom | delimiter | dot ).

    In many LISPs atoms that are not strings or numbers are converted to upper case. In other LISPs the same atoms are converted to lower case.

    The dot (a period) separated from an atom or number is use to idicate the fundamental data structure in LISP of the dotted pair: "( FIRST . SECOND)".

    Lexemes

  17. comment::= semicolon #char end_of_line.

  18. delimiter::= comma | parenthesis | brackets | ...,

  19. For x, non(x)::= char~(x).
  20. O::=optional,
  21. optional(x)::= (x|).

  22. string::= quote #non(quote) quote,
     		"string"
  23. Strings are atoms that can include spaces and where the case of the letters is significant.

  24. number::= fixed_point_number |floating_point_number,

  25. fixed_point_number::= optional(sign) digit #digit,

  26. floating_point_number::= optional(sign) digit #digit period digit #digit,
  27. -- floating point is not available in every LISP.

  28. atom::= string | number | word, -- an atom is the fundamental unit of data in LISP.

  29. word::=non_numeric_lexeme~dot, A word can not be a sigle dot or a number but it can be any string of non-space and non-delimeter characters.

  30. non_numeric_lexeme::=#non(space|delimiter) non(digit) #non(space|delimiter). -- one or more characters with at least one non-digit. Notice that a word that has no letter is treated as a number. Things like '*2' and '2a' are valid words!

  31. dot::=period.

    Special Atoms

  32. nil::="NIL"|"nil", -- indicates an empty list.
  33. false::=nil,
  34. true::= "T" | "t",
  35. true::scheme= "#t",
  36. false::=scheme= "#f",
  37. lambda::="LAMBDA" | "lambda", -- operator indicating a function
  38. cond::="COND" | "cond", -- operator for conditional expressions.
  39. define::scheme="DEFINE" | "define", -- operator that defines a function.
  40. defun::="DEFUN" | "defun", -- operator that defines a function.
  41. car::="CAR" | "car", -- function return the front of a list
  42. cdr::="CDR" | "cdr", -- function returning the rest of a list.
  43. cons::="CONS"|"cons",-- a function that constructs a CAR/CDR pair.
  44. progn::="PROGN" | "progn", -- an operator for constructing blocks and compound statements.
  45. let::="LET" | "LET", -- an operator for constructing blocks with local variables.
  46. ... . There are a great many other ready made functions in most LISPs, for example in the XLISP implemented at CSUSB: [ lisp.functions.html ]

    Glossary

  47. scheme::=a modern simplified and statically scoped LISP.

End