[erlang-questions] Adoption of perl/javascript-style regexp syntax

Richard O'Keefe ok@REDACTED
Tue Jun 2 01:51:53 CEST 2009

We have discussed the issue of including other-language syntax in
Erlang several times.  If I recall correctly, there are several
proposals for how one might deal with it, including one of mine
which would allow any number of notations without "nesting".

In the mean time, may I respectfully point out to something that
seems pretty much kindergarten level to me, but doesn't seem to
be taught effectively:


Just because it's source code, that doesn't mean it had to be
typed in by a human being.  For example, suppose we wanted
something like shell here-files.  I'll just do the literal case
(no substitution) to make my point.

<input> ::= (<line> | <here-file>)*
<here-file> ::= .{{<newline>
<line> ::= <any text not starting with .{{ or .}}><newline>

A trivial AWK script can recognise this and turn a <here-file> into
a string literal, generating whatever quoting is necessary.  All you
have to do is write less than a page of AWK (once), and then tell
your build tools how to turn .erl-hf files into .erl files.

For a non-entirely-unrelated idea, see the UNIX 'xstr(1)' program.

More information about the erlang-questions mailing list