[erlang-questions] Erlang Language Specification

Joe Armstrong erlang@REDACTED
Fri Dec 1 12:48:42 CET 2017


On Thu, Nov 30, 2017 at 11:17 PM, Richard A. O'Keefe <ok@REDACTED> wrote:
>
>
> On 1/12/17 5:58 AM, Simon Thompson wrote:
>>
>> Yes, I’ve done this, but did trip up with some of the escaping
>> conventions for multiple languages …
>
>
> One approach goes like this.
> You have two DTDs.  One includes this:
>
>   <!ELEMENT include EMPTY>
>   <!ATTLIST include
>      src CDATA #REQUIRED
>      in  NMTOKEN #REQUIRED>
>
> So you do things like
>
>   <include src="snippets/flatten.erl" in="Erlang"/>
>
> You have a program that reads the parsed form of the
> file in either a SAX-like or DOM-like manner, and
> processes the <include/> elements, generating whatever
> markup is appropriate, and emits the complete result
> as XML, ready for formatting.

This is a great approach - my erlang book is marked up in xml
with code includes, for example, <code file="foo.erl" section="connecting"/>

The the code in foo.erl is tagged like this

    %% START:connecting
     ....
    %% END:connecting

The XML is validated - and a simple program extracts the Erlang
and color codes it and does whatever you want.

Very simple and works beautifully.

I'm very much in favor of making ad hoc tools that do
little things like exactly as you want them, rather than relying
on generic masterpieces (like docbook).

Cheers

/Joe


/Joe


>
> *Manual* escaping is tedious and error-prone.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list