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

Should Go runtime ATN export some fields? #4702

Open
vczyh opened this issue Sep 26, 2024 · 10 comments
Open

Should Go runtime ATN export some fields? #4702

vczyh opened this issue Sep 26, 2024 · 10 comments

Comments

@vczyh
Copy link

vczyh commented Sep 26, 2024

For example, I want access ruleToStartState field, but it is not exported.

Go can't

ruleToStartState []*RuleStartState

But javascript can.

ruleToStartState: RuleStartState[];

@jimidle
Copy link
Collaborator

jimidle commented Sep 26, 2024

Why do you want to access this?

@vczyh
Copy link
Author

vczyh commented Sep 26, 2024

Why do you want to access this?

I am trying to understand the code, the repo implements autocompletion.

https:/mike-lischke/antlr4-c3/blob/44e0b76074b6ca7f0a080cbf12c2e8961b1ff127/src/CodeCompletionCore.ts#L203

@vczyh
Copy link
Author

vczyh commented Sep 26, 2024

type Transition interface {
	getTarget() ATNState
	setTarget(ATNState)
	getIsEpsilon() bool
	getLabel() *IntervalSet
	getSerializationType() int
	Matches(int, int, int) bool
}

only Matches(int, int, int) accessed.

@jimidle
Copy link
Collaborator

jimidle commented Sep 26, 2024

Some of this is left over from the code I took over and probably could still do with some clean up. But I don't see why Matches has been made public. I would have to look at the code.

@vczyh
Copy link
Author

vczyh commented Sep 26, 2024

Some of this is left over from the code I took over and probably could still do with some clean up. But I don't see why Matches has been made public. I would have to look at the code.

Thanks.
I found Java made a lot of methods public. Does Go need to conform to the other languages?

@vczyh
Copy link
Author

vczyh commented Sep 26, 2024

	public abstract int getSerializationType();

	/**
	 * Determines if the transition is an "epsilon" transition.
	 *
	 * <p>The default implementation returns {@code false}.</p>
	 *
	 * @return {@code true} if traversing this transition in the ATN does not
	 * consume an input symbol; otherwise, {@code false} if traversing this
	 * transition consumes (matches) an input symbol.
	 */
	public boolean isEpsilon() {
		return false;
	}


	public IntervalSet label() { return null; }

	public abstract boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol);

@jimidle
Copy link
Collaborator

jimidle commented Sep 26, 2024

Some of this is left over from the code I took over and probably could still do with some clean up. But I don't see why Matches has been made public. I would have to look at the code.

Thanks. I found Java made a lot of methods public. Does Go need to conform to the other languages?

No - only results. Go is not an OOP language

@vczyh
Copy link
Author

vczyh commented Sep 26, 2024

Some of this is left over from the code I took over and probably could still do with some clean up. But I don't see why Matches has been made public. I would have to look at the code.

Thanks. I found Java made a lot of methods public. Does Go need to conform to the other languages?

No - only results. Go is not an OOP language

Yes, but public method should conform.

@jimidle
Copy link
Collaborator

jimidle commented Sep 26, 2024

Some of this is left over from the code I took over and probably could still do with some clean up. But I don't see why Matches has been made public. I would have to look at the code.

Thanks. I found Java made a lot of methods public. Does Go need to conform to the other languages?

No - only results. Go is not an OOP language

Yes, but public method should conform.

Says who? ;)

The go runtime is completely different thing to Java and as such while the same functionality and indeed more functionality may well be available, it may operate completely differently. No obligations are placed upon target authors. The java target is the reference point, but it isn't a requirem,ent to copy it.

@vczyh
Copy link
Author

vczyh commented Sep 27, 2024

Some of this is left over from the code I took over and probably could still do with some clean up. But I don't see why Matches has been made public. I would have to look at the code.

Thanks. I found Java made a lot of methods public. Does Go need to conform to the other languages?

No - only results. Go is not an OOP language

Yes, but public method should conform.

Says who? ;)

The go runtime is completely different thing to Java and as such while the same functionality and indeed more functionality may well be available, it may operate completely differently. No obligations are placed upon target authors. The java target is the reference point, but it isn't a requirem,ent to copy it.

Well, thank you for your reply, I will try other methods.

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

No branches or pull requests

2 participants