caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Soegtrop, Michael" <michael.soegtrop@intel.com>
To: "syshen@nudt.edu.cn" <syshen@nudt.edu.cn>
Cc: caml-list <caml-list@inria.fr>
Subject: RE: [Caml-list] [OCAML]:: how to switch buffer in ocamllex?
Date: Wed, 9 Dec 2015 08:42:33 +0000	[thread overview]
Message-ID: <0F7D3B1B3C4B894D824F5B822E3E5A172CE49142@IRSMSX102.ger.corp.intel.com> (raw)
In-Reply-To: <13dd7e2d.1043.1518465adb0.Coremail.syshen@nudt.edu.cn>

[-- Attachment #1: Type: text/plain, Size: 3258 bytes --]

Desr Shen,

I have a working parser for a subset of analog Verilog in Menhir. I haven’t worked with ocamlyacc but compared to C yacc or bison, Menhir is quite user friendly, e.g. the capability to explain conflicts. This gave me sufficient insight to slightly change the productions (not the grammar!) such that it is acceptable to Menhir. Unfortunately I cannot share my parser, but if you name the specific production rules you have issues with, I might be able to help.

Best regards,

Michael


From: 沈胜宇 [mailto:syshen@nudt.edu.cn]
Sent: Wednesday, December 09, 2015 2:41 AM
To: Soegtrop, Michael
Cc: caml-list
Subject: Re: RE: [Caml-list] [OCAML]:: how to switch buffer in ocamllex?


I have resolved it, and I have a further question:

I am developing a parser with ocamllex and ocamyacc for verilog language.

But I find the BNF include some rules that beyond the LA(1), so how to result this ?

Shen


-----原始邮件-----
发件人: "Soegtrop, Michael" <michael.soegtrop@intel.com<mailto:michael.soegtrop@intel.com>>
发送时间: 2015-11-25 22:24:57 (星期三)
收件人: ??? <syshen@nudt.edu.cn<mailto:syshen@nudt.edu.cn>>, caml-list <caml-list@inria.fr<mailto:caml-list@inria.fr>>
抄送:
主题: RE: [Caml-list] [OCAML]:: how to switch buffer in ocamllex?
Dear Shen,

the technique I typically use is to define a preprocessor, which sits in between the lexer and the parser. It provides the same interface to the parser as a lexer and takes your lexer at the other end. Your lexer also includes preprocessor tokens. The preprocessor usually just forwards tokens from the lexer to the parser, but it intercepts preprocessor tokens and then creates e.g. a new instance of the lexer to read from an include file or plays back token from a define. When the preprocessor receives an EOF token from an include file, it closes the include lexer and switches back to the main lexer. So typically the preprocessor maintains a stack of lexers. The advantage compared to messing around inside of the lexer is that it is clearer and more easily reused.

Best regards,

Michael


From: caml-list-request@inria.fr<mailto:caml-list-request@inria.fr> [mailto:caml-list-request@inria.fr<mailto:caml-list-request@inria.fr>] On Behalf Of ???
Sent: Wednesday, November 25, 2015 3:04 PM
To: caml-list
Subject: [Caml-list] [OCAML]:: how to switch buffer in ocamllex?

Dear all:

I am using ocamllex to write a lexer, the language I am analyzing have "include" mechanism that refer to another file.

So how can I open the refered file and switch to it in ocamllex?

Shen

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de<http://www.intel.de>
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

[-- Attachment #2: Type: text/html, Size: 10814 bytes --]

  parent reply	other threads:[~2015-12-09  8:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 14:04 沈胜宇
2015-11-25 14:24 ` Soegtrop, Michael
     [not found]   ` <13dd7e2d.1043.1518465adb0.Coremail.syshen@nudt.edu.cn>
2015-12-09  8:42     ` Soegtrop, Michael [this message]
     [not found]       ` <1d2e3f25.10d7.15185feb280.Coremail.syshen@nudt.edu.cn>
2015-12-09 10:05         ` Soegtrop, Michael
2015-11-25 15:30 ` Gerd Stolpmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0F7D3B1B3C4B894D824F5B822E3E5A172CE49142@IRSMSX102.ger.corp.intel.com \
    --to=michael.soegtrop@intel.com \
    --cc=caml-list@inria.fr \
    --cc=syshen@nudt.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).