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

Shared token types #2100

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

TwoOfTwelve
Copy link
Contributor

@TwoOfTwelve TwoOfTwelve commented Dec 9, 2024

Added shared token types and description for how they should be used

Copy link

sonarqubecloud bot commented Dec 9, 2024

Copy link
Member

@tsaglam tsaglam left a comment

Choose a reason for hiding this comment

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

A few thoughts, maybe we need to discuss this in a meeting.

Comment on lines +1 to +7
Shared token types enable comparisons between languages

Examples are given in a pseudo language similar to Java or Cpp

# The Imperative paradigm

## Variables
Copy link
Member

Choose a reason for hiding this comment

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

This might be a bit too detailed for the wiki, as the wiki is currently mostly user-focused and has some high-level info for developers. However, we do not even explain tokenization in detail. Maybe we should move this documentation elsewhere, e.g. to the language API.

Comment on lines +8 to +9
METHOD("METHOD"),
METHOD_END("METHOD_END"),
Copy link
Member

Choose a reason for hiding this comment

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

Are methods really that object-oriented? I would say no, as this token would correspond to any function/routine.


import de.jplag.TokenType;

public enum ObjectOrientationTokens implements TokenType {
Copy link
Member

Choose a reason for hiding this comment

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

I would expect the tokens for classes, interfaces, and enums here or maybe in a separate enum for types.


import de.jplag.TokenType;

public enum AnnotationTokenTypes implements TokenType {
Copy link
Member

Choose a reason for hiding this comment

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

I would try avoid token types with single tokens.

Comment on lines +13 to +24
IF("IF"),
ELSE("ELSE"),
IF_END("IF_END"),
SWITCH("SWITCH"),
SWITCH_END("SWITCH_END"),
CASE("CASE"),
CASE_END("CASE_END"),
LOOP("LOOP"),
LOOP_END("LOOP_END"),
GOTO("GOTO"), // TODO different context?
BREAK("BREAK"),
CONTINUE("CONTINUE"),
Copy link
Member

Choose a reason for hiding this comment

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

I would move those into a token type for control flow tokens.

Comment on lines +26 to +27
FUNCTION_DEFINITION("FUNCTION_DEF"),
FUNCTION_END("FUNCTION_END"),
Copy link
Member

Choose a reason for hiding this comment

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

Why differentiate from methods here? Do we have languages that distinguish methods and functions during tokenization?

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.

2 participants