eini_lexer.xrl 1.79 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
%% Licensed to the Apache Software Foundation (ASF) under one
%% or more contributor license agreements.  See the NOTICE file
%% distributed with this work for additional information
%% regarding copyright ownership.  The ASF licenses this file
%% to you under the Apache License, Version 2.0 (the
%% "License"); you may not use this file except in compliance
%% with the License.  You may obtain a copy of the License at
%%
%%   http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied.  See the License for the
%% specific language governing permissions and limitations
%% under the License.

Shunichi Shinohara's avatar
Shunichi Shinohara committed
18
%% @author: shino@accense.com
19

Devin Torres's avatar
Devin Torres committed
20
21
Definitions.

22
23
K = [a-z][a-zA-Z0-9_\.]*
V = [a-z][a-zA-Z0-9_\.]*
Devin Torres's avatar
Devin Torres committed
24
S = [\s\t]
25
B = [\n\r]
Devin Torres's avatar
Devin Torres committed
26
27
28

Rules.

Shunichi Shinohara's avatar
Shunichi Shinohara committed
29
%% skip comment line,which has ; at the beginning of line
30
{B};.*{B}        : {skip_token, "\n"}.
Shunichi Shinohara's avatar
Shunichi Shinohara committed
31
32

%% skip empty lines or lines with space/tab chars
33
{B}{S}*{B}       : {skip_token, "\n"}.
Shunichi Shinohara's avatar
Shunichi Shinohara committed
34
35

%% mark line break by token 'break' in order to use as delimiters
36
{B}              : {token, {break,   TokenLine, TokenChars}}.
Shunichi Shinohara's avatar
Shunichi Shinohara committed
37
38

%% Just chars
39
40
41
=                : {token, {'=',     TokenLine}}.
\[               : {token, {'[',     TokenLine}}.
\]               : {token, {']',     TokenLine}}.
Shunichi Shinohara's avatar
Shunichi Shinohara committed
42
43

%% word-like tokens
44
{S}+             : {token, {blank,   TokenLine, TokenChars}}.
45
46
47
"{K}"            : {token, {quoted,  TokenLine, TokenChars}}.
{K}              : {token, {word,    TokenLine, TokenChars}}.
{V}              : {token, {value,   TokenLine, TokenChars}}.
Shunichi Shinohara's avatar
Shunichi Shinohara committed
48
49

%% comment-like token, but may be a part of value depending on the location
50
;.*              : {token, {comment, TokenLine, TokenChars}}.
Devin Torres's avatar
Devin Torres committed
51
52

Erlang code.