[erlang-questions] Leex dot

datacompboy datacompboy@REDACTED
Fri Dec 8 07:14:17 CET 2006



rvirding wrote:
'.' is supposed to mean any character except newline
(end of quote)


I have separate rule for newline


rvirding wrote:
so what you have there may seem wrong. But the characters for each state are not independant of all other state, it could depend on your other rules. 
(end of quote)


Whole grammar:

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


After compilation code above (you can just remove unknown functions, that was defined in erlang code to see), we have one of state follows:
yystate(??, [C|Ics], Line, Tlen, _Action, _Alen) when C >= $



More information about the erlang-questions mailing list