Try to make an answer to this question How to go about creating custom parser in Latex, I have the following problem. The result of the macro seem no conform to what I expect :
(1:1)--(-1:2)--(2,2)
or there is a problem related to expansion ...
\documentclass{article}
\usepackage{tikz,expl3,xparse}
\ExplSyntaxOn
\NewDocumentCommand{\makelinesegment}{ m } {
\tl_set:Nn \l_bob_func_tl { #1 }
\regex_replace_all:nnN { ([0-9])- } { \1)--( } \l_bob_func_tl
\regex_replace_all:nnN { : } { , } \l_bob_func_tl
(\l_bob_func_tl)
}
\ExplSyntaxOff
\begin{document}
\makelinesegment{1:1--1:2-2:2}
% If uncommented
% Package tikz Error: Giving up on this path. Did you forget a semicolon?.
%\tikz\draw \makelinesegment{1:1--1:2-2:2} ;
\end{document}
\makelinesegment{1:1--1:2-2:2}\tikz\draw\l_bob_func_tl;
or program\pgfextra
in your command if you are going to use it inside TikZ.\draw
expects to see something like(1,1)--(1,2)--(2,2)
, not the set of instructions necessary to get those tokens.\romannumeral
trick ...)