blob: 7a75fd9b3bbdd95a9956a945cffcf6a1cd243f3e (
plain)
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
|
token newline / '\n' /
token index / 'Index:' [ \t]* /
token consume_line / [^\n]* /
def index_stmt [index consume_line newline]
token separator_line / '='+ '\n' /
# Whitespace separated word list
lex word_list
{
token word /[^\t \n]+/
ignore /[\t ]+/
def word_list
[word word_list]
| []
}
token old_file_start / '---' [\t ]+ /
token new_file_start / '+++' [\t ]+ /
def old_file
[old_file_start word_list newline]
def new_file
[new_file_start word_list newline]
def file_header
[index_stmt separator_line old_file new_file]
token hunk_header / '@@' any* :>> '@@' '\n' /
token hunk_line / ( ' ' | '-' | '+' ) [^\n]* '\n' /
def hunk_body
[hunk_line*]
def hunk
[hunk_header hunk_body]
# diff of a single file: header followed by a hunk list.
def file_diff
[file_header hunk*]
def start
[file_diff*]
parse S: start( stdin )
for OF: old_file in S {
# Get the first word and check if it is
# the file we are interested in.
if match OF [
"--- fsmrun.cpp"
Rest: word_list
"\n"
]
{
OF = construct old_file
["--- newfilename.cpp " Rest "\n"]
}
}
print( S )
|