aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ast
Commit message (Collapse)AuthorAgeFilesLines
* pkg/ast: remove trailing spaces when formattingDmitry Vyukov2020-11-251-3/+4
|
* sys/targets: add OS/Arch name constsDmitry Vyukov2020-10-261-1/+3
| | | | | | | | | | | | We use strings to identify OS/Arch. These strings are duplicated throughout the code base massively. golangci-lint points to possiblity of typos and duplication. We already had to define these names in pkg/csource and disable checking for prog package. A future change triggers such warnings in another package. Add OS/Arch name consts to sys/targets so that they can be used to refer to OS/Arch. Use the consts everywhere.
* pkg, prog: add per-field direction attributeNecip Fazil Yildiran2020-08-136-15/+44
|
* all: fix dup types in func argsDmitry Vyukov2020-07-041-1/+1
|
* .golangci.yml: make goconst checker more strictDmitry Vyukov2020-06-071-1/+1
|
* .golangci.yml: enable receiver name check for pkg/astDmitry Vyukov2020-06-071-38/+38
|
* .golangci.yml: enable godot checkerDmitry Vyukov2020-06-051-2/+2
| | | | | A good one. Lots of fixed comments are contributed by episodic contributors. So it's good to catch these earlier.
* pkg/ast: print full file name in errorsDmitry Vyukov2020-05-181-1/+1
| | | | | Print full names so that github annotations work. I.e. sys/linux/sys.txt instead of just sys.txt.
* pkg/ast: improve test outputDmitry Vyukov2020-05-052-12/+62
| | | | Improve the test utility to group error messages by line.
* pkg/ast: extend testsDmitry Vyukov2020-05-013-79/+114
| | | | Test more functions that we currently don't test.
* pkg/ast: add call attributesDmitry Vyukov2020-04-196-1/+26
|
* pkg/compiler: add tests for generation phaseDmitry Vyukov2020-03-172-7/+9
| | | | | | Add errors3.txt with tests for errors that are produced during generation phase. Refactor tests to reduce duplication. Tidy struct/union size errors: better locations and make testable.
* pkg/ast: introduce hex-encoded string literalsDmitry Vyukov2020-02-106-41/+70
| | | | | | | | | | | | | The stringnozescapes does not make sense with filename, also we may need similar escaping for string flags. Handle escaped strings on ast level instead. This avoids introducing new type and works seamleassly with flags. As alternative I've also tried using strconv.Quote/Unquote but it leads to ugly half-escaped strings: "\xb0\x80s\xe8\xd4N\x91\xe3ڒ,\"C\x82D\xbb\x88\\i\xe2i\xc8\xe9\xd85\xb1\x14):M\xdcn" Make hex-encoded strings a separate string format instead.
* pkg/ast: unexport Node.Walk()Paul Chaignon2019-10-232-20/+20
| | | | | | | Other packages should use ast.Recursive and ast.PostRecursive to ensure the root node is visited as well. Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
* pkg/compiler: fix infinite recursion in template instantiationDmitry Vyukov2019-10-101-1/+10
| | | | | | | | | Currently we replace a template argument and then recurse into the new type AST to see if there is more to replace. If the description is buggy and the template argument contains itself, then we will recurse infintiely trying to replace it more and more. Use post-order traversal when replacing template argument to fix this.
* pkg/ast: fix out-of-bounds accessDmitry Vyukov2019-07-301-1/+0
| | | | | Scanner can access data out of bounds on bad input. Also fix regression fuzz test to be able to detect the bug.
* pkg/compiler: support complex len targetsDmitry Vyukov2019-05-142-14/+17
| | | | | | | | | | This change adds compiler support for complex path expressions in len targets. E.g. it allows to refer to a sibling field as len[parent_struct:field:another_field]. See the docs change for details. This is just a compiler change. The feature is not yet supported by the prog package.
* pkg/ast: refactor COLON handlingDmitry Vyukov2019-05-145-23/+14
| | | | | | | This prepared for handling of bytesize[parent:foo:bar] expressions by allowing multiple identifiers after colon. No functional changes for now, just preparation for storing more than one identifier after colon.
* sys/linux: extend AX25/ROSE/NETROM descriptionsDmitry Vyukov2018-12-241-0/+1
|
* sys/fuchsia: prune unused structs in syscall description generated by fidlgenDokyung Song2018-09-111-0/+14
| | | | | | | | After generating syscall description for fidl files using fidlgen, prune all unused structs using the exact same mechanism used by the compiler's check for unused structs. This allows the FIDL compiler to support modular compilation; it does not need to have global knowledge of whether each struct is used or not.
* gometalinter: clean up vetshadowDmitry Vyukov2018-07-311-2/+2
| | | | | | | This just cleans up existing warnings. vetshadow is not enabled yet because it crashes. Update #538
* .gometalinter: reduce dupl thresholdDmitry Vyukov2018-07-311-40/+36
| | | | | | Reduce dupl threshold from 63 to 60 and fix violations. Update #538
* pkg/compiler: support negative integersDmitry Vyukov2018-07-096-47/+55
| | | | | | Currently we have to use 0xffffffffffffffff to represent -1, and we can't express e.g. -20:20 int range. Support negative consts to fix both problems.
* gometalinter: enable cyclomatic complexity checkingDmitry Vyukov2018-05-041-70/+93
| | | | | | Refactor some functions to be simpler. Update #538
* pkg/ast: support char constantsDmitry Vyukov2018-04-296-18/+49
| | | | | | | Frequently it's useful to do something like: int8['a':'z'] punctuation = ',', '-', ':'
* all: fix gometalinter warningsDmitry Vyukov2018-03-082-5/+5
| | | | Fix typos, non-canonical code, remove dead code, etc.
* pkg/compiler: switch attributes from Ident to TypeDmitry Vyukov2018-03-055-11/+16
| | | | | This allows parametrized attributes like size[10]. But this is not used for now.
* pkg/compiler: allow unions as syscall argumentsDmitry Vyukov2018-02-231-0/+6
| | | | | If all union options can be syscall arguments, allow the union itself as syscall argument.
* pkg/compiler: allow use of empty stringsDmitry Vyukov2018-01-236-13/+10
| | | | This comes up in several contexts in netfilter.
* pkg/compiler: support type templatesDmitry Vyukov2018-01-137-110/+180
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Netlink descriptions contain tons of code duplication, and need much more for proper descriptions. Introduce type templates to simplify writing such descriptions and remove code duplication. Note: type templates are experimental, have poor error handling and are subject to change. Type templates can be declared as follows: ``` type buffer[DIR] ptr[DIR, array[int8]] type fileoff[BASE] BASE type nlattr[TYPE, PAYLOAD] { nla_len len[parent, int16] nla_type const[TYPE, int16] payload PAYLOAD } [align_4] ``` and later used as follows: ``` syscall(a buffer[in], b fileoff[int64], c ptr[in, nlattr[FOO, int32]]) ```
* pkg/ast: refactor WalkDmitry Vyukov2018-01-114-74/+98
| | | | | Refactor Walk so that it's possible to abort or wrap walk of child nodes. Will be needed for future changes.
* pkg/compiler: add builtin bool type aliasesDmitry Vyukov2018-01-081-2/+2
| | | | | | | | | | | | | | | | This adds builtin: type bool8 int8[0:1] type bool16 int16[0:1] type bool32 int32[0:1] type bool64 int64[0:1] type boolptr intptr[0:1] We used to use just int's for bools. But bool types provide several advantages: - make true/false probability equal - improve description expressiveness - reduce search space (we will take advantage of this later)
* sys: support type aliases (aka typedefs)Dmitry Vyukov2018-01-086-64/+107
| | | | | | | | | | | | | | | | | | | | | | Complex types that are often repeated can be given short type aliases using the following syntax: ``` type identifier underlying_type ``` For example: ``` type signalno int32[0:65] type net_port proc[20000, 4, int16be] ``` Then, type alias can be used instead of the underlying type in any contexts. Underlying type needs to be described as if it's a struct field, that is, with the base type if it's required. However, type alias can be used as syscall arguments as well. Underlying types are currently restricted to integer types, `ptr`, `ptr64`, `const`, `flags` and `proc` types.
* pkg/ast: fix TestParseAllDmitry Vyukov2017-10-191-10/+6
|
* executor, sys/windows: initial windows supportDmitry Vyukov2017-09-251-0/+3
|
* pkg/ast: prohibit empty stringsDmitry Vyukov2017-09-042-0/+12
| | | | This is currently unsupported and unused.
* pkg/ast: fix struct comment parsingDmitry Vyukov2017-09-042-0/+13
|
* pkg/compiler: check and generate typesDmitry Vyukov2017-09-022-10/+10
| | | | | | Move most of the logic from sysgen to pkg/compiler. Update #217
* pkg/compiler: more static error checkingDmitry Vyukov2017-08-277-103/+211
| | | | Update #217
* pkg/compiler: move more const-processing code to compilerDmitry Vyukov2017-08-273-67/+57
|
* pkg/compiler, sys/syz-sysgen: move const handling to pkg/compilerDmitry Vyukov2017-08-277-88/+312
| | | | Now pkg/compiler deals with consts.
* sys/syz-sysgen: switch to new parserDmitry Vyukov2017-08-182-3/+36
| | | | | For now we just generate the old structs from the new AST. But this allows to delete the old parser entirely.
* sys/syz-extract: switch to the new parserDmitry Vyukov2017-08-184-6/+116
|
* Makefile: enforce formatting of sys files in presubmitDmitry Vyukov2017-08-181-6/+4
|
* pkg/ast: new parser for sys descriptionsDmitry Vyukov2017-08-186-0/+1213
The old parser in sys/sysparser is too hacky, difficult to extend and drops debug info too early, so that we can't produce proper error messages. Add a new parser that is build like a proper language parser and preserves full debug info for every token.