Jaseci-Labs / jaclang

The Jac Programming Language
https://www.jac-lang.org
22 stars 21 forks source link

Trailing comma isn't supported in Jaclang #613

Open TharukaCkasthuri opened 1 month ago

TharukaCkasthuri commented 1 month ago

The Trailing comma isn't supported in Jaclang, and in some cases, when we mistakenly add a trailing comma, it throws a recursion error (RecursionError: maximum recursion depth exceeded) as in the screenshot.

Screenshot 2024-09-09 at 16 05 11

The example code in python;

ft.Column(
                spacing=25,
                controls=[
                    self.filter,
                    self.tasks,
                    ft.Row(
                        alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
                        vertical_alignment=ft.CrossAxisAlignment.CENTER,
                        controls=[
                            self.items_left,
                            ft.OutlinedButton(
                                text="Clear completed", on_click=self.clear_clicked
                            ),
                        ],
                    ),
                ],
            )

The code we are supposed to write in Jaclang;

    ft.Column(
                spacing=25,
                controls=[
                    self.filter,
                    self.tasks,
                    ft.Row(
                        alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
                        vertical_alignment=ft.CrossAxisAlignment.CENTER,
                        controls=[
                            self.items_left,
                            ft.OutlinedButton(
                                text="Clear completed", on_click=self.clear_clicked
                            )
                        ]
                    )
                ]
            );

it is good if the Trailing comma is made optional, similar to Python.

marsninja commented 1 month ago

Basically, i think we shoudl just update the language grammar to support that optional trailing comma, may have to double check parser.py