SceneLang interpreter API
Documentation of SceneLang interpreter.
Contents
Public API
Raytracer.Interpreter
— ModuleRaytracer.Interpreter
SceneLang interpreter module.
Raytracer.Interpreter.TokenValue
— TypeTokenValue
Union of all types that can be used as token values while interpreting a SceneLang script.
Types
Raytracer.Interpreter.Identifier
— TypeIdentifier
Type wrapping a Symbol
representing an identifier in a SceneLang script.
Fields
value::Symbol
: the value of the token
Raytracer.Interpreter.InputStream
— TypeInputStream
Type wrapping the IO
from the source code of a SceneLang script.
Fields
stream::IO
: IO stream from the source codelocation::SourceLocation
: aSourceLocation
that keeps track of the reading position in the source filesaved_char::Union{Char, Nothing}
: stores a character fromunread_char!
or nothingsaved_location::SourceLocation
: aSourceLocation
storing the previous reading positionsaved_token::Union{Token, Nothing}
: stores an unreadedToken
tabulations::Int
: how many columns a<tab>
character is worth
Raytracer.Interpreter.InterpreterException
— TypeInterpreterException <: Exception
Abstract type for all SceneLang interpreter errors.
See also: BadCharacter
, UnfinishedExpression
, UndefinedIdentifier
, WrongTokenType
, WrongValueType
, InvalidKeyword
, InvalidType
, InvalidCommand
, InvalidExpression
, InvalidSymbol
, InvalidNumber
, InvalidSize
, InvalidFilePath
, IdentifierRedefinition
SettingRedefinition
UndefinedSetting
Raytracer.Interpreter.Keyword
— TypeKeyword
Type wrapping a Symbol
representing a command or type in a SceneLang script.
Fields
value::Symbol
: the value of the token
Raytracer.Interpreter.LiteralNumber
— TypeLiteralNumber
Type wrapping a Float32
representing a floating-point number in a SceneLang script.
Fields
value::Float32
: the value of the token
Raytracer.Interpreter.LiteralString
— TypeLiteralString
Type wrapping a String
representing a literal string in a SceneLang script.
Fields
value::String
: the value of the token
Raytracer.Interpreter.LiteralSymbol
— TypeLiteralSymbol
Type wrapping a Symbol
representing a symbol in a SceneLang script.
Fields
value::Symbol
: the value of the token
Raytracer.Interpreter.MathExpression
— TypeMathExpression
Type wrapping a Expr
representing a mathematical expression in a SceneLang script.
Fields
value::Expr
: the value of the token
Raytracer.Interpreter.Scene
— TypeScene
A mutable struct containing all the significant elements of a renderable scene and all the declared variables of the SceneLang script.
Fields
variables::
IdTable
: stores all the variables declared in the scriptworld::
World
: stores all the spawnedShape
slights::
Lights
: stores all the spawnedPointLight
simage::
ImageOrNot
: stores either theHdrImage
to impress ornothing
camera::
CameraOrNot
: stores either theCamera
ornothing
renderer::
RendererOrNot
: stores either theRendererSettings
for theRenderer
ornothing
tracer::
TracerOrNot
: strores either theTracerSettings
for theImageTracer
ornothing
time::Float32
: stores the animation time
Raytracer.Interpreter.Scene
— MethodScene(variables::Vector{Pair{Type{<:TokenValue}, Vector{Pair{Symbol, Token}}}};
world::World = World(),
lights::Lights = Lights(),
image::ImageOrNot = nothing,
camera::CameraOrNot = nothing,
renderer::RendererOrNot = nothing,
tracer::TracerOrNot = nothing,
time = 0f0)
Constructor for a Scene
instance.
Slightly more convenient than the default constructor to manually construct in a Julia code.
Raytracer.Interpreter.Scene
— MethodScene(; variables::IdTable = IdTable(),
world::World = World(),
lights::Lights = Lights(),
image::ImageOrNot = nothing,
camera::CameraOrNot = nothing,
renderer::RendererOrNot = nothing,
tracer::TracerOrNot = nothing,
time::Float32 = 0f0)
Constructor for a Scene
instance.
Raytracer.Interpreter.SourceLocation
— TypeSourceLocation
Represents a position in a file at a certain line and column.
Fields
file_name::String
: the input file nameline_num::Int
: line positioncol_num::Int
: column position
Raytracer.Interpreter.SourceLocation
— MethodSourceLocation(file_name::String, line_num::Int, col_num::Int)
Constructor for a SourceLocation
instance.
Raytracer.Interpreter.SourceLocation
— MethodSourceLocation(; file_name::String = "", line_num::Int = 1, col_num::Int = 0)
Constructor for a SourceLocation
instance.
Raytracer.Interpreter.StopToken
— TypeStopToken
Convenience empty type to help identify the end of a SceneLang script.
Fields
value::Nothing
: the value of the token
Raytracer.Interpreter.Token
— TypeToken{T <: TokenValue}
Type representing a language token of a SceneLang script.
Fields
loc::SourceLocation
: aSourceLocation
representing the position in the script at which the token starts,value::T
: aTokenValue
representing the value of the token (seeTokenValue
)length::Int
: length of the input token.
Raytracer.Interpreter.open_stream
— Methodopen_stream(f::Function, file_name::String; tabulations::Int = 8)
Open read-only a file named file_name
as an InputStream
and apply f
to it.
Raytracer.Interpreter.parse_scene
— Functionparse_scene(stream::InputStream, scene::Scene = Scene())
Return the Scene
instance resulting parsing the SceneLang script associated with the given InputStream
.
Raytracer.Interpreter.parse_variables_from_string
— Methodparse_variables_from_string(str::AbstractString; table::IdTable = IdTable()) -> IdTable
Parse a string containing comma separated identifier-constructor pairs and return the resulting IdTable
.
Private API
Raytracer.Interpreter.CameraOrNot
— TypeRaytracer.Interpreter.IdTableKey
— TypeIdTableKey
Alias for Union{Type{<:TokenValue}, LiteralType}
. Used as the key type for IdTable
.
Raytracer.Interpreter.ImageOrNot
— TypeRaytracer.Interpreter.RendererOrNot
— TypeRaytracer.Interpreter.TracerOrNot
— TypeRaytracer.Interpreter.valid_operations
— Constantvalid_operations
A dictionary storing the operation Symbol
and a function ::Int -> ::Bool
that return true when the number of arguments is under a threshold.
For example the pair :+ => ( ::Int) -> true
indicates that the operation +
is valid with any number of arguments, while the pair :floor => (n::Int) -> n == 1
indicates that the operation floor
is valid only if it has one argument.
See also: Raytracer.isvalid
Raytracer.Interpreter.BadCharacter
— TypeBadCharacter <: InterpreterException
There is an invalid character in the SceneLang script.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.BadCharacter
— MethodBadCharacter(location::SourceLocation, msg::AbstractString)
Construct an instance of BadCharacter
with len = 1
.
Raytracer.Interpreter.Command
— TypeCommand
Enum type listing all commands of SceneLang.
Instances
Raytracer.Interpreter.USING
Raytracer.Interpreter.SET
Raytracer.Interpreter.UNSET
Raytracer.Interpreter.SPAWN
Raytracer.Interpreter.DUMP
Raytracer.Interpreter.LOAD
Raytracer.Interpreter.ROTATE
Raytracer.Interpreter.TRANSLATE
Raytracer.Interpreter.SCALE
Raytracer.Interpreter.UNITE
Raytracer.Interpreter.INTERSECT
Raytracer.Interpreter.DIFF
Raytracer.Interpreter.FUSE
Raytracer.Interpreter.TIME
Raytracer.Interpreter.IdTable
— TypeIdTable
Alias to Dict{IdTableKey, Dict{Symbol, ValueLoc}}
.
Dictionary with all the variables set in a SceneLang script. Keys represent the equivalent TokenValue
or LiteralType
type to the Julia type stored in ValueLoc
.
Raytracer.Interpreter.IdentifierRedefinition
— TypeIdentifierRedefinition <: InterpreterException
An identifier is being redefined without being unset first.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.IdentifierRedefinition
— MethodIdentifierRedefinition(location::SourceLocation, msg::AbstractString)
Construct an instance of IdentifierRedefinition
with len = 1
.
Raytracer.Interpreter.InvalidCommand
— TypeInvalidCommand <: InterpreterException
The given command does not exist.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.InvalidCommand
— MethodInvalidCommand(location::SourceLocation, msg::AbstractString)
Construct an instance of InvalidCommand
with len = 1
.
Raytracer.Interpreter.InvalidExpression
— TypeInvalidExpression <: InterpreterException
The given expression contains invalid elements. Capabilities are restrained to contain malicious code injection.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.InvalidExpression
— MethodInvalidExpression(location::SourceLocation, msg::AbstractString)
Construct an instance of InvalidExpression
with len = 1
.
Raytracer.Interpreter.InvalidFilePath
— TypeInvalidFilePath <: InterpreterException
The given file path is invalid.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.InvalidFilePath
— MethodInvalidFilePath(location::SourceLocation, msg::AbstractString)
Construct an instance of InvalidFilePath
with len = 1
.
Raytracer.Interpreter.InvalidKeyword
— TypeInvalidKeyword <: InterpreterException
The given keyword is not valid in the given context.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.InvalidKeyword
— MethodInvalidKeyword(location::SourceLocation, msg::AbstractString)
Construct an instance of InvalidKeyword
with len = 1
.
Raytracer.Interpreter.InvalidNumber
— TypeInvalidNumber <: InterpreterException
The token has an invalid numerical format.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.InvalidNumber
— MethodInvalidNumber(location::SourceLocation, msg::AbstractString)
Construct an instance of InvalidNumber
with len = 1
.
Raytracer.Interpreter.InvalidSize
— TypeInvalidSize <: InterpreterException
The given collection has an invalid size in the given context.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.InvalidSize
— MethodInvalidSize(location::SourceLocation, msg::AbstractString)
Construct an instance of InvalidSize
with len = 1
.
Raytracer.Interpreter.InvalidSymbol
— TypeInvalidSymbol <: InterpreterException
The given symbol is not valid in the given context.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.InvalidSymbol
— MethodInvalidSymbol(location::SourceLocation, msg::AbstractString)
Construct an instance of InvalidSymbol
with len = 1
.
Raytracer.Interpreter.InvalidType
— TypeInvalidType <: InterpreterException
The given type does not exist.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.InvalidType
— MethodInvalidType(location::SourceLocation, msg::AbstractString)
Construct an instance of InvalidType
with len = 1
.
Raytracer.Interpreter.LiteralType
— TypeLiteralType
Enum type listing all main types of SceneLang.
Instances
Raytracer.Interpreter.ColorType
Raytracer.Interpreter.PointType
Raytracer.Interpreter.ListType
Raytracer.Interpreter.TransformationType
Raytracer.Interpreter.MaterialType
Raytracer.Interpreter.BrdfType
Raytracer.Interpreter.PigmentType
Raytracer.Interpreter.ShapeType
Raytracer.Interpreter.LightType
Raytracer.Interpreter.ImageType
Raytracer.Interpreter.RendererType
Raytracer.Interpreter.CameraType
Raytracer.Interpreter.PcgType
Raytracer.Interpreter.TracerType
Raytracer.Interpreter.RendererSettings
— TypeRendererSettings
Struct containing a renderer type and a NamedTuple
of the named arguments needed for its construction.
Since a Renderer
type cannot be directly stored into a Scene
due to it needing at least the World
argument, we can use this struct to store everything else, ready to be constructed.
Raytracer.Interpreter.SettingRedefinition
— TypeSettingRedefinition <: InterpreterException
A rendering setting is being defined multiple times.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.SettingRedefinition
— MethodSettingRedefinition(location::SourceLocation, msg::AbstractString)
Construct an instance of SettingRedefinition
with len = 1
.
Raytracer.Interpreter.TracerSettings
— TypeTracerSettings
Struct containing a NamedTuple
of the named arguments needed to construct an ImageTracer
.
Since a ImageTracer
type cannot be directly stored into a Scene
due to it needing at least the Camera
and HdrImage
arguments, we can use this struct to store everything else, ready to be constructed.
Raytracer.Interpreter.UndefinedIdentifier
— TypeUndefinedIdentifier <: InterpreterException
The given identifier has not been defined in the script.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.UndefinedIdentifier
— MethodUndefinedIdentifier(location::SourceLocation, msg::AbstractString)
Construct an instance of UndefinedIdentifier
with len = 1
.
Raytracer.Interpreter.UndefinedSetting
— TypeUndefinedSetting <: InterpreterException
One or more necessary rendering settings have not been set up in the SceneLang script.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.UndefinedSetting
— MethodUndefinedSetting(location::SourceLocation, msg::AbstractString)
Construct an instance of UndefinedSetting
with len = 1
.
Raytracer.Interpreter.UnfinishedExpression
— TypeUnfinishedExpression <: InterpreterException
A special environment (e.g. a string, mathematical expression, list...) has been opened and not closed.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.UnfinishedExpression
— MethodUnfinishedExpression(location::SourceLocation, msg::AbstractString)
Construct an instance of UnfinishedExpression
with len = 1
.
Raytracer.Interpreter.ValueLoc
— TypeValueLoc
Stores a Julia value and the source location of its declaration.
Raytracer.Interpreter.WrongTokenType
— TypeWrongTokenType <: InterpreterException
The given value is of a different type than expected by the syntax.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.WrongTokenType
— MethodWrongTokenType(location::SourceLocation, msg::AbstractString)
Construct an instance of WrongTokenType
with len = 1
.
Raytracer.Interpreter.WrongValueType
— TypeWrongValueType <: InterpreterException
The given value has a different type than expected by the syntax.
See also: InterpreterException
Fields
location::SourceLocation
: location of the errormsg::AbstractString
: descriptive error messagelen::Int
: how many characters are involved in the error
Raytracer.Interpreter.WrongValueType
— MethodWrongValueType(location::SourceLocation, msg::AbstractString)
Construct an instance of WrongValueType
with len = 1
.
Base.eof
— Methodeof(stream::InputStream)
Check if the stream has reached the end-of-file.
Base.isvalid
— MethodRaytracer.isvalid(expr::Expr, str_len::Int, token_location::SourceLocation)
Return true
if the given expression is valid in a SceneLang script, else throw an appropriate exception using str_len
and token_location
.
See also: valid_operations
Raytracer.Interpreter._parse_command_or_type_token
— Method_parse_command_or_type_token(stream::InputStream, first_char::Char, token_location::SourceLocation)
Parse the stream into a Token
with Command
or LiteralType
value.
Raytracer.Interpreter._parse_identifier_token
— Method_parse_identifier_token(stream::InputStream, first_char::Char, token_location::SourceLocation)
Parse the stream into a Token
with Identifier
value.
Raytracer.Interpreter._parse_keyword_token
— Method_parse_keyword_token(stream::InputStream, first_char::Char, token_location::SourceLocation)
Raytracer.Interpreter._parse_math_expression_token
— Method_parse_math_expression_token(stream::InputStream, token_location::SourceLocation)
Parse the stream into a Token
with MathExpression
value.
Raytracer.Interpreter._parse_number_token
— Method_parse_number_token(stream::InputStream, first_char::Char, token_location::SourceLocation)
Parse the stream into a Token
with LiteralNumber
value.
Raytracer.Interpreter._parse_string_token
— Method_parse_string_token(stream::InputStream, token_location::SourceLocation)
Parse the stream into a Token
with LiteralString
value.
Raytracer.Interpreter._update_pos!
— Method_update_pos!(stream::InputStream, ch::Union{Char, Nothing})
Update stream.location
after having read ch
from the stream.
Raytracer.Interpreter.evaluate_math_expression
— Methodevaluate_math_expression(token::Token{MathExpression}, scene::Scene)
Replace all identifiers in the mathematical expression stored in the MathExpression
token and then evaluate it.
Raytracer.Interpreter.expect_command
— Methodexpect_command(stream::InputStream, command::Command)
Read a token from an InputStream
and check that it is a given Command
.
Raytracer.Interpreter.expect_command
— Methodexpect_command(stream::InputStream, commands::Union{NTuple{N, Command} where {N}, AbstractVector{Command}})
Read a token from an InputStream
and check that it is a Command
in the given commands
.
Raytracer.Interpreter.expect_command
— Methodexpect_command(stream::InputStream)
Read a token from an InputStream
and check that it is a Command
.
Raytracer.Interpreter.expect_identifier
— Methodexpect_identifier(stream::InputStream)
Read a token from an InputStream
and check that it is an Identifier
.
Raytracer.Interpreter.expect_keyword
— Methodexpect_keyword(stream::InputStream, keyword::Symbol)
Read a token from an InputStream
and check that it is a given Keyword
.
Raytracer.Interpreter.expect_keyword
— Methodexpect_keyword(stream::InputStream, keywords_list::Union{NTuple{N, Symbol} where {N}, AbstractVector{Symbol}})
Read a token from an InputStream
and check that it is a Keyword
in keywords_list
.
Raytracer.Interpreter.expect_number
— Methodexpect_number(stream::InputStream, scene::Scene)
Read a token from an InputStream
and check that it is a LiteralNumber
.
Raytracer.Interpreter.expect_string
— Methodexpect_string(stream::InputStream)
Read a token from an InputStream
and check that it is a LiteralString
.
Raytracer.Interpreter.expect_symbol
— Methodexpect_symbol(stream::InputStream, symbol::LiteralSymbol)
Read a token from an InputStream
and check that it is the requested LiteralSymbol
.
Raytracer.Interpreter.expect_symbol
— Methodexpect_symbol(stream::InputStream, symbols::Union{Tuple{N, Symbol} where {N}, AbstractVector{Symbol}})
Read a token from an InputStream
and check that it is one of the requested LiteralSymbol
s.
Raytracer.Interpreter.expect_type
— Methodexpect_type(stream::InputStream, type::LiteralType)
Read a token from an InputStream
and check that it is a given LiteralType
.
Raytracer.Interpreter.expect_type
— Methodexpect_type(stream::InputStream, types::Union{NTuple{N, LiteralType} where {N}, AbstractVector{LiteralType}})
Read a token from an InputStream
and check that it is a LiteralType
in the given types
.
Raytracer.Interpreter.expect_type
— Methodexpect_type(stream::InputStream)
Read a token from an InputStream
and check that it is a LiteralType
.
Raytracer.Interpreter.generate_kwargs
— Methodfunction generate_kwargs(stream::InputStream, scene::Scene, kw::NamedTuple)
Return a Dict{Symbol, Any}
as instructed by the given kw
NamedTuple
.
The argument kw
pairs all the keywords a constructor need with the parsing functions they need. This function parses keywords and/or values until it reaches the end of the constructor. The arguments may also be positional, but positional arguments must not follow keyword arguments. If a keyword is used more than once an exception is thrown.
Raytracer.Interpreter.isnewline
— Methodisnewline(c::Char)
Check if c
is a newline character.
Raytracer.Interpreter.issymbol
— Methodissymbol(c::Char)
Check if c
is in a partucular set of characters used in a SceneLang script.
Raytracer.Interpreter.parse_brdf
— Methodparse_brdf(stream::InputStream, scene::Scene)
Return a BRDF
value from either a named constructor or an appropriate Identifier
.
The concrete type is determined by the first keyword after the BrdfType
token, which also determines the keyword arguments to be read by generate_kwargs
.
Raytracer.Interpreter.parse_by_identifier
— Methodparse_by_identifier(expected_type::IdTableKey, stream::InputStream, table::IdTable)
If the next token is an Identifier
, check that its type is coherent with expected_type
and return its value.
Raytracer.Interpreter.parse_camera
— Methodparse_camera(stream::InputStream, scene::Scene)
Return a Camera
value from either a named constructor or an appropriate Identifier
.
The concrete type is determined by the first keyword after the CameraType
token, which also determines the keyword arguments to be read by generate_kwargs
.
Raytracer.Interpreter.parse_color
— Methodparse_color(stream::InputStream, scene::Scene)
Return a RGB{Float32}
value from either a named constructor, a symbolic constructor, an appropriate MathExpression
, or an appropriate Identifier
.
If the constructor has not exactly three arguments an exception will be thrown.
Raytracer.Interpreter.parse_constructor
— Methodparse_constructor(stream::InputStream, scene::Scene)
Return a Tuple{Any, IdTableKey}
containing the result of the construction and its type.
If the expression from the stream
is not a valid constructor an exception is thrown.
Raytracer.Interpreter.parse_dump_command
— Methodparse_dump_command(stream::InputStream, scene::Scene)
Show the contents of the Scene
. What is shown depends on the Keyword
following the DUMP
Command
.
The valid Keyword
s are .ALL
for showing the whole Scene
, or the name of one of its fields (in lowercase letters) to show that specific field.
Raytracer.Interpreter.parse_explicit_image
— Methodparse_explicit_image(stream::InputStream, scene::Scene)
Return an HdrImage
value from a named constructor.
There are two versions of the constructor:
- one taking a valid file path
LiteralString
as the only argument and loading the image stored in that file - the other taking two integer
LiteralNumber
s as width and height and constructing an empty image.
See also: parse_image
Raytracer.Interpreter.parse_explicit_shape
— Methodparse_explicit_shape(stream::InputStream, scene::Scene)
Return a Shape
value from either a named constructor or an appropriate Identifier
.
The concrete type is determined by the first keyword after the ShapeType
token, which also determines the keyword arguments to be read by generate_kwargs
.
Raytracer.Interpreter.parse_explicit_transformation
— Methodparse_explicit_transformation(stream::InputStream, scene::Scene)
Return a Transformation
value from a named constructor taking a 16-long list as the only argument.
There is no way to set the inverse matrix, so it will be calculated by the inv
algorithm upon construction.
See also: parse_transformation
Raytracer.Interpreter.parse_float
— Methodparse_float(stream::InputStream, scene::Scene)
Return a Float32
value from either a LiteralNumber
constructor, the TIME
command, an appropriate MathExpression
, or an appropriate Identifier
.
Raytracer.Interpreter.parse_fusion
— Methodparse_fusion(stream::InputStream, scene::Scene)
Return a FusionCSG
value from the FUSE
Command
.
See also: parse_shape_from_command
Raytracer.Interpreter.parse_image
— Methodparse_image(stream::InputStream, scene::Scene)
Return an HdrImage
value from either a named constructor, a construction command, or an appropriate Identifier
.
See also: parse_explicit_image
, parse_image_from_command
Raytracer.Interpreter.parse_image_from_command
— Methodparse_image_from_command(stream::InputStream, scene::Scene)
Return an HdrImage
value from the LOAD
Command
.
The LOAD
Command
takes only one LiteralString
representing a valid file path to an image file as an argument.
See also: parse_image
Raytracer.Interpreter.parse_int
— Methodparse_int(stream::InputStream, scene::Scene)
Return a Int
value from either a LiteralNumber
constructor, the TIME
command, an appropriate MathExpression
, or an appropriate Identifier
.
If the Float32
number is not exactly representing an integer number an exception is thrown.
Raytracer.Interpreter.parse_intersection
— Methodparse_intersection(stream::InputStream, scene::Scene)
Return a IntersectionCSG
value from the INTERSECT
Command
.
See also: parse_shape_from_command
Raytracer.Interpreter.parse_light
— Methodparse_light(stream::InputStream, scene::Scene)
Return a PointLight
value from either a named constructor or an appropriate Identifier
.
Raytracer.Interpreter.parse_list
— Methodparse_list(stream::InputStream, scene::Scene, list_length::Int)
Return a SVector{list_length, Float32}
value from either a named constructor, a symbolic constructor or an appropriate Identifier
.
If the list is not exactly list_length
long an exception will be thrown.
Raytracer.Interpreter.parse_list
— Methodparse_list(stream::InputStream, scene::Scene)
Return a Vector{Float32}
value from either a named constructor, a symbolic constructor or an appropriate Identifier
.
Raytracer.Interpreter.parse_material
— Methodparse_material(stream::InputStream, scene::Scene)
Return a Material
value from either a named constructor or an appropriate Identifier
.
The concrete type is determined by the first keyword after the MaterialType
token, which also determines the keyword arguments to be read by generate_kwargs
.
Raytracer.Interpreter.parse_pcg
— Methodparse_pcg(stream::InputStream, scene::Scene)
Return a PCG
value from either a named constructor or an appropriate Identifier
.
Raytracer.Interpreter.parse_pigment
— Methodparse_pigment(stream::InputStream, scene::Scene)
Return a Pigment
value from either a named constructor or an appropriate Identifier
.
The concrete type is determined by the first keyword after the PigmentType
token, which also determines the keyword arguments to be read by generate_kwargs
.
Raytracer.Interpreter.parse_point
— Methodparse_point(stream::InputStream, scene::Scene)
Return a Point
value from either a named constructor, a symbolic constructor, an appropriate MathExpression
, or an appropriate Identifier
.
If the constructor has not exactly three arguments an exception will be thrown.
Raytracer.Interpreter.parse_renderer_settings
— Methodparse_renderer_settings(stream::InputStream, scene::Scene)
Return a RendererSettings
value from either a named constructor or an appropriate Identifier
.
The renderer type is determined by the first keyword after the RendererType
token, which also determines the keyword arguments to be read by generate_kwargs
and stored in the kwargs
field of the result.
Raytracer.Interpreter.parse_rotation
— Methodparse_rotation(stream::InputStream, scene::Scene)
Return a Transformation
value from the ROTATE
Command
.
The argument of this command is a sequence of keyword arguments, with keywords representing the three axes of rotation .X
, .Y
, and .Z
, followed by a number representing the rotation angle in degrees. Each of these keyword arguments are separated by a *
operator which behaves as a concatenation of rotation following the usual rules of matrix multiplication (i.e. the rightmost rotation will be the first to be applied)
See also: parse_transformation_from_command
Raytracer.Interpreter.parse_scaling
— Methodparse_scaling(stream::InputStream, scene::Scene)
Return a Transformation
value from the SCALE
Command
.
The arguments of this command are a sequence of keyword arguments, with keywords representing the three axes of scaling .X
, .Y
, and .Z
, followed by a number representing the scaling factor. Each of these keyword arguments are separated by a ,
. The order of these arguments is indifferent since, in our euclidean space, scalings are commutative transformations.
An alternate form of this command sees only one numeric argument, without parenthesis, and indicates uniform scaling in all directions.
See also: parse_transformation_from_command
Raytracer.Interpreter.parse_set_command
— Methodparse_set_command(stream::InputStream, scene::Scene)
Push to the 'scene.variables' IdTable
a constructed value and its identifier variable.
Raytracer.Interpreter.parse_setdiff
— Methodparse_setdiff(stream::InputStream, scene::Scene)
Return a DiffCSG
value from the DIFF
Command
.
See also: parse_shape_from_command
Raytracer.Interpreter.parse_shape
— Methodparse_shape(stream::InputStream, scene::Scene)
Return a Shape
value from either a named constructor, a construction command, or an appropriate Identifier
.
See also: parse_explicit_shape
, parse_shape_from_command
Raytracer.Interpreter.parse_shape_from_command
— Methodparse_shape_from_command(stream::InputStream, scene::Scene)
Return a Shape
value from the UNITE
, INTERSECT
, DIFF
, and FUSE
Command
s.
See also: parse_shape
, parse_union
, parse_intersection
, parse_setdiff
, parse_fusion
Raytracer.Interpreter.parse_spawn_command
— Methodparse_spawn_command(stream::InputStream, scene::Scene)
Push the given ShapeType
or LightType
to the scene.world
World
or scene.lights
Lights
respectively.
See also: Scene
Raytracer.Interpreter.parse_string
— Methodparse_string(stream::InputStream, scene::Scene)
Return a String
value from either a LiteralString
constructor or an appropriate Identifier
.
Raytracer.Interpreter.parse_tracer_settings
— Methodparse_tracer_settings(stream::InputStream, scene::Scene)
Return a TracerSettings
value from either a named constructor or an appropriate Identifier
.
Raytracer.Interpreter.parse_transformation
— Methodparse_transformation(stream::InputStream, scene::Scene)
Return a Transformation
value from either a named constructor, a construction command, or an appropriate Identifier
.
If the constructor/command/identifier is followed by an *
operator the transformations will be concatenated following the usual matrix multiplication rules (i.e. the rightmost transformation will be applied first).
See also: parse_explicit_transformation
, parse_transformation_from_command
Raytracer.Interpreter.parse_transformation_from_command
— Methodparse_transformation_from_command(stream::InputStream, scene::Scene)
Return a Transformation
value from the ROTATE
, TRANSLATE
, and SCALE
Command
s.
See also: parse_transformation
, parse_rotation
, parse_translation
, parse_scaling
Raytracer.Interpreter.parse_translation
— Methodparse_translation(stream::InputStream, scene::Scene)
Return a Transformation
value from the TRANSLATE
Command
.
The arguments of this command are a sequence of keyword arguments, with keywords representing the three axes of translation .X
, .Y
, and .Z
, followed by a number representing the displacement. Each of these keyword arguments are separated by a ,
. The order of these arguments is indifferent since, in our euclidean space, translations are commutative transformations.
See also: parse_transformation_from_command
Raytracer.Interpreter.parse_union
— Methodparse_union(stream::InputStream, scene::Scene)
Return a UnionCSG
value from the UNITE
Command
.
See also: parse_shape_from_command
Raytracer.Interpreter.parse_unset_command
— Methodparse_unset_command(stream::InputStream, scene::Scene)
Pop identifier variable from the scene.variables
IdTable
.
Raytracer.Interpreter.parse_using_command
— Methodparse_using_command(stream::InputStream, scene::Scene)
Set the given CameraType
, ImageType
or RendererType
to the scene.camera
, scene.image
, or scene.renderer
respectively.
Can only be used once per type in a SceneLang script.
See also: Scene
Raytracer.Interpreter.read_at_line
— Methodread_at_line(io::IO, line_num::Int)
Read the line_num
-th line of io
.
Raytracer.Interpreter.read_at_line
— Methodread_at_line(file_name::String, line_num::Int)
Read the line_num
-th line of a file named file_name
.
Raytracer.Interpreter.read_char!
— Methodread_char!(stream::InputStream)
Read a new character from the stream.
Raytracer.Interpreter.read_token
— Methodread_token(stream::InputStream)
Read the next token in the stream.
Raytracer.Interpreter.skip_whitespaces_and_comments
— Methodskip_whitespaces_and_comments(stream::InputStream)
Keep reading characters until a non-whitespace character is found out of a commented line.
Raytracer.Interpreter.unread_char!
— Methodunread_char!(stream::InputStream, ch::Union{Char, Nothing})
Push a character back to the stream. Accepts a nothing
value to deal with eof.
Raytracer.Interpreter.unread_token
— Methodunread_token(stream::InputStream, ch::Token)
Push a token back to the stream.
Index
Raytracer.Interpreter.valid_operations
Raytracer.Interpreter.BadCharacter
Raytracer.Interpreter.BadCharacter
Raytracer.Interpreter.CameraOrNot
Raytracer.Interpreter.Command
Raytracer.Interpreter.IdTable
Raytracer.Interpreter.IdTableKey
Raytracer.Interpreter.Identifier
Raytracer.Interpreter.IdentifierRedefinition
Raytracer.Interpreter.IdentifierRedefinition
Raytracer.Interpreter.ImageOrNot
Raytracer.Interpreter.InputStream
Raytracer.Interpreter.InterpreterException
Raytracer.Interpreter.InvalidCommand
Raytracer.Interpreter.InvalidCommand
Raytracer.Interpreter.InvalidExpression
Raytracer.Interpreter.InvalidExpression
Raytracer.Interpreter.InvalidFilePath
Raytracer.Interpreter.InvalidFilePath
Raytracer.Interpreter.InvalidKeyword
Raytracer.Interpreter.InvalidKeyword
Raytracer.Interpreter.InvalidNumber
Raytracer.Interpreter.InvalidNumber
Raytracer.Interpreter.InvalidSize
Raytracer.Interpreter.InvalidSize
Raytracer.Interpreter.InvalidSymbol
Raytracer.Interpreter.InvalidSymbol
Raytracer.Interpreter.InvalidType
Raytracer.Interpreter.InvalidType
Raytracer.Interpreter.Keyword
Raytracer.Interpreter.LiteralNumber
Raytracer.Interpreter.LiteralString
Raytracer.Interpreter.LiteralSymbol
Raytracer.Interpreter.LiteralType
Raytracer.Interpreter.MathExpression
Raytracer.Interpreter.RendererOrNot
Raytracer.Interpreter.RendererSettings
Raytracer.Interpreter.Scene
Raytracer.Interpreter.Scene
Raytracer.Interpreter.Scene
Raytracer.Interpreter.SettingRedefinition
Raytracer.Interpreter.SettingRedefinition
Raytracer.Interpreter.SourceLocation
Raytracer.Interpreter.SourceLocation
Raytracer.Interpreter.SourceLocation
Raytracer.Interpreter.StopToken
Raytracer.Interpreter.Token
Raytracer.Interpreter.TokenValue
Raytracer.Interpreter.TracerOrNot
Raytracer.Interpreter.TracerSettings
Raytracer.Interpreter.UndefinedIdentifier
Raytracer.Interpreter.UndefinedIdentifier
Raytracer.Interpreter.UndefinedSetting
Raytracer.Interpreter.UndefinedSetting
Raytracer.Interpreter.UnfinishedExpression
Raytracer.Interpreter.UnfinishedExpression
Raytracer.Interpreter.ValueLoc
Raytracer.Interpreter.WrongTokenType
Raytracer.Interpreter.WrongTokenType
Raytracer.Interpreter.WrongValueType
Raytracer.Interpreter.WrongValueType
Raytracer.Interpreter._parse_command_or_type_token
Raytracer.Interpreter._parse_identifier_token
Raytracer.Interpreter._parse_keyword_token
Raytracer.Interpreter._parse_math_expression_token
Raytracer.Interpreter._parse_number_token
Raytracer.Interpreter._parse_string_token
Raytracer.Interpreter._update_pos!
Raytracer.Interpreter.evaluate_math_expression
Raytracer.Interpreter.expect_command
Raytracer.Interpreter.expect_command
Raytracer.Interpreter.expect_command
Raytracer.Interpreter.expect_identifier
Raytracer.Interpreter.expect_keyword
Raytracer.Interpreter.expect_keyword
Raytracer.Interpreter.expect_number
Raytracer.Interpreter.expect_string
Raytracer.Interpreter.expect_symbol
Raytracer.Interpreter.expect_symbol
Raytracer.Interpreter.expect_type
Raytracer.Interpreter.expect_type
Raytracer.Interpreter.expect_type
Raytracer.Interpreter.generate_kwargs
Raytracer.Interpreter.isnewline
Raytracer.Interpreter.issymbol
Raytracer.Interpreter.open_stream
Raytracer.Interpreter.parse_brdf
Raytracer.Interpreter.parse_by_identifier
Raytracer.Interpreter.parse_camera
Raytracer.Interpreter.parse_color
Raytracer.Interpreter.parse_constructor
Raytracer.Interpreter.parse_dump_command
Raytracer.Interpreter.parse_explicit_image
Raytracer.Interpreter.parse_explicit_shape
Raytracer.Interpreter.parse_explicit_transformation
Raytracer.Interpreter.parse_float
Raytracer.Interpreter.parse_fusion
Raytracer.Interpreter.parse_image
Raytracer.Interpreter.parse_image_from_command
Raytracer.Interpreter.parse_int
Raytracer.Interpreter.parse_intersection
Raytracer.Interpreter.parse_light
Raytracer.Interpreter.parse_list
Raytracer.Interpreter.parse_list
Raytracer.Interpreter.parse_material
Raytracer.Interpreter.parse_pcg
Raytracer.Interpreter.parse_pigment
Raytracer.Interpreter.parse_point
Raytracer.Interpreter.parse_renderer_settings
Raytracer.Interpreter.parse_rotation
Raytracer.Interpreter.parse_scaling
Raytracer.Interpreter.parse_scene
Raytracer.Interpreter.parse_set_command
Raytracer.Interpreter.parse_setdiff
Raytracer.Interpreter.parse_shape
Raytracer.Interpreter.parse_shape_from_command
Raytracer.Interpreter.parse_spawn_command
Raytracer.Interpreter.parse_string
Raytracer.Interpreter.parse_tracer_settings
Raytracer.Interpreter.parse_transformation
Raytracer.Interpreter.parse_transformation_from_command
Raytracer.Interpreter.parse_translation
Raytracer.Interpreter.parse_union
Raytracer.Interpreter.parse_unset_command
Raytracer.Interpreter.parse_using_command
Raytracer.Interpreter.parse_variables_from_string
Raytracer.Interpreter.read_at_line
Raytracer.Interpreter.read_at_line
Raytracer.Interpreter.read_char!
Raytracer.Interpreter.read_token
Raytracer.Interpreter.skip_whitespaces_and_comments
Raytracer.Interpreter.unread_char!
Raytracer.Interpreter.unread_token