. Lexical Elements of LISP Most LISP's use a subset of ASCII: .See http://www/dick/samples/comp.text.ASCII.html space::=" "| CR | LF | HT |... . white_space::= space #space. One or more space characters. char::=`any ASCII character`. digit::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0". letter::= "A".."Z" | "a".."z", sign::= "+" | "-". quote::="\"", comma::=",", period::=".", parenthesis::="(" | ")", back_quote::="`", at_sign::="@", , semicolon::=";" 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: lexical_input::= #( $atom | $delimiter | $dot | $whitespace | $comment), 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 comment::= $semicolon #$char $end_of_line. delimiter::= $comma | $parenthesis | $brackets | ..., For x, non(x)::= $char~(x). O::=$optional, optional(x)::= (x|). string::= $quote #$non($quote) $quote, .As_is "string" Strings are atoms that can include spaces and where the case of the letters is significant. number::= $fixed_point_number |$floating_point_number, fixed_point_number::= $optional($sign) $digit #$digit, floating_point_number::= $optional($sign) $digit #$digit $period $digit #$digit, -- floating point is not available in every LISP. atom::= $string | $number | $word, -- an atom is the fundamental unit of data in LISP. 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. 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! dot::=$period. . Special Atoms nil::="NIL"|"nil", -- indicates an empty list. false::=$nil, true::= "T" | "t", true::$scheme= "#t", false::=$scheme= "#f", lambda::="LAMBDA" | "lambda", -- operator indicating a function cond::="COND" | "cond", -- operator for conditional expressions. define::$scheme="DEFINE" | "define", -- operator that defines a function. defun::="DEFUN" | "defun", -- operator that defines a function. car::="CAR" | "car", -- function return the front of a list cdr::="CDR" | "cdr", -- function returning the rest of a list. cons::="CONS"|"cons",-- a function that constructs a CAR/CDR pair. progn::="PROGN" | "progn", -- an operator for constructing blocks and compound statements. let::="LET" | "LET", -- an operator for constructing blocks with local variables. ... . There are a great many other ready made functions in most LISPs, for example in the XLISP implemented at CSUSB: .See http://www/dick/samples/lisp.functions.html . Glossary scheme::=a modern simplified and statically scoped LISP.