nlex.lsp

Module index

source download

Module: Nlex

Author: cormullion

newLISP source code lexer/tokenizer/parser

Location: https://github.com/cormullion/newlisp-projects
Version: 0.1 of 2011-09-19 08:55:19

About this module

The Nlex module is a lexer/tokenizer/parser for newLISP source code. An expert from StackOverflow xplains: A tokenizer breaks a stream of text into tokens. A lexer is basically a tokenizer, but it usually attaches extra context to the tokens. A parser takes the stream of tokens from the lexer and turns it into an abstract syntax tree representing the program represented by the original text.

Usage

To tokenize/parse source code stored in symbol 'original, use parse-newlisp, To convert the parsed source tree back to plain source, use nlx-to-plaintext:

(letn ((converted    (Nlex:parse-newlisp     original-source)) ; parses 
       (new-original (Nlex:nlx-to-plaintext  converted)))      ; converts back to plain text

After this round trip, original-source and new-original should be identical.



- ∂ -

generated with newLISP  and newLISPdoc