all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: schwab@linux-m68k.org, emacs-devel@gnu.org
Subject: Re: Creating a coding system
Date: Sun, 21 Dec 2014 22:25:01 +0100	[thread overview]
Message-ID: <87zjagelw2.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <83fvcaqcdj.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 20 Dec 2014 22:45:12 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: David Kastrup <dak@gnu.org>
>> Cc: schwab@linux-m68k.org,  emacs-devel@gnu.org
>> Date: Sat, 20 Dec 2014 21:11:49 +0100
>> 
>> > I might be mistaken, but this doesn't look to me like a job for a
>> > coding-system.  You are talking about parsing input into some abstract
>> > notation,
>> 
>> "parsing input" is sort of bombastic for interpreting a binary
>> representation consisting of isolated minimal words.
>
> Yes, but coding-systems machinery is not a general-purpose bytestream
> conversion facility.  It was designed and implemented specifically for
> converting between known families of encodings.  You might be able to
> tweak it enough to do what you want, eventually, but it doesn't look
> like a piece of cake to me.  Programming in CCL is like writing
> assembly code in a restricted machine language, hardly something well
> suited to converting one complex bytestream into another.
>
>> > then generating a representation of that input in a different
>> > language.  This is sufficiently different from converting characters
>> > from one encoding to another that you should perhaps look at
>> > cedet/semantic/ stuff instead.
>> 
>> Uh, there is no grammar involved here, no context, most certainly not a
>> push-down stack or something.
>
> But there's definitely some kind of "lexing", no?  You are talking
> about sequences of symbols, not about letters from some alphabet.  If
> you try representing each sequence as an encoding of a letter, won't
> you get an enormously large alphabet?
>
> Then again, I might be dead wrong.

(define-ccl-program midi-notenames
  '(9
    ((read r0)
     (if ((r0 & 240) == 144)
	 ((read r0)
	  (r0 //= 12)
	  (branch r7 "c" "des" "d" "es" "e" "f" "fis" "g" "as" "a" "bes" "b")
	  (branch r0 ",,,," ",,," ",," "," " " "'" "''" "'''" "''''" "'''''" "''''''"))))))

(define-ccl-program no-conversion
  '(1 ((read r0)(write r0))))

(define-coding-system 'midi-notenames
  "This converts Midi note-on events to note names"
  :mnemonic ?M
  :coding-type 'ccl
  :charset-list '(iso-8859-1)
  :eol-type 'unix
  :ccl-decoder 'midi-notenames
  :ccl-encoder 'no-conversion)

This actually seems to do the trick for the original stuff I'd been
wrestling with.  I still have to figure out how to parameterize stuff
without redefining CCL programs all the time.

-- 
David Kastrup



  parent reply	other threads:[~2014-12-21 21:25 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-20  9:05 Creating a coding system David Kastrup
2014-12-20 10:20 ` Thien-Thi Nguyen
2014-12-20 10:42   ` David Kastrup
2014-12-20 13:51 ` Andreas Schwab
2014-12-20 14:19   ` David Kastrup
2014-12-20 14:50     ` Eli Zaretskii
2014-12-20 15:56     ` Thien-Thi Nguyen
2014-12-20 16:11     ` Andreas Schwab
2014-12-20 16:14     ` Andreas Schwab
2014-12-20 16:43       ` David Kastrup
2014-12-20 16:53         ` Eli Zaretskii
2014-12-20 17:38           ` David Kastrup
2014-12-20 18:31             ` Stephen J. Turnbull
2014-12-20 18:40               ` David Kastrup
2014-12-20 18:35             ` Eli Zaretskii
2014-12-20 19:06               ` David Kastrup
2014-12-20 20:02                 ` Eli Zaretskii
2014-12-20 20:11                   ` David Kastrup
2014-12-20 20:45                     ` Eli Zaretskii
2014-12-20 21:15                       ` David Kastrup
2014-12-21 19:46                         ` David Kastrup
2014-12-21 21:25                       ` David Kastrup [this message]
2014-12-21  5:54                 ` Stephen J. Turnbull
2014-12-20 16:21     ` Stephen J. Turnbull
2014-12-20 16:52       ` David Kastrup
2014-12-20 18:34         ` Eli Zaretskii
2014-12-20 18:42           ` David Kastrup
2014-12-23  8:59 ` K. Handa
2014-12-23  9:25   ` David Kastrup
2014-12-24 15:06     ` K. Handa
2014-12-25  6:39       ` David Kastrup
2014-12-29 14:11         ` K. Handa
2014-12-29 14:25           ` David Kastrup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zjagelw2.fsf@fencepost.gnu.org \
    --to=dak@gnu.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.