emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a coding system


From: David Kastrup
Subject: Re: Creating a coding system
Date: Sun, 21 Dec 2014 22:25:01 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> From: David Kastrup <address@hidden>
>> Cc: address@hidden,  address@hidden
>> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]