Skip to main content
25 votes
Accepted

Is it important that the front-end has a built-in parser?

Is it strictly necessary? In most cases, no, but doing so gives us many advantages. Most of those advantages might be worked around with various heuristics. But most importantly, it would have been ...
John Fultz's user avatar
  • 12.6k
16 votes

How can I ingest and analyze benchmark results posted at MSE?

Ingestion Get all answers from MSE discussion in an XML object: ...
Anton Antonov's user avatar
15 votes

Is it important that the front-end has a built-in parser?

Not really an answer and I may have to delete it, but...I had something of a different reaction to this business of the front end having its own parser, circa 2004. For motivation I recommend the ...
Daniel Lichtblau's user avatar
15 votes

Why is this syntax for patterns with Optional values not supported?

The Documentation states (emphasis is mine): Pattern (:): s:obj represents the pattern object ...
Alexey Popkov's user avatar
13 votes

Tokenize Mathematica input in a simple way

I am a developer at Wolfram Research and I am trying to share some of the work I have been doing with parsing WL code. I have written a package for parsing WL code and retaining interesting metadata, ...
brenton's user avatar
  • 521
12 votes

How to convert a string having nested parentheses into an expression?

I'd do the minimum necessary to make a legitimate, unambiguous Mathematica expression, and then let Mathematica rewrite it. ...
John Doty's user avatar
  • 13.9k
12 votes
Accepted

What is the best way to parse differential equations and boundary conditions to a custom function?

Assuming everything is syntactically correct, the function that does what you want is Internal`ProcessEquations`SeparateEquations: ...
Michael E2's user avatar
  • 241k
11 votes
Accepted

How to parse JSON

The example JSON string: ...
C. E.'s user avatar
  • 71.1k
11 votes

Is it important that the front-end has a built-in parser?

The result of the front-end's parsing is definitely used, but it does not need to be complete, it seems. This can be seen by constructing Cells/Boxes manually. Try ...
masterxilo's user avatar
  • 5,739
11 votes

Is building an event-based parser possible/reasonable in Mathematica (WL)?

Note: If you want this type of parser added for JSON, I think WRI could do it easily. They already have Developer`ReadRawJSONStream so I think adding some event-...
b3m2a1's user avatar
  • 47k
11 votes

Lexical scanning and parsing in a toy language

This can be done using functional parsers. Does the solution below look like something you would be interested in? (If you are I will elaborate on the current answer...) Grammar ...
Anton Antonov's user avatar
11 votes

Repeated string pattern: difference between the FrontEnd and WolframScript?

The notebook interface and the kernel have different parsers, because the notebook needs to manipulate the input before the kernel sees it for a variety of reasons. There are many differences between ...
Robert Jacobson's user avatar
11 votes
Accepted

Removing banal words from a list

Please also see a related problem here, it might give you more ideas. Words can be banal wrt all words in the dictionary or wrt some particular list of words. Let's consider the later case. ...
Vitaliy Kaurov's user avatar
10 votes
Accepted

Validate `Box` grammar, is it possible?

You may try using MathLink`CallFrontEnd[FrontEnd`ReparseBoxStructurePacket[...]]. ...
Domen's user avatar
  • 31.2k
9 votes

Efficient JSON parser for Mathematica

Recent versions of Mathematica no longer use Java for parsing JSON, and work very fast. There are at least three ways to read JSON. Import[..., "JSON"] is fast an ...
Szabolcs's user avatar
  • 236k
9 votes
Accepted

Context inside Do[...]-loop

Begin["mycontext`"] affects the parser, not the evaluator. These are separate expressions: Begin["mycontext`"]; ...
Szabolcs's user avatar
  • 236k
8 votes

Is it important that the front-end has a built-in parser?

Maybe that is not exactly the point of your question but is relevant. We need the FronEnd's parser, it is the only one that knows what is $CellContext` in given ...
Kuba's user avatar
  • 137k
8 votes
Accepted

Repeated string pattern: difference between the FrontEnd and WolframScript?

I suspect, much to my chagrin, that the FE is right and the InputForm parser is wrong. For one thing, the kernel itself thinks that parens are needed for Repeated: ...
Itai Seggev's user avatar
  • 14.2k
8 votes

What is the best way to parse differential equations and boundary conditions to a custom function?

I'll just give an idea to make it easier to do this. Which is not to use the same API as NDSolve, as that requires much much more work to parse it. Instead, have ...
Nasser's user avatar
  • 149k
7 votes
Accepted

Can Read[] apply a custom function automatically to the read values?

Yes! This is documented under Details: You can use Read to get objects to insert into any expression structure, not necessarily a list. Example: ...
7 votes

How to get the longest bracket pairs from a string

This works: ...
Alexey Popkov's user avatar
7 votes
Accepted

Can we make preread replacements in an *.m* file before being run?

No. In fact, even $PreRead is ignored when reading .m files. What you can do is define a myGet as ...
Itai Seggev's user avatar
  • 14.2k
7 votes
Accepted

Is there a system option to make Mathematica generate syntax error when reading code from file which has red syntax warning in frontend?

Using the code inspector can show you issues with the code, << CodeInspector` CodeInspect["ode=y''[x]+y[x]==Exp(2*x) DSolve[ode,y[x],x] "] This ...
Jason B.'s user avatar
  • 69.7k
6 votes
Accepted

Can we make new definitions for InputForm in packages?

Unfortunately, I don't think there is. The association between characters and symbol names is burned into the kernel (in the form of a "yacc" grammar), with complete information about associativity, ...
Itai Seggev's user avatar
  • 14.2k
5 votes

How to get the longest bracket pairs from a string

Not a regular expression but counting the left and right separators to find positions where they're equal in number can find top level bracket pairs: ...
V.E.'s user avatar
  • 1,720
5 votes

Pulling Out Values from JSON Association

First of all, I think you can make your life a bit easier by using RawJSON as input format specification. It basically makes Mathematica use Associations where appropriate when importing JSON. ...
Samuel Novák's user avatar
5 votes

How to convert a string having nested parentheses into an expression?

In your example you need [] if and only if two letters precede. If that fact extends to the generel case, then ...
Coolwater's user avatar
  • 20.4k
5 votes

What is the best way to parse differential equations and boundary conditions to a custom function?

Here's a simpler way (simpler than my first answer) that I came up with today exploring a problem with DSolve. It calls ...
Michael E2's user avatar
  • 241k
4 votes
Accepted

Parse command line arguments

The DSL perspective As it is discussed in the comments, the question can be seen as parsing of a particular DSL in WL. Direct implementation This notebook screenshot image shows a direct ...
Anton Antonov's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible