Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

str_item and other syntactic elements with Nils are not very usable #5387

Closed
vicuna opened this issue Oct 26, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented Oct 26, 2011

Original bug ID: 5387
Reporter: furuse
Assigned to: @diml
Status: closed (set by @xavierleroy on 2013-08-31T10:44:07Z)
Resolution: fixed
Priority: normal
Severity: tweak
Version: 3.12.1
Fixed in version: 3.12.1+dev
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues

Bug description

<:str_item< let x = 1 >> currently represents the following data structure:

Ast.StSem (_loc,
(Ast.StVal (_loc, Ast.ReNil,
(Ast.BiEq (_loc, (Ast.PaId (_loc, (Ast.IdLid (_loc, "x")))),
(Ast.ExInt (_loc, "1")))))),
(Ast.StNil _loc))

The phrase is not parsed as one str_item but a list of str_items. This makes it impossible to use <:str_item< .. >> as a constructor/pattern for one single str_item.

I do not know what is the best solution, but Jake Donham has seen the same issue and written a nice blog entry. It contains a workaround: http://ambassadortothecomputers.blogspot.com/2010/03/reading-camlp4-part-5-filters.html

@vicuna

This comment has been minimized.

Copy link
Author

commented Oct 26, 2011

Comment author: furuse

Some more info. For example, the following pattern

function
| <:str_item< module $modname$ = struct $sitems$ end >> -> ...

never matches with code like:

module M = struct ... end

Since the former is StSem(.., StNil ..) but the latter lacks StNil.

@vicuna

This comment has been minimized.

Copy link
Author

commented Jan 5, 2012

Comment author: @diml

Fixed for str_item, sig_item, class_str_item and class_sig_item.

Now Ast.*Nil is not added when the quotation contains only one item.

Commits 11985, 11986, 11987 and 11988.

@vicuna vicuna closed this Aug 31, 2013

@vicuna vicuna added the camlp4 label Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.