File: example.lisp

package info (click to toggle)
cl-lexer 1-5
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 88 kB
  • sloc: lisp: 160; makefile: 52; sh: 28
file content (24 lines) | stat: -rw-r--r-- 548 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(eval-when (:compile-toplevel :load-toplevel :execute)
  (require :lexer))

(defpackage #:test-lexer
  (:use #:common-lisp #:lexer)
  (:export #:test))

(in-package #:test-lexer)

(deflexer test-lexer
    ("[0-9]+([.][0-9]+([Ee][0-9]+)?)"
     (return (values 'flt (num %0))))
  ("[0-9]+"
   (return (values 'int (int %0))))
  ("[:alpha:][:alnum:]*"
   (return (values 'name %0)))
  ("[:space:]+") )


(defparameter *lex* (test-lexer "1.0 12 fred 10.23e12"))

(defun test ()
  (loop repeat 5
        collect (multiple-value-list (funcall *lex*))))