-
Notifications
You must be signed in to change notification settings - Fork 0
Change generics syntax #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Changed generic function syntax from `fn func<T>(x: T) -> T` to `fn func T' (x: T) -> T`. - Updated member access expressions to type member access expressions in various files. - Modified array initialization syntax to align with new type member access conventions. - Adjusted variable definitions to use the new syntax for non-primitive types. - Added a new parser and library files for inference functionality.
… multiple files - Updated comment syntax from `///` to `//` in various function definitions and specifications. - Removed unnecessary operators in the grammar specifications for function definitions, variable declarations, and expressions. - Cleaned up the structure of the code to improve readability and maintainability. - Ensured consistency in the representation of variable assignments and function definitions in the specification files.
…case for 'inference'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request changes the generics syntax from angle brackets (<>) to a postfix apostrophe (') notation and updates various language constructs to improve consistency and readability.
- Changes generic syntax from
Array<T>toArray T'format - Removes unnecessary operator tokens (function_keyword, assign_operator, etc.) in favor of direct string literals
- Updates comment syntax from
///(docstring) to//(regular comments) in test files - Modernizes tree-sitter grammar structure and node definitions
Reviewed Changes
Copilot reviewed 30 out of 35 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| grammar.js | Core grammar changes implementing new generics syntax and removing operator tokens |
| src/grammar.json | Generated grammar JSON reflecting the new syntax rules |
| src/node-types.json | Updated node type definitions for the new grammar structure |
| test/corpus/*.txt | Test corpus files updated to reflect new generics and comment syntax |
| queries/highlights.scm | Updated syntax highlighting for new function keyword handling |
| package.json | Updated dependencies to newer versions |
| example.inf | Example file demonstrating the new syntax |
Comments suppressed due to low confidence (1)
test/corpus/expressions/binary.txt:115
- The parentheses around generic types in member access expressions
(Array u32')::new()creates visual inconsistency. The syntax should be standardized - either always require parentheses for generics in member access or find an alternative approach.
(number_literal)
…o 'tree_sitter_inference' in header files and related configurations
…o 'tree_sitter_inference' in header files and related configurations
|
I agree with general idea - overuse of |
|
Thanks for the question |
…roject.toml; update generated parser version in parser.c
…er version in parser.c
Description
Apart from internal grammar improvements, this PR changes the way of defining generics. The reason is to get rid of ambiguity using
<and>symbols inGeneric parameters definition
Was:
fn foo<A>() -> i32Now:
fn foo A' () -> i32Similarly with types
Was:
struct Vector<T>Now:
struct Vector T'Access to generalized type functions
Was:
Vector<i32>::new()Now:
(Vector i32')::new()What's new
Now, the angle brackets are not a part of the generic syntax definition. Instead, we use a list of names with a prime suffix.
Comments are not separated from Docstrings
//is a comment///is a docstring