We can disentangle what is going on at the low level. First of all, shift is defined as
\tikzoption{shift}{\tikz@addtransform{\tikz@scan@one@point\pgftransformshift#1\relax}}%
The macro that does the heavy lifting scanning a point is \tikz@scan@one@point. The result is a \pgfpoint which is then passed to \pgftransformshift. This transformation is then added to the stack of transformations which is managed by \tikz@addtransform.
The procedure of \tikz@scan@one@point is a bit more tricky. Here is a tree diagram of what happens inside approximately.
\tikz@scan@one@point
|
if next character is +
/yes no\
scan relative point |
| |
if next character is + |
/yes no\ |
relative to previous relative to first |
\ / |
scan absolute point --------------
|
if character is (
/yes no\
| expand tokens (at most 100 times)
| |
| valid coordinate found?
| /yes no\
| | Give up.
| | "Cannot parse this coordinate"
| |
-- if next character is [
/yes no\
scan until ] and pass to \tikzset |
\ /
if next character is $
/yes no\
<--- calc library |
if coordinate contains with cs:
/yes no\
parse coordinate system |
if coordinate contains intersection
/yes no\
parse intersection if coordinate contains with |
/yes no\
if coordinate contains -| |
/yes no\ |
parse -| specifier parse |- specifier |
|
if coordinate contains :
/yes no\
parse polar coordinate |
if coordinate contains ,
/yes no\
parse regular coordinate parse node name
In your case it will descend into the parse regular coordinate branch, where the point will just be split at the comma and each component will be evaluated with \pgfmathparse.
Regarding the second part of your question:
And if I want to define a pgfkey with a coordinate-like parameter so that when I pass a string like (2, 3, 4), it is parsed and the values are saved to three macros respectively, is it feasible to imitate the way how tikz handles or are there some other convenient methods?
In this case I think you are better off parsing this by hand, i.e. something along those lines:
\tikzset{
triple/x/.store in=\triplex,
triple/y/.store in=\tripley,
triple/z/.store in=\triplez,
triple/.style args={(#1,#2,#3)}{
triple/x=#1,
triple/y=#2,
triple/z=#3,
}
}
\tikzset{triple={(1,2,3)}}
shift={(1, 1)}is parsed as "shift by 1e_1 + 1e_2", where e_1 and e_2 are the units vectors. This is different fromshift={(1cm, 1cm)}, which produces a shift by 1cm in x direction and 1cm in y directions. In the default setting, e_1=(1cm,0) and e_2=(0,1cm), so both "accidentally" yield the same result. It is really instructive to read https://tex.stackexchange.com/a/31606/194703 for that. tikz also parses and interprets the coordinates in terms of some dimensions that specify their location in screen coordinates in pt. – Nov 18 '19 at 05:06\csname tikz@dcl@coord@#1\endcsname, where#1is the name of the coordinate. This happens if you use e.g.\path (2,3,4) coordinate (A);, then\tikz@dcl@coord@Ais(2,3,4). This has been used in https://github.com/tallmarmot/pgf/tree/master/experiments/Marmot/3dtools to allow TikZ to store 3D coordinates, and use them for vector operations. – Nov 18 '19 at 05:12