From e59ec59b027f921a6bfbe5014b15c2a802445ada Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 29 Nov 2023 16:01:41 +0100 Subject: pkg/ast: support expressions with ast.Type So far they have the following grammar: OP = "==", "!=", "&" value-expr = value-expr OP value-expr | factor factor = "(" and-expr ")" | integer | identifier | string Operators are left associative, e.g. A & B & C is the same as (A & B) & C. Further restrictions will be imposed in pkg/compiler. This will help implement conditionally included fields. --- pkg/ast/testdata/errors.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'pkg/ast/testdata/errors.txt') diff --git a/pkg/ast/testdata/errors.txt b/pkg/ast/testdata/errors.txt index 266babf8f..b3d9e7f52 100644 --- a/pkg/ast/testdata/errors.txt +++ b/pkg/ast/testdata/errors.txt @@ -11,7 +11,7 @@ meta foo, bar ### unexpected ',', expecting '\n' int_flags0 = 0, 0x1, 0xab int_flags1 = 123ab0x ### bad integer "123ab0x" -int_flags1 == 0, 1 ### unexpected '=', expecting int, identifier, string +int_flags1 == 0, 1 ### unexpected ==, expecting '(', '{', '[', '=' int_flags = 0, "foo" ### unexpected string, expecting int, identifier int_flags2 = ' ### char literal is not terminated int_flags3 = 'a ### char literal is not terminated @@ -67,6 +67,14 @@ s3 { f1 int8 } [attribute[1, "foo"], another[and[another]]] +sCondFieldsError1 { + f0 int16 (out, if[val[mask] SOME_CONST == val[mask]]) ### unexpected identifier, expecting ']' +} ### unexpected '}', expecting comment, define, include, resource, identifier + +sCondFieldsError2 { + f5 int16 (out, if[val[mask] & == val[mask]]) ### unexpected ==, expecting int, identifier, string +} ### unexpected '}', expecting comment, define, include, resource, identifier + type mybool8 int8 type net_port proc[1, 2, int16be] type mybool16 ### unexpected '\n', expecting '[', identifier -- cgit mrf-deployment