titzer / virgil

A fast and lightweight native programming language
1.22k stars 42 forks source link

Precedence of virgil syntax #68

Closed csmoe closed 2 years ago

csmoe commented 2 years ago

Is there any material specifies the precedence of virgil syntax?

I'm trying to write the virgil's grammar.js for tree-sitter, which will bring syntax highlight and basic code navigation for virgil in common editors like vim, vscode etc.

cc the rust precedence table https://github.com/tree-sitter/tree-sitter-rust/blob/0f14a10011ac6e56f309fb99a94829c3312b743a/grammar.js#L1

titzer commented 2 years ago

Yep, the precedence of each infix operator is specifed here:

https://github.com/titzer/virgil/blob/master/aeneas/src/v3/V3Infix.v3

The parser uses those constants directly, so that definition is canonical.

titzer commented 2 years ago

Thanks for doing this!

Also note there is a vim mode in bin/dev/virgil-vim.

titzer commented 2 years ago

Going to close this, as I think the above answers the original question. Feel free to submit a PR if you succeed at making a grammar for tree-sitter. Thanks.