1using System.Collections.Generic;
24 return context.InputNode.Name ==
"bs:function";
34 return value.EndsWith(
"?") || value.EndsWith(
"?!");
44 return value.EndsWith(
"!") || value.EndsWith(
"!?");
54 return value.EndsWith(
"*");
66 string name = attribute.Value;
68 while (name.EndsWith(
"*") || name.EndsWith(
"?") || name.EndsWith(
"!"))
70 name = name.Remove(name.Length - 1);
73 if (
string.IsNullOrEmpty(name))
80 if (expressions.Length != 1)
84 $
"Invalid parameter type expression for parameter {attribute.Name} in 'bs:function' node",
89 return expressions[0];
95 HtmlAttribute? nameAttribute = context.
InputNode.Attributes[
"name"];
97 if (nameAttribute ==
null)
101 "Missing 'name' attribute in 'bs:function' node",
106 if (
string.IsNullOrEmpty(nameAttribute.Value))
110 "Empty 'name' attribute in 'bs:function' node",
115 IEnumerable<HtmlAttribute> parameterAttributes =
116 context.
InputNode.Attributes.Where(x => x.Name.StartsWith(
"param:"));
120 x.Name.Remove(0,
"param:".Length),
131 (ctx, args) =>
InvokeFunction(nameAttribute.Value, context, parameters, ctx, args),
170 HtmlDocument outputDocument =
new HtmlDocument();
171 outputDocument.OptionUseIdAttribute =
true;
172 outputDocument.LoadHtml(
"");
181 foreach (HtmlNode? child
in context.InputNode.ChildNodes)
185 outputDocument.DocumentNode,
195 return outputDocument.DocumentNode.InnerHtml;
Implements the Html Context for the Transformation Process.
BadSourcePosition CreateAttributePosition(HtmlAttribute attribute)
Creates the Source Position of the specified Attribute.
BadSourcePosition CreateOuterPosition()
Creates the Source Position of the current Input Nodes Outer Content.
readonly HtmlNode InputNode
The Current Input Node.
readonly BadExecutionContext ExecutionContext
The Execution Context that is used to evaluate badscript code.
BadExpression[] Parse(string code, BadSourcePosition pos)
Parses the specified code and returns the expressions with their positions set to the specified posit...
Base Implementation for all Expressions used inside the Script.
The Execution Context. Every execution of a script needs a context the script is running in....
BadScope Scope
The Root Scope of the Context.
BadScope CreateChild(string name, BadScope? caller, bool? useVisibility, BadScopeFlags flags=BadScopeFlags.RootScope)
Creates a subscope of the current scope.
void DefineVariable(string name, BadObject value, BadScope? caller=null, BadPropertyInfo? info=null, BadObject[]? attributes=null)
Defines a new Variable in the current scope.
Gets thrown by the runtime.
static BadRuntimeException Create(BadScope? scope, string message)
Creates a new BadScriptException.
Interop Function taking an array of arguments.
The Base Class for all BadScript Objects.
Stores Meta Information about a Property.
Implements a function that can be called from the script.
static void ApplyParameters(string funcStr, BadFunctionParameter[] parameters, BadExecutionContext context, BadObject[] args, BadSourcePosition? position=null)
Applies the function arguments to the context of the function.
string GetHeader()
Returns the Header of the function.
override BadClassPrototype GetPrototype()
Provides function parameter info.
Helper Class that Builds a Native Class from a Prototype.
static BadClassPrototype GetNative(string name)
Returns a Native Class Prototype for the given Native Type.
Contains the Expressions for the BadScript2 Language.
Contains the Error Objects for the BadScript2 Language.
Contains the Interop Function Classes for the BadScript2 Language.
Contains Runtime Function Objects.
Contains Runtime Type Objects.
Contains the Runtime Objects.
Contains the Runtime Implementation.
BadScopeFlags
Defines Different Behaviours for the Current Scope.