[erlang-questions] Leex dot
Robert Virding
robert.virding@REDACTED
Mon Dec 11 23:24:06 CET 2006
Sorry I have been away for a few days.
Some mailer along the way had played havoc with you file but I have
managed to decypher it and have included it last. Some general comments:
- you need only mention YYlen, YYtcs, YYline when you use them
- the ordering of rules defines precedence, so be careful putting short
patterns early
- the \. pattern will match the '.' character
- as '*' meta characters your comment definitions seem a little strange
- is the last pattern the catch all . one?
What is the token syntax you are trying to scan? I will try to run your
spec through and see what happens. What is the real problem? Is it not
working?
Robert
-----
Definitions.
COMMENT1 = (*(*([^*)]|[^*])|*[^)])****)
COMMENT2 = //([^n]*)
STRING = "(\^.|\.|[^"])*"
QUOTE = '(\^.|\.|[^'])*'
Rules.
// Numbers
([0-9]+[.][0-9]+[eE][+-][0-9]+) : YYlen, YYtcs, YYline, {token, {number,
YYline, erlang:list_to_float(YYtext)}}.
([0-9]+[.][0-9]+[eE][0-9]+) : YYlen, YYtcs, YYline, {token, {number,
YYline, erlang:list_to_float(YYtext)}}.
([0-9]+[.][0-9]+) : YYlen, YYtcs, YYline, {token, {number, YYline,
erlang:list_to_float(YYtext)}}.
([1-9][0-9]*) : YYlen, YYtcs, YYline, {token, {number, YYline,
erlang:list_to_integer(YYtext)}}.
([0]*) : YYlen, YYtcs, YYline, {token, {number, YYline, 0}}.
(0x[0-9]+) : YYlen, YYtcs, YYline, {token, {number, YYline,
erlang:list_to_integer(YYtext,16)}}.
% Number as char with code
\. : YYlen, YYtcs, YYline, {token, {number, YYline,
lists:nth(2,YYtext)}}.
% Any atom:
([A-Za-z_][a-z0-9A-Z_]*) : YYlen, YYtcs, YYline, {token,
special(YYtext, YYline)}.
%% string
({STRING}|{QUOTE}) : %% Strip quotes.
S = lists:sublist(YYtext, 2, length(YYtext) - 2),
YYlen, YYtcs, YYline, {token,{string,YYline,string_gen(S)}}.
{COMMENT1}|{COMMENT2} : YYlen, YYtcs, YYline, skip_token.
>= : YYlen, YYtcs, YYline, {token, {'>=', YYline}}.
<= : YYlen, YYtcs, YYline, {token, {'<=', YYline}}.
<> : YYlen, YYtcs, YYline, {token, {'!=', YYline}}.
!= : YYlen, YYtcs, YYline, {token, {'!=', YYline}}.
=~ : YYlen, YYtcs, YYline, {token, {'=~', YYline}}.
-> : YYlen, YYtcs, YYline, {token, {'->', YYline}}.
, : YYlen, YYtcs, YYline, {token, {',', YYline}}.
+ : YYlen, YYtcs, YYline, {token, {'+', YYline}}.
- : YYlen, YYtcs, YYline, {token, {'-', YYline}}.
> : YYlen, YYtcs, YYline, {token, {'>', YYline}}.
< : YYlen, YYtcs, YYline, {token, {'<', YYline}}.
= : YYlen, YYtcs, YYline, {token, {'=', YYline}}.
* : YYlen, YYtcs, YYline, {token, {'*', YYline}}.
: : YYlen, YYtcs, YYline, {token, {':', YYline}}.
/ : YYlen, YYtcs, YYline, {token, {'/', YYline}}.
$ : YYlen, YYtcs, YYline, {token, {'$', YYline}}.
@ : YYlen, YYtcs, YYline, {token, {'@', YYline}}.
% : YYlen, YYtcs, YYline, {token, {'%', YYline}}.
( : YYlen, YYtcs, YYline, {token, {'(', YYline}}.
) : YYlen, YYtcs, YYline, {token, {')', YYline}}.
%} : YYlen, YYtcs, YYline, {token, {'}', YYline}}.
%{ : YYlen, YYtcs, YYline, {token, {'{', YYline}}.
%[ : YYlen, YYtcs, YYline, {token, {'[', YYline}}.
%] : YYlen, YYtcs, YYline, {token, {']', YYline}}.
[rts] : YYlen, YYtcs, YYline, skip_token.
n : YYlen, YYtcs, YYline, {token, {'n', YYline}}.
: YYlen, YYtcs, YYline, {token, {char, YYline, hd(YYtext)}}.
Erlang code.
% Skipped
More information about the erlang-questions
mailing list