Is the separators created by the FSYacc thread safe?

If I generate a parser using FSYacc, will it be stream safe?

The only reason I ask is because functions

Parsing.rhs_start_pos and Parsing.symbol_end_pos

it seems like they did not have any state, which would make me assume that they get the current NonTerminal / Symbols from a common location, is that correct?

After reflecting the code, I see that they get the post from the static property

internal static IParseState parse_information
{
    get
    {
        return parse_information;
    }
    set
    {
        parse_information = value;
    }
}

It is right? If so, what can I do about it?

Edit: I also see a static method called set_parse_state

public static void set_parse_state(IParseState x)
{
    parse_information = x;
}

But this still will not solve my problem ...

+3
source share
1 answer

, , - , - .

, , , . parseState, IParseState, .

(, ): NonTerminal,

%token<string> NAME
%%
Person:
       NAME NAME { $1 (* action *) }

:

(fun (parseState : Microsoft.FSharp.Text.Parsing.IParseState) ->
      let _1 = (let data = parseState.GetInput(1) in 
                           (Microsoft.FSharp.Core.Operators.unbox data : string)
                ) in
      Microsoft.FSharp.Core.Operators.box((_1) : 'Person)
);

, parseState .

%token<string> NAME
%%
Person:
       NAME NAME { parseState.DoStuff(); }

rhs_start_pos :

let startPos,endPos = parseState.InputRange(n)

symbol_end_pos :

let startSymb,endSymb = parseState.ResultRange

,

+2

Source: https://habr.com/ru/post/1709736/


All Articles