[Nice-commit] Nice/src/bossa/modules Parser.java,NONE,1.1 Package.java,1.116,1.117 Content.java,1.14
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2004-06-30 14:12:47
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421/src/bossa/modules Modified Files: Package.java Content.java Compilation.nice Compilation.java Added Files: Parser.java Log Message: Defined a parser interface, and made the core independent of the implementation of the parser. This makes bootstrap and future modifications simpler. --- NEW FILE: Parser.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.modules; import java.io.*; import java.util.*; import bossa.syntax.LocatedString; /** The interface of a parser for the Nice language @author Daniel Bonniot (bo...@us...) */ public interface Parser { LocatedString readImports(Reader r, List imports, Collection opens); void read(Reader r, List definitions); bossa.syntax.FormalParameters formalParameters(String parameters); } Index: Compilation.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Compilation.nice,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Compilation.nice 18 Jan 2004 01:14:31 -0000 1.27 --- Compilation.nice 30 Jun 2004 14:12:38 -0000 1.28 *************** *** 46,51 **** boolean strictJavaTypes = false; - boolean storeDocStrings = false; - /** Location of the nice.jar file. */ ?String runtimeFile = null; --- 46,49 ---- *************** *** 55,58 **** --- 53,58 ---- CompilationListener listener; + Parser parser; + Map<String,Package> packages = new HashMap(); Map<String,mlsub.typing.TypeConstructor> javaTypeConstructors = new HashMap(); *************** *** 148,153 **** } ! Compilation createCompilation(CompilationListener listener) = ! new Compilation(listener: listener); class Exit extends RuntimeException {} --- 148,153 ---- } ! Compilation createCompilation(CompilationListener listener, Parser parser) = ! new Compilation(listener: listener, parser: parser); class Exit extends RuntimeException {} Index: Package.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Package.java,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** Package.java 11 Jun 2004 15:58:58 -0000 1.116 --- Package.java 30 Jun 2004 14:12:37 -0000 1.117 *************** *** 116,120 **** definitions = new ArrayList(); ! source.getDefinitions(definitions, shouldReload, compilation.storeDocStrings); this.ast = new AST(this, definitions); definitions = null; --- 116,120 ---- definitions = new ArrayList(); ! source.getDefinitions(definitions, shouldReload); this.ast = new AST(this, definitions); definitions = null; Index: Compilation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Compilation.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Compilation.java 18 Jan 2004 01:14:30 -0000 1.8 --- Compilation.java 30 Jun 2004 14:12:38 -0000 1.9 *************** *** 31,35 **** public boolean excludeRuntime; public boolean strictJavaTypes; ! public boolean storeDocStrings; public Locator locator; --- 31,35 ---- public boolean excludeRuntime; public boolean strictJavaTypes; ! public Parser parser; public Locator locator; Index: Content.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Content.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Content.java 18 Jan 2004 01:14:31 -0000 1.14 --- Content.java 30 Jun 2004 14:12:37 -0000 1.15 *************** *** 74,78 **** } ! void getDefinitions(List definitions, boolean shouldReload, boolean storeDocStrings) { Content.Unit[] readers = getReaders(shouldReload); --- 74,78 ---- } ! void getDefinitions(List definitions, boolean shouldReload) { Content.Unit[] readers = getReaders(shouldReload); *************** *** 80,84 **** for(int i = 0; i<readers.length; i++) try{ ! read(readers[i], definitions, storeDocStrings); } catch(UserError ex){ --- 80,84 ---- for(int i = 0; i<readers.length; i++) try{ ! read(readers[i], definitions); } catch(UserError ex){ *************** *** 93,98 **** bossa.util.Location.setCurrentFile(unit.file); ! bossa.syntax.LocatedString pkgName = ! bossa.parser.Loader.readImports(unit.reader, imports, opens); if (pkgName != null && ! pkgName.equals(pkg.name)) User.error(pkgName, --- 93,99 ---- bossa.util.Location.setCurrentFile(unit.file); ! bossa.syntax.LocatedString pkgName = ! pkg.compilation.parser.readImports(unit.reader, imports, opens); ! if (pkgName != null && ! pkgName.equals(pkg.name)) User.error(pkgName, *************** *** 100,110 **** ", but it was found in package " + pkg.name); } ! ! private void read(Content.Unit unit, List definitions, boolean storeDocStrings) { bossa.util.Location.setCurrentFile(unit.file); ! bossa.parser.Loader.open(unit.reader, definitions, storeDocStrings); } ! /** @param shouldReload reload if the source if available. --- 101,111 ---- ", but it was found in package " + pkg.name); } ! ! private void read(Content.Unit unit, List definitions) { bossa.util.Location.setCurrentFile(unit.file); ! pkg.compilation.parser.read(unit.reader, definitions); } ! /** @param shouldReload reload if the source if available. |