[erlang-questions] : sytax of atoms
Raimo Niskanen
raimo+erlang-questions@REDACTED
Mon Apr 16 12:07:35 CEST 2007
To elaborate on the atom syntax definition. Erlang is defined for
ISO-8859-1 and there are more characters allowed for unquoted atoms,
see erl_scan.erl.
Allowed decimal ASCII ranges for the first character:
97-122,223-246,248-255
That is a-z and ß-ÿ except ÷.
Allowed decimal ASCII ranges for the following character(s):
97-122,223-246,248-255,
65-90,192-214,216-222,
48-57,95,64
That is a-z and ß-ÿ except ÷,
A-Z and À-Þ except ×,
0-9, _ and @.
On top of this a dot between atoms is translated by the compiler
and the shell evaluator to a quoted atom containing the dot.
It has to be a dot, not a full stop. A full stop is a dot
followed by whitespace, comment or end of file. This is an atom:
'a.b' = a .b
Note that the unquoted variant is not a legal pattern, so:
a .b = 'a.b'
gives an illegal_pattern runtime error.
For quoted atoms any char is allowed between the quotes ''.
Plus, a \ opens an escape sequence:
'\\\'\n\r\t\v\b\f\e\s\d'
'\000 - \177'
'\^@\^A - \^Z\^[\^\\^]\^_'
On Sun, Apr 15, 2007 at 04:11:46AM +0200, Robert Virding wrote:
> As regular expressions for leex:
>
> [a-z][A-Za-z0-9_-.]*
> '(\\\^.|\\.|[^'])*'
>
> With macros they're even shorter.
>
> Robert
>
>
> Caoyuan Deng wrote:
> > There is an LALR-1 grammar definition similar to yacc:
> > lib/stdlib-1.14.4/src/erl_parse.yrl
> >
> > And as I'm writing a Erlang IDE for NetBeans, I also wrote a LL(k)
> > grammar definition for Erlang:
> > http://erlybird.svn.sourceforge.net/viewvc/erlybird/trunk/erlybird/erlybird-erlang-editor/src/org/netbeans/modules/languages/erlang/Erlang.nbs?revision=96&view=markup
> >
> > For the Atom, it's something like:
> > TOKEN:atom: (
> > ["a"-"z"] ["a"-"z" "A"-"Z" "0"-"9" "_" "@"]* |
> > "\'" ([^ "\\" "\'" "\n" "\r"] |
> > ("\\" (. |
> > (["0"-"7"]) |
> > (["0"-"7"] ["0"-"7"]) |
> > (["0"-"7"] ["0"-"7"] ["0"-"7"])
> > ("^" ["@" "A"-"Z" "["-"_"])
> > )
> > )
> > )*
> > "\'"
> > )
> >
> >
> > On 4/14/07, Tony Finch <dot@REDACTED> wrote:
> >> The reference manual doesn't say that dots are permitted in atoms but they
> >> seem to be, e.g. in unquoted long node names.
> >>
> >> Is there a formal grammar (e.g. BNF) of Erlang anywhere?
> >>
> >> Tony.
> >> --
> >> f.a.n.finch <dot@REDACTED> http://dotat.at/
> >> HEBRIDES: SOUTH OR SOUTHEAST 4 OR 5, OCCASIONALLY 6 OR 7. MODERATE OR ROUGH.
> >> RAIN LATER. MODERATE OR GOOD.
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://www.erlang.org/mailman/listinfo/erlang-questions
> >>
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list