-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexer.mll
66 lines (58 loc) · 1.88 KB
/
lexer.mll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
(* ----------------------------------------------------------------------------
* SchedMCore - A MultiCore Scheduling Framework
* Copyright (C) 2012, ONERA, Toulouse, FRANCE
*
* This file is part of Mince
*
* Mince is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Mince is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*---------------------------------------------------------------------------- *)
{
open Parser
exception Error of Location.t
(* Update line number for location info *)
let incr_line lexbuf =
let pos = lexbuf.Lexing.lex_curr_p in
lexbuf.Lexing.lex_curr_p <- { pos with
Lexing.pos_lnum = pos.Lexing.pos_lnum + 1;
Lexing.pos_bol = pos.Lexing.pos_cnum;
}
}
let blank = [' ' '\009' '\012']
rule token = parse
| '#' [^ '\n']*
{ token lexbuf }
| '\n'
{ incr_line lexbuf;
token lexbuf }
| blank +
{ token lexbuf }
| "TFF-2.0" { MAGIC_V2 }
| "Task" { TASK }
| "Dependency" { DEPENDENCY }
| "ComBuffer" { COMBUFFER }
| "Map" { MAP }
| '-'?['0'-'9']+
{ INT (int_of_string (Lexing.lexeme lexbuf)) }
| '"'[^'"']*'"'
{ STRING (String.sub (Lexing.lexeme lexbuf)
1 ((String.length (Lexing.lexeme lexbuf))-2)) }
| '(' { LPAR }
| ')' { RPAR }
| ',' { COMMA }
| ':' { COLON }
| ":=" { DEF }
| eof { EOF }
| _ { raise (Error (Location.curr lexbuf)) }