progress
This commit is contained in:
parent
16e76d6b31
commit
484dbfc9d9
529 changed files with 113694 additions and 0 deletions
25
.dockerignore
Normal file
25
.dockerignore
Normal file
|
@ -0,0 +1,25 @@
|
|||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
BIN
.vs/aspclassic/DesignTimeBuild/.dtbcache.v2
Normal file
BIN
.vs/aspclassic/DesignTimeBuild/.dtbcache.v2
Normal file
Binary file not shown.
BIN
.vs/aspclassic/v17/.futdcache.v1
Normal file
BIN
.vs/aspclassic/v17/.futdcache.v1
Normal file
Binary file not shown.
BIN
.vs/aspclassic/v17/.suo
Normal file
BIN
.vs/aspclassic/v17/.suo
Normal file
Binary file not shown.
67
AspClassic.Parser/AddHandlerAccessorDeclaration.cs
Normal file
67
AspClassic.Parser/AddHandlerAccessorDeclaration.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a AddHandler property accessor.
|
||||
/// </summary>
|
||||
public sealed class AddHandlerAccessorDeclaration : ModifiedDeclaration
|
||||
{
|
||||
private readonly Location _AddHandlerLocation;
|
||||
|
||||
private readonly ParameterCollection _Parameters;
|
||||
|
||||
private readonly StatementCollection _Statements;
|
||||
|
||||
private readonly EndBlockDeclaration _EndStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'AddHandler'.
|
||||
/// </summary>
|
||||
public Location AddHandlerLocation => _AddHandlerLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The accessor's parameters.
|
||||
/// </summary>
|
||||
public ParameterCollection Parameters => _Parameters;
|
||||
|
||||
/// <summary>
|
||||
/// The statements in the accessor.
|
||||
/// </summary>
|
||||
public StatementCollection Statements => _Statements;
|
||||
|
||||
/// <summary>
|
||||
/// The End declaration for the accessor.
|
||||
/// </summary>
|
||||
public EndBlockDeclaration EndStatement => _EndStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a property accessor.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes for the parse tree.</param>
|
||||
/// <param name="addHandlerLocation">The location of the 'AddHandler'.</param>
|
||||
/// <param name="parameters">The parameters of the declaration.</param>
|
||||
/// <param name="statements">The statements in the declaration.</param>
|
||||
/// <param name="endStatement">The end block declaration, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public AddHandlerAccessorDeclaration(AttributeBlockCollection attributes, Location addHandlerLocation, ParameterCollection parameters, StatementCollection statements, EndBlockDeclaration endStatement, Span span, IList<Comment> comments)
|
||||
: base(TreeType.AddHandlerAccessorDeclaration, attributes, null, span, comments)
|
||||
{
|
||||
SetParent(parameters);
|
||||
SetParent(statements);
|
||||
SetParent(endStatement);
|
||||
_Parameters = parameters;
|
||||
_AddHandlerLocation = addHandlerLocation;
|
||||
_Statements = statements;
|
||||
_EndStatement = endStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, Parameters);
|
||||
Tree.AddChild(childList, Statements);
|
||||
Tree.AddChild(childList, EndStatement);
|
||||
}
|
||||
}
|
22
AspClassic.Parser/AddHandlerStatement.cs
Normal file
22
AspClassic.Parser/AddHandlerStatement.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an AddHandler statement.
|
||||
/// </summary>
|
||||
public sealed class AddHandlerStatement : HandlerStatement
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an AddHandler statement.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the event.</param>
|
||||
/// <param name="commaLocation">The location of the ','.</param>
|
||||
/// <param name="delegateExpression">The delegate expression.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public AddHandlerStatement(Expression name, Location commaLocation, Expression delegateExpression, Span span, IList<Comment> comments)
|
||||
: base(TreeType.AddHandlerStatement, name, commaLocation, delegateExpression, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
17
AspClassic.Parser/AddressOfExpression.cs
Normal file
17
AspClassic.Parser/AddressOfExpression.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an AddressOf expression.
|
||||
/// </summary>
|
||||
public sealed class AddressOfExpression : UnaryExpression
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new AddressOf expression parse tree.
|
||||
/// </summary>
|
||||
/// <param name="operand">The operand of AddressOf.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public AddressOfExpression(Expression operand, Span span)
|
||||
: base(TreeType.AddressOfExpression, operand, span)
|
||||
{
|
||||
}
|
||||
}
|
38
AspClassic.Parser/AggregateInitializer.cs
Normal file
38
AspClassic.Parser/AggregateInitializer.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an aggregate initializer.
|
||||
/// </summary>
|
||||
public sealed class AggregateInitializer : Initializer
|
||||
{
|
||||
private readonly InitializerCollection _Elements;
|
||||
|
||||
/// <summary>
|
||||
/// The elements of the aggregate initializer.
|
||||
/// </summary>
|
||||
public InitializerCollection Elements => _Elements;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new aggregate initializer parse tree.
|
||||
/// </summary>
|
||||
/// <param name="elements">The elements of the aggregate initializer.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public AggregateInitializer(InitializerCollection elements, Span span)
|
||||
: base(TreeType.AggregateInitializer, span)
|
||||
{
|
||||
if (elements == null)
|
||||
{
|
||||
throw new ArgumentNullException("elements");
|
||||
}
|
||||
SetParent(elements);
|
||||
_Elements = elements;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Elements);
|
||||
}
|
||||
}
|
62
AspClassic.Parser/AliasImport.cs
Normal file
62
AspClassic.Parser/AliasImport.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an Imports statement that aliases a type or namespace.
|
||||
/// </summary>
|
||||
public sealed class AliasImport : Import
|
||||
{
|
||||
private readonly SimpleName _Name;
|
||||
|
||||
private readonly Location _EqualsLocation;
|
||||
|
||||
private readonly TypeName _AliasedTypeName;
|
||||
|
||||
/// <summary>
|
||||
/// The alias name.
|
||||
/// </summary>
|
||||
public SimpleName Name => _Name;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the '='.
|
||||
/// </summary>
|
||||
public Location EqualsLocation => _EqualsLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The name being aliased.
|
||||
/// </summary>
|
||||
public TypeName AliasedTypeName => _AliasedTypeName;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new aliased import parse tree.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the alias.</param>
|
||||
/// <param name="equalsLocation">The location of the '='.</param>
|
||||
/// <param name="aliasedTypeName">The name being aliased.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public AliasImport(SimpleName name, Location equalsLocation, TypeName aliasedTypeName, Span span)
|
||||
: base(TreeType.AliasImport, span)
|
||||
{
|
||||
if (aliasedTypeName == null)
|
||||
{
|
||||
throw new ArgumentNullException("aliasedTypeName");
|
||||
}
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
SetParent(name);
|
||||
SetParent(aliasedTypeName);
|
||||
_Name = name;
|
||||
_EqualsLocation = equalsLocation;
|
||||
_AliasedTypeName = aliasedTypeName;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, AliasedTypeName);
|
||||
}
|
||||
}
|
63
AspClassic.Parser/Argument.cs
Normal file
63
AspClassic.Parser/Argument.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an argument to a call or index.
|
||||
/// </summary>
|
||||
public sealed class Argument : Tree
|
||||
{
|
||||
private readonly SimpleName _Name;
|
||||
|
||||
private readonly Location _ColonEqualsLocation;
|
||||
|
||||
private readonly Expression _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// The name of the argument, if any.
|
||||
/// </summary>
|
||||
public SimpleName Name => _Name;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the ':=', if any.
|
||||
/// </summary>
|
||||
public Location ColonEqualsLocation => _ColonEqualsLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The argument, if any.
|
||||
/// </summary>
|
||||
public Expression Expression => _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an argument.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the argument, if any.</param>
|
||||
/// <param name="colonEqualsLocation">The location of the ':=', if any.</param>
|
||||
/// <param name="expression">The expression, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public Argument(SimpleName name, Location colonEqualsLocation, Expression expression, Span span)
|
||||
: base(TreeType.Argument, span)
|
||||
{
|
||||
if (expression == null)
|
||||
{
|
||||
throw new ArgumentNullException("expression");
|
||||
}
|
||||
SetParent(name);
|
||||
SetParent(expression);
|
||||
_Name = name;
|
||||
_ColonEqualsLocation = colonEqualsLocation;
|
||||
_Expression = expression;
|
||||
}
|
||||
|
||||
private Argument()
|
||||
: base(TreeType.Argument, default(Span))
|
||||
{
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Name);
|
||||
Tree.AddChild(childList, Expression);
|
||||
}
|
||||
}
|
29
AspClassic.Parser/ArgumentCollection.cs
Normal file
29
AspClassic.Parser/ArgumentCollection.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A read-only collection of arguments.
|
||||
/// </summary>
|
||||
public sealed class ArgumentCollection : CommaDelimitedTreeCollection<Argument>
|
||||
{
|
||||
private readonly Location _RightParenthesisLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the ')'.
|
||||
/// </summary>
|
||||
public Location RightParenthesisLocation => _RightParenthesisLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new argument collection.
|
||||
/// </summary>
|
||||
/// <param name="arguments">The arguments in the collection.</param>
|
||||
/// <param name="commaLocations">The location of the commas in the collection.</param>
|
||||
/// <param name="rightParenthesisLocation">The location of the ')'.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public ArgumentCollection(IList<Argument> arguments, IList<Location> commaLocations, Location rightParenthesisLocation, Span span)
|
||||
: base(TreeType.ArgumentCollection, arguments, commaLocations, span)
|
||||
{
|
||||
_RightParenthesisLocation = rightParenthesisLocation;
|
||||
}
|
||||
}
|
61
AspClassic.Parser/ArrayTypeName.cs
Normal file
61
AspClassic.Parser/ArrayTypeName.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an array type name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This tree may contain size arguments as well.
|
||||
/// </remarks>
|
||||
public sealed class ArrayTypeName : TypeName
|
||||
{
|
||||
private readonly TypeName _ElementTypeName;
|
||||
|
||||
private readonly int _Rank;
|
||||
|
||||
private readonly ArgumentCollection _Arguments;
|
||||
|
||||
/// <summary>
|
||||
/// The type name for the element type of the array.
|
||||
/// </summary>
|
||||
public TypeName ElementTypeName => _ElementTypeName;
|
||||
|
||||
/// <summary>
|
||||
/// The rank of the array type name.
|
||||
/// </summary>
|
||||
public int Rank => _Rank;
|
||||
|
||||
/// <summary>
|
||||
/// The arguments of the array type name, if any.
|
||||
/// </summary>
|
||||
public ArgumentCollection Arguments => _Arguments;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an array type name.
|
||||
/// </summary>
|
||||
/// <param name="elementTypeName">The type name for the array element type.</param>
|
||||
/// <param name="rank">The rank of the array type name.</param>
|
||||
/// <param name="arguments">The arguments of the array type name, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public ArrayTypeName(TypeName elementTypeName, int rank, ArgumentCollection arguments, Span span)
|
||||
: base(TreeType.ArrayType, span)
|
||||
{
|
||||
if (arguments == null)
|
||||
{
|
||||
throw new ArgumentNullException("arguments");
|
||||
}
|
||||
SetParent(elementTypeName);
|
||||
SetParent(arguments);
|
||||
_ElementTypeName = elementTypeName;
|
||||
_Rank = rank;
|
||||
_Arguments = arguments;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, ElementTypeName);
|
||||
Tree.AddChild(childList, Arguments);
|
||||
}
|
||||
}
|
9
AspClassic.Parser/AspClassic.Parser.csproj
Normal file
9
AspClassic.Parser/AspClassic.Parser.csproj
Normal file
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
82
AspClassic.Parser/AssignmentStatement.cs
Normal file
82
AspClassic.Parser/AssignmentStatement.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an assignment statement.
|
||||
/// </summary>
|
||||
public sealed class AssignmentStatement : Statement
|
||||
{
|
||||
private readonly Expression _TargetExpression;
|
||||
|
||||
private readonly Location _OperatorLocation;
|
||||
|
||||
private readonly Expression _SourceExpression;
|
||||
|
||||
private readonly bool _IsSetStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The target of the assignment.
|
||||
/// </summary>
|
||||
public Expression TargetExpression => _TargetExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the operator.
|
||||
/// </summary>
|
||||
public Location OperatorLocation => _OperatorLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The source of the assignment.
|
||||
/// </summary>
|
||||
public Expression SourceExpression => _SourceExpression;
|
||||
|
||||
public bool IsSetStatement => _IsSetStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an assignment statement.
|
||||
/// </summary>
|
||||
/// <param name="targetExpression">The target of the assignment.</param>
|
||||
/// <param name="operatorLocation">The location of the operator.</param>
|
||||
/// <param name="sourceExpression">The source of the assignment.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
/// <param name="isSetStatement">Whether is is a set statement</param>
|
||||
public AssignmentStatement(Expression targetExpression, Location operatorLocation, Expression sourceExpression, Span span, IList<Comment> comments, bool isSetStatement)
|
||||
: base(TreeType.AssignmentStatement, span, comments)
|
||||
{
|
||||
if (targetExpression == null)
|
||||
{
|
||||
throw new ArgumentNullException("targetExpression");
|
||||
}
|
||||
if (sourceExpression == null)
|
||||
{
|
||||
throw new ArgumentNullException("sourceExpression");
|
||||
}
|
||||
SetParent(targetExpression);
|
||||
SetParent(sourceExpression);
|
||||
_TargetExpression = targetExpression;
|
||||
_OperatorLocation = operatorLocation;
|
||||
_SourceExpression = sourceExpression;
|
||||
_IsSetStatement = isSetStatement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an assignment statement.
|
||||
/// </summary>
|
||||
/// <param name="targetExpression">The target of the assignment.</param>
|
||||
/// <param name="operatorLocation">The location of the operator.</param>
|
||||
/// <param name="sourceExpression">The source of the assignment.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public AssignmentStatement(Expression targetExpression, Location operatorLocation, Expression sourceExpression, Span span, IList<Comment> comments)
|
||||
: this(targetExpression, operatorLocation, sourceExpression, span, comments, isSetStatement: false)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, TargetExpression);
|
||||
Tree.AddChild(childList, SourceExpression);
|
||||
}
|
||||
}
|
76
AspClassic.Parser/Attribute.cs
Normal file
76
AspClassic.Parser/Attribute.cs
Normal file
|
@ -0,0 +1,76 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an attribute usage.
|
||||
/// </summary>
|
||||
public sealed class Attribute : Tree
|
||||
{
|
||||
private readonly AttributeTypes _AttributeType;
|
||||
|
||||
private readonly Location _AttributeTypeLocation;
|
||||
|
||||
private readonly Location _ColonLocation;
|
||||
|
||||
private readonly Name _Name;
|
||||
|
||||
private readonly ArgumentCollection _Arguments;
|
||||
|
||||
/// <summary>
|
||||
/// The target type of the attribute.
|
||||
/// </summary>
|
||||
public AttributeTypes AttributeType => _AttributeType;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the attribute type, if any.
|
||||
/// </summary>
|
||||
public Location AttributeTypeLocation => _AttributeTypeLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the ':', if any.
|
||||
/// </summary>
|
||||
public Location ColonLocation => _ColonLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The name of the attribute being applied.
|
||||
/// </summary>
|
||||
public Name Name => _Name;
|
||||
|
||||
/// <summary>
|
||||
/// The arguments to the attribute.
|
||||
/// </summary>
|
||||
public ArgumentCollection Arguments => _Arguments;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new attribute parse tree.
|
||||
/// </summary>
|
||||
/// <param name="attributeType">The target type of the attribute.</param>
|
||||
/// <param name="attributeTypeLocation">The location of the attribute type.</param>
|
||||
/// <param name="colonLocation">The location of the ':'.</param>
|
||||
/// <param name="name">The name of the attribute being applied.</param>
|
||||
/// <param name="arguments">The arguments to the attribute.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public Attribute(AttributeTypes attributeType, Location attributeTypeLocation, Location colonLocation, Name name, ArgumentCollection arguments, Span span)
|
||||
: base(TreeType.Attribute, span)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
SetParent(name);
|
||||
SetParent(arguments);
|
||||
_AttributeType = attributeType;
|
||||
_AttributeTypeLocation = attributeTypeLocation;
|
||||
_ColonLocation = colonLocation;
|
||||
_Name = name;
|
||||
_Arguments = arguments;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Name);
|
||||
Tree.AddChild(childList, Arguments);
|
||||
}
|
||||
}
|
24
AspClassic.Parser/AttributeBlockCollection.cs
Normal file
24
AspClassic.Parser/AttributeBlockCollection.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A read-only collection of attributes.
|
||||
/// </summary>
|
||||
public sealed class AttributeBlockCollection : TreeCollection<AttributeCollection>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new collection of attribute blocks.
|
||||
/// </summary>
|
||||
/// <param name="attributeBlocks">The attribute blockss in the collection.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public AttributeBlockCollection(IList<AttributeCollection> attributeBlocks, Span span)
|
||||
: base(TreeType.AttributeBlockCollection, attributeBlocks, span)
|
||||
{
|
||||
if (attributeBlocks == null || attributeBlocks.Count == 0)
|
||||
{
|
||||
throw new ArgumentException("AttributeBlocksCollection cannot be empty.");
|
||||
}
|
||||
}
|
||||
}
|
34
AspClassic.Parser/AttributeCollection.cs
Normal file
34
AspClassic.Parser/AttributeCollection.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A read-only collection of attributes.
|
||||
/// </summary>
|
||||
public sealed class AttributeCollection : CommaDelimitedTreeCollection<Attribute>
|
||||
{
|
||||
private readonly Location _RightBracketLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the '}'.
|
||||
/// </summary>
|
||||
public Location RightBracketLocation => _RightBracketLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new collection of attributes.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes in the collection.</param>
|
||||
/// <param name="commaLocations">The location of the commas in the list.</param>
|
||||
/// <param name="rightBracketLocation">The location of the right bracket.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public AttributeCollection(IList<Attribute> attributes, IList<Location> commaLocations, Location rightBracketLocation, Span span)
|
||||
: base(TreeType.AttributeCollection, attributes, commaLocations, span)
|
||||
{
|
||||
if (attributes == null || attributes.Count == 0)
|
||||
{
|
||||
throw new ArgumentException("AttributeCollection cannot be empty.");
|
||||
}
|
||||
_RightBracketLocation = rightBracketLocation;
|
||||
}
|
||||
}
|
39
AspClassic.Parser/AttributeDeclaration.cs
Normal file
39
AspClassic.Parser/AttributeDeclaration.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an assembly-level or module-level attribute declaration.
|
||||
/// </summary>
|
||||
public sealed class AttributeDeclaration : Declaration
|
||||
{
|
||||
private readonly AttributeBlockCollection _Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// The attributes.
|
||||
/// </summary>
|
||||
public AttributeBlockCollection Attributes => _Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for assembly-level or module-level attribute declarations.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public AttributeDeclaration(AttributeBlockCollection attributes, Span span, IList<Comment> comments)
|
||||
: base(TreeType.AttributeDeclaration, span, comments)
|
||||
{
|
||||
if (attributes == null)
|
||||
{
|
||||
throw new ArgumentNullException("attributes");
|
||||
}
|
||||
SetParent(attributes);
|
||||
_Attributes = attributes;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Attributes);
|
||||
}
|
||||
}
|
17
AspClassic.Parser/AttributeTypes.cs
Normal file
17
AspClassic.Parser/AttributeTypes.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// The type of an attribute usage.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum AttributeTypes
|
||||
{
|
||||
/// <summary>Regular application.</summary>
|
||||
Regular = 1,
|
||||
/// <summary>Applied to the netmodule.</summary>
|
||||
Module = 2,
|
||||
/// <summary>Applied to the assembly.</summary>
|
||||
Assembly = 4
|
||||
}
|
77
AspClassic.Parser/BinaryOperatorExpression.cs
Normal file
77
AspClassic.Parser/BinaryOperatorExpression.cs
Normal file
|
@ -0,0 +1,77 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a binary operator expression.
|
||||
/// </summary>
|
||||
public sealed class BinaryOperatorExpression : Expression
|
||||
{
|
||||
private readonly Expression _LeftOperand;
|
||||
|
||||
private readonly OperatorType _Operator;
|
||||
|
||||
private readonly Location _OperatorLocation;
|
||||
|
||||
private readonly Expression _RightOperand;
|
||||
|
||||
/// <summary>
|
||||
/// The left operand expression.
|
||||
/// </summary>
|
||||
public Expression LeftOperand => _LeftOperand;
|
||||
|
||||
/// <summary>
|
||||
/// The operator.
|
||||
/// </summary>
|
||||
public OperatorType Operator => _Operator;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the operator.
|
||||
/// </summary>
|
||||
public Location OperatorLocation => _OperatorLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The right operand expression.
|
||||
/// </summary>
|
||||
public Expression RightOperand => _RightOperand;
|
||||
|
||||
public override bool IsConstant => LeftOperand.IsConstant && RightOperand.IsConstant;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a binary operation.
|
||||
/// </summary>
|
||||
/// <param name="leftOperand">The left operand expression.</param>
|
||||
/// <param name="operator">The operator.</param>
|
||||
/// <param name="operatorLocation">The location of the operator.</param>
|
||||
/// <param name="rightOperand">The right operand expression.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public BinaryOperatorExpression(Expression leftOperand, OperatorType @operator, Location operatorLocation, Expression rightOperand, Span span)
|
||||
: base(TreeType.BinaryOperatorExpression, span)
|
||||
{
|
||||
if (@operator < OperatorType.Plus || @operator > OperatorType.GreaterThanEquals)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("operator");
|
||||
}
|
||||
if (leftOperand == null)
|
||||
{
|
||||
throw new ArgumentNullException("leftOperand");
|
||||
}
|
||||
if (rightOperand == null)
|
||||
{
|
||||
throw new ArgumentNullException("rightOperand");
|
||||
}
|
||||
SetParent(leftOperand);
|
||||
SetParent(rightOperand);
|
||||
_LeftOperand = leftOperand;
|
||||
_Operator = @operator;
|
||||
_OperatorLocation = operatorLocation;
|
||||
_RightOperand = rightOperand;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, LeftOperand);
|
||||
Tree.AddChild(childList, RightOperand);
|
||||
}
|
||||
}
|
65
AspClassic.Parser/BlockDeclaration.cs
Normal file
65
AspClassic.Parser/BlockDeclaration.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
#define DEBUG
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a block declaration.
|
||||
/// </summary>
|
||||
public abstract class BlockDeclaration : ModifiedDeclaration
|
||||
{
|
||||
private readonly Location _KeywordLocation;
|
||||
|
||||
private readonly SimpleName _Name;
|
||||
|
||||
private readonly DeclarationCollection _Declarations;
|
||||
|
||||
private readonly EndBlockDeclaration _EndDeclaration;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the keyword.
|
||||
/// </summary>
|
||||
public Location KeywordLocation => _KeywordLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The name of the declaration.
|
||||
/// </summary>
|
||||
public SimpleName Name => _Name;
|
||||
|
||||
/// <summary>
|
||||
/// The declarations in the block.
|
||||
/// </summary>
|
||||
public DeclarationCollection Declarations => _Declarations;
|
||||
|
||||
/// <summary>
|
||||
/// The End statement for the block.
|
||||
/// </summary>
|
||||
public EndBlockDeclaration EndDeclaration => _EndDeclaration;
|
||||
|
||||
protected BlockDeclaration(TreeType type, AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, SimpleName name, DeclarationCollection declarations, EndBlockDeclaration endDeclaration, Span span, IList<Comment> comments)
|
||||
: base(type, attributes, modifiers, span, comments)
|
||||
{
|
||||
Debug.Assert(type == TreeType.ClassDeclaration || type == TreeType.ModuleDeclaration || type == TreeType.InterfaceDeclaration || type == TreeType.StructureDeclaration || type == TreeType.EnumDeclaration);
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
SetParent(name);
|
||||
SetParent(declarations);
|
||||
SetParent(endDeclaration);
|
||||
_KeywordLocation = keywordLocation;
|
||||
_Name = name;
|
||||
_Declarations = declarations;
|
||||
_EndDeclaration = endDeclaration;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, Name);
|
||||
Tree.AddChild(childList, Declarations);
|
||||
Tree.AddChild(childList, EndDeclaration);
|
||||
}
|
||||
}
|
28
AspClassic.Parser/BlockStatement.cs
Normal file
28
AspClassic.Parser/BlockStatement.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a block statement.
|
||||
/// </summary>
|
||||
public abstract class BlockStatement : Statement
|
||||
{
|
||||
private readonly StatementCollection _Statements;
|
||||
|
||||
/// <summary>
|
||||
/// The statements in the block.
|
||||
/// </summary>
|
||||
public StatementCollection Statements => _Statements;
|
||||
|
||||
protected BlockStatement(TreeType type, StatementCollection statements, Span span, IList<Comment> comments)
|
||||
: base(type, span, comments)
|
||||
{
|
||||
_Statements = statements;
|
||||
SetParent(statements);
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Statements);
|
||||
}
|
||||
}
|
34
AspClassic.Parser/BlockType.cs
Normal file
34
AspClassic.Parser/BlockType.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// The type a block declaration.
|
||||
/// </summary>
|
||||
public enum BlockType
|
||||
{
|
||||
None,
|
||||
Do,
|
||||
For,
|
||||
While,
|
||||
Select,
|
||||
If,
|
||||
Try,
|
||||
SyncLock,
|
||||
Using,
|
||||
With,
|
||||
Sub,
|
||||
Function,
|
||||
Operator,
|
||||
Event,
|
||||
AddHandler,
|
||||
RemoveHandler,
|
||||
RaiseEvent,
|
||||
Get,
|
||||
Set,
|
||||
Property,
|
||||
Class,
|
||||
Structure,
|
||||
Module,
|
||||
Interface,
|
||||
Enum,
|
||||
Namespace
|
||||
}
|
27
AspClassic.Parser/BooleanLiteralExpression.cs
Normal file
27
AspClassic.Parser/BooleanLiteralExpression.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Boolean literal expression.
|
||||
/// </summary>
|
||||
public sealed class BooleanLiteralExpression : LiteralExpression
|
||||
{
|
||||
private readonly bool _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// The literal value.
|
||||
/// </summary>
|
||||
public bool Literal => _Literal;
|
||||
|
||||
public override object Value => _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a Boolean literal expression.
|
||||
/// </summary>
|
||||
/// <param name="literal">The literal value.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public BooleanLiteralExpression(bool literal, Span span)
|
||||
: base(TreeType.BooleanLiteralExpression, span)
|
||||
{
|
||||
_Literal = literal;
|
||||
}
|
||||
}
|
21
AspClassic.Parser/CTypeExpression.cs
Normal file
21
AspClassic.Parser/CTypeExpression.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a CType expression.
|
||||
/// </summary>
|
||||
public sealed class CTypeExpression : CastTypeExpression
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a CType expression.
|
||||
/// </summary>
|
||||
/// <param name="leftParenthesisLocation">The location of the '('.</param>
|
||||
/// <param name="operand">The expression to be converted.</param>
|
||||
/// <param name="commaLocation">The location of the ','.</param>
|
||||
/// <param name="target">The target type of the conversion.</param>
|
||||
/// <param name="rightParenthesisLocation">The location of the ')'.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public CTypeExpression(Location leftParenthesisLocation, Expression operand, Location commaLocation, TypeName target, Location rightParenthesisLocation, Span span)
|
||||
: base(TreeType.CTypeExpression, leftParenthesisLocation, operand, commaLocation, target, rightParenthesisLocation, span)
|
||||
{
|
||||
}
|
||||
}
|
49
AspClassic.Parser/CallOrIndexExpression.cs
Normal file
49
AspClassic.Parser/CallOrIndexExpression.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a call or index expression.
|
||||
/// </summary>
|
||||
public sealed class CallOrIndexExpression : Expression
|
||||
{
|
||||
private readonly Expression _TargetExpression;
|
||||
|
||||
private readonly ArgumentCollection _Arguments;
|
||||
|
||||
/// <summary>
|
||||
/// The target of the call or index.
|
||||
/// </summary>
|
||||
public Expression TargetExpression => _TargetExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The arguments to the call or index.
|
||||
/// </summary>
|
||||
public ArgumentCollection Arguments => _Arguments;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a call or index expression.
|
||||
/// </summary>
|
||||
/// <param name="targetExpression">The target of the call or index.</param>
|
||||
/// <param name="arguments">The arguments to the call or index.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public CallOrIndexExpression(Expression targetExpression, ArgumentCollection arguments, Span span)
|
||||
: base(TreeType.CallOrIndexExpression, span)
|
||||
{
|
||||
if (targetExpression == null)
|
||||
{
|
||||
throw new ArgumentNullException("targetExpression");
|
||||
}
|
||||
SetParent(targetExpression);
|
||||
SetParent(arguments);
|
||||
_TargetExpression = targetExpression;
|
||||
_Arguments = arguments;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, TargetExpression);
|
||||
Tree.AddChild(childList, Arguments);
|
||||
}
|
||||
}
|
59
AspClassic.Parser/CallStatement.cs
Normal file
59
AspClassic.Parser/CallStatement.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a method call statement.
|
||||
/// </summary>
|
||||
public sealed class CallStatement : Statement
|
||||
{
|
||||
private readonly Location _CallLocation;
|
||||
|
||||
private readonly Expression _TargetExpression;
|
||||
|
||||
private readonly ArgumentCollection _Arguments;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'Call', if any.
|
||||
/// </summary>
|
||||
public Location CallLocation => _CallLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The target of the call.
|
||||
/// </summary>
|
||||
public Expression TargetExpression => _TargetExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The arguments to the call.
|
||||
/// </summary>
|
||||
public ArgumentCollection Arguments => _Arguments;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a method call statement.
|
||||
/// </summary>
|
||||
/// <param name="callLocation">The location of the 'Call', if any.</param>
|
||||
/// <param name="targetExpression">The target of the call.</param>
|
||||
/// <param name="arguments">The arguments to the call.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments of the parse tree.</param>
|
||||
public CallStatement(Location callLocation, Expression targetExpression, ArgumentCollection arguments, Span span, IList<Comment> comments)
|
||||
: base(TreeType.CallStatement, span, comments)
|
||||
{
|
||||
if (targetExpression == null)
|
||||
{
|
||||
throw new ArgumentNullException("targetExpression");
|
||||
}
|
||||
SetParent(targetExpression);
|
||||
SetParent(arguments);
|
||||
_CallLocation = callLocation;
|
||||
_TargetExpression = targetExpression;
|
||||
_Arguments = arguments;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, TargetExpression);
|
||||
Tree.AddChild(childList, Arguments);
|
||||
}
|
||||
}
|
41
AspClassic.Parser/CaseBlockStatement.cs
Normal file
41
AspClassic.Parser/CaseBlockStatement.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for the block of a Case statement.
|
||||
/// </summary>
|
||||
public sealed class CaseBlockStatement : BlockStatement
|
||||
{
|
||||
private readonly CaseStatement _CaseStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The Case statement that started the block.
|
||||
/// </summary>
|
||||
public CaseStatement CaseStatement => _CaseStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for the block of a Case statement.
|
||||
/// </summary>
|
||||
/// <param name="caseStatement">The Case statement that started the block.</param>
|
||||
/// <param name="statements">The statements in the block.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments of the tree.</param>
|
||||
public CaseBlockStatement(CaseStatement caseStatement, StatementCollection statements, Span span, IList<Comment> comments)
|
||||
: base(TreeType.CaseBlockStatement, statements, span, comments)
|
||||
{
|
||||
if (caseStatement == null)
|
||||
{
|
||||
throw new ArgumentNullException("caseStatement");
|
||||
}
|
||||
SetParent(caseStatement);
|
||||
_CaseStatement = caseStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, CaseStatement);
|
||||
base.GetChildTrees(childList);
|
||||
}
|
||||
}
|
16
AspClassic.Parser/CaseClause.cs
Normal file
16
AspClassic.Parser/CaseClause.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
#define DEBUG
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a case clause in a Select statement.
|
||||
/// </summary>
|
||||
public abstract class CaseClause : Tree
|
||||
{
|
||||
protected CaseClause(TreeType type, Span span)
|
||||
: base(type, span)
|
||||
{
|
||||
Debug.Assert(type == TreeType.ComparisonCaseClause || type == TreeType.RangeCaseClause);
|
||||
}
|
||||
}
|
25
AspClassic.Parser/CaseClauseCollection.cs
Normal file
25
AspClassic.Parser/CaseClauseCollection.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A collection of case clauses.
|
||||
/// </summary>
|
||||
public sealed class CaseClauseCollection : CommaDelimitedTreeCollection<CaseClause>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new collection of case clauses.
|
||||
/// </summary>
|
||||
/// <param name="caseClauses">The case clauses in the collection.</param>
|
||||
/// <param name="commaLocations">The locations of the commas in the list.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public CaseClauseCollection(IList<CaseClause> caseClauses, IList<Location> commaLocations, Span span)
|
||||
: base(TreeType.CaseClauseCollection, caseClauses, commaLocations, span)
|
||||
{
|
||||
if (caseClauses == null || caseClauses.Count == 0)
|
||||
{
|
||||
throw new ArgumentException("CaseClauseCollection cannot be empty.");
|
||||
}
|
||||
}
|
||||
}
|
41
AspClassic.Parser/CaseElseBlockStatement.cs
Normal file
41
AspClassic.Parser/CaseElseBlockStatement.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for the block of a Case Else statement.
|
||||
/// </summary>
|
||||
public sealed class CaseElseBlockStatement : BlockStatement
|
||||
{
|
||||
private readonly CaseElseStatement _CaseElseStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The Case Else statement that started the block.
|
||||
/// </summary>
|
||||
public CaseElseStatement CaseElseStatement => _CaseElseStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for the block of a Case Else statement.
|
||||
/// </summary>
|
||||
/// <param name="caseElseStatement">The Case Else statement that started the block.</param>
|
||||
/// <param name="statements">The statements in the block.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments of the tree.</param>
|
||||
public CaseElseBlockStatement(CaseElseStatement caseElseStatement, StatementCollection statements, Span span, IList<Comment> comments)
|
||||
: base(TreeType.CaseElseBlockStatement, statements, span, comments)
|
||||
{
|
||||
if (caseElseStatement == null)
|
||||
{
|
||||
throw new ArgumentNullException("caseElseStatement");
|
||||
}
|
||||
SetParent(caseElseStatement);
|
||||
_CaseElseStatement = caseElseStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, CaseElseStatement);
|
||||
base.GetChildTrees(childList);
|
||||
}
|
||||
}
|
28
AspClassic.Parser/CaseElseStatement.cs
Normal file
28
AspClassic.Parser/CaseElseStatement.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Case Else statement.
|
||||
/// </summary>
|
||||
public sealed class CaseElseStatement : Statement
|
||||
{
|
||||
private readonly Location _ElseLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'Else'.
|
||||
/// </summary>
|
||||
public Location ElseLocation => _ElseLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a Case Else statement.
|
||||
/// </summary>
|
||||
/// <param name="elseLocation">The location of the 'Else'.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public CaseElseStatement(Location elseLocation, Span span, IList<Comment> comments)
|
||||
: base(TreeType.CaseElseStatement, span, comments)
|
||||
{
|
||||
_ElseLocation = elseLocation;
|
||||
}
|
||||
}
|
39
AspClassic.Parser/CaseStatement.cs
Normal file
39
AspClassic.Parser/CaseStatement.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Case statement.
|
||||
/// </summary>
|
||||
public sealed class CaseStatement : Statement
|
||||
{
|
||||
private readonly CaseClauseCollection _CaseClauses;
|
||||
|
||||
/// <summary>
|
||||
/// The clauses in the Case statement.
|
||||
/// </summary>
|
||||
public CaseClauseCollection CaseClauses => _CaseClauses;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a Case statement.
|
||||
/// </summary>
|
||||
/// <param name="caseClauses">The clauses in the Case statement.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments on the parse tree.</param>
|
||||
public CaseStatement(CaseClauseCollection caseClauses, Span span, IList<Comment> comments)
|
||||
: base(TreeType.CaseStatement, span, comments)
|
||||
{
|
||||
if (caseClauses == null)
|
||||
{
|
||||
throw new ArgumentNullException("caseClauses");
|
||||
}
|
||||
SetParent(caseClauses);
|
||||
_CaseClauses = caseClauses;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, CaseClauses);
|
||||
}
|
||||
}
|
61
AspClassic.Parser/CastTypeExpression.cs
Normal file
61
AspClassic.Parser/CastTypeExpression.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
#define DEBUG
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a CType or DirectCast expression.
|
||||
/// </summary>
|
||||
public abstract class CastTypeExpression : UnaryExpression
|
||||
{
|
||||
private readonly Location _LeftParenthesisLocation;
|
||||
|
||||
private readonly Location _CommaLocation;
|
||||
|
||||
private readonly TypeName _Target;
|
||||
|
||||
private readonly Location _RightParenthesisLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the '('.
|
||||
/// </summary>
|
||||
public Location LeftParenthesisLocation => _LeftParenthesisLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the ','.
|
||||
/// </summary>
|
||||
public Location CommaLocation => _CommaLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The target type for the operand.
|
||||
/// </summary>
|
||||
public TypeName Target => _Target;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the ')'.
|
||||
/// </summary>
|
||||
public Location RightParenthesisLocation => _RightParenthesisLocation;
|
||||
|
||||
protected CastTypeExpression(TreeType type, Location leftParenthesisLocation, Expression operand, Location commaLocation, TypeName target, Location rightParenthesisLocation, Span span)
|
||||
: base(type, operand, span)
|
||||
{
|
||||
Debug.Assert(type == TreeType.CTypeExpression || type == TreeType.DirectCastExpression || type == TreeType.TryCastExpression);
|
||||
if (target == null)
|
||||
{
|
||||
throw new ArgumentNullException("target");
|
||||
}
|
||||
SetParent(target);
|
||||
_Target = target;
|
||||
_LeftParenthesisLocation = leftParenthesisLocation;
|
||||
_CommaLocation = commaLocation;
|
||||
_RightParenthesisLocation = rightParenthesisLocation;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, Target);
|
||||
}
|
||||
}
|
41
AspClassic.Parser/CatchBlockStatement.cs
Normal file
41
AspClassic.Parser/CatchBlockStatement.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Catch block statement.
|
||||
/// </summary>
|
||||
public sealed class CatchBlockStatement : BlockStatement
|
||||
{
|
||||
private readonly CatchStatement _CatchStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The Catch statement.
|
||||
/// </summary>
|
||||
public CatchStatement CatchStatement => _CatchStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a Catch block statement.
|
||||
/// </summary>
|
||||
/// <param name="catchStatement">The Catch statement.</param>
|
||||
/// <param name="statements">The statements in the block.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public CatchBlockStatement(CatchStatement catchStatement, StatementCollection statements, Span span, IList<Comment> comments)
|
||||
: base(TreeType.CatchBlockStatement, statements, span, comments)
|
||||
{
|
||||
if (catchStatement == null)
|
||||
{
|
||||
throw new ArgumentNullException("catchStatement");
|
||||
}
|
||||
SetParent(catchStatement);
|
||||
_CatchStatement = catchStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, CatchStatement);
|
||||
base.GetChildTrees(childList);
|
||||
}
|
||||
}
|
74
AspClassic.Parser/CatchStatement.cs
Normal file
74
AspClassic.Parser/CatchStatement.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Catch statement.
|
||||
/// </summary>
|
||||
public sealed class CatchStatement : Statement
|
||||
{
|
||||
private readonly SimpleName _Name;
|
||||
|
||||
private readonly Location _AsLocation;
|
||||
|
||||
private readonly TypeName _ExceptionType;
|
||||
|
||||
private readonly Location _WhenLocation;
|
||||
|
||||
private readonly Expression _FilterExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The name of the catch variable, if any.
|
||||
/// </summary>
|
||||
public SimpleName Name => _Name;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'As', if any.
|
||||
/// </summary>
|
||||
public Location AsLocation => _AsLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The type of the catch variable, if any.
|
||||
/// </summary>
|
||||
public TypeName ExceptionType => _ExceptionType;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'When', if any.
|
||||
/// </summary>
|
||||
public Location WhenLocation => _WhenLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The filter expression, if any.
|
||||
/// </summary>
|
||||
public Expression FilterExpression => _FilterExpression;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a Catch statement.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the catch variable, if any.</param>
|
||||
/// <param name="asLocation">The location of the 'As', if any.</param>
|
||||
/// <param name="exceptionType">The type of the catch variable, if any.</param>
|
||||
/// <param name="whenLocation">The location of the 'When', if any.</param>
|
||||
/// <param name="filterExpression">The filter expression, if any.</param>
|
||||
/// <param name="span">The location of the parse tree, if any.</param>
|
||||
/// <param name="comments">The comments for the parse tree, if any.</param>
|
||||
public CatchStatement(SimpleName name, Location asLocation, TypeName exceptionType, Location whenLocation, Expression filterExpression, Span span, IList<Comment> comments)
|
||||
: base(TreeType.CatchStatement, span, comments)
|
||||
{
|
||||
SetParent(name);
|
||||
SetParent(exceptionType);
|
||||
SetParent(filterExpression);
|
||||
_Name = name;
|
||||
_AsLocation = asLocation;
|
||||
_ExceptionType = exceptionType;
|
||||
_WhenLocation = whenLocation;
|
||||
_FilterExpression = filterExpression;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Name);
|
||||
Tree.AddChild(childList, ExceptionType);
|
||||
Tree.AddChild(childList, FilterExpression);
|
||||
}
|
||||
}
|
27
AspClassic.Parser/CharacterLiteralExpression.cs
Normal file
27
AspClassic.Parser/CharacterLiteralExpression.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a character literal expression.
|
||||
/// </summary>
|
||||
public sealed class CharacterLiteralExpression : LiteralExpression
|
||||
{
|
||||
private readonly char _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// The literal value.
|
||||
/// </summary>
|
||||
public char Literal => _Literal;
|
||||
|
||||
public override object Value => _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a character literal expression.
|
||||
/// </summary>
|
||||
/// <param name="literal">The literal value.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public CharacterLiteralExpression(char literal, Span span)
|
||||
: base(TreeType.CharacterLiteralExpression, span)
|
||||
{
|
||||
_Literal = literal;
|
||||
}
|
||||
}
|
25
AspClassic.Parser/CharacterLiteralToken.cs
Normal file
25
AspClassic.Parser/CharacterLiteralToken.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A character literal.
|
||||
/// </summary>
|
||||
public sealed class CharacterLiteralToken : Token
|
||||
{
|
||||
private readonly char _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// The literal value.
|
||||
/// </summary>
|
||||
public char Literal => _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new character literal token.
|
||||
/// </summary>
|
||||
/// <param name="literal">The literal value.</param>
|
||||
/// <param name="span">The location of the literal.</param>
|
||||
public CharacterLiteralToken(char literal, Span span)
|
||||
: base(TokenType.CharacterLiteral, span)
|
||||
{
|
||||
_Literal = literal;
|
||||
}
|
||||
}
|
11
AspClassic.Parser/Charset.cs
Normal file
11
AspClassic.Parser/Charset.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// The character set of a Declare statement.
|
||||
/// </summary>
|
||||
public enum Charset
|
||||
{
|
||||
Ansi,
|
||||
Unicode,
|
||||
Auto
|
||||
}
|
26
AspClassic.Parser/ClassDeclaration.cs
Normal file
26
AspClassic.Parser/ClassDeclaration.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Class declaration.
|
||||
/// </summary>
|
||||
public sealed class ClassDeclaration : GenericBlockDeclaration
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a Class declaration.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes for the parse tree.</param>
|
||||
/// <param name="modifiers">The modifiers for the parse tree.</param>
|
||||
/// <param name="keywordLocation">The location of the keyword.</param>
|
||||
/// <param name="name">The name of the declaration.</param>
|
||||
/// <param name="typeParameters">The type parameters of the type, if any.</param>
|
||||
/// <param name="declarations">The declarations in the block.</param>
|
||||
/// <param name="endStatement">The end block declaration, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ClassDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, SimpleName name, TypeParameterCollection typeParameters, DeclarationCollection declarations, EndBlockDeclaration endStatement, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ClassDeclaration, attributes, modifiers, keywordLocation, name, typeParameters, declarations, endStatement, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
29
AspClassic.Parser/ColonDelimitedTreeCollection.cs
Normal file
29
AspClassic.Parser/ColonDelimitedTreeCollection.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
#define DEBUG
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A collection of trees that are colon delimited.
|
||||
/// </summary>
|
||||
public abstract class ColonDelimitedTreeCollection<T> : TreeCollection<T> where T : Tree
|
||||
{
|
||||
private readonly ReadOnlyCollection<Location> _ColonLocations;
|
||||
|
||||
/// <summary>
|
||||
/// The locations of the colons in the collection.
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<Location> ColonLocations => _ColonLocations;
|
||||
|
||||
protected ColonDelimitedTreeCollection(TreeType type, IList<T> trees, IList<Location> colonLocations, Span span)
|
||||
: base(type, trees, span)
|
||||
{
|
||||
Debug.Assert(type == TreeType.StatementCollection || type == TreeType.DeclarationCollection);
|
||||
if (colonLocations != null && colonLocations.Count > 0)
|
||||
{
|
||||
_ColonLocations = new ReadOnlyCollection<Location>(colonLocations);
|
||||
}
|
||||
}
|
||||
}
|
29
AspClassic.Parser/CommaDelimitedTreeCollection.cs
Normal file
29
AspClassic.Parser/CommaDelimitedTreeCollection.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
#define DEBUG
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A collection of trees that are delimited by commas.
|
||||
/// </summary>
|
||||
public abstract class CommaDelimitedTreeCollection<T> : TreeCollection<T> where T : Tree
|
||||
{
|
||||
private readonly ReadOnlyCollection<Location> _CommaLocations;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the commas in the list.
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<Location> CommaLocations => _CommaLocations;
|
||||
|
||||
protected CommaDelimitedTreeCollection(TreeType type, IList<T> trees, IList<Location> commaLocations, Span span)
|
||||
: base(type, trees, span)
|
||||
{
|
||||
Debug.Assert(type >= TreeType.ArgumentCollection && type <= TreeType.ImportCollection);
|
||||
if (commaLocations != null && commaLocations.Count > 0)
|
||||
{
|
||||
_CommaLocations = new ReadOnlyCollection<Location>(commaLocations);
|
||||
}
|
||||
}
|
||||
}
|
40
AspClassic.Parser/Comment.cs
Normal file
40
AspClassic.Parser/Comment.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a comment.
|
||||
/// </summary>
|
||||
public sealed class Comment : Tree
|
||||
{
|
||||
private readonly string _Comment;
|
||||
|
||||
private readonly bool _IsREM;
|
||||
|
||||
/// <summary>
|
||||
/// The text of the comment.
|
||||
/// </summary>
|
||||
public string VComment => _Comment;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the comment is a REM comment.
|
||||
/// </summary>
|
||||
public bool IsREM => _IsREM;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new comment parse tree.
|
||||
/// </summary>
|
||||
/// <param name="comment">The text of the comment.</param>
|
||||
/// <param name="isREM">Whether the comment is a REM comment.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public Comment(string comment, bool isREM, Span span)
|
||||
: base(TreeType.Comment, span)
|
||||
{
|
||||
if (comment == null)
|
||||
{
|
||||
throw new ArgumentNullException("comment");
|
||||
}
|
||||
_Comment = comment;
|
||||
_IsREM = isREM;
|
||||
}
|
||||
}
|
40
AspClassic.Parser/CommentToken.cs
Normal file
40
AspClassic.Parser/CommentToken.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A comment token.
|
||||
/// </summary>
|
||||
public sealed class CommentToken : Token
|
||||
{
|
||||
private readonly bool _IsREM;
|
||||
|
||||
private readonly string _Comment;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the comment was preceded by REM.
|
||||
/// </summary>
|
||||
public bool IsREM => _IsREM;
|
||||
|
||||
/// <summary>
|
||||
/// The text of the comment.
|
||||
/// </summary>
|
||||
public string Comment => _Comment;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new comment token.
|
||||
/// </summary>
|
||||
/// <param name="comment">The comment value.</param>
|
||||
/// <param name="isREM">Whether the comment was preceded by REM.</param>
|
||||
/// <param name="span">The location of the comment.</param>
|
||||
public CommentToken(string comment, bool isREM, Span span)
|
||||
: base(TokenType.Comment, span)
|
||||
{
|
||||
if (comment == null)
|
||||
{
|
||||
throw new ArgumentNullException("comment");
|
||||
}
|
||||
_IsREM = isREM;
|
||||
_Comment = comment;
|
||||
}
|
||||
}
|
69
AspClassic.Parser/ComparisonCaseClause.cs
Normal file
69
AspClassic.Parser/ComparisonCaseClause.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a case clause that compares values.
|
||||
/// </summary>
|
||||
public sealed class ComparisonCaseClause : CaseClause
|
||||
{
|
||||
private readonly Location _IsLocation;
|
||||
|
||||
private readonly OperatorType _ComparisonOperator;
|
||||
|
||||
private readonly Location _OperatorLocation;
|
||||
|
||||
private readonly Expression _Operand;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'Is', if any.
|
||||
/// </summary>
|
||||
public Location IsLocation => _IsLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The comparison operator used in the case clause.
|
||||
/// </summary>
|
||||
public OperatorType ComparisonOperator => _ComparisonOperator;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the comparison operator.
|
||||
/// </summary>
|
||||
public Location OperatorLocation => _OperatorLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The operand of the case clause.
|
||||
/// </summary>
|
||||
public Expression Operand => _Operand;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a comparison case clause.
|
||||
/// </summary>
|
||||
/// <param name="isLocation">The location of the 'Is', if any.</param>
|
||||
/// <param name="comparisonOperator">The comparison operator used.</param>
|
||||
/// <param name="operatorLocation">The location of the comparison operator.</param>
|
||||
/// <param name="operand">The operand of the comparison.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public ComparisonCaseClause(Location isLocation, OperatorType comparisonOperator, Location operatorLocation, Expression operand, Span span)
|
||||
: base(TreeType.ComparisonCaseClause, span)
|
||||
{
|
||||
if (operand == null)
|
||||
{
|
||||
throw new ArgumentNullException("operand");
|
||||
}
|
||||
if (comparisonOperator < OperatorType.Equals || comparisonOperator > OperatorType.GreaterThanEquals)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("comparisonOperator");
|
||||
}
|
||||
SetParent(operand);
|
||||
_IsLocation = isLocation;
|
||||
_ComparisonOperator = comparisonOperator;
|
||||
_OperatorLocation = operatorLocation;
|
||||
_Operand = operand;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Operand);
|
||||
}
|
||||
}
|
76
AspClassic.Parser/CompoundAssignmentStatement.cs
Normal file
76
AspClassic.Parser/CompoundAssignmentStatement.cs
Normal file
|
@ -0,0 +1,76 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a compound assignment statement.
|
||||
/// </summary>
|
||||
public sealed class CompoundAssignmentStatement : Statement
|
||||
{
|
||||
private readonly Expression _TargetExpression;
|
||||
|
||||
private readonly OperatorType _CompoundOperator;
|
||||
|
||||
private readonly Location _OperatorLocation;
|
||||
|
||||
private readonly Expression _SourceExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The target of the assignment.
|
||||
/// </summary>
|
||||
public Expression TargetExpression => _TargetExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The compound operator.
|
||||
/// </summary>
|
||||
public OperatorType CompoundOperator => _CompoundOperator;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the operator.
|
||||
/// </summary>
|
||||
public Location OperatorLocation => _OperatorLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The source of the assignment.
|
||||
/// </summary>
|
||||
public Expression SourceExpression => _SourceExpression;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a compound assignment statement.
|
||||
/// </summary>
|
||||
/// <param name="compoundOperator">The compound operator.</param>
|
||||
/// <param name="targetExpression">The target of the assignment.</param>
|
||||
/// <param name="operatorLocation">The location of the operator.</param>
|
||||
/// <param name="sourceExpression">The source of the assignment.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public CompoundAssignmentStatement(OperatorType compoundOperator, Expression targetExpression, Location operatorLocation, Expression sourceExpression, Span span, IList<Comment> comments)
|
||||
: base(TreeType.CompoundAssignmentStatement, span, comments)
|
||||
{
|
||||
if (compoundOperator < OperatorType.Plus || compoundOperator > OperatorType.Power)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("compoundOperator");
|
||||
}
|
||||
if (targetExpression == null)
|
||||
{
|
||||
throw new ArgumentNullException("targetExpression");
|
||||
}
|
||||
if (sourceExpression == null)
|
||||
{
|
||||
throw new ArgumentNullException("sourceExpression");
|
||||
}
|
||||
SetParent(targetExpression);
|
||||
SetParent(sourceExpression);
|
||||
_CompoundOperator = compoundOperator;
|
||||
_TargetExpression = targetExpression;
|
||||
_OperatorLocation = operatorLocation;
|
||||
_SourceExpression = sourceExpression;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, TargetExpression);
|
||||
Tree.AddChild(childList, SourceExpression);
|
||||
}
|
||||
}
|
39
AspClassic.Parser/ConstructedTypeName.cs
Normal file
39
AspClassic.Parser/ConstructedTypeName.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a constructed generic type name.
|
||||
/// </summary>
|
||||
public sealed class ConstructedTypeName : NamedTypeName
|
||||
{
|
||||
private readonly TypeArgumentCollection _TypeArguments;
|
||||
|
||||
/// <summary>
|
||||
/// The type arguments.
|
||||
/// </summary>
|
||||
public TypeArgumentCollection TypeArguments => _TypeArguments;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a generic constructed type name.
|
||||
/// </summary>
|
||||
/// <param name="name">The generic type being constructed.</param>
|
||||
/// <param name="typeArguments">The type arguments.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public ConstructedTypeName(Name name, TypeArgumentCollection typeArguments, Span span)
|
||||
: base(TreeType.ConstructedType, name, span)
|
||||
{
|
||||
if (typeArguments == null)
|
||||
{
|
||||
throw new ArgumentNullException("typeArguments");
|
||||
}
|
||||
SetParent(typeArguments);
|
||||
_TypeArguments = typeArguments;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, TypeArguments);
|
||||
}
|
||||
}
|
26
AspClassic.Parser/ConstructorDeclaration.cs
Normal file
26
AspClassic.Parser/ConstructorDeclaration.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a constructor declaration.
|
||||
/// </summary>
|
||||
public sealed class ConstructorDeclaration : MethodDeclaration
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new parse tree for a constructor declaration.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes for the parse tree.</param>
|
||||
/// <param name="modifiers">The modifiers for the parse tree.</param>
|
||||
/// <param name="keywordLocation">The location of the keyword.</param>
|
||||
/// <param name="name">The name of the declaration.</param>
|
||||
/// <param name="parameters">The parameters of the declaration.</param>
|
||||
/// <param name="statements">The statements in the declaration.</param>
|
||||
/// <param name="endDeclaration">The end block declaration, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ConstructorDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, SimpleName name, ParameterCollection parameters, StatementCollection statements, EndBlockDeclaration endDeclaration, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ConstructorDeclaration, attributes, modifiers, keywordLocation, name, null, parameters, default(Location), null, null, null, null, statements, endDeclaration, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
42
AspClassic.Parser/ContinueStatement.cs
Normal file
42
AspClassic.Parser/ContinueStatement.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an Continue statement.
|
||||
/// </summary>
|
||||
public sealed class ContinueStatement : Statement
|
||||
{
|
||||
private readonly BlockType _ContinueType;
|
||||
|
||||
private readonly Location _ContinueArgumentLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The type of tree this statement continues.
|
||||
/// </summary>
|
||||
public BlockType ContinueType => _ContinueType;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the Continue statement type.
|
||||
/// </summary>
|
||||
public Location ContinueArgumentLocation => _ContinueArgumentLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a parse tree for an Continue statement.
|
||||
/// </summary>
|
||||
/// <param name="continueType">The type of tree this statement continues.</param>
|
||||
/// <param name="continueArgumentLocation">The location of the Continue statement type.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ContinueStatement(BlockType continueType, Location continueArgumentLocation, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ContinueStatement, span, comments)
|
||||
{
|
||||
if ((uint)continueType > 3u)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("continueType");
|
||||
}
|
||||
_ContinueType = continueType;
|
||||
_ContinueArgumentLocation = continueArgumentLocation;
|
||||
}
|
||||
}
|
72
AspClassic.Parser/CustomEventDeclaration.cs
Normal file
72
AspClassic.Parser/CustomEventDeclaration.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a custom event declaration.
|
||||
/// </summary>
|
||||
public sealed class CustomEventDeclaration : SignatureDeclaration
|
||||
{
|
||||
private readonly Location _CustomLocation;
|
||||
|
||||
private readonly NameCollection _ImplementsList;
|
||||
|
||||
private readonly DeclarationCollection _Accessors;
|
||||
|
||||
private readonly EndBlockDeclaration _EndDeclaration;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'Custom' keyword.
|
||||
/// </summary>
|
||||
public Location CustomLocation => _CustomLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The list of implemented members.
|
||||
/// </summary>
|
||||
public NameCollection ImplementsList => _ImplementsList;
|
||||
|
||||
/// <summary>
|
||||
/// The event accessors.
|
||||
/// </summary>
|
||||
public DeclarationCollection Accessors => _Accessors;
|
||||
|
||||
/// <summary>
|
||||
/// The End Event declaration, if any.
|
||||
/// </summary>
|
||||
public EndBlockDeclaration EndDeclaration => _EndDeclaration;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a custom property declaration.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes on the declaration.</param>
|
||||
/// <param name="modifiers">The modifiers on the declaration.</param>
|
||||
/// <param name="customLocation">The location of the 'Custom' keyword.</param>
|
||||
/// <param name="keywordLocation">The location of the keyword.</param>
|
||||
/// <param name="name">The name of the custom event.</param>
|
||||
/// <param name="asLocation">The location of the 'As', if any.</param>
|
||||
/// <param name="resultType">The result type, if any.</param>
|
||||
/// <param name="implementsList">The implements list.</param>
|
||||
/// <param name="accessors">The custom event accessors.</param>
|
||||
/// <param name="endDeclaration">The End Event declaration, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public CustomEventDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location customLocation, Location keywordLocation, SimpleName name, Location asLocation, TypeName resultType, NameCollection implementsList, DeclarationCollection accessors, EndBlockDeclaration endDeclaration, Span span, IList<Comment> comments)
|
||||
: base(TreeType.CustomEventDeclaration, attributes, modifiers, keywordLocation, name, null, null, asLocation, null, resultType, span, comments)
|
||||
{
|
||||
SetParent(accessors);
|
||||
SetParent(endDeclaration);
|
||||
SetParent(implementsList);
|
||||
_CustomLocation = customLocation;
|
||||
_ImplementsList = implementsList;
|
||||
_Accessors = accessors;
|
||||
_EndDeclaration = endDeclaration;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, ImplementsList);
|
||||
Tree.AddChild(childList, Accessors);
|
||||
Tree.AddChild(childList, EndDeclaration);
|
||||
}
|
||||
}
|
29
AspClassic.Parser/DateLiteralExpression.cs
Normal file
29
AspClassic.Parser/DateLiteralExpression.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a date literal expression.
|
||||
/// </summary>
|
||||
public sealed class DateLiteralExpression : LiteralExpression
|
||||
{
|
||||
private readonly DateTime _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// The literal value.
|
||||
/// </summary>
|
||||
public DateTime Literal => _Literal;
|
||||
|
||||
public override object Value => _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a date literal.
|
||||
/// </summary>
|
||||
/// <param name="literal">The literal value.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public DateLiteralExpression(DateTime literal, Span span)
|
||||
: base(TreeType.DateLiteralExpression, span)
|
||||
{
|
||||
_Literal = literal;
|
||||
}
|
||||
}
|
27
AspClassic.Parser/DateLiteralToken.cs
Normal file
27
AspClassic.Parser/DateLiteralToken.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A date/time literal.
|
||||
/// </summary>
|
||||
public sealed class DateLiteralToken : Token
|
||||
{
|
||||
private readonly DateTime _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// The literal value.
|
||||
/// </summary>
|
||||
public DateTime Literal => _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new date literal instance.
|
||||
/// </summary>
|
||||
/// <param name="literal">The literal value.</param>
|
||||
/// <param name="span">The location of the literal.</param>
|
||||
public DateLiteralToken(DateTime literal, Span span)
|
||||
: base(TokenType.DateLiteral, span)
|
||||
{
|
||||
_Literal = literal;
|
||||
}
|
||||
}
|
42
AspClassic.Parser/DecimalLiteralExpression.cs
Normal file
42
AspClassic.Parser/DecimalLiteralExpression.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a decimal literal expression.
|
||||
/// </summary>
|
||||
public sealed class DecimalLiteralExpression : LiteralExpression
|
||||
{
|
||||
private readonly decimal _Literal;
|
||||
|
||||
private readonly TypeCharacter _TypeCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// The literal value.
|
||||
/// </summary>
|
||||
public decimal Literal => _Literal;
|
||||
|
||||
public override object Value => _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// The type character on the literal value.
|
||||
/// </summary>
|
||||
public TypeCharacter TypeCharacter => _TypeCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a floating point literal.
|
||||
/// </summary>
|
||||
/// <param name="literal">The literal value.</param>
|
||||
/// <param name="typeCharacter">The type character on the literal value.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public DecimalLiteralExpression(decimal literal, TypeCharacter typeCharacter, Span span)
|
||||
: base(TreeType.DecimalLiteralExpression, span)
|
||||
{
|
||||
if (typeCharacter != 0 && typeCharacter != TypeCharacter.DecimalChar && typeCharacter != TypeCharacter.DecimalSymbol)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("typeCharacter");
|
||||
}
|
||||
_Literal = literal;
|
||||
_TypeCharacter = typeCharacter;
|
||||
}
|
||||
}
|
40
AspClassic.Parser/DecimalLiteralToken.cs
Normal file
40
AspClassic.Parser/DecimalLiteralToken.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A decimal literal token.
|
||||
/// </summary>
|
||||
public sealed class DecimalLiteralToken : Token
|
||||
{
|
||||
private readonly decimal _Literal;
|
||||
|
||||
private readonly TypeCharacter _TypeCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// The literal value.
|
||||
/// </summary>
|
||||
public decimal Literal => _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// The type character of the literal.
|
||||
/// </summary>
|
||||
public TypeCharacter TypeCharacter => _TypeCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new decimal literal token.
|
||||
/// </summary>
|
||||
/// <param name="literal">The literal value.</param>
|
||||
/// <param name="typeCharacter">The literal's type character.</param>
|
||||
/// <param name="span">The location of the literal.</param>
|
||||
public DecimalLiteralToken(decimal literal, TypeCharacter typeCharacter, Span span)
|
||||
: base(TokenType.DecimalLiteral, span)
|
||||
{
|
||||
if (typeCharacter != 0 && typeCharacter != TypeCharacter.DecimalChar && typeCharacter != TypeCharacter.DecimalSymbol)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("typeCharacter");
|
||||
}
|
||||
_Literal = literal;
|
||||
_TypeCharacter = typeCharacter;
|
||||
}
|
||||
}
|
35
AspClassic.Parser/Declaration.cs
Normal file
35
AspClassic.Parser/Declaration.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
#define DEBUG
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a declaration.
|
||||
/// </summary>
|
||||
public class Declaration : Statement
|
||||
{
|
||||
public override bool IsBad => base.Type == TreeType.SyntaxError;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bad declaration.
|
||||
/// </summary>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
/// <returns>A bad declaration.</returns>
|
||||
public static Declaration GetBadDeclaration(Span span, IList<Comment> comments)
|
||||
{
|
||||
return new Declaration(span, comments);
|
||||
}
|
||||
|
||||
protected Declaration(TreeType type, Span span, IList<Comment> comments)
|
||||
: base(type, span, comments)
|
||||
{
|
||||
Debug.Assert(type >= TreeType.EmptyDeclaration && type <= TreeType.DelegateFunctionDeclaration);
|
||||
}
|
||||
|
||||
private Declaration(Span span, IList<Comment> comments)
|
||||
: base(TreeType.SyntaxError, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
25
AspClassic.Parser/DeclarationCollection.cs
Normal file
25
AspClassic.Parser/DeclarationCollection.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A read-only collection of declarations.
|
||||
/// </summary>
|
||||
public sealed class DeclarationCollection : ColonDelimitedTreeCollection<Declaration>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new collection of declarations.
|
||||
/// </summary>
|
||||
/// <param name="declarations">The declarations in the collection.</param>
|
||||
/// <param name="colonLocations">The locations of the colons in the collection.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public DeclarationCollection(IList<Declaration> declarations, IList<Location> colonLocations, Span span)
|
||||
: base(TreeType.DeclarationCollection, declarations, colonLocations, span)
|
||||
{
|
||||
if ((declarations == null || declarations.Count == 0) && (colonLocations == null || colonLocations.Count == 0))
|
||||
{
|
||||
throw new ArgumentException("DeclarationCollection cannot be empty.");
|
||||
}
|
||||
}
|
||||
}
|
30
AspClassic.Parser/DelegateDeclaration.cs
Normal file
30
AspClassic.Parser/DelegateDeclaration.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
#define DEBUG
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a delegate declaration.
|
||||
/// </summary>
|
||||
public abstract class DelegateDeclaration : SignatureDeclaration
|
||||
{
|
||||
private readonly Location _SubOrFunctionLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The location of 'Sub' or 'Function'.
|
||||
/// </summary>
|
||||
public Location SubOrFunctionLocation => _SubOrFunctionLocation;
|
||||
|
||||
protected DelegateDeclaration(TreeType type, AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, Location subOrFunctionLocation, SimpleName name, TypeParameterCollection typeParameters, ParameterCollection parameters, Location asLocation, AttributeBlockCollection resultTypeAttributes, TypeName resultType, Span span, IList<Comment> comments)
|
||||
: base(type, attributes, modifiers, keywordLocation, name, typeParameters, parameters, asLocation, resultTypeAttributes, resultType, span, comments)
|
||||
{
|
||||
Debug.Assert(type == TreeType.DelegateSubDeclaration || type == TreeType.DelegateFunctionDeclaration);
|
||||
_SubOrFunctionLocation = subOrFunctionLocation;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
}
|
||||
}
|
34
AspClassic.Parser/DelegateFunctionDeclaration.cs
Normal file
34
AspClassic.Parser/DelegateFunctionDeclaration.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a delegate Function declaration.
|
||||
/// </summary>
|
||||
public sealed class DelegateFunctionDeclaration : DelegateDeclaration
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a delegate declaration.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes for the parse tree.</param>
|
||||
/// <param name="modifiers">The modifiers for the parse tree.</param>
|
||||
/// <param name="keywordLocation">The location of the keyword.</param>
|
||||
/// <param name="functionLocation">The location of the 'Function'.</param>
|
||||
/// <param name="name">The name of the declaration.</param>
|
||||
/// <param name="typeParameters">The type parameters of the declaration, if any.</param>
|
||||
/// <param name="parameters">The parameters of the declaration.</param>
|
||||
/// <param name="asLocation">The location of the 'As', if any.</param>
|
||||
/// <param name="resultTypeAttributes">The attributes on the result type, if any.</param>
|
||||
/// <param name="resultType">The result type, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public DelegateFunctionDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, Location functionLocation, SimpleName name, TypeParameterCollection typeParameters, ParameterCollection parameters, Location asLocation, AttributeBlockCollection resultTypeAttributes, TypeName resultType, Span span, IList<Comment> comments)
|
||||
: base(TreeType.DelegateFunctionDeclaration, attributes, modifiers, keywordLocation, functionLocation, name, typeParameters, parameters, asLocation, resultTypeAttributes, resultType, span, comments)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
}
|
||||
}
|
26
AspClassic.Parser/DelegateSubDeclaration.cs
Normal file
26
AspClassic.Parser/DelegateSubDeclaration.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a delegate Sub declaration.
|
||||
/// </summary>
|
||||
public sealed class DelegateSubDeclaration : DelegateDeclaration
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a delegate Sub declaration.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes for the parse tree.</param>
|
||||
/// <param name="modifiers">The modifiers for the parse tree.</param>
|
||||
/// <param name="keywordLocation">The location of the keyword.</param>
|
||||
/// <param name="subLocation">The location of the 'Sub'.</param>
|
||||
/// <param name="name">The name of the declaration.</param>
|
||||
/// <param name="typeParameters">The type parameters of the declaration, if any.</param>
|
||||
/// <param name="parameters">The parameters of the declaration.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public DelegateSubDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, Location subLocation, SimpleName name, TypeParameterCollection typeParameters, ParameterCollection parameters, Span span, IList<Comment> comments)
|
||||
: base(TreeType.DelegateSubDeclaration, attributes, modifiers, keywordLocation, subLocation, name, typeParameters, parameters, default(Location), null, null, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
58
AspClassic.Parser/DictionaryLookupExpression.cs
Normal file
58
AspClassic.Parser/DictionaryLookupExpression.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a dictionary lookup expression.
|
||||
/// </summary>
|
||||
public sealed class DictionaryLookupExpression : Expression
|
||||
{
|
||||
private readonly Expression _Qualifier;
|
||||
|
||||
private readonly Location _BangLocation;
|
||||
|
||||
private readonly SimpleName _Name;
|
||||
|
||||
/// <summary>
|
||||
/// The dictionary expression.
|
||||
/// </summary>
|
||||
public Expression Qualifier => _Qualifier;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the '!'.
|
||||
/// </summary>
|
||||
public Location BangLocation => _BangLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The name to look up.
|
||||
/// </summary>
|
||||
public SimpleName Name => _Name;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a dictionary lookup expression.
|
||||
/// </summary>
|
||||
/// <param name="qualifier">The dictionary expression.</param>
|
||||
/// <param name="bangLocation">The location of the '!'.</param>
|
||||
/// <param name="name">The name to look up..</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public DictionaryLookupExpression(Expression qualifier, Location bangLocation, SimpleName name, Span span)
|
||||
: base(TreeType.DictionaryLookupExpression, span)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
SetParent(qualifier);
|
||||
SetParent(name);
|
||||
_Qualifier = qualifier;
|
||||
_BangLocation = bangLocation;
|
||||
_Name = name;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Qualifier);
|
||||
Tree.AddChild(childList, Name);
|
||||
}
|
||||
}
|
21
AspClassic.Parser/DirectCastExpression.cs
Normal file
21
AspClassic.Parser/DirectCastExpression.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a DirectCast expression.
|
||||
/// </summary>
|
||||
public sealed class DirectCastExpression : CastTypeExpression
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a DirectCast expression.
|
||||
/// </summary>
|
||||
/// <param name="leftParenthesisLocation">The location of the '('.</param>
|
||||
/// <param name="operand">The expression to be converted.</param>
|
||||
/// <param name="commaLocation">The location of the ','.</param>
|
||||
/// <param name="target">The target type of the conversion.</param>
|
||||
/// <param name="rightParenthesisLocation">The location of the ')'.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public DirectCastExpression(Location leftParenthesisLocation, Expression operand, Location commaLocation, TypeName target, Location rightParenthesisLocation, Span span)
|
||||
: base(TreeType.DirectCastExpression, leftParenthesisLocation, operand, commaLocation, target, rightParenthesisLocation, span)
|
||||
{
|
||||
}
|
||||
}
|
65
AspClassic.Parser/DoBlockStatement.cs
Normal file
65
AspClassic.Parser/DoBlockStatement.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Do statement.
|
||||
/// </summary>
|
||||
public sealed class DoBlockStatement : BlockStatement
|
||||
{
|
||||
private readonly bool _IsWhile;
|
||||
|
||||
private readonly Location _WhileOrUntilLocation;
|
||||
|
||||
private readonly Expression _Expression;
|
||||
|
||||
private readonly LoopStatement _EndStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Do is followed by a While or Until, if any.
|
||||
/// </summary>
|
||||
public bool IsWhile => _IsWhile;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the While or Until, if any.
|
||||
/// </summary>
|
||||
public Location WhileOrUntilLocation => _WhileOrUntilLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The While or Until expression, if any.
|
||||
/// </summary>
|
||||
public Expression Expression => _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// The ending Loop statement.
|
||||
/// </summary>
|
||||
public LoopStatement EndStatement => _EndStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a Do statement.
|
||||
/// </summary>
|
||||
/// <param name="expression">The While or Until expression, if any.</param>
|
||||
/// <param name="isWhile">Whether the Do is followed by a While or Until, if any.</param>
|
||||
/// <param name="whileOrUntilLocation">The location of the While or Until, if any.</param>
|
||||
/// <param name="statements">The statements in the block.</param>
|
||||
/// <param name="endStatement">The ending Loop statement.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments on the parse tree.</param>
|
||||
public DoBlockStatement(Expression expression, bool isWhile, Location whileOrUntilLocation, StatementCollection statements, LoopStatement endStatement, Span span, IList<Comment> comments)
|
||||
: base(TreeType.DoBlockStatement, statements, span, comments)
|
||||
{
|
||||
SetParent(expression);
|
||||
SetParent(endStatement);
|
||||
_Expression = expression;
|
||||
_IsWhile = isWhile;
|
||||
_WhileOrUntilLocation = whileOrUntilLocation;
|
||||
_EndStatement = endStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Expression);
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, EndStatement);
|
||||
}
|
||||
}
|
41
AspClassic.Parser/ElseBlockStatement.cs
Normal file
41
AspClassic.Parser/ElseBlockStatement.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an Else block statement.
|
||||
/// </summary>
|
||||
public sealed class ElseBlockStatement : BlockStatement
|
||||
{
|
||||
private readonly ElseStatement _ElseStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The Else or Else If statement.
|
||||
/// </summary>
|
||||
public ElseStatement ElseStatement => _ElseStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an Else block statement.
|
||||
/// </summary>
|
||||
/// <param name="elseStatement">The Else statement.</param>
|
||||
/// <param name="statements">The statements in the block.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ElseBlockStatement(ElseStatement elseStatement, StatementCollection statements, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ElseBlockStatement, statements, span, comments)
|
||||
{
|
||||
if (elseStatement == null)
|
||||
{
|
||||
throw new ArgumentNullException("elseStatement");
|
||||
}
|
||||
SetParent(elseStatement);
|
||||
_ElseStatement = elseStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, ElseStatement);
|
||||
base.GetChildTrees(childList);
|
||||
}
|
||||
}
|
41
AspClassic.Parser/ElseIfBlockStatement.cs
Normal file
41
AspClassic.Parser/ElseIfBlockStatement.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an Else If block statement.
|
||||
/// </summary>
|
||||
public sealed class ElseIfBlockStatement : BlockStatement
|
||||
{
|
||||
private readonly ElseIfStatement _ElseIfStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The Else If statement.
|
||||
/// </summary>
|
||||
public ElseIfStatement ElseIfStatement => _ElseIfStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an Else If block statement.
|
||||
/// </summary>
|
||||
/// <param name="elseIfStatement">The Else If statement.</param>
|
||||
/// <param name="statements">The statements in the block.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ElseIfBlockStatement(ElseIfStatement elseIfStatement, StatementCollection statements, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ElseIfBlockStatement, statements, span, comments)
|
||||
{
|
||||
if (elseIfStatement == null)
|
||||
{
|
||||
throw new ArgumentNullException("elseIfStatement");
|
||||
}
|
||||
SetParent(elseIfStatement);
|
||||
_ElseIfStatement = elseIfStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, ElseIfStatement);
|
||||
base.GetChildTrees(childList);
|
||||
}
|
||||
}
|
48
AspClassic.Parser/ElseIfStatement.cs
Normal file
48
AspClassic.Parser/ElseIfStatement.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an Else If statement.
|
||||
/// </summary>
|
||||
public sealed class ElseIfStatement : Statement
|
||||
{
|
||||
private readonly Expression _Expression;
|
||||
|
||||
private readonly Location _ThenLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The conditional expression.
|
||||
/// </summary>
|
||||
public Expression Expression => _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'Then', if any.
|
||||
/// </summary>
|
||||
public Location ThenLocation => _ThenLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an Else If statement.
|
||||
/// </summary>
|
||||
/// <param name="expression">The conditional expression.</param>
|
||||
/// <param name="thenLocation">The location of the 'Then', if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ElseIfStatement(Expression expression, Location thenLocation, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ElseIfStatement, span, comments)
|
||||
{
|
||||
if (expression == null)
|
||||
{
|
||||
throw new ArgumentNullException("expression");
|
||||
}
|
||||
SetParent(expression);
|
||||
_Expression = expression;
|
||||
_ThenLocation = thenLocation;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Expression);
|
||||
}
|
||||
}
|
19
AspClassic.Parser/ElseStatement.cs
Normal file
19
AspClassic.Parser/ElseStatement.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an Else statement.
|
||||
/// </summary>
|
||||
public sealed class ElseStatement : Statement
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an Else statement.
|
||||
/// </summary>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ElseStatement(Span span, IList<Comment> comments)
|
||||
: base(TreeType.ElseStatement, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
19
AspClassic.Parser/EmptyDeclaration.cs
Normal file
19
AspClassic.Parser/EmptyDeclaration.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an empty declaration.
|
||||
/// </summary>
|
||||
public sealed class EmptyDeclaration : Declaration
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an empty declaration.
|
||||
/// </summary>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public EmptyDeclaration(Span span, IList<Comment> comments)
|
||||
: base(TreeType.EmptyDeclaration, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
19
AspClassic.Parser/EmptyStatement.cs
Normal file
19
AspClassic.Parser/EmptyStatement.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an empty statement.
|
||||
/// </summary>
|
||||
public sealed class EmptyStatement : Statement
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an empty statement.
|
||||
/// </summary>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public EmptyStatement(Span span, IList<Comment> comments)
|
||||
: base(TreeType.EmptyStatement, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
55
AspClassic.Parser/EndBlockDeclaration.cs
Normal file
55
AspClassic.Parser/EndBlockDeclaration.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an End declaration.
|
||||
/// </summary>
|
||||
public sealed class EndBlockDeclaration : Declaration
|
||||
{
|
||||
private readonly BlockType _EndType;
|
||||
|
||||
private readonly Location _EndArgumentLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The type of block the declaration ends.
|
||||
/// </summary>
|
||||
public BlockType EndType => _EndType;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the end block argument.
|
||||
/// </summary>
|
||||
public Location EndArgumentLocation => _EndArgumentLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new parse tree for an End block declaration.
|
||||
/// </summary>
|
||||
/// <param name="endType">The type of the block the statement ends.</param>
|
||||
/// <param name="endArgumentLocation">The location of the end block argument.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public EndBlockDeclaration(BlockType endType, Location endArgumentLocation, Span span, IList<Comment> comments)
|
||||
: base(TreeType.EndBlockDeclaration, span, comments)
|
||||
{
|
||||
if (endType < BlockType.Sub && endType > BlockType.Namespace)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("endType");
|
||||
}
|
||||
_EndType = endType;
|
||||
_EndArgumentLocation = endArgumentLocation;
|
||||
}
|
||||
|
||||
internal EndBlockDeclaration(EndBlockStatement endBlockStatement)
|
||||
: base(TreeType.EndBlockDeclaration, endBlockStatement.Span, endBlockStatement.Comments)
|
||||
{
|
||||
BlockType endType = endBlockStatement.EndType;
|
||||
if ((uint)(endType - 10) <= 2u || (uint)(endType - 14) <= 4u)
|
||||
{
|
||||
_EndType = endBlockStatement.EndType;
|
||||
_EndArgumentLocation = endBlockStatement.EndArgumentLocation;
|
||||
return;
|
||||
}
|
||||
throw new ArgumentException("Invalid EndBlockStatement type.");
|
||||
}
|
||||
}
|
42
AspClassic.Parser/EndBlockStatement.cs
Normal file
42
AspClassic.Parser/EndBlockStatement.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an End statement of a block.
|
||||
/// </summary>
|
||||
public sealed class EndBlockStatement : Statement
|
||||
{
|
||||
private readonly BlockType _EndType;
|
||||
|
||||
private readonly Location _EndArgumentLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The type of block the statement ends.
|
||||
/// </summary>
|
||||
public BlockType EndType => _EndType;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the end block argument.
|
||||
/// </summary>
|
||||
public Location EndArgumentLocation => _EndArgumentLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new parse tree for an End block statement.
|
||||
/// </summary>
|
||||
/// <param name="endType">The type of the block the statement ends.</param>
|
||||
/// <param name="endArgumentLocation">The location of the end block argument.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public EndBlockStatement(BlockType endType, Location endArgumentLocation, Span span, IList<Comment> comments)
|
||||
: base(TreeType.EndBlockStatement, span, comments)
|
||||
{
|
||||
if (endType < BlockType.While || endType > BlockType.Namespace)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("endType");
|
||||
}
|
||||
_EndType = endType;
|
||||
_EndArgumentLocation = endArgumentLocation;
|
||||
}
|
||||
}
|
16
AspClassic.Parser/EndOfStreamToken.cs
Normal file
16
AspClassic.Parser/EndOfStreamToken.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A token representing the end of the file.
|
||||
/// </summary>
|
||||
public sealed class EndOfStreamToken : Token
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new end-of-stream token.
|
||||
/// </summary>
|
||||
/// <param name="span">The location of the end of the stream.</param>
|
||||
public EndOfStreamToken(Span span)
|
||||
: base(TokenType.EndOfStream, span)
|
||||
{
|
||||
}
|
||||
}
|
19
AspClassic.Parser/EndStatement.cs
Normal file
19
AspClassic.Parser/EndStatement.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an End statement.
|
||||
/// </summary>
|
||||
public sealed class EndStatement : Statement
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an End statement.
|
||||
/// </summary>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public EndStatement(Span span, IList<Comment> comments)
|
||||
: base(TreeType.EndStatement, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
50
AspClassic.Parser/EnumDeclaration.cs
Normal file
50
AspClassic.Parser/EnumDeclaration.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an Enum declaration.
|
||||
/// </summary>
|
||||
public sealed class EnumDeclaration : BlockDeclaration
|
||||
{
|
||||
private readonly Location _AsLocation;
|
||||
|
||||
private readonly TypeName _ElementType;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'As', if any.
|
||||
/// </summary>
|
||||
public Location AsLocation => _AsLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The element type of the enumerated type, if any.
|
||||
/// </summary>
|
||||
public TypeName ElementType => _ElementType;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a parse tree for an Enum declaration.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes for the parse tree.</param>
|
||||
/// <param name="modifiers">The modifiers for the parse tree.</param>
|
||||
/// <param name="keywordLocation">The location of the keyword.</param>
|
||||
/// <param name="name">The name of the declaration.</param>
|
||||
/// <param name="asLocation">The location of the 'As', if any.</param>
|
||||
/// <param name="elementType">The element type of the enumerated type, if any.</param>
|
||||
/// <param name="declarations">The enumerated values.</param>
|
||||
/// <param name="endStatement">The end block declaration, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public EnumDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, SimpleName name, Location asLocation, TypeName elementType, DeclarationCollection declarations, EndBlockDeclaration endStatement, Span span, IList<Comment> comments)
|
||||
: base(TreeType.EnumDeclaration, attributes, modifiers, keywordLocation, name, declarations, endStatement, span, comments)
|
||||
{
|
||||
SetParent(elementType);
|
||||
_AsLocation = asLocation;
|
||||
_ElementType = elementType;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, ElementType);
|
||||
}
|
||||
}
|
61
AspClassic.Parser/EnumValueDeclaration.cs
Normal file
61
AspClassic.Parser/EnumValueDeclaration.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an enumerated value declaration.
|
||||
/// </summary>
|
||||
public sealed class EnumValueDeclaration : ModifiedDeclaration
|
||||
{
|
||||
private readonly Name _Name;
|
||||
|
||||
private readonly Location _EqualsLocation;
|
||||
|
||||
private readonly Expression _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// The name of the enumerated value.
|
||||
/// </summary>
|
||||
public Name Name => _Name;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the '=', if any.
|
||||
/// </summary>
|
||||
public Location EqualsLocation => _EqualsLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The enumerated value, if any.
|
||||
/// </summary>
|
||||
public Expression Expression => _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an enumerated value.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes on the declaration.</param>
|
||||
/// <param name="name">The name of the declaration.</param>
|
||||
/// <param name="equalsLocation">The location of the '=', if any.</param>
|
||||
/// <param name="expression">The enumerated value, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public EnumValueDeclaration(AttributeBlockCollection attributes, Name name, Location equalsLocation, Expression expression, Span span, IList<Comment> comments)
|
||||
: base(TreeType.EnumValueDeclaration, attributes, null, span, comments)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
SetParent(name);
|
||||
SetParent(expression);
|
||||
_Name = name;
|
||||
_EqualsLocation = equalsLocation;
|
||||
_Expression = expression;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, Name);
|
||||
Tree.AddChild(childList, Expression);
|
||||
}
|
||||
}
|
39
AspClassic.Parser/EraseStatement.cs
Normal file
39
AspClassic.Parser/EraseStatement.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an Erase statement.
|
||||
/// </summary>
|
||||
public sealed class EraseStatement : Statement
|
||||
{
|
||||
private readonly ExpressionCollection _Variables;
|
||||
|
||||
/// <summary>
|
||||
/// The variables to erase.
|
||||
/// </summary>
|
||||
public ExpressionCollection Variables => _Variables;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an Erase statement.
|
||||
/// </summary>
|
||||
/// <param name="variables">The variables to erase.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public EraseStatement(ExpressionCollection variables, Span span, IList<Comment> comments)
|
||||
: base(TreeType.EraseStatement, span, comments)
|
||||
{
|
||||
if (variables == null)
|
||||
{
|
||||
throw new ArgumentNullException("variables");
|
||||
}
|
||||
SetParent(variables);
|
||||
_Variables = variables;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Variables);
|
||||
}
|
||||
}
|
20
AspClassic.Parser/ErrorStatement.cs
Normal file
20
AspClassic.Parser/ErrorStatement.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an Error statement.
|
||||
/// </summary>
|
||||
public sealed class ErrorStatement : ExpressionStatement
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an Error statement.
|
||||
/// </summary>
|
||||
/// <param name="expression">The expression.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ErrorStatement(Expression expression, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ErrorStatement, expression, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
31
AspClassic.Parser/ErrorToken.cs
Normal file
31
AspClassic.Parser/ErrorToken.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A lexical error.
|
||||
/// </summary>
|
||||
public sealed class ErrorToken : Token
|
||||
{
|
||||
private readonly SyntaxError _SyntaxError;
|
||||
|
||||
/// <summary>
|
||||
/// The syntax error that represents the lexical error.
|
||||
/// </summary>
|
||||
public SyntaxError SyntaxError => _SyntaxError;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new lexical error token.
|
||||
/// </summary>
|
||||
/// <param name="errorType">The type of the error.</param>
|
||||
/// <param name="span">The location of the error.</param>
|
||||
public ErrorToken(SyntaxErrorType errorType, Span span)
|
||||
: base(TokenType.LexicalError, span)
|
||||
{
|
||||
if (errorType < SyntaxErrorType.InvalidEscapedIdentifier || errorType > SyntaxErrorType.InvalidDecimalLiteral)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("errorType");
|
||||
}
|
||||
_SyntaxError = new SyntaxError(errorType, span);
|
||||
}
|
||||
}
|
39
AspClassic.Parser/ErrorXmlSerializer.cs
Normal file
39
AspClassic.Parser/ErrorXmlSerializer.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
public class ErrorXmlSerializer
|
||||
{
|
||||
private readonly XmlWriter Writer;
|
||||
|
||||
public ErrorXmlSerializer(XmlWriter Writer)
|
||||
{
|
||||
this.Writer = Writer;
|
||||
}
|
||||
|
||||
private void Serialize(Span Span)
|
||||
{
|
||||
Writer.WriteAttributeString("startLine", Conversions.ToString(Span.Start.Line));
|
||||
Writer.WriteAttributeString("startCol", Conversions.ToString(Span.Start.Column));
|
||||
Writer.WriteAttributeString("endLine", Conversions.ToString(Span.Finish.Line));
|
||||
Writer.WriteAttributeString("endCol", Conversions.ToString(Span.Finish.Column));
|
||||
}
|
||||
|
||||
public void Serialize(SyntaxError SyntaxError)
|
||||
{
|
||||
Writer.WriteStartElement(SyntaxError.Type.ToString());
|
||||
Serialize(SyntaxError.Span);
|
||||
Writer.WriteString(SyntaxError.ToString());
|
||||
Writer.WriteEndElement();
|
||||
}
|
||||
|
||||
public void Serialize(List<SyntaxError> SyntaxErrors)
|
||||
{
|
||||
foreach (SyntaxError SyntaxError in SyntaxErrors)
|
||||
{
|
||||
Serialize(SyntaxError);
|
||||
}
|
||||
}
|
||||
}
|
43
AspClassic.Parser/EventDeclaration.cs
Normal file
43
AspClassic.Parser/EventDeclaration.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an event declaration.
|
||||
/// </summary>
|
||||
public sealed class EventDeclaration : SignatureDeclaration
|
||||
{
|
||||
private readonly NameCollection _ImplementsList;
|
||||
|
||||
/// <summary>
|
||||
/// The list of implemented members.
|
||||
/// </summary>
|
||||
public NameCollection ImplementsList => _ImplementsList;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a parse tree for an event declaration.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes for the parse tree.</param>
|
||||
/// <param name="modifiers">The modifiers for the parse tree.</param>
|
||||
/// <param name="keywordLocation">The location of the keyword.</param>
|
||||
/// <param name="name">The name of the declaration.</param>
|
||||
/// <param name="parameters">The parameters of the declaration.</param>
|
||||
/// <param name="asLocation">The location of the 'As', if any.</param>
|
||||
/// <param name="resultTypeAttributes">The attributes on the result type, if any.</param>
|
||||
/// <param name="resultType">The result type, if any.</param>
|
||||
/// <param name="implementsList">The list of implemented members.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public EventDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, SimpleName name, ParameterCollection parameters, Location asLocation, AttributeBlockCollection resultTypeAttributes, TypeName resultType, NameCollection implementsList, Span span, IList<Comment> comments)
|
||||
: base(TreeType.EventDeclaration, attributes, modifiers, keywordLocation, name, null, parameters, asLocation, resultTypeAttributes, resultType, span, comments)
|
||||
{
|
||||
SetParent(implementsList);
|
||||
_ImplementsList = implementsList;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, ImplementsList);
|
||||
}
|
||||
}
|
53
AspClassic.Parser/ExitStatement.cs
Normal file
53
AspClassic.Parser/ExitStatement.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an Exit statement.
|
||||
/// </summary>
|
||||
public sealed class ExitStatement : Statement
|
||||
{
|
||||
private readonly BlockType _ExitType;
|
||||
|
||||
private readonly Location _ExitArgumentLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The type of tree this statement exits.
|
||||
/// </summary>
|
||||
public BlockType ExitType => _ExitType;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the exit statement type.
|
||||
/// </summary>
|
||||
public Location ExitArgumentLocation => _ExitArgumentLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a parse tree for an Exit statement.
|
||||
/// </summary>
|
||||
/// <param name="exitType">The type of tree this statement exits.</param>
|
||||
/// <param name="exitArgumentLocation">The location of the exit statement type.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ExitStatement(BlockType exitType, Location exitArgumentLocation, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ExitStatement, span, comments)
|
||||
{
|
||||
switch (exitType)
|
||||
{
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("exitType");
|
||||
case BlockType.None:
|
||||
case BlockType.Do:
|
||||
case BlockType.For:
|
||||
case BlockType.While:
|
||||
case BlockType.Select:
|
||||
case BlockType.Try:
|
||||
case BlockType.Sub:
|
||||
case BlockType.Function:
|
||||
case BlockType.Property:
|
||||
_ExitType = exitType;
|
||||
_ExitArgumentLocation = exitArgumentLocation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
38
AspClassic.Parser/Expression.cs
Normal file
38
AspClassic.Parser/Expression.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
#define DEBUG
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an expression.
|
||||
/// </summary>
|
||||
public class Expression : Tree
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the expression is constant or not.
|
||||
/// </summary>
|
||||
public virtual bool IsConstant => false;
|
||||
|
||||
public override bool IsBad => base.Type == TreeType.SyntaxError;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bad expression.
|
||||
/// </summary>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <returns>A bad expression.</returns>
|
||||
public static Expression GetBadExpression(Span span)
|
||||
{
|
||||
return new Expression(span);
|
||||
}
|
||||
|
||||
protected Expression(TreeType type, Span span)
|
||||
: base(type, span)
|
||||
{
|
||||
Debug.Assert(type >= TreeType.SimpleNameExpression && type <= TreeType.GetTypeExpression);
|
||||
}
|
||||
|
||||
private Expression(Span span)
|
||||
: base(TreeType.SyntaxError, span)
|
||||
{
|
||||
}
|
||||
}
|
42
AspClassic.Parser/ExpressionBlockStatement.cs
Normal file
42
AspClassic.Parser/ExpressionBlockStatement.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
#define DEBUG
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an expression block statement.
|
||||
/// </summary>
|
||||
public abstract class ExpressionBlockStatement : BlockStatement
|
||||
{
|
||||
private readonly Expression _Expression;
|
||||
|
||||
private readonly EndBlockStatement _EndStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The expression.
|
||||
/// </summary>
|
||||
public Expression Expression => _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// The End statement for the block, if any.
|
||||
/// </summary>
|
||||
public EndBlockStatement EndStatement => _EndStatement;
|
||||
|
||||
protected ExpressionBlockStatement(TreeType type, Expression expression, StatementCollection statements, EndBlockStatement endStatement, Span span, IList<Comment> comments)
|
||||
: base(type, statements, span, comments)
|
||||
{
|
||||
Debug.Assert(type == TreeType.WithBlockStatement || type == TreeType.SyncLockBlockStatement || type == TreeType.WhileBlockStatement || type == TreeType.UsingBlockStatement);
|
||||
SetParent(expression);
|
||||
SetParent(endStatement);
|
||||
_Expression = expression;
|
||||
_EndStatement = endStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Expression);
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, EndStatement);
|
||||
}
|
||||
}
|
25
AspClassic.Parser/ExpressionCollection.cs
Normal file
25
AspClassic.Parser/ExpressionCollection.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A read-only collection of expressions.
|
||||
/// </summary>
|
||||
public sealed class ExpressionCollection : CommaDelimitedTreeCollection<Expression>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new collection of expressions.
|
||||
/// </summary>
|
||||
/// <param name="expressions">The expressions in the collection.</param>
|
||||
/// <param name="commaLocations">The locations of the commas in the collection.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public ExpressionCollection(IList<Expression> expressions, IList<Location> commaLocations, Span span)
|
||||
: base(TreeType.ExpressionCollection, expressions, commaLocations, span)
|
||||
{
|
||||
if ((expressions == null || expressions.Count == 0) && (commaLocations == null || commaLocations.Count == 0))
|
||||
{
|
||||
throw new ArgumentException("ExpressionCollection cannot be empty.");
|
||||
}
|
||||
}
|
||||
}
|
38
AspClassic.Parser/ExpressionInitializer.cs
Normal file
38
AspClassic.Parser/ExpressionInitializer.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an expression initializer.
|
||||
/// </summary>
|
||||
public sealed class ExpressionInitializer : Initializer
|
||||
{
|
||||
private readonly Expression _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// The expression.
|
||||
/// </summary>
|
||||
public Expression Expression => _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new expression initializer parse tree.
|
||||
/// </summary>
|
||||
/// <param name="expression">The expression.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public ExpressionInitializer(Expression expression, Span span)
|
||||
: base(TreeType.ExpressionInitializer, span)
|
||||
{
|
||||
if (expression == null)
|
||||
{
|
||||
throw new ArgumentNullException("expression");
|
||||
}
|
||||
SetParent(expression);
|
||||
_Expression = expression;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Expression);
|
||||
}
|
||||
}
|
38
AspClassic.Parser/ExpressionStatement.cs
Normal file
38
AspClassic.Parser/ExpressionStatement.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
#define DEBUG
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an expression statement.
|
||||
/// </summary>
|
||||
public abstract class ExpressionStatement : Statement
|
||||
{
|
||||
private readonly Expression _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// The expression.
|
||||
/// </summary>
|
||||
public Expression Expression => _Expression;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for an expression statement.
|
||||
/// </summary>
|
||||
/// <param name="type">The type of the parse tree.</param>
|
||||
/// <param name="expression">The expression.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
protected ExpressionStatement(TreeType type, Expression expression, Span span, IList<Comment> comments)
|
||||
: base(type, span, comments)
|
||||
{
|
||||
Debug.Assert(type == TreeType.ReturnStatement || type == TreeType.ErrorStatement || type == TreeType.ThrowStatement);
|
||||
SetParent(expression);
|
||||
_Expression = expression;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Expression);
|
||||
}
|
||||
}
|
41
AspClassic.Parser/ExternalChecksum.cs
Normal file
41
AspClassic.Parser/ExternalChecksum.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// An external checksum for a file.
|
||||
/// </summary>
|
||||
public sealed class ExternalChecksum
|
||||
{
|
||||
private readonly string _Filename;
|
||||
|
||||
private readonly string _Guid;
|
||||
|
||||
private readonly string _Checksum;
|
||||
|
||||
/// <summary>
|
||||
/// The filename that the checksum is for.
|
||||
/// </summary>
|
||||
public string Filename => _Filename;
|
||||
|
||||
/// <summary>
|
||||
/// The guid of the file.
|
||||
/// </summary>
|
||||
public string Guid => _Guid;
|
||||
|
||||
/// <summary>
|
||||
/// The checksum for the file.
|
||||
/// </summary>
|
||||
public string Checksum => _Checksum;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new external checksum.
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename that the checksum is for.</param>
|
||||
/// <param name="guid">The guid of the file.</param>
|
||||
/// <param name="checksum">The checksum for the file.</param>
|
||||
public ExternalChecksum(string filename, string guid, string checksum)
|
||||
{
|
||||
_Filename = filename;
|
||||
_Guid = guid;
|
||||
_Checksum = checksum;
|
||||
}
|
||||
}
|
79
AspClassic.Parser/ExternalDeclaration.cs
Normal file
79
AspClassic.Parser/ExternalDeclaration.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Declare statement.
|
||||
/// </summary>
|
||||
public abstract class ExternalDeclaration : SignatureDeclaration
|
||||
{
|
||||
private readonly Location _CharsetLocation;
|
||||
|
||||
private readonly Charset _Charset;
|
||||
|
||||
private readonly Location _SubOrFunctionLocation;
|
||||
|
||||
private readonly Location _LibLocation;
|
||||
|
||||
private readonly StringLiteralExpression _LibLiteral;
|
||||
|
||||
private readonly Location _AliasLocation;
|
||||
|
||||
private readonly StringLiteralExpression _AliasLiteral;
|
||||
|
||||
/// <summary>
|
||||
/// The location of 'Auto', 'Ansi' or 'Unicode', if any.
|
||||
/// </summary>
|
||||
public Location CharsetLocation => _CharsetLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The charset.
|
||||
/// </summary>
|
||||
public Charset Charset => _Charset;
|
||||
|
||||
/// <summary>
|
||||
/// The location of 'Sub' or 'Function'.
|
||||
/// </summary>
|
||||
public Location SubOrFunctionLocation => _SubOrFunctionLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The location of 'Lib', if any.
|
||||
/// </summary>
|
||||
public Location LibLocation => _LibLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The library, if any.
|
||||
/// </summary>
|
||||
public StringLiteralExpression LibLiteral => _LibLiteral;
|
||||
|
||||
/// <summary>
|
||||
/// The location of 'Alias', if any.
|
||||
/// </summary>
|
||||
public Location AliasLocation => _AliasLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The alias, if any.
|
||||
/// </summary>
|
||||
public StringLiteralExpression AliasLiteral => _AliasLiteral;
|
||||
|
||||
protected ExternalDeclaration(TreeType type, AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, Location charsetLocation, Charset charset, Location subOrFunctionLocation, SimpleName name, Location libLocation, StringLiteralExpression libLiteral, Location aliasLocation, StringLiteralExpression aliasLiteral, ParameterCollection parameters, Location asLocation, AttributeBlockCollection resultTypeAttributes, TypeName resultType, Span span, IList<Comment> comments)
|
||||
: base(type, attributes, modifiers, keywordLocation, name, null, parameters, asLocation, resultTypeAttributes, resultType, span, comments)
|
||||
{
|
||||
SetParent(libLiteral);
|
||||
SetParent(aliasLiteral);
|
||||
_CharsetLocation = charsetLocation;
|
||||
_Charset = charset;
|
||||
_SubOrFunctionLocation = subOrFunctionLocation;
|
||||
_LibLocation = libLocation;
|
||||
_LibLiteral = libLiteral;
|
||||
_AliasLocation = aliasLocation;
|
||||
_AliasLiteral = aliasLiteral;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, LibLiteral);
|
||||
Tree.AddChild(childList, AliasLiteral);
|
||||
}
|
||||
}
|
34
AspClassic.Parser/ExternalFunctionDeclaration.cs
Normal file
34
AspClassic.Parser/ExternalFunctionDeclaration.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Declare Function statement.
|
||||
/// </summary>
|
||||
public sealed class ExternalFunctionDeclaration : ExternalDeclaration
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a parse tree for a Declare Function statement.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes for the parse tree.</param>
|
||||
/// <param name="modifiers">The modifiers for the parse tree.</param>
|
||||
/// <param name="keywordLocation">The location of the keyword.</param>
|
||||
/// <param name="charsetLocation">The location of the 'Ansi', 'Auto' or 'Unicode', if any.</param>
|
||||
/// <param name="charset">The charset.</param>
|
||||
/// <param name="functionLocation">The location of 'Function'.</param>
|
||||
/// <param name="name">The name of the declaration.</param>
|
||||
/// <param name="libLocation">The location of 'Lib', if any.</param>
|
||||
/// <param name="libLiteral">The library, if any.</param>
|
||||
/// <param name="aliasLocation">The location of 'Alias', if any.</param>
|
||||
/// <param name="aliasLiteral">The alias, if any.</param>
|
||||
/// <param name="parameters">The parameters of the declaration.</param>
|
||||
/// <param name="asLocation">The location of the 'As', if any.</param>
|
||||
/// <param name="resultTypeAttributes">The attributes on the result type, if any.</param>
|
||||
/// <param name="resultType">The result type, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ExternalFunctionDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, Location charsetLocation, Charset charset, Location functionLocation, SimpleName name, Location libLocation, StringLiteralExpression libLiteral, Location aliasLocation, StringLiteralExpression aliasLiteral, ParameterCollection parameters, Location asLocation, AttributeBlockCollection resultTypeAttributes, TypeName resultType, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ExternalFunctionDeclaration, attributes, modifiers, keywordLocation, charsetLocation, charset, functionLocation, name, libLocation, libLiteral, aliasLocation, aliasLiteral, parameters, asLocation, resultTypeAttributes, resultType, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
50
AspClassic.Parser/ExternalLineMapping.cs
Normal file
50
AspClassic.Parser/ExternalLineMapping.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A line mapping from a source span to an external file and line.
|
||||
/// </summary>
|
||||
public sealed class ExternalLineMapping
|
||||
{
|
||||
private readonly Location _Start;
|
||||
|
||||
private readonly Location _Finish;
|
||||
|
||||
private readonly string _File;
|
||||
|
||||
private readonly long _Line;
|
||||
|
||||
/// <summary>
|
||||
/// The start location of the mapping in the source.
|
||||
/// </summary>
|
||||
public Location Start => _Start;
|
||||
|
||||
/// <summary>
|
||||
/// The end location of the mapping in the source.
|
||||
/// </summary>
|
||||
public Location Finish => _Finish;
|
||||
|
||||
/// <summary>
|
||||
/// The external file the source maps to.
|
||||
/// </summary>
|
||||
public string File => _File;
|
||||
|
||||
/// <summary>
|
||||
/// The external line number the source maps to.
|
||||
/// </summary>
|
||||
public long Line => _Line;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new external line mapping.
|
||||
/// </summary>
|
||||
/// <param name="start">The start location in the source.</param>
|
||||
/// <param name="finish">The end location in the source.</param>
|
||||
/// <param name="file">The name of the external file.</param>
|
||||
/// <param name="line">The line number in the external file.</param>
|
||||
public ExternalLineMapping(Location start, Location finish, string file, long line)
|
||||
{
|
||||
_Start = start;
|
||||
_Finish = finish;
|
||||
_File = file;
|
||||
_Line = line;
|
||||
}
|
||||
}
|
31
AspClassic.Parser/ExternalSubDeclaration.cs
Normal file
31
AspClassic.Parser/ExternalSubDeclaration.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Declare Sub statement.
|
||||
/// </summary>
|
||||
public sealed class ExternalSubDeclaration : ExternalDeclaration
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a parse tree for a Declare Sub statement.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes for the parse tree.</param>
|
||||
/// <param name="modifiers">The modifiers for the parse tree.</param>
|
||||
/// <param name="keywordLocation">The location of the keyword.</param>
|
||||
/// <param name="charsetLocation">The location of the 'Ansi', 'Auto' or 'Unicode', if any.</param>
|
||||
/// <param name="charset">The charset.</param>
|
||||
/// <param name="subLocation">The location of 'Sub'.</param>
|
||||
/// <param name="name">The name of the declaration.</param>
|
||||
/// <param name="libLocation">The location of 'Lib', if any.</param>
|
||||
/// <param name="libLiteral">The library, if any.</param>
|
||||
/// <param name="aliasLocation">The location of 'Alias', if any.</param>
|
||||
/// <param name="aliasLiteral">The alias, if any.</param>
|
||||
/// <param name="parameters">The parameters of the declaration.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ExternalSubDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, Location charsetLocation, Charset charset, Location subLocation, SimpleName name, Location libLocation, StringLiteralExpression libLiteral, Location aliasLocation, StringLiteralExpression aliasLiteral, ParameterCollection parameters, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ExternalSubDeclaration, attributes, modifiers, keywordLocation, charsetLocation, charset, subLocation, name, libLocation, libLiteral, aliasLocation, aliasLiteral, parameters, default(Location), null, null, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
33
AspClassic.Parser/File.cs
Normal file
33
AspClassic.Parser/File.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for an entire file.
|
||||
/// </summary>
|
||||
public sealed class File : Tree
|
||||
{
|
||||
private readonly DeclarationCollection _Declarations;
|
||||
|
||||
/// <summary>
|
||||
/// The declarations in the file.
|
||||
/// </summary>
|
||||
public DeclarationCollection Declarations => _Declarations;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new file parse tree.
|
||||
/// </summary>
|
||||
/// <param name="declarations">The declarations in the file.</param>
|
||||
/// <param name="span">The location of the tree.</param>
|
||||
public File(DeclarationCollection declarations, Span span)
|
||||
: base(TreeType.File, span)
|
||||
{
|
||||
SetParent(declarations);
|
||||
_Declarations = declarations;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Declarations);
|
||||
}
|
||||
}
|
41
AspClassic.Parser/FinallyBlockStatement.cs
Normal file
41
AspClassic.Parser/FinallyBlockStatement.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Finally block statement.
|
||||
/// </summary>
|
||||
public sealed class FinallyBlockStatement : BlockStatement
|
||||
{
|
||||
private readonly FinallyStatement _FinallyStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The Finally statement.
|
||||
/// </summary>
|
||||
public FinallyStatement FinallyStatement => _FinallyStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a Finally block statement.
|
||||
/// </summary>
|
||||
/// <param name="finallyStatement">The Finally statement.</param>
|
||||
/// <param name="statements">The statements in the block.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public FinallyBlockStatement(FinallyStatement finallyStatement, StatementCollection statements, Span span, IList<Comment> comments)
|
||||
: base(TreeType.FinallyBlockStatement, statements, span, comments)
|
||||
{
|
||||
if (finallyStatement == null)
|
||||
{
|
||||
throw new ArgumentNullException("finallyStatement");
|
||||
}
|
||||
SetParent(finallyStatement);
|
||||
_FinallyStatement = finallyStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, FinallyStatement);
|
||||
base.GetChildTrees(childList);
|
||||
}
|
||||
}
|
19
AspClassic.Parser/FinallyStatement.cs
Normal file
19
AspClassic.Parser/FinallyStatement.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Finally statement.
|
||||
/// </summary>
|
||||
public sealed class FinallyStatement : Statement
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a Finally statement.
|
||||
/// </summary>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public FinallyStatement(Span span, IList<Comment> comments)
|
||||
: base(TreeType.FinallyStatement, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
42
AspClassic.Parser/FloatingPointLiteralExpression.cs
Normal file
42
AspClassic.Parser/FloatingPointLiteralExpression.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a floating point literal.
|
||||
/// </summary>
|
||||
public sealed class FloatingPointLiteralExpression : LiteralExpression
|
||||
{
|
||||
private readonly double _Literal;
|
||||
|
||||
private readonly TypeCharacter _TypeCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// The literal value.
|
||||
/// </summary>
|
||||
public double Literal => _Literal;
|
||||
|
||||
public override object Value => _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// The type character on the literal value.
|
||||
/// </summary>
|
||||
public TypeCharacter TypeCharacter => _TypeCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a floating point literal.
|
||||
/// </summary>
|
||||
/// <param name="literal">The literal value.</param>
|
||||
/// <param name="typeCharacter">The type character on the literal.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public FloatingPointLiteralExpression(double literal, TypeCharacter typeCharacter, Span span)
|
||||
: base(TreeType.FloatingPointLiteralExpression, span)
|
||||
{
|
||||
if (typeCharacter != 0 && typeCharacter != TypeCharacter.SingleSymbol && typeCharacter != TypeCharacter.SingleChar && typeCharacter != TypeCharacter.DoubleSymbol && typeCharacter != TypeCharacter.DoubleChar)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("typeCharacter");
|
||||
}
|
||||
_Literal = literal;
|
||||
_TypeCharacter = typeCharacter;
|
||||
}
|
||||
}
|
40
AspClassic.Parser/FloatingPointLiteralToken.cs
Normal file
40
AspClassic.Parser/FloatingPointLiteralToken.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A floating point literal.
|
||||
/// </summary>
|
||||
public sealed class FloatingPointLiteralToken : Token
|
||||
{
|
||||
private readonly double _Literal;
|
||||
|
||||
private readonly TypeCharacter _TypeCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// The value of the literal.
|
||||
/// </summary>
|
||||
public double Literal => _Literal;
|
||||
|
||||
/// <summary>
|
||||
/// The type character after the literal.
|
||||
/// </summary>
|
||||
public TypeCharacter TypeCharacter => _TypeCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new floating point literal token.
|
||||
/// </summary>
|
||||
/// <param name="literal">The literal value.</param>
|
||||
/// <param name="typeCharacter">The type character of the literal.</param>
|
||||
/// <param name="span">The location of the literal.</param>
|
||||
public FloatingPointLiteralToken(double literal, TypeCharacter typeCharacter, Span span)
|
||||
: base(TokenType.FloatingPointLiteral, span)
|
||||
{
|
||||
if (typeCharacter != 0 && typeCharacter != TypeCharacter.SingleSymbol && typeCharacter != TypeCharacter.SingleChar && typeCharacter != TypeCharacter.DoubleSymbol && typeCharacter != TypeCharacter.DoubleChar)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("typeCharacter");
|
||||
}
|
||||
_Literal = literal;
|
||||
_TypeCharacter = typeCharacter;
|
||||
}
|
||||
}
|
123
AspClassic.Parser/ForBlockStatement.cs
Normal file
123
AspClassic.Parser/ForBlockStatement.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a For statement.
|
||||
/// </summary>
|
||||
public sealed class ForBlockStatement : BlockStatement
|
||||
{
|
||||
private readonly Expression _ControlExpression;
|
||||
|
||||
private readonly VariableDeclarator _ControlVariableDeclarator;
|
||||
|
||||
private readonly Location _EqualsLocation;
|
||||
|
||||
private readonly Expression _LowerBoundExpression;
|
||||
|
||||
private readonly Location _ToLocation;
|
||||
|
||||
private readonly Expression _UpperBoundExpression;
|
||||
|
||||
private readonly Location _StepLocation;
|
||||
|
||||
private readonly Expression _StepExpression;
|
||||
|
||||
private readonly NextStatement _NextStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The control expression for the loop.
|
||||
/// </summary>
|
||||
public Expression ControlExpression => _ControlExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The control variable declarator, if any.
|
||||
/// </summary>
|
||||
public VariableDeclarator ControlVariableDeclarator => _ControlVariableDeclarator;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the '='.
|
||||
/// </summary>
|
||||
public Location EqualsLocation => _EqualsLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The lower bound of the loop.
|
||||
/// </summary>
|
||||
public Expression LowerBoundExpression => _LowerBoundExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'To'.
|
||||
/// </summary>
|
||||
public Location ToLocation => _ToLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The upper bound of the loop.
|
||||
/// </summary>
|
||||
public Expression UpperBoundExpression => _UpperBoundExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'Step', if any.
|
||||
/// </summary>
|
||||
public Location StepLocation => _StepLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The step of the loop, if any.
|
||||
/// </summary>
|
||||
public Expression StepExpression => _StepExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The Next statement, if any.
|
||||
/// </summary>
|
||||
public NextStatement NextStatement => _NextStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a For statement.
|
||||
/// </summary>
|
||||
/// <param name="controlExpression">The control expression for the loop.</param>
|
||||
/// <param name="controlVariableDeclarator">The control variable declarator, if any.</param>
|
||||
/// <param name="equalsLocation">The location of the '='.</param>
|
||||
/// <param name="lowerBoundExpression">The lower bound of the loop.</param>
|
||||
/// <param name="toLocation">The location of the 'To'.</param>
|
||||
/// <param name="upperBoundExpression">The upper bound of the loop.</param>
|
||||
/// <param name="stepLocation">The location of the 'Step', if any.</param>
|
||||
/// <param name="stepExpression">The step of the loop, if any.</param>
|
||||
/// <param name="statements">The statements in the For loop.</param>
|
||||
/// <param name="nextStatement">The Next statement, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ForBlockStatement(Expression controlExpression, VariableDeclarator controlVariableDeclarator, Location equalsLocation, Expression lowerBoundExpression, Location toLocation, Expression upperBoundExpression, Location stepLocation, Expression stepExpression, StatementCollection statements, NextStatement nextStatement, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ForBlockStatement, statements, span, comments)
|
||||
{
|
||||
if (controlExpression == null)
|
||||
{
|
||||
throw new ArgumentNullException("controlExpression");
|
||||
}
|
||||
SetParent(controlExpression);
|
||||
SetParent(controlVariableDeclarator);
|
||||
SetParent(lowerBoundExpression);
|
||||
SetParent(upperBoundExpression);
|
||||
SetParent(stepExpression);
|
||||
SetParent(nextStatement);
|
||||
_ControlExpression = controlExpression;
|
||||
_ControlVariableDeclarator = controlVariableDeclarator;
|
||||
_EqualsLocation = equalsLocation;
|
||||
_LowerBoundExpression = lowerBoundExpression;
|
||||
_ToLocation = toLocation;
|
||||
_UpperBoundExpression = upperBoundExpression;
|
||||
_StepLocation = stepLocation;
|
||||
_StepExpression = stepExpression;
|
||||
_NextStatement = nextStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, ControlExpression);
|
||||
Tree.AddChild(childList, ControlVariableDeclarator);
|
||||
Tree.AddChild(childList, LowerBoundExpression);
|
||||
Tree.AddChild(childList, UpperBoundExpression);
|
||||
Tree.AddChild(childList, StepExpression);
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, NextStatement);
|
||||
}
|
||||
}
|
92
AspClassic.Parser/ForEachBlockStatement.cs
Normal file
92
AspClassic.Parser/ForEachBlockStatement.cs
Normal file
|
@ -0,0 +1,92 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a For Each statement.
|
||||
/// </summary>
|
||||
public sealed class ForEachBlockStatement : BlockStatement
|
||||
{
|
||||
private readonly Location _EachLocation;
|
||||
|
||||
private readonly Expression _ControlExpression;
|
||||
|
||||
private readonly VariableDeclarator _ControlVariableDeclarator;
|
||||
|
||||
private readonly Location _InLocation;
|
||||
|
||||
private readonly Expression _CollectionExpression;
|
||||
|
||||
private readonly NextStatement _NextStatement;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'Each'.
|
||||
/// </summary>
|
||||
public Location EachLocation => _EachLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The control expression.
|
||||
/// </summary>
|
||||
public Expression ControlExpression => _ControlExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The control variable declarator, if any.
|
||||
/// </summary>
|
||||
public VariableDeclarator ControlVariableDeclarator => _ControlVariableDeclarator;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the 'In'.
|
||||
/// </summary>
|
||||
public Location InLocation => _InLocation;
|
||||
|
||||
/// <summary>
|
||||
/// The collection expression.
|
||||
/// </summary>
|
||||
public Expression CollectionExpression => _CollectionExpression;
|
||||
|
||||
/// <summary>
|
||||
/// The Next statement, if any.
|
||||
/// </summary>
|
||||
public NextStatement NextStatement => _NextStatement;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a For Each statement.
|
||||
/// </summary>
|
||||
/// <param name="eachLocation">The location of the 'Each'.</param>
|
||||
/// <param name="controlExpression">The control expression.</param>
|
||||
/// <param name="controlVariableDeclarator">The control variable declarator, if any.</param>
|
||||
/// <param name="inLocation">The location of the 'In'.</param>
|
||||
/// <param name="collectionExpression">The collection expression.</param>
|
||||
/// <param name="statements">The statements in the block.</param>
|
||||
/// <param name="nextStatement">The Next statement, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public ForEachBlockStatement(Location eachLocation, Expression controlExpression, VariableDeclarator controlVariableDeclarator, Location inLocation, Expression collectionExpression, StatementCollection statements, NextStatement nextStatement, Span span, IList<Comment> comments)
|
||||
: base(TreeType.ForEachBlockStatement, statements, span, comments)
|
||||
{
|
||||
if (controlExpression == null)
|
||||
{
|
||||
throw new ArgumentNullException("controlExpression");
|
||||
}
|
||||
SetParent(controlExpression);
|
||||
SetParent(controlVariableDeclarator);
|
||||
SetParent(collectionExpression);
|
||||
SetParent(nextStatement);
|
||||
_EachLocation = eachLocation;
|
||||
_ControlExpression = controlExpression;
|
||||
_ControlVariableDeclarator = controlVariableDeclarator;
|
||||
_InLocation = inLocation;
|
||||
_CollectionExpression = collectionExpression;
|
||||
_NextStatement = nextStatement;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, ControlExpression);
|
||||
Tree.AddChild(childList, ControlVariableDeclarator);
|
||||
Tree.AddChild(childList, CollectionExpression);
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, NextStatement);
|
||||
}
|
||||
}
|
32
AspClassic.Parser/FunctionDeclaration.cs
Normal file
32
AspClassic.Parser/FunctionDeclaration.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a Function declaration.
|
||||
/// </summary>
|
||||
public sealed class FunctionDeclaration : MethodDeclaration
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new parse tree for a Function declaration.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The attributes for the parse tree.</param>
|
||||
/// <param name="modifiers">The modifiers for the parse tree.</param>
|
||||
/// <param name="keywordLocation">The location of the keyword.</param>
|
||||
/// <param name="name">The name of the declaration.</param>
|
||||
/// <param name="typeParameters">The type parameters on the declaration, if any.</param>
|
||||
/// <param name="parameters">The parameters of the declaration.</param>
|
||||
/// <param name="asLocation">The location of the 'As', if any.</param>
|
||||
/// <param name="resultTypeAttributes">The attributes on the result type, if any.</param>
|
||||
/// <param name="resultType">The result type, if any.</param>
|
||||
/// <param name="implementsList">The list of implemented members.</param>
|
||||
/// <param name="handlesList">The list of handled events.</param>
|
||||
/// <param name="statements">The statements in the declaration.</param>
|
||||
/// <param name="endDeclaration">The end block declaration, if any.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
/// <param name="comments">The comments for the parse tree.</param>
|
||||
public FunctionDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, SimpleName name, TypeParameterCollection typeParameters, ParameterCollection parameters, Location asLocation, AttributeBlockCollection resultTypeAttributes, TypeName resultType, NameCollection implementsList, NameCollection handlesList, StatementCollection statements, EndBlockDeclaration endDeclaration, Span span, IList<Comment> comments)
|
||||
: base(TreeType.FunctionDeclaration, attributes, modifiers, keywordLocation, name, typeParameters, parameters, asLocation, resultTypeAttributes, resultType, implementsList, handlesList, statements, endDeclaration, span, comments)
|
||||
{
|
||||
}
|
||||
}
|
32
AspClassic.Parser/GenericBlockDeclaration.cs
Normal file
32
AspClassic.Parser/GenericBlockDeclaration.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
#define DEBUG
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a possibly generic block declaration.
|
||||
/// </summary>
|
||||
public abstract class GenericBlockDeclaration : BlockDeclaration
|
||||
{
|
||||
private readonly TypeParameterCollection _TypeParameters;
|
||||
|
||||
/// <summary>
|
||||
/// The type parameters of the type, if any.
|
||||
/// </summary>
|
||||
public TypeParameterCollection TypeParameters => _TypeParameters;
|
||||
|
||||
protected GenericBlockDeclaration(TreeType type, AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, SimpleName name, TypeParameterCollection typeParameters, DeclarationCollection declarations, EndBlockDeclaration endStatement, Span span, IList<Comment> comments)
|
||||
: base(type, attributes, modifiers, keywordLocation, name, declarations, endStatement, span, comments)
|
||||
{
|
||||
Debug.Assert(type == TreeType.ClassDeclaration || type == TreeType.InterfaceDeclaration || type == TreeType.StructureDeclaration);
|
||||
SetParent(typeParameters);
|
||||
_TypeParameters = typeParameters;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
base.GetChildTrees(childList);
|
||||
Tree.AddChild(childList, TypeParameters);
|
||||
}
|
||||
}
|
53
AspClassic.Parser/GenericQualifiedExpression.cs
Normal file
53
AspClassic.Parser/GenericQualifiedExpression.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A parse tree for a qualified name expression.
|
||||
/// </summary>
|
||||
public sealed class GenericQualifiedExpression : Expression
|
||||
{
|
||||
private readonly Expression _Base;
|
||||
|
||||
private readonly TypeArgumentCollection _TypeArguments;
|
||||
|
||||
/// <summary>
|
||||
/// The base expression.
|
||||
/// </summary>
|
||||
public Expression Base => _Base;
|
||||
|
||||
/// <summary>
|
||||
/// The qualifying type arguments.
|
||||
/// </summary>
|
||||
public TypeArgumentCollection TypeArguments => _TypeArguments;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new parse tree for a generic qualified expression.
|
||||
/// </summary>
|
||||
/// <param name="base">The base expression.</param>
|
||||
/// <param name="typeArguments">The qualifying type arguments.</param>
|
||||
/// <param name="span">The location of the parse tree.</param>
|
||||
public GenericQualifiedExpression(Expression @base, TypeArgumentCollection typeArguments, Span span)
|
||||
: base(TreeType.GenericQualifiedExpression, span)
|
||||
{
|
||||
if (@base == null)
|
||||
{
|
||||
throw new ArgumentNullException("base");
|
||||
}
|
||||
if (typeArguments == null)
|
||||
{
|
||||
throw new ArgumentNullException("typeArguments");
|
||||
}
|
||||
SetParent(@base);
|
||||
SetParent(typeArguments);
|
||||
_Base = @base;
|
||||
_TypeArguments = typeArguments;
|
||||
}
|
||||
|
||||
protected override void GetChildTrees(IList<Tree> childList)
|
||||
{
|
||||
Tree.AddChild(childList, Base);
|
||||
Tree.AddChild(childList, TypeArguments);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue