Improve decoupling of generated parsers and scanners from frontend code.
Somewhat related to #43 (closed) .
I am trying to add CIF as frontend to JPlag, and I thought it would be a good idea to use the existing CIF grammar. Jplag is a stand-alone plain Java program, and parsing a CIF file is just tokenizing the input file, and firing callbacks for recognized production rules, so my first guess was this should be easy.
So I took the grammar, changed the result-types of the rules, and generated the scanner, parser and hooks file. Then I had a look at the import tree, and ended up with (see the bottom of the description).
Some is expected, eg setext.runtime
, and ESCET.common.java
, but it drags in a lot of FRAMEWORK
, EMF code for Position, right upto and including code from eclipse.swt
, eclipse.ui
, eclipse.core
.
This seems silly for an empty scanner and parser that is to be embedded in a plain Java program. Not sure what to do here, I started thinking about introducing an interface class to seperate higher level code from the core code, but not sure.
Ideas? Thoughts?
Should I just start hacking the generated code and make it incompatible with the generator?
[[Dot file with the recursive dependencies, unfold for details.]]
// ESCET = org.eclipse.escet // FRAMEWORK = org.eclipse.escet.app.framework digraph C { "ROOT" -> "de.jplag.cif.CifParserHooks"; "ROOT" -> "de.jplag.cif.CifParser"; "ROOT" -> "de.jplag.cif.CifScanner"; "de.jplag.cif.CifParserHooks" -> "ESCET.setext.runtime.Token"; "de.jplag.cif.CifParserHooks" -> "de.jplag.cif.StructToken.CifToken"; "de.jplag.cif.CifParserHooks" -> "ESCET.setext.runtime.Parser"; "de.jplag.cif.CifParserHooks" -> "ESCET.common.java.Assert"; "de.jplag.cif.CifParserHooks" -> "ESCET.common.java.Lists"; "de.jplag.cif.CifParser" -> "ESCET.setext.runtime.Token"; "de.jplag.cif.CifParser" -> "ESCET.common.java.Strings"; "de.jplag.cif.CifParser" -> "ESCET.setext.runtime.ParserHooksBase"; "de.jplag.cif.CifParser" -> "ESCET.setext.runtime.Parser"; "de.jplag.cif.CifScanner" -> "ESCET.setext.runtime.Scanner"; "de.jplag.cif.CifScanner" -> "ESCET.setext.runtime.Token"; "ESCET.setext.runtime.Token" -> "ESCET.common.java.Strings"; "ESCET.setext.runtime.Token" -> "ESCET.common.position.metamodel.position.Position"; "ESCET.setext.runtime.Scanner" -> "ESCET.common.java.Strings"; "ESCET.setext.runtime.Scanner" -> "ESCET.setext.runtime.exceptions.SyntaxException"; "ESCET.setext.runtime.Scanner" -> "ESCET.common.position.metamodel.position.Position"; "ESCET.setext.runtime.Scanner" -> "ESCET.setext.runtime.exceptions.ScanException"; "ESCET.setext.runtime.Scanner" -> "FRAMEWORK.output.OutputProvider"; "ESCET.setext.runtime.Scanner" -> "ESCET.common.position.metamodel.position.PositionFactory"; "ESCET.setext.runtime.Scanner" -> "ESCET.common.java.Lists"; "ESCET.setext.runtime.exceptions.ScanException" -> "ESCET.common.java.Strings"; "ESCET.setext.runtime.exceptions.ScanException" -> "ESCET.common.position.metamodel.position.Position"; "ESCET.common.position.metamodel.position.PositionFactory" -> "org.eclipse.emf.ecore.EFactory"; "ESCET.common.position.metamodel.position.Position" -> "org.eclipse.emf.ecore.EObject"; "FRAMEWORK.output.OutputProvider" -> "ESCET.common.java.Strings"; "FRAMEWORK.output.OutputProvider" -> "FRAMEWORK.Application"; "FRAMEWORK.output.OutputProvider" -> "FRAMEWORK.AppEnv"; "FRAMEWORK.output.OutputProvider" -> "ESCET.common.java.Assert"; "FRAMEWORK.output.OutputProvider" -> "ESCET.common.java.Lists"; "ESCET.common.java.Strings" -> "org.apache.commons.lang.StringEscapeUtils"; "ESCET.common.java.Strings" -> "ESCET.common.java.Lists"; "ESCET.common.java.Strings" -> "org.apache.commons.lang.StringUtils"; "ESCET.setext.runtime.exceptions.SyntaxException" -> "FRAMEWORK.exceptions.ApplicationException"; "ESCET.setext.runtime.exceptions.SyntaxException" -> "ESCET.common.position.metamodel.position.Position"; "ESCET.setext.runtime.exceptions.SyntaxException" -> "ESCET.common.java.Assert"; "ESCET.common.java.Assert" -> "ESCET.common.java.Strings"; "FRAMEWORK.AppEnv" -> "FRAMEWORK.output.StreamOutputComponent"; "FRAMEWORK.AppEnv" -> "FRAMEWORK.exceptions.DependencyException"; "FRAMEWORK.AppEnv" -> "FRAMEWORK.options.DevModeOption"; "FRAMEWORK.AppEnv" -> "FRAMEWORK.output.OutputModeOption"; "FRAMEWORK.AppEnv" -> "FRAMEWORK.output.OutputProvider"; "FRAMEWORK.AppEnv" -> "ESCET.common.java.Assert"; "FRAMEWORK.AppEnv" -> "FRAMEWORK.output.OutputMode"; "FRAMEWORK.AppEnv" -> "FRAMEWORK.options.Options"; "FRAMEWORK.AppEnv" -> "FRAMEWORK.output.IOutputComponent"; "FRAMEWORK.AppEnv" -> "FRAMEWORK.io.AppStreams"; "FRAMEWORK.Application" -> "FRAMEWORK.management.AppStatus"; "FRAMEWORK.Application" -> "FRAMEWORK.options.OptionDialogOption"; "FRAMEWORK.Application" -> "FRAMEWORK.options.GuiMode"; "FRAMEWORK.Application" -> "FRAMEWORK.options.OptionDialog"; "FRAMEWORK.Application" -> "FRAMEWORK.options.LicenseOption"; "FRAMEWORK.Application" -> "FRAMEWORK.output.IOutputComponent"; "FRAMEWORK.Application" -> "FRAMEWORK.io.AppStream"; "FRAMEWORK.Application" -> "FRAMEWORK.options.OptionValue"; "FRAMEWORK.Application" -> "FRAMEWORK.output.StreamOutputComponent"; "FRAMEWORK.Application" -> "org.eclipse.core.resources.IFile"; "FRAMEWORK.Application" -> "FRAMEWORK.options.DevModeOption"; "FRAMEWORK.Application" -> "FRAMEWORK.options.GuiOption"; "FRAMEWORK.Application" -> "org.eclipse.ui.PlatformUI"; "FRAMEWORK.Application" -> "FRAMEWORK.output.OutputModeOption"; "FRAMEWORK.Application" -> "org.eclipse.core.resources.ResourcesPlugin"; "FRAMEWORK.Application" -> "ESCET.common.java.Pair"; "FRAMEWORK.Application" -> "FRAMEWORK.management.AppManager"; "FRAMEWORK.Application" -> "org.osgi.framework.FrameworkUtil"; "FRAMEWORK.Application" -> "FRAMEWORK.options.OptionCategory"; "FRAMEWORK.Application" -> "org.eclipse.core.resources.IResource"; "FRAMEWORK.Application" -> "FRAMEWORK.exceptions.EndUserException"; "FRAMEWORK.Application" -> "FRAMEWORK.output.OutputProvider"; "FRAMEWORK.Application" -> "FRAMEWORK.options.Options"; "FRAMEWORK.Application" -> "ESCET.common.java.Lists"; "FRAMEWORK.Application" -> "FRAMEWORK.io.AppStreams"; "FRAMEWORK.Application" -> "ESCET.common.java.Strings"; "FRAMEWORK.Application" -> "org.eclipse.core.runtime.Platform"; "FRAMEWORK.Application" -> "org.eclipse.core.runtime.CoreException"; "FRAMEWORK.Application" -> "FRAMEWORK.options.HelpOption"; "FRAMEWORK.Application" -> "FRAMEWORK.options.Option"; "FRAMEWORK.Application" -> "FRAMEWORK.exceptions.ApplicationException"; "FRAMEWORK.Application" -> "org.osgi.framework.Bundle"; "FRAMEWORK.io.AppStream" -> "org.apache.commons.lang.ArrayUtils"; "FRAMEWORK.io.AppStream" -> "ESCET.common.java.Strings"; "FRAMEWORK.io.AppStream" -> "FRAMEWORK.exceptions.InputOutputException"; "FRAMEWORK.options.OptionDialog" -> "FRAMEWORK.AppEnvData"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.Composite"; "FRAMEWORK.options.OptionDialog" -> "FRAMEWORK.AppEnv"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.events.SelectionEvent"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.events.SelectionAdapter"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.jface.resource.JFaceResources"; "FRAMEWORK.options.OptionDialog" -> "FRAMEWORK.SWTUtils"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.Display"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.layout.FormLayout"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.Event"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.layout.FormAttachment"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.Listener"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.Shell"; "FRAMEWORK.options.OptionDialog" -> "FRAMEWORK.io.MemAppStream"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.TreeItem"; "FRAMEWORK.options.OptionDialog" -> "ESCET.common.java.Maps"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.custom.SashForm"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.graphics.Rectangle"; "FRAMEWORK.options.OptionDialog" -> "ESCET.common.java.Sets"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.custom.ScrolledComposite"; "FRAMEWORK.options.OptionDialog" -> "ESCET.common.java.Lists"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.Text"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.layout.FormData"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.Tree"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.Control"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.SWT"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.Label"; "FRAMEWORK.options.OptionDialog" -> "ESCET.common.java.Assert"; "FRAMEWORK.options.OptionDialog" -> "FRAMEWORK.exceptions.ApplicationException"; "FRAMEWORK.options.OptionDialog" -> "org.eclipse.swt.widgets.Button"; "FRAMEWORK.output.StreamOutputComponent" -> "ESCET.common.java.Strings"; "FRAMEWORK.output.StreamOutputComponent" -> "FRAMEWORK.io.StdAppStream"; "FRAMEWORK.output.StreamOutputComponent" -> "FRAMEWORK.io.AppStream"; "FRAMEWORK.management.AppManager" -> "FRAMEWORK.Application"; "FRAMEWORK.management.AppManager" -> "ESCET.common.java.Lists"; "FRAMEWORK.management.AppManager" -> "ESCET.common.java.Maps"; "FRAMEWORK.options.OptionCategory" -> "ESCET.common.java.Strings"; "FRAMEWORK.options.OptionCategory" -> "FRAMEWORK.AppEnv"; "FRAMEWORK.options.OptionCategory" -> "org.apache.commons.lang.StringUtils"; "FRAMEWORK.options.OptionCategory" -> "ESCET.common.java.Sets"; "FRAMEWORK.options.OptionCategory" -> "ESCET.common.java.Assert"; "FRAMEWORK.options.OptionCategory" -> "ESCET.common.java.Lists"; "FRAMEWORK.options.Options" -> "ESCET.common.java.Strings"; "FRAMEWORK.options.Options" -> "FRAMEWORK.exceptions.InvalidOptionException"; "FRAMEWORK.options.Options" -> "FRAMEWORK.Application"; "FRAMEWORK.options.Options" -> "FRAMEWORK.AppEnv"; "FRAMEWORK.options.Options" -> "ESCET.common.java.Maps"; "FRAMEWORK.options.Options" -> "ESCET.common.java.Assert"; "FRAMEWORK.options.Options" -> "FRAMEWORK.exceptions.ApplicationException"; "FRAMEWORK.options.HelpOption" -> "ESCET.common.java.Strings"; "FRAMEWORK.options.HelpOption" -> "FRAMEWORK.Application"; "FRAMEWORK.options.HelpOption" -> "FRAMEWORK.AppEnv"; "FRAMEWORK.options.HelpOption" -> "ESCET.common.java.Assert"; "FRAMEWORK.options.HelpOption" -> "ESCET.common.java.Lists"; "FRAMEWORK.options.HelpOption" -> "org.apache.commons.io.IOUtils"; "FRAMEWORK.options.HelpOption" -> "FRAMEWORK.io.AppStream"; "FRAMEWORK.options.Option" -> "FRAMEWORK.exceptions.InvalidOptionException"; "FRAMEWORK.options.Option" -> "ESCET.common.java.Strings"; "FRAMEWORK.options.Option" -> "ESCET.common.java.Assert"; "FRAMEWORK.options.Option" -> "FRAMEWORK.exceptions.ApplicationException"; "FRAMEWORK.options.Option" -> "org.eclipse.swt.widgets.Composite"; "FRAMEWORK.management.AppStatus" -> "FRAMEWORK.Application"; "FRAMEWORK.management.AppStatus" -> "FRAMEWORK.AppEnvData"; "FRAMEWORK.options.OptionDialogOption" -> "org.eclipse.swt.widgets.Composite"; "FRAMEWORK.options.LicenseOption" -> "FRAMEWORK.Application"; "FRAMEWORK.options.LicenseOption" -> "FRAMEWORK.AppEnv"; "FRAMEWORK.output.OutputModeOption" -> "FRAMEWORK.options.Options"; "FRAMEWORK.output.OutputModeOption" -> "FRAMEWORK.options.EnumOption"; "ESCET.common.java.Pair" -> "ESCET.common.java.Strings"; "FRAMEWORK.options.EnumOption" -> "FRAMEWORK.exceptions.InvalidOptionException"; "FRAMEWORK.options.EnumOption" -> "org.apache.commons.lang.ArrayUtils"; "FRAMEWORK.options.EnumOption" -> "org.eclipse.swt.widgets.Composite"; "FRAMEWORK.options.EnumOption" -> "org.eclipse.swt.SWT"; "FRAMEWORK.options.EnumOption" -> "org.eclipse.swt.widgets.Button"; "FRAMEWORK.options.EnumOption" -> "ESCET.common.java.Sets"; "FRAMEWORK.options.EnumOption" -> "ESCET.common.java.Assert"; "FRAMEWORK.options.EnumOption" -> "org.eclipse.swt.widgets.Group"; "ESCET.common.java.Sets" -> "ESCET.common.java.Strings"; "ESCET.common.java.Sets" -> "org.apache.commons.lang.StringUtils"; "ESCET.common.java.Sets" -> "ESCET.common.java.Lists"; "FRAMEWORK.exceptions.InvalidOptionException" -> "ESCET.common.java.Assert"; "FRAMEWORK.AppEnvData" -> "ESCET.common.java.Strings"; "FRAMEWORK.AppEnvData" -> "FRAMEWORK.management.AppStatus"; "FRAMEWORK.AppEnvData" -> "FRAMEWORK.exceptions.DependencyException"; "FRAMEWORK.AppEnvData" -> "FRAMEWORK.console.Console"; "FRAMEWORK.AppEnvData" -> "FRAMEWORK.options.GuiMode"; "FRAMEWORK.AppEnvData" -> "FRAMEWORK.output.OutputProvider"; "FRAMEWORK.AppEnvData" -> "FRAMEWORK.options.Options"; "FRAMEWORK.AppEnvData" -> "FRAMEWORK.output.IOutputComponent"; "FRAMEWORK.AppEnvData" -> "FRAMEWORK.management.AppManager"; "FRAMEWORK.AppEnvData" -> "FRAMEWORK.io.AppStreams"; "FRAMEWORK.console.Console" -> "org.eclipse.swt.graphics.Color"; "FRAMEWORK.console.Console" -> "FRAMEWORK.Application"; "FRAMEWORK.console.Console" -> "FRAMEWORK.io.EclipseConsoleAppStream"; "FRAMEWORK.console.Console" -> "org.eclipse.ui.console.IOConsoleInputStream"; "FRAMEWORK.console.Console" -> "org.eclipse.ui.console.ConsolePlugin"; "FRAMEWORK.console.Console" -> "org.eclipse.ui.console.IConsoleManager"; "FRAMEWORK.console.Console" -> "org.eclipse.ui.console.IOConsole"; "FRAMEWORK.console.Console" -> "org.eclipse.ui.console.IOConsoleOutputStream"; "FRAMEWORK.console.Console" -> "org.eclipse.swt.widgets.Display"; "FRAMEWORK.console.Console" -> "org.eclipse.ui.console.IConsole"; "FRAMEWORK.console.Console" -> "FRAMEWORK.io.AppStream"; "FRAMEWORK.console.Console" -> "FRAMEWORK.io.AppStreams"; "FRAMEWORK.io.EclipseConsoleAppStream" -> "ESCET.common.java.Strings"; "FRAMEWORK.io.EclipseConsoleAppStream" -> "FRAMEWORK.exceptions.InputOutputException"; "FRAMEWORK.io.EclipseConsoleAppStream" -> "org.eclipse.ui.console.IOConsoleOutputStream"; "FRAMEWORK.io.StdAppStream" -> "ESCET.common.java.Strings"; "FRAMEWORK.io.StdAppStream" -> "FRAMEWORK.exceptions.InputOutputException"; "FRAMEWORK.SWTUtils" -> "org.eclipse.swt.graphics.Rectangle"; "FRAMEWORK.SWTUtils" -> "org.eclipse.swt.widgets.Shell"; "FRAMEWORK.SWTUtils" -> "org.eclipse.swt.widgets.Display"; "FRAMEWORK.SWTUtils" -> "org.eclipse.swt.SWT"; "FRAMEWORK.SWTUtils" -> "org.eclipse.swt.widgets.Monitor"; "ESCET.setext.runtime.Parser" -> "FRAMEWORK.Paths"; "ESCET.setext.runtime.Parser" -> "ESCET.common.java.Strings"; "ESCET.setext.runtime.Parser" -> "org.apache.commons.lang.StringUtils"; "ESCET.setext.runtime.Parser" -> "ESCET.setext.runtime.exceptions.SyntaxException"; "ESCET.setext.runtime.Parser" -> "FRAMEWORK.exceptions.InputOutputException"; "ESCET.setext.runtime.Parser" -> "ESCET.common.position.metamodel.position.Position"; "ESCET.setext.runtime.Parser" -> "FRAMEWORK.exceptions.InvalidInputException"; "ESCET.setext.runtime.Parser" -> "ESCET.common.java.Pair"; "ESCET.setext.runtime.Parser" -> "FRAMEWORK.output.OutputProvider"; "ESCET.setext.runtime.Parser" -> "ESCET.common.java.Assert"; "ESCET.setext.runtime.Parser" -> "ESCET.common.java.Sets"; "ESCET.setext.runtime.Parser" -> "ESCET.common.java.Lists"; "ESCET.setext.runtime.Parser" -> "ESCET.setext.runtime.exceptions.ParseException"; "FRAMEWORK.Paths" -> "ESCET.common.java.Strings"; "FRAMEWORK.Paths" -> "org.eclipse.emf.ecore.resource.impl.URIHandlerImpl"; "FRAMEWORK.Paths" -> "org.eclipse.emf.ecore.resource.URIHandler"; "FRAMEWORK.Paths" -> "FRAMEWORK.exceptions.InvalidInputException"; "FRAMEWORK.Paths" -> "org.eclipse.emf.common.util.URI"; "FRAMEWORK.Paths" -> "ESCET.common.java.Assert"; "FRAMEWORK.Paths" -> "ESCET.common.java.Lists"; "FRAMEWORK.Paths" -> "org.apache.commons.lang.SystemUtils"; "FRAMEWORK.Paths" -> "org.apache.commons.lang.StringUtils"; "ESCET.setext.runtime.exceptions.ParseException" -> "ESCET.common.java.Strings"; "ESCET.setext.runtime.exceptions.ParseException" -> "ESCET.common.position.metamodel.position.Position"; "ESCET.setext.runtime.exceptions.ParseException" -> "ESCET.common.java.Assert"; }