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

Parsec w/ T.Text #2

Closed
adamwespiser opened this issue Apr 17, 2016 · 2 comments
Closed

Parsec w/ T.Text #2

adamwespiser opened this issue Apr 17, 2016 · 2 comments

Comments

@adamwespiser
Copy link
Collaborator

@sdiehl, having problems getting the parser to work creating LispVal values of strings

gce-work:scheme$ stack build && stack exec scheme
Repl> '(a)
List [Atom "a"]
Repl> '("a")
Parser "<stdin>" (line 1, column 4):
unexpected "a"
expecting end of "\"" or literal string
Repl> '(\"a\")
Parser "<stdin>" (line 1, column 4):
unexpected '\\'
expecting end of "("

It looks like the Parsec standard lisp parser is taking a different approach: https://hackage.haskell.org/package/lispparser-0.3.1/docs/src/Text-ParserCombinators-Parsec-Lisp.html

any insight on parsing in double quoted strings from the repl into LispVal?

@sdiehl
Copy link
Contributor

sdiehl commented Apr 17, 2016

Use this in your parser

parseString :: Parser LispVal
parseString = do
  x <- strLit
  return $ String x
Repl> '("a")
List [String "a"]
Repl> "foo"
String "foo"
Repl> '("foo \"inner quote\" ")
List [String "foo \"inner quote\" "]

@adamwespiser
Copy link
Collaborator Author

that's great! see 05855b1 for working solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants