unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* define-language
@ 2020-08-07 19:31 Stephen Scheck
  2020-08-07 21:46 ` define-language Matt Wette
  2020-08-07 22:34 ` define-language Matt Wette
  0 siblings, 2 replies; 3+ messages in thread
From: Stephen Scheck @ 2020-08-07 19:31 UTC (permalink / raw)
  To: guile-user

What is the right way to use `define-language`? The Guile manual says that
when using this form "the language will be added to the global language
set." I interpret that to mean that the `,language` meta-command switches
the REPL to use the newly-defined language, but it doesn't work:

scheme@(guile-user)> (use-modules (system base language))
scheme@(guile-user)> (define-language mylingua
  #:title "Mylingua"
  #:reader (lambda (port env) ...)
  #:evaluator (lambda (x module) ...)
  #:printer write)
scheme@(guile-user)> mylingua
$1 = #<<language> name: mylingua title: "Mylingua" reader: #<procedure
1bfcd38 at <unknown port>:5:11 (port env)> printer: #<procedure write (_
#:optional _)> parser: #f compilers: () decompilers: () evaluator:
#<procedure 1bfcd48 at <unknown port>:6:14 (x module)> joiner: #f
for-humans?: #t make-default-environment: #<procedure
make-fresh-user-module ()> lowerer: #f analyzer: #f compiler-chooser: #f>
scheme@(guile-user)> ,language mylingua
While executing meta-command:
no such language mylingua


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: define-language
  2020-08-07 19:31 define-language Stephen Scheck
@ 2020-08-07 21:46 ` Matt Wette
  2020-08-07 22:34 ` define-language Matt Wette
  1 sibling, 0 replies; 3+ messages in thread
From: Matt Wette @ 2020-08-07 21:46 UTC (permalink / raw)
  To: guile-user

On 8/7/20 12:31 PM, Stephen Scheck wrote:
> What is the right way to use `define-language`? The Guile manual says that
> when using this form "the language will be added to the global language
> set." I interpret that to mean that the `,language` meta-command switches
> the REPL to use the newly-defined language, but it doesn't work:
>
> scheme@(guile-user)> (use-modules (system base language))
> scheme@(guile-user)> (define-language mylingua
>    #:title "Mylingua"
>    #:reader (lambda (port env) ...)
>    #:evaluator (lambda (x module) ...)
>    #:printer write)
> scheme@(guile-user)> mylingua
> $1 = #<<language> name: mylingua title: "Mylingua" reader: #<procedure
> 1bfcd38 at <unknown port>:5:11 (port env)> printer: #<procedure write (_
> #:optional _)> parser: #f compilers: () decompilers: () evaluator:
> #<procedure 1bfcd48 at <unknown port>:6:14 (x module)> joiner: #f
> for-humans?: #t make-default-environment: #<procedure
> make-fresh-user-module ()> lowerer: #f analyzer: #f compiler-chooser: #f>
> scheme@(guile-user)> ,language mylingua
> While executing meta-command:
> no such language mylingua
I usually use a reader and compiler (something that compiles to tree-il).
The important item to know is that the output of the reader is the input
  for the compiler.

I do have spec.scm files with evaluator but it's just the default I think.
I don't remember what the evaluator does but guessing it processes
input to the `eval' procedure.

Check examples/language  and examples/language/nyacc/lang/
in https://download.savannah.gnu.org/project/nyacc
or https://git.savannah.nongnu.org/cgit/nyacc.git/tree/

  I include examples for a calculator (calc), javascript (nx-javascript),
matlab (nx-mlang) and tcl (nx-tcl).  You can download and unpack the 
nyacc distribution.

$ cd examples
$ source env.sh
$ guile
guile> ,L nx-javascript
....
nx-javascript@(guile-user)> var a = 1;
nx-javascript@(guile-user)> a
$1 = 1
nx-javascript@(guile-user)>





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: define-language
  2020-08-07 19:31 define-language Stephen Scheck
  2020-08-07 21:46 ` define-language Matt Wette
@ 2020-08-07 22:34 ` Matt Wette
  1 sibling, 0 replies; 3+ messages in thread
From: Matt Wette @ 2020-08-07 22:34 UTC (permalink / raw)
  To: guile-user



On 8/7/20 12:31 PM, Stephen Scheck wrote:
> What is the right way to use `define-language`? The Guile manual says that
> when using this form "the language will be added to the global language
> set." I interpret that to mean that the `,language` meta-command switches
> the REPL to use the newly-defined language, but it doesn't work:
>
> scheme@(guile-user)> (use-modules (system base language))
> scheme@(guile-user)> (define-language mylingua
>    #:title "Mylingua"
>    #:reader (lambda (port env) ...)
>    #:evaluator (lambda (x module) ...)
>    #:printer write)
> scheme@(guile-user)> mylingua
> $1 = #<<language> name: mylingua title: "Mylingua" reader: #<procedure
> 1bfcd38 at <unknown port>:5:11 (port env)> printer: #<procedure write (_
> #:optional _)> parser: #f compilers: () decompilers: () evaluator:
> #<procedure 1bfcd48 at <unknown port>:6:14 (x module)> joiner: #f
> for-humans?: #t make-default-environment: #<procedure
> make-fresh-user-module ()> lowerer: #f analyzer: #f compiler-chooser: #f>
> scheme@(guile-user)> ,language mylingua
> While executing meta-command:
> no such language mylingua

Also, I believe you need to have the language defined in a
module (i.e., define-module) with path (language mylingua spec)
in file spec.scm in a subdirectory language/mylingua.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-07 22:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-07 19:31 define-language Stephen Scheck
2020-08-07 21:46 ` define-language Matt Wette
2020-08-07 22:34 ` define-language Matt Wette

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).