Skip to content
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

Adding some basic of F# #4042

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Adding some basic of F# #4042

wants to merge 1 commit into from

Conversation

georga399
Copy link

Adding F# grammar.

@KvanTTT KvanTTT self-assigned this Apr 8, 2024
Copy link
Member

@KvanTTT KvanTTT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big thanks for the new grammar and welcome to ANTLR grammars!

But please fix the following things:

  • Get rid of not needed parentheses
  • Factor out common parts
  • Split operators by whitespaces


WHITE_SPACE: [ \t\r\n]+ -> channel(HIDDEN) ;
LINECOMMENT: '//' ~[\r\n]* -> channel(HIDDEN);
BLOCKCOMMENT: ('(*' .*? '*)') -> channel(HIDDEN);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please get rid of not needed parentheses:

Suggested change
BLOCKCOMMENT: ('(*' .*? '*)') -> channel(HIDDEN);
BLOCKCOMMENT: '(*' .*? '*)' -> channel(HIDDEN);

LINECOMMENT: '//' ~[\r\n]* -> channel(HIDDEN);
BLOCKCOMMENT: ('(*' .*? '*)') -> channel(HIDDEN);

INT: [0-9]+('uy'|'y'|'s'|'us'|'u'|'L')?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please factor out common parts:

Suggested change
INT: [0-9]+('uy'|'y'|'s'|'us'|'u'|'L')?;
INT: [0-9]+ ('u' ('y' | 's')? | 'y' | 's' | 'L')?;


FLOAT: [0-9]+'.'[0-9]+ ('f'|'m')?;

INTERPOLATIONSIGN: '%s'|'%d'|'%f'|'%c';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
INTERPOLATIONSIGN: '%s'|'%d'|'%f'|'%c';
INTERPOLATIONSIGN: '%' ('s' | 'd' | 'f' | 'c');


INTERPOLATIONSIGN: '%s'|'%d'|'%f'|'%c';

CHAR: '\''(~[\\']|'\\'['"nt\\]|'\\u'[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])'\'';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split operators by whitespaces (exclusing parentheses):

Suggested change
CHAR: '\''(~[\\']|'\\'['"nt\\]|'\\u'[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])'\'';
CHAR: '\'' (~[\\'] | '\\' ['"nt\\] | '\\u' [0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) '\'';

It improves grammar reading experience and fits other grammars' code-style.


INT: [0-9]+('uy'|'y'|'s'|'us'|'u'|'L')?;

FLOAT: [0-9]+'.'[0-9]+ ('f'|'m')?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FLOAT: [0-9]+'.'[0-9]+ ('f'|'m')?;
FLOAT: [0-9]+ '.' [0-9]+ ('f'|'m')?;


of:OF;

enum: (VERTICAL_LINE dotIentifier (equal|of) dotIentifier)+;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enum: (VERTICAL_LINE dotIentifier (equal|of) dotIentifier)+;
enum: (VERTICAL_LINE dotIentifier (equal | of) dotIentifier)+;


with: WITH;

record: OPEN_BRACE (((expression COLON dotIentifier) *)| (expression* with expression*)) CLOSE_BRACE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
record: OPEN_BRACE (((expression COLON dotIentifier) *)| (expression* with expression*)) CLOSE_BRACE;
record: OPEN_BRACE ((expression COLON dotIentifier)* | expression* with expression*) CLOSE_BRACE;

Comment on lines +180 to +182
with_get_set: (WITH ((private|internal|public)? GET UNIT EQUAL expression)
(AND ((private|internal|public)? SET expression* EQUAL expression)?)
| (WITH (private|internal|public)? expression* EQUAL expression));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with_get_set: (WITH ((private|internal|public)? GET UNIT EQUAL expression)
(AND ((private|internal|public)? SET expression* EQUAL expression)?)
| (WITH (private|internal|public)? expression* EQUAL expression));
with_get_set: WITH visibilityModifier?
( GET UNIT EQUAL expression AND (visibilityModifier? SET expression* EQUAL expression)?
| expression* EQUAL expression
)
;
visibilityModifier: private | internal | public;


record: OPEN_BRACE (((expression COLON dotIentifier) *)| (expression* with expression*)) CLOSE_BRACE;

of:OF;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
of:OF;
of: OF;

Comment on lines +1 to +3
### Grammar for F#
Maybe some troubles with handling tabulation.
Maybe some troubles with defining classes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Grammar for F#
Maybe some troubles with handling tabulation.
Maybe some troubles with defining classes.
### Grammar for F#
Maybe some troubles with handling tabulation.
Maybe some troubles with defining classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants