guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, lua, updated. release_1-9-10-192-gb10c


From: No Itisnt
Subject: [Guile-commits] GNU Guile branch, lua, updated. release_1-9-10-192-gb10c4e5
Date: Tue, 25 May 2010 04:09:25 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=b10c4e52116f01860e159abe42b935560abbbb8c

The branch, lua has been updated
       via  b10c4e52116f01860e159abe42b935560abbbb8c (commit)
       via  f5f1bdae98dbdac9ef1314155282c19fa9eab9db (commit)
       via  39d9a470b12f67592c6bde023b0f774018a29d58 (commit)
       via  29b98fb2566e0b021ddbfaac70b6951bcb775cf3 (commit)
       via  139fa149a8dbb56a35178bc898e0f0bbfc33c19a (commit)
       via  43d6eb75f305cbe0ed9ca65024e6f5da597282bf (commit)
       via  96640816c8e69aa6a8fa5cdfd773a4218ea40eb5 (commit)
      from  2a0864e5f0c4fd1e7e6cbb117c28e36794dcc937 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b10c4e52116f01860e159abe42b935560abbbb8c
Author: No Itisnt <address@hidden>
Date:   Mon May 24 23:06:54 2010 -0500

    * test-suite/tests/lua.test: add simple tests

commit f5f1bdae98dbdac9ef1314155282c19fa9eab9db
Author: No Itisnt <address@hidden>
Date:   Mon May 24 21:24:31 2010 -0500

    * module/language/lua/lexer.scm: add basic lexical analyser

commit 39d9a470b12f67592c6bde023b0f774018a29d58
Merge: 2a0864e5f0c4fd1e7e6cbb117c28e36794dcc937 
29b98fb2566e0b021ddbfaac70b6951bcb775cf3
Author: No Itisnt <address@hidden>
Date:   Mon May 24 15:59:36 2010 -0500

    Merge branch 'master' of git.sv.gnu.org:/srv/git/guile into lua

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                     |  236 ++++++++++++------------------
 doc/ref/api-modules.texi                 |   35 ++---
 module/language/assembly/disassemble.scm |   10 +-
 module/language/lua/lexer.scm            |   44 ++++++
 test-suite/tests/lua.test                |   41 +++++
 5 files changed, 203 insertions(+), 163 deletions(-)
 create mode 100644 module/language/lua/lexer.scm
 create mode 100644 test-suite/tests/lua.test

diff --git a/NEWS b/NEWS
index d610d83..c58e569 100644
--- a/NEWS
+++ b/NEWS
@@ -8,83 +8,8 @@ Please send Guile bug reports to address@hidden
 (During the 1.9 series, we will keep an incremental NEWS for the latest
 prerelease, and a full NEWS corresponding to 1.8 -> 2.0.)
 
-Changes in 1.9.10 (since the 1.9.9 prerelease):
+Changes in 1.9.11 (since the 1.9.10 prerelease):
 
