lambdacube-engine-0.1.1: Graphics/LambdaCube/Loader/CompositorScriptScanner.x
{
-- alex scanner for use with uulib
-- compile with alex -o Scanner.hs -g Scanner.x
module Graphics.LambdaCube.Loader.Generated.CompositorScriptScanner(tokenize) where
import UU.Scanner
}
$litChar = [^[\" \\]]
$identChar = [a-zA-Z0-9_\.\-\/\~\&]
tokens :-
$white+ ; -- whitespace
"//".* ; -- comment
\" ($litChar | \\ \\ | \\ \" )* \" { valueToken TkString } -- string
[0-9]+ { valueToken TkInteger10 } -- int
[0-9]+\.[0-9]+ { valueToken TkFraction } -- float
(
on | off |
compositor | technique | texture | target_width | target_height | target_width_scaled | target_height_scaled | shared |
PF_A8R8G8B8 | PF_R8G8B8A8 | PF_R8G8B8 | PF_FLOAT16_RGBA | PF_FLOAT16_RGB | PF_FLOAT16_R | PF_FLOAT32_RGBA | PF_FLOAT32_RGB | PF_FLOAT32_R |
target | target_output | input | none | previous | only_initial | visibility_mask | lod_bias | shadows | material_scheme |
pass | render_quad | clear | stencil | render_scene | material | identifier | first_render_queue | last_render_queue |
buffers | colour | depth | colour_value | depth_value | stencil_value | check | comp_func |
always_fail | always_pass | less | less_equal | not_equal | greater_equal | greater | ref_value | mask | fail_op |
keep | zero | replace | increment | decrement | increment_wrap | decrement_wrap | invert | depth_fail_op | pass_op | two_sided
) { reserved } -- reserved keywords
[\{\}] { reserved } -- reserved symbols
$identChar+ { valueToken TkVarid } -- identifier
{
-- boilerplate code needed for Alex
type AlexInput = (Pos, String)
alexInputPrevChar :: AlexInput -> Char
alexInputPrevChar = error "alexInputPrevChar: there is no need to go back in the input."
alexGetChar :: AlexInput -> Maybe (Char, AlexInput)
alexGetChar (_, []) = Nothing
alexGetChar (p, (c:cs))
= let p' = adv p c
in Just (c, (p', cs))
-- use the Alex scanner to generate a list of tokens for the uulib token parsers
tokenize :: String -> String -> [Token]
tokenize filename str
= go (initpos, str)
where
initpos = Pos 1 1 filename
go inp@(pos, cs)
= case alexScan inp 0 of
AlexEOF -> []
AlexError inp' -> valueToken TkError [head cs] pos : go inp'
AlexSkip inp' _ -> go inp'
AlexToken inp' len act -> act (take len cs) pos : go inp'
}