diff options
| author | Yuzhe Han <hyz0906@gmail.com> | 2017-06-26 16:52:47 +0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-06-26 10:52:47 +0200 |
| commit | 7077339b7023f597d9d91113974204fbc7ff43cc (patch) | |
| tree | 9282720ad883993598c9c8c621caea53f49ab63f /sys/sysparser | |
| parent | 9af315342072b6df7f56cf5387534f390c794fa0 (diff) | |
Parse incdir "incdir" in syscall description file to add custom include directories. (#180)
* Parse #incdir "incdir" in syscall description file to add custom include directories.
* add flagLinux
* remove '#' in incdir flag
* Update sys/README.md AUTHORS CONTRIBUTORS.
Diffstat (limited to 'sys/sysparser')
| -rw-r--r-- | sys/sysparser/lexer.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/sysparser/lexer.go b/sys/sysparser/lexer.go index 505b52059..c6a0f802e 100644 --- a/sys/sysparser/lexer.go +++ b/sys/sysparser/lexer.go @@ -14,6 +14,7 @@ import ( type Description struct { Includes []string + Incdirs []string Defines map[string]string Syscalls []Syscall Structs map[string]*Struct @@ -48,6 +49,7 @@ type Resource struct { func Parse(in io.Reader) *Description { p := newParser(in) var includes []string + var incdirs []string defines := make(map[string]string) var syscalls []Syscall structs := make(map[string]*Struct) @@ -164,6 +166,19 @@ func Parse(in io.Reader) *Description { failf("struct '%v' is redefined as resource", name) } resources[id] = Resource{id, base, vals} + } else if name == "incdir" { + p.Parse('"') + var incdir []byte + for { + ch := p.Char() + if ch == '"' { + break + } + p.Parse(ch) + incdir = append(incdir, ch) + } + p.Parse('"') + incdirs = append(incdirs, string(incdir)) } else { switch ch := p.Char(); ch { case '(': @@ -237,6 +252,7 @@ func Parse(in io.Reader) *Description { sort.Sort(syscallArray(syscalls)) return &Description{ Includes: includes, + Incdirs: incdirs, Defines: defines, Syscalls: syscalls, Structs: structs, |
