link_text_parser.yrl (2537B)
1 Nonterminals link_or_image 2 link rest 3 inside_brackets inside_brackets_part anything. 4 5 Terminals any_quote open_bracket open_title close_bracket open_paren close_paren verbatim escaped exclamation_mark ws. 6 7 Rootsymbol link_or_image. 8 9 link_or_image -> exclamation_mark link : make_image_tuple('$2'). 10 link_or_image -> link : '$1'. 11 12 link -> open_bracket close_bracket : {link, "", "[]"}. 13 link -> open_bracket close_bracket rest : {link, "", "[]"}. 14 link -> open_bracket inside_brackets close_bracket : title_tuple('$2'). 15 link -> open_bracket inside_brackets close_bracket rest : title_tuple('$2'). 16 17 inside_brackets -> inside_brackets_part : '$1'. 18 inside_brackets -> inside_brackets_part inside_brackets : concat_tuple('$1', '$2'). 19 20 inside_brackets_part -> exclamation_mark : extract_token('$1'). 21 inside_brackets_part -> verbatim : extract_token('$1'). 22 inside_brackets_part -> ws : extract_token('$1'). 23 inside_brackets_part -> open_title : extract_token('$1'). 24 inside_brackets_part -> open_paren : {"(", "("}. 25 inside_brackets_part -> close_paren : {")", ")"}. 26 inside_brackets_part -> any_quote : extract_token('$1'). 27 inside_brackets_part -> escaped : escaped_token('$1'). 28 inside_brackets_part -> open_bracket close_bracket : {"[]", "[]"}. 29 inside_brackets_part -> open_bracket inside_brackets close_bracket : concat_3t("[", '$2', "]"). 30 31 rest -> anything. 32 rest -> anything rest. 33 34 anything -> exclamation_mark. 35 anything -> ws. 36 anything -> verbatim. 37 anything -> open_paren. 38 anything -> close_paren. 39 anything -> open_bracket. 40 anything -> close_bracket. 41 anything -> any_quote. 42 anything -> escaped. 43 anything -> open_title. 44 45 Erlang code. 46 47 concat_tuple({LT, LP}, {RT, RP}) -> {string:concat(LT, RT), string:concat(LP, RP)}. 48 49 concat_3t(L, {MT, MP}, R) -> {string:join([L, MT, R], ""), string:join([ L, MP, R ], "")}. 50 51 escaped_token({_Token, _Line, Value}) -> {string:concat("\\", Value), string:concat("\\", Value)}. 52 53 extract_token({_Token, _Line, Value}) -> {Value, Value}. 54 55 make_image_tuple({_Link, L, R}) -> {image, L, string:concat("!", R)}. 56 57 title_tuple({Title, Parsed}) -> {link, Title, string:join(["[", Parsed, "]"], "")}. 58 59 %% SPDX-License-Identifier: Apache-2.0