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

Cannot generate Dart target, version 0.6.0. #39

Closed
kaby76 opened this issue Jan 17, 2025 · 5 comments
Closed

Cannot generate Dart target, version 0.6.0. #39

kaby76 opened this issue Jan 17, 2025 · 5 comments
Labels
possible bug Something isn't working

Comments

@kaby76
Copy link

kaby76 commented Jan 17, 2025

For any grammar in grammars-v4, e.g., abb. error(31): ANTLR cannot generate Dart code as of version 0.6.0

@mike-lischke mike-lischke added the possible bug Something isn't working label Jan 17, 2025
@kaby76
Copy link
Author

kaby76 commented Jan 17, 2025

This seems to fix some things.

$ git diff .
diff --git a/src/codegen/CodeGenerator.ts b/src/codegen/CodeGenerator.ts
index ef780ad..2fed999 100644
--- a/src/codegen/CodeGenerator.ts
+++ b/src/codegen/CodeGenerator.ts
@@ -24,6 +24,7 @@ import { Target } from "./Target.js";
 import type { IToolParameters } from "../tool-parameters.js";
 import { CppTarget } from "./target/CppTarget.js";
 import { CSharpTarget } from "./target/CSharpTarget.js";
+import { DartTarget } from "./target/DartTarget.js";
 import { GoTarget } from "./target/GoTarget.js";
 import { JavaScriptTarget } from "./target/JavaScriptTarget.js";
 import { JavaTarget } from "./target/JavaTarget.js";
@@ -33,7 +34,7 @@ import { SwiftTarget } from "./target/SwiftTarget.js";
 import { TypeScriptTarget } from "./target/TypeScriptTarget.js";

 export const targetLanguages = [
-    "Cpp", "CSharp", "Go", "JavaScript", "Java", "PHP", "Python3", "Swift", "TypeScript"
+    "Cpp", "CSharp", "Dart", "Go", "JavaScript", "Java", "PHP", "Python3", "Swift", "TypeScript"
 ] as const;

 export type SupportedLanguage = typeof targetLanguages[number];
@@ -57,6 +58,7 @@ export class CodeGenerator {
     static #languageMap = new Map<SupportedLanguage, new (generator: CodeGenerator) => Target>([
         ["Cpp", CppTarget],
         ["CSharp", CSharpTarget],
+        ["Dart", DartTarget],
         ["Go", GoTarget],
         ["JavaScript", JavaScriptTarget],
         ["Java", JavaTarget],
01/17-13:19:00 ~/antlr-ng/src
$

@mike-lischke
Copy link
Owner

Odd, how comes this wasn't there before? I'm also pretty sure I have once created Dart files.

Is this all what's needed to fix this issue?

@kaby76
Copy link
Author

kaby76 commented Jan 17, 2025

I thought I tested it, but maybe not. But, it's all being tested side-by-side with the old Antlr tool (with antlr/grammars-v4#4385). I think these changes fix the problem, but I haven't checked. Maybe you can make the changes, and I'll test it locally on my machine?

@mike-lischke
Copy link
Owner

OK, will do as soon as I can.

@mike-lischke
Copy link
Owner

That solved it @kaby76, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants