Ticket #7581: M90.x

File M90.x, 943 bytes (added by guest, 15 months ago)

Original Alex file

Line 
1{
2module Main (main) where
3
4import System.Environment
5}
6
7%wrapper "basic"
8
9$digit = 0-9  --digits
10$alpha = [a-zA-Z] --alphabetic characters
11
12tokens :-
13  \n  ;
14  ^90.00[$printable$white]*$ {\s -> Header s}
15  ^90.05[$printable$white]*$ {\s -> line9005 s}
16  ^99.00[$printable$white]*$ {\s -> Footer s}
17{
18--Each action has type :: String -> Token
19
20--The token type:
21data Token =
22  Header String |
23  Line9005 String |
24  Footer String
25  deriving (Eq,show)
26
27--instance Show Token where
28--  show (Header _) = "smthg"
29--  show (Line9005 s) = s
30--  show (Footer _) = "smthg2"
31
32rmSpace = filter (' ' /=)
33
34takeDrop t d s = take t $ drop d s
35
36codePro s = rmSpace $ takeDrop 17 23 s
37
38totUVC s = take 9 $ drop 78 s
39
40motImm s = take 3 (drop 130 s)
41
42line9005 s = Line9005 $ codePro s ++ "," ++ totUVC s ++ "," ++ motImm s
43
44main = do
45  args <- getArgs
46  s <- readFile $ head args
47  print (alexScanTokens s)
48}
49