One of the strengths of a parser combinator is that it can handle things like this more readily than generated parsers. In regex you have the regex string, which is unchangeable. A parser combinator is a combination of smaller parser subunits joined seamlessly by code. Well. The good ones are. The manner in which they parse content can change if they are constructed and written in such a way.
As a trivial example, I have two parsers. One of them catches ``
@GregRos In the context of syntax highlighting in a document for editing, most of the time the awkward side cases are avoided, plus of course you want something quite fast
@GregRos consider \setbox0=\hbox{hello}\ifdim\wd0>20pt \catcode'Z=12 \fi \ZZ That final \ZZ is either the command \ZZ (a single token) or the command \Z followed by the character Z (two tokens) depending on the width of the word hello in the current font so you can not even parse the input without typesetting
In „Why does the use of microtype and xfrac lead to a high compile time?“ the comment seems to provide the best answer. If seen this also in other questions. What is the best way to accept it as answer?
You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML. Regular expressions are a tool th...
@GregRos course it is relevant in that you can use regex to tokenize xhtml tags just not to parse element structure, which is exactly where we started. But xhtml has a lot more structure than Tex which can't in full generality be parsed by anything other than tex
@kan You can produce font tables with the fonttable package. You can simply give the combination "encoding+family+weight+shape" as stated in the relative \DeclareSymbolFont using the \xfonttable command (see the doc); the \xfonttable command was suggested by … :)
@DavidCarlisle Look there are completely different topics here. First, can a parser-combinator type program parse TeX. Second, should one use regex to tokenize TeX or xhtml for that matter.
The first subject aside, the reason for why one shouldn't use regex to tokenize TeX is that regex is, a) impossible to maintain b) practically unreadable c) can silently fail, or produce incorrect results for unforseen inputs d) will not give you the reason for the failure or even where it occurred in the context of the document itself
@GregRos answer to first has to be no (well of course if you use the tex engine to split the parsing problem in to small enough units I suppose the answer might be yes, but basically it is no, you can not writ e grammar that says whether \ZZ is one token or two in TeX. Second, parsing with regex will get some answers wrong but so will parsing with anything, so as it's quick and easy in most editors then yes it makes sense for syntax highlighting, it's good enough
@GregRos Works for me and many others highlighting syntax in TeXworks, certainly as well as the other highlighting approaches I've seen (say in WinEdt)
I am currently working on a bunch of little assignments for university. Everything was fine until yesterday:
All of a sudden when compiling the BibTeX I get an error and can therefore not create my bibliography. I thought it was a problem with some entries in my .bib file. After a lot of very d...
@GregRos For syntax highlighting you don't want error reports for failure, you just put up with the wrong colour here and there look at the answers in tex.stackexchange.com/questions/48229/… The command colour ends half way tthrough the command as the regex isn't expecting _
@GregRos You mentioned the f#/haskel parser but for syntax highlting it needs to be embedded in the system, so on this site in JavaScript in every TeX editor in that editor, regex is available in all those places, f# typically in none of them. got to go...
@NicolaTalbot Actually, it’s not the fault of the bug reporter: Oracle (I guess) decided, that Java should not be found on the system path. It’s the same here. But the OP is wrong in another way: The Oracle (?) developers did it worse and found, it was a good idea to put a java.exe and a javaw.exe into the Windows system folder! For this apparently admin rights upon installation are needed. At least it is here so, and I did not do this manually. (cont.)
@NicolaTalbot Your jpgfdraw and other Java programs run with a call of java(w).exewithout any path specification. @PauloCereda can you confirm, what I wrote?
@Speravir Yes, I basically just adapted the bash script command to a Windows equivalent. I don't like the idea of writing the full path for commands like that as you'd have to edit all the scripts if you install a new version of java in a different location.
(I wasted ages today trying to locate what script on my laptop is determined that latex resides in the now non-existant /usr/local/texlive/2009 path. In the end I gave up and make a symbolic link to the 2012 path.)
I'm too cold to carry on typing, so I'm going to shutdown and curl up with a book and a hot chocolate :-) Night all.
@egreg whatever blows your culinary minds. I'm of those who thank for the meal before they eat, who don't feel a strong reason to have an extra enjoyable meal, and who is aware of being in the lucky ~20% of population who eat more than once a day.
@tohecz All we're talking about is "poor cuisine": bouillabaisse is a fish soup. And the "focaccia" is just as I said above (in Recco it's different, but the only other ingredient is cheese).
I know it has been said before and is is being solved. Dispite of this I repeat it: I hate when something is so basic question that everyone knows it has been asked milion times. Still, instead of looking for the duplicate (which took 3 minutes) they provide the answer again.
Labeling and linking in LaTeX confuses me.
I have something like the following:
\section{main section}
\label{sec:mainsection}
%lots of text
\label{SomethingDescribedButNotDocumentElement}
%more text
I want to be able to link to the second label, but it seems those labels are associated with...
@GregRos no, it would not, simply because that is impossible. You either lose the control (how should $((1+1/x)y/3)/((1+x/2)(1-y))$ be typeset? All slashed changed to fractions? No way, that would be too ugly) or you lose the "very simple" input.
@kan Not off hand, there is asciimathml which goes from a plain text syntax to mathml, then various ways to get from mathml to tex, but probably doesn't result in the most compact natural tex coding
@DavidCarlisle Well, for basic functionality such as this... no, I am not willing to pay. But, of course, if I want some solid stuff, I can pay you. :)
@tohecz It's incorrect, even if one uses \mleft and \mright. I mean, if one just wants some output slightly reminding of good typography, then OK. But a good document needs human intervention.
@Speravir If I'm not mistaken, newer versions of Java write entries in the Windows registry, so there's a lookup there in case the tools are not explicitly added to the path. I think Nicola's scripts are safe. :)
If the area of a circle is 279.46cm and it has a diameter of 18cm, is it possible to find the circumference without using or making Pi in any way at all, and if it is possible, how?