-** Hygienic macros documented as the primary syntactic extension mechanism.
-
-The macro documentation was finally fleshed out with some documentation
-on `syntax-case' macros, and other parts of the macro expansion process.
-See "Macros" in the manual, for details.
-
-** Interactive Guile follows GNU conventions
-
-As recommended by the GPL, Guile now shows a brief copyright and
-warranty disclaimer on startup, along with pointers to more information.
-On the other hand, changing languages is more concise.
-
-** Support for arbitrary procedure metadata
-
-Building on its support for docstrings, Guile now supports multiple
-docstrings, adding them to the tail of a compiled procedure's
-properties. For example:
-
-  (define (foo)
-    "one"
-    "two"
-    3)
-  (use-modules (system vm program))
-  (program-properties foo)
-  => ((name . foo) (documentation . "one") (documentation . "two"))
-
-Also, vectors of pairs are now treated as additional metadata entries:
-
-  (define (bar)
-    #((quz . #f) (docstring . "xyzzy"))
-    3)
-  (use-modules (system vm program))
-  (program-properties bar)
-  => ((name . bar) (quz . #f) (docstring . "xyzzy"))
-
-This allows arbitrary literals to be embedded as metadata in a compiled
-procedure.
-
-** Better documentation infrastructure for macros
-
-It is now possible to introspect on the type of a macro, e.g.
-syntax-rules, identifier-syntax, etc, and extract information about that
-macro, such as the syntax-rules patterns or the defmacro arguments.
-`(texinfo reflection)' takes advantage of this to give better macro
-documentation.
-
-** Autocompilation for applications that use Guile as an extension language
-
-It used to be that only applications that ran Guile through the
-`scm_shell' function got the advantages of autocompilation. This has
-been changed so that all applications have autocompilation on by
-default.
-
-** Better integration of Lisp nil
-
-`scm_is_boolean', `scm_is_false', and `scm_is_null' all return true now
-for Lisp's `nil'. This shouldn't affect any Scheme code at this point,
-but when we start to integrate more with Emacs, it is possible that we
-break code that assumes that, for example, `(not x)' implies that `x' is
-`eq?' to `#f'. This is not a common assumption. Refactoring affected
-code to rely on properties instead of identities will improve code
-correctness. See "Nil" in the manual, for more details.
-
-** Integration of lalr-scm, a parser generator
-
-Guile has included Dominique Boucher's fine `lalr-scm' parser generator
-as `(system base lalr)'. See "LALR(1) Parsing" in the manual, for more
-information.
-
-** Documentation for the dynamic foreign function interface (FFI).
-
-See "Foreign Function Interface" in the manual, for more information.
-
-** Unicode character set update to Unicode 5.2.
-    
 ** And of course, the usual collection of bugfixes
  
 Interested users should see the ChangeLog for more information.
@@ -109,6 +34,12 @@ The statprof statistical profiler, the SSAX XML toolkit, 
and the texinfo
 toolkit from Guile-Lib have been imported into Guile proper. See
 "Standard Library" in the manual for more details.
 
+** Integration of lalr-scm, a parser generator
+
+Guile has included Dominique Boucher's fine `lalr-scm' parser generator
+as `(system base lalr)'. See "LALR(1) Parsing" in the manual, for more
+information.
+
 * Changes to the stand-alone interpreter
 
 ** Guile now can compile Scheme to bytecode for a custom virtual machine.
@@ -116,11 +47,11 @@ toolkit from Guile-Lib have been imported into Guile 
proper. See
 Compiled code loads much faster than Scheme source code, and runs around
 3 or 4 times as fast, generating much less garbage in the process.
 
-** The stack limit is now initialized from the environment.
+** Evaluating Scheme code does not use the C stack.
 
-If getrlimit(2) is available and a stack limit is set, Guile will set
-its stack limit to 80% of the rlimit. Otherwise the limit is 160000
-words, a four-fold increase from the earlier default limit.
+Besides when compiling Guile itself, Guile no longer uses a recursive C
+function as an evaluator. This obviates the need to check the C stack
+pointer for overflow. Continuations still capture the C stack, however.
 
 ** New environment variables: GUILE_LOAD_COMPILED_PATH,
    GUILE_SYSTEM_LOAD_COMPILED_PATH
@@ -140,7 +71,7 @@ documented in the manual. This will be fixed before 2.0.
 
 The reader supports a new option (changeable via `read-options'),
 `square-brackets', which instructs it to interpret square brackets as
-parenthesis.  This option is on by default.
+parentheses.  This option is on by default.
 
 When the new `r6rs-hex-escapes' reader option is enabled, the reader
 will recognize string escape sequences as defined in R6RS.
@@ -185,6 +116,10 @@ allows Guile's copy of SSAX to override any Guile-Lib copy 
the user has
 installed. Also it should cut the number of `stat' system calls by half,
 in the common case.
 
+** Interactive Guile follows GNU conventions
+
+As recommended by the GPL, Guile now shows a brief copyright and
+warranty disclaimer on startup, along with pointers to more information.
 
 * Changes to Scheme functions and syntax
 
@@ -230,8 +165,7 @@ If you think you need `local-eval', you should probably 
implement your
 own metacircular evaluator. It will probably be as fast as Guile's
 anyway.
 
-** Files loaded with `primitive-load-path' will now be compiled
-   automatically.
+** Scheme source files will now be compiled automatically.
 
 If a compiled .go file corresponding to a .scm file is not found or is
 not fresh, the .scm file will be compiled on the fly, and the resulting
@@ -249,20 +183,6 @@ will be created if needed.
 To inhibit autocompilation, set the GUILE_AUTO_COMPILE environment
 variable to 0, or pass --no-autocompile on the Guile command line.
 
-** Files loaded with `load' will now be compiled automatically.
-
-As with files loaded via `primitive-load-path', `load' will also compile
-its target if autocompilation is enabled, and a fresh compiled file is
-not found.
-
-There are two points of difference to note, however. First, `load' does
-not search `GUILE_LOAD_COMPILED_PATH' for the file; it only looks in the
-autocompilation directory, normally a subdirectory of ~/.cache/guile.
-
-Secondly, autocompilation also applies to files loaded via the -l
-command-line argument -- so the user may experience a slight slowdown
-the first time they run a Guile script, as the script is autocompiled.
-
 ** New POSIX procedures: `getrlimit' and `setrlimit'
 
 Note however that the interface of these functions is likely to change
@@ -280,7 +200,7 @@ Scheme binding for the `getaddrinfo' C library function.
 
 ** New procedures in (ice-9 session): `add-value-help-handler!',
    `remove-value-help-handler!', `add-name-help-handler!'
-   `remove-name-help-handler!', `procedure-arguments',
+   `remove-name-help-handler!', `procedure-arguments'
 
 The value and name help handlers provide some minimal extensibility to
 the help interface. Guile-lib's `(texinfo reflection)' uses them, for
@@ -324,12 +244,37 @@ Guile now has an experimental Emacs Lisp compiler and 
runtime. You can
 now switch to Elisp at the repl: `,language elisp'. All kudos to Daniel
 Kraft, and all bugs to address@hidden
 
-** Defmacros may now have docstrings.
+** Better documentation infrastructure for macros
+
+It is now possible to introspect on the type of a macro, e.g.
+syntax-rules, identifier-syntax, etc, and extract information about that
+macro, such as the syntax-rules patterns or the defmacro arguments.
+`(texinfo reflection)' takes advantage of this to give better macro
+documentation.
+
+** Support for arbitrary procedure metadata
+
+Building on its support for docstrings, Guile now supports multiple
+docstrings, adding them to the tail of a compiled procedure's
+properties. For example:
+
+  (define (foo)
+    "one"
+    "two"
+    3)
+  (procedure-properties foo)
+  => ((name . foo) (documentation . "one") (documentation . "two"))
 
-Indeed, any macro may have a docstring. `object-documentation' from
-`(ice-9 documentation)' may be used to retrieve the docstring, once you
-have a macro value -- but see the above note about first-class macros.
-Docstrings are associated with the syntax transformer procedures.
+Also, vectors of pairs are now treated as additional metadata entries:
+
+  (define (bar)
+    #((quz . #f) (docstring . "xyzzy"))
+    3)
+  (procedure-properties bar)
+  => ((name . bar) (quz . #f) (docstring . "xyzzy"))
+
+This allows arbitrary literals to be embedded as metadata in a compiled
+procedure.
 
 ** The psyntax expander now knows how to interpret the @ and @@ special
    forms.
@@ -367,8 +312,8 @@ for more information.
 
 ** `eval-case' has been deprecated, and replaced by `eval-when'.
 
-The semantics of `eval-when' are easier to understand. It is still
-missing documentation, however.
+The semantics of `eval-when' are easier to understand. See "Eval When"
+in the manual, for more information.
 
 ** Guile is now more strict about prohibiting definitions in expression
    contexts.
@@ -455,18 +400,20 @@ the definition of `double-helper' in `eval-when':
   (define-macro (double-literal x) (double-helper x))
   (double-literal 2) => 4
 
-See the (currently missing) documentation for eval-when for more
-information.
+See the documentation for eval-when for more information.
 
-** New variable, %pre-modules-transformer
+** `macroexpand' produces structures, not S-expressions.
 
-Need to document this one some more.
+Given the need to maintain referential transparency, both lexically and
+modular, the result of expanding Scheme expressions is no longer itself
+an s-expression. If you want a human-readable approximation of the
+result of `macroexpand', call `tree-il->scheme' from `(language
+tree-il)'.
 
-** Temporarily removed functions: `macroexpand', `macroexpand-1'
+** Removed function: `macroexpand-1'
 
-`macroexpand' will be added back before 2.0. It is unclear how to
-implement `macroexpand-1' with syntax-case, though PLT Scheme does prove
-that it is possible.
+It is unclear how to implement `macroexpand-1' with syntax-case, though
+PLT Scheme does prove that it is possible.
 
 ** New reader macros: #' #` #, #,@
 
@@ -508,7 +455,7 @@ stack will result in an empty stack. To fix this, narrow to 
a procedure
 that is active in the current continuation, or narrow to a specific
 number of stack frames.
 
-** backtraces through compiled procedures only show procedures that are
+** Backtraces through compiled procedures only show procedures that are
    active in the current continuation
 
 Similarly to the previous issue, backtraces in compiled code may be
@@ -528,8 +475,8 @@ Before, `(define ((f a) b) (* a b))' would translate to
   (define f (lambda (a) (lambda (b) (* a b))))
 
 Now a syntax error is signaled, as this syntax is not supported by
-default. If there is sufficient demand, this syntax can be supported
-again by default.
+default. Use the `(ice-9 curried-definitions)' module to get back the
+old behavior.
 
 ** New procedure, `define!'
 
@@ -594,6 +541,12 @@ been removed, along with `defmacro-transformer', 
`macro-table',
 any of these procedures provided useful facilities to you, we encourage
 you to contact the Guile developers.
 
+** Hygienic macros documented as the primary syntactic extension mechanism.
+
+The macro documentation was finally fleshed out with some documentation
+on `syntax-rules' and `syntax-case' macros, and other parts of the macro
+expansion process. See "Macros" in the manual, for details.
+
 ** psyntax is now the default expander
 
 Scheme code is now expanded by default by the psyntax hygienic macro
@@ -618,7 +571,7 @@ in psyntax since then. If you find one, please notify 
address@hidden
 
 There is no longer any need to import the `(ice-9 syncase)' module
 (which is now deprecated). The expander may be invoked directly via
-`sc-expand', though it is normally searched for via the current module
+`macroexpand', though it is normally searched for via the current module
 transformer.
 
 Also, the helper routines for syntax-case are available in the default
@@ -626,11 +579,6 @@ environment as well: `syntax->datum', `datum->syntax',
 `bound-identifier=?', `free-identifier=?', `generate-temporaries',
 `identifier?', and `syntax-violation'. See the R6RS for documentation.
 
-** Documentation of `syntax-rules' and `syntax-case' macros
-
-The documentation of macros in the manual is now separate from that of
-procedures.  A new section on hygienic macros has been added.
-
 ** Tail patterns in syntax-case
 
 Guile has pulled in some more recent changes from the psyntax portable
@@ -685,9 +633,12 @@ Macros still /exist/ as first-class values, but they must 
be
 /referenced/ via the module system, e.g. `(module-ref (current-module)
 'if)'.
 
-This decision may be revisited before the 2.0 release. Feedback welcome
-to address@hidden (subscription required) or address@hidden (no
-subscription required).
+** Macros may now have docstrings.
+
+`object-documentation' from `(ice-9 documentation)' may be used to
+retrieve the docstring, once you have a macro value -- but see the above
+note about first-class macros. Docstrings are associated with the syntax
+transformer procedures.
 
 ** `case-lambda' is now available in the default environment.
 
@@ -695,7 +646,7 @@ The binding in the default environment is equivalent to the 
one from the
 `(srfi srfi-16)' module. Use the srfi-16 module explicitly if you wish
 to maintain compatibility with Guile 1.8 and earlier.
 
-** Compiled procedures may now have more than one arity.
+** Procedures may now have more than one arity.
 
 This can be the case, for example, in case-lambda procedures. The
 arities of compiled procedures may be accessed via procedures from the
@@ -879,15 +830,6 @@ This change will in the future allow users to customize 
generic function
 dispatch without incurring a performance penalty, and allow us to
 implement method combinations.
 
-** GOOPS cleanups.
-
-GOOPS had a number of concepts that were relevant to the days of Tcl,
-but not any more: operators and entities, mainly. These objects were
-never documented, and it is unlikely that they were ever used. Operators
-were a kind of generic specific to the Tcl support. Entities were
-applicable structures, but were unusable; entities will come back in the
-next alpha release, but with a less stupid name.
-
 ** Applicable struct support
 
 One may now make structs from Scheme that may be applied as procedures.
@@ -899,6 +841,14 @@ that new struct are assumed to have the procedure in their 
first slot.
 `<applicable-struct-with-setter-vtable>', which looks for the setter in
 the second slot. This needs to be better documented.
 
+** GOOPS cleanups.
+
+GOOPS had a number of concepts that were relevant to the days of Tcl,
+but not any more: operators and entities, mainly. These objects were
+never documented, and it is unlikely that they were ever used. Operators
+were a kind of generic specific to the Tcl support. Entities were
+replaced by applicable structs, mentioned above.
+
 ** New struct slot allocation: "hidden"
 
 A hidden slot is readable and writable, but will not be initialized by a
@@ -1096,12 +1046,6 @@ Removed the deprecated array functions `scm_i_arrayp',
 `SCM_DEFINE1', `SCM_PRIMITIVE_GENERIC_1', `SCM_PROC1, and `SCM_GPROC1'
 are no more. Use SCM_DEFINE or SCM_PRIMITIVE_GENERIC instead.
 
-** Add foreign value wrapper
-    
-Guile now has a datatype for aliasing "foreign" values, such as native
-long values. This should be useful for making a proper foreign function
-interface. Interested hackers should see libguile/foreign.h.
-
 ** New functions: `scm_call_n', `scm_c_run_hookn'
     
 `scm_call_n' applies to apply a function to an array of arguments.
@@ -1195,6 +1139,16 @@ efficient to check e.g. if a value is equal to Scheme's 
end-of-list or
 Lisp's nil. Additionally there are a heap of new, specific predicates
 like scm_is_null_or_nil.
 
+** Better integration of Lisp `nil'.
+
+`scm_is_boolean', `scm_is_false', and `scm_is_null' all return true now
+for Lisp's `nil'. This shouldn't affect any Scheme code at this point,
+but when we start to integrate more with Emacs, it is possible that we
+break code that assumes that, for example, `(not x)' implies that `x' is
+`eq?' to `#f'. This is not a common assumption. Refactoring affected
+code to rely on properties instead of identities will improve code
+correctness. See "Nil" in the manual, for more details.
+
 ** Support for static allocation of strings, symbols, and subrs.
 
 Calls to snarfing CPP macros like SCM_DEFINE macro will now allocate
diff --git a/doc/ref/api-modules.texi b/doc/ref/api-modules.texi
index 28656d7..a1aff34 100644
--- a/doc/ref/api-modules.texi
+++ b/doc/ref/api-modules.texi
@@ -783,15 +783,15 @@ expressions:
 @subsection R6RS Libraries
 
 In addition to the API described in the previous sections, you also
-have the option to create modules using the portable ``library'' form
+have the option to create modules using the portable @code{library} form
 described in R6RS (@pxref{Library form, R6RS Library Form,, r6rs, The
 Revised^6 Report on the Algorithmic Language Scheme}), and to import 
 libraries created in this format by other programmers.  Guile's R6RS 
-libraries implementation takes advantage of the flexibility built 
-into the module system by expanding the R6RS library form into a 
-corresponding Guile ``define-module'' form that specifies equivalent
-import and export requirements and includes the same body 
-expressions.  The library expression:
+library implementation takes advantage of the flexibility built into the
+module system by expanding the R6RS library form into a corresponding 
+Guile @code{define-module} form that specifies equivalent import and 
+export requirements and includes the same body expressions.  The library
+expression:
 
 @lisp
   (library (mylib (1 2))
@@ -809,7 +809,7 @@ is equivalent to the module definition:
 @end lisp
 
 Central to the mechanics of R6RS libraries is the concept of import
-and export ``levels,'' which control the visibility of bindings at
+and export @dfn{levels}, which control the visibility of bindings at
 various phases of a library's lifecycle --- macros necessary to 
 expand forms in the library's body need to be available at expand 
 time; variables used in the body of a procedure exported by the
@@ -819,15 +819,14 @@ as a mechanism by which a library author can indicate 
that a
 particular library import should take place at a particular phase 
 with respect to the lifecycle of the importing library.  
 
-Guile's libraries implementation uses a technique called ``implicit 
-phasing'' (see @cite{Implicit Phasing for R6RS Libraries} by 
-Abdulaziz Ghuloum and R. Kent Dybvig), which allows the expander and
-compiler to automatically determine the necessary visibility of a 
-binding imported from another library.  As such, the @code{for} 
-sub-form described below is ignored by Guile (but may be required by
-Schemes in which phasing is explicit).
+Guile's libraries implementation uses a technique called 
address@hidden phasing} (first described by Abdulaziz Ghuloum and R. 
+Kent Dybvig), which allows the expander and compiler to automatically 
+determine the necessary visibility of a binding imported from another 
+library.  As such, the @code{for} sub-form described below is ignored by
+Guile (but may be required by Schemes in which phasing is explicit).
 
address@hidden syntax library name (export export-spec ...) (import import-spec 
...) body ...
address@hidden {Scheme Syntax} library name (export export-spec ...) (import 
import-spec ...) body ...
 Defines a new library with the specified name, exports, and imports,
 and evaluates the specified body expressions in this library's 
 environment.
@@ -843,7 +842,7 @@ identifier @var{internal-name} names a variable defined or 
imported
 by the library and @var{external-name} is the name by which the
 variable is seen by importing libraries.
 
-Each @var{import-spec} must be either an ``import set'' (see below) 
+Each @var{import-spec} must be either an @dfn{import set} (see below)
 or must be of the form @code{(for import-set import-level ...)}, 
 where each @var{import-level} is one of:
 
@@ -910,10 +909,10 @@ your libraries less portable to other Schemes.
 
 @end deffn
 
address@hidden syntax import import-spec ...
address@hidden {Scheme Syntax} import import-spec ...
 Import into the current environment the libraries specified by the
 given import specifications, where each @var{import-spec} takes the
-same form as in the ``library'' form described above.
+same form as in the @code{library} form described above.
 @end deffn
 
 
diff --git a/module/language/assembly/disassemble.scm 
b/module/language/assembly/disassemble.scm
index 4cac32a..bd1f6a1 100644
--- a/module/language/assembly/disassemble.scm
+++ b/module/language/assembly/disassemble.scm
@@ -20,6 +20,7 @@
 
 (define-module (language assembly disassemble)
   #:use-module (ice-9 format)
+  #:use-module (srfi srfi-1)
   #:use-module (system vm instruction)
   #:use-module (system vm program)
   #:use-module (system base pmatch)
@@ -90,10 +91,11 @@
 
 (define (disassemble-free-vars free-vars)
   (display "Free variables:\n\n")
-  (let lp ((i 0))
-    (cond ((< i (vector-length free-vars))
-           (print-info i (vector-ref free-vars i) #f #f)
-           (lp (1+ i))))))
+  (fold (lambda (free-var i)
+          (print-info i free-var #f #f)
+          (+ 1 i))
+        0
+        free-vars))
 
 (define-macro (unless test . body)
   `(if (not ,test) (begin ,@body)))
diff --git a/module/language/lua/lexer.scm b/module/language/lua/lexer.scm
new file mode 100644
index 0000000..8c38e47
--- /dev/null
+++ b/module/language/lua/lexer.scm
@@ -0,0 +1,44 @@
+(define-module (language lua lexer)
+  #:use-module (srfi srfi-9)
+  #:use-module ((rnrs control) #:version (6))
+  #:export (make-token make-lexer token/type token/value))
+
+(define (assert-no-eof port desc)
+  (when (eof-object? (peek-char port))
+    (throw 'lua-unexpected-eof (string-append "unexpected end-of-file " 
desc))))
+
+(define-syntax define-record-printer
+  (syntax-rules ()
+    ((_ name thunk)
+     (struct-set! name vtable-index-printer thunk))))
+
+(define-record-type token
+  (make-token type value)
+  token?
+  (type token/type)
+  (value token/value))
+
+(define-record-printer token
+   (lambda (r p)
+     (write-char #\<)
+     (write (token/type r))
+     (write-char #\space)
+     (write (token/value r))
+     (write-char #\>)))
+
+(define (eat-char port) (read-char port) (if #f #f))
+
+(define (make-lexer port)
+    (define (lex-string)
+      (eat-char port)
+      (with-output-to-string
+       (lambda ()
+         (let loop ((c (peek-char port)))
+           (assert-no-eof port "in string")
+           (cond ((eq? c #\") (get-output-string (current-output-port)))
+                 (else (write-char (read-char port)) (loop (peek-char 
port))))))))
+    (lambda ()
+      (define c (peek-char port))
+      (cond ((eof-object? c) c)
+            ((eq? c #\") (make-token 'string (lex-string)))
+            (else #f))))
diff --git a/test-suite/tests/lua.test b/test-suite/tests/lua.test
new file mode 100644
index 0000000..fb2a26c
--- /dev/null
+++ b/test-suite/tests/lua.test
@@ -0,0 +1,41 @@
+;; lua.test --- test guile-lua -*- scheme -*-
+
+(define-module (test-lua)
+  #:use-module (test-suite lib)
+  #:use-module (language lua lexer))
+
+;;; Local Variables:
+;;; eval: (put 'with-test-prefix 'scheme-indent-function 1)
+;;; End:
+
+(use-modules
+ (test-suite lib))
+
+(define (token-equal=? type value token)
+  (and (eq? type (token/type token)) (equal? value (token/value token))))
+
+(define (read-token-from-string string)
+  ((make-lexer (open-input-string string))))
+
+(define-syntax eof
+  (syntax-rules ()
+    ((_ name string)
+     (pass-if name
+       ((catch 'lua-unexpected-eof
+               (lambda () (read-token-from-string string) #f)
+               (lambda (key val) #t)))))))
+
+(define-syntax token
+  (syntax-rules ()
+    ((_ name string result-type result-value)
+     (pass-if name
+       (token-equal=?
+        result-type result-value
+        (read-token-from-string string))))))
+       
+(with-test-prefix "lua"
+  (token "string" "\"hello world\"" 'string "hello world")
+
+  (eof "string without terminator" "\"hell")
+  
+  )
\ No newline at end of file


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]