-
Notifications
You must be signed in to change notification settings - Fork 0
/
bonapp.pegjs
91 lines (71 loc) · 1.99 KB
/
bonapp.pegjs
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
File
= head:PageHeader _ table:Table _
{ return {info: head, data: table} }
PageHeader "Page Header"
= _ "MEALPLANTRANLEDG.TRANDATE in" _ from:DateTime _ "to" _ to:DateTime
{ return {from, to} }
DateTime
= "DateTime("
year:Integer cs
month:Integer cs
day:Integer cs
hour:Integer cs
minute:Integer cs
second:Integer ")"
{ return {year, month, day, hour, minute, second} }
Table
= header:TableHeader _ body:TableBody
{ return body }
TableHeader
= _ "Stav Ha STO GUI STO Mic Total"
/ _ "STO GUI STO Mic Total"
/ _ "STO Mic Total"
TableBody
= TableRow+
TableRow
= _ row:(BasicRow / SummaryRow / PeriodSummaryRow / GrandTotalRow) _
{ return row }
BasicRow "Basic Row"
= data:DataColumns
{ return {type: 'basic', data} }
DataColumns "Data Columns"
= mic:Number _ total:Number !([ \t]+ Number)
{ return {mic, total} }
/ gui:Number _ mic:Number _ total:Number !([ \t]+ Number)
{ return {gui, mic, total} }
/ stav:Number _ gui:Number _ mic:Number _ total:Number
{ return {stav, gui, mic, total} }
SummaryRow
= ("Meal Period"?) _ time:Time _ data:DataColumns
{ return {type: 'summary', time, data} }
Time
= hour:Integer ":"
minute:Integer ":"
rest:( second:Integer meridiam:("AM" / "PM") { return second + " " + meridiam }
/ "Group" { return "" } )
{ return hour + ":" + minute + (rest ? ":" + rest : "") }
PeriodSummaryRow "Period Summary Row"
= num:(Integer / "?") _ "--" _ title:PeriodTitle _ "Total" _ data:DataColumns
{ return {type: 'period', num, title, data} }
GrandTotalRow "Grand Total Row"
= "Grand Total" _ data:DataColumns
{ return {type: 'total', data} }
PeriodTitle
= "*UNKNOW"
/ "Breakfa"
/ "Brunch"
/ "Lunch"
/ "Dinner"
String
= text:[a-zA-Z*]+
{ return text.join('') }
Number "number"
= text:[0-9,]+
{ return parseInt(text.filter(ch => ch !== ',').join(''), 10) }
Integer "integer"
= text:[0-9]+
{ return parseInt(text.join(''), 10) }
cs "comma-space"
= ", "
_ "whitespace"
= [ \t\n\r]*