all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Sample functions for String Parsers in Lisp
@ 2009-10-13 10:34 Nordlöw
  2009-10-13 12:47 ` Pascal J. Bourguignon
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nordlöw @ 2009-10-13 10:34 UTC (permalink / raw)
  To: help-gnu-emacs

Has anybody any good sample code in elisp that shows how to
conveniently do parsing of code contained in a string?

Reason: I am writing a parser that converts Emacs regexps (back) into
rx expressions. I need this for my file magic pattern matcher in order
to read as little data as possible from the file (locality) and do
several matchings in parallel.

I think the main loop should be string-iteration-driven using while()
and aref() and length() I presume.

Any suggestions?,
Nordlöw


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Sample functions for String Parsers in Lisp
  2009-10-13 10:34 Sample functions for String Parsers in Lisp Nordlöw
@ 2009-10-13 12:47 ` Pascal J. Bourguignon
  2009-10-13 16:19   ` Helmut Eller
  2009-10-13 23:18 ` Andreas Politz
  2009-10-14  1:59 ` LanX
  2 siblings, 1 reply; 5+ messages in thread
From: Pascal J. Bourguignon @ 2009-10-13 12:47 UTC (permalink / raw)
  To: help-gnu-emacs

Nordlöw <per.nordlow@gmail.com> writes:

> Has anybody any good sample code in elisp that shows how to
> conveniently do parsing of code contained in a string?
>
> Reason: I am writing a parser that converts Emacs regexps (back) into
> rx expressions. I need this for my file magic pattern matcher in order
> to read as little data as possible from the file (locality) and do
> several matchings in parallel.
>
> I think the main loop should be string-iteration-driven using while()
> and aref() and length() I presume.
>
> Any suggestions?,

1- Read the Dragon Book.
   http://www.amazon.com/Compilers-Principles-Techniques-Alfred-Aho/dp/0201100886

2- Use a parser generator.  
   http://cedet.sourceforge.net/info/semantic.html


-- 
__Pascal Bourguignon__


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Sample functions for String Parsers in Lisp
  2009-10-13 12:47 ` Pascal J. Bourguignon
@ 2009-10-13 16:19   ` Helmut Eller
  0 siblings, 0 replies; 5+ messages in thread
From: Helmut Eller @ 2009-10-13 16:19 UTC (permalink / raw)
  To: help-gnu-emacs

* Pascal J. Bourguignon [2009-10-13 14:47+0200] writes:

> Nordlöw <per.nordlow@gmail.com> writes:
>> Any suggestions?,
>
> 1- Read the Dragon Book.
>    http://www.amazon.com/Compilers-Principles-Techniques-Alfred-Aho/dp/0201100886
>
> 2- Use a parser generator.  
>    http://cedet.sourceforge.net/info/semantic.html

3. Use parsing expression grammars:
http://www.emacswiki.org/emacs/peg.el

Helmut


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Sample functions for String Parsers in Lisp
  2009-10-13 10:34 Sample functions for String Parsers in Lisp Nordlöw
  2009-10-13 12:47 ` Pascal J. Bourguignon
@ 2009-10-13 23:18 ` Andreas Politz
  2009-10-14  1:59 ` LanX
  2 siblings, 0 replies; 5+ messages in thread
From: Andreas Politz @ 2009-10-13 23:18 UTC (permalink / raw)
  To: help-gnu-emacs

Nordlöw <per.nordlow@gmail.com> writes:

> Reason: I am writing a parser that converts Emacs regexps (back) into
> rx expressions. I need this for my file magic pattern matcher in order
> to read as little data as possible from the file (locality) and do
> several matchings in parallel.
>
[...]

> Any suggestions?,
> Nordlöw

Yes, save yourself the headache and make the assumption, that all magic
pattern are fully contained in the first n bytes of the file.

-ap





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Sample functions for String Parsers in Lisp
  2009-10-13 10:34 Sample functions for String Parsers in Lisp Nordlöw
  2009-10-13 12:47 ` Pascal J. Bourguignon
  2009-10-13 23:18 ` Andreas Politz
@ 2009-10-14  1:59 ` LanX
  2 siblings, 0 replies; 5+ messages in thread
From: LanX @ 2009-10-14  1:59 UTC (permalink / raw)
  To: help-gnu-emacs

> Any suggestions?,
> Nordlöw

Do you speak Perl?

If yes you may wanna have a look at the structure of the YAPE module
and try to port the parser.

http://search.cpan.org/dist/YAPE-Regex-Explain/Explain.pm

IMHO you just have to get alog with the backslasheritis of elisp...

Good luck
  Rolf


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-10-14  1:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-13 10:34 Sample functions for String Parsers in Lisp Nordlöw
2009-10-13 12:47 ` Pascal J. Bourguignon
2009-10-13 16:19   ` Helmut Eller
2009-10-13 23:18 ` Andreas Politz
2009-10-14  1:59 ` LanX

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.