* PEG tutorial example doesnt work
@ 2024-08-12 2:52 Diego Antonio Rosario Palomino
2024-08-12 23:38 ` Tomas Volf
0 siblings, 1 reply; 2+ messages in thread
From: Diego Antonio Rosario Palomino @ 2024-08-12 2:52 UTC (permalink / raw)
To: guile-user
[-- Attachment #1: Type: text/plain, Size: 1189 bytes --]
Hello, i am a new scheme user trying to exploit the peg library but have
encountered the following error :
guile c.scm
;;; note: source file /home/diego/Documents/Guile/c.scm
;;; newer than compiled
/home/diego/.cache/guile/ccache/3.0-LE-8-4.6/home/diego/Documents/Guile/c.scm.go
;;; note: auto-compilation is enabled, set GUILEAUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/diego/Documents/Guile/c.scm
;;; /home/diego/Documents/Guile/c.scm:20:57: warning: possibly unbound
variable `⇒'
;;; compiled
/home/diego/.cache/guile/ccache/3.0-LE-8-4.6/home/diego/Documents/Guile/c.scm.go
Backtrace:
In ice-9/boot-9.scm:
1752:10 6 (with-exception-handler #:unwind? # )
In unknown file:
5 (apply-smob/0 #<thunk 7fcf881b52a0>)
In ice-9/boot-9.scm:
724:2 4 (call-with-prompt #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
619:8 3 ( #(#(#<directory (guile-user) 7fcf881b9c80>)))
In ice-9/boot-9.scm:
2836:4 2 (save-module-excursion )
4388:12 1 ()
In /home/diego/Documents/Guile/c.scm:
20:57 0 (_)
/home/diego/Documents/Guile/c.scm:20:57: Unbound variable: ⇒
[-- Attachment #2: c.scm --]
[-- Type: application/octet-stream, Size: 934 bytes --]
(define-peg-string-patterns
"cfunc <-- cSP ctype cSP cname cSP cargs cLB cSP cbody cRB
ctype <-- cidentifier
cname <-- cidentifier
cargs <-- cLP (! (cSP cRP) carg cSP (cCOMMA / cRP) cSP)* cSP
carg <-- cSP ctype cSP cname
cbody <-- cstatement *
cidentifier <- [a-zA-z][a-zA-Z0-9_]*
cstatement <-- (!';'.)*cSC cSP
cSC < ';'
cCOMMA < ','
cLP < '('
cRP < ')'
cLB < '{'
cRB < '}'
cSP < [ \t\n]*")
(match-pattern cfunc "int square(int a) { return a*a;}") ⇒
(32
(cfunc (ctype "int")
(cname "square")
(cargs (carg (ctype "int") (cname "a")))
(cbody (cstatement "return a*a"))))
(match-pattern cfunc "int mod(int a, int b) { int c = a/b;return a-b*c; }") ⇒
(52
(cfunc (ctype "int")
(cname "mod")
(cargs (carg (ctype "int") (cname "a"))
(carg (ctype "int") (cname "b")))
(cbody (cstatement "int c = a/b")
(cstatement "return a- b*c"))))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PEG tutorial example doesnt work
2024-08-12 2:52 PEG tutorial example doesnt work Diego Antonio Rosario Palomino
@ 2024-08-12 23:38 ` Tomas Volf
0 siblings, 0 replies; 2+ messages in thread
From: Tomas Volf @ 2024-08-12 23:38 UTC (permalink / raw)
To: Diego Antonio Rosario Palomino; +Cc: guile-user
[-- Attachment #1: Type: text/plain, Size: 2178 bytes --]
Hello,
On 2024-08-11 21:52:42 -0500, Diego Antonio Rosario Palomino wrote:
> Hello, i am a new scheme user trying to exploit the peg library but have
> encountered the following error :
>
> guile c.scm
> ;;; note: source file /home/diego/Documents/Guile/c.scm
> ;;; newer than compiled
> /home/diego/.cache/guile/ccache/3.0-LE-8-4.6/home/diego/Documents/Guile/c.scm.go
> ;;; note: auto-compilation is enabled, set GUILEAUTO_COMPILE=0
> ;;; or pass the --no-auto-compile argument to disable.
> ;;; compiling /home/diego/Documents/Guile/c.scm
> ;;; /home/diego/Documents/Guile/c.scm:20:57: warning: possibly unbound
> variable `⇒'
> ;;; compiled
> /home/diego/.cache/guile/ccache/3.0-LE-8-4.6/home/diego/Documents/Guile/c.scm.go
> Backtrace:
> In ice-9/boot-9.scm:
> 1752:10 6 (with-exception-handler #:unwind? # )
> In unknown file:
> 5 (apply-smob/0 #<thunk 7fcf881b52a0>)
> In ice-9/boot-9.scm:
> 724:2 4 (call-with-prompt #<procedure default-prompt-handle…>)
> In ice-9/eval.scm:
> 619:8 3 ( #(#(#<directory (guile-user) 7fcf881b9c80>)))
> In ice-9/boot-9.scm:
> 2836:4 2 (save-module-excursion )
> 4388:12 1 ()
> In /home/diego/Documents/Guile/c.scm:
> 20:57 0 (_)
>
> /home/diego/Documents/Guile/c.scm:20:57: Unbound variable: ⇒
The arrow character in the documentation is a stand in meaning that A returns
B.
So in this example:
(match-pattern cfunc "int square(int a) { return a*a;}") ⇒
(32
(cfunc (ctype "int")
(cname "square")
(cargs (carg (ctype "int") (cname "a")))
(cbody (cstatement "return a*a"))))
It means that
(match-pattern cfunc "int square(int a) { return a*a;}")
Returns this value:
(32
(cfunc (ctype "int")
(cname "square")
(cargs (carg (ctype "int") (cname "a")))
(cbody (cstatement "return a*a"))))
This is used fairly commonly across Scheme info pages, so it is good thing to
know.
Hope this helps,
Tomas
--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-12 23:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-12 2:52 PEG tutorial example doesnt work Diego Antonio Rosario Palomino
2024-08-12 23:38 ` Tomas Volf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).