Last change
on this file since 93 was 93, checked in by nmir-saito, 8 years ago |
add Combined package of SSP kernel for QB-R5F100LE-TB(RL78 processor)
|
File size:
2.0 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.IO;
|
---|
3 | using System.Text.RegularExpressions;
|
---|
4 |
|
---|
5 | namespace gensyms_rl78
|
---|
6 | {
|
---|
7 | class Program
|
---|
8 | {
|
---|
9 | static void Main(string[] args)
|
---|
10 | {
|
---|
11 | // 引数チェック
|
---|
12 | if (args.Length != 1)
|
---|
13 | {
|
---|
14 | Console.Error.WriteLine("usage: gensyms-rl78 <symbol-table-filename>");
|
---|
15 | Environment.Exit(1);
|
---|
16 | }
|
---|
17 |
|
---|
18 | /*
|
---|
19 | * ファイル中でチェックするパターン
|
---|
20 | */
|
---|
21 | // (パブリック・ローカル)シンボル定義開始
|
---|
22 | var regDelim = new Regex(@";FF (?<name>.+)");
|
---|
23 | // シンボル定義
|
---|
24 | var regEntry = new Regex(@"^(?<attr>\d\d)(?<addr>[0-9a-fA-F]{5})(?<name>.+)");
|
---|
25 |
|
---|
26 | try
|
---|
27 | {
|
---|
28 | var sr = new StreamReader(args[0]);
|
---|
29 | string line;
|
---|
30 |
|
---|
31 | // シンボルテーブルファイルの先頭をチェック
|
---|
32 | if (!new Regex(@"#05").IsMatch(sr.ReadLine()))
|
---|
33 | {
|
---|
34 | throw new Exception("This file is not a symbol table file. abort.");
|
---|
35 | }
|
---|
36 |
|
---|
37 | while ((line = sr.ReadLine()) != null)
|
---|
38 | {
|
---|
39 | // パブリックシンボルの開始を探す
|
---|
40 | if (regDelim.Match(line).Groups["name"].Value == "PUBLIC")
|
---|
41 | {
|
---|
42 | // パブリックシンボル定義の終わりまで,シンボル定義を出力
|
---|
43 | while (!regDelim.IsMatch(line = sr.ReadLine()))
|
---|
44 | {
|
---|
45 | var m = regEntry.Match(line);
|
---|
46 | Console.WriteLine("000" + m.Groups["addr"] + " T " + m.Groups["name"]);
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
50 | }
|
---|
51 | catch (Exception e)
|
---|
52 | {
|
---|
53 | Console.Error.WriteLine("処理に失敗しました:" + e.ToString());
|
---|
54 | Environment.Exit(1);
|
---|
55 | }
|
---|
56 | }
|
---|
57 | }
|
---|
58 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.