Comments (26)
Hmm. I think only quote, backslash, comma, backtick, and #'
.
from coq-serapi.
Indeed, sexplib serializes data in a particular way. The base data type, quoting from: https://github.com/janestreet/sexplib/blob/master/src/type.ml is
type t = Atom of string | List of t list
Thus, the choice is really what to do with strings!
For that, sexplib uses the code at
https://github.com/janestreet/sexplib/blob/master/src/pre_sexp.ml#L22
to guess when it should add quotes, as to make the output more "sexpy"-friendly.
Unfortunately the comma is not there, so I wonder what would the best solution be on our part; I am not an expert on S-expressions myself, but I will definitively try to bring this issue with sexplib developers.
from coq-serapi.
@cpitclaudel , do you know if this comma thing will create problems in emacs?
from coq-serapi.
Ok, a53964e should provide a more sensible escaping if --custom-escape
is passed: we now treat every Atom as a UTF-8 string. Also, naked commas should not be produced.
Would you mind testing the comma part? Thanks
from coq-serapi.
I think it will be an issue in Emacs as well, yes; ,
is taken by the lisp reader to be a reader macro expanding to unquote
.
Then again, it shouldn't be very hard to write a separate parser in list; but it would be nice to use the off-the-shelf one. The surprising thing is that Sexplib doesn't distinguish between symbols and strings.
from coq-serapi.
@cpitclaudel , any other special character we should keep in mind?
--custom-escape
should solve the comma issue. I'm happy having our own printer.
Indeed sexplib makes the choice of "symbols == strings".
from coq-serapi.
Cool thanks, I'm gonna ask upstream about the quoting. It seems that double quote and backslash are OK.
The rest don't seem OK, I'll fix them in --custom-escape
, while I get an answer from sexplib upstream.
Comma, quote, and backtick should be escaped only if at the beginning of a symbol, right?
What about #'
?
I couldn't find an elisp grammar/lexical conventions.
from coq-serapi.
How to test sexplib quoting
Install utop and sexplib using OPAM, then:
$ utop
# #require "sexplib";;
# let p x = Sexplib.Sexp.(Format.(printf "@[%a@]@\n" pp (Atom x)));;
# p ",";;
from coq-serapi.
Comma, quote, and backtick should be escaped only if at the beginning of a symbol, right?
What about #'?
No, anywhere in a symbol. Same for #'
(and there's actually #<
and ##
as well apparently, though just escaping # would fix that too.
from coq-serapi.
I wonder why sexplib doesn't simply use quotes for everything that is a string on the OCaml side, and symbols for the rest.
from coq-serapi.
What do you mean by "everything that is a string on the OCaml side" ?
For sexplib, everything is a string, so it would then print ("Control" ("StmAdd" () "Command"))
, etc...
from coq-serapi.
Is Control
a string? I thought it was the name of a constructor.
from coq-serapi.
At the sexp-level, Control
is indeed a string. Recall the sexp syntax:
type t = Atom of string | List of t list
so sexplib expressions are just possibly nested lists of strings.
from coq-serapi.
Ah, right.
Maybe it would be simpler to just quote everything?
from coq-serapi.
Maybe we should quote everything, would that be a problem for emacs?
The new printer has been committed, I will close this once I add the proper documentation.
from coq-serapi.
Quoting everything would be totally fine :)
from coq-serapi.
I no longer have a problem with (PCData ,)
, but I have a problem with (PCData fold')
.
from coq-serapi.
@Ptival understood, will fix.
from coq-serapi.
Can square braces also be quoted? In (Query () (Vernac "Print nat."))
for example, I see (Pp_string ])
which causes an error for the emacs parser.
from coq-serapi.
@riswords , sure, I'll take of it.
from coq-serapi.
Should be better now, note that we currently depend on coq/coq#822 due to them having broke its linking spec.
from coq-serapi.
See e2982c1 if you need to tweak escaping more, and of course submit a pull request!
from coq-serapi.
Great, thank you!
from coq-serapi.
NP, let me know if you have any additional trouble, note also that we have a gitter channel that may work well for concrete questions.
from coq-serapi.
Ha, just got bit by (PCData [)
and (PCData ])
myself!
from coq-serapi.
Yup at some point we'll make the custom quoting the default.
from coq-serapi.
Related Issues (20)
- Is sercomp broken in v8.16? HOT 2
- How to handle "Needs option -impredicative-set." HOT 3
- installation HOT 4
- what version of coq serapi works with coq 8.10.2? HOT 9
- what is the best version of coq-serapi that works with coq 8.12? HOT 5
- Please pick the version you prefer for Coq 8.17 in Coq Platform 2023.03 HOT 12
- Segfault on (Query () Goals) with sertop 8.15.0+0.15.3 HOT 4
- What is the purpose of coq-serapi's existance and why can't everything be done in coqtop? HOT 5
- Expose Section Variable Determining API in SerAPI HOT 6
- Incorrect goals when providing -topfile in sertop 8.10.0+0.7.2 HOT 2
- Please pick the version you prefer for Coq 8.18 in Coq Platform 2023.10 HOT 1
- Serlib testing needs to be improved.
- Missing conversion functions for types for the extraction plugin? HOT 3
- Can't run `make test` due to an error related to `eqType` HOT 4
- Windows PATH length (again) HOT 21
- macOS: serapi loads Coq .vo from compile time path HOT 5
- Run tests with MC 2 HOT 3
- Please pick the version you prefer for Coq 8.19 in Coq Platform 2024.01 HOT 5
- Segmentation fault in coq/getDocument call HOT 4
- New versioning scheme. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coq-serapi.