{parsing} is the process of analysing a string of symbols, either in natural or computer language.
Questions tagged [parsing]
205 questions
11
votes
6 answers
How to go about creating custom parser in Latex
Say I wanted to write a macro like this:
\makelinesegment{1:1-1:2-2:2}
And have it become something like:
\draw (1,1) -- (1,2) -- (2,2);
The question is, how to go about parsing that 1:1-1:2-2:2 as a single option.
In another language you could…
Lance
- 1,799
9
votes
3 answers
Parsing various types of page ranges with a single command
Having to treat a considerable amount of page ranges, I'd like to have a robust and simple command that would parse and print them correctly.
The most simple case is e.g.
264,15-26
which means:
page 264, lines 15 to 26
Then we have things…
7
votes
4 answers
LaTeX parser to perform operations on tags (commands) and its content?
Is there a LaTeX parser available that can be run from a (*nix) command line, and that allows operations on LaTeX tags/commands and its content?
What I am trying to do is, for example:
script-wise extracting certain text blocks, like all…
Rabarberski
- 6,459
7
votes
4 answers
Parse a string into tokens of numbers and not numbers
I have a string that I want to parse into to numbers and non-numbers.
For my purposes:
A Number can EITHER be any sequential string of digits OR sequential string of digits with a . followed by another sequential string.
A Non-Number is anything…
Uiy
- 6,132
7
votes
2 answers
Parser for pure LaTeX
Is it possible to create a parser for pure LaTeX (no plain TeX, no TeX primitive) without using any TeX engine that supports total LaTeX?
I know about an iOS app to create and typeset LaTeX and I don't think that they are using a TeX engine.
Is…
John webner
- 267
7
votes
2 answers
Parse filename and extract revision from name
My file is named 'cv3.01.tex'. I want to extract the '3.01' part and use it in the footer of the document, i.e. 'Rev 3.01'.
I found Parsing file name into document, but it does not work for my filename structure.
Here is my code based on the…
John Johnson
- 381
- 2
- 10
6
votes
4 answers
Simple pre-parser to separate TeX and comments?
I want to write a mathematical paper both with formulas
and with program snippets, side by side. However I do not
want the programs displayed or documented by TeX, just be
able to extract them into a file if desired.
Note that my intention has…
Sophia Antipolis
- 1,065
6
votes
3 answers
Parsing file name into document
I have a group of tex files named according to the following convention:
xxx_yyy_zzz.tex
I would like to use the components (xxx, yyy, zzz) of the file name as inputs in the document, n particular when creating the title / header. For example, I…
Liz
- 61
5
votes
1 answer
Nested maths mode - Latex parsing
I needed a tiny bullet and found this solution :
$\vcenter{\hbox{\tiny$\bullet$}}$
Howover, I don't understand how latex interpret / parse this formula.
\vcenter is math mode
\hbox and \tiny are text mode
\bullet is math mode
What exactly are in…
Matheod
- 450
- 3
- 14
5
votes
1 answer
Generate a parse tree for TeX
If I google for parse tree and TeX. All I'm getting are how to draw parse trees in TeX.
I want to know if there are programs that can parse TeX, and output a parse tree that's easy to manipulate.
Chao Xu
- 245
- 1
- 5
5
votes
3 answers
Cartesian product of two lists as parameters for a command
Friends, I used to suffer a lot when had to iterate through elements of a list, but thanks to egreg's suggestion, I've been successfully using the etoolbox package for that task, e.g.:
\DeclareListParser*{\dothedance}{;}
\dothedance{\fbox}{item1;…
Paulo Cereda
- 44,220
5
votes
1 answer
Is it possible to run a command stored as text in a variable?
I have some complicated expressions with loads of nested commands which are difficult to work with. To solve this I wrote a parser using pgfparser which creates the expressions for me. I can then copy the output back in to LaTeX and it outputs what…
DQuick
- 53
4
votes
3 answers
How to absorb the content of the page into a variable?
This is what I'm trying to do:
\documentclass{article}
\begin{document}
\start
Hello, world!
\stop
\print % here!
\end{document}
I'm expecting Hello, world! to be printed twice. The second time by the \print command. I want \start to start…
yegor256
- 12,021
4
votes
1 answer
Parse macro arguments char by char and for loop through these chars
I have an idea. I want to loop through every character in string argument of macro. For example:
\def\dowithchar#1{%
% some actions with #1
}
\def\mymacro#1{%
% further pseudocode
for (every character \ch in #1)
\dowithchar{\ch}
}
In…
Gubin Aleksandr
- 323
3
votes
2 answers
How to make plain text be understood as a macro?
I'd like to create an environment, which will have its own parsing rules inside, for example:
\begin{foo}
a := 42;
c := a;
\end{foo}
Would be understood as:
a \mapsto 42 \\[2pt] c \mapsto a \\[2pt]
Here, := is understood by TeX as \mapsto and ; as…
yegor256
- 12,021