Nothing Special   »   [go: up one dir, main page]

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

Make backends more resilient against keyword and Prelude clashes #278

Closed
10 tasks done
andreasabel opened this issue Dec 16, 2019 · 3 comments
Closed
10 tasks done
Assignees
Milestone

Comments

@andreasabel
Copy link
Member
andreasabel commented Dec 16, 2019

OP: Haskell: Printer: variable name "pattern" might clash with PatternSynonyms language extension.

Prg. Program ::= Pattern;
PVar. Pattern ::= Ident;

creates Haskell printer containing:

instance Print Test.Abs.Program where
  prt i e = case e of
    Test.Abs.Prg pattern -> prPrec i 0 (concatD [prt 0 pattern])

However, pattern is a Haskell keyword when using {-# LANGUAGE PatternSynonyms #-}.

When trying to get a test case through that has one category for each keyword of each backend target, I notice a number of related issues:

  • Haskell abstract syntax: avoid Prelude clashes
  • Haskell template: import Abs module qualified to avoid clashes
  • Haskell parser: import Abs qualified
  • Agda AST: import Abs qualified in COMPILE pragmas
  • Haskell/GADT: same as Haskell
  • C: clash of user-defined category Int with token type int in parser
  • C++: same as C
  • Ocaml: refer to abstract syntax qualified in print/show
  • Java: qualified absyn, names need to be unique modulo case (case insensitive file systems!)
  • Java/ANTLR: labels for alternatives may clash with rule names
@andreasabel andreasabel added Haskell printer Concerning the generated printer labels Dec 16, 2019
@andreasabel andreasabel added this to the 2.8.4 milestone Dec 16, 2019
@andreasabel andreasabel self-assigned this Dec 16, 2019
@andreasabel andreasabel changed the title Haskell: Printer: variable name "pattern" might clash with PatternSynonyms language extension Make backends more resiliant againt keyword and Prelude clashes Dec 16, 2019
@andreasabel andreasabel changed the title Make backends more resiliant againt keyword and Prelude clashes Make backends more resilient againt keyword and Prelude clashes Dec 16, 2019
@andreasabel andreasabel changed the title Make backends more resilient againt keyword and Prelude clashes Make backends more resilient against keyword and Prelude clashes Dec 16, 2019
andreasabel added a commit that referenced this issue Dec 16, 2019
andreasabel added a commit that referenced this issue Dec 16, 2019
andreasabel added a commit that referenced this issue Dec 16, 2019
Abs      : import Prelude qualified
Par/Skel : import Abs qualified

The printer already used qualified import.
andreasabel added a commit that referenced this issue Dec 22, 2019
Allows e.g. to use Boolean and Object as category names.

Visitors need not import the "absyn" package, as they only refer to the
syntax classes in a qualified way.

In "absyn", we refer to Object as "java.lang.Object".
andreasabel added a commit that referenced this issue Dec 22, 2019
Also fixes in VisitSkel:
- A layout problem: missing newlines between methods of a visitor.
- New: calls to "accept" in for-loops.
andreasabel added a commit that referenced this issue Dec 22, 2019
On case insensitive file systems, we cannot have public java classes
that are only distinguished by case.  Thus, report an error for clashes
modulo case, e.g. between Foo and FOO:

  Foo.  FOO ::= "foo" ;
andreasabel added a commit that referenced this issue Dec 25, 2019
Patched the generation of show and printing functions for abstract
syntax to refer qualified to the abstract syntax module.
andreasabel added a commit that referenced this issue Dec 25, 2019
Using _int instead of int_ avoids the clash with a user-defined category
"Int".
@andreasabel
Copy link
Member Author

Ocamlyacc can currently only handle 127 entry points correctly, see ocaml/ocaml#9207, less than the test case produces.

andreasabel added a commit that referenced this issue Dec 25, 2019
andreasabel added a commit that referenced this issue Dec 27, 2019
This backend does not like constructor name schema

  Foo_ . Foo ::= ...

since it uses Foo_ as tag for data type Foo.

  Foo = Tree Foo_
andreasabel added a commit that referenced this issue Dec 27, 2019
Use Prelude qualified in Abs module.
Use Abs module qualified in Skel module.
@andreasabel
Copy link
Member Author

Menhir also crashes on this testcase, see https://gitlab.inria.fr/fpottier/menhir/issues/31.

andreasabel added a commit that referenced this issue Jan 2, 2020
andreasabel added a commit that referenced this issue Jan 3, 2020
andreasabel added a commit that referenced this issue Jan 3, 2020
We already test for keywords in #278, why not for "i" as well?
andreasabel added a commit that referenced this issue Jan 3, 2020
When translating `define`d constructors to Haskell, we need to refer to
the native AST constructors in a qualified way (after the changes
introduced in #278).
@andreasabel
Copy link
Member Author

Both ocamlyacc (shipped with ocaml 4.11.1) and menhir (20200624, my birthday version) are up to the task now.

andreasabel added a commit that referenced this issue Feb 14, 2021
The generated Test.hs file lacks imports, regressions introduced by
work on #331 and #278.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant