mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 14:21:10 +02:00
Add ECMAScript Unicode literal support
* module/language/ecmascript/tokenize.scm: add unicode literals * test-suite/tests/ecmascript.test ("parser"): Add new tests for Latin-1 and Unicode escapes in string literals. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
a7d8a8a63b
commit
b1846b7fb3
2 changed files with 11 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
;;; ECMAScript for Guile
|
;;; ECMAScript for Guile
|
||||||
|
|
||||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
;; Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||||
|
|
||||||
;;;; This library is free software; you can redistribute it and/or
|
;;;; This library is free software; you can redistribute it and/or
|
||||||
;;;; modify it under the terms of the GNU Lesser General Public
|
;;;; modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -150,7 +150,11 @@
|
||||||
(else
|
(else
|
||||||
(syntax-error "bad hex character escape" loc (string a b))))))
|
(syntax-error "bad hex character escape" loc (string a b))))))
|
||||||
((#\u)
|
((#\u)
|
||||||
(syntax-error "unicode not supported" loc #f))
|
(let* ((a (read-char port))
|
||||||
|
(b (read-char port))
|
||||||
|
(c (read-char port))
|
||||||
|
(d (read-char port)))
|
||||||
|
(integer->char (string->number (string a b c d) 16))))
|
||||||
(else
|
(else
|
||||||
c))))
|
c))))
|
||||||
(let lp ((str (read-until terms port loc)))
|
(let lp ((str (read-until terms port loc)))
|
||||||
|
|
|
@ -48,7 +48,11 @@
|
||||||
(parse "var x = { foo: 12, bar: \"hello\" };"
|
(parse "var x = { foo: 12, bar: \"hello\" };"
|
||||||
'(begin (var (x (object (foo (number 12))
|
'(begin (var (x (object (foo (number 12))
|
||||||
(bar (string "hello")))))
|
(bar (string "hello")))))
|
||||||
(begin))))
|
(begin)))
|
||||||
|
(parse "\"\\x12\";" ; Latin-1 escape in string literal
|
||||||
|
'(string "\x12"))
|
||||||
|
(parse "\"\\u1234\";" ; Unicode escape in string literal
|
||||||
|
'(string "\u1234")))
|
||||||
|
|
||||||
|
|
||||||
(define-syntax ecompile
|
(define-syntax ecompile
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue