diff options
| author | Paul Chaignon <paul.chaignon@gmail.com> | 2023-12-01 16:22:30 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2023-12-05 13:40:28 +0000 |
| commit | a1e6e87df50aaef1dce280405b59ba2bfa93c0f3 (patch) | |
| tree | d1035ca4136096f9e8d83e22826dfb46bb54c304 /pkg/ast | |
| parent | ada1d56f0f3c555123547e44695695f7d284b6d6 (diff) | |
compiler: require nested flags to be at the end of the list
This commit adds the requirement that nested flags must be at the end of
the list of values. For example,
flags1 = 1, 2, 3, 4, flags2
flags2 cannot be moved to another position in the list. The goal is to
simplify parsing of the list by humans.
Enforcing that the nested flags be at the end (vs. the beginning) makes
things a bit easier for the parser. If we enforced that they should be
at the beginning, then the parser would need to look further forward to
determine if a flags definition is an integer flags or a string flags.
flags1 = flags2, flags3, flags4, 5, 6
In this example, the parser would need to look to the 4th value in the
list to tell that it's an integer flags.
Suggested-by: Aleksandr Nogikh <nogikh@google.com>
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'pkg/ast')
| -rw-r--r-- | pkg/ast/ast.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/ast/ast.go b/pkg/ast/ast.go index 2e8a7a015..2458c1245 100644 --- a/pkg/ast/ast.go +++ b/pkg/ast/ast.go @@ -30,6 +30,7 @@ type Node interface { type Flags[T FlagValue] interface { SetValues(values []T) GetValues() []T + GetPos() Pos } type FlagValue interface { @@ -152,6 +153,10 @@ func (n *IntFlags) GetValues() []*Int { return n.Values } +func (n *IntFlags) GetPos() Pos { + return n.Pos +} + type StrFlags struct { Pos Pos Name *Ident @@ -170,6 +175,10 @@ func (n *StrFlags) GetValues() []*String { return n.Values } +func (n *StrFlags) GetPos() Pos { + return n.Pos +} + type TypeDef struct { Pos Pos Name *Ident |
