modify uahgi-ng
This commit is contained in:
parent
4c117df0c5
commit
c0d3e83989
4 changed files with 51 additions and 15 deletions
|
@ -1,3 +1,42 @@
|
||||||
|
|
||||||
(module uahgi-ng racket/base
|
(module uahgi-ng racket/base
|
||||||
(provide lambda quote add1 begin #%module-begin #%app #%datum #%expression #%top)
|
(require racket/dict)
|
||||||
|
(define main-config (make-hash
|
||||||
|
'(["paper-width". 2480]
|
||||||
|
["paper-height". 3508]
|
||||||
|
["font-family" . "FreeSerif"]
|
||||||
|
["font-family-CJK" . "Noto Sans CJK TC"]
|
||||||
|
["font-size" . 14]
|
||||||
|
["font-weight" . "regular"]
|
||||||
|
["font-style" . "normal"]
|
||||||
|
|
||||||
|
)))
|
||||||
|
(define main-frame (make-hash
|
||||||
|
'(["id" . 1]
|
||||||
|
["font-family" . (dict-ref main-config "font-family")]
|
||||||
|
["class" . frame]
|
||||||
|
["width" . 2000]
|
||||||
|
["height" . 3000]
|
||||||
|
["x" . 200]
|
||||||
|
["y" . 250]
|
||||||
|
["content" . #f])))
|
||||||
|
|
||||||
|
(define (set-main-config attr val)
|
||||||
|
(dict-set! main-config attr val))
|
||||||
|
|
||||||
|
(define (main-text txt)
|
||||||
|
(dict-set! main-frame "content" txt))
|
||||||
|
|
||||||
|
(define-syntax text-series
|
||||||
|
(syntax-rules ()
|
||||||
|
[(_ x ...)
|
||||||
|
; delete the beginning newline
|
||||||
|
(if (eq? (caar `(x ...)) "\n")
|
||||||
|
`('text ,(cdar `(x ...)))
|
||||||
|
`('text ,(caar `(x ...)) ,(cdar `(x ...)))))]))
|
||||||
|
|
||||||
|
(provide text-series main-text main-frame main-config set-main-config set!
|
||||||
|
(all-from-out racket/base) (all-from-out racket/dict)
|
||||||
|
#%module-begin #%app #%datum #%expression #%top)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
|
|
||||||
(define-lex-abbrev digits (+ (char-set "0123456789")))
|
(define-lex-abbrev digits (+ (char-set "0123456789")))
|
||||||
(define-lex-abbrev raw-id (: (or "_" (/ "a" "z") (/ "A" "Z")) (* (or "_" (/ "0" "9") (/ "a" "z") (/ "A" "Z")))))
|
(define-lex-abbrev raw-id (: (or "_" (/ "a" "z") (/ "A" "Z")) (* (or "_" "-" "!" "?" (/ "0" "9") (/ "a" "z") (/ "A" "Z")))))
|
||||||
(define-lex-abbrev any-other-char (~ (char-set "0123456789@\\{}%|")))
|
(define-lex-abbrev any-other-char (~ (char-set "0123456789@\\{}%|")))
|
||||||
|
|
||||||
(define uahgi2-lexer
|
(define uahgi2-lexer
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
|
|
||||||
|
|
||||||
(define sexp-elem/p
|
(define sexp-elem/p
|
||||||
(delay/p (or/p expr/p
|
(delay/p (or/p (try/p series/p)
|
||||||
series/p)))
|
expr/p)))
|
||||||
|
|
||||||
|
|
||||||
(define sexp/p
|
(define sexp/p
|
||||||
|
@ -47,11 +47,6 @@
|
||||||
converting-num/p
|
converting-num/p
|
||||||
sexp/p))
|
sexp/p))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define series-elem/p
|
(define series-elem/p
|
||||||
(or/p newline/p
|
(or/p newline/p
|
||||||
num/p
|
num/p
|
||||||
|
@ -63,12 +58,6 @@
|
||||||
(do [args <- (many/p series-elem/p #:min 2)]
|
(do [args <- (many/p series-elem/p #:min 2)]
|
||||||
(pure (list 'text-series args))))
|
(pure (list 'text-series args))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define prog/p
|
(define prog/p
|
||||||
(syntax/p
|
(syntax/p
|
||||||
(do
|
(do
|
||||||
|
|
8
uahgi-ng/test1.ug
Normal file
8
uahgi-ng/test1.ug
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#lang uahgi-ng
|
||||||
|
{@display|`10.3}
|
||||||
|
{@dict?|@main-config}
|
||||||
|
{@set-main-config|paper-width|`2480}
|
||||||
|
{@display|{@dict-ref|@main-config|paper-width}}
|
||||||
|
{@main-text|
|
||||||
|
天地人123我為貓}
|
||||||
|
{@display|@main-frame}
|
Loading…
Reference in a new issue