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 ...
16
votes
How can I ingest and analyze benchmark results posted at MSE?
Ingestion
Get all answers from MSE discussion in an XML object:
...
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 ...
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 ...
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, ...
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.
...
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:
...
11
votes
Accepted
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
...
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-...
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
...
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 ...
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. ...
10
votes
Accepted
Validate `Box` grammar, is it possible?
You may try using MathLink`CallFrontEnd[FrontEnd`ReparseBoxStructurePacket[...]].
...
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 ...
9
votes
Accepted
Context inside Do[...]-loop
Begin["mycontext`"] affects the parser, not the evaluator.
These are separate expressions:
Begin["mycontext`"];
...
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 ...
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:
...
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 ...
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
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
...
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 ...
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, ...
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:
...
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.
...
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
...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
parsing × 92string-manipulation × 16
import × 13
front-end × 10
bugs × 8
xml × 8
syntax × 7
pattern-matching × 6
packages × 5
streams × 5
data × 4
formatting × 4
expression-manipulation × 4
command-line × 4
html × 4
regular-expressions × 4
json-format × 4
performance-tuning × 3
replacement × 3
customization × 3
text × 3
web-access × 3
contexts × 3
boxes × 3
input-forms × 3