зеркало из https://github.com/stride3d/CppNet.git
Fix invalid newlines
This commit is contained in:
Родитель
4b7387ccbb
Коммит
e4b64ada8f
120
Argument.cs
120
Argument.cs
|
@ -1,72 +1,72 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace CppNet {
|
namespace CppNet {
|
||||||
/**
|
/**
|
||||||
* A macro argument.
|
* A macro argument.
|
||||||
*
|
*
|
||||||
* This encapsulates a raw and preprocessed token stream.
|
* This encapsulates a raw and preprocessed token stream.
|
||||||
*/
|
*/
|
||||||
internal class Argument : List<Token> {
|
internal class Argument : List<Token> {
|
||||||
public const int NO_ARGS = -1;
|
public const int NO_ARGS = -1;
|
||||||
|
|
||||||
private List<Token> _expansion;
|
private List<Token> _expansion;
|
||||||
|
|
||||||
public Argument() {
|
public Argument() {
|
||||||
this._expansion = null;
|
this._expansion = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToken(Token tok) {
|
public void addToken(Token tok) {
|
||||||
Add(tok);
|
Add(tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void expand(Preprocessor p) {
|
internal void expand(Preprocessor p) {
|
||||||
/* Cache expansion. */
|
/* Cache expansion. */
|
||||||
if(_expansion == null) {
|
if(_expansion == null) {
|
||||||
this._expansion = p.expand(this);
|
this._expansion = p.expand(this);
|
||||||
// System.out.println("Expanded arg " + this);
|
// System.out.println("Expanded arg " + this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterator<Token> expansion()
|
public Iterator<Token> expansion()
|
||||||
{
|
{
|
||||||
return _expansion.iterator();
|
return _expansion.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
override public String ToString() {
|
override public String ToString() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.Append("Argument(");
|
buf.Append("Argument(");
|
||||||
// buf.Append(super.toString());
|
// buf.Append(super.toString());
|
||||||
buf.Append("raw=[ ");
|
buf.Append("raw=[ ");
|
||||||
for (int i = 0; i < this.Count; i++)
|
for (int i = 0; i < this.Count; i++)
|
||||||
buf.Append(this[i].getText());
|
buf.Append(this[i].getText());
|
||||||
buf.Append(" ];expansion=[ ");
|
buf.Append(" ];expansion=[ ");
|
||||||
if(_expansion == null)
|
if(_expansion == null)
|
||||||
buf.Append("null");
|
buf.Append("null");
|
||||||
else
|
else
|
||||||
for(int i = 0; i < _expansion.Count; i++)
|
for(int i = 0; i < _expansion.Count; i++)
|
||||||
buf.Append(_expansion[i].getText());
|
buf.Append(_expansion[i].getText());
|
||||||
buf.Append(" ])");
|
buf.Append(" ])");
|
||||||
return buf.ToString();
|
return buf.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
36
Feature.cs
36
Feature.cs
|
@ -1,26 +1,26 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace CppNet
|
namespace CppNet
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Features of the Preprocessor, which may be enabled or disabled.
|
* Features of the Preprocessor, which may be enabled or disabled.
|
||||||
*/
|
*/
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum Feature
|
public enum Feature
|
||||||
|
@ -46,4 +46,4 @@ namespace CppNet
|
||||||
INCLUDENEXT = 1 << 9
|
INCLUDENEXT = 1 << 9
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,4 +64,4 @@ public class FileLexerSource : LexerSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,57 +1,57 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace CppNet {
|
namespace CppNet {
|
||||||
|
|
||||||
internal class FixedTokenSource : Source {
|
internal class FixedTokenSource : Source {
|
||||||
private static readonly Token EOF =
|
private static readonly Token EOF =
|
||||||
new Token(Token.EOF, "<ts-eof>");
|
new Token(Token.EOF, "<ts-eof>");
|
||||||
|
|
||||||
private List<Token> tokens;
|
private List<Token> tokens;
|
||||||
private int idx;
|
private int idx;
|
||||||
|
|
||||||
internal FixedTokenSource(params Token[] tokens) {
|
internal FixedTokenSource(params Token[] tokens) {
|
||||||
this.tokens = new List<Token>(tokens);
|
this.tokens = new List<Token>(tokens);
|
||||||
this.idx = 0;
|
this.idx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal FixedTokenSource(List<Token> tokens) {
|
internal FixedTokenSource(List<Token> tokens) {
|
||||||
this.tokens = tokens;
|
this.tokens = tokens;
|
||||||
this.idx = 0;
|
this.idx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Token token() {
|
public override Token token() {
|
||||||
if (idx >= tokens.Count)
|
if (idx >= tokens.Count)
|
||||||
return EOF;
|
return EOF;
|
||||||
return tokens[idx++];
|
return tokens[idx++];
|
||||||
}
|
}
|
||||||
|
|
||||||
override public String ToString() {
|
override public String ToString() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.Append("constant token stream " + tokens);
|
buf.Append("constant token stream " + tokens);
|
||||||
Source parent = getParent();
|
Source parent = getParent();
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
buf.Append(" in ").Append(parent);
|
buf.Append(" in ").Append(parent);
|
||||||
return buf.ToString();
|
return buf.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace CppNet
|
namespace CppNet
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A virtual filesystem implementation using java.io.
|
* A virtual filesystem implementation using java.io.
|
||||||
*/
|
*/
|
||||||
public class JavaFileSystem : VirtualFileSystem
|
public class JavaFileSystem : VirtualFileSystem
|
||||||
{
|
{
|
||||||
|
@ -37,4 +37,4 @@ namespace CppNet
|
||||||
return new JavaFile(Path.Combine(dir, name));
|
return new JavaFile(Path.Combine(dir, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace CppNet {
|
namespace CppNet {
|
||||||
/**
|
/**
|
||||||
* A preprocessor exception.
|
* A preprocessor exception.
|
||||||
*
|
*
|
||||||
* Note to users: I don't really like the name of this class. S.
|
* Note to users: I don't really like the name of this class. S.
|
||||||
*/
|
*/
|
||||||
public class LexerException : Exception {
|
public class LexerException : Exception {
|
||||||
public LexerException(String msg) : base(msg) { }
|
public LexerException(String msg) : base(msg) { }
|
||||||
|
|
||||||
public LexerException(Exception cause) : base(cause.Message, cause) {}
|
public LexerException(Exception cause) : base(cause.Message, cause) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
1530
LexerSource.cs
1530
LexerSource.cs
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
160
Macro.cs
160
Macro.cs
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -20,20 +20,20 @@ using System.Text;
|
||||||
|
|
||||||
namespace CppNet
|
namespace CppNet
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* A macro object.
|
* A macro object.
|
||||||
*
|
*
|
||||||
* This encapsulates a name, an argument count, and a token stream
|
* This encapsulates a name, an argument count, and a token stream
|
||||||
* for replacement. The replacement token stream may contain the
|
* for replacement. The replacement token stream may contain the
|
||||||
* extra tokens {@link Token#M_ARG} and {@link Token#M_STRING}.
|
* extra tokens {@link Token#M_ARG} and {@link Token#M_STRING}.
|
||||||
*/
|
*/
|
||||||
public class Macro
|
public class Macro
|
||||||
{
|
{
|
||||||
private Source source;
|
private Source source;
|
||||||
private String name;
|
private String name;
|
||||||
/* It's an explicit decision to keep these around here. We don't
|
/* 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
|
* need to; the argument token type is M_ARG and the value
|
||||||
* is the index. The strings themselves are only used in
|
* is the index. The strings themselves are only used in
|
||||||
* stringification of the macro, for debugging. */
|
* stringification of the macro, for debugging. */
|
||||||
private List<String> args;
|
private List<String> args;
|
||||||
private bool variadic;
|
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)
|
public void setSource(Source s)
|
||||||
{
|
{
|
||||||
this.source = s;
|
this.source = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Source from which this macro was parsed.
|
* Returns the Source from which this macro was parsed.
|
||||||
*
|
*
|
||||||
* This method may return null if the macro was not parsed
|
* This method may return null if the macro was not parsed
|
||||||
* from a regular file.
|
* from a regular file.
|
||||||
*/
|
*/
|
||||||
public Source getSource()
|
public Source getSource()
|
||||||
{
|
{
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of this macro.
|
* Returns the name of this macro.
|
||||||
*/
|
*/
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the arguments to this macro.
|
* Sets the arguments to this macro.
|
||||||
*/
|
*/
|
||||||
public void setArgs(List<String> args)
|
public void setArgs(List<String> args)
|
||||||
{
|
{
|
||||||
this.args = 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()
|
public bool isFunctionLike()
|
||||||
{
|
{
|
||||||
return args != null;
|
return args != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of arguments to this macro.
|
* Returns the number of arguments to this macro.
|
||||||
*/
|
*/
|
||||||
public int getArgs()
|
public int getArgs()
|
||||||
{
|
{
|
||||||
return args.Count;
|
return args.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the variadic flag on this Macro.
|
* Sets the variadic flag on this Macro.
|
||||||
*/
|
*/
|
||||||
public void setVariadic(bool b)
|
public void setVariadic(bool b)
|
||||||
{
|
{
|
||||||
this.variadic = 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()
|
public bool isVariadic()
|
||||||
{
|
{
|
||||||
return variadic;
|
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)
|
public void addToken(Token tok)
|
||||||
{
|
{
|
||||||
this.tokens.Add(tok);
|
this.tokens.Add(tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a "paste" operator to the expansion of this macro.
|
* Adds a "paste" operator to the expansion of this macro.
|
||||||
*
|
*
|
||||||
* A paste operator causes the next token added to be pasted
|
* A paste operator causes the next token added to be pasted
|
||||||
* to the previous token when the macro is expanded.
|
* to the previous token when the macro is expanded.
|
||||||
* It is an error for a macro to end with a paste token.
|
* It is an error for a macro to end with a paste token.
|
||||||
*/
|
*/
|
||||||
public void addPaste(Token tok)
|
public void addPaste(Token tok)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Given: tok0 ## tok1
|
* Given: tok0 ## tok1
|
||||||
* We generate: M_PASTE, tok0, tok1
|
* We generate: M_PASTE, tok0, tok1
|
||||||
* This extends as per a stack language:
|
* This extends as per a stack language:
|
||||||
* tok0 ## tok1 ## tok2 ->
|
* tok0 ## tok1 ## tok2 ->
|
||||||
* M_PASTE, tok0, M_PASTE, tok1, tok2
|
* M_PASTE, tok0, M_PASTE, tok1, tok2
|
||||||
*/
|
*/
|
||||||
this.tokens.Insert(tokens.Count - 1, tok);
|
this.tokens.Insert(tokens.Count - 1, tok);
|
||||||
}
|
}
|
||||||
|
@ -152,30 +152,30 @@ namespace CppNet
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Paste tokens are inserted before the first of the two pasted
|
/* Paste tokens are inserted before the first of the two pasted
|
||||||
* tokens, so it's a kind of bytecode notation. This method
|
* tokens, so it's a kind of bytecode notation. This method
|
||||||
* swaps them around again. We know that there will never be two
|
* swaps them around again. We know that there will never be two
|
||||||
* sequential paste tokens, so a bool is sufficient. */
|
* sequential paste tokens, so a bool is sufficient. */
|
||||||
public String getText() {
|
public String getText() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
bool paste = false;
|
bool paste = false;
|
||||||
for (int i = 0; i < tokens.Count; i++) {
|
for (int i = 0; i < tokens.Count; i++) {
|
||||||
Token tok = tokens[i];
|
Token tok = tokens[i];
|
||||||
if (tok.getType() == Token.M_PASTE) {
|
if (tok.getType() == Token.M_PASTE) {
|
||||||
System.Diagnostics.Debug.Assert(paste == false, "Two sequential pastes.");
|
System.Diagnostics.Debug.Assert(paste == false, "Two sequential pastes.");
|
||||||
paste = true;
|
paste = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf.Append(tok.getText());
|
buf.Append(tok.getText());
|
||||||
}
|
}
|
||||||
if (paste) {
|
if (paste) {
|
||||||
buf.Append(" #" + "# ");
|
buf.Append(" #" + "# ");
|
||||||
paste = false;
|
paste = false;
|
||||||
}
|
}
|
||||||
// buf.Append(tokens.get(i));
|
// buf.Append(tokens.get(i));
|
||||||
}
|
}
|
||||||
return buf.ToString();
|
return buf.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
override public String ToString()
|
override public String ToString()
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using boolean = System.Boolean;
|
using boolean = System.Boolean;
|
||||||
using Debug = System.Diagnostics.Debug;
|
using Debug = System.Diagnostics.Debug;
|
||||||
|
|
||||||
namespace CppNet {
|
namespace CppNet {
|
||||||
|
|
||||||
/* This source should always be active, since we don't expand macros
|
/* This source should always be active, since we don't expand macros
|
||||||
* in any inactive context. */
|
* in any inactive context. */
|
||||||
internal class MacroTokenSource : Source {
|
internal class MacroTokenSource : Source {
|
||||||
private Macro macro;
|
private Macro macro;
|
||||||
private Iterator<Token> tokens; /* Pointer into the macro. */
|
private Iterator<Token> tokens; /* Pointer into the macro. */
|
||||||
private List<Argument> args; /* { unexpanded, expanded } */
|
private List<Argument> args; /* { unexpanded, expanded } */
|
||||||
|
@ -186,16 +186,16 @@ internal class MacroTokenSource : Source {
|
||||||
}
|
}
|
||||||
} /* for */
|
} /* for */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override public String ToString() {
|
override public String ToString() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.Append("expansion of ").Append(macro.getName());
|
buf.Append("expansion of ").Append(macro.getName());
|
||||||
Source parent = getParent();
|
Source parent = getParent();
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
buf.Append(" in ").Append(parent);
|
buf.Append(" in ").Append(parent);
|
||||||
return buf.ToString();
|
return buf.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2245,4 +2245,4 @@ public class Preprocessor : IDisposable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,4 +49,4 @@ namespace CppNet
|
||||||
print(source.getName() + ":" + line + ":" + column + ": error: " + msg);
|
print(source.getName() + ":" + line + ":" + column + ": error: " + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,4 +76,4 @@ namespace CppNet
|
||||||
public virtual void handleSourceChange(Source source, String ev) {
|
public virtual void handleSourceChange(Source source, String ev) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
52
Source.cs
52
Source.cs
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -23,16 +23,16 @@ namespace CppNet
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An input to the Preprocessor.
|
* An input to the Preprocessor.
|
||||||
*
|
*
|
||||||
* Inputs may come from Files, Strings or other sources. The
|
* Inputs may come from Files, Strings or other sources. The
|
||||||
* preprocessor maintains a stack of Sources. Operations such as
|
* preprocessor maintains a stack of Sources. Operations such as
|
||||||
* file inclusion or token pasting will push a new source onto
|
* file inclusion or token pasting will push a new source onto
|
||||||
* the Preprocessor stack. Sources pop from the stack when they
|
* the Preprocessor stack. Sources pop from the stack when they
|
||||||
* are exhausted; this may be transparent or explicit.
|
* are exhausted; this may be transparent or explicit.
|
||||||
*
|
*
|
||||||
* BUG: Error messages are not handled properly.
|
* BUG: Error messages are not handled properly.
|
||||||
*/
|
*/
|
||||||
public abstract class Source : Iterable<Token>, Closeable
|
public abstract class Source : Iterable<Token>, Closeable
|
||||||
{
|
{
|
||||||
|
@ -295,4 +295,4 @@ namespace CppNet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
@ -24,9 +24,9 @@ using boolean = System.Boolean;
|
||||||
namespace CppNet
|
namespace CppNet
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Iterator for {@link Source Sources},
|
* An Iterator for {@link Source Sources},
|
||||||
* returning {@link Token Tokens}.
|
* returning {@link Token Tokens}.
|
||||||
*/
|
*/
|
||||||
public class SourceIterator : Iterator<Token>
|
public class SourceIterator : Iterator<Token>
|
||||||
{
|
{
|
||||||
|
@ -95,4 +95,4 @@ namespace CppNet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
32
State.cs
32
State.cs
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
@ -86,4 +86,4 @@ namespace CppNet
|
||||||
", sawelse=" + _sawElse;
|
", sawelse=" + _sawElse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,4 +66,4 @@ public class StringLexerSource : LexerSource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
2
Token.cs
2
Token.cs
|
@ -350,4 +350,4 @@ namespace CppNet {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,4 @@ public interface VirtualFile {
|
||||||
Source getSource();
|
Source getSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
/*
|
/*
|
||||||
* Anarres C Preprocessor
|
* Anarres C Preprocessor
|
||||||
* Copyright (c) 2007-2008, Shevek
|
* Copyright (c) 2007-2008, Shevek
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* or implied. See the License for the specific language governing
|
* or implied. See the License for the specific language governing
|
||||||
* permissions and limitations under the License.
|
* permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace CppNet
|
namespace CppNet
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* An extremely lightweight virtual file system interface.
|
* An extremely lightweight virtual file system interface.
|
||||||
*/
|
*/
|
||||||
public interface VirtualFileSystem
|
public interface VirtualFileSystem
|
||||||
{
|
{
|
||||||
|
@ -27,4 +27,4 @@ namespace CppNet
|
||||||
VirtualFile getFile(String dir, String name);
|
VirtualFile getFile(String dir, String name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,4 +35,4 @@ namespace CppNet
|
||||||
// SYSTEM_HEADERS
|
// SYSTEM_HEADERS
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче