Questions tagged [parsing]
20 questions
12
votes
2 answers
For what languages is `syntax-ppss` appropriate?
I've been looking at a way of detecting whether point is on a comment by looking at how the current buffer is fontified.
Smartparens defines sp-point-in-comment, which relies on syntax-ppss. However, it seems that syntax-ppss and parse-partial-sexp…

Wilfred Hughes
- 6,890
- 2
- 29
- 59
9
votes
2 answers
Make forward-sexp recognize blocks defined by keywords, not just parentheses
In a language (julia) that has blocks defined by keywords such as for..end, begin..end, as well as parentheses, what is a good way to skip over such a block? Also, end is not only a block keyword, but also a valid identifier used in other…

Kirill
- 1,019
- 7
- 19
8
votes
3 answers
Split a complicated string?
Q: how do I split a complicated string when whitespace
delimiters aren't discriminating enough?
Background
I'm working with BibTeX files. I want to split an author string
of the form "first-name middle-name last-name" into its tokens.
Doing so is…

Dan
- 32,584
- 6
- 98
- 168
8
votes
4 answers
How can I find surrounding parenthesis (from emacs lisp)?
Is there a way to find out the type of the surrounding parenthesis (i.e. '(', '[' or '{') around point? For example (using | to represent point)
{ abc, | df }
should return '{', and
{ abc[ | ], 123 }
should return '['. Ideally I would like it to…

dshepherd
- 1,281
- 6
- 18
7
votes
2 answers
Elisp function to see a date for next Wednesday
Admitting up front that I am not capable of much Lisp, I have found ways to produce the current date or a number of seconds from a date, but I am looking for a simple equivalent to shell command like date -d "next wed" I believe that with the output…

David D.
- 113
- 6
7
votes
0 answers
How do I parse a simple grammar and obtain a syntax tree in Emacs lisp?
How can I construct a parse tree from a string and a simple grammar? Semantic seems very tricky, and SMIE does not seem to produce a parse tree.
Here's an example, assuming a language that looks like this:
BLAH [ FOO "aaa"; "bbb" | BAR [ "ccc" |…

Clément
- 3,924
- 1
- 22
- 37
5
votes
2 answers
What is a good strategy to locating function arguments in a buffer?
I'd like to create a few routines for manipulating function arguments in buffers, which of course requires me to first locate the arguments. Suppose that I'm operating on a buffer with a programming language with a C-like syntax, then I could…

dpritch
- 425
- 5
- 7
4
votes
5 answers
find end of string constant
I'm using a simple (re-search-forward "\"") to find the end of string constants in my buffer. This is to copy the string in a def like (defconst name1 "some string"). The problem is that string constants may contain the ?\" character if it is…

phs
- 1,095
- 6
- 13
3
votes
1 answer
How can I make `forward-sexp` handle other balanced character-pairs such as < and > or << and >>?
I am trying to find an easy and efficient way to modify the behaviour of forward-sexp to handle balanced pairs of characters not normally supported by it, such as balanced < and > and balanced << and >>.
My specific case is to enhance the support of…

PRouleau
- 744
- 3
- 10
3
votes
2 answers
Check whether a string is a date in a specific format, e.g. "%Y-%m-%d"
I have a string and would like to check whether it contains a date in a given date format, e.g. "%Y-%m-%d", with format as for format-time-string. This is for a package and users can configure the date format freely. So I cannot just hard-code a…

tmalsburg
- 2,540
- 1
- 14
- 29
3
votes
1 answer
Pretty print s expressions from the command line
I've got a file containing an emacs s-expression and I want to pretty print it from the command line: Is there an easy way of doing this? Paranoia suggests I want to do as little parsing of this data as possible
Context (stack exchange loves…

Att Righ
- 725
- 4
- 14
2
votes
2 answers
Can syntax parsing recognize the SQL '' (escape apostrophe/single quote) construct within SQL strings?
I am trying to enhance SQL mode such that editing of files of SQL code becomes more convenient, especially as far as jumping around is concerned (e.g. things like sql-goto-end-of-string etc.). I have found syntax parsing to be very useful in that,…

fsavigny
- 33
- 3
2
votes
3 answers
Split command line into a list of arguments
How do I take a string giving a shell command line such as:
"program arg1 arg2 \"long argument with spaces\" arg\\\"3"
and turn it into a list of unquoted arguments like:
("program" "arg1" "arg2" "long argument with spaces" "arg\"3")
I.e. almost…

Lassi
- 377
- 1
- 7
2
votes
0 answers
Is it possible to detect C/C++/Java variable declarations.?
I'm writing a minor mode to handle automatic spacing of operator characters, but I'm having some trouble with C/C++. The problem is that I can't figure out how to tell in general whether a * is a multiplication or a pointer type. Similarly for &,…

dshepherd
- 1,281
- 6
- 18
1
vote
1 answer
Lisp function to parse shebang line?
Before I probably re-invent the wheel, has anyone written a function (or perhaps there's one somewhere in Emacs already) to parse the shebang line of the current buffer (or some specified buffer). For example, if the first line of the buffer is…

Ed Sabol
- 141
- 6