Merge remote-tracking branch 'github/master'

Conflicts:
	.gitignore
	CoreFX
	CppNet.sln
	CppNet_CoreCLR.csproj
	LexerSource.cs
	Preprocessor.cs
	SourceIterator.cs
This commit is contained in:
Manu 2016-07-01 15:21:13 +09:00
Родитель b76f8ebe66 e4b64ada8f
Коммит 4bd1ad0ed0
21 изменённых файлов: 2695 добавлений и 2802 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -1,4 +1,5 @@
project.lock.json
.vs/
bin/
Bin/
obj/

Просмотреть файл

@ -1,72 +1,72 @@
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace CppNet {
/**
* A macro argument.
*
* This encapsulates a raw and preprocessed token stream.
*/
internal class Argument : List<Token> {
public const int NO_ARGS = -1;
private List<Token> _expansion;
using System.Text;
namespace CppNet {
/**
* A macro argument.
*
* This encapsulates a raw and preprocessed token stream.
*/
internal class Argument : List<Token> {
public const int NO_ARGS = -1;
private List<Token> _expansion;
public Argument() {
this._expansion = null;
}
public void addToken(Token tok) {
Add(tok);
}
internal void expand(Preprocessor p) {
this._expansion = null;
}
public void addToken(Token tok) {
Add(tok);
}
internal void expand(Preprocessor p) {
/* Cache expansion. */
if(_expansion == null) {
this._expansion = p.expand(this);
// System.out.println("Expanded arg " + this);
}
this._expansion = p.expand(this);
// System.out.println("Expanded arg " + this);
}
}
public Iterator<Token> expansion()
{
return _expansion.iterator();
}
override public String ToString() {
StringBuilder buf = new StringBuilder();
buf.Append("Argument(");
// buf.Append(super.toString());
buf.Append("raw=[ ");
for (int i = 0; i < this.Count; i++)
buf.Append(this[i].getText());
}
override public String ToString() {
StringBuilder buf = new StringBuilder();
buf.Append("Argument(");
// buf.Append(super.toString());
buf.Append("raw=[ ");
for (int i = 0; i < this.Count; i++)
buf.Append(this[i].getText());
buf.Append(" ];expansion=[ ");
if(_expansion == null)
buf.Append("null");
if(_expansion == null)
buf.Append("null");
else
for(int i = 0; i < _expansion.Count; i++)
buf.Append(_expansion[i].getText());
buf.Append(" ])");
return buf.ToString();
}
}
}
buf.Append(_expansion[i].getText());
buf.Append(" ])");
return buf.ToString();
}
}
}

2
CoreFX

@ -1 +1 @@
Subproject commit 00c228f7e217e44afd3031955891e3ef67cf34fe
Subproject commit 32c2d0c0b6b0675b0ce22b13b7f85d5ae3e78e8d

Просмотреть файл

@ -1,108 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{197C3819-9942-408D-AFBC-951FA7A69259}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CppNet</RootNamespace>
<AssemblyName>CppNet</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkRootPath>$(MSBuildThisFileDirectory)\CoreFX\</TargetFrameworkRootPath>
<FrameworkPathOverride>$(TargetFrameworkRootPath)\CoreCLR\v5.0</FrameworkPathOverride>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\CoreCLR\Debug\</OutputPath>
<IntermediateOutputPath>obj\CoreCLR</IntermediateOutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\CoreCLR\Release\</OutputPath>
<IntermediateOutputPath>obj\CoreCLR</IntermediateOutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugCoreCLR|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\CoreCLR\Debug\</OutputPath>
<IntermediateOutputPath>obj\CoreCLR</IntermediateOutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseCoreCLR|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\CoreCLR\Release\</OutputPath>
<IntermediateOutputPath>obj\CoreCLR</IntermediateOutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>cppnet.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Argument.cs" />
<Compile Include="Feature.cs" />
<Compile Include="FileLexerSource.cs" />
<Compile Include="FixedTokenSource.cs" />
<Compile Include="JavaCompat\JavaCompat.cs" />
<Compile Include="JavaFile.cs" />
<Compile Include="JavaFileSystem.cs" />
<Compile Include="JoinReader.cs" />
<Compile Include="LexerException.cs" />
<Compile Include="LexerSource.cs" />
<Compile Include="Macro.cs" />
<Compile Include="MacroTokenSource.cs" />
<Compile Include="Preprocessor.cs" />
<Compile Include="PreprocessorListener.cs" />
<Compile Include="PreprocessorListenerBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Source.cs" />
<Compile Include="SourceIterator.cs" />
<Compile Include="State.cs" />
<Compile Include="StringLexerSource.cs" />
<Compile Include="Token.cs" />
<Compile Include="VirtualFile.cs" />
<Compile Include="VirtualFileSystem.cs" />
<Compile Include="Warning.cs" />
</ItemGroup>
<ItemGroup>
<None Include="cppnet.snk" />
</ItemGroup>
<Import Project="$(TargetFrameworkRootPath)\configs\CoreCLR.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -1,26 +1,26 @@
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
namespace CppNet
{
/**
* Features of the Preprocessor, which may be enabled or disabled.
/**
* Features of the Preprocessor, which may be enabled or disabled.
*/
[Flags]
public enum Feature
@ -46,4 +46,4 @@ namespace CppNet
INCLUDENEXT = 1 << 9
}
}
}

Просмотреть файл

@ -64,4 +64,4 @@ public class FileLexerSource : LexerSource {
}
}
}
}

Просмотреть файл

@ -1,57 +1,57 @@
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Text;
using System.Collections.Generic;
namespace CppNet {
internal class FixedTokenSource : Source {
private static readonly Token EOF =
new Token(Token.EOF, "<ts-eof>");
private List<Token> tokens;
private int idx;
using System.Collections.Generic;
namespace CppNet {
internal class FixedTokenSource : Source {
private static readonly Token EOF =
new Token(Token.EOF, "<ts-eof>");
private List<Token> tokens;
private int idx;
internal FixedTokenSource(params Token[] tokens) {
this.tokens = new List<Token>(tokens);
this.idx = 0;
}
internal FixedTokenSource(List<Token> tokens) {
this.tokens = tokens;
this.idx = 0;
}
public override Token token() {
if (idx >= tokens.Count)
return EOF;
return tokens[idx++];
}
override public String ToString() {
StringBuilder buf = new StringBuilder();
buf.Append("constant token stream " + tokens);
Source parent = getParent();
if (parent != null)
buf.Append(" in ").Append(parent);
return buf.ToString();
}
}
}
this.tokens = new List<Token>(tokens);
this.idx = 0;
}
internal FixedTokenSource(List<Token> tokens) {
this.tokens = tokens;
this.idx = 0;
}
public override Token token() {
if (idx >= tokens.Count)
return EOF;
return tokens[idx++];
}
override public String ToString() {
StringBuilder buf = new StringBuilder();
buf.Append("constant token stream " + tokens);
Source parent = getParent();
if (parent != null)
buf.Append(" in ").Append(parent);
return buf.ToString();
}
}
}

Просмотреть файл

@ -1,27 +1,27 @@
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.IO;
namespace CppNet
{
/**
* A virtual filesystem implementation using java.io.
/**
* A virtual filesystem implementation using java.io.
*/
public class JavaFileSystem : VirtualFileSystem
{
@ -37,4 +37,4 @@ namespace CppNet
return new JavaFile(Path.Combine(dir, name));
}
}
}
}

Просмотреть файл

@ -1,32 +1,32 @@
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
namespace CppNet {
/**
* A preprocessor exception.
*
* Note to users: I don't really like the name of this class. S.
*/
using System;
namespace CppNet {
/**
* A preprocessor exception.
*
* Note to users: I don't really like the name of this class. S.
*/
public class LexerException : Exception {
public LexerException(String msg) : base(msg) { }
public LexerException(Exception cause) : base(cause.Message, cause) {}
}
}
public LexerException(String msg) : base(msg) { }
public LexerException(Exception cause) : base(cause.Message, cause) {}
}
}

160
Macro.cs
Просмотреть файл

@ -1,18 +1,18 @@
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
@ -20,20 +20,20 @@ using System.Text;
namespace CppNet
{
/**
* A macro object.
*
* This encapsulates a name, an argument count, and a token stream
* for replacement. The replacement token stream may contain the
* extra tokens {@link Token#M_ARG} and {@link Token#M_STRING}.
/**
* A macro object.
*
* This encapsulates a name, an argument count, and a token stream
* for replacement. The replacement token stream may contain the
* extra tokens {@link Token#M_ARG} and {@link Token#M_STRING}.
*/
public class Macro
{
private Source source;
private String name;
/* It's an explicit decision to keep these around here. We don't
* need to; the argument token type is M_ARG and the value
* is the index. The strings themselves are only used in
/* It's an explicit decision to keep these around here. We don't
* need to; the argument token type is M_ARG and the value
* is the index. The strings themselves are only used in
* stringification of the macro, for debugging. */
private List<String> args;
private bool variadic;
@ -53,96 +53,96 @@ namespace CppNet
{
}
/**
* Sets the Source from which this macro was parsed.
/**
* Sets the Source from which this macro was parsed.
*/
public void setSource(Source s)
{
this.source = s;
}
/**
* Returns the Source from which this macro was parsed.
*
* This method may return null if the macro was not parsed
* from a regular file.
/**
* Returns the Source from which this macro was parsed.
*
* This method may return null if the macro was not parsed
* from a regular file.
*/
public Source getSource()
{
return source;
}
/**
* Returns the name of this macro.
/**
* Returns the name of this macro.
*/
public String getName()
{
return name;
}
/**
* Sets the arguments to this macro.
/**
* Sets the arguments to this macro.
*/
public void setArgs(List<String> args)
{
this.args = args;
}
/**
* Returns true if this is a function-like macro.
/**
* Returns true if this is a function-like macro.
*/
public bool isFunctionLike()
{
return args != null;
}
/**
* Returns the number of arguments to this macro.
/**
* Returns the number of arguments to this macro.
*/
public int getArgs()
{
return args.Count;
}
/**
* Sets the variadic flag on this Macro.
/**
* Sets the variadic flag on this Macro.
*/
public void setVariadic(bool b)
{
this.variadic = b;
}
/**
* Returns true if this is a variadic function-like macro.
/**
* Returns true if this is a variadic function-like macro.
*/
public bool isVariadic()
{
return variadic;
}
/**
* Adds a token to the expansion of this macro.
/**
* Adds a token to the expansion of this macro.
*/
public void addToken(Token tok)
{
this.tokens.Add(tok);
}
/**
* Adds a "paste" operator to the expansion of this macro.
*
* A paste operator causes the next token added to be pasted
* to the previous token when the macro is expanded.
* It is an error for a macro to end with a paste token.
/**
* Adds a "paste" operator to the expansion of this macro.
*
* A paste operator causes the next token added to be pasted
* to the previous token when the macro is expanded.
* It is an error for a macro to end with a paste token.
*/
public void addPaste(Token tok)
{
/*
* Given: tok0 ## tok1
* We generate: M_PASTE, tok0, tok1
* This extends as per a stack language:
* tok0 ## tok1 ## tok2 ->
* M_PASTE, tok0, M_PASTE, tok1, tok2
/*
* Given: tok0 ## tok1
* We generate: M_PASTE, tok0, tok1
* This extends as per a stack language:
* tok0 ## tok1 ## tok2 ->
* M_PASTE, tok0, M_PASTE, tok1, tok2
*/
this.tokens.Insert(tokens.Count - 1, tok);
}
@ -152,30 +152,30 @@ namespace CppNet
return tokens;
}
/* Paste tokens are inserted before the first of the two pasted
* tokens, so it's a kind of bytecode notation. This method
* swaps them around again. We know that there will never be two
/* Paste tokens are inserted before the first of the two pasted
* tokens, so it's a kind of bytecode notation. This method
* swaps them around again. We know that there will never be two
* sequential paste tokens, so a bool is sufficient. */
public String getText() {
StringBuilder buf = new StringBuilder();
bool paste = false;
for (int i = 0; i < tokens.Count; i++) {
Token tok = tokens[i];
if (tok.getType() == Token.M_PASTE) {
System.Diagnostics.Debug.Assert(paste == false, "Two sequential pastes.");
paste = true;
continue;
}
else {
buf.Append(tok.getText());
}
if (paste) {
buf.Append(" #" + "# ");
paste = false;
}
// buf.Append(tokens.get(i));
}
return buf.ToString();
public String getText() {
StringBuilder buf = new StringBuilder();
bool paste = false;
for (int i = 0; i < tokens.Count; i++) {
Token tok = tokens[i];
if (tok.getType() == Token.M_PASTE) {
System.Diagnostics.Debug.Assert(paste == false, "Two sequential pastes.");
paste = true;
continue;
}
else {
buf.Append(tok.getText());
}
if (paste) {
buf.Append(" #" + "# ");
paste = false;
}
// buf.Append(tokens.get(i));
}
return buf.ToString();
}
override public String ToString()

Просмотреть файл

@ -1,30 +1,30 @@
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Text;
using System.Collections.Generic;
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Text;
using System.Collections.Generic;
using boolean = System.Boolean;
using Debug = System.Diagnostics.Debug;
namespace CppNet {
/* This source should always be active, since we don't expand macros
* in any inactive context. */
internal class MacroTokenSource : Source {
using Debug = System.Diagnostics.Debug;
namespace CppNet {
/* This source should always be active, since we don't expand macros
* in any inactive context. */
internal class MacroTokenSource : Source {
private Macro macro;
private Iterator<Token> tokens; /* Pointer into the macro. */
private List<Argument> args; /* { unexpanded, expanded } */
@ -186,16 +186,16 @@ internal class MacroTokenSource : Source {
}
} /* for */
}
override public String ToString() {
StringBuilder buf = new StringBuilder();
buf.Append("expansion of ").Append(macro.getName());
Source parent = getParent();
if (parent != null)
buf.Append(" in ").Append(parent);
return buf.ToString();
}
}
}
override public String ToString() {
StringBuilder buf = new StringBuilder();
buf.Append("expansion of ").Append(macro.getName());
Source parent = getParent();
if (parent != null)
buf.Append(" in ").Append(parent);
return buf.ToString();
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -76,4 +76,4 @@ namespace CppNet
public virtual void handleSourceChange(Source source, String ev) {
}
}
}
}

Просмотреть файл

@ -1,18 +1,18 @@
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
@ -23,16 +23,16 @@ namespace CppNet
{
/**
* An input to the Preprocessor.
*
* Inputs may come from Files, Strings or other sources. The
* preprocessor maintains a stack of Sources. Operations such as
* file inclusion or token pasting will push a new source onto
* the Preprocessor stack. Sources pop from the stack when they
* are exhausted; this may be transparent or explicit.
*
* BUG: Error messages are not handled properly.
/**
* An input to the Preprocessor.
*
* Inputs may come from Files, Strings or other sources. The
* preprocessor maintains a stack of Sources. Operations such as
* file inclusion or token pasting will push a new source onto
* the Preprocessor stack. Sources pop from the stack when they
* are exhausted; this may be transparent or explicit.
*
* BUG: Error messages are not handled properly.
*/
public abstract class Source : Iterable<Token>, Closeable
{
@ -295,4 +295,4 @@ namespace CppNet
}
}
}
}

Просмотреть файл

@ -13,84 +13,84 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.IO;
using boolean = System.Boolean;
namespace CppNet
{
*/
using System;
using System.Collections.Generic;
using System.IO;
using boolean = System.Boolean;
namespace CppNet
{
/**
* An Iterator for {@link Source Sources},
* returning {@link Token Tokens}.
*/
public class SourceIterator : Iterator<Token>
{
private Source source;
private Token tok;
public SourceIterator(Source s)
{
this.source = s;
this.tok = null;
}
/**
* Rethrows IOException inside IllegalStateException.
*/
private void advance()
{
try {
if(tok == null)
tok = source.token();
} catch(LexerException e) {
throw new IllegalStateException(e);
}
}
/**
* Returns true if the enclosed Source has more tokens.
*
* The EOF token is never returned by the iterator.
* @throws IllegalStateException if the Source
* throws a LexerException or IOException
*/
public boolean hasNext()
{
advance();
return tok.getType() != Token.EOF;
}
/**
* Returns the next token from the enclosed Source.
*
* The EOF token is never returned by the iterator.
* @throws IllegalStateException if the Source
* throws a LexerException or IOException
*/
public Token next()
{
if(!hasNext())
throw new ArgumentOutOfRangeException();
Token t = this.tok;
this.tok = null;
return t;
}
/**
* Not supported.
*
* @throws UnsupportedOperationException.
*/
public void remove()
{
throw new NotSupportedException();
}
}
*/
public class SourceIterator : Iterator<Token>
{
private Source source;
private Token tok;
public SourceIterator(Source s)
{
this.source = s;
this.tok = null;
}
/**
* Rethrows IOException inside IllegalStateException.
*/
private void advance()
{
try {
if(tok == null)
tok = source.token();
} catch(LexerException e) {
throw new IllegalStateException(e);
} catch(IOException e) {
throw new Exception("",e);
}
}
/**
* Returns true if the enclosed Source has more tokens.
*
* The EOF token is never returned by the iterator.
* @throws IllegalStateException if the Source
* throws a LexerException or IOException
*/
public boolean hasNext()
{
advance();
return tok.getType() != Token.EOF;
}
/**
* Returns the next token from the enclosed Source.
*
* The EOF token is never returned by the iterator.
* @throws IllegalStateException if the Source
* throws a LexerException or IOException
*/
public Token next()
{
if(!hasNext())
throw new ArgumentOutOfRangeException();
Token t = this.tok;
this.tok = null;
return t;
}
/**
* Not supported.
*
* @throws UnsupportedOperationException.
*/
public void remove()
{
throw new NotSupportedException();
}
}
}

Просмотреть файл

@ -1,18 +1,18 @@
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
@ -86,4 +86,4 @@ namespace CppNet
", sawelse=" + _sawElse;
}
}
}
}

Просмотреть файл

@ -66,4 +66,4 @@ public class StringLexerSource : LexerSource
}
}
}
}

Просмотреть файл

@ -350,4 +350,4 @@ namespace CppNet {
}
}
}
}

Просмотреть файл

@ -30,4 +30,4 @@ public interface VirtualFile {
Source getSource();
}
}
}

Просмотреть файл

@ -1,25 +1,25 @@
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
/*
* Anarres C Preprocessor
* Copyright (c) 2007-2008, Shevek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
namespace CppNet
{
/**
* An extremely lightweight virtual file system interface.
/**
* An extremely lightweight virtual file system interface.
*/
public interface VirtualFileSystem
{
@ -27,4 +27,4 @@ namespace CppNet
VirtualFile getFile(String dir, String name);
}
}
}

Просмотреть файл

@ -35,4 +35,4 @@ namespace CppNet
// SYSTEM_HEADERS
}
}
}