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

Stratego signature generation fails with string literals in context-free syntax #18

Closed
RvanBaarle opened this issue Jul 16, 2021 · 1 comment
Assignees

Comments

@RvanBaarle
Copy link
Contributor

Using string or character literals in context-free syntax causes the build to fail on signature generation. Such as the following example:

module start

context-free start-symbols

  Start

context-free sorts

  Start
  Word

context-free syntax

  Start.Empty = <>
  Start.Program = Word*
  Word.Hello = "Hello"  // Does not work
  Word.World = <World>  // Templates do work
  
syntax
  Word-CF.DoubleQuotedWord =  "\"" Word-CF "\""  // Does not work
  Word-CF.QuotedWord = QUOTE-CF Word-CF QUOTE-CF // Does work

lexical sorts
  QUOTE

lexical syntax
  QUOTE = "'"

  LAYOUT = [\ \n\v\f\r]

context-free restrictions

  LAYOUT? -/- [\ \n\v\f\r]

This example produces the following error (Note the occurences of nabl2.Var("./src/start.sdf3", "y_1-..."){OfSort(SORT("TYPE"))} in the AST):

ERROR: Could not check Stratego because it could not be configured
  Exception of message: mb.spoofax.lwb.compiler.stratego.StrategoConfigureExceptions$Sdf3SignatureGenerateFail: SDF3 to signature generator failed
  Caused by: mb.stratego.common.StrategoExceptions$StrategyFail: Invoking Stratego strategy 'pp-stratego-string' failed 
Stratego stack trace:
	abox2text_list_1_2
	abox2text_1_2
	abox2text_0_1
	box2text_string_0_1
	pp_stratego_string_0_0
	pp_stratego_string_0_0
Stratego input term:
Module(
  "signatures/start-sig"
, [ Imports([Import("libstratego-lib")])
  , Signature(
      [ Sorts([SortNoArgs("Start"{TermIndex("./src/start.sdf3", 12)}), SortNoArgs("Word"{TermIndex("./src/start.sdf3", 14)})]{TermIndex("./src/start.sdf3", 19)})
      , Sorts([SortNoArgs("QUOTE"{TermIndex("./src/start.sdf3", 154)})]{TermIndex("./src/start.sdf3", 158)})
      , Constructors(
          [ OpDecl("Empty"{TermIndex("./src/start.sdf3", 24)}, ConstType(SortNoArgs("Start"{TermIndex("./src/start.sdf3", 22)})))
          , OpDecl(
              "Program"{TermIndex("./src/start.sdf3", 41)}
            , FunType(
                [ConstType(Sort("List", [ConstType(SortNoArgs("Word"{TermIndex("./src/start.sdf3", 72)}))]))]
              , ConstType(SortNoArgs("Start"{TermIndex("./src/start.sdf3", 39)}))
              )
            )
          , OpDecl(
              "Hello"{TermIndex("./src/start.sdf3", 58)}
            , FunType([nabl2.Var("./src/start.sdf3", "y_1-225"){OfSort(SORT("TYPE"))}], ConstType(SortNoArgs("Word"{TermIndex("./src/start.sdf3", 56)})))
            )
          , OpDecl("World"{TermIndex("./src/start.sdf3", 74)}, ConstType(SortNoArgs("Word"{TermIndex("./src/start.sdf3", 72)})))
          , OpDecl("Start-Plhdr", ConstType(SortNoArgs("Start")))
          , OpDecl("Word-Plhdr", ConstType(SortNoArgs("Word")))
          , OpDecl(
              "Start-Plhdr"
            , FunType([ConstType(SortNoArgs("COMPLETION-INSERTION"))], ConstType(SortNoArgs("Start")))
            )
          , OpDecl(
              "Word-Plhdr"
            , FunType([ConstType(SortNoArgs("COMPLETION-INSERTION"))], ConstType(SortNoArgs("Word")))
            )
          , OpDecl("Start-Opt-Plhdr", ConstType(SortNoArgs("Start")))
          , OpDecl("Word-Opt-Plhdr", ConstType(SortNoArgs("Word")))
          , OpDecl(
              "DoubleQuotedWord"{TermIndex("./src/start.sdf3", 103)}
            , FunType(
                [nabl2.Var("./src/start.sdf3", "y_1-139"){OfSort(SORT("TYPE"))}, ConstType(SortNoArgs("Word"{TermIndex("./src/start.sdf3", 72)})), nabl2.Var("./src/start.sdf3", "y_1-147"){OfSort(SORT("TYPE"))}]
              , ConstType(SortNoArgs("Word"{TermIndex("./src/start.sdf3", 100)}))
              )
            )
          , OpDecl(
              "QuotedWord"{TermIndex("./src/start.sdf3", 126)}
            , FunType(
                [ConstType(SortNoArgs("QUOTE"{TermIndex("./src/start.sdf3", 161)})), ConstType(SortNoArgs("Word"{TermIndex("./src/start.sdf3", 72)})), ConstType(SortNoArgs("QUOTE"{TermIndex("./src/start.sdf3", 161)}))]
              , ConstType(SortNoArgs("Word"{TermIndex("./src/start.sdf3", 123)}))
              )
            )
          , OpDecl("Word-Plhdr", ConstType(SortNoArgs("Word")))
          , OpDecl("QUOTE-Plhdr", ConstType(SortNoArgs("QUOTE")))
          , OpDecl(
              "Word-Plhdr"
            , FunType([ConstType(SortNoArgs("COMPLETION-INSERTION"))], ConstType(SortNoArgs("Word")))
            )
          , OpDecl(
              "QUOTE-Plhdr"
            , FunType([ConstType(SortNoArgs("COMPLETION-INSERTION"))], ConstType(SortNoArgs("QUOTE")))
            )
          , OpDeclInj(FunType([SortVar("string")], ConstType(SortNoArgs("QUOTE"{TermIndex("./src/start.sdf3", 161)}))))
          ]
        )
      ]
    )
  ]
)
@Gohla Gohla self-assigned this Jul 16, 2021
@Gohla
Copy link
Member

Gohla commented Jul 16, 2021

Fixed in metaborg/sdf@eafe4ac

@Gohla Gohla closed this as completed Jul 16, 2021
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