1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/**
* Copyright (c) 2004, 2008, 2014 INRIA.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* INRIA - initial API and implementation
* Dennis Wagelaar
*
* $Id: TCSInjector.java,v 1.1 2009/04/21 14:11:03 wpiers Exp $
*/
package org.eclipse.gmt.tcs.injector;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.m2m.atl.engine.injectors.Injector;
import org.eclipse.m2m.atl.engine.vm.nativelib.ASMModel;
import org.eclipse.m2m.atl.engine.vm.nativelib.ASMModelElement;
/**
* @author <a href="mailto:frederic.jouault@univ-nantes.fr">Frederic Jouault</a>
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
* @author <a href="mailto:dwagelaar@gmail.com">Dennis Wagelaar</a>
*/
public class TCSInjector implements Injector {
private static Map parameterTypes = new HashMap();
static {
parameterTypes.put("name", "String"); // required
parameterTypes.put("keepNL", "String"); // optional, default = false
parameterTypes.put("keepLocation", "String"); // optional, default = true
parameterTypes.put("keepComments", "String"); // optional, default = true
parameterTypes.put("tabSize", "String"); // optional, default = 8
parameterTypes.put("parserGenerator", "String");// optional, default = "antlr3"
parameterTypes.put("hyperlinks", "Map"); // optional, default = null
parameterTypes.put("trace", "Map"); // optional, default = null
parameterTypes.put("locationByElement", "Map"); // optional, default = null
parameterTypes.put("problems", "Model:Problem");// optional, default = null
// Useful when the lexer and/or parser cannot be resolved from here
parameterTypes.put("lexerClass", "Class"); // optional, default = null
parameterTypes.put("parserClass", "Class"); // optional, default = null
}
public Map getParameterTypes() {
return parameterTypes;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.m2m.atl.engine.injectors.Injector#inject(org.eclipse.m2m.atl.engine.vm.nativelib.ASMModel, java.io.InputStream, java.util.Map)
*/
public ASMModelElement inject(ASMModel target, InputStream source, Map params) throws IOException {
return inject(target, new InputStreamReader(source), params);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.m2m.atl.engine.injectors.Injector#inject(org.eclipse.m2m.atl.engine.vm.nativelib.ASMModel, java.io.Reader, java.util.Map)
*/
public ASMModelElement inject(ASMModel target, Reader source, Map params) throws IOException {
this.targetModelAdapter = new ASMModelAdapter(target);
ASMModel problems = (ASMModel)params.get("problems");
if (problems != null) {
this.problemsModelAdapter = new ASMModelAdapter(problems);
params.put("problems", this.problemsModelAdapter);
}
ASMModelElement root = (ASMModelElement)new ParserLauncher().parse(targetModelAdapter, source, params);
return root;
}
public String getPrefix() {
return "ebnf2";
}
protected ModelAdapter problemsModelAdapter;
protected ModelAdapter targetModelAdapter;
public void performImportation(ASMModel format, ASMModel extent, InputStream in, String other) throws IOException {
throw new UnsupportedOperationException("Was deprecated a long time ago. It is now unsupported");
}
}
|