mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 01:41:17 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a24638a91 |
No files matched your search
@@ -1,21 +1,3 @@
|
||||
2001-07-15 Joe Shaw <[email protected]>
|
||||
|
||||
* configure.in: Don't create doc/Makefile as there's nothing there
|
||||
to make.
|
||||
|
||||
* Makefile.am: Don't build the doc directory because there's no
|
||||
Makefile.am there.
|
||||
|
||||
* autogen.sh: Call aclocal with the $ACLOCAL_FLAGS env var.
|
||||
|
||||
2001-07-15 Miguel de Icaza <[email protected]>
|
||||
|
||||
* doc/class-library (A): Updated FAQ with question on error 1595.
|
||||
|
||||
2001-07-14 Miguel de Icaza <[email protected]>
|
||||
|
||||
* doc/index:
|
||||
|
||||
Wed Jul 11 00:36:36 CEST 2001 Paolo Molaro <[email protected]>
|
||||
|
||||
* status/*: scripts and data to create statistics about the
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
libtoolize --automake
|
||||
automake -a
|
||||
autoheader
|
||||
aclocal $ACLOCAL_FLAGS
|
||||
aclocal
|
||||
autoconf
|
||||
./configure $*
|
||||
./configure $*
|
||||
+1
-1
@@ -33,5 +33,5 @@ mono/metadata/Makefile
|
||||
mono/dis/Makefile
|
||||
mono/cil/Makefile
|
||||
mono/interpreter/Makefile
|
||||
mono/doc/Makefile
|
||||
doc/Makefile
|
||||
])
|
||||
@@ -1,3 +0,0 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
all-docs
|
||||
@@ -1,16 +0,0 @@
|
||||
WEB_FILES=
|
||||
c-sharp class-library contact contributing documentation download \
|
||||
faq gcc-frontend ideas index makefile passport rationale resources \
|
||||
roadmap runtime status team testing thanks tools
|
||||
|
||||
OTHERS= pending resources-pending todo
|
||||
|
||||
EXTRA_DIST = $(WEB_FILES) README $(OTHERS)
|
||||
|
||||
all-docs: $(WEB_FILES)
|
||||
cat rationale roadmap c-sharp tools class-library \
|
||||
runtime documentation download faq contributing \
|
||||
resources status > all-docs
|
||||
|
||||
webit:
|
||||
(cd web; make && make push)
|
||||
+7
-32
@@ -3,30 +3,10 @@
|
||||
The Class Library should be compatible with Microsoft's .NET
|
||||
implementation.
|
||||
|
||||
Please see the <a href="class-status.html">Class Status</a>
|
||||
page for a status of who is working on which classes.
|
||||
|
||||
We will write as much code as possible in C#. We may need to
|
||||
interface with code written in C to gain access to the
|
||||
functionality of libraries like libart, Gtk+, and libc.
|
||||
|
||||
** Contributing
|
||||
|
||||
We welcome contributions to the the Class Library. To get
|
||||
started, check the status page for information about which
|
||||
APIs are being worked on, and how to get in touch with
|
||||
individual maintainers.
|
||||
|
||||
If you want to work on a class, first check the <a
|
||||
href="download.html">Classes Distribution</a> to see if it is
|
||||
not implemented yet, if not, check the <a
|
||||
href="class-status.html">Class Status</a> to see if someone is
|
||||
already working on it, and maybe contact them.
|
||||
|
||||
If nobody is working on it, mail <a
|
||||
href="mailto:[email protected]">[email protected]</a>
|
||||
with the class you want to implement and CC <a
|
||||
href="mailto:[email protected]">[email protected]</a>
|
||||
functionality of
|
||||
libraries like libart, Gtk+, and libc.
|
||||
|
||||
** Layout
|
||||
|
||||
@@ -160,15 +140,10 @@
|
||||
|
||||
In those cases, use the keyword "LAMESPEC".
|
||||
|
||||
** FAQ
|
||||
** Contributing
|
||||
|
||||
Frequently asked questions about the class library:
|
||||
We welcome contributions to the the Class Library. To get
|
||||
started, check the status page for information about which
|
||||
APIs are being worked on, and how to get in touch with
|
||||
individual maintainers.
|
||||
|
||||
Q: I am writing a new class that overrides one of the system classes,
|
||||
and I am getting a 1595 warning from the compiler. Should we use a
|
||||
different namespace?
|
||||
|
||||
A: There is a quick solution to the problem, you can pass the command
|
||||
line argument /nowarn:1595 and this will effectively let you use
|
||||
your implementation of the code, while overriding the ones from the
|
||||
system assemblies.
|
||||
@@ -1,27 +0,0 @@
|
||||
* Status of the various pieces of the class library
|
||||
|
||||
You can browse the status of the class library and see who has
|
||||
registered to work on what parts of the system. These list
|
||||
work-in-progress components currently.
|
||||
|
||||
<ul>
|
||||
* Per <a href="class-status/per-assembly.html">Assembly</a>
|
||||
|
||||
* Per <a href="class-status/per-completion.html">Completion</a>
|
||||
|
||||
* Per <a href="class-status/per-maintainer.html">Maintainer</a>
|
||||
|
||||
* Per <a href="class-status/per-unimplemented.html">Unimplemented</a>
|
||||
</ul>
|
||||
|
||||
A better mechanism will soon be in place, I just did this
|
||||
really quickly, as we already got one duplicated implementation.
|
||||
|
||||
You can also download the XML <a
|
||||
href="class-status/maintainers.xml">maintainers</a> file that
|
||||
contains the actual maintainers list.
|
||||
|
||||
I am sure we can generate better reports, if you are
|
||||
interested in contributing, let <a
|
||||
href="mailto:[email protected]">me</a> know.
|
||||
|
||||
+1
-3
@@ -19,15 +19,13 @@
|
||||
we make the first tarball release.
|
||||
|
||||
<ul>
|
||||
<a name="july-14">
|
||||
<b>July 14th, 2001</b>
|
||||
<b>July 12th, 2001</b>
|
||||
<ul>
|
||||
* <a href="archive/jay.cs.tar.gz">archive/jay.cs.tar.gz</a>: Sources to Jay.
|
||||
* <a href="archive/mcs-12-Jul-2001.tar.gz">mcs-12-Jul-2001.tar.gz</a>: CVS snapshot.
|
||||
* <a href="archive/mono-0.3.tar.gz">mono-0.3.tar.gz</a>: Packaged Source Code.
|
||||
</ul>
|
||||
|
||||
<a name="july-8">
|
||||
<b>July 8th, 2001</b>
|
||||
|
||||
<ul>
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
** Jul 14, 2001
|
||||
|
||||
A <a
|
||||
href="http://mail.ximian.com/archives/public/mono-list/2001-July/000399.html">new
|
||||
release</a> of the
|
||||
runtime, compiler and classes has been made. Get it <a href="download.html#july-14">here</a>
|
||||
|
||||
** Jul 12, 2001
|
||||
|
||||
I keep getting questions about my opinion on Passport, even when
|
||||
|
||||
+4
-1
@@ -132,7 +132,10 @@
|
||||
For instant messaging (another pieces of the Hailstorm bit),
|
||||
you want to use a non-centralized system like Sun's <a
|
||||
href="http://www.jxta.org">JXTA</a>. Some people mailed me to
|
||||
mention Jabber as a messaging platform.
|
||||
mention Jabber as a messaging platform. Jabber suffers from
|
||||
the same problems that a centralized Passport has. If you
|
||||
want to do things right, you want to start with a fully
|
||||
distributed system.
|
||||
|
||||
It could also just use the user e-mail address as the `key' to
|
||||
choose the registrar (msn.com, hotmail.com -> passport.com;
|
||||
|
||||
+21
-36
@@ -19,8 +19,7 @@
|
||||
external assemblies to our own version of the assemblies on
|
||||
GNU/Linux.
|
||||
|
||||
Our roadmap looks like this, this has been updated as of
|
||||
<b>Jul 15, 2001</b>:
|
||||
Our roadmap looks like this:
|
||||
|
||||
<ul>
|
||||
|
||||
@@ -32,15 +31,14 @@
|
||||
run CIL byte code on a system where no JIT is
|
||||
available.
|
||||
|
||||
* Milestone 3: Define an <i>lburg</i> instruction
|
||||
selector for the JITer for Intel. Although slower
|
||||
at JITing than a streaming JITer, it generates
|
||||
better code. The same grammar can later be used for
|
||||
the stream jitter.
|
||||
* Milestone 3: IA32 translating-JIT engine.
|
||||
|
||||
* Milestone 4: Implement JITer.
|
||||
* Milestone 4: non-Intel port of the JIT engine.
|
||||
|
||||
* Milestone 5: Port of the JITer to non IA32 systems.
|
||||
* Milestone 5: Optimizing JIT engine port for IA32.
|
||||
|
||||
* Milestone 6: non-Intel port of the Optimizing JIT
|
||||
engine.
|
||||
</ul>
|
||||
|
||||
A setup similar to the Kaffe JIT engine can be used to
|
||||
@@ -48,38 +46,25 @@
|
||||
will be focused on getting a IA32 version running first.
|
||||
|
||||
The JIT engine should work on Linux and Win32, although you
|
||||
will need to install the CygWin32 development tools to get a
|
||||
might need to install the CygWin32 development tools to get a
|
||||
Unix-like compilation environment.
|
||||
|
||||
** JIT Engine (<b>updated, Jul 14th, 2001</b>)
|
||||
** JIT Engine
|
||||
|
||||
We will be using a code-generator generator approach for our
|
||||
JITer. Given the properties of CIL byte codes, we can take
|
||||
full advantage of a real instruction selector for our code
|
||||
generator.
|
||||
Currently we are evaluating various mechanisms for our JIT
|
||||
engine (<a
|
||||
href="http://www.intel.com/research/mrl/orp/">ORP</a>, <a
|
||||
href="http://www.gnu.org/software/lightning/">GNU
|
||||
Lightning</a>, and <a
|
||||
href="http://www.eecs.harvard.edu/~nr/toolkit/">NJ Machine
|
||||
Toolkit</a>.).
|
||||
|
||||
There are a couple of books that deal with this technique: "A
|
||||
We have not made a decision yet, but we might want to use a
|
||||
Code Generator Generator for the Common Intermediate Language,
|
||||
as that is likely going to allow us to create better code
|
||||
(There are a couple of books that deal with this technique: "A
|
||||
Retargetable C Compiler" and "Advanced Compiler Design and
|
||||
Implementation" are good references. You can also get a
|
||||
technical description of <a
|
||||
href="http://research.microsoft.com/copyright/accept.asp?path=http://www.research.microsoft.com/~drh/pubs/iburg.pdf&pub=ACM">lbrug</a>
|
||||
|
||||
Previously we had looked at a number of JIT engines and tools,
|
||||
but they would not take full advantage of the CIL properties:
|
||||
|
||||
<ul>
|
||||
* <a
|
||||
href="http://www.intel.com/research/mrl/orp/">ORP</a>
|
||||
|
||||
* <a
|
||||
href="http://www.gnu.org/software/lightning/">GNU
|
||||
Lightning</a>
|
||||
|
||||
* href="http://www.eecs.harvard.edu/~nr/toolkit/">NJ Machine
|
||||
Toolkit</a>.).
|
||||
|
||||
* VCODE.
|
||||
</ul>
|
||||
Implementation").
|
||||
|
||||
** Garbage Collection
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
* Project Status
|
||||
|
||||
|
||||
|
||||
Pieces of Mono that have been implemented:
|
||||
|
||||
<ul>
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
0,Mono,rationale.html,rationale.src
|
||||
1,Runtime,runtime.html,runtime.src
|
||||
1,Classes,class-library.html,class-library.src
|
||||
2,Class Status,class-status.html,class-status.src
|
||||
1,C# Compiler,c-sharp.html,c-sharp.src
|
||||
1,Status,status.html,status.src
|
||||
0,Contributing,contributing.html,contributing.src
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
SOURCES= \
|
||||
../contributing \
|
||||
../class-library \
|
||||
../class-status \
|
||||
../contact \
|
||||
../c-sharp \
|
||||
../documentation \
|
||||
|
||||
+1
-9
@@ -1,9 +1 @@
|
||||
C# Compiler:
|
||||
Miguel de Icaza ([email protected])
|
||||
|
||||
Class Libraries:
|
||||
Jeff Stedfast ([email protected])
|
||||
Joe Shaw ([email protected])
|
||||
Miguel de Icaza ([email protected])
|
||||
Sean MacIsaac ([email protected])
|
||||
Vladimir Vukicevic ([email protected])
|
||||
Miguel de Icaza ([email protected])
|
||||
@@ -1,40 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// Driver.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
public class Driver
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
XmlReader xmlReader = null;
|
||||
|
||||
if (args.Length < 1)
|
||||
{
|
||||
xmlReader = new XmlTextReader(Console.In);
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlReader = new XmlTextReader(args[0]);
|
||||
}
|
||||
|
||||
while (xmlReader.Read())
|
||||
{
|
||||
Console.WriteLine("NodeType = {0}", xmlReader.NodeType);
|
||||
Console.WriteLine(" Name = {0}", xmlReader.Name);
|
||||
Console.WriteLine(" IsEmptyElement = {0}", xmlReader.IsEmptyElement);
|
||||
Console.WriteLine(" HasAttributes = {0}", xmlReader.HasAttributes);
|
||||
Console.WriteLine(" AttributeCount = {0}", xmlReader.AttributeCount);
|
||||
Console.WriteLine(" HasValue = {0}", xmlReader.HasValue);
|
||||
Console.WriteLine(" Value = {0}", xmlReader.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Xml.ReadState.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
namespace System.Xml
|
||||
{
|
||||
public enum ReadState
|
||||
{
|
||||
Closed,
|
||||
EndOfFile,
|
||||
Error,
|
||||
Initial,
|
||||
Interactive
|
||||
}
|
||||
}
|
||||
@@ -1,817 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Xml.Test.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace System.Xml
|
||||
{
|
||||
public class Test : TestCase
|
||||
{
|
||||
public Test(string name) : base(name) { }
|
||||
|
||||
private void AssertStartDocument(XmlReader xmlReader)
|
||||
{
|
||||
Assert(xmlReader.ReadState == ReadState.Initial);
|
||||
Assert(xmlReader.NodeType == XmlNodeType.None);
|
||||
Assert(!xmlReader.EOF);
|
||||
}
|
||||
|
||||
private void AssertNode(
|
||||
XmlReader xmlReader,
|
||||
XmlNodeType nodeType,
|
||||
bool isEmptyElement,
|
||||
string name,
|
||||
string value,
|
||||
int attributeCount)
|
||||
{
|
||||
Assert(xmlReader.Read());
|
||||
Assert(xmlReader.ReadState == ReadState.Interactive);
|
||||
Assert(!xmlReader.EOF);
|
||||
|
||||
Assert(xmlReader.NodeType == nodeType);
|
||||
Assert(xmlReader.IsEmptyElement == isEmptyElement);
|
||||
Assert(xmlReader.Name == name);
|
||||
Assert(xmlReader.HasValue == (value != String.Empty));
|
||||
Assert(xmlReader.Value == value);
|
||||
Assert(xmlReader.HasAttributes == (attributeCount > 0));
|
||||
Assert(xmlReader.AttributeCount == attributeCount);
|
||||
}
|
||||
|
||||
private void AssertAttribute(
|
||||
XmlReader xmlReader,
|
||||
string name,
|
||||
string value)
|
||||
{
|
||||
Assert(xmlReader[name] == value);
|
||||
Assert(xmlReader.GetAttribute(name) == value);
|
||||
}
|
||||
|
||||
private void AssertEndDocument(XmlReader xmlReader)
|
||||
{
|
||||
Assert(!xmlReader.Read());
|
||||
Assert(xmlReader.NodeType == XmlNodeType.None);
|
||||
Assert(xmlReader.ReadState == ReadState.EndOfFile);
|
||||
Assert(xmlReader.EOF);
|
||||
|
||||
xmlReader.Close();
|
||||
Assert(xmlReader.ReadState == ReadState.Closed);
|
||||
}
|
||||
|
||||
public void TestEmptyElement()
|
||||
{
|
||||
string xml = "<foo/>";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
true, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
public void TestEmptyElementWithWhitespace()
|
||||
{
|
||||
string xml = "<foo />";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
true, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
public void TestEmptyElementWithStartAndEndTag()
|
||||
{
|
||||
string xml = "<foo></foo>";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.EndElement, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
public void TestEmptyElementWithStartAndEndTagWithWhitespace()
|
||||
{
|
||||
string xml = "<foo ></foo >";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.EndElement, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
public void TestNestedEmptyTag()
|
||||
{
|
||||
string xml = "<foo><bar/></foo>";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
true, // isEmptyElement
|
||||
"bar", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.EndElement, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
public void TestNestedText()
|
||||
{
|
||||
string xml = "<foo>bar</foo>";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Text, // nodeType
|
||||
false, // isEmptyElement
|
||||
String.Empty, // name
|
||||
"bar", // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.EndElement, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
public void TestEmptyElementWithAttribute()
|
||||
{
|
||||
string xml = @"<foo bar=""baz""/>";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
true, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
1 // attributeCount
|
||||
);
|
||||
|
||||
AssertAttribute(
|
||||
xmlReader, // xmlReader
|
||||
"bar", // name
|
||||
"baz" // value
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
public void TestStartAndEndTagWithAttribute()
|
||||
{
|
||||
string xml = @"<foo bar='baz'></foo>";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
1 // attributeCount
|
||||
);
|
||||
|
||||
AssertAttribute(
|
||||
xmlReader, // xmlReader
|
||||
"bar", // name
|
||||
"baz" // value
|
||||
);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.EndElement, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
public void TestEmptyElementWithTwoAttributes()
|
||||
{
|
||||
string xml = @"<foo bar=""baz"" quux='quuux'/>";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
true, // isEmptyElement
|
||||
"foo", // name
|
||||
String.Empty, // value
|
||||
2 // attributeCount
|
||||
);
|
||||
|
||||
AssertAttribute(
|
||||
xmlReader, // xmlReader
|
||||
"bar", // name
|
||||
"baz" // value
|
||||
);
|
||||
|
||||
AssertAttribute(
|
||||
xmlReader, // xmlReader
|
||||
"quux", // name
|
||||
"quuux" // value
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
public void TestProcessingInstructionBeforeDocumentElement()
|
||||
{
|
||||
string xml = "<?foo bar?><baz/>";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.ProcessingInstruction, // nodeType
|
||||
false, // isEmptyElement
|
||||
"foo", // name
|
||||
"bar", // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
true, // isEmptyElement
|
||||
"baz", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
public void TestCommentBeforeDocumentElement()
|
||||
{
|
||||
string xml = "<!--foo--><bar/>";
|
||||
XmlReader xmlReader =
|
||||
new XmlTextReader(new StringReader(xml));
|
||||
|
||||
AssertStartDocument(xmlReader);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Comment, // nodeType
|
||||
false, // isEmptyElement
|
||||
String.Empty, // name
|
||||
"foo", // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertNode(
|
||||
xmlReader, // xmlReader
|
||||
XmlNodeType.Element, // nodeType
|
||||
true, // isEmptyElement
|
||||
"bar", // name
|
||||
String.Empty, // value
|
||||
0 // attributeCount
|
||||
);
|
||||
|
||||
AssertEndDocument(xmlReader);
|
||||
}
|
||||
|
||||
// The following is #if'ed out because it's specific to the Mono
|
||||
// implementation and won't compile when testing Microsoft's code.
|
||||
// Feel free to turn it on if you want to test Mono's name tables.
|
||||
|
||||
#if false
|
||||
|
||||
public void TestIsFirstNameChar()
|
||||
{
|
||||
for (int ch = 0; ch <= 0xFFFF; ++ch)
|
||||
{
|
||||
Assert(
|
||||
XmlChar.IsFirstNameChar(ch) ==
|
||||
IsFirstNameChar(ch));
|
||||
}
|
||||
}
|
||||
|
||||
public void TestIsNameChar()
|
||||
{
|
||||
for (int ch = 0; ch <= 0xFFFF; ++ch)
|
||||
{
|
||||
Assert(
|
||||
XmlChar.IsNameChar(ch) ==
|
||||
IsNameChar(ch));
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsFirstNameChar(int ch)
|
||||
{
|
||||
return
|
||||
IsLetter(ch) ||
|
||||
(ch == '_') ||
|
||||
(ch == ':');
|
||||
}
|
||||
|
||||
private static bool IsNameChar(int ch)
|
||||
{
|
||||
return
|
||||
IsLetter(ch) ||
|
||||
IsDigit(ch) ||
|
||||
(ch == '.') ||
|
||||
(ch == '-') ||
|
||||
(ch == '_') ||
|
||||
(ch == ':') ||
|
||||
IsCombiningChar(ch) ||
|
||||
IsExtender(ch);
|
||||
}
|
||||
|
||||
private static bool IsLetter(int ch)
|
||||
{
|
||||
return
|
||||
IsBaseChar(ch) ||
|
||||
IsIdeographic(ch);
|
||||
}
|
||||
|
||||
private static bool IsBaseChar(int ch)
|
||||
{
|
||||
return
|
||||
(ch >= 0x0041 && ch <= 0x005A) ||
|
||||
(ch >= 0x0061 && ch <= 0x007A) ||
|
||||
(ch >= 0x00C0 && ch <= 0x00D6) ||
|
||||
(ch >= 0x00D8 && ch <= 0x00F6) ||
|
||||
(ch >= 0x00F8 && ch <= 0x00FF) ||
|
||||
(ch >= 0x0100 && ch <= 0x0131) ||
|
||||
(ch >= 0x0134 && ch <= 0x013E) ||
|
||||
(ch >= 0x0141 && ch <= 0x0148) ||
|
||||
(ch >= 0x014A && ch <= 0x017E) ||
|
||||
(ch >= 0x0180 && ch <= 0x01C3) ||
|
||||
(ch >= 0x01CD && ch <= 0x01F0) ||
|
||||
(ch >= 0x01F4 && ch <= 0x01F5) ||
|
||||
(ch >= 0x01FA && ch <= 0x0217) ||
|
||||
(ch >= 0x0250 && ch <= 0x02A8) ||
|
||||
(ch >= 0x02BB && ch <= 0x02C1) ||
|
||||
(ch == 0x0386) ||
|
||||
(ch >= 0x0388 && ch <= 0x038A) ||
|
||||
(ch == 0x038C) ||
|
||||
(ch >= 0x038E && ch <= 0x03A1) ||
|
||||
(ch >= 0x03A3 && ch <= 0x03CE) ||
|
||||
(ch >= 0x03D0 && ch <= 0x03D6) ||
|
||||
(ch == 0x03DA) ||
|
||||
(ch == 0x03DC) ||
|
||||
(ch == 0x03DE) ||
|
||||
(ch == 0x03E0) ||
|
||||
(ch >= 0x03E2 && ch <= 0x03F3) ||
|
||||
(ch >= 0x0401 && ch <= 0x040C) ||
|
||||
(ch >= 0x040E && ch <= 0x044F) ||
|
||||
(ch >= 0x0451 && ch <= 0x045C) ||
|
||||
(ch >= 0x045E && ch <= 0x0481) ||
|
||||
(ch >= 0x0490 && ch <= 0x04C4) ||
|
||||
(ch >= 0x04C7 && ch <= 0x04C8) ||
|
||||
(ch >= 0x04CB && ch <= 0x04CC) ||
|
||||
(ch >= 0x04D0 && ch <= 0x04EB) ||
|
||||
(ch >= 0x04EE && ch <= 0x04F5) ||
|
||||
(ch >= 0x04F8 && ch <= 0x04F9) ||
|
||||
(ch >= 0x0531 && ch <= 0x0556) ||
|
||||
(ch == 0x0559) ||
|
||||
(ch >= 0x0561 && ch <= 0x0586) ||
|
||||
(ch >= 0x05D0 && ch <= 0x05EA) ||
|
||||
(ch >= 0x05F0 && ch <= 0x05F2) ||
|
||||
(ch >= 0x0621 && ch <= 0x063A) ||
|
||||
(ch >= 0x0641 && ch <= 0x064A) ||
|
||||
(ch >= 0x0671 && ch <= 0x06B7) ||
|
||||
(ch >= 0x06BA && ch <= 0x06BE) ||
|
||||
(ch >= 0x06C0 && ch <= 0x06CE) ||
|
||||
(ch >= 0x06D0 && ch <= 0x06D3) ||
|
||||
(ch == 0x06D5) ||
|
||||
(ch >= 0x06E5 && ch <= 0x06E6) ||
|
||||
(ch >= 0x0905 && ch <= 0x0939) ||
|
||||
(ch == 0x093D) ||
|
||||
(ch >= 0x0958 && ch <= 0x0961) ||
|
||||
(ch >= 0x0985 && ch <= 0x098C) ||
|
||||
(ch >= 0x098F && ch <= 0x0990) ||
|
||||
(ch >= 0x0993 && ch <= 0x09A8) ||
|
||||
(ch >= 0x09AA && ch <= 0x09B0) ||
|
||||
(ch == 0x09B2) ||
|
||||
(ch >= 0x09B6 && ch <= 0x09B9) ||
|
||||
(ch >= 0x09DC && ch <= 0x09DD) ||
|
||||
(ch >= 0x09DF && ch <= 0x09E1) ||
|
||||
(ch >= 0x09F0 && ch <= 0x09F1) ||
|
||||
(ch >= 0x0A05 && ch <= 0x0A0A) ||
|
||||
(ch >= 0x0A0F && ch <= 0x0A10) ||
|
||||
(ch >= 0x0A13 && ch <= 0x0A28) ||
|
||||
(ch >= 0x0A2A && ch <= 0x0A30) ||
|
||||
(ch >= 0x0A32 && ch <= 0x0A33) ||
|
||||
(ch >= 0x0A35 && ch <= 0x0A36) ||
|
||||
(ch >= 0x0A38 && ch <= 0x0A39) ||
|
||||
(ch >= 0x0A59 && ch <= 0x0A5C) ||
|
||||
(ch == 0x0A5E) ||
|
||||
(ch >= 0x0A72 && ch <= 0x0A74) ||
|
||||
(ch >= 0x0A85 && ch <= 0x0A8B) ||
|
||||
(ch == 0x0A8D) ||
|
||||
(ch >= 0x0A8F && ch <= 0x0A91) ||
|
||||
(ch >= 0x0A93 && ch <= 0x0AA8) ||
|
||||
(ch >= 0x0AAA && ch <= 0x0AB0) ||
|
||||
(ch >= 0x0AB2 && ch <= 0x0AB3) ||
|
||||
(ch >= 0x0AB5 && ch <= 0x0AB9) ||
|
||||
(ch == 0x0ABD) ||
|
||||
(ch == 0x0AE0) ||
|
||||
(ch >= 0x0B05 && ch <= 0x0B0C) ||
|
||||
(ch >= 0x0B0F && ch <= 0x0B10) ||
|
||||
(ch >= 0x0B13 && ch <= 0x0B28) ||
|
||||
(ch >= 0x0B2A && ch <= 0x0B30) ||
|
||||
(ch >= 0x0B32 && ch <= 0x0B33) ||
|
||||
(ch >= 0x0B36 && ch <= 0x0B39) ||
|
||||
(ch == 0x0B3D) ||
|
||||
(ch >= 0x0B5C && ch <= 0x0B5D) ||
|
||||
(ch >= 0x0B5F && ch <= 0x0B61) ||
|
||||
(ch >= 0x0B85 && ch <= 0x0B8A) ||
|
||||
(ch >= 0x0B8E && ch <= 0x0B90) ||
|
||||
(ch >= 0x0B92 && ch <= 0x0B95) ||
|
||||
(ch >= 0x0B99 && ch <= 0x0B9A) ||
|
||||
(ch == 0x0B9C) ||
|
||||
(ch >= 0x0B9E && ch <= 0x0B9F) ||
|
||||
(ch >= 0x0BA3 && ch <= 0x0BA4) ||
|
||||
(ch >= 0x0BA8 && ch <= 0x0BAA) ||
|
||||
(ch >= 0x0BAE && ch <= 0x0BB5) ||
|
||||
(ch >= 0x0BB7 && ch <= 0x0BB9) ||
|
||||
(ch >= 0x0C05 && ch <= 0x0C0C) ||
|
||||
(ch >= 0x0C0E && ch <= 0x0C10) ||
|
||||
(ch >= 0x0C12 && ch <= 0x0C28) ||
|
||||
(ch >= 0x0C2A && ch <= 0x0C33) ||
|
||||
(ch >= 0x0C35 && ch <= 0x0C39) ||
|
||||
(ch >= 0x0C60 && ch <= 0x0C61) ||
|
||||
(ch >= 0x0C85 && ch <= 0x0C8C) ||
|
||||
(ch >= 0x0C8E && ch <= 0x0C90) ||
|
||||
(ch >= 0x0C92 && ch <= 0x0CA8) ||
|
||||
(ch >= 0x0CAA && ch <= 0x0CB3) ||
|
||||
(ch >= 0x0CB5 && ch <= 0x0CB9) ||
|
||||
(ch == 0x0CDE) ||
|
||||
(ch >= 0x0CE0 && ch <= 0x0CE1) ||
|
||||
(ch >= 0x0D05 && ch <= 0x0D0C) ||
|
||||
(ch >= 0x0D0E && ch <= 0x0D10) ||
|
||||
(ch >= 0x0D12 && ch <= 0x0D28) ||
|
||||
(ch >= 0x0D2A && ch <= 0x0D39) ||
|
||||
(ch >= 0x0D60 && ch <= 0x0D61) ||
|
||||
(ch >= 0x0E01 && ch <= 0x0E2E) ||
|
||||
(ch == 0x0E30) ||
|
||||
(ch >= 0x0E32 && ch <= 0x0E33) ||
|
||||
(ch >= 0x0E40 && ch <= 0x0E45) ||
|
||||
(ch >= 0x0E81 && ch <= 0x0E82) ||
|
||||
(ch == 0x0E84) ||
|
||||
(ch >= 0x0E87 && ch <= 0x0E88) ||
|
||||
(ch == 0x0E8A) ||
|
||||
(ch == 0x0E8D) ||
|
||||
(ch >= 0x0E94 && ch <= 0x0E97) ||
|
||||
(ch >= 0x0E99 && ch <= 0x0E9F) ||
|
||||
(ch >= 0x0EA1 && ch <= 0x0EA3) ||
|
||||
(ch == 0x0EA5) ||
|
||||
(ch == 0x0EA7) ||
|
||||
(ch >= 0x0EAA && ch <= 0x0EAB) ||
|
||||
(ch >= 0x0EAD && ch <= 0x0EAE) ||
|
||||
(ch == 0x0EB0) ||
|
||||
(ch >= 0x0EB2 && ch <= 0x0EB3) ||
|
||||
(ch == 0x0EBD) ||
|
||||
(ch >= 0x0EC0 && ch <= 0x0EC4) ||
|
||||
(ch >= 0x0F40 && ch <= 0x0F47) ||
|
||||
(ch >= 0x0F49 && ch <= 0x0F69) ||
|
||||
(ch >= 0x10A0 && ch <= 0x10C5) ||
|
||||
(ch >= 0x10D0 && ch <= 0x10F6) ||
|
||||
(ch == 0x1100) ||
|
||||
(ch >= 0x1102 && ch <= 0x1103) ||
|
||||
(ch >= 0x1105 && ch <= 0x1107) ||
|
||||
(ch == 0x1109) ||
|
||||
(ch >= 0x110B && ch <= 0x110C) ||
|
||||
(ch >= 0x110E && ch <= 0x1112) ||
|
||||
(ch == 0x113C) ||
|
||||
(ch == 0x113E) ||
|
||||
(ch == 0x1140) ||
|
||||
(ch == 0x114C) ||
|
||||
(ch == 0x114E) ||
|
||||
(ch == 0x1150) ||
|
||||
(ch >= 0x1154 && ch <= 0x1155) ||
|
||||
(ch == 0x1159) ||
|
||||
(ch >= 0x115F && ch <= 0x1161) ||
|
||||
(ch == 0x1163) ||
|
||||
(ch == 0x1165) ||
|
||||
(ch == 0x1167) ||
|
||||
(ch == 0x1169) ||
|
||||
(ch >= 0x116D && ch <= 0x116E) ||
|
||||
(ch >= 0x1172 && ch <= 0x1173) ||
|
||||
(ch == 0x1175) ||
|
||||
(ch == 0x119E) ||
|
||||
(ch == 0x11A8) ||
|
||||
(ch == 0x11AB) ||
|
||||
(ch >= 0x11AE && ch <= 0x11AF) ||
|
||||
(ch >= 0x11B7 && ch <= 0x11B8) ||
|
||||
(ch == 0x11BA) ||
|
||||
(ch >= 0x11BC && ch <= 0x11C2) ||
|
||||
(ch == 0x11EB) ||
|
||||
(ch == 0x11F0) ||
|
||||
(ch == 0x11F9) ||
|
||||
(ch >= 0x1E00 && ch <= 0x1E9B) ||
|
||||
(ch >= 0x1EA0 && ch <= 0x1EF9) ||
|
||||
(ch >= 0x1F00 && ch <= 0x1F15) ||
|
||||
(ch >= 0x1F18 && ch <= 0x1F1D) ||
|
||||
(ch >= 0x1F20 && ch <= 0x1F45) ||
|
||||
(ch >= 0x1F48 && ch <= 0x1F4D) ||
|
||||
(ch >= 0x1F50 && ch <= 0x1F57) ||
|
||||
(ch == 0x1F59) ||
|
||||
(ch == 0x1F5B) ||
|
||||
(ch == 0x1F5D) ||
|
||||
(ch >= 0x1F5F && ch <= 0x1F7D) ||
|
||||
(ch >= 0x1F80 && ch <= 0x1FB4) ||
|
||||
(ch >= 0x1FB6 && ch <= 0x1FBC) ||
|
||||
(ch == 0x1FBE) ||
|
||||
(ch >= 0x1FC2 && ch <= 0x1FC4) ||
|
||||
(ch >= 0x1FC6 && ch <= 0x1FCC) ||
|
||||
(ch >= 0x1FD0 && ch <= 0x1FD3) ||
|
||||
(ch >= 0x1FD6 && ch <= 0x1FDB) ||
|
||||
(ch >= 0x1FE0 && ch <= 0x1FEC) ||
|
||||
(ch >= 0x1FF2 && ch <= 0x1FF4) ||
|
||||
(ch >= 0x1FF6 && ch <= 0x1FFC) ||
|
||||
(ch == 0x2126) ||
|
||||
(ch >= 0x212A && ch <= 0x212B) ||
|
||||
(ch == 0x212E) ||
|
||||
(ch >= 0x2180 && ch <= 0x2182) ||
|
||||
(ch >= 0x3041 && ch <= 0x3094) ||
|
||||
(ch >= 0x30A1 && ch <= 0x30FA) ||
|
||||
(ch >= 0x3105 && ch <= 0x312C) ||
|
||||
(ch >= 0xAC00 && ch <= 0xD7A3);
|
||||
}
|
||||
|
||||
private static bool IsIdeographic(int ch)
|
||||
{
|
||||
return
|
||||
(ch >= 0x4E00 && ch <= 0x9FA5) ||
|
||||
(ch == 0x3007) ||
|
||||
(ch >= 0x3021 && ch <= 0x3029);
|
||||
}
|
||||
|
||||
private static bool IsDigit(int ch)
|
||||
{
|
||||
return
|
||||
(ch >= 0x0030 && ch <= 0x0039) ||
|
||||
(ch >= 0x0660 && ch <= 0x0669) ||
|
||||
(ch >= 0x06F0 && ch <= 0x06F9) ||
|
||||
(ch >= 0x0966 && ch <= 0x096F) ||
|
||||
(ch >= 0x09E6 && ch <= 0x09EF) ||
|
||||
(ch >= 0x0A66 && ch <= 0x0A6F) ||
|
||||
(ch >= 0x0AE6 && ch <= 0x0AEF) ||
|
||||
(ch >= 0x0B66 && ch <= 0x0B6F) ||
|
||||
(ch >= 0x0BE7 && ch <= 0x0BEF) ||
|
||||
(ch >= 0x0C66 && ch <= 0x0C6F) ||
|
||||
(ch >= 0x0CE6 && ch <= 0x0CEF) ||
|
||||
(ch >= 0x0D66 && ch <= 0x0D6F) ||
|
||||
(ch >= 0x0E50 && ch <= 0x0E59) ||
|
||||
(ch >= 0x0ED0 && ch <= 0x0ED9) ||
|
||||
(ch >= 0x0F20 && ch <= 0x0F29);
|
||||
}
|
||||
|
||||
private static bool IsCombiningChar(int ch)
|
||||
{
|
||||
return
|
||||
(ch >= 0x0300 && ch <= 0x0345) ||
|
||||
(ch >= 0x0360 && ch <= 0x0361) ||
|
||||
(ch >= 0x0483 && ch <= 0x0486) ||
|
||||
(ch >= 0x0591 && ch <= 0x05A1) ||
|
||||
(ch >= 0x05A3 && ch <= 0x05B9) ||
|
||||
(ch >= 0x05BB && ch <= 0x05BD) ||
|
||||
(ch == 0x05BF) ||
|
||||
(ch >= 0x05C1 && ch <= 0x05C2) ||
|
||||
(ch == 0x05C4) ||
|
||||
(ch >= 0x064B && ch <= 0x0652) ||
|
||||
(ch == 0x0670) ||
|
||||
(ch >= 0x06D6 && ch <= 0x06DC) ||
|
||||
(ch >= 0x06DD && ch <= 0x06DF) ||
|
||||
(ch >= 0x06E0 && ch <= 0x06E4) ||
|
||||
(ch >= 0x06E7 && ch <= 0x06E8) ||
|
||||
(ch >= 0x06EA && ch <= 0x06ED) ||
|
||||
(ch >= 0x0901 && ch <= 0x0903) ||
|
||||
(ch == 0x093C) ||
|
||||
(ch >= 0x093E && ch <= 0x094C) ||
|
||||
(ch == 0x094D) ||
|
||||
(ch >= 0x0951 && ch <= 0x0954) ||
|
||||
(ch >= 0x0962 && ch <= 0x0963) ||
|
||||
(ch >= 0x0981 && ch <= 0x0983) ||
|
||||
(ch == 0x09BC) ||
|
||||
(ch == 0x09BE) ||
|
||||
(ch == 0x09BF) ||
|
||||
(ch >= 0x09C0 && ch <= 0x09C4) ||
|
||||
(ch >= 0x09C7 && ch <= 0x09C8) ||
|
||||
(ch >= 0x09CB && ch <= 0x09CD) ||
|
||||
(ch == 0x09D7) ||
|
||||
(ch >= 0x09E2 && ch <= 0x09E3) ||
|
||||
(ch == 0x0A02) ||
|
||||
(ch == 0x0A3C) ||
|
||||
(ch == 0x0A3E) ||
|
||||
(ch == 0x0A3F) ||
|
||||
(ch >= 0x0A40 && ch <= 0x0A42) ||
|
||||
(ch >= 0x0A47 && ch <= 0x0A48) ||
|
||||
(ch >= 0x0A4B && ch <= 0x0A4D) ||
|
||||
(ch >= 0x0A70 && ch <= 0x0A71) ||
|
||||
(ch >= 0x0A81 && ch <= 0x0A83) ||
|
||||
(ch == 0x0ABC) ||
|
||||
(ch >= 0x0ABE && ch <= 0x0AC5) ||
|
||||
(ch >= 0x0AC7 && ch <= 0x0AC9) ||
|
||||
(ch >= 0x0ACB && ch <= 0x0ACD) ||
|
||||
(ch >= 0x0B01 && ch <= 0x0B03) ||
|
||||
(ch == 0x0B3C) ||
|
||||
(ch >= 0x0B3E && ch <= 0x0B43) ||
|
||||
(ch >= 0x0B47 && ch <= 0x0B48) ||
|
||||
(ch >= 0x0B4B && ch <= 0x0B4D) ||
|
||||
(ch >= 0x0B56 && ch <= 0x0B57) ||
|
||||
(ch >= 0x0B82 && ch <= 0x0B83) ||
|
||||
(ch >= 0x0BBE && ch <= 0x0BC2) ||
|
||||
(ch >= 0x0BC6 && ch <= 0x0BC8) ||
|
||||
(ch >= 0x0BCA && ch <= 0x0BCD) ||
|
||||
(ch == 0x0BD7) ||
|
||||
(ch >= 0x0C01 && ch <= 0x0C03) ||
|
||||
(ch >= 0x0C3E && ch <= 0x0C44) ||
|
||||
(ch >= 0x0C46 && ch <= 0x0C48) ||
|
||||
(ch >= 0x0C4A && ch <= 0x0C4D) ||
|
||||
(ch >= 0x0C55 && ch <= 0x0C56) ||
|
||||
(ch >= 0x0C82 && ch <= 0x0C83) ||
|
||||
(ch >= 0x0CBE && ch <= 0x0CC4) ||
|
||||
(ch >= 0x0CC6 && ch <= 0x0CC8) ||
|
||||
(ch >= 0x0CCA && ch <= 0x0CCD) ||
|
||||
(ch >= 0x0CD5 && ch <= 0x0CD6) ||
|
||||
(ch >= 0x0D02 && ch <= 0x0D03) ||
|
||||
(ch >= 0x0D3E && ch <= 0x0D43) ||
|
||||
(ch >= 0x0D46 && ch <= 0x0D48) ||
|
||||
(ch >= 0x0D4A && ch <= 0x0D4D) ||
|
||||
(ch == 0x0D57) ||
|
||||
(ch == 0x0E31) ||
|
||||
(ch >= 0x0E34 && ch <= 0x0E3A) ||
|
||||
(ch >= 0x0E47 && ch <= 0x0E4E) ||
|
||||
(ch == 0x0EB1) ||
|
||||
(ch >= 0x0EB4 && ch <= 0x0EB9) ||
|
||||
(ch >= 0x0EBB && ch <= 0x0EBC) ||
|
||||
(ch >= 0x0EC8 && ch <= 0x0ECD) ||
|
||||
(ch >= 0x0F18 && ch <= 0x0F19) ||
|
||||
(ch == 0x0F35) ||
|
||||
(ch == 0x0F37) ||
|
||||
(ch == 0x0F39) ||
|
||||
(ch == 0x0F3E) ||
|
||||
(ch == 0x0F3F) ||
|
||||
(ch >= 0x0F71 && ch <= 0x0F84) ||
|
||||
(ch >= 0x0F86 && ch <= 0x0F8B) ||
|
||||
(ch >= 0x0F90 && ch <= 0x0F95) ||
|
||||
(ch == 0x0F97) ||
|
||||
(ch >= 0x0F99 && ch <= 0x0FAD) ||
|
||||
(ch >= 0x0FB1 && ch <= 0x0FB7) ||
|
||||
(ch == 0x0FB9) ||
|
||||
(ch >= 0x20D0 && ch <= 0x20DC) ||
|
||||
(ch == 0x20E1) ||
|
||||
(ch >= 0x302A && ch <= 0x302F) ||
|
||||
(ch == 0x3099) ||
|
||||
(ch == 0x309A);
|
||||
}
|
||||
|
||||
private static bool IsExtender(int ch)
|
||||
{
|
||||
return
|
||||
(ch == 0x00B7) ||
|
||||
(ch == 0x02D0) ||
|
||||
(ch == 0x02D1) ||
|
||||
(ch == 0x0387) ||
|
||||
(ch == 0x0640) ||
|
||||
(ch == 0x0E46) ||
|
||||
(ch == 0x0EC6) ||
|
||||
(ch == 0x3005) ||
|
||||
(ch >= 0x3031 && ch <= 0x3035) ||
|
||||
(ch >= 0x309D && ch <= 0x309E) ||
|
||||
(ch >= 0x30FC && ch <= 0x30FE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public void TestIsName()
|
||||
{
|
||||
Assert(XmlReader.IsName("foo"));
|
||||
Assert(!XmlReader.IsName("1foo"));
|
||||
Assert(!XmlReader.IsName(" foo"));
|
||||
}
|
||||
|
||||
public void TestIsNameToken()
|
||||
{
|
||||
Assert(XmlReader.IsNameToken("foo"));
|
||||
Assert(XmlReader.IsNameToken("1foo"));
|
||||
Assert(!XmlReader.IsNameToken(" foo"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Xml.XmlChar.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Xml
|
||||
{
|
||||
internal class XmlChar
|
||||
{
|
||||
internal static bool IsWhitespace(int ch)
|
||||
{
|
||||
return ch == 0x20 || ch == 0x9 || ch == 0xD || ch == 0xA;
|
||||
}
|
||||
|
||||
internal static bool IsFirstNameChar(int ch)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (ch >= 0 && ch <= 0xFFFF)
|
||||
{
|
||||
result = (nameBitmap[(firstNamePages[ch >> 8] << 3) + ((ch & 0xFF) >> 5)] & (1 << (ch & 0x1F))) != 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static bool IsNameChar(int ch)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (ch >= 0 && ch <= 0xFFFF)
|
||||
{
|
||||
result = (nameBitmap[(namePages[ch >> 8] << 3) + ((ch & 0xFF) >> 5)] & (1 << (ch & 0x1F))) != 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static byte[] firstNamePages =
|
||||
{
|
||||
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
|
||||
0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
private static byte[] namePages =
|
||||
{
|
||||
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
|
||||
0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
private static uint[] nameBitmap =
|
||||
{
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
|
||||
0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
|
||||
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
|
||||
0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
|
||||
0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
|
||||
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
|
||||
0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
|
||||
0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
|
||||
0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
|
||||
0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
|
||||
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
|
||||
0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
|
||||
0x40000000, 0xF580C900, 0x00000007, 0x02010800,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
|
||||
0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
|
||||
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
|
||||
0x00000000, 0x00004C40, 0x00000000, 0x00000000,
|
||||
0x00000007, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
|
||||
0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
|
||||
0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
|
||||
0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
|
||||
0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
|
||||
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
|
||||
0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
|
||||
0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
|
||||
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
|
||||
0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
|
||||
0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
|
||||
0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
|
||||
0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
|
||||
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
|
||||
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Xml.XmlNameTable.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
namespace System.Xml
|
||||
{
|
||||
public abstract class XmlNameTable
|
||||
{
|
||||
public abstract string Add(string name);
|
||||
public abstract string Add(char[] buffer, int offset, int length);
|
||||
public abstract string Get(string name);
|
||||
public abstract string Get(char[] buffer, int offset, int length);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Xml.XmlNamespaceManager.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
using System.Collections;
|
||||
|
||||
namespace System.Xml
|
||||
{
|
||||
public class XmlNamespaceManager : IEnumerable
|
||||
{
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Xml.XmlNodeType.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
namespace System.Xml
|
||||
{
|
||||
public enum XmlNodeType
|
||||
{
|
||||
Attribute,
|
||||
CDATA,
|
||||
Comment,
|
||||
Document,
|
||||
DocumentFragment,
|
||||
DocumentType,
|
||||
Element,
|
||||
EndElement,
|
||||
EndEntity,
|
||||
Entity,
|
||||
EntityReference,
|
||||
None,
|
||||
Notation,
|
||||
ProcessingInstruction,
|
||||
SignifigantWhitespace,
|
||||
Text,
|
||||
Whitespace,
|
||||
XmlDeclaration
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Xml.XmlParserContext.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
namespace System.Xml
|
||||
{
|
||||
public class XmlParserContext
|
||||
{
|
||||
// constructors
|
||||
|
||||
public XmlParserContext(
|
||||
XmlNameTable nameTable,
|
||||
XmlNamespaceManager namespaceManager,
|
||||
string xmlLang,
|
||||
XmlSpace xmlSpace) :
|
||||
|
||||
this(
|
||||
nameTable,
|
||||
namespaceManager,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
xmlLang,
|
||||
xmlSpace
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public XmlParserContext(
|
||||
XmlNameTable nameTable,
|
||||
XmlNamespaceManager namespaceManager,
|
||||
string docTypeName,
|
||||
string publicID,
|
||||
string systemID,
|
||||
string internalSubset,
|
||||
string baseURI,
|
||||
string xmlLang,
|
||||
XmlSpace xmlSpace)
|
||||
{
|
||||
this.nameTable = nameTable;
|
||||
this.namespaceManager = namespaceManager;
|
||||
this.docTypeName = docTypeName;
|
||||
this.publicID = publicID;
|
||||
this.systemID = systemID;
|
||||
this.internalSubset = internalSubset;
|
||||
this.baseURI = baseURI;
|
||||
this.xmlLang = xmlLang;
|
||||
this.xmlSpace = xmlSpace;
|
||||
}
|
||||
|
||||
// properties
|
||||
|
||||
public string BaseURI
|
||||
{
|
||||
get { return baseURI; }
|
||||
set { baseURI = value; }
|
||||
}
|
||||
|
||||
public string DocTypeName
|
||||
{
|
||||
get { return docTypeName; }
|
||||
set { docTypeName = value; }
|
||||
}
|
||||
|
||||
public string InternalSubset
|
||||
{
|
||||
get { return internalSubset; }
|
||||
set { internalSubset = value; }
|
||||
}
|
||||
|
||||
public XmlNamespaceManager NamespaceManager
|
||||
{
|
||||
get { return namespaceManager; }
|
||||
set { namespaceManager = value; }
|
||||
}
|
||||
|
||||
public XmlNameTable NameTable
|
||||
{
|
||||
get { return nameTable; }
|
||||
set { nameTable = nameTable; }
|
||||
}
|
||||
|
||||
public string PublicId
|
||||
{
|
||||
get { return publicID; }
|
||||
set { publicID = value; }
|
||||
}
|
||||
|
||||
public string SystemId
|
||||
{
|
||||
get { return systemID; }
|
||||
set { systemID = value; }
|
||||
}
|
||||
|
||||
public string XmlLang
|
||||
{
|
||||
get { return xmlLang; }
|
||||
set { xmlLang = value; }
|
||||
}
|
||||
|
||||
public XmlSpace XmlSpace
|
||||
{
|
||||
get { return xmlSpace; }
|
||||
set { xmlSpace = value; }
|
||||
}
|
||||
|
||||
// privates
|
||||
|
||||
private string baseURI;
|
||||
private string docTypeName;
|
||||
private string internalSubset;
|
||||
private XmlNamespaceManager namespaceManager;
|
||||
private XmlNameTable nameTable;
|
||||
private string publicID;
|
||||
private string systemID;
|
||||
private string xmlLang;
|
||||
private XmlSpace xmlSpace;
|
||||
}
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Xml.XmlReader.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
namespace System.Xml
|
||||
{
|
||||
public abstract class XmlReader
|
||||
{
|
||||
// properties
|
||||
|
||||
public abstract int AttributeCount { get; }
|
||||
|
||||
public abstract string BaseURI { get; }
|
||||
|
||||
public virtual bool CanResolveEntity
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract int Depth { get; }
|
||||
|
||||
public abstract bool EOF { get; }
|
||||
|
||||
public virtual bool HasAttributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return AttributeCount > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract bool HasValue { get; }
|
||||
|
||||
public abstract bool IsDefault { get; }
|
||||
|
||||
public abstract bool IsEmptyElement { get; }
|
||||
|
||||
public abstract string this[int i] { get; }
|
||||
|
||||
public abstract string this[string name] { get; }
|
||||
|
||||
public abstract string this[
|
||||
string localName,
|
||||
string namespaceName]
|
||||
{ get; }
|
||||
|
||||
public abstract string LocalName { get; }
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract string NamespaceURI { get; }
|
||||
|
||||
public abstract XmlNameTable NameTable { get; }
|
||||
|
||||
public abstract XmlNodeType NodeType { get; }
|
||||
|
||||
public abstract string Prefix { get; }
|
||||
|
||||
public abstract char QuoteChar { get; }
|
||||
|
||||
public abstract ReadState ReadState { get; }
|
||||
|
||||
public abstract string Value { get; }
|
||||
|
||||
public abstract string XmlLang { get; }
|
||||
|
||||
public abstract XmlSpace XmlSpace { get; }
|
||||
|
||||
// methods
|
||||
|
||||
public abstract void Close();
|
||||
|
||||
public abstract string GetAttribute(int i);
|
||||
|
||||
public abstract string GetAttribute(string name);
|
||||
|
||||
public abstract string GetAttribute(
|
||||
string localName,
|
||||
string namespaceName);
|
||||
|
||||
public static bool IsName(string s)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (s != null && s.Length > 0)
|
||||
{
|
||||
char[] chars = s.ToCharArray();
|
||||
|
||||
if (XmlChar.IsFirstNameChar(chars[0]))
|
||||
{
|
||||
int i = 1;
|
||||
int n = chars.Length;
|
||||
|
||||
while (i < n && XmlChar.IsNameChar(chars[i]))
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
result = i == n;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool IsNameToken(string s)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (s != null && s.Length > 0)
|
||||
{
|
||||
char[] chars = s.ToCharArray();
|
||||
|
||||
int i = 0;
|
||||
int n = chars.Length;
|
||||
|
||||
while (i < n && XmlChar.IsNameChar(chars[i]))
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
result = i == n;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual bool IsStartElement()
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsStartElement(string name)
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsStartElement(
|
||||
string localName,
|
||||
string namespaceName)
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract string LookupNamespace(string prefix);
|
||||
|
||||
public abstract void MoveToAttribute(int i);
|
||||
|
||||
public abstract bool MoveToAttribute(string name);
|
||||
|
||||
public abstract bool MoveToAttribute(
|
||||
string localName,
|
||||
string namespaceName);
|
||||
|
||||
public virtual XmlNodeType MoveToContent()
|
||||
{
|
||||
// TODO: implement me.
|
||||
return XmlNodeType.None;
|
||||
}
|
||||
|
||||
public abstract bool MoveToElement();
|
||||
|
||||
public abstract bool MoveToFirstAttribute();
|
||||
|
||||
public abstract bool MoveToNextAttribute();
|
||||
|
||||
public abstract bool Read();
|
||||
|
||||
public abstract bool ReadAttributeValue();
|
||||
|
||||
public virtual string ReadElementString()
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual string ReadElementString(string name)
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual string ReadElementString(
|
||||
string localName,
|
||||
string namespaceName)
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void ReadEndElement()
|
||||
{
|
||||
// TODO: implement me.
|
||||
}
|
||||
|
||||
public abstract string ReadInnerXml();
|
||||
|
||||
public abstract string ReadOuterXml();
|
||||
|
||||
public virtual void ReadStartElement()
|
||||
{
|
||||
// TODO: implement me.
|
||||
}
|
||||
|
||||
public virtual void ReadStartElement(string name)
|
||||
{
|
||||
// TODO: implement me.
|
||||
}
|
||||
|
||||
public virtual void ReadStartElement(
|
||||
string localName,
|
||||
string namespaceName)
|
||||
{
|
||||
// TODO: implement me.
|
||||
}
|
||||
|
||||
public abstract string ReadString();
|
||||
|
||||
public abstract void ResolveEntity();
|
||||
|
||||
public virtual void Skip()
|
||||
{
|
||||
// TODO: implement me.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Xml.XmlSpace.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
namespace System.Xml
|
||||
{
|
||||
public enum XmlSpace
|
||||
{
|
||||
Default,
|
||||
None,
|
||||
Preserve
|
||||
}
|
||||
}
|
||||
@@ -1,797 +0,0 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Xml.XmlTextReader.cs
|
||||
//
|
||||
// Author:
|
||||
// Jason Diamond ([email protected])
|
||||
//
|
||||
// (C) 2001 Jason Diamond http://injektilo.org/
|
||||
//
|
||||
|
||||
// FIXME:
|
||||
// This can only parse basic XML: elements, attributes, processing
|
||||
// instructions, and comments are OK but there's no support for
|
||||
// entity/character references or namespaces yet.
|
||||
//
|
||||
// It barfs on DOCTYPE declarations and CDATA sections.
|
||||
//
|
||||
// There's also no checking being done for either well-formedness
|
||||
// or validity.
|
||||
//
|
||||
// ParserContext and NameTables aren't being used yet.
|
||||
//
|
||||
// The XmlTextReader-specific properties and methods have yet to
|
||||
// be added or implemented.
|
||||
//
|
||||
// Some thought needs to be given to performance. There's too many
|
||||
// strings and string builders being allocated.
|
||||
//
|
||||
// None of the MoveTo methods have been implemented yet.
|
||||
//
|
||||
// LineNumber and LinePosition aren't being tracked.
|
||||
//
|
||||
// xml:space, xml:lang, and xml:base aren't being tracked.
|
||||
//
|
||||
// Depth isn't being tracked.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace System.Xml
|
||||
{
|
||||
public class XmlTextReader : XmlReader
|
||||
{
|
||||
// constructors
|
||||
|
||||
protected XmlTextReader()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public XmlTextReader(Stream input)
|
||||
{
|
||||
Init();
|
||||
reader = new StreamReader(
|
||||
input,
|
||||
Encoding.UTF8,
|
||||
true);
|
||||
}
|
||||
|
||||
public XmlTextReader(string url)
|
||||
{
|
||||
Init();
|
||||
WebClient client = new WebClient();
|
||||
reader = new StreamReader(
|
||||
client.OpenRead(url),
|
||||
Encoding.UTF8,
|
||||
true);
|
||||
}
|
||||
|
||||
public XmlTextReader(TextReader input)
|
||||
{
|
||||
Init();
|
||||
reader = input;
|
||||
}
|
||||
|
||||
public XmlTextReader(Stream input, XmlNameTable nameTable)
|
||||
{
|
||||
// TODO: implement me.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public XmlTextReader(string baseURI, Stream input)
|
||||
{
|
||||
// TODO: implement me.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public XmlTextReader(string baseURI, TextReader input)
|
||||
{
|
||||
// TODO: implement me.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public XmlTextReader(string url, XmlNameTable nameTable)
|
||||
{
|
||||
// TODO: implement me.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public XmlTextReader(
|
||||
TextReader input,
|
||||
XmlNameTable nameTable)
|
||||
{
|
||||
// TODO: implement me.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public XmlTextReader(
|
||||
Stream inputFragment,
|
||||
XmlNodeType fragmentType,
|
||||
XmlParserContext context)
|
||||
{
|
||||
// TODO: implement me.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public XmlTextReader(
|
||||
string baseURI,
|
||||
Stream input,
|
||||
XmlNameTable nameTable)
|
||||
{
|
||||
// TODO: implement me.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public XmlTextReader(
|
||||
string baseURI,
|
||||
TextReader input,
|
||||
XmlNameTable nameTable)
|
||||
{
|
||||
// TODO: implement me.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public XmlTextReader(
|
||||
string fragment,
|
||||
XmlNodeType fragmentType,
|
||||
XmlParserContext context)
|
||||
{
|
||||
// TODO: implement me.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
// properties
|
||||
|
||||
public override int AttributeCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return attributes.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public override string BaseURI
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanResolveEntity
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Depth
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool EOF
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
readState == ReadState.EndOfFile ||
|
||||
readState == ReadState.Closed;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return value != String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsDefault
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsEmptyElement
|
||||
{
|
||||
get
|
||||
{
|
||||
return isEmptyElement;
|
||||
}
|
||||
}
|
||||
|
||||
public override string this[int i]
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetAttribute(i);
|
||||
}
|
||||
}
|
||||
|
||||
public override string this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetAttribute(name);
|
||||
}
|
||||
}
|
||||
|
||||
public override string this[
|
||||
string localName,
|
||||
string namespaceName]
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetAttribute(localName, namespaceName);
|
||||
}
|
||||
}
|
||||
|
||||
public override string LocalName
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public override string NamespaceURI
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override XmlNameTable NameTable
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override XmlNodeType NodeType
|
||||
{
|
||||
get
|
||||
{
|
||||
return nodeType;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Prefix
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override char QuoteChar
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return '"';
|
||||
}
|
||||
}
|
||||
|
||||
public override ReadState ReadState
|
||||
{
|
||||
get
|
||||
{
|
||||
return readState;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string XmlLang
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override XmlSpace XmlSpace
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: implement me.
|
||||
return XmlSpace.Default;
|
||||
}
|
||||
}
|
||||
|
||||
// methods
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
readState = ReadState.Closed;
|
||||
}
|
||||
|
||||
public override string GetAttribute(int i)
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string GetAttribute(string name)
|
||||
{
|
||||
return (string)attributes[name];
|
||||
}
|
||||
|
||||
public override string GetAttribute(
|
||||
string localName,
|
||||
string namespaceName)
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string LookupNamespace(string prefix)
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void MoveToAttribute(int i)
|
||||
{
|
||||
// TODO: implement me.
|
||||
}
|
||||
|
||||
public override bool MoveToAttribute(string name)
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool MoveToAttribute(
|
||||
string localName,
|
||||
string namespaceName)
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool MoveToElement()
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool MoveToFirstAttribute()
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool MoveToNextAttribute()
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool Read()
|
||||
{
|
||||
bool more = false;
|
||||
|
||||
readState = ReadState.Interactive;
|
||||
|
||||
more = ReadContent();
|
||||
|
||||
return more;
|
||||
}
|
||||
|
||||
public override bool ReadAttributeValue()
|
||||
{
|
||||
// TODO: implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override string ReadInnerXml()
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ReadOuterXml()
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ReadString()
|
||||
{
|
||||
// TODO: implement me.
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void ResolveEntity()
|
||||
{
|
||||
// TODO: implement me.
|
||||
}
|
||||
|
||||
// privates
|
||||
|
||||
private TextReader reader;
|
||||
private ReadState readState;
|
||||
|
||||
private XmlNodeType nodeType;
|
||||
private string name;
|
||||
private bool isEmptyElement;
|
||||
private string value;
|
||||
private Hashtable attributes;
|
||||
|
||||
private void Init()
|
||||
{
|
||||
readState = ReadState.Initial;
|
||||
|
||||
nodeType = XmlNodeType.None;
|
||||
name = String.Empty;
|
||||
isEmptyElement = false;
|
||||
value = String.Empty;
|
||||
attributes = new Hashtable();
|
||||
}
|
||||
|
||||
// Use this method rather than setting the properties
|
||||
// directly so that all the necessary properties can
|
||||
// be changed in harmony with each other. Maybe the
|
||||
// fields should be in a seperate class to help enforce
|
||||
// this.
|
||||
private void SetProperties(
|
||||
XmlNodeType nodeType,
|
||||
string name,
|
||||
bool isEmptyElement,
|
||||
string value,
|
||||
bool clearAttributes)
|
||||
{
|
||||
this.nodeType = nodeType;
|
||||
this.name = name;
|
||||
this.isEmptyElement = isEmptyElement;
|
||||
this.value = value;
|
||||
|
||||
if (clearAttributes)
|
||||
{
|
||||
ClearAttributes();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddAttribute(string name, string value)
|
||||
{
|
||||
attributes.Add(name, value);
|
||||
}
|
||||
|
||||
private void ClearAttributes()
|
||||
{
|
||||
attributes.Clear();
|
||||
}
|
||||
|
||||
// This should really keep track of some state so
|
||||
// that it's not possible to have more than one document
|
||||
// element or text outside of the document element.
|
||||
private bool ReadContent()
|
||||
{
|
||||
bool more = false;
|
||||
|
||||
switch (reader.Peek())
|
||||
{
|
||||
case '<':
|
||||
reader.Read();
|
||||
ReadTag();
|
||||
more = true;
|
||||
break;
|
||||
case -1:
|
||||
readState = ReadState.EndOfFile;
|
||||
SetProperties(
|
||||
XmlNodeType.None, // nodeType
|
||||
String.Empty, // name
|
||||
false, // isEmptyElement
|
||||
String.Empty, // value
|
||||
true // clearAttributes
|
||||
);
|
||||
more = false;
|
||||
break;
|
||||
default:
|
||||
ReadText();
|
||||
more = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return more;
|
||||
}
|
||||
|
||||
// The leading '<' has already been consumed.
|
||||
private void ReadTag()
|
||||
{
|
||||
switch (reader.Peek())
|
||||
{
|
||||
case '/':
|
||||
reader.Read();
|
||||
ReadEndTag();
|
||||
break;
|
||||
case '?':
|
||||
reader.Read();
|
||||
ReadProcessingInstruction();
|
||||
break;
|
||||
case '!':
|
||||
reader.Read();
|
||||
ReadComment();
|
||||
break;
|
||||
default:
|
||||
ReadStartTag();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// The leading '<' has already been consumed.
|
||||
private void ReadStartTag()
|
||||
{
|
||||
string name = ReadName();
|
||||
SkipWhitespace();
|
||||
|
||||
bool isEmptyElement = false;
|
||||
|
||||
ClearAttributes();
|
||||
|
||||
if (XmlChar.IsFirstNameChar(reader.Peek()))
|
||||
{
|
||||
ReadAttributes();
|
||||
}
|
||||
|
||||
if (reader.Peek() == '/')
|
||||
{
|
||||
reader.Read();
|
||||
isEmptyElement = true;
|
||||
}
|
||||
|
||||
Expect('>');
|
||||
|
||||
SetProperties(
|
||||
XmlNodeType.Element, // nodeType
|
||||
name, // name
|
||||
isEmptyElement, // isEmptyElement
|
||||
String.Empty, // value
|
||||
false // clearAttributes
|
||||
);
|
||||
}
|
||||
|
||||
// The reader is positioned on the first character
|
||||
// of the element's name.
|
||||
private void ReadEndTag()
|
||||
{
|
||||
string name = ReadName();
|
||||
SkipWhitespace();
|
||||
Expect('>');
|
||||
|
||||
SetProperties(
|
||||
XmlNodeType.EndElement, // nodeType
|
||||
name, // name
|
||||
false, // isEmptyElement
|
||||
String.Empty, // value
|
||||
true // clearAttributes
|
||||
);
|
||||
}
|
||||
|
||||
// The reader is positioned on the first character
|
||||
// of the text.
|
||||
private void ReadText()
|
||||
{
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.Append((char)reader.Read());
|
||||
|
||||
while (reader.Peek() != '<' && reader.Peek() != -1)
|
||||
{
|
||||
text.Append((char)reader.Read());
|
||||
}
|
||||
|
||||
SetProperties(
|
||||
XmlNodeType.Text, // nodeType
|
||||
String.Empty, // name
|
||||
false, // isEmptyElement
|
||||
text.ToString(), // value
|
||||
true // clearAttributes
|
||||
);
|
||||
}
|
||||
|
||||
// The reader is positioned on the first character of
|
||||
// the attribute name.
|
||||
private void ReadAttributes()
|
||||
{
|
||||
do
|
||||
{
|
||||
string name = ReadName();
|
||||
SkipWhitespace();
|
||||
Expect('=');
|
||||
SkipWhitespace();
|
||||
string value = ReadAttribute();
|
||||
SkipWhitespace();
|
||||
|
||||
AddAttribute(name, value);
|
||||
}
|
||||
while (reader.Peek() != '/' && reader.Peek() != '>' && reader.Peek() != -1);
|
||||
}
|
||||
|
||||
// The reader is positioned on the quote character.
|
||||
private string ReadAttribute()
|
||||
{
|
||||
int quoteChar = reader.Read();
|
||||
|
||||
if (quoteChar != '\'' && quoteChar != '\"')
|
||||
{
|
||||
throw new Exception("an attribute value was not quoted");
|
||||
}
|
||||
|
||||
StringBuilder valueBuilder = new StringBuilder();
|
||||
|
||||
while (reader.Peek() != quoteChar)
|
||||
{
|
||||
int ch = reader.Read();
|
||||
|
||||
switch (ch)
|
||||
{
|
||||
case '<':
|
||||
throw new Exception("attribute values cannot contain '<'");
|
||||
case -1:
|
||||
throw new Exception("unexpected end of file in an attribute value");
|
||||
}
|
||||
|
||||
valueBuilder.Append((char)ch);
|
||||
}
|
||||
|
||||
reader.Read();
|
||||
|
||||
return valueBuilder.ToString();
|
||||
}
|
||||
|
||||
// The reader is positioned on the first character
|
||||
// of the target.
|
||||
private void ReadProcessingInstruction()
|
||||
{
|
||||
string target = ReadName();
|
||||
SkipWhitespace();
|
||||
|
||||
StringBuilder valueBuilder = new StringBuilder();
|
||||
|
||||
while (reader.Peek() != -1)
|
||||
{
|
||||
int ch = reader.Read();
|
||||
|
||||
if (ch == '?' && reader.Peek() == '>')
|
||||
{
|
||||
reader.Read();
|
||||
break;
|
||||
}
|
||||
|
||||
valueBuilder.Append((char)ch);
|
||||
}
|
||||
|
||||
SetProperties(
|
||||
XmlNodeType.ProcessingInstruction, // nodeType
|
||||
target, // name
|
||||
false, // isEmptyElement
|
||||
valueBuilder.ToString(), // value
|
||||
true // clearAttributes
|
||||
);
|
||||
}
|
||||
|
||||
// The reader is positioned on the first character after
|
||||
// the leading '<!'.
|
||||
private void ReadComment()
|
||||
{
|
||||
Expect('-');
|
||||
Expect('-');
|
||||
|
||||
StringBuilder valueBuilder = new StringBuilder();
|
||||
|
||||
while (reader.Peek() != -1)
|
||||
{
|
||||
int ch = reader.Read();
|
||||
|
||||
if (ch == '-' && reader.Peek() == '-')
|
||||
{
|
||||
reader.Read();
|
||||
|
||||
if (reader.Peek() != '>')
|
||||
{
|
||||
throw new Exception("comments cannot contain '--'");
|
||||
}
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
}
|
||||
|
||||
valueBuilder.Append((char)ch);
|
||||
}
|
||||
|
||||
SetProperties(
|
||||
XmlNodeType.Comment, // nodeType
|
||||
String.Empty, // name
|
||||
false, // isEmptyElement
|
||||
valueBuilder.ToString(), // value
|
||||
true // clearAttributes
|
||||
);
|
||||
}
|
||||
|
||||
// The reader is positioned on the first character
|
||||
// of the name.
|
||||
private string ReadName()
|
||||
{
|
||||
if (!XmlChar.IsFirstNameChar(reader.Peek()))
|
||||
{
|
||||
throw new Exception("a name did not start with a legal character");
|
||||
}
|
||||
|
||||
StringBuilder nameBuilder = new StringBuilder();
|
||||
|
||||
nameBuilder.Append((char)reader.Read());
|
||||
|
||||
while (XmlChar.IsNameChar(reader.Peek()))
|
||||
{
|
||||
nameBuilder.Append((char)reader.Read());
|
||||
}
|
||||
|
||||
return nameBuilder.ToString();
|
||||
}
|
||||
|
||||
// Read the next character and compare it against the
|
||||
// specified character.
|
||||
private void Expect(int expected)
|
||||
{
|
||||
int ch = reader.Read();
|
||||
|
||||
if (ch != expected)
|
||||
{
|
||||
throw new Exception(String.Format(
|
||||
"expected '{0}' ({1:X}) but found '{2}' ({3:X})",
|
||||
(char)expected,
|
||||
expected,
|
||||
(char)ch,
|
||||
ch));
|
||||
}
|
||||
}
|
||||
|
||||
// Does not consume the first non-whitespace character.
|
||||
private void SkipWhitespace()
|
||||
{
|
||||
while (XmlChar.IsWhitespace(reader.Peek()))
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
XmlChar.cs
|
||||
XmlNameTable.cs
|
||||
XmlNamespaceManager.cs
|
||||
XmlNodeType.cs
|
||||
XmlParserContext.cs
|
||||
XmlReader.cs
|
||||
XmlSpace.cs
|
||||
XmlTextReader.cs
|
||||
@@ -1,14 +0,0 @@
|
||||
all:
|
||||
@echo "You must use 'make windows' or 'make unix'."
|
||||
@echo "'make unix' is broken for now."
|
||||
|
||||
windows: make-list
|
||||
$(CSC) /target:library /out:System.XML.dll /nowarn:1595 @list
|
||||
|
||||
unix:
|
||||
@echo "'make unix' is broken for now."
|
||||
|
||||
make-list:
|
||||
cat $$i/common.src $$i/windows.src | sed "s/^/$$i\\\\/";
|
||||
|
||||
test: $(PLATFORM)
|
||||
@@ -1,2 +0,0 @@
|
||||
System.dll
|
||||
list
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Revision
|
||||
// Build Number
|
||||
//
|
||||
// You can specify all the value or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified - the assembly cannot be signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine.
|
||||
// (*) If the key file and a key name attributes are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP - that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the file is installed into the CSP and used.
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
@@ -1,5 +0,0 @@
|
||||
2001-07-15 Sean MacIsaac <[email protected]>
|
||||
|
||||
* CodeGenerator.cs: moved using statement out of namespace
|
||||
declaration.
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
|
||||
using System.CodeDom;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
|
||||
namespace System.CodeDom.Compiler {
|
||||
|
||||
using System.CodeDom;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
|
||||
public abstract class CodeGenerator : ICodeGenerator {
|
||||
protected TextWriter output;
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
ICodeGenerator.cs
|
||||
CodeGenerator.cs
|
||||
Whitespace-only changes.
Whitespace-only changes.
+51
@@ -0,0 +1,51 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Revision
|
||||
// Build Number
|
||||
//
|
||||
// You can specify all the value or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified - the assembly cannot be signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine.
|
||||
// (*) If the key file and a key name attributes are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP - that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the file is installed into the CSP and used.
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
@@ -1,19 +1,5 @@
|
||||
2001-07-15 Sean MacIsaac <[email protected]>
|
||||
|
||||
* MemberAttributes.cs: Added so rest of classes would compile.
|
||||
|
||||
* FieldDirection.cs: Added so rest of classes would compile.
|
||||
|
||||
* CodeTypeMember.cs: Added so rest of classes would compile.
|
||||
|
||||
* CodeTypeDeclaration.cs: Added so rest of classes would compile.
|
||||
|
||||
* CodeObject.cs: Added so rest of classes would compile.
|
||||
|
||||
* CodeBinaryOperatorType.cs: Added so rest of classes would compile.
|
||||
|
||||
2001-07-12 Sean MacIsaac <[email protected]>
|
||||
|
||||
|
||||
* All files implementing IList: Added IsFixedSize property.
|
||||
|
||||
* All files: Changed CodeDOM to CodeDom.
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// System.CodeDom CodeBinaryOperatorType Enum implementation
|
||||
//
|
||||
// Author:
|
||||
// Sean MacIsaac ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
|
||||
namespace System.CodeDom {
|
||||
public enum CodeBinaryOperatorType {
|
||||
Add,
|
||||
Assign,
|
||||
BitwiseAnd,
|
||||
BitwiseOr,
|
||||
BooleanAnd,
|
||||
BooleanOr,
|
||||
Divide,
|
||||
GreaterThan,
|
||||
GreaterThanOrEqual,
|
||||
IdentityEquality,
|
||||
IdentityInequality,
|
||||
LessThan,
|
||||
LessThanOrEqual,
|
||||
Modulus,
|
||||
Multiply,
|
||||
Subtract,
|
||||
ValueEquality
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,37 @@
|
||||
//
|
||||
// System.CodeDom CodeMethodReturnStatement class implementation
|
||||
// System.CodeDom CodeReturnStatement Class implementation
|
||||
//
|
||||
// Author:
|
||||
// Sean MacIsaac (macisaac@ximian.com)
|
||||
// Miguel de Icaza (miguel@ximian.com)
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
|
||||
public class CodeMethodReturnStatement : CodeStatement {
|
||||
namespace System.CodeDom {
|
||||
|
||||
public class CodeReturnStatement : CodeStatement {
|
||||
CodeExpression expression;
|
||||
|
||||
public CodeReturnStatement ()
|
||||
{
|
||||
}
|
||||
|
||||
public CodeReturnStatement (CodeExpression expression)
|
||||
{
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
CodeExpression Expression {
|
||||
get {
|
||||
return expression;
|
||||
}
|
||||
|
||||
set {
|
||||
expression = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
//
|
||||
// System.CodeDom CodeObject class implementation
|
||||
//
|
||||
// Author:
|
||||
// Sean MacIsaac ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
|
||||
public class CodeObject {
|
||||
|
||||
}
|
||||
@@ -1,12 +1,47 @@
|
||||
//
|
||||
// System.CodeDom CodeStatement class implementation
|
||||
// System.CodeDom CodeStatement Class implementation
|
||||
//
|
||||
// Author:
|
||||
// Sean MacIsaac (macisaac@ximian.com)
|
||||
// Miguel de Icaza (miguel@ximian.com)
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
|
||||
public class CodeStatement : CodeObject {
|
||||
namespace System.CodeDom {
|
||||
|
||||
public class CodeStatement {
|
||||
|
||||
CodeLinePragma codeLinePragma;
|
||||
object userData;
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public CodeStatement ()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
public CodeLinePragma LinePragma {
|
||||
get {
|
||||
return codeLinePragma;
|
||||
}
|
||||
|
||||
set {
|
||||
codeLinePragma = value;
|
||||
}
|
||||
}
|
||||
|
||||
public object UserData {
|
||||
get {
|
||||
return userData;
|
||||
}
|
||||
|
||||
set {
|
||||
userData = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
//
|
||||
// System.CodeDom CodeTypeDeclaration Class implementation
|
||||
//
|
||||
// Author:
|
||||
// Sean MacIsaac ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
|
||||
public class CodeTypeDeclaration : CodeTypeMember {
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// System.CodeDom CodeTypeMember Class implementation
|
||||
//
|
||||
// Author:
|
||||
// Sean MacIsaac ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
|
||||
public class CodeTypeMember : CodeObject {
|
||||
private string name;
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return name;
|
||||
}
|
||||
set {
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
//
|
||||
// System.CodeDom FieldDirection Enum implementation
|
||||
//
|
||||
// Author:
|
||||
// Sean MacIsaac ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
|
||||
namespace System.CodeDom {
|
||||
public enum FieldDirection {
|
||||
In, Out, Ref
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// System.CodeDom MemberAttributes Enum implementation
|
||||
//
|
||||
// Author:
|
||||
// Sean MacIsaac ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
|
||||
namespace System.CodeDom {
|
||||
public enum MemberAttributes {
|
||||
Abstract,
|
||||
AccessMask,
|
||||
Assembly,
|
||||
Const,
|
||||
Family,
|
||||
FamilyAndAssembly,
|
||||
FamilyOrAssembly,
|
||||
Final,
|
||||
New,
|
||||
Overloaded,
|
||||
Override,
|
||||
Private,
|
||||
Public,
|
||||
ScopeMask,
|
||||
Static,
|
||||
VTableMask
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
CodeArrayCreateExpression.cs
|
||||
CodeAssignStatement.cs
|
||||
CodeAttachEventStatement.cs
|
||||
CodeAttributeArgument.cs
|
||||
CodeAttributeArgumentCollection.cs
|
||||
CodeAttributeBlock.cs
|
||||
CodeAttributeDeclaration.cs
|
||||
CodeAttributeDeclarationCollection.cs
|
||||
CodeBaseReferenceExpression.cs
|
||||
CodeBinaryOperatorExpression.cs
|
||||
CodeBinaryOperatorType.cs
|
||||
CodeCastExpression.cs
|
||||
CodeCatchClause.cs
|
||||
CodeCatchClauseCollection.cs
|
||||
CodeClass.cs
|
||||
CodeClassCollection.cs
|
||||
CodeClassConstructor.cs
|
||||
CodeClassDelegate.cs
|
||||
CodeClassMember.cs
|
||||
CodeClassMemberCollection.cs
|
||||
CodeCommentStatement.cs
|
||||
CodeConstructor.cs
|
||||
CodeDelegateCreateExpression.cs
|
||||
CodeDelegateInvokeExpression.cs
|
||||
CodeDelegateInvokeStatement.cs
|
||||
CodeDetachEventStatement.cs
|
||||
CodeExpression.cs
|
||||
CodeExpressionCollection.cs
|
||||
CodeFieldReferenceExpression.cs
|
||||
CodeForLoopStatement.cs
|
||||
CodeIfStatement.cs
|
||||
CodeIndexerExpression.cs
|
||||
CodeLinePragma.cs
|
||||
CodeLiteralClassMember.cs
|
||||
CodeLiteralExpression.cs
|
||||
CodeLiteralNamespace.cs
|
||||
CodeLiteralStatement.cs
|
||||
CodeMemberEvent.cs
|
||||
CodeMemberField.cs
|
||||
CodeMemberMethod.cs
|
||||
CodeMemberProperty.cs
|
||||
CodeMethodInvokeExpression.cs
|
||||
CodeMethodInvokeStatement.cs
|
||||
CodeMethodReturnStatement.cs
|
||||
CodeNamespace.cs
|
||||
CodeNamespaceImport.cs
|
||||
CodeNamespaceImportCollection.cs
|
||||
CodeObject.cs
|
||||
CodeObjectCreateExpression.cs
|
||||
CodeParameterDeclarationExpression.cs
|
||||
CodeParameterDeclarationExpressionCollection.cs
|
||||
CodePrimitiveExpression.cs
|
||||
CodePropertyReferenceExpression.cs
|
||||
CodeStatement.cs
|
||||
CodeStatementCollection.cs
|
||||
CodeThisReferenceExpression.cs
|
||||
CodeThrowExceptionStatement.cs
|
||||
CodeTryCatchFinallyStatement.cs
|
||||
CodeTypeDeclaration.cs
|
||||
CodeTypeMember.cs
|
||||
CodeTypeOfExpression.cs
|
||||
CodeTypeReferenceExpression.cs
|
||||
CodeVariableDeclarationStatement.cs
|
||||
FieldDirection.cs
|
||||
MemberAttributes.cs
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
CodeClassCollection.cs: Code-X-Collection.cs
|
||||
sed -e 's/@CONTAINEE@/Class/g' -e 's/@arrayname@/classes/g' < Code-X-Collection.cs > CodeClassCollection.cs
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
dx ()
|
||||
{
|
||||
sed -e "s/@CONTAINEE@/$1/g" -e "s/@arrayname@/$2/g" < Code-X-Collection.cs > Code$1Collection.cs
|
||||
}
|
||||
|
||||
dx AttributeArgument attributeArgs
|
||||
dx AttributeDeclaration attributeDecls
|
||||
dx CatchClause catchClauses
|
||||
dx Class classes
|
||||
dx ClassMember classMembers
|
||||
dx Expression expressions
|
||||
dx NamespaceImport namespaceImports
|
||||
dx ParameterDeclarationExpression parameterDeclExprs
|
||||
dx Statement statements
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1,4 +0,0 @@
|
||||
2001-07-15 Sean MacIsaac <[email protected]>
|
||||
|
||||
* StringCollection.cs: Added so that CodeDom.* would compile.
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
//
|
||||
// System.Collections.Specialized.StringCollection.cs
|
||||
//
|
||||
// Author:
|
||||
// Sean MacIsaac ([email protected])
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
namespace System.Collections.Specialized {
|
||||
|
||||
public class StringCollection {
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
BitVector32.cs
|
||||
StringCollection.cs
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1,8 +0,0 @@
|
||||
AuthenticationManager.cs
|
||||
Authorization.cs
|
||||
EndPoint.cs
|
||||
IAuthenticationModule.cs
|
||||
ICredentialLookup.cs
|
||||
IPAdress.cs
|
||||
IPEndPoint.cs
|
||||
SocketAddress.cs
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1,16 +1,4 @@
|
||||
DIRS=System.CodeDom System.CodeDom.Compiler System.Collections.Specialized
|
||||
all: windows
|
||||
|
||||
all:
|
||||
@echo "You must use 'make windows' or 'make unix'."
|
||||
@echo "'make unix' is broken for now."
|
||||
|
||||
windows: make-list
|
||||
$(CSC) /target:library /out:System.dll /nowarn:1595 @list
|
||||
|
||||
unix:
|
||||
@echo "'make unix' is broken for now."
|
||||
|
||||
make-list:
|
||||
for i in $(DIRS); do \
|
||||
cat $$i/common.src $$i/windows.src | sed "s/^/$$i\\\\/"; \
|
||||
done > list
|
||||
windows:
|
||||
$(csc) /target:library /out:System.dll /nowarn:1595 /recurse:*.cs
|
||||
@@ -1,2 +0,0 @@
|
||||
corlib.dll
|
||||
list
|
||||
@@ -1,7 +1,3 @@
|
||||
2001-07-15 Sean MacIsaac <[email protected]>
|
||||
|
||||
* IDictionary.cs: Clear was clear.
|
||||
|
||||
2001-07-13 Miguel de Icaza <[email protected]>
|
||||
|
||||
* All files: Renamespace things to System.
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace System.Collections {
|
||||
|
||||
void Add (object key, object value);
|
||||
|
||||
void Clear ();
|
||||
void clear ();
|
||||
|
||||
bool Contains (object key);
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
ArrayList.cs
|
||||
ICollection.cs
|
||||
IComparer.cs
|
||||
IDictionary.cs
|
||||
IDictionaryEnumerator.cs
|
||||
IEnumerable.cs
|
||||
IEnumerator.cs
|
||||
IHashCodeProvider.cs
|
||||
IList.cs
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1 +0,0 @@
|
||||
UnicodeCategory.cs
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1,4 +1,3 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Text.Encoding.cs
|
||||
//
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Text.StringBuilder
|
||||
//
|
||||
@@ -14,551 +13,551 @@
|
||||
//
|
||||
|
||||
namespace System.Text {
|
||||
public sealed class StringBuilder {
|
||||
public sealed class StringBuilder {
|
||||
|
||||
const int defaultCapacity = 16;
|
||||
const int defaultCapacity = 16;
|
||||
|
||||
private int sCapacity;
|
||||
private int sLength;
|
||||
private char[] sString;
|
||||
private int sCapacity;
|
||||
private int sLength;
|
||||
private char[] sString;
|
||||
|
||||
public StringBuilder() {
|
||||
public StringBuilder() {
|
||||
|
||||
// The MS Implementation uses the default
|
||||
// capacity for a StringBuilder. The spec
|
||||
// says it's up to the implementer, but
|
||||
// we'll do it the MS way just in case.
|
||||
|
||||
sString = new char[ defaultCapacity ];
|
||||
sCapacity = defaultCapacity;
|
||||
sLength = 0;
|
||||
}
|
||||
// The MS Implementation uses the default
|
||||
// capacity for a StringBuilder. The spec
|
||||
// says it's up to the implementer, but
|
||||
// we'll do it the MS way just in case.
|
||||
|
||||
sString = new char[ defaultCapacity ];
|
||||
sCapacity = defaultCapacity;
|
||||
sLength = 0;
|
||||
}
|
||||
|
||||
public StringBuilder( int capacity ) {
|
||||
if( capacity < defaultCapacity ) {
|
||||
// The spec says that the capacity
|
||||
// has to be at least the default capacity
|
||||
capacity = defaultCapacity;
|
||||
}
|
||||
public StringBuilder( int capacity ) {
|
||||
if( capacity < defaultCapacity ) {
|
||||
// The spec says that the capacity
|
||||
// has to be at least the default capacity
|
||||
capacity = defaultCapacity;
|
||||
}
|
||||
|
||||
sString = new char[capacity];
|
||||
sCapacity = capacity;
|
||||
sLength = 0;
|
||||
}
|
||||
sString = new char[capacity];
|
||||
sCapacity = capacity;
|
||||
sLength = 0;
|
||||
}
|
||||
|
||||
public StringBuilder( string str ) {
|
||||
|
||||
if( str.Length < defaultCapacity ) {
|
||||
char[] tString = str.ToCharArray();
|
||||
sString = new char[ defaultCapacity ];
|
||||
Array.Copy( tString, sString, str.Length );
|
||||
sLength = str.Length;
|
||||
sCapacity = defaultCapacity;
|
||||
} else {
|
||||
sString = str.ToCharArray();
|
||||
sCapacity = sString.Length;
|
||||
sLength = sString.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public int Capacity {
|
||||
get {
|
||||
return sCapacity;
|
||||
}
|
||||
public StringBuilder( string str ) {
|
||||
|
||||
if( str.Length < defaultCapacity ) {
|
||||
char[] tString = str.ToCharArray();
|
||||
sString = new char[ defaultCapacity ];
|
||||
Array.Copy( tString, sString, str.Length );
|
||||
sLength = str.Length;
|
||||
sCapacity = defaultCapacity;
|
||||
} else {
|
||||
sString = str.ToCharArray();
|
||||
sCapacity = sString.Length;
|
||||
sLength = sString.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public int Capacity {
|
||||
get {
|
||||
return sCapacity;
|
||||
}
|
||||
|
||||
set {
|
||||
if( value < sLength ) {
|
||||
throw new ArgumentException( "Capacity must be > length" );
|
||||
} else {
|
||||
char[] tString = new char[value];
|
||||
Array.Copy( sString, tString, sLength );
|
||||
sString = tString;
|
||||
sCapacity = sString.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
set {
|
||||
if( value < sLength ) {
|
||||
throw new ArgumentException( "Capacity must be > length" );
|
||||
} else {
|
||||
char[] tString = new char[value];
|
||||
Array.Copy( sString, tString, sLength );
|
||||
sString = tString;
|
||||
sCapacity = sString.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int Length {
|
||||
get {
|
||||
return sLength;
|
||||
}
|
||||
public int Length {
|
||||
get {
|
||||
return sLength;
|
||||
}
|
||||
|
||||
set {
|
||||
if( value < 0 || value > Int32.MaxValue) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
} else {
|
||||
if( value < sLength ) {
|
||||
// Truncate current string at value
|
||||
set {
|
||||
if( value < 0 || value > Int32.MaxValue) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
} else {
|
||||
if( value < sLength ) {
|
||||
// Truncate current string at value
|
||||
|
||||
// LAMESPEC: The spec is unclear as to what to do
|
||||
// with the capacity when truncating the string.
|
||||
//
|
||||
// Don't change the capacity, as this is what
|
||||
// the MS implementation does.
|
||||
// LAMESPEC: The spec is unclear as to what to do
|
||||
// with the capacity when truncating the string.
|
||||
//
|
||||
// Don't change the capacity, as this is what
|
||||
// the MS implementation does.
|
||||
|
||||
sLength = value;
|
||||
} else {
|
||||
// Expand the capacity to the new length and
|
||||
// pad the string with spaces.
|
||||
|
||||
// LAMESPEC: The spec says to put the spaces on the
|
||||
// left of the string however the MS implementation
|
||||
// puts them on the right. We'll do that for
|
||||
// compatibility (!)
|
||||
sLength = value;
|
||||
} else {
|
||||
// Expand the capacity to the new length and
|
||||
// pad the string with spaces.
|
||||
|
||||
// LAMESPEC: The spec says to put the spaces on the
|
||||
// left of the string however the MS implementation
|
||||
// puts them on the right. We'll do that for
|
||||
// compatibility (!)
|
||||
|
||||
char[] tString = new char[ value ];
|
||||
int padLength = value - sLength;
|
||||
|
||||
string padding = new String( ' ', padLength );
|
||||
Array.Copy( sString, tString, sLength );
|
||||
Array.Copy( padding.ToCharArray(), 0, tString, sLength, padLength );
|
||||
sString = tString;
|
||||
sLength = sString.Length;
|
||||
sCapacity = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
char[] tString = new char[ value ];
|
||||
int padLength = value - sLength;
|
||||
|
||||
string padding = new String( ' ', padLength );
|
||||
Array.Copy( sString, tString, sLength );
|
||||
Array.Copy( padding.ToCharArray(), 0, tString, sLength, padLength );
|
||||
sString = tString;
|
||||
sLength = sString.Length;
|
||||
sCapacity = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public char this[ int index ] {
|
||||
get {
|
||||
public char this[ int index ] {
|
||||
get {
|
||||
|
||||
if( index >= sLength || index < 0 ) {
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return sString[ index ];
|
||||
}
|
||||
if( index >= sLength || index < 0 ) {
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return sString[ index ];
|
||||
}
|
||||
|
||||
set {
|
||||
if( index >= sLength || index < 0 ) {
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
sString[ index ] = value;
|
||||
}
|
||||
}
|
||||
set {
|
||||
if( index >= sLength || index < 0 ) {
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
sString[ index ] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return ToString(0, sLength);
|
||||
}
|
||||
public override string ToString() {
|
||||
return ToString(0, sLength);
|
||||
}
|
||||
|
||||
public string ToString( int startIndex, int length ) {
|
||||
if( startIndex < 0 || length < 0 || startIndex + length > sLength ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
return new String( sString, startIndex, length );
|
||||
}
|
||||
public string ToString( int startIndex, int length ) {
|
||||
if( startIndex < 0 || length < 0 || startIndex + length > sLength ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
return new String( sString, startIndex, length );
|
||||
}
|
||||
|
||||
public int EnsureCapacity( int capacity ) {
|
||||
if( capacity < 0 ) {
|
||||
throw new ArgumentOutOfRangeException(
|
||||
public int EnsureCapacity( int capacity ) {
|
||||
if( capacity < 0 ) {
|
||||
throw new ArgumentOutOfRangeException(
|
||||
"Capacity must be greater than 0." );
|
||||
}
|
||||
}
|
||||
|
||||
if( capacity <= sCapacity ) {
|
||||
return sCapacity;
|
||||
} else {
|
||||
Capacity = capacity;
|
||||
return sCapacity;
|
||||
}
|
||||
}
|
||||
if( capacity <= sCapacity ) {
|
||||
return sCapacity;
|
||||
} else {
|
||||
Capacity = capacity;
|
||||
return sCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals( StringBuilder sb ) {
|
||||
if( this.ToString() == sb.ToString() ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool Equals( StringBuilder sb ) {
|
||||
if( this.ToString() == sb.ToString() ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public StringBuilder Remove( int startIndex, int length ) {
|
||||
if( startIndex < 0 || length < 0 || startIndex + length > sLength ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
public StringBuilder Remove( int startIndex, int length ) {
|
||||
if( startIndex < 0 || length < 0 || startIndex + length > sLength ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
// Copy everything after the 'removed' part to the start
|
||||
// Copy everything after the 'removed' part to the start
|
||||
// of the removed part and truncate the sLength
|
||||
|
||||
Array.Copy( sString, startIndex + length, sString,
|
||||
Array.Copy( sString, startIndex + length, sString,
|
||||
startIndex, length );
|
||||
|
||||
sLength -= length;
|
||||
return this;
|
||||
}
|
||||
sLength -= length;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder Replace( char oldChar, char newChar ) {
|
||||
|
||||
return Replace( oldChar, newChar, 0, sLength);
|
||||
}
|
||||
public StringBuilder Replace( char oldChar, char newChar ) {
|
||||
|
||||
return Replace( oldChar, newChar, 0, sLength);
|
||||
}
|
||||
|
||||
public StringBuilder Replace( char oldChar, char newChar, int startIndex, int count ) {
|
||||
if( startIndex + count > sLength || startIndex < 0 || count < 0 ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
public StringBuilder Replace( char oldChar, char newChar, int startIndex, int count ) {
|
||||
if( startIndex + count > sLength || startIndex < 0 || count < 0 ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
for( int replaceIterate = startIndex; replaceIterate < startIndex + count; replaceIterate++ ) {
|
||||
if( this[replaceIterate] == oldChar ) {
|
||||
this[replaceIterate] = newChar;
|
||||
}
|
||||
}
|
||||
for( int replaceIterate = startIndex; replaceIterate < startIndex + count; replaceIterate++ ) {
|
||||
if( this[replaceIterate] == oldChar ) {
|
||||
this[replaceIterate] = newChar;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder Replace( string oldValue, string newValue ) {
|
||||
return Replace( oldValue, newValue, 0, sLength );
|
||||
}
|
||||
public StringBuilder Replace( string oldValue, string newValue ) {
|
||||
return Replace( oldValue, newValue, 0, sLength );
|
||||
}
|
||||
|
||||
public StringBuilder Replace( string oldValue, string newValue, int startIndex, int count ) {
|
||||
string startString = this.ToString();
|
||||
StringBuilder newStringB = new StringBuilder();
|
||||
string newString;
|
||||
public StringBuilder Replace( string oldValue, string newValue, int startIndex, int count ) {
|
||||
string startString = this.ToString();
|
||||
StringBuilder newStringB = new StringBuilder();
|
||||
string newString;
|
||||
|
||||
if( oldValue == null ) {
|
||||
throw new ArgumentNullException(
|
||||
if( oldValue == null ) {
|
||||
throw new ArgumentNullException(
|
||||
"The old value cannot be null.");
|
||||
}
|
||||
}
|
||||
|
||||
if( startIndex < 0 || count < 0 || startIndex + count > sLength ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
if( startIndex < 0 || count < 0 || startIndex + count > sLength ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
if( oldValue.Length == 0 ) {
|
||||
throw new ArgumentException(
|
||||
if( oldValue.Length == 0 ) {
|
||||
throw new ArgumentException(
|
||||
"The old value cannot be zero length.");
|
||||
}
|
||||
}
|
||||
|
||||
int nextIndex = startIndex; // Where to start the next search
|
||||
int lastIndex = nextIndex; // Where the last search finished
|
||||
int nextIndex = startIndex; // Where to start the next search
|
||||
int lastIndex = nextIndex; // Where the last search finished
|
||||
|
||||
while( nextIndex != -1 ) {
|
||||
nextIndex = startString.IndexOf( oldValue, lastIndex);
|
||||
if( nextIndex != -1 ) {
|
||||
// The MS implementation won't replace a substring
|
||||
while( nextIndex != -1 ) {
|
||||
nextIndex = startString.IndexOf( oldValue, lastIndex);
|
||||
if( nextIndex != -1 ) {
|
||||
// The MS implementation won't replace a substring
|
||||
// if that substring goes over the "count"
|
||||
// boundary, so we'll make sure the behaviour
|
||||
// here is the same.
|
||||
|
||||
if( nextIndex + oldValue.Length < startIndex + count ) {
|
||||
if( nextIndex + oldValue.Length < startIndex + count ) {
|
||||
|
||||
// Add everything to the left of the old
|
||||
// Add everything to the left of the old
|
||||
// string
|
||||
newStringB.Append( startString.Substring( lastIndex, nextIndex - lastIndex ) );
|
||||
|
||||
// Add the replacement string
|
||||
newStringB.Append( newValue );
|
||||
|
||||
// Set the next start point to the
|
||||
newStringB.Append( startString.Substring( lastIndex, nextIndex - lastIndex ) );
|
||||
|
||||
// Add the replacement string
|
||||
newStringB.Append( newValue );
|
||||
|
||||
// Set the next start point to the
|
||||
// end of the last match
|
||||
lastIndex = nextIndex + oldValue.Length;
|
||||
} else {
|
||||
// We're past the "count" we're supposed to replace within
|
||||
nextIndex = -1;
|
||||
newStringB.Append(
|
||||
lastIndex = nextIndex + oldValue.Length;
|
||||
} else {
|
||||
// We're past the "count" we're supposed to replace within
|
||||
nextIndex = -1;
|
||||
newStringB.Append(
|
||||
startString.Substring( lastIndex ) );
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Append everything left over
|
||||
newStringB.Append( startString.Substring( lastIndex ) );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Append everything left over
|
||||
newStringB.Append( startString.Substring( lastIndex ) );
|
||||
}
|
||||
}
|
||||
|
||||
newString = newStringB.ToString();
|
||||
newString = newStringB.ToString();
|
||||
|
||||
EnsureCapacity( newString.Length );
|
||||
sString = newString.ToCharArray();
|
||||
sLength = newString.Length;
|
||||
return this;
|
||||
}
|
||||
EnsureCapacity( newString.Length );
|
||||
sString = newString.ToCharArray();
|
||||
sLength = newString.Length;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/* The Append Methods */
|
||||
|
||||
/* The Append Methods */
|
||||
|
||||
// TODO: Currently most of these methods convert the
|
||||
// parameter to a CharArray (via a String) and then pass
|
||||
// it to Append( char[] ). There might be a faster way
|
||||
// of doing this, but it's probably adequate and anything else
|
||||
// would make it too messy.
|
||||
//
|
||||
// As an example, a sample test run of appending a 100 character
|
||||
// string to the StringBuilder, and loooping this 50,000 times
|
||||
// results in an elapsed time of 2.4s using the MS StringBuilder
|
||||
// and 2.7s using this StringBuilder. Note that this results
|
||||
// in a 5 million character string. I believe MS uses a lot
|
||||
// of "native" DLLs for the "meat" of the base classes.
|
||||
// TODO: Currently most of these methods convert the
|
||||
// parameter to a CharArray (via a String) and then pass
|
||||
// it to Append( char[] ). There might be a faster way
|
||||
// of doing this, but it's probably adequate and anything else
|
||||
// would make it too messy.
|
||||
//
|
||||
// As an example, a sample test run of appending a 100 character
|
||||
// string to the StringBuilder, and loooping this 50,000 times
|
||||
// results in an elapsed time of 2.4s using the MS StringBuilder
|
||||
// and 2.7s using this StringBuilder. Note that this results
|
||||
// in a 5 million character string. I believe MS uses a lot
|
||||
// of "native" DLLs for the "meat" of the base classes.
|
||||
|
||||
|
||||
public StringBuilder Append( char[] value ) {
|
||||
if( sLength + value.Length > sCapacity ) {
|
||||
// Need more capacity, double the capacity StringBuilder
|
||||
// and make sure we have at least enough for the value
|
||||
// if that's going to go over double.
|
||||
|
||||
Capacity = value.Length + ( sCapacity + sCapacity);
|
||||
}
|
||||
public StringBuilder Append( char[] value ) {
|
||||
if( sLength + value.Length > sCapacity ) {
|
||||
// Need more capacity, double the capacity StringBuilder
|
||||
// and make sure we have at least enough for the value
|
||||
// if that's going to go over double.
|
||||
|
||||
Capacity = value.Length + ( sCapacity + sCapacity);
|
||||
}
|
||||
|
||||
Array.Copy( value, 0, sString, sLength, value.Length );
|
||||
sLength += value.Length;
|
||||
Array.Copy( value, 0, sString, sLength, value.Length );
|
||||
sLength += value.Length;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder Append( string value ) {
|
||||
if( value != null ) {
|
||||
return Append( value.ToCharArray() );
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder Append( string value ) {
|
||||
if( value != null ) {
|
||||
return Append( value.ToCharArray() );
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public StringBuilder Append( bool value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( byte value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( bool value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( byte value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( int index, char value) {
|
||||
char[] appendChar = new char[1];
|
||||
|
||||
appendChar[0] = value;
|
||||
return Append( appendChar );
|
||||
}
|
||||
public StringBuilder Append( int index, char value) {
|
||||
char[] appendChar = new char[1];
|
||||
|
||||
appendChar[0] = value;
|
||||
return Append( appendChar );
|
||||
}
|
||||
|
||||
|
||||
public StringBuilder Append( decimal value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( decimal value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( double value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( double value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( short value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( short value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( int value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( int value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( long value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( long value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( object value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( object value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( sbyte value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( sbyte value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( float value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( float value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( ushort value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( uint value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( ushort value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( uint value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( ulong value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Append( ulong value ) {
|
||||
return Append( value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Append( char value, int repeatCount ) {
|
||||
if( repeatCount < 0 ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
public StringBuilder Append( char value, int repeatCount ) {
|
||||
if( repeatCount < 0 ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
return Append( new String( value, repeatCount) );
|
||||
}
|
||||
return Append( new String( value, repeatCount) );
|
||||
}
|
||||
|
||||
public StringBuilder Append( char[] value, int startIndex, int charCount ) {
|
||||
public StringBuilder Append( char[] value, int startIndex, int charCount ) {
|
||||
|
||||
if( (charCount < 0 || startIndex < 0) ||
|
||||
( charCount + startIndex > value.Length ) ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
if( value == null ) {
|
||||
if( !(startIndex == 0 && charCount == 0) ) {
|
||||
throw new ArgumentNullException();
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
} else {
|
||||
char[] appendChars = new char[ charCount ];
|
||||
|
||||
Array.Copy( value, startIndex, appendChars, 0, charCount );
|
||||
return Append( appendChars );
|
||||
}
|
||||
}
|
||||
if( (charCount < 0 || startIndex < 0) ||
|
||||
( charCount + startIndex > value.Length ) ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
if( value == null ) {
|
||||
if( !(startIndex == 0 && charCount == 0) ) {
|
||||
throw new ArgumentNullException();
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
} else {
|
||||
char[] appendChars = new char[ charCount ];
|
||||
|
||||
Array.Copy( value, startIndex, appendChars, 0, charCount );
|
||||
return Append( appendChars );
|
||||
}
|
||||
}
|
||||
|
||||
public StringBuilder Append( string value, int startIndex, int count ) {
|
||||
if( (count < 0 || startIndex < 0) ||
|
||||
public StringBuilder Append( string value, int startIndex, int count ) {
|
||||
if( (count < 0 || startIndex < 0) ||
|
||||
( startIndex + count > value.Length ) ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
return Append( value.Substring( startIndex, count ).ToCharArray() );
|
||||
}
|
||||
return Append( value.Substring( startIndex, count ).ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder AppendFormat( string format, object arg0 ) {
|
||||
// TODO: Implement
|
||||
return this;
|
||||
}
|
||||
public StringBuilder AppendFormat( string format, object arg0 ) {
|
||||
// TODO: Implement
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder AppendFormat( string format, params object[] args ) {
|
||||
// TODO: Implement
|
||||
return this;
|
||||
}
|
||||
public StringBuilder AppendFormat( string format, params object[] args ) {
|
||||
// TODO: Implement
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder AppendFormat( IFormatProvider provider, string format,
|
||||
params object[] args ) {
|
||||
// TODO: Implement
|
||||
return this;
|
||||
}
|
||||
public StringBuilder AppendFormat( IFormatProvider provider, string format,
|
||||
params object[] args ) {
|
||||
// TODO: Implement
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder AppendFormat( string format, object arg0, object arg1 ) {
|
||||
// TODO: Implement;
|
||||
return this;
|
||||
}
|
||||
public StringBuilder AppendFormat( string format, object arg0, object arg1 ) {
|
||||
// TODO: Implement;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder AppendFormat( string format, object arg0, object arg1, object arg2 ) {
|
||||
// TODO Implement
|
||||
return this;
|
||||
}
|
||||
public StringBuilder AppendFormat( string format, object arg0, object arg1, object arg2 ) {
|
||||
// TODO Implement
|
||||
return this;
|
||||
}
|
||||
|
||||
/* The Insert Functions */
|
||||
|
||||
// Similarly to the Append functions, get everything down to a CharArray
|
||||
// and insert that.
|
||||
|
||||
public StringBuilder Insert( int index, char[] value ) {
|
||||
if( index > sLength || index < 0) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
/* The Insert Functions */
|
||||
|
||||
// Similarly to the Append functions, get everything down to a CharArray
|
||||
// and insert that.
|
||||
|
||||
public StringBuilder Insert( int index, char[] value ) {
|
||||
if( index > sLength || index < 0) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
if( value == null || value.Length == 0 ) {
|
||||
return this;
|
||||
} else {
|
||||
// Check we have the capacity to insert this array
|
||||
if( sCapacity < sLength + value.Length ) {
|
||||
Capacity = value.Length + ( sCapacity + sCapacity );
|
||||
}
|
||||
if( value == null || value.Length == 0 ) {
|
||||
return this;
|
||||
} else {
|
||||
// Check we have the capacity to insert this array
|
||||
if( sCapacity < sLength + value.Length ) {
|
||||
Capacity = value.Length + ( sCapacity + sCapacity );
|
||||
}
|
||||
|
||||
// Move everything to the right of the insert point across
|
||||
Array.Copy( sString, index, sString, index + value.Length, sLength - index);
|
||||
|
||||
// Copy in stuff from the insert buffer
|
||||
Array.Copy( value, 0, sString, index, value.Length );
|
||||
|
||||
sLength += value.Length;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, string value ) {
|
||||
return Insert( index, value.ToCharArray() );
|
||||
}
|
||||
// Move everything to the right of the insert point across
|
||||
Array.Copy( sString, index, sString, index + value.Length, sLength - index);
|
||||
|
||||
// Copy in stuff from the insert buffer
|
||||
Array.Copy( value, 0, sString, index, value.Length );
|
||||
|
||||
sLength += value.Length;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, string value ) {
|
||||
return Insert( index, value.ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, bool value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, byte value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Insert( int index, bool value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, byte value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, char value) {
|
||||
char[] insertChar = new char[1];
|
||||
|
||||
insertChar[0] = value;
|
||||
return Insert( index, insertChar );
|
||||
}
|
||||
public StringBuilder Insert( int index, char value) {
|
||||
char[] insertChar = new char[1];
|
||||
|
||||
insertChar[0] = value;
|
||||
return Insert( index, insertChar );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, decimal value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Insert( int index, decimal value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, double value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, short value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Insert( int index, double value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, short value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, int value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Insert( int index, int value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, long value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, object value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Insert( int index, long value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, object value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, sbyte value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Insert( int index, sbyte value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, float value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Insert( int index, float value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, ushort value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Insert( int index, ushort value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, uint value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Insert( int index, uint value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, ulong value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
public StringBuilder Insert( int index, ulong value ) {
|
||||
return Insert( index, value.ToString().ToCharArray() );
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, string value, int count ) {
|
||||
if ( count < 0 ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
public StringBuilder Insert( int index, string value, int count ) {
|
||||
if ( count < 0 ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
if( value != null ) {
|
||||
if( value != "" ) {
|
||||
for( int insertCount = 0; insertCount < count;
|
||||
if( value != null ) {
|
||||
if( value != "" ) {
|
||||
for( int insertCount = 0; insertCount < count;
|
||||
insertCount++ ) {
|
||||
Insert( index, value.ToCharArray() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
Insert( index, value.ToCharArray() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder Insert( int index, char[] value, int startIndex,
|
||||
public StringBuilder Insert( int index, char[] value, int startIndex,
|
||||
int charCount ) {
|
||||
|
||||
if( value != null ) {
|
||||
if( charCount < 0 || startIndex < 0 || startIndex + charCount > value.Length ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
char[] insertChars = new char[ charCount ];
|
||||
Array.Copy( value, startIndex, insertChars, 0, charCount );
|
||||
return Insert( index, insertChars );
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( value != null ) {
|
||||
if( charCount < 0 || startIndex < 0 || startIndex + charCount > value.Length ) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
char[] insertChars = new char[ charCount ];
|
||||
Array.Copy( value, startIndex, insertChars, 0, charCount );
|
||||
return Insert( index, insertChars );
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
//
|
||||
// System.Text.UnicodeEncoding.cs
|
||||
//
|
||||
@@ -44,3 +43,4 @@ namespace System.Text {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
ASCIIEncoding.cs
|
||||
Encoding.cs
|
||||
StringBuilder.cs
|
||||
UTF7Encoding.cs
|
||||
UTF8Encoding.cs
|
||||
UnicodeEncoding.cs
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1,41 +1,3 @@
|
||||
2001-07-15 Sean MacIsaac <[email protected]>
|
||||
|
||||
* String.cs: Spelling error of IComparable, object's
|
||||
MemberwiseClone cannot be overridden. Made indexer valid for now,
|
||||
but not sure what to do about this in the long run. Seems to be a
|
||||
couple bugs in csc.exe having to do with multiple pointer defs in
|
||||
the same statement, and returning subclasses of a class in the
|
||||
return type of an interface function implementation. Also moved
|
||||
operators inside of class definition.
|
||||
|
||||
2001-07-14 Jeffrey Stedfast <[email protected]>
|
||||
|
||||
* String.cs: A tom of compile fixes, although we still don't compile.
|
||||
|
||||
* IConvertible.cs: The To*Int64() methods return *Int64's, not
|
||||
*Int32's. Also, it's ToDateTime() not ToDateType().
|
||||
|
||||
2001-07-14 Jeffrey Stedfast <[email protected]>
|
||||
|
||||
* String.cs: Apparently I needed to at least write stubs for the
|
||||
IConvertible interfaces. *sigh*
|
||||
|
||||
2001-07-14 Jeffrey Stedfast <[email protected]>
|
||||
|
||||
* String.cs: Many logic/other fixes and better usage of the
|
||||
features of c#
|
||||
(tolower): New convenience method to help condense code.
|
||||
(toupper): Another new helper method.
|
||||
(Compare): Use the new helper methods.
|
||||
(ToLower): use tolower().
|
||||
(ToUpper): use toupper().
|
||||
(LastIndexOfAny): Implemented.
|
||||
(BoyerMoore): New private helper method that implements a modified
|
||||
version of the Boyer-Moore search algorithm. Noothing uses it yet
|
||||
as I'm not 100% sure it even works properly with unicode strings
|
||||
not to mention it uses a huge lookup-table :-)
|
||||
(Split): Implemented.
|
||||
|
||||
2001-07-13 Jeffrey Stedfast <[email protected]>
|
||||
|
||||
* TODO: Added things that need to be finished in System.String
|
||||
|
||||
@@ -16,18 +16,18 @@ namespace System {
|
||||
bool ToBoolean (IFormatProvider provider);
|
||||
byte ToByte (IFormatProvider provider);
|
||||
char ToChar (IFormatProvider provider);
|
||||
DateTime ToDateTime (IFormatProvider provider);
|
||||
DateTime ToDateType (IFormatProvider provider);
|
||||
Decimal ToDecimal (IFormatProvider provider);
|
||||
Double ToDouble (IFormatProvider provider);
|
||||
Int16 ToInt16 (IFormatProvider provider);
|
||||
Int32 ToInt32 (IFormatProvider provider);
|
||||
Int64 ToInt64 (IFormatProvider provider);
|
||||
Int32 ToInt64 (IFormatProvider provider);
|
||||
SByte ToSByte (IFormatProvider provider);
|
||||
float ToSingle (IFormatProvider provider);
|
||||
string ToString (IFormatProvider provider);
|
||||
object ToType (Type conversionType, IFormatProvider provider);
|
||||
UInt16 ToUInt16 (IFormatProvider provider);
|
||||
UInt32 ToUInt32 (IFormatProvider provider);
|
||||
UInt64 ToUInt64 (IFormatProvider provider);
|
||||
UInt32 ToUInt64 (IFormatProvider provider);
|
||||
}
|
||||
}
|
||||
+220
-474
File diff suppressed because it is too large.
Load diff
@@ -7,16 +7,6 @@ System.ValueType:
|
||||
C#, the problem is figuring out the size of the object.
|
||||
|
||||
System.String:
|
||||
Need to implement the Format() and CompareOrdinal() methods
|
||||
Need to implement the Format() and CompareOrdincal() methods
|
||||
as we all implement all of the methods that take into account
|
||||
CultureInfo or Encoding stuff.
|
||||
|
||||
System.Array:
|
||||
It's not possible to test to see if the whole thing works, as
|
||||
GetValue() and SetValue() make calls into the runtime. However,
|
||||
I've tried my implementations of things like BinarySearch() and
|
||||
Sort() on the MS-provided System.Array and they seem to work fine.
|
||||
According to the spec, System.Array implements the IList interface.
|
||||
The spec doesn't have the methods for those interfaces, however,
|
||||
the class doesn't (yet) implement that interface and those methods
|
||||
are not (yet) written.
|
||||
CultureInfo.
|
||||
@@ -1,44 +0,0 @@
|
||||
ApplicationException.cs
|
||||
ArgumentException.cs
|
||||
ArgumentNullException.cs
|
||||
ArgumentOutOfRangeException.cs
|
||||
ArithmeticException.cs
|
||||
Array.cs
|
||||
ArrayTypeMismatchException.cs
|
||||
DivideByZeroException.cs
|
||||
DuplicateWaitObjectException.cs
|
||||
Exception.cs
|
||||
ExecutionEngineException.cs
|
||||
FormatException.cs
|
||||
ICloneable.cs
|
||||
IComparable.cs
|
||||
IConvertible.cs
|
||||
ICustomFormatter.cs
|
||||
IDisposable.cs
|
||||
IFormatProvider.cs
|
||||
IFormattable.cs
|
||||
IndexOutOfRangeException.cs
|
||||
Int16.cs
|
||||
Int32.cs
|
||||
Int64.cs
|
||||
InvalidCastException.cs
|
||||
InvalidOperationException.cs
|
||||
InvalidProgramException.cs
|
||||
MulticastNotSupportedException.cs
|
||||
NotFiniteNumberException.cs
|
||||
NotSupportedException.cs
|
||||
NullReferenceException.cs
|
||||
Object.cs
|
||||
OutOfMemoryException.cs
|
||||
OverflowException.cs
|
||||
RankException.cs
|
||||
StackOverflowException.cs
|
||||
SystemException.cs
|
||||
TypeCode.cs
|
||||
TypeInitializationException.cs
|
||||
UInt16.cs
|
||||
UInt32.cs
|
||||
UInt64.cs
|
||||
ValueType.cs
|
||||
Version.cs
|
||||
Void.cs
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1,16 +1,4 @@
|
||||
DIRS=System System.Collections System.Globalization System.Net System.Text
|
||||
all: windows
|
||||
|
||||
all:
|
||||
@echo "You must use 'make windows' or 'make unix'."
|
||||
@echo "'make unix' is broken for now."
|
||||
|
||||
windows: make-list
|
||||
$(CSC) /unsafe /target:library /out:corlib.dll /nowarn:1595 @list
|
||||
|
||||
unix:
|
||||
@echo "'make unix' is broken for now."
|
||||
|
||||
make-list:
|
||||
for i in $(DIRS); do \
|
||||
cat $$i/common.src $$i/windows.src | sed "s/^/$$i\\\\/"; \
|
||||
done > list
|
||||
windows:
|
||||
$(csc) /target:library /out:corlib.dll /nowarn:1595 /recurse:*.cs
|
||||
+5
-10
@@ -1,14 +1,9 @@
|
||||
DIRS=corlib System
|
||||
CSC=//c/winnt/microsoft.net/framework/v1.0.2914/csc.exe
|
||||
SUBDIRS=corlib System
|
||||
csc=/c/winnt/microsoft.net/framework/v1.0.2914/csc.exe
|
||||
|
||||
all:
|
||||
@echo "You must use 'make windows' or 'make unix'."
|
||||
@echo "'make unix' is broken for now."
|
||||
all: windows
|
||||
|
||||
windows:
|
||||
for i in $(DIRS); do \
|
||||
(cd $$i; CSC=$(CSC) NUNIT_CONSOLE=NUnitConsole.exe PLATFORM=window make windows)\
|
||||
for subdir in $(SUBDIRS); do \
|
||||
cd $$subdir; csc=$(csc) make windows; cd ..; \
|
||||
done;
|
||||
|
||||
unix:
|
||||
@echo "'make unix' is broken for now."
|
||||
@@ -1,2 +0,0 @@
|
||||
jay
|
||||
jay.exe
|
||||
@@ -1,25 +0,0 @@
|
||||
Berkeley Yacc owes much to the unflagging efforts of Keith Bostic.
|
||||
His badgering kept me working on it long after I was ready to quit.
|
||||
|
||||
Berkeley Yacc is based on the excellent algorithm for computing LALR(1)
|
||||
lookaheads developed by Tom Pennello and Frank DeRemer. The algorithm is
|
||||
described in their almost impenetrable article in TOPLAS 4,4.
|
||||
|
||||
Finally, much of the credit for the latest version must go to those
|
||||
who pointed out deficiencies of my earlier releases. Among the most
|
||||
prolific contributors were
|
||||
|
||||
Benson I. Margulies
|
||||
Dave Gentzel
|
||||
Antoine Verheijen
|
||||
Peter S. Housel
|
||||
Dale Smith
|
||||
Ozan Yigit
|
||||
John Campbell
|
||||
Bill Sommerfeld
|
||||
Paul Hilfinger
|
||||
Gary Bridgewater
|
||||
Dave Bakken
|
||||
Dan Lanciani
|
||||
Richard Sargent
|
||||
Parag Patel
|
||||
@@ -1,9 +0,0 @@
|
||||
2001-07-15 Sean MacIsaac <[email protected]>
|
||||
|
||||
* makefile: added windows and unix targets.
|
||||
|
||||
2001-07-14 Sean MacIsaac <[email protected]>
|
||||
|
||||
* main.c: fixed error in command line flag -c if it was not first
|
||||
option.
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
The -r option has been implemented. The -r option tells Yacc to
|
||||
put the read-only tables in y.tab.c and the code and variables in
|
||||
y.code.c. Keith Bostic asked for this option so that :yyfix could be
|
||||
eliminated.
|
||||
|
||||
The -l and -t options have been implemented. The -l option tells
|
||||
Yacc not to include #line directives in the code it produces. The -t
|
||||
option causes debugging code to be included in the compiled parser.
|
||||
|
||||
The code for error recovery has been changed to implement the same
|
||||
algorithm as AT&T Yacc. There will still be differences in the way
|
||||
error recovery works because AT&T Yacc uses more default reductions
|
||||
than Berkeley Yacc.
|
||||
|
||||
The environment variable TMPDIR determines the directory where
|
||||
temporary files will be created. If TMPDIR is defined, temporary files
|
||||
will be created in the directory whose pathname is the value of TMPDIR.
|
||||
By default, temporary files are created in /tmp.
|
||||
|
||||
The keywords are now case-insensitive. For example, %nonassoc,
|
||||
%NONASSOC, %NonAssoc, and %nOnAsSoC are all equivalent.
|
||||
|
||||
Commas and semicolons that are not part of C code are treated as
|
||||
commentary.
|
||||
|
||||
Line-end comments, as in BCPL, are permitted. Line-end comments
|
||||
begin with // and end at the next end-of-line. Line-end comments are
|
||||
permitted in C code; they are converted to C comments on output.
|
||||
|
||||
The form of y.output files has been changed to look more like
|
||||
those produced by AT&T Yacc.
|
||||
|
||||
A new kind of declaration has been added. The form of the declaration
|
||||
is
|
||||
|
||||
%ident string
|
||||
|
||||
where string is a sequence of characters begining with a double quote
|
||||
and ending with either a double quote or the next end-of-line, whichever
|
||||
comes first. The declaration will cause a #ident directive to be written
|
||||
near the start of the output file.
|
||||
|
||||
If a parser has been compiled with debugging code, that code can be
|
||||
enabled by setting an environment variable. If the environment variable
|
||||
YYDEBUG is set to 0, debugging output is suppressed. If it is set to 1,
|
||||
debugging output is written to standard output.
|
||||
@@ -1,9 +0,0 @@
|
||||
Berkeley Yacc reflects its origins. The reason so many routines
|
||||
use exactly six register variables is that Berkeley Yacc was
|
||||
developed on a VAX using PCC. PCC placed at most six variables
|
||||
in registers. I went to considerable effort to find which six
|
||||
variables most belonged in registers. Changes in machines and
|
||||
compilers make that effort worthless, perhaps even harmful.
|
||||
|
||||
The code contains many instances where address calculations are
|
||||
performed in particular ways to optimize the code for the VAX.
|
||||
@@ -1,10 +0,0 @@
|
||||
This is a port of Jay to C#, the original Jay can be found here:
|
||||
http://www.informatik.uni-osnabrueck.de/bernd/jay/
|
||||
|
||||
This is a temporary solution as we move to a Bison-generated parser
|
||||
as it would provide better error recovery (and error productions
|
||||
are broken in my port of Jay).
|
||||
|
||||
The original README from Jay is in `README.jay'
|
||||
|
||||
Miguel
|
||||
@@ -1,55 +0,0 @@
|
||||
This version of Berkeley Yacc was taken from the BSD-Lite CD and targeted
|
||||
to Java by
|
||||
|
||||
[email protected]
|
||||
|
||||
Makefile -> makefile removed Berkeleyisms, call it jay
|
||||
defs.h eliminate -dlpr options, %union, output_file, #ident
|
||||
eliminate sekeleton.c references
|
||||
error.c eliminate %union
|
||||
main.c eliminate -dlpr options, %union, output_file
|
||||
output.c eliminate -dlpr options, %union, output_file
|
||||
fix #define, short, -t/yyDebug
|
||||
respell YYERRCODE, YYTABLESIZE, YYFINAL, YYMAXTOKEN
|
||||
output trailer last
|
||||
switch to filter behaviour
|
||||
reader.c eliminate output_file, #ident
|
||||
#line -> // line, pass //
|
||||
yyvsp[] -> yyVals[yyTop], yyval -> yyVal
|
||||
skeleton.c -> skeleton Java skeleton
|
||||
test removed
|
||||
yacc.1 -> jay.1 adapted
|
||||
yyfix.* removed
|
||||
|
||||
Types: there is a significant difference. yacc uses %union to cast the value
|
||||
stack and <tag> to select alternatives. This works for l- and r-values alike.
|
||||
jay uses Object as the value stack and <tag> to set a class. l-values must not
|
||||
be cast. $n should not be assigned to, but $$ usually is. $n is referenced,
|
||||
but $$ usually is not. Consequently jay casts $n and $<tag>$ but not $<>n
|
||||
and $$. This makes assignment to $n references to $$ kludgily possible.
|
||||
As another kludge, to prevent 'untyped' messages and to avoid unnecessary
|
||||
casts, casts to "Object" are not emitted.
|
||||
-------------------------------------------------------------------------------
|
||||
Berkeley Yacc is an LALR(1) parser generator. Berkeley Yacc has been made
|
||||
as compatible as possible with AT&T Yacc. Berkeley Yacc can accept any input
|
||||
specification that conforms to the AT&T Yacc documentation. Specifications
|
||||
that take advantage of undocumented features of AT&T Yacc will probably be
|
||||
rejected.
|
||||
|
||||
Berkeley Yacc is distributed with no warranty whatever. The code is certain
|
||||
to contain errors. Neither the author nor any contributor takes responsibility
|
||||
for any consequences of its use.
|
||||
|
||||
Berkeley Yacc is in the public domain. The data structures and algorithms
|
||||
used in Berkeley Yacc are all either taken from documents available to the
|
||||
general public or are inventions of the author. Anyone may freely distribute
|
||||
source or binary forms of Berkeley Yacc whether unchanged or modified.
|
||||
Distributers may charge whatever fees they can obtain for Berkeley Yacc.
|
||||
Programs generated by Berkeley Yacc may be distributed freely.
|
||||
|
||||
Please report bugs to
|
||||
|
||||
[email protected]
|
||||
|
||||
Include a small example if possible. Please include the banner string from
|
||||
skeleton.c with the bug report. Do not expect rapid responses.
|
||||
@@ -1,295 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Robert Paul Corbett.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)closure.c 5.3 (Berkeley) 5/24/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
short *itemset;
|
||||
short *itemsetend;
|
||||
unsigned *ruleset;
|
||||
|
||||
static unsigned *first_derives;
|
||||
static unsigned *EFF;
|
||||
|
||||
|
||||
set_EFF()
|
||||
{
|
||||
register unsigned *row;
|
||||
register int symbol;
|
||||
register short *sp;
|
||||
register int rowsize;
|
||||
register int i;
|
||||
register int rule;
|
||||
|
||||
rowsize = WORDSIZE(nvars);
|
||||
EFF = NEW2(nvars * rowsize, unsigned);
|
||||
|
||||
row = EFF;
|
||||
for (i = start_symbol; i < nsyms; i++)
|
||||
{
|
||||
sp = derives[i];
|
||||
for (rule = *sp; rule > 0; rule = *++sp)
|
||||
{
|
||||
symbol = ritem[rrhs[rule]];
|
||||
if (ISVAR(symbol))
|
||||
{
|
||||
symbol -= start_symbol;
|
||||
SETBIT(row, symbol);
|
||||
}
|
||||
}
|
||||
row += rowsize;
|
||||
}
|
||||
|
||||
reflexive_transitive_closure(EFF, nvars);
|
||||
|
||||
#ifdef DEBUG
|
||||
print_EFF();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
set_first_derives()
|
||||
{
|
||||
register unsigned *rrow;
|
||||
register unsigned *vrow;
|
||||
register int j;
|
||||
register unsigned k;
|
||||
register unsigned cword;
|
||||
register short *rp;
|
||||
|
||||
int rule;
|
||||
int i;
|
||||
int rulesetsize;
|
||||
int varsetsize;
|
||||
|
||||
rulesetsize = WORDSIZE(nrules);
|
||||
varsetsize = WORDSIZE(nvars);
|
||||
first_derives = NEW2(nvars * rulesetsize, unsigned) - ntokens * rulesetsize;
|
||||
|
||||
set_EFF();
|
||||
|
||||
rrow = first_derives + ntokens * rulesetsize;
|
||||
for (i = start_symbol; i < nsyms; i++)
|
||||
{
|
||||
vrow = EFF + ((i - ntokens) * varsetsize);
|
||||
k = BITS_PER_WORD;
|
||||
for (j = start_symbol; j < nsyms; k++, j++)
|
||||
{
|
||||
if (k >= BITS_PER_WORD)
|
||||
{
|
||||
cword = *vrow++;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (cword & (1 << k))
|
||||
{
|
||||
rp = derives[j];
|
||||
while ((rule = *rp++) >= 0)
|
||||
{
|
||||
SETBIT(rrow, rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vrow += varsetsize;
|
||||
rrow += rulesetsize;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
print_first_derives();
|
||||
#endif
|
||||
|
||||
FREE(EFF);
|
||||
}
|
||||
|
||||
|
||||
closure(nucleus, n)
|
||||
short *nucleus;
|
||||
int n;
|
||||
{
|
||||
register int ruleno;
|
||||
register unsigned word;
|
||||
register unsigned i;
|
||||
register short *csp;
|
||||
register unsigned *dsp;
|
||||
register unsigned *rsp;
|
||||
register int rulesetsize;
|
||||
|
||||
short *csend;
|
||||
unsigned *rsend;
|
||||
int symbol;
|
||||
int itemno;
|
||||
|
||||
rulesetsize = WORDSIZE(nrules);
|
||||
rsp = ruleset;
|
||||
rsend = ruleset + rulesetsize;
|
||||
for (rsp = ruleset; rsp < rsend; rsp++)
|
||||
*rsp = 0;
|
||||
|
||||
csend = nucleus + n;
|
||||
for (csp = nucleus; csp < csend; ++csp)
|
||||
{
|
||||
symbol = ritem[*csp];
|
||||
if (ISVAR(symbol))
|
||||
{
|
||||
dsp = first_derives + symbol * rulesetsize;
|
||||
rsp = ruleset;
|
||||
while (rsp < rsend)
|
||||
*rsp++ |= *dsp++;
|
||||
}
|
||||
}
|
||||
|
||||
ruleno = 0;
|
||||
itemsetend = itemset;
|
||||
csp = nucleus;
|
||||
for (rsp = ruleset; rsp < rsend; ++rsp)
|
||||
{
|
||||
word = *rsp;
|
||||
if (word)
|
||||
{
|
||||
for (i = 0; i < BITS_PER_WORD; ++i)
|
||||
{
|
||||
if (word & (1 << i))
|
||||
{
|
||||
itemno = rrhs[ruleno+i];
|
||||
while (csp < csend && *csp < itemno)
|
||||
*itemsetend++ = *csp++;
|
||||
*itemsetend++ = itemno;
|
||||
while (csp < csend && *csp == itemno)
|
||||
++csp;
|
||||
}
|
||||
}
|
||||
}
|
||||
ruleno += BITS_PER_WORD;
|
||||
}
|
||||
|
||||
while (csp < csend)
|
||||
*itemsetend++ = *csp++;
|
||||
|
||||
#ifdef DEBUG
|
||||
print_closure(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
finalize_closure()
|
||||
{
|
||||
FREE(itemset);
|
||||
FREE(ruleset);
|
||||
FREE(first_derives + ntokens * WORDSIZE(nrules));
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
print_closure(n)
|
||||
int n;
|
||||
{
|
||||
register short *isp;
|
||||
|
||||
printf("\n\nn = %d\n\n", n);
|
||||
for (isp = itemset; isp < itemsetend; isp++)
|
||||
printf(" %d\n", *isp);
|
||||
}
|
||||
|
||||
|
||||
print_EFF()
|
||||
{
|
||||
register int i, j;
|
||||
register unsigned *rowp;
|
||||
register unsigned word;
|
||||
register unsigned k;
|
||||
|
||||
printf("\n\nEpsilon Free Firsts\n");
|
||||
|
||||
for (i = start_symbol; i < nsyms; i++)
|
||||
{
|
||||
printf("\n%s", symbol_name[i]);
|
||||
rowp = EFF + ((i - start_symbol) * WORDSIZE(nvars));
|
||||
word = *rowp++;
|
||||
|
||||
k = BITS_PER_WORD;
|
||||
for (j = 0; j < nvars; k++, j++)
|
||||
{
|
||||
if (k >= BITS_PER_WORD)
|
||||
{
|
||||
word = *rowp++;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (word & (1 << k))
|
||||
printf(" %s", symbol_name[start_symbol + j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print_first_derives()
|
||||
{
|
||||
register int i;
|
||||
register int j;
|
||||
register unsigned *rp;
|
||||
register unsigned cword;
|
||||
register unsigned k;
|
||||
|
||||
printf("\n\n\nFirst Derives\n");
|
||||
|
||||
for (i = start_symbol; i < nsyms; i++)
|
||||
{
|
||||
printf("\n%s derives\n", symbol_name[i]);
|
||||
rp = first_derives + i * WORDSIZE(nrules);
|
||||
k = BITS_PER_WORD;
|
||||
for (j = 0; j <= nrules; k++, j++)
|
||||
{
|
||||
if (k >= BITS_PER_WORD)
|
||||
{
|
||||
cword = *rp++;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (cword & (1 << k))
|
||||
printf(" %d\n", j);
|
||||
}
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
#endif
|
||||
-308
@@ -1,308 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Robert Paul Corbett.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)defs.h 5.6 (Berkeley) 5/24/93
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/* machine-dependent definitions */
|
||||
/* the following definitions are for the Tahoe */
|
||||
/* they might have to be changed for other machines */
|
||||
|
||||
/* MAXCHAR is the largest unsigned character value */
|
||||
/* MAXSHORT is the largest value of a C short */
|
||||
/* MINSHORT is the most negative value of a C short */
|
||||
/* MAXTABLE is the maximum table size */
|
||||
/* BITS_PER_WORD is the number of bits in a C unsigned */
|
||||
/* WORDSIZE computes the number of words needed to */
|
||||
/* store n bits */
|
||||
/* BIT returns the value of the n-th bit starting */
|
||||
/* from r (0-indexed) */
|
||||
/* SETBIT sets the n-th bit starting from r */
|
||||
|
||||
#define MAXCHAR 255
|
||||
#define MAXSHORT 32767
|
||||
#define MINSHORT -32768
|
||||
#define MAXTABLE 32500
|
||||
#define BITS_PER_WORD 32
|
||||
#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)
|
||||
#define BIT(r, n) ((((r)[(n)>>5])>>((n)&31))&1)
|
||||
#define SETBIT(r, n) ((r)[(n)>>5]|=((unsigned)1<<((n)&31)))
|
||||
|
||||
|
||||
/* character names */
|
||||
|
||||
#define NUL '\0' /* the null character */
|
||||
#define NEWLINE '\n' /* line feed */
|
||||
#define SP ' ' /* space */
|
||||
#define BS '\b' /* backspace */
|
||||
#define HT '\t' /* horizontal tab */
|
||||
#define VT '\013' /* vertical tab */
|
||||
#define CR '\r' /* carriage return */
|
||||
#define FF '\f' /* form feed */
|
||||
#define QUOTE '\'' /* single quote */
|
||||
#define DOUBLE_QUOTE '\"' /* double quote */
|
||||
#define BACKSLASH '\\' /* backslash */
|
||||
|
||||
|
||||
/* defines for constructing filenames */
|
||||
|
||||
#define CODE_SUFFIX ".code.c"
|
||||
#define DEFINES_SUFFIX ".tab.h"
|
||||
#define OUTPUT_SUFFIX ".tab.c"
|
||||
#define VERBOSE_SUFFIX ".output"
|
||||
|
||||
|
||||
/* keyword codes */
|
||||
|
||||
#define TOKEN 0
|
||||
#define LEFT 1
|
||||
#define RIGHT 2
|
||||
#define NONASSOC 3
|
||||
#define MARK 4
|
||||
#define TEXT 5
|
||||
#define TYPE 6
|
||||
#define START 7
|
||||
|
||||
|
||||
/* symbol classes */
|
||||
|
||||
#define UNKNOWN 0
|
||||
#define TERM 1
|
||||
#define NONTERM 2
|
||||
|
||||
|
||||
/* the undefined value */
|
||||
|
||||
#define UNDEFINED (-1)
|
||||
|
||||
|
||||
/* action codes */
|
||||
|
||||
#define SHIFT 1
|
||||
#define REDUCE 2
|
||||
|
||||
|
||||
/* character macros */
|
||||
|
||||
#define IS_IDENT(c) (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$')
|
||||
#define IS_OCTAL(c) ((c) >= '0' && (c) <= '7')
|
||||
#define NUMERIC_VALUE(c) ((c) - '0')
|
||||
|
||||
|
||||
/* symbol macros */
|
||||
|
||||
#define ISTOKEN(s) ((s) < start_symbol)
|
||||
#define ISVAR(s) ((s) >= start_symbol)
|
||||
|
||||
|
||||
/* storage allocation macros */
|
||||
|
||||
#define CALLOC(k,n) (calloc((unsigned)(k),(unsigned)(n)))
|
||||
#define FREE(x) (free((char*)(x)))
|
||||
#define MALLOC(n) (malloc((unsigned)(n)))
|
||||
#define NEW(t) ((t*)allocate(sizeof(t)))
|
||||
#define NEW2(n,t) ((t*)allocate((unsigned)((n)*sizeof(t))))
|
||||
#define REALLOC(p,n) (realloc((char*)(p),(unsigned)(n)))
|
||||
|
||||
|
||||
/* the structure of a symbol table entry */
|
||||
|
||||
typedef struct bucket bucket;
|
||||
struct bucket
|
||||
{
|
||||
struct bucket *link;
|
||||
struct bucket *next;
|
||||
char *name;
|
||||
char *tag;
|
||||
short value;
|
||||
short index;
|
||||
short prec;
|
||||
char class;
|
||||
char assoc;
|
||||
};
|
||||
|
||||
|
||||
/* the structure of the LR(0) state machine */
|
||||
|
||||
typedef struct core core;
|
||||
struct core
|
||||
{
|
||||
struct core *next;
|
||||
struct core *link;
|
||||
short number;
|
||||
short accessing_symbol;
|
||||
short nitems;
|
||||
short items[1];
|
||||
};
|
||||
|
||||
|
||||
/* the structure used to record shifts */
|
||||
|
||||
typedef struct shifts shifts;
|
||||
struct shifts
|
||||
{
|
||||
struct shifts *next;
|
||||
short number;
|
||||
short nshifts;
|
||||
short shift[1];
|
||||
};
|
||||
|
||||
|
||||
/* the structure used to store reductions */
|
||||
|
||||
typedef struct reductions reductions;
|
||||
struct reductions
|
||||
{
|
||||
struct reductions *next;
|
||||
short number;
|
||||
short nreds;
|
||||
short rules[1];
|
||||
};
|
||||
|
||||
|
||||
/* the structure used to represent parser actions */
|
||||
|
||||
typedef struct action action;
|
||||
struct action
|
||||
{
|
||||
struct action *next;
|
||||
short symbol;
|
||||
short number;
|
||||
short prec;
|
||||
char action_code;
|
||||
char assoc;
|
||||
char suppressed;
|
||||
};
|
||||
|
||||
|
||||
/* global variables */
|
||||
|
||||
extern char tflag;
|
||||
extern char vflag;
|
||||
|
||||
extern char *myname;
|
||||
extern char *cptr;
|
||||
extern char *line;
|
||||
extern int lineno;
|
||||
extern int outline;
|
||||
|
||||
extern char *action_file_name;
|
||||
extern char *input_file_name;
|
||||
extern char *prolog_file_name;
|
||||
extern char *local_file_name;
|
||||
extern char *verbose_file_name;
|
||||
|
||||
extern FILE *action_file;
|
||||
extern FILE *input_file;
|
||||
extern FILE *prolog_file;
|
||||
extern FILE *local_file;
|
||||
extern FILE *verbose_file;
|
||||
|
||||
extern int nitems;
|
||||
extern int nrules;
|
||||
extern int nsyms;
|
||||
extern int ntokens;
|
||||
extern int nvars;
|
||||
extern int ntags;
|
||||
|
||||
extern char *line_format;
|
||||
|
||||
extern int start_symbol;
|
||||
extern char **symbol_name;
|
||||
extern short *symbol_value;
|
||||
extern short *symbol_prec;
|
||||
extern char *symbol_assoc;
|
||||
|
||||
extern short *ritem;
|
||||
extern short *rlhs;
|
||||
extern short *rrhs;
|
||||
extern short *rprec;
|
||||
extern char *rassoc;
|
||||
|
||||
extern short **derives;
|
||||
extern char *nullable;
|
||||
|
||||
extern bucket *first_symbol;
|
||||
extern bucket *last_symbol;
|
||||
|
||||
extern int nstates;
|
||||
extern core *first_state;
|
||||
extern shifts *first_shift;
|
||||
extern reductions *first_reduction;
|
||||
extern short *accessing_symbol;
|
||||
extern core **state_table;
|
||||
extern shifts **shift_table;
|
||||
extern reductions **reduction_table;
|
||||
extern unsigned *LA;
|
||||
extern short *LAruleno;
|
||||
extern short *lookaheads;
|
||||
extern short *goto_map;
|
||||
extern short *from_state;
|
||||
extern short *to_state;
|
||||
|
||||
extern action **parser;
|
||||
extern int SRtotal;
|
||||
extern int RRtotal;
|
||||
extern short *SRconflicts;
|
||||
extern short *RRconflicts;
|
||||
extern short *defred;
|
||||
extern short *rules_used;
|
||||
extern short nunused;
|
||||
extern short final_state;
|
||||
|
||||
/* global functions */
|
||||
|
||||
extern char *allocate();
|
||||
extern bucket *lookup();
|
||||
extern bucket *make_bucket();
|
||||
|
||||
|
||||
/* system variables */
|
||||
|
||||
extern int errno;
|
||||
|
||||
|
||||
/* system functions */
|
||||
|
||||
extern void free();
|
||||
extern char *calloc();
|
||||
extern char *malloc();
|
||||
extern char *realloc();
|
||||
extern char *strcpy();
|
||||
@@ -1,11 +0,0 @@
|
||||
closure.o: closure.c defs.h
|
||||
error.o: error.c defs.h
|
||||
lalr.o: lalr.c defs.h
|
||||
lr0.o: lr0.c defs.h
|
||||
main.o: main.c defs.h
|
||||
mkpar.o: mkpar.c defs.h
|
||||
output.o: output.c defs.h
|
||||
reader.o: reader.c defs.h
|
||||
symtab.o: symtab.c defs.h
|
||||
verbose.o: verbose.c defs.h
|
||||
warshall.o: warshall.c defs.h
|
||||
-335
@@ -1,335 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Robert Paul Corbett.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
|
||||
#endif /* not lint */
|
||||
|
||||
/* routines for printing error messages */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
|
||||
fatal(msg)
|
||||
char *msg;
|
||||
{
|
||||
fprintf(stderr, "%s: f - %s\n", myname, msg);
|
||||
done(2);
|
||||
}
|
||||
|
||||
|
||||
no_space()
|
||||
{
|
||||
fprintf(stderr, "%s: f - out of space\n", myname);
|
||||
done(2);
|
||||
}
|
||||
|
||||
|
||||
open_error(filename)
|
||||
char *filename;
|
||||
{
|
||||
fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
|
||||
done(2);
|
||||
}
|
||||
|
||||
|
||||
unexpected_EOF()
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
|
||||
myname, lineno, input_file_name);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
print_pos(st_line, st_cptr)
|
||||
char *st_line;
|
||||
char *st_cptr;
|
||||
{
|
||||
register char *s;
|
||||
|
||||
if (st_line == 0) return;
|
||||
for (s = st_line; *s != '\n'; ++s)
|
||||
{
|
||||
if (isprint(*s) || *s == '\t')
|
||||
putc(*s, stderr);
|
||||
else
|
||||
putc('?', stderr);
|
||||
}
|
||||
putc('\n', stderr);
|
||||
for (s = st_line; s < st_cptr; ++s)
|
||||
{
|
||||
if (*s == '\t')
|
||||
putc('\t', stderr);
|
||||
else
|
||||
putc(' ', stderr);
|
||||
}
|
||||
putc('^', stderr);
|
||||
putc('\n', stderr);
|
||||
}
|
||||
|
||||
|
||||
syntax_error(st_lineno, st_line, st_cptr)
|
||||
int st_lineno;
|
||||
char *st_line;
|
||||
char *st_cptr;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n",
|
||||
myname, st_lineno, input_file_name);
|
||||
print_pos(st_line, st_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
unterminated_comment(c_lineno, c_line, c_cptr)
|
||||
int c_lineno;
|
||||
char *c_line;
|
||||
char *c_cptr;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
|
||||
myname, c_lineno, input_file_name);
|
||||
print_pos(c_line, c_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
unterminated_string(s_lineno, s_line, s_cptr)
|
||||
int s_lineno;
|
||||
char *s_line;
|
||||
char *s_cptr;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
|
||||
myname, s_lineno, input_file_name);
|
||||
print_pos(s_line, s_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
unterminated_text(t_lineno, t_line, t_cptr)
|
||||
int t_lineno;
|
||||
char *t_line;
|
||||
char *t_cptr;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
|
||||
myname, t_lineno, input_file_name);
|
||||
print_pos(t_line, t_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
illegal_tag(t_lineno, t_line, t_cptr)
|
||||
int t_lineno;
|
||||
char *t_line;
|
||||
char *t_cptr;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n",
|
||||
myname, t_lineno, input_file_name);
|
||||
print_pos(t_line, t_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
illegal_character(c_cptr)
|
||||
char *c_cptr;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n",
|
||||
myname, lineno, input_file_name);
|
||||
print_pos(line, c_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
used_reserved(s)
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
|
||||
%s\n", myname, lineno, input_file_name, s);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
tokenized_start(s)
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
|
||||
declared to be a token\n", myname, lineno, input_file_name, s);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
retyped_warning(s)
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
|
||||
redeclared\n", myname, lineno, input_file_name, s);
|
||||
}
|
||||
|
||||
|
||||
reprec_warning(s)
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
|
||||
redeclared\n", myname, lineno, input_file_name, s);
|
||||
}
|
||||
|
||||
|
||||
revalued_warning(s)
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
|
||||
redeclared\n", myname, lineno, input_file_name, s);
|
||||
}
|
||||
|
||||
|
||||
terminal_start(s)
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
|
||||
token\n", myname, lineno, input_file_name, s);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
restarted_warning()
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
|
||||
redeclared\n", myname, lineno, input_file_name);
|
||||
}
|
||||
|
||||
|
||||
no_grammar()
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
|
||||
specified\n", myname, lineno, input_file_name);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
terminal_lhs(s_lineno)
|
||||
int s_lineno;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
|
||||
of a production\n", myname, s_lineno, input_file_name);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
prec_redeclared()
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
|
||||
specifiers\n", myname, lineno, input_file_name);
|
||||
}
|
||||
|
||||
|
||||
unterminated_action(a_lineno, a_line, a_cptr)
|
||||
int a_lineno;
|
||||
char *a_line;
|
||||
char *a_cptr;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
|
||||
myname, a_lineno, input_file_name);
|
||||
print_pos(a_line, a_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
dollar_warning(a_lineno, i)
|
||||
int a_lineno;
|
||||
int i;
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \
|
||||
end of the current rule\n", myname, a_lineno, input_file_name, i);
|
||||
}
|
||||
|
||||
|
||||
dollar_error(a_lineno, a_line, a_cptr)
|
||||
int a_lineno;
|
||||
char *a_line;
|
||||
char *a_cptr;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n",
|
||||
myname, a_lineno, input_file_name);
|
||||
print_pos(a_line, a_cptr);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
untyped_lhs()
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", $$ is untyped\n",
|
||||
myname, lineno, input_file_name);
|
||||
/** done(1); */
|
||||
}
|
||||
|
||||
|
||||
untyped_rhs(i, s)
|
||||
int i;
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", $%d (%s) is untyped\n",
|
||||
myname, lineno, input_file_name, i, s);
|
||||
/** done(1); */
|
||||
}
|
||||
|
||||
|
||||
unknown_rhs(i)
|
||||
int i;
|
||||
{
|
||||
fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
|
||||
myname, lineno, input_file_name, i);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
default_action_warning()
|
||||
{
|
||||
fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
|
||||
undefined value to $$\n", myname, lineno, input_file_name);
|
||||
}
|
||||
|
||||
|
||||
undefined_goal(s)
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
undefined_symbol_warning(s)
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
|
||||
}
|
||||
-120
@@ -1,120 +0,0 @@
|
||||
.\" Copyright (c) 1989, 1990 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" Robert Paul Corbett.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" 4. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)yacc.1 5.8 (Berkeley) 5/24/93
|
||||
.\"
|
||||
.TH JAY 1 "May 24, 1993 / July 8, 1998"
|
||||
.UC 6
|
||||
.SH NAME
|
||||
jay \- an LALR(1) parser generator for Java and C#
|
||||
.SH SYNOPSIS
|
||||
.B jay [ -tv ] [ -c ] [ -b
|
||||
.I file_prefix
|
||||
.B ] [ -V
|
||||
.I yyValue
|
||||
.B ]
|
||||
.I filename
|
||||
.B <
|
||||
.I skeleton
|
||||
.SH DESCRIPTION
|
||||
.I Jay
|
||||
reads the grammar specification in the file
|
||||
.I filename
|
||||
and generates an LR(1) parser for it.
|
||||
The parsers consist of a set of LALR(1) parsing tables and a driver routine
|
||||
from the file
|
||||
.I skeleton
|
||||
written in the Java programming language.
|
||||
.I Jay
|
||||
writes the parse tables and the driver routine to standard output.
|
||||
.PP
|
||||
The following options are available:
|
||||
.RS
|
||||
.TP
|
||||
\fB-b \fIfile_prefix\fR
|
||||
The
|
||||
.B -b
|
||||
option changes the prefix prepended to the output file names to
|
||||
the string denoted by
|
||||
.IR file_prefix.
|
||||
The default prefix is the character
|
||||
.IR y.
|
||||
.TP
|
||||
.B -c
|
||||
The
|
||||
.B -c
|
||||
option makes jay generate C# code instead of the default Java.
|
||||
.TP
|
||||
.B -t
|
||||
The
|
||||
.B -t
|
||||
option arranges for
|
||||
debugging information to be incorporated in the compiled code.
|
||||
.TP
|
||||
.B -v
|
||||
The
|
||||
.B -v
|
||||
option causes a human-readable description of the generated parser to
|
||||
be written to the file
|
||||
.IR y.output.
|
||||
.RE
|
||||
.PP
|
||||
If the environment variable TMPDIR is set, the string denoted by
|
||||
TMPDIR will be used as the name of the directory where the temporary
|
||||
files are created.
|
||||
.SH FILES
|
||||
.IR skeleton
|
||||
.br
|
||||
.IR y.output
|
||||
.br
|
||||
.IR /tmp/yacc.aXXXXXX
|
||||
.br
|
||||
.IR /tmp/yacc.tXXXXXX
|
||||
.br
|
||||
.IR /tmp/yacc.uXXXXXX
|
||||
.SH DIAGNOSTICS
|
||||
If there are rules that are never reduced, the number of such rules is
|
||||
reported on standard error.
|
||||
If there are any LALR(1) conflicts, the number of conflicts is reported
|
||||
on standard error.
|
||||
.SH HISTORY
|
||||
.I Jay
|
||||
is derived from Berkeley
|
||||
.I yacc .
|
||||
Input conventions closely follow those of
|
||||
.I yacc ;
|
||||
for details,
|
||||
consult the parser
|
||||
.I skeleton
|
||||
file and the commented example included with the sources.
|
||||
-678
@@ -1,678 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Robert Paul Corbett.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)lalr.c 5.3 (Berkeley) 6/1/90";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
typedef
|
||||
struct shorts
|
||||
{
|
||||
struct shorts *next;
|
||||
short value;
|
||||
}
|
||||
shorts;
|
||||
|
||||
int tokensetsize;
|
||||
short *lookaheads;
|
||||
short *LAruleno;
|
||||
unsigned *LA;
|
||||
short *accessing_symbol;
|
||||
core **state_table;
|
||||
shifts **shift_table;
|
||||
reductions **reduction_table;
|
||||
short *goto_map;
|
||||
short *from_state;
|
||||
short *to_state;
|
||||
|
||||
short **transpose();
|
||||
|
||||
static int infinity;
|
||||
static int maxrhs;
|
||||
static int ngotos;
|
||||
static unsigned *F;
|
||||
static short **includes;
|
||||
static shorts **lookback;
|
||||
static short **R;
|
||||
static short *INDEX;
|
||||
static short *VERTICES;
|
||||
static int top;
|
||||
|
||||
|
||||
lalr()
|
||||
{
|
||||
tokensetsize = WORDSIZE(ntokens);
|
||||
|
||||
set_state_table();
|
||||
set_accessing_symbol();
|
||||
set_shift_table();
|
||||
set_reduction_table();
|
||||
set_maxrhs();
|
||||
initialize_LA();
|
||||
set_goto_map();
|
||||
initialize_F();
|
||||
build_relations();
|
||||
compute_FOLLOWS();
|
||||
compute_lookaheads();
|
||||
}
|
||||
|
||||
|
||||
|
||||
set_state_table()
|
||||
{
|
||||
register core *sp;
|
||||
|
||||
state_table = NEW2(nstates, core *);
|
||||
for (sp = first_state; sp; sp = sp->next)
|
||||
state_table[sp->number] = sp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
set_accessing_symbol()
|
||||
{
|
||||
register core *sp;
|
||||
|
||||
accessing_symbol = NEW2(nstates, short);
|
||||
for (sp = first_state; sp; sp = sp->next)
|
||||
accessing_symbol[sp->number] = sp->accessing_symbol;
|
||||
}
|
||||
|
||||
|
||||
|
||||
set_shift_table()
|
||||
{
|
||||
register shifts *sp;
|
||||
|
||||
shift_table = NEW2(nstates, shifts *);
|
||||
for (sp = first_shift; sp; sp = sp->next)
|
||||
shift_table[sp->number] = sp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
set_reduction_table()
|
||||
{
|
||||
register reductions *rp;
|
||||
|
||||
reduction_table = NEW2(nstates, reductions *);
|
||||
for (rp = first_reduction; rp; rp = rp->next)
|
||||
reduction_table[rp->number] = rp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
set_maxrhs()
|
||||
{
|
||||
register short *itemp;
|
||||
register short *item_end;
|
||||
register int length;
|
||||
register int max;
|
||||
|
||||
length = 0;
|
||||
max = 0;
|
||||
item_end = ritem + nitems;
|
||||
for (itemp = ritem; itemp < item_end; itemp++)
|
||||
{
|
||||
if (*itemp >= 0)
|
||||
{
|
||||
length++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (length > max) max = length;
|
||||
length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
maxrhs = max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
initialize_LA()
|
||||
{
|
||||
register int i, j, k;
|
||||
register reductions *rp;
|
||||
|
||||
lookaheads = NEW2(nstates + 1, short);
|
||||
|
||||
k = 0;
|
||||
for (i = 0; i < nstates; i++)
|
||||
{
|
||||
lookaheads[i] = k;
|
||||
rp = reduction_table[i];
|
||||
if (rp)
|
||||
k += rp->nreds;
|
||||
}
|
||||
lookaheads[nstates] = k;
|
||||
|
||||
LA = NEW2(k * tokensetsize, unsigned);
|
||||
LAruleno = NEW2(k, short);
|
||||
lookback = NEW2(k, shorts *);
|
||||
|
||||
k = 0;
|
||||
for (i = 0; i < nstates; i++)
|
||||
{
|
||||
rp = reduction_table[i];
|
||||
if (rp)
|
||||
{
|
||||
for (j = 0; j < rp->nreds; j++)
|
||||
{
|
||||
LAruleno[k] = rp->rules[j];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
set_goto_map()
|
||||
{
|
||||
register shifts *sp;
|
||||
register int i;
|
||||
register int symbol;
|
||||
register int k;
|
||||
register short *temp_map;
|
||||
register int state2;
|
||||
register int state1;
|
||||
|
||||
goto_map = NEW2(nvars + 1, short) - ntokens;
|
||||
temp_map = NEW2(nvars + 1, short) - ntokens;
|
||||
|
||||
ngotos = 0;
|
||||
for (sp = first_shift; sp; sp = sp->next)
|
||||
{
|
||||
for (i = sp->nshifts - 1; i >= 0; i--)
|
||||
{
|
||||
symbol = accessing_symbol[sp->shift[i]];
|
||||
|
||||
if (ISTOKEN(symbol)) break;
|
||||
|
||||
if (ngotos == MAXSHORT)
|
||||
fatal("too many gotos");
|
||||
|
||||
ngotos++;
|
||||
goto_map[symbol]++;
|
||||
}
|
||||
}
|
||||
|
||||
k = 0;
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
{
|
||||
temp_map[i] = k;
|
||||
k += goto_map[i];
|
||||
}
|
||||
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
goto_map[i] = temp_map[i];
|
||||
|
||||
goto_map[nsyms] = ngotos;
|
||||
temp_map[nsyms] = ngotos;
|
||||
|
||||
from_state = NEW2(ngotos, short);
|
||||
to_state = NEW2(ngotos, short);
|
||||
|
||||
for (sp = first_shift; sp; sp = sp->next)
|
||||
{
|
||||
state1 = sp->number;
|
||||
for (i = sp->nshifts - 1; i >= 0; i--)
|
||||
{
|
||||
state2 = sp->shift[i];
|
||||
symbol = accessing_symbol[state2];
|
||||
|
||||
if (ISTOKEN(symbol)) break;
|
||||
|
||||
k = temp_map[symbol]++;
|
||||
from_state[k] = state1;
|
||||
to_state[k] = state2;
|
||||
}
|
||||
}
|
||||
|
||||
FREE(temp_map + ntokens);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Map_goto maps a state/symbol pair into its numeric representation. */
|
||||
|
||||
int
|
||||
map_goto(state, symbol)
|
||||
int state;
|
||||
int symbol;
|
||||
{
|
||||
register int high;
|
||||
register int low;
|
||||
register int middle;
|
||||
register int s;
|
||||
|
||||
low = goto_map[symbol];
|
||||
high = goto_map[symbol + 1];
|
||||
|
||||
for (;;)
|
||||
{
|
||||
assert(low <= high);
|
||||
middle = (low + high) >> 1;
|
||||
s = from_state[middle];
|
||||
if (s == state)
|
||||
return (middle);
|
||||
else if (s < state)
|
||||
low = middle + 1;
|
||||
else
|
||||
high = middle - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
initialize_F()
|
||||
{
|
||||
register int i;
|
||||
register int j;
|
||||
register int k;
|
||||
register shifts *sp;
|
||||
register short *edge;
|
||||
register unsigned *rowp;
|
||||
register short *rp;
|
||||
register short **reads;
|
||||
register int nedges;
|
||||
register int stateno;
|
||||
register int symbol;
|
||||
register int nwords;
|
||||
|
||||
nwords = ngotos * tokensetsize;
|
||||
F = NEW2(nwords, unsigned);
|
||||
|
||||
reads = NEW2(ngotos, short *);
|
||||
edge = NEW2(ngotos + 1, short);
|
||||
nedges = 0;
|
||||
|
||||
rowp = F;
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
stateno = to_state[i];
|
||||
sp = shift_table[stateno];
|
||||
|
||||
if (sp)
|
||||
{
|
||||
k = sp->nshifts;
|
||||
|
||||
for (j = 0; j < k; j++)
|
||||
{
|
||||
symbol = accessing_symbol[sp->shift[j]];
|
||||
if (ISVAR(symbol))
|
||||
break;
|
||||
SETBIT(rowp, symbol);
|
||||
}
|
||||
|
||||
for (; j < k; j++)
|
||||
{
|
||||
symbol = accessing_symbol[sp->shift[j]];
|
||||
if (nullable[symbol])
|
||||
edge[nedges++] = map_goto(stateno, symbol);
|
||||
}
|
||||
|
||||
if (nedges)
|
||||
{
|
||||
reads[i] = rp = NEW2(nedges + 1, short);
|
||||
|
||||
for (j = 0; j < nedges; j++)
|
||||
rp[j] = edge[j];
|
||||
|
||||
rp[nedges] = -1;
|
||||
nedges = 0;
|
||||
}
|
||||
}
|
||||
|
||||
rowp += tokensetsize;
|
||||
}
|
||||
|
||||
SETBIT(F, 0);
|
||||
digraph(reads);
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
if (reads[i])
|
||||
FREE(reads[i]);
|
||||
}
|
||||
|
||||
FREE(reads);
|
||||
FREE(edge);
|
||||
}
|
||||
|
||||
|
||||
|
||||
build_relations()
|
||||
{
|
||||
register int i;
|
||||
register int j;
|
||||
register int k;
|
||||
register short *rulep;
|
||||
register short *rp;
|
||||
register shifts *sp;
|
||||
register int length;
|
||||
register int nedges;
|
||||
register int done;
|
||||
register int state1;
|
||||
register int stateno;
|
||||
register int symbol1;
|
||||
register int symbol2;
|
||||
register short *shortp;
|
||||
register short *edge;
|
||||
register short *states;
|
||||
register short **new_includes;
|
||||
|
||||
includes = NEW2(ngotos, short *);
|
||||
edge = NEW2(ngotos + 1, short);
|
||||
states = NEW2(maxrhs + 1, short);
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
nedges = 0;
|
||||
state1 = from_state[i];
|
||||
symbol1 = accessing_symbol[to_state[i]];
|
||||
|
||||
for (rulep = derives[symbol1]; *rulep >= 0; rulep++)
|
||||
{
|
||||
length = 1;
|
||||
states[0] = state1;
|
||||
stateno = state1;
|
||||
|
||||
for (rp = ritem + rrhs[*rulep]; *rp >= 0; rp++)
|
||||
{
|
||||
symbol2 = *rp;
|
||||
sp = shift_table[stateno];
|
||||
k = sp->nshifts;
|
||||
|
||||
for (j = 0; j < k; j++)
|
||||
{
|
||||
stateno = sp->shift[j];
|
||||
if (accessing_symbol[stateno] == symbol2) break;
|
||||
}
|
||||
|
||||
states[length++] = stateno;
|
||||
}
|
||||
|
||||
add_lookback_edge(stateno, *rulep, i);
|
||||
|
||||
length--;
|
||||
done = 0;
|
||||
while (!done)
|
||||
{
|
||||
done = 1;
|
||||
rp--;
|
||||
if (ISVAR(*rp))
|
||||
{
|
||||
stateno = states[--length];
|
||||
edge[nedges++] = map_goto(stateno, *rp);
|
||||
if (nullable[*rp] && length > 0) done = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nedges)
|
||||
{
|
||||
includes[i] = shortp = NEW2(nedges + 1, short);
|
||||
for (j = 0; j < nedges; j++)
|
||||
shortp[j] = edge[j];
|
||||
shortp[nedges] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
new_includes = transpose(includes, ngotos);
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
if (includes[i])
|
||||
FREE(includes[i]);
|
||||
|
||||
FREE(includes);
|
||||
|
||||
includes = new_includes;
|
||||
|
||||
FREE(edge);
|
||||
FREE(states);
|
||||
}
|
||||
|
||||
|
||||
add_lookback_edge(stateno, ruleno, gotono)
|
||||
int stateno, ruleno, gotono;
|
||||
{
|
||||
register int i, k;
|
||||
register int found;
|
||||
register shorts *sp;
|
||||
|
||||
i = lookaheads[stateno];
|
||||
k = lookaheads[stateno + 1];
|
||||
found = 0;
|
||||
while (!found && i < k)
|
||||
{
|
||||
if (LAruleno[i] == ruleno)
|
||||
found = 1;
|
||||
else
|
||||
++i;
|
||||
}
|
||||
assert(found);
|
||||
|
||||
sp = NEW(shorts);
|
||||
sp->next = lookback[i];
|
||||
sp->value = gotono;
|
||||
lookback[i] = sp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
short **
|
||||
transpose(R, n)
|
||||
short **R;
|
||||
int n;
|
||||
{
|
||||
register short **new_R;
|
||||
register short **temp_R;
|
||||
register short *nedges;
|
||||
register short *sp;
|
||||
register int i;
|
||||
register int k;
|
||||
|
||||
nedges = NEW2(n, short);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
sp = R[i];
|
||||
if (sp)
|
||||
{
|
||||
while (*sp >= 0)
|
||||
nedges[*sp++]++;
|
||||
}
|
||||
}
|
||||
|
||||
new_R = NEW2(n, short *);
|
||||
temp_R = NEW2(n, short *);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
k = nedges[i];
|
||||
if (k > 0)
|
||||
{
|
||||
sp = NEW2(k + 1, short);
|
||||
new_R[i] = sp;
|
||||
temp_R[i] = sp;
|
||||
sp[k] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
FREE(nedges);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
sp = R[i];
|
||||
if (sp)
|
||||
{
|
||||
while (*sp >= 0)
|
||||
*temp_R[*sp++]++ = i;
|
||||
}
|
||||
}
|
||||
|
||||
FREE(temp_R);
|
||||
|
||||
return (new_R);
|
||||
}
|
||||
|
||||
|
||||
|
||||
compute_FOLLOWS()
|
||||
{
|
||||
digraph(includes);
|
||||
}
|
||||
|
||||
|
||||
compute_lookaheads()
|
||||
{
|
||||
register int i, n;
|
||||
register unsigned *fp1, *fp2, *fp3;
|
||||
register shorts *sp, *next;
|
||||
register unsigned *rowp;
|
||||
|
||||
rowp = LA;
|
||||
n = lookaheads[nstates];
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
fp3 = rowp + tokensetsize;
|
||||
for (sp = lookback[i]; sp; sp = sp->next)
|
||||
{
|
||||
fp1 = rowp;
|
||||
fp2 = F + tokensetsize * sp->value;
|
||||
while (fp1 < fp3)
|
||||
*fp1++ |= *fp2++;
|
||||
}
|
||||
rowp = fp3;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (sp = lookback[i]; sp; sp = next)
|
||||
{
|
||||
next = sp->next;
|
||||
FREE(sp);
|
||||
}
|
||||
|
||||
FREE(lookback);
|
||||
FREE(F);
|
||||
}
|
||||
|
||||
|
||||
digraph(relation)
|
||||
short **relation;
|
||||
{
|
||||
register int i;
|
||||
|
||||
infinity = ngotos + 2;
|
||||
INDEX = NEW2(ngotos + 1, short);
|
||||
VERTICES = NEW2(ngotos + 1, short);
|
||||
top = 0;
|
||||
|
||||
R = relation;
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
INDEX[i] = 0;
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
if (INDEX[i] == 0 && R[i])
|
||||
traverse(i);
|
||||
}
|
||||
|
||||
FREE(INDEX);
|
||||
FREE(VERTICES);
|
||||
}
|
||||
|
||||
|
||||
|
||||
traverse(i)
|
||||
register int i;
|
||||
{
|
||||
register unsigned *fp1;
|
||||
register unsigned *fp2;
|
||||
register unsigned *fp3;
|
||||
register int j;
|
||||
register short *rp;
|
||||
|
||||
int height;
|
||||
unsigned *base;
|
||||
|
||||
VERTICES[++top] = i;
|
||||
INDEX[i] = height = top;
|
||||
|
||||
base = F + i * tokensetsize;
|
||||
fp3 = base + tokensetsize;
|
||||
|
||||
rp = R[i];
|
||||
if (rp)
|
||||
{
|
||||
while ((j = *rp++) >= 0)
|
||||
{
|
||||
if (INDEX[j] == 0)
|
||||
traverse(j);
|
||||
|
||||
if (INDEX[i] > INDEX[j])
|
||||
INDEX[i] = INDEX[j];
|
||||
|
||||
fp1 = base;
|
||||
fp2 = F + j * tokensetsize;
|
||||
|
||||
while (fp1 < fp3)
|
||||
*fp1++ |= *fp2++;
|
||||
}
|
||||
}
|
||||
|
||||
if (INDEX[i] == height)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
j = VERTICES[top--];
|
||||
INDEX[j] = infinity;
|
||||
|
||||
if (i == j)
|
||||
break;
|
||||
|
||||
fp1 = base;
|
||||
fp2 = F + j * tokensetsize;
|
||||
|
||||
while (fp1 < fp3)
|
||||
*fp2++ = *fp1++;
|
||||
}
|
||||
}
|
||||
}
|
||||
-637
@@ -1,637 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Robert Paul Corbett.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)lr0.c 5.3 (Berkeley) 1/20/91";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
extern short *itemset;
|
||||
extern short *itemsetend;
|
||||
extern unsigned *ruleset;
|
||||
|
||||
int nstates;
|
||||
core *first_state;
|
||||
shifts *first_shift;
|
||||
reductions *first_reduction;
|
||||
|
||||
int get_state();
|
||||
core *new_state();
|
||||
|
||||
static core **state_set;
|
||||
static core *this_state;
|
||||
static core *last_state;
|
||||
static shifts *last_shift;
|
||||
static reductions *last_reduction;
|
||||
|
||||
static int nshifts;
|
||||
static short *shift_symbol;
|
||||
|
||||
static short *redset;
|
||||
static short *shiftset;
|
||||
|
||||
static short **kernel_base;
|
||||
static short **kernel_end;
|
||||
static short *kernel_items;
|
||||
|
||||
|
||||
allocate_itemsets()
|
||||
{
|
||||
register short *itemp;
|
||||
register short *item_end;
|
||||
register int symbol;
|
||||
register int i;
|
||||
register int count;
|
||||
register int max;
|
||||
register short *symbol_count;
|
||||
|
||||
count = 0;
|
||||
symbol_count = NEW2(nsyms, short);
|
||||
|
||||
item_end = ritem + nitems;
|
||||
for (itemp = ritem; itemp < item_end; itemp++)
|
||||
{
|
||||
symbol = *itemp;
|
||||
if (symbol >= 0)
|
||||
{
|
||||
count++;
|
||||
symbol_count[symbol]++;
|
||||
}
|
||||
}
|
||||
|
||||
kernel_base = NEW2(nsyms, short *);
|
||||
kernel_items = NEW2(count, short);
|
||||
|
||||
count = 0;
|
||||
max = 0;
|
||||
for (i = 0; i < nsyms; i++)
|
||||
{
|
||||
kernel_base[i] = kernel_items + count;
|
||||
count += symbol_count[i];
|
||||
if (max < symbol_count[i])
|
||||
max = symbol_count[i];
|
||||
}
|
||||
|
||||
shift_symbol = symbol_count;
|
||||
kernel_end = NEW2(nsyms, short *);
|
||||
}
|
||||
|
||||
|
||||
allocate_storage()
|
||||
{
|
||||
allocate_itemsets();
|
||||
shiftset = NEW2(nsyms, short);
|
||||
redset = NEW2(nrules + 1, short);
|
||||
state_set = NEW2(nitems, core *);
|
||||
}
|
||||
|
||||
|
||||
append_states()
|
||||
{
|
||||
register int i;
|
||||
register int j;
|
||||
register int symbol;
|
||||
|
||||
#ifdef TRACE
|
||||
fprintf(stderr, "Entering append_states()\n");
|
||||
#endif
|
||||
for (i = 1; i < nshifts; i++)
|
||||
{
|
||||
symbol = shift_symbol[i];
|
||||
j = i;
|
||||
while (j > 0 && shift_symbol[j - 1] > symbol)
|
||||
{
|
||||
shift_symbol[j] = shift_symbol[j - 1];
|
||||
j--;
|
||||
}
|
||||
shift_symbol[j] = symbol;
|
||||
}
|
||||
|
||||
for (i = 0; i < nshifts; i++)
|
||||
{
|
||||
symbol = shift_symbol[i];
|
||||
shiftset[i] = get_state(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free_storage()
|
||||
{
|
||||
FREE(shift_symbol);
|
||||
FREE(redset);
|
||||
FREE(shiftset);
|
||||
FREE(kernel_base);
|
||||
FREE(kernel_end);
|
||||
FREE(kernel_items);
|
||||
FREE(state_set);
|
||||
}
|
||||
|
||||
|
||||
|
||||
generate_states()
|
||||
{
|
||||
allocate_storage();
|
||||
itemset = NEW2(nitems, short);
|
||||
ruleset = NEW2(WORDSIZE(nrules), unsigned);
|
||||
set_first_derives();
|
||||
initialize_states();
|
||||
|
||||
while (this_state)
|
||||
{
|
||||
closure(this_state->items, this_state->nitems);
|
||||
save_reductions();
|
||||
new_itemsets();
|
||||
append_states();
|
||||
|
||||
if (nshifts > 0)
|
||||
save_shifts();
|
||||
|
||||
this_state = this_state->next;
|
||||
}
|
||||
|
||||
finalize_closure();
|
||||
free_storage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
get_state(symbol)
|
||||
int symbol;
|
||||
{
|
||||
register int key;
|
||||
register short *isp1;
|
||||
register short *isp2;
|
||||
register short *iend;
|
||||
register core *sp;
|
||||
register int found;
|
||||
register int n;
|
||||
|
||||
#ifdef TRACE
|
||||
fprintf(stderr, "Entering get_state(%d)\n", symbol);
|
||||
#endif
|
||||
|
||||
isp1 = kernel_base[symbol];
|
||||
iend = kernel_end[symbol];
|
||||
n = iend - isp1;
|
||||
|
||||
key = *isp1;
|
||||
assert(0 <= key && key < nitems);
|
||||
sp = state_set[key];
|
||||
if (sp)
|
||||
{
|
||||
found = 0;
|
||||
while (!found)
|
||||
{
|
||||
if (sp->nitems == n)
|
||||
{
|
||||
found = 1;
|
||||
isp1 = kernel_base[symbol];
|
||||
isp2 = sp->items;
|
||||
|
||||
while (found && isp1 < iend)
|
||||
{
|
||||
if (*isp1++ != *isp2++)
|
||||
found = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
if (sp->link)
|
||||
{
|
||||
sp = sp->link;
|
||||
}
|
||||
else
|
||||
{
|
||||
sp = sp->link = new_state(symbol);
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
state_set[key] = sp = new_state(symbol);
|
||||
}
|
||||
|
||||
return (sp->number);
|
||||
}
|
||||
|
||||
|
||||
|
||||
initialize_states()
|
||||
{
|
||||
register int i;
|
||||
register short *start_derives;
|
||||
register core *p;
|
||||
|
||||
start_derives = derives[start_symbol];
|
||||
for (i = 0; start_derives[i] >= 0; ++i)
|
||||
continue;
|
||||
|
||||
p = (core *) MALLOC(sizeof(core) + i*sizeof(short));
|
||||
if (p == 0) no_space();
|
||||
|
||||
p->next = 0;
|
||||
p->link = 0;
|
||||
p->number = 0;
|
||||
p->accessing_symbol = 0;
|
||||
p->nitems = i;
|
||||
|
||||
for (i = 0; start_derives[i] >= 0; ++i)
|
||||
p->items[i] = rrhs[start_derives[i]];
|
||||
|
||||
first_state = last_state = this_state = p;
|
||||
nstates = 1;
|
||||
}
|
||||
|
||||
|
||||
new_itemsets()
|
||||
{
|
||||
register int i;
|
||||
register int shiftcount;
|
||||
register short *isp;
|
||||
register short *ksp;
|
||||
register int symbol;
|
||||
|
||||
for (i = 0; i < nsyms; i++)
|
||||
kernel_end[i] = 0;
|
||||
|
||||
shiftcount = 0;
|
||||
isp = itemset;
|
||||
while (isp < itemsetend)
|
||||
{
|
||||
i = *isp++;
|
||||
symbol = ritem[i];
|
||||
if (symbol > 0)
|
||||
{
|
||||
ksp = kernel_end[symbol];
|
||||
if (!ksp)
|
||||
{
|
||||
shift_symbol[shiftcount++] = symbol;
|
||||
ksp = kernel_base[symbol];
|
||||
}
|
||||
|
||||
*ksp++ = i + 1;
|
||||
kernel_end[symbol] = ksp;
|
||||
}
|
||||
}
|
||||
|
||||
nshifts = shiftcount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
core *
|
||||
new_state(symbol)
|
||||
int symbol;
|
||||
{
|
||||
register int n;
|
||||
register core *p;
|
||||
register short *isp1;
|
||||
register short *isp2;
|
||||
register short *iend;
|
||||
|
||||
#ifdef TRACE
|
||||
fprintf(stderr, "Entering new_state(%d)\n", symbol);
|
||||
#endif
|
||||
|
||||
if (nstates >= MAXSHORT)
|
||||
fatal("too many states");
|
||||
|
||||
isp1 = kernel_base[symbol];
|
||||
iend = kernel_end[symbol];
|
||||
n = iend - isp1;
|
||||
|
||||
p = (core *) allocate((unsigned) (sizeof(core) + (n - 1) * sizeof(short)));
|
||||
p->accessing_symbol = symbol;
|
||||
p->number = nstates;
|
||||
p->nitems = n;
|
||||
|
||||
isp2 = p->items;
|
||||
while (isp1 < iend)
|
||||
*isp2++ = *isp1++;
|
||||
|
||||
last_state->next = p;
|
||||
last_state = p;
|
||||
|
||||
nstates++;
|
||||
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
/* show_cores is used for debugging */
|
||||
|
||||
show_cores()
|
||||
{
|
||||
core *p;
|
||||
int i, j, k, n;
|
||||
int itemno;
|
||||
|
||||
k = 0;
|
||||
for (p = first_state; p; ++k, p = p->next)
|
||||
{
|
||||
if (k) printf("\n");
|
||||
printf("state %d, number = %d, accessing symbol = %s\n",
|
||||
k, p->number, symbol_name[p->accessing_symbol]);
|
||||
n = p->nitems;
|
||||
for (i = 0; i < n; ++i)
|
||||
{
|
||||
itemno = p->items[i];
|
||||
printf("%4d ", itemno);
|
||||
j = itemno;
|
||||
while (ritem[j] >= 0) ++j;
|
||||
printf("%s :", symbol_name[rlhs[-ritem[j]]]);
|
||||
j = rrhs[-ritem[j]];
|
||||
while (j < itemno)
|
||||
printf(" %s", symbol_name[ritem[j++]]);
|
||||
printf(" .");
|
||||
while (ritem[j] >= 0)
|
||||
printf(" %s", symbol_name[ritem[j++]]);
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* show_ritems is used for debugging */
|
||||
|
||||
show_ritems()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nitems; ++i)
|
||||
printf("ritem[%d] = %d\n", i, ritem[i]);
|
||||
}
|
||||
|
||||
|
||||
/* show_rrhs is used for debugging */
|
||||
show_rrhs()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nrules; ++i)
|
||||
printf("rrhs[%d] = %d\n", i, rrhs[i]);
|
||||
}
|
||||
|
||||
|
||||
/* show_shifts is used for debugging */
|
||||
|
||||
show_shifts()
|
||||
{
|
||||
shifts *p;
|
||||
int i, j, k;
|
||||
|
||||
k = 0;
|
||||
for (p = first_shift; p; ++k, p = p->next)
|
||||
{
|
||||
if (k) printf("\n");
|
||||
printf("shift %d, number = %d, nshifts = %d\n", k, p->number,
|
||||
p->nshifts);
|
||||
j = p->nshifts;
|
||||
for (i = 0; i < j; ++i)
|
||||
printf("\t%d\n", p->shift[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
save_shifts()
|
||||
{
|
||||
register shifts *p;
|
||||
register short *sp1;
|
||||
register short *sp2;
|
||||
register short *send;
|
||||
|
||||
p = (shifts *) allocate((unsigned) (sizeof(shifts) +
|
||||
(nshifts - 1) * sizeof(short)));
|
||||
|
||||
p->number = this_state->number;
|
||||
p->nshifts = nshifts;
|
||||
|
||||
sp1 = shiftset;
|
||||
sp2 = p->shift;
|
||||
send = shiftset + nshifts;
|
||||
|
||||
while (sp1 < send)
|
||||
*sp2++ = *sp1++;
|
||||
|
||||
if (last_shift)
|
||||
{
|
||||
last_shift->next = p;
|
||||
last_shift = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
first_shift = p;
|
||||
last_shift = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
save_reductions()
|
||||
{
|
||||
register short *isp;
|
||||
register short *rp1;
|
||||
register short *rp2;
|
||||
register int item;
|
||||
register int count;
|
||||
register reductions *p;
|
||||
register short *rend;
|
||||
|
||||
count = 0;
|
||||
for (isp = itemset; isp < itemsetend; isp++)
|
||||
{
|
||||
item = ritem[*isp];
|
||||
if (item < 0)
|
||||
{
|
||||
redset[count++] = -item;
|
||||
}
|
||||
}
|
||||
|
||||
if (count)
|
||||
{
|
||||
p = (reductions *) allocate((unsigned) (sizeof(reductions) +
|
||||
(count - 1) * sizeof(short)));
|
||||
|
||||
p->number = this_state->number;
|
||||
p->nreds = count;
|
||||
|
||||
rp1 = redset;
|
||||
rp2 = p->rules;
|
||||
rend = rp1 + count;
|
||||
|
||||
while (rp1 < rend)
|
||||
*rp2++ = *rp1++;
|
||||
|
||||
if (last_reduction)
|
||||
{
|
||||
last_reduction->next = p;
|
||||
last_reduction = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
first_reduction = p;
|
||||
last_reduction = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
set_derives()
|
||||
{
|
||||
register int i, k;
|
||||
register int lhs;
|
||||
register short *rules;
|
||||
|
||||
derives = NEW2(nsyms, short *);
|
||||
rules = NEW2(nvars + nrules, short);
|
||||
|
||||
k = 0;
|
||||
for (lhs = start_symbol; lhs < nsyms; lhs++)
|
||||
{
|
||||
derives[lhs] = rules + k;
|
||||
for (i = 0; i < nrules; i++)
|
||||
{
|
||||
if (rlhs[i] == lhs)
|
||||
{
|
||||
rules[k] = i;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
rules[k] = -1;
|
||||
k++;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
print_derives();
|
||||
#endif
|
||||
}
|
||||
|
||||
free_derives()
|
||||
{
|
||||
FREE(derives[start_symbol]);
|
||||
FREE(derives);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
print_derives()
|
||||
{
|
||||
register int i;
|
||||
register short *sp;
|
||||
|
||||
printf("\nDERIVES\n\n");
|
||||
|
||||
for (i = start_symbol; i < nsyms; i++)
|
||||
{
|
||||
printf("%s derives ", symbol_name[i]);
|
||||
for (sp = derives[i]; *sp >= 0; sp++)
|
||||
{
|
||||
printf(" %d", *sp);
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
set_nullable()
|
||||
{
|
||||
register int i, j;
|
||||
register int empty;
|
||||
int done;
|
||||
|
||||
nullable = MALLOC(nsyms);
|
||||
if (nullable == 0) no_space();
|
||||
|
||||
for (i = 0; i < nsyms; ++i)
|
||||
nullable[i] = 0;
|
||||
|
||||
done = 0;
|
||||
while (!done)
|
||||
{
|
||||
done = 1;
|
||||
for (i = 1; i < nitems; i++)
|
||||
{
|
||||
empty = 1;
|
||||
while ((j = ritem[i]) >= 0)
|
||||
{
|
||||
if (!nullable[j])
|
||||
empty = 0;
|
||||
++i;
|
||||
}
|
||||
if (empty)
|
||||
{
|
||||
j = rlhs[-j];
|
||||
if (!nullable[j])
|
||||
{
|
||||
nullable[j] = 1;
|
||||
done = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
for (i = 0; i < nsyms; i++)
|
||||
{
|
||||
if (nullable[i])
|
||||
printf("%s is nullable\n", symbol_name[i]);
|
||||
else
|
||||
printf("%s is not nullable\n", symbol_name[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
free_nullable()
|
||||
{
|
||||
FREE(nullable);
|
||||
}
|
||||
|
||||
|
||||
lr0()
|
||||
{
|
||||
set_derives();
|
||||
set_nullable();
|
||||
generate_states();
|
||||
}
|
||||
-341
@@ -1,341 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Robert Paul Corbett.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <signal.h>
|
||||
#include "defs.h"
|
||||
|
||||
char tflag;
|
||||
char vflag;
|
||||
char csharp = 0;
|
||||
|
||||
char *file_prefix = "y";
|
||||
char *myname = "yacc";
|
||||
char *temp_form = "yacc.XXXXXXX";
|
||||
|
||||
int lineno;
|
||||
int outline;
|
||||
|
||||
char *action_file_name;
|
||||
char *input_file_name = "";
|
||||
char *prolog_file_name;
|
||||
char *local_file_name;
|
||||
char *verbose_file_name;
|
||||
|
||||
FILE *action_file; /* a temp file, used to save actions associated */
|
||||
/* with rules until the parser is written */
|
||||
FILE *input_file; /* the input file */
|
||||
FILE *prolog_file; /* temp files, used to save text until all */
|
||||
FILE *local_file; /* symbols have been defined */
|
||||
FILE *verbose_file; /* y.output */
|
||||
|
||||
int nitems;
|
||||
int nrules;
|
||||
int nsyms;
|
||||
int ntokens;
|
||||
int nvars;
|
||||
|
||||
int start_symbol;
|
||||
char **symbol_name;
|
||||
short *symbol_value;
|
||||
short *symbol_prec;
|
||||
char *symbol_assoc;
|
||||
|
||||
short *ritem;
|
||||
short *rlhs;
|
||||
short *rrhs;
|
||||
short *rprec;
|
||||
char *rassoc;
|
||||
short **derives;
|
||||
char *nullable;
|
||||
|
||||
extern char *mktemp();
|
||||
extern char *getenv();
|
||||
|
||||
done(k)
|
||||
int k;
|
||||
{
|
||||
if (action_file) { fclose(action_file); unlink(action_file_name); }
|
||||
if (prolog_file) { fclose(prolog_file); unlink(prolog_file_name); }
|
||||
if (local_file) { fclose(local_file); unlink(local_file_name); }
|
||||
exit(k);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
onintr(signo)
|
||||
int signo;
|
||||
{
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
set_signals()
|
||||
{
|
||||
#ifdef SIGINT
|
||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
||||
signal(SIGINT, onintr);
|
||||
#endif
|
||||
#ifdef SIGTERM
|
||||
if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
|
||||
signal(SIGTERM, onintr);
|
||||
#endif
|
||||
#ifdef SIGHUP
|
||||
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
|
||||
signal(SIGHUP, onintr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-tvc] [-b file_prefix] filename\n", myname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
getargs(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
register int i;
|
||||
register char *s;
|
||||
|
||||
if (argc > 0) myname = argv[0];
|
||||
for (i = 1; i < argc; ++i)
|
||||
{
|
||||
s = argv[i];
|
||||
if (*s != '-') break;
|
||||
switch (*++s)
|
||||
{
|
||||
case '\0':
|
||||
input_file = stdin;
|
||||
if (i + 1 < argc) usage();
|
||||
return;
|
||||
|
||||
case '-':
|
||||
++i;
|
||||
goto no_more_options;
|
||||
|
||||
case 'b':
|
||||
if (*++s)
|
||||
file_prefix = s;
|
||||
else if (++i < argc)
|
||||
file_prefix = argv[i];
|
||||
else
|
||||
usage();
|
||||
continue;
|
||||
|
||||
case 't':
|
||||
tflag = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
csharp = 1;
|
||||
line_format = "#line %d \"%s\"\n";
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
switch (*++s)
|
||||
{
|
||||
case '\0':
|
||||
goto end_of_option;
|
||||
|
||||
case 't':
|
||||
tflag = 1;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
csharp = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
end_of_option:;
|
||||
}
|
||||
|
||||
no_more_options:;
|
||||
if (i + 1 != argc) usage();
|
||||
input_file_name = argv[i];
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
allocate(n)
|
||||
unsigned n;
|
||||
{
|
||||
register char *p;
|
||||
|
||||
p = NULL;
|
||||
if (n)
|
||||
{
|
||||
p = CALLOC(1, n);
|
||||
if (!p) no_space();
|
||||
}
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
create_file_names()
|
||||
{
|
||||
int i, len;
|
||||
char *tmpdir;
|
||||
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (tmpdir == 0) tmpdir = "/tmp";
|
||||
|
||||
len = strlen(tmpdir);
|
||||
i = len + 13;
|
||||
if (len && tmpdir[len-1] != '/')
|
||||
++i;
|
||||
|
||||
action_file_name = MALLOC(i);
|
||||
if (action_file_name == 0) no_space();
|
||||
prolog_file_name = MALLOC(i);
|
||||
if (prolog_file_name == 0) no_space();
|
||||
local_file_name = MALLOC(i);
|
||||
if (local_file_name == 0) no_space();
|
||||
|
||||
strcpy(action_file_name, tmpdir);
|
||||
strcpy(prolog_file_name, tmpdir);
|
||||
strcpy(local_file_name, tmpdir);
|
||||
|
||||
if (len && tmpdir[len - 1] != '/')
|
||||
{
|
||||
action_file_name[len] = '/';
|
||||
prolog_file_name[len] = '/';
|
||||
local_file_name[len] = '/';
|
||||
++len;
|
||||
}
|
||||
|
||||
strcpy(action_file_name + len, temp_form);
|
||||
strcpy(prolog_file_name + len, temp_form);
|
||||
strcpy(local_file_name + len, temp_form);
|
||||
|
||||
action_file_name[len + 5] = 'a';
|
||||
prolog_file_name[len + 5] = 'p';
|
||||
local_file_name[len + 5] = 'l';
|
||||
|
||||
mktemp(action_file_name);
|
||||
mktemp(prolog_file_name);
|
||||
mktemp(local_file_name);
|
||||
|
||||
len = strlen(file_prefix);
|
||||
|
||||
if (vflag)
|
||||
{
|
||||
verbose_file_name = MALLOC(len + 8);
|
||||
if (verbose_file_name == 0)
|
||||
no_space();
|
||||
strcpy(verbose_file_name, file_prefix);
|
||||
strcpy(verbose_file_name + len, VERBOSE_SUFFIX);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
open_files()
|
||||
{
|
||||
create_file_names();
|
||||
|
||||
if (input_file == 0)
|
||||
{
|
||||
input_file = fopen(input_file_name, "r");
|
||||
if (input_file == 0)
|
||||
open_error(input_file_name);
|
||||
}
|
||||
|
||||
action_file = fopen(action_file_name, "w");
|
||||
if (action_file == 0)
|
||||
open_error(action_file_name);
|
||||
|
||||
prolog_file = fopen(prolog_file_name, "w");
|
||||
if (prolog_file == 0)
|
||||
open_error(prolog_file_name);
|
||||
|
||||
local_file = fopen(local_file_name, "w");
|
||||
if (local_file == 0)
|
||||
open_error(local_file_name);
|
||||
|
||||
if (vflag)
|
||||
{
|
||||
verbose_file = fopen(verbose_file_name, "w");
|
||||
if (verbose_file == 0)
|
||||
open_error(verbose_file_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
set_signals();
|
||||
getargs(argc, argv);
|
||||
open_files();
|
||||
reader();
|
||||
lr0();
|
||||
lalr();
|
||||
make_parser();
|
||||
verbose();
|
||||
output();
|
||||
done(0);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
all = jay
|
||||
c = closure.c error.c lalr.c lr0.c main.c mkpar.c output.c reader.c \
|
||||
symtab.c verbose.c warshall.c
|
||||
|
||||
CFLAGS=#-g
|
||||
|
||||
jay: $(c:.c=.o) ; $(CC) -o $@ $(CFLAGS) $(c:.c=.o)
|
||||
|
||||
clean:
|
||||
rm -f jay *.o
|
||||
|
||||
windows: jay
|
||||
|
||||
unix: jay
|
||||
-395
@@ -1,395 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Robert Paul Corbett.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)mkpar.c 5.3 (Berkeley) 1/20/91";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
action **parser;
|
||||
int SRtotal;
|
||||
int RRtotal;
|
||||
short *SRconflicts;
|
||||
short *RRconflicts;
|
||||
short *defred;
|
||||
short *rules_used;
|
||||
short nunused;
|
||||
short final_state;
|
||||
|
||||
static int SRcount;
|
||||
static int RRcount;
|
||||
|
||||
extern action *parse_actions();
|
||||
extern action *get_shifts();
|
||||
extern action *add_reductions();
|
||||
extern action *add_reduce();
|
||||
|
||||
|
||||
make_parser()
|
||||
{
|
||||
register int i;
|
||||
|
||||
parser = NEW2(nstates, action *);
|
||||
for (i = 0; i < nstates; i++)
|
||||
parser[i] = parse_actions(i);
|
||||
|
||||
find_final_state();
|
||||
remove_conflicts();
|
||||
unused_rules();
|
||||
if (SRtotal + RRtotal > 0) total_conflicts();
|
||||
defreds();
|
||||
}
|
||||
|
||||
|
||||
action *
|
||||
parse_actions(stateno)
|
||||
register int stateno;
|
||||
{
|
||||
register action *actions;
|
||||
|
||||
actions = get_shifts(stateno);
|
||||
actions = add_reductions(stateno, actions);
|
||||
return (actions);
|
||||
}
|
||||
|
||||
|
||||
action *
|
||||
get_shifts(stateno)
|
||||
int stateno;
|
||||
{
|
||||
register action *actions, *temp;
|
||||
register shifts *sp;
|
||||
register short *to_state;
|
||||
register int i, k;
|
||||
register int symbol;
|
||||
|
||||
actions = 0;
|
||||
sp = shift_table[stateno];
|
||||
if (sp)
|
||||
{
|
||||
to_state = sp->shift;
|
||||
for (i = sp->nshifts - 1; i >= 0; i--)
|
||||
{
|
||||
k = to_state[i];
|
||||
symbol = accessing_symbol[k];
|
||||
if (ISTOKEN(symbol))
|
||||
{
|
||||
temp = NEW(action);
|
||||
temp->next = actions;
|
||||
temp->symbol = symbol;
|
||||
temp->number = k;
|
||||
temp->prec = symbol_prec[symbol];
|
||||
temp->action_code = SHIFT;
|
||||
temp->assoc = symbol_assoc[symbol];
|
||||
actions = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (actions);
|
||||
}
|
||||
|
||||
action *
|
||||
add_reductions(stateno, actions)
|
||||
int stateno;
|
||||
register action *actions;
|
||||
{
|
||||
register int i, j, m, n;
|
||||
register int ruleno, tokensetsize;
|
||||
register unsigned *rowp;
|
||||
|
||||
tokensetsize = WORDSIZE(ntokens);
|
||||
m = lookaheads[stateno];
|
||||
n = lookaheads[stateno + 1];
|
||||
for (i = m; i < n; i++)
|
||||
{
|
||||
ruleno = LAruleno[i];
|
||||
rowp = LA + i * tokensetsize;
|
||||
for (j = ntokens - 1; j >= 0; j--)
|
||||
{
|
||||
if (BIT(rowp, j))
|
||||
actions = add_reduce(actions, ruleno, j);
|
||||
}
|
||||
}
|
||||
return (actions);
|
||||
}
|
||||
|
||||
|
||||
action *
|
||||
add_reduce(actions, ruleno, symbol)
|
||||
register action *actions;
|
||||
register int ruleno, symbol;
|
||||
{
|
||||
register action *temp, *prev, *next;
|
||||
|
||||
prev = 0;
|
||||
for (next = actions; next && next->symbol < symbol; next = next->next)
|
||||
prev = next;
|
||||
|
||||
while (next && next->symbol == symbol && next->action_code == SHIFT)
|
||||
{
|
||||
prev = next;
|
||||
next = next->next;
|
||||
}
|
||||
|
||||
while (next && next->symbol == symbol &&
|
||||
next->action_code == REDUCE && next->number < ruleno)
|
||||
{
|
||||
prev = next;
|
||||
next = next->next;
|
||||
}
|
||||
|
||||
temp = NEW(action);
|
||||
temp->next = next;
|
||||
temp->symbol = symbol;
|
||||
temp->number = ruleno;
|
||||
temp->prec = rprec[ruleno];
|
||||
temp->action_code = REDUCE;
|
||||
temp->assoc = rassoc[ruleno];
|
||||
|
||||
if (prev)
|
||||
prev->next = temp;
|
||||
else
|
||||
actions = temp;
|
||||
|
||||
return (actions);
|
||||
}
|
||||
|
||||
|
||||
find_final_state()
|
||||
{
|
||||
register int goal, i;
|
||||
register short *to_state;
|
||||
register shifts *p;
|
||||
|
||||
p = shift_table[0];
|
||||
to_state = p->shift;
|
||||
goal = ritem[1];
|
||||
for (i = p->nshifts - 1; i >= 0; --i)
|
||||
{
|
||||
final_state = to_state[i];
|
||||
if (accessing_symbol[final_state] == goal) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unused_rules()
|
||||
{
|
||||
register int i;
|
||||
register action *p;
|
||||
|
||||
rules_used = (short *) MALLOC(nrules*sizeof(short));
|
||||
if (rules_used == 0) no_space();
|
||||
|
||||
for (i = 0; i < nrules; ++i)
|
||||
rules_used[i] = 0;
|
||||
|
||||
for (i = 0; i < nstates; ++i)
|
||||
{
|
||||
for (p = parser[i]; p; p = p->next)
|
||||
{
|
||||
if (p->action_code == REDUCE && p->suppressed == 0)
|
||||
rules_used[p->number] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
nunused = 0;
|
||||
for (i = 3; i < nrules; ++i)
|
||||
if (!rules_used[i]) ++nunused;
|
||||
|
||||
if (nunused)
|
||||
if (nunused == 1)
|
||||
fprintf(stderr, "%s: 1 rule never reduced\n", myname);
|
||||
else
|
||||
fprintf(stderr, "%s: %d rules never reduced\n", myname, nunused);
|
||||
}
|
||||
|
||||
|
||||
remove_conflicts()
|
||||
{
|
||||
register int i;
|
||||
register int symbol;
|
||||
register action *p, *pref;
|
||||
|
||||
SRtotal = 0;
|
||||
RRtotal = 0;
|
||||
SRconflicts = NEW2(nstates, short);
|
||||
RRconflicts = NEW2(nstates, short);
|
||||
for (i = 0; i < nstates; i++)
|
||||
{
|
||||
SRcount = 0;
|
||||
RRcount = 0;
|
||||
symbol = -1;
|
||||
for (p = parser[i]; p; p = p->next)
|
||||
{
|
||||
if (p->symbol != symbol)
|
||||
{
|
||||
pref = p;
|
||||
symbol = p->symbol;
|
||||
}
|
||||
else if (i == final_state && symbol == 0)
|
||||
{
|
||||
SRcount++;
|
||||
p->suppressed = 1;
|
||||
}
|
||||
else if (pref->action_code == SHIFT)
|
||||
{
|
||||
if (pref->prec > 0 && p->prec > 0)
|
||||
{
|
||||
if (pref->prec < p->prec)
|
||||
{
|
||||
pref->suppressed = 2;
|
||||
pref = p;
|
||||
}
|
||||
else if (pref->prec > p->prec)
|
||||
{
|
||||
p->suppressed = 2;
|
||||
}
|
||||
else if (pref->assoc == LEFT)
|
||||
{
|
||||
pref->suppressed = 2;
|
||||
pref = p;
|
||||
}
|
||||
else if (pref->assoc == RIGHT)
|
||||
{
|
||||
p->suppressed = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pref->suppressed = 2;
|
||||
p->suppressed = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SRcount++;
|
||||
p->suppressed = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RRcount++;
|
||||
p->suppressed = 1;
|
||||
}
|
||||
}
|
||||
SRtotal += SRcount;
|
||||
RRtotal += RRcount;
|
||||
SRconflicts[i] = SRcount;
|
||||
RRconflicts[i] = RRcount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
total_conflicts()
|
||||
{
|
||||
fprintf(stderr, "%s: ", myname);
|
||||
if (SRtotal == 1)
|
||||
fprintf(stderr, "1 shift/reduce conflict");
|
||||
else if (SRtotal > 1)
|
||||
fprintf(stderr, "%d shift/reduce conflicts", SRtotal);
|
||||
|
||||
if (SRtotal && RRtotal)
|
||||
fprintf(stderr, ", ");
|
||||
|
||||
if (RRtotal == 1)
|
||||
fprintf(stderr, "1 reduce/reduce conflict");
|
||||
else if (RRtotal > 1)
|
||||
fprintf(stderr, "%d reduce/reduce conflicts", RRtotal);
|
||||
|
||||
fprintf(stderr, ".\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sole_reduction(stateno)
|
||||
int stateno;
|
||||
{
|
||||
register int count, ruleno;
|
||||
register action *p;
|
||||
|
||||
count = 0;
|
||||
ruleno = 0;
|
||||
for (p = parser[stateno]; p; p = p->next)
|
||||
{
|
||||
if (p->action_code == SHIFT && p->suppressed == 0)
|
||||
return (0);
|
||||
else if (p->action_code == REDUCE && p->suppressed == 0)
|
||||
{
|
||||
if (ruleno > 0 && p->number != ruleno)
|
||||
return (0);
|
||||
if (p->symbol != 1)
|
||||
++count;
|
||||
ruleno = p->number;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
return (0);
|
||||
return (ruleno);
|
||||
}
|
||||
|
||||
|
||||
defreds()
|
||||
{
|
||||
register int i;
|
||||
|
||||
defred = NEW2(nstates, short);
|
||||
for (i = 0; i < nstates; i++)
|
||||
defred[i] = sole_reduction(i);
|
||||
}
|
||||
|
||||
free_action_row(p)
|
||||
register action *p;
|
||||
{
|
||||
register action *q;
|
||||
|
||||
while (p)
|
||||
{
|
||||
q = p->next;
|
||||
FREE(p);
|
||||
p = q;
|
||||
}
|
||||
}
|
||||
|
||||
free_parser()
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < nstates; i++)
|
||||
free_action_row(parser[i]);
|
||||
|
||||
FREE(parser);
|
||||
}
|
||||
Loaded 100 of 135 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user