How to interpret a custom key value syntax? [closed]

I am a (La)TeX developer. I haven't explored mainstream programming languages much. So apologies in advance if the question sounds too dumb or basic. I will describe my problem with a small example. In LaTeX, there is a standard way of using key value pairs. I have exploited it a little to create a syntax like follows: abcd = { abcd_val, efgh = {efgh_val}, ijkl = {ijkl_val, mnop = {mnop_val} } } A { starts a group in TeX. So when I compile the code using LaTeX, the following things are done: At the beginning of every group, a scratch variable is updated. Let's say the variable is called tmp. After entering the group abcd (i.e., just after abcd = {) tmp is updated. Its value becomes abcd. It becomes abcd_efgh when it enters the embedded group efgh, i.e.: after efgh = { in the example. If a string without any key is encountered, a variable is created using the value of tmp at that time. E.g., when abcd_val is encountered on line number 2, a variable is created using the value of tmp at that time which is abcd as described above. So a variable say, tmp_abcd with the value abcd_val is created. The nesting goes on and on like this resulting in the following four variables at the end of compilation: tmp_abcd = abcd_val tmp_abcd_efgh = efgh_val tmp_abcd_ijkl = ijkl_val tmp_abcd_ijkl_mnop = mnop_val Now I want replicate this interpretation and write external files with the syntax shown in the example. I tried doing it in TeX itself, but it is more complicated there. I thought maybe switching to another language might help. Which programming language would be the most efficient for achieving this? Can you suggest some pointers regarding what I can read in order to achieve this?

May 12, 2025 - 13:24
 0

I am a (La)TeX developer. I haven't explored mainstream programming languages much. So apologies in advance if the question sounds too dumb or basic. I will describe my problem with a small example.

In LaTeX, there is a standard way of using key value pairs. I have exploited it a little to create a syntax like follows:

abcd = {
  abcd_val,
  efgh = {efgh_val},
  ijkl = {ijkl_val,
    mnop = {mnop_val}
  }
}

A { starts a group in TeX. So when I compile the code using LaTeX, the following things are done:

  1. At the beginning of every group, a scratch variable is updated. Let's say the variable is called tmp. After entering the group abcd (i.e., just after abcd = {) tmp is updated. Its value becomes abcd. It becomes abcd_efgh when it enters the embedded group efgh, i.e.: after efgh = { in the example.
  2. If a string without any key is encountered, a variable is created using the value of tmp at that time. E.g., when abcd_val is encountered on line number 2, a variable is created using the value of tmp at that time which is abcd as described above. So a variable say, tmp_abcd with the value abcd_val is created.
  3. The nesting goes on and on like this resulting in the following four variables at the end of compilation:
tmp_abcd           = abcd_val
tmp_abcd_efgh      = efgh_val
tmp_abcd_ijkl      = ijkl_val
tmp_abcd_ijkl_mnop = mnop_val

Now I want replicate this interpretation and write external files with the syntax shown in the example. I tried doing it in TeX itself, but it is more complicated there. I thought maybe switching to another language might help. Which programming language would be the most efficient for achieving this? Can you suggest some pointers regarding what I can read in order to achieve this?