// Implementation file for parser generated by fsyacc module Parser #nowarn "64";; // turn off warnings that type variables used in production annotations are instantiated to concrete type open FSharp.Text.Lexing open FSharp.Text.Parsing.ParseHelpers # 1 "Parser.fsy" open LDText.Ast open FSharp.Text.Lexing # 11 "Parser.fs" // This type is the type of tokens accepted by the parser type token = | EOF | QUESTION_MARK | SEMICOLON | COMMA | RIGHT_BRACKET | LEFT_BRACKET | RIGHT_PAREN | LEFT_PAREN | IDENTIFIER of (string) // This type is used to give symbolic names to token indexes, useful for error messages type tokenId = | TOKEN_EOF | TOKEN_QUESTION_MARK | TOKEN_SEMICOLON | TOKEN_COMMA | TOKEN_RIGHT_BRACKET | TOKEN_LEFT_BRACKET | TOKEN_RIGHT_PAREN | TOKEN_LEFT_PAREN | TOKEN_IDENTIFIER | TOKEN_end_of_input | TOKEN_error // This type is used to give symbolic names to token indexes, useful for error messages type nonTerminalId = | NONTERM__startrung | NONTERM_rung | NONTERM_steps | NONTERM_instr | NONTERM_operands | NONTERM_operand // This function maps tokens to integer indexes let tagOfToken (t:token) = match t with | EOF -> 0 | QUESTION_MARK -> 1 | SEMICOLON -> 2 | COMMA -> 3 | RIGHT_BRACKET -> 4 | LEFT_BRACKET -> 5 | RIGHT_PAREN -> 6 | LEFT_PAREN -> 7 | IDENTIFIER _ -> 8 // This function maps integer indexes to symbolic token ids let tokenTagToTokenId (tokenIdx:int) = match tokenIdx with | 0 -> TOKEN_EOF | 1 -> TOKEN_QUESTION_MARK | 2 -> TOKEN_SEMICOLON | 3 -> TOKEN_COMMA | 4 -> TOKEN_RIGHT_BRACKET | 5 -> TOKEN_LEFT_BRACKET | 6 -> TOKEN_RIGHT_PAREN | 7 -> TOKEN_LEFT_PAREN | 8 -> TOKEN_IDENTIFIER | 11 -> TOKEN_end_of_input | 9 -> TOKEN_error | _ -> failwith "tokenTagToTokenId: bad token" /// This function maps production indexes returned in syntax errors to strings representing the non terminal that would be produced by that production let prodIdxToNonTerminal (prodIdx:int) = match prodIdx with | 0 -> NONTERM__startrung | 1 -> NONTERM_rung | 2 -> NONTERM_steps | 3 -> NONTERM_steps | 4 -> NONTERM_instr | 5 -> NONTERM_operands | 6 -> NONTERM_operands | 7 -> NONTERM_operands | 8 -> NONTERM_operand | 9 -> NONTERM_operand | _ -> failwith "prodIdxToNonTerminal: bad production index" let _fsyacc_endOfInputTag = 11 let _fsyacc_tagOfErrorTerminal = 9 // This function gets the name of a token as a string let token_to_string (t:token) = match t with | EOF -> "EOF" | QUESTION_MARK -> "QUESTION_MARK" | SEMICOLON -> "SEMICOLON" | COMMA -> "COMMA" | RIGHT_BRACKET -> "RIGHT_BRACKET" | LEFT_BRACKET -> "LEFT_BRACKET" | RIGHT_PAREN -> "RIGHT_PAREN" | LEFT_PAREN -> "LEFT_PAREN" | IDENTIFIER _ -> "IDENTIFIER" // This function gets the data carried by a token as an object let _fsyacc_dataOfToken (t:token) = match t with | EOF -> (null : System.Object) | QUESTION_MARK -> (null : System.Object) | SEMICOLON -> (null : System.Object) | COMMA -> (null : System.Object) | RIGHT_BRACKET -> (null : System.Object) | LEFT_BRACKET -> (null : System.Object) | RIGHT_PAREN -> (null : System.Object) | LEFT_PAREN -> (null : System.Object) | IDENTIFIER _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x let _fsyacc_gotos = [| 0us;65535us;1us;65535us;0us;1us;2us;65535us;0us;2us;5us;6us;2us;65535us;0us;5us;5us;5us;2us;65535us;8us;9us;12us;13us;2us;65535us;8us;11us;12us;11us;|] let _fsyacc_sparseGotoTableRowOffsets = [|0us;1us;3us;6us;9us;12us;|] let _fsyacc_stateToProdIdxsTableElements = [| 1us;0us;1us;0us;1us;1us;1us;1us;1us;1us;1us;3us;1us;3us;1us;4us;1us;4us;1us;4us;1us;4us;2us;6us;7us;1us;6us;1us;6us;1us;8us;1us;9us;|] let _fsyacc_stateToProdIdxsTableRowOffsets = [|0us;2us;4us;6us;8us;10us;12us;14us;16us;18us;20us;22us;25us;27us;29us;31us;|] let _fsyacc_action_rows = 16 let _fsyacc_actionTableElements = [|1us;16386us;8us;7us;0us;49152us;1us;32768us;2us;3us;1us;32768us;0us;4us;0us;16385us;1us;16386us;8us;7us;0us;16387us;1us;32768us;7us;8us;2us;16389us;1us;15us;8us;14us;1us;32768us;6us;10us;0us;16388us;1us;16391us;3us;12us;2us;16389us;1us;15us;8us;14us;0us;16390us;0us;16392us;0us;16393us;|] let _fsyacc_actionTableRowOffsets = [|0us;2us;3us;5us;7us;8us;10us;11us;13us;16us;18us;19us;21us;24us;25us;26us;|] let _fsyacc_reductionSymbolCounts = [|1us;3us;0us;2us;4us;0us;3us;1us;1us;1us;|] let _fsyacc_productionToNonTerminalTable = [|0us;1us;2us;2us;3us;4us;4us;4us;5us;5us;|] let _fsyacc_immediateActions = [|65535us;49152us;65535us;65535us;16385us;65535us;16387us;65535us;65535us;65535us;16388us;65535us;65535us;16390us;16392us;16393us;|] let _fsyacc_reductions = lazy [| # 128 "Parser.fs" (fun (parseState : FSharp.Text.Parsing.IParseState) -> let _1 = parseState.GetInput(1) :?> Instr list in Microsoft.FSharp.Core.Operators.box ( ( raise (FSharp.Text.Parsing.Accept(Microsoft.FSharp.Core.Operators.box _1)) ) : 'gentype__startrung)); # 137 "Parser.fs" (fun (parseState : FSharp.Text.Parsing.IParseState) -> let _1 = parseState.GetInput(1) :?> 'gentype_steps in Microsoft.FSharp.Core.Operators.box ( ( # 26 "Parser.fsy" _1 ) # 26 "Parser.fsy" : Instr list)); # 148 "Parser.fs" (fun (parseState : FSharp.Text.Parsing.IParseState) -> Microsoft.FSharp.Core.Operators.box ( ( # 29 "Parser.fsy" [] ) # 29 "Parser.fsy" : 'gentype_steps)); # 158 "Parser.fs" (fun (parseState : FSharp.Text.Parsing.IParseState) -> let _1 = parseState.GetInput(1) :?> 'gentype_instr in let _2 = parseState.GetInput(2) :?> 'gentype_steps in Microsoft.FSharp.Core.Operators.box ( ( # 30 "Parser.fsy" _1 :: _2 ) # 30 "Parser.fsy" : 'gentype_steps)); # 170 "Parser.fs" (fun (parseState : FSharp.Text.Parsing.IParseState) -> let _1 = parseState.GetInput(1) :?> string in let _3 = parseState.GetInput(3) :?> 'gentype_operands in Microsoft.FSharp.Core.Operators.box ( ( # 33 "Parser.fsy" { Op = _1; Args = _3 } ) # 33 "Parser.fsy" : 'gentype_instr)); # 182 "Parser.fs" (fun (parseState : FSharp.Text.Parsing.IParseState) -> Microsoft.FSharp.Core.Operators.box ( ( # 36 "Parser.fsy" [] ) # 36 "Parser.fsy" : 'gentype_operands)); # 192 "Parser.fs" (fun (parseState : FSharp.Text.Parsing.IParseState) -> let _1 = parseState.GetInput(1) :?> 'gentype_operand in let _3 = parseState.GetInput(3) :?> 'gentype_operands in Microsoft.FSharp.Core.Operators.box ( ( # 37 "Parser.fsy" _1 :: _3 ) # 37 "Parser.fsy" : 'gentype_operands)); # 204 "Parser.fs" (fun (parseState : FSharp.Text.Parsing.IParseState) -> let _1 = parseState.GetInput(1) :?> 'gentype_operand in Microsoft.FSharp.Core.Operators.box ( ( # 38 "Parser.fsy" [ _1 ] ) # 38 "Parser.fsy" : 'gentype_operands)); # 215 "Parser.fs" (fun (parseState : FSharp.Text.Parsing.IParseState) -> let _1 = parseState.GetInput(1) :?> string in Microsoft.FSharp.Core.Operators.box ( ( # 41 "Parser.fsy" OperandTag _1 ) # 41 "Parser.fsy" : 'gentype_operand)); # 226 "Parser.fs" (fun (parseState : FSharp.Text.Parsing.IParseState) -> Microsoft.FSharp.Core.Operators.box ( ( # 42 "Parser.fsy" OperandHole ) # 42 "Parser.fsy" : 'gentype_operand)); |] # 237 "Parser.fs" let tables : FSharp.Text.Parsing.Tables<_> = { reductions = _fsyacc_reductions.Value; endOfInputTag = _fsyacc_endOfInputTag; tagOfToken = tagOfToken; dataOfToken = _fsyacc_dataOfToken; actionTableElements = _fsyacc_actionTableElements; actionTableRowOffsets = _fsyacc_actionTableRowOffsets; stateToProdIdxsTableElements = _fsyacc_stateToProdIdxsTableElements; stateToProdIdxsTableRowOffsets = _fsyacc_stateToProdIdxsTableRowOffsets; reductionSymbolCounts = _fsyacc_reductionSymbolCounts; immediateActions = _fsyacc_immediateActions; gotos = _fsyacc_gotos; sparseGotoTableRowOffsets = _fsyacc_sparseGotoTableRowOffsets; tagOfErrorTerminal = _fsyacc_tagOfErrorTerminal; parseError = (fun (ctxt:FSharp.Text.Parsing.ParseErrorContext<_>) -> match parse_error_rich with | Some f -> f ctxt | None -> parse_error ctxt.Message); numTerminals = 12; productionToNonTerminalTable = _fsyacc_productionToNonTerminalTable } let engine lexer lexbuf startState = tables.Interpret(lexer, lexbuf, startState) let rung lexer lexbuf : Instr list = engine lexer lexbuf 0 :?> _