src/share/classes/com/sun/tools/javac/parser/ParserFactory.java

Mon, 15 Dec 2008 16:55:33 -0800

author
xdono
date
Mon, 15 Dec 2008 16:55:33 -0800
changeset 174
fdfed22db054
parent 113
eff38cc97183
child 333
7c2d6da61646
permissions
-rw-r--r--

6785258: Update copyright year
Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008
Reviewed-by: katleman, ohair, tbell

jjg@111 1 /*
jjg@111 2 * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
jjg@111 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@111 4 *
jjg@111 5 * This code is free software; you can redistribute it and/or modify it
jjg@111 6 * under the terms of the GNU General Public License version 2 only, as
jjg@111 7 * published by the Free Software Foundation. Sun designates this
jjg@111 8 * particular file as subject to the "Classpath" exception as provided
jjg@111 9 * by Sun in the LICENSE file that accompanied this code.
jjg@111 10 *
jjg@111 11 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@111 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@111 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@111 14 * version 2 for more details (a copy is included in the LICENSE file that
jjg@111 15 * accompanied this code).
jjg@111 16 *
jjg@111 17 * You should have received a copy of the GNU General Public License version
jjg@111 18 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@111 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@111 20 *
jjg@111 21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
jjg@111 22 * CA 95054 USA or visit www.sun.com if you need additional information or
jjg@111 23 * have any questions.
jjg@111 24 */
jjg@111 25
jjg@111 26 package com.sun.tools.javac.parser;
jjg@111 27
jjg@111 28 import com.sun.tools.javac.code.Source;
jjg@111 29 import com.sun.tools.javac.tree.TreeMaker;
jjg@111 30 import com.sun.tools.javac.util.Context;
jjg@111 31 import com.sun.tools.javac.util.Log;
jjg@113 32 import com.sun.tools.javac.util.Names;
jjg@111 33 import com.sun.tools.javac.util.Options;
jjg@111 34
jjg@111 35 /**
jjg@111 36 * A factory for creating parsers.
jjg@111 37 */
jjg@111 38 public class ParserFactory {
jjg@111 39
jjg@111 40 /** The context key for the parser factory. */
jjg@111 41 protected static final Context.Key<ParserFactory> parserFactoryKey = new Context.Key<ParserFactory>();
jjg@111 42
jjg@111 43 public static ParserFactory instance(Context context) {
jjg@111 44 ParserFactory instance = context.get(parserFactoryKey);
jjg@111 45 if (instance == null) {
jjg@111 46 instance = new ParserFactory(context);
jjg@111 47 }
jjg@111 48 return instance;
jjg@111 49 }
jjg@111 50
jjg@111 51 final TreeMaker F;
jjg@111 52 final Log log;
jjg@111 53 final Keywords keywords;
jjg@111 54 final Source source;
jjg@113 55 final Names names;
jjg@111 56 final Options options;
jjg@111 57 final Scanner.Factory scannerFactory;
jjg@111 58
jjg@111 59 protected ParserFactory(Context context) {
jjg@111 60 super();
jjg@111 61 context.put(parserFactoryKey, this);
jjg@111 62 this.F = TreeMaker.instance(context);
jjg@111 63 this.log = Log.instance(context);
jjg@113 64 this.names = Names.instance(context);
jjg@111 65 this.keywords = Keywords.instance(context);
jjg@111 66 this.source = Source.instance(context);
jjg@111 67 this.options = Options.instance(context);
jjg@111 68 this.scannerFactory = Scanner.Factory.instance(context);
jjg@111 69 }
jjg@111 70
jjg@111 71 public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) {
jjg@111 72 Lexer lexer = scannerFactory.newScanner(input);
jjg@111 73 if (keepEndPos) {
jjg@111 74 return new EndPosParser(this, lexer, keepDocComments, keepLineMap);
jjg@111 75 } else {
jjg@111 76 return new JavacParser(this, lexer, keepDocComments, keepLineMap);
jjg@111 77 }
jjg@111 78 }
jjg@111 79 }

mercurial