Skip to content

Parsing broken on quasi quotes #323

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

Closed
s9gf4ult opened this issue Aug 20, 2014 · 10 comments · Fixed by #909
Closed

Parsing broken on quasi quotes #323

s9gf4ult opened this issue Aug 20, 2014 · 10 comments · Fixed by #909

Comments

@s9gf4ult
Copy link

for example, if I enter something like this

func = do 
    r <- withPG $ \con -> query con [sql|
select codes.user_id, aps.client_id
from authorization_codes as codes inner join applications as aps on codes.application_id = aps.id
where codes.access_token = ? and (codes.expires > now() or codes.expires is null)|]
                             [token]
    doSomething -- Indentation broken from this line with "parser error" message
    doMore

quasi quotes must be considered as strings, but they are considered as usual Haskell code. Maybe you can suggest how to solve it? I hope it is not very hard to solve this.

@s9gf4ult s9gf4ult changed the title Parsing breaks on quasi quoting Parsing broken on quasi quoting Aug 20, 2014
@s9gf4ult s9gf4ult changed the title Parsing broken on quasi quoting Parsing broken on quasi quotes Aug 20, 2014
@s9gf4ult
Copy link
Author

bump

@gracjan
Copy link
Contributor

gracjan commented Mar 27, 2015

True. This should not be that hard:

  • mark opening bracket as generic string
  • mark closing bracket as generic string
  • fontify as string or maybe something special

@s9gf4ult
Copy link
Author

Yes, but how? I am not familiar with Emacs's parsing stuff and especially how and where it used in haskell-mode

@gracjan
Copy link
Contributor

gracjan commented Mar 28, 2015

You should look at haskell-basic-syntactic-keywords in haskell-font-lock.el and understand what is going on there with double-quoted strings and single-quoted character literals. That is the hard part.

Quasi-quotes are basically string literals so you need to put "|" char class on opening bracket and on the closing bracket.

(Note additional issues with multiline. If you get the single line case working then we can convert it to multiline case later).

Relevant documentation starts about here: https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Class-Table.html

@s9gf4ult
Copy link
Author

s9gf4ult commented Apr 1, 2015

But operator || becomes string starter in this case.

String must be started at pattern, matching to regexp \[[a-zA-Z]*\| and ended at string |]. Is there such posibility?

@gracjan
Copy link
Contributor

gracjan commented Apr 1, 2015

More exactly the char [ should be marked as generic string and then the last ']' should be also marked as generic string.

The char | does not change its meaning. The syntax code | means generic string and it is given to brackets. Sorry for the confusion.

(Note: some quasiquotes like e, d, t are actually Haskell so it might be good to use paired delimiters $ syntax class).

@s9gf4ult
Copy link
Author

s9gf4ult commented Apr 2, 2015

If I understand you correctly, you propose make Emacs consider any symbols between [ and ] as generic string. This means that usual Haskell lists like

[1,2,3]

and list comprehensions like

[(i,j) | i <- [1,2], j <- [1..4]]

become "strings" also, which is unacceptable.

@gracjan
Copy link
Contributor

gracjan commented Apr 2, 2015

@s9gf4ult: This is not at all what I propose. Please have a look at documentation for variable font-lock-syntactic-keywords so that you understand how emacs puts syntactic properties on characters in a buffer.

@geraldus
Copy link
Contributor

@gracjan this looks irrelevant.

@gracjan
Copy link
Contributor

gracjan commented Jun 18, 2015 via email

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

Successfully merging a pull request may close this issue.

3 participants