Skip to content

Commit

Permalink
update array syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
grencez committed Jul 5, 2024
1 parent a077cc5 commit 3ad1750
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 32 deletions.
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ bazel_dep(name = "rules_proto", version = "4.0.0")

git_override(
module_name = "fildesh",
commit = "85b2789f5b4051bf8771bcea5bc4034c8253336a",
remote = "https://github.com/grencez/fildesh.git",
commit = "87a214f39cd54c68ff8889204ad9d964c1015541",
remote = "https://github.com/fildesh/fildesh.git",
)
8 changes: 4 additions & 4 deletions example/intro_5_array.sxpb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
; An array of integers.
((my_integers) 1 2 3)
(my_integers (()) 1 2 3)

; An array of strings.
((my_strings) "yo" "howdy" "sup")
(my_strings (()) "yo" "howdy" "sup")

; An array of 3 messages.
((my_messages)
(my_messages (())
(() (i 5))
(())
()
(() (i 5) (f 5.5) (s "hello")))
12 changes: 7 additions & 5 deletions example/popcorn.sxpb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
(name "popcorn")
(name popcorn)
(amount 3)
(variety +true)
(expect_unit_cost 7.50)

; List of favorite kinds.
((favorites)
"cheddar" "caramel" "butter")
(favorites ()
cheddar caramel butter
)

; In case of no popcorn.
(alternative
(name "hot dog")
(amount 2))
(name "hot dog")
(amount 2)
)
10 changes: 6 additions & 4 deletions example/sauces.sxpb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
(budget 30)

((items)
(items ()
(()
(name "dip")
(amount 1)
(expect_cost 6.50)
((favorites) "hummus" "garlic"))
(favorites () "hummus" "garlic"))
(()
(name "hot sauce")
(amount 3)
(variety +true)
(expect_unit_cost 6.50)
((favorites)
(favorites ()
"yuzu" "kiss" "fire"
"bee" "sunshine")))
"bee" "sunshine")
)
)

; vim: ft=lisp lw=nil
5 changes: 2 additions & 3 deletions src/binaryproto2sxproto_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ write_message_to_sxproto_ostream(
reflection->ListFields(message, &fields);

for (const FieldDescriptor* field : fields) {
out << '(';
out << '(' << field->name() << ' ';
if (field->is_repeated()) {
out << '(' << field->name() << ')';
out << "(())";
int n = reflection->FieldSize(message, field);

if (field->type() == FieldDescriptor::TYPE_MESSAGE) {
Expand All @@ -50,7 +50,6 @@ write_message_to_sxproto_ostream(
}
}
else {
out << field->name() << ' ';
if (field->type() == FieldDescriptor::TYPE_MESSAGE) {
const Message& submessage = reflection->GetMessage(message, field);
const bool good = write_message_to_sxproto_ostream(out, submessage);
Expand Down
2 changes: 1 addition & 1 deletion test/depend/shopping.sxpb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(grocery_list
(budget 10)
((items)
(items ()
(()
(name "jar of olives")
(amount 1))
Expand Down
13 changes: 7 additions & 6 deletions test/depend/task.sxpb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(shopping_list
(grocery_list
((items)
(()
(name "beer")
(amount 99))
)
(grocery_list
(items (())
(()
(name beer)
(amount 99)
)
)
)
)
15 changes: 8 additions & 7 deletions test/manyof/boolexpr.sxpb
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
((expressions)
(expressions ((value))

(value +true)

(not (value +false))

((or) (() (value +false)) (() (value +true)))
((or) (value +false) (value +true))
(((or)) +false +true)
(or (()) (() (value +false)) (() (value +true)))
(or (()) (value +false) (value +true))
(or ((value)) +false +true)

(((or))
(or ((value))
+false
(((and)) +true +false)
(((or)) +false +false +true))
(and ((value)) +true +false)
(or ((value)) +false +false +true)
)
)

0 comments on commit 3ad1750

Please sign in to comment.