-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormatter.g
More file actions
54 lines (48 loc) · 1.69 KB
/
Formatter.g
File metadata and controls
54 lines (48 loc) · 1.69 KB
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
grammar Formatter;
@members {
private int eol = 0, events = 0;
private String name;
}
/* type
: n = CPU { name = $n.text; } rest_of_type eol // { System.out.println("Saw and cpu");
| n = ID { name = $n.text; } rest_of_type eol // { System.out.println("Saw and id");
| n = FUNC { name = $n.text; } rest_of_type eol // { System.out.println("Saw and func");
| n = BEGIN { name = $n.text; } rest_of_type eol // { System.out.println("Saw and begin");} */
/*
rest_of_type
: e = INTEGER { events = (Integer.valueOf($e.text)); }EVENTS FLOAT SECONDS INTEGER EPERS
;
*/
output
@init { eol
String s = "";
String s1 = "";
}
: (eol)*
CPU ID FUNC eol
INTEGER INTEGER BEGIN eol
INTEGER events = INTEGER t = TICK eol
INTEGER INTEGER END eol
DASHES KS DASHES eol
sidenum = INTEGER eol
{ System.out.println("insert into ibprofile (line, events, ticks, cpu, count, function, stack) values(" +
eol() + ", " + events + ", " + t + ", " + sidenum
+ ", " + $count.text + ", '" + $funct.text + "', '" + s.replace('\'', '^') + "') ;");
s = "";
}
;
eol : EOL+ { eol++; }
;
WS : (' ' | '\t')+ { $channel=HIDDEN; } ;
COLON: ':' ;
CPU: 'CPU' ;
ID: 'ID' ;
FUNC: 'FUNCTION:NAME' ;
BEGIN: ':BEGIN' ;
END: ':END' ;
TICK: ':tick-' ('0'..'9')+ 's' ;
DASHES: ('-')+ ;
KS: 'Kernel stacks' ;
INTEGER: ('0'..'9')+ ;
STACKELEM: '0x' ('!'..'~')+ | ('a'..'z' | 'A'..'Z' | '_' | '\'')? ('!'..'~')+ ; // A string of any printable ascii characters (except space) that begins with an alpha or 0x or '_'
EOL: '\n' | '\r' | '\n\r' | '\r\n' ;