Skip to content

Step #5 : Compile time Query parsing with Scala Macro

sadache edited this page Oct 18, 2012 · 1 revision

Syntax error in query

DatomicCompiler.query[Args2, Args2]("""
  [ :find ?e ?n 
    :where  [ ?e :person/name ?n
            [ ?e :person/character :person.character/violent ]
  ]
"""))

gives at compile time:

[info] Compiling 1 Scala source to /Volumes/PVO/workspaces/workspace_pellucid/reactive-datomic/target/scala-2.10/test-classes...
[error] /Volumes/PVO/workspaces/workspace_pellucid/reactive-datomic/src/test/scala/DatomicCompilerSpec.scala:38: `]' expected but `[' found
[error]                   [ ?e :person/character :person.character/violent ]
[error]                   ^
[error] one error found
[error] (test:compile) Compilation failed

Syntax error in number of output arguments

DatomicCompiler.query[Args2, Args3]("""
  [ :find ?e ?n 
    :where  [ ?e :person/name ?n ]
            [ ?e :person/character :person.character/violent ]
  ]
"""))

gives at compile time:

[info] Compiling 1 Scala source to /Volumes/PVO/workspaces/workspace_pellucid/reactive-datomic/target/scala-2.10/test-classes...
[error] /Volumes/PVO/workspaces/workspace_pellucid/reactive-datomic/src/test/scala/DatomicCompilerSpec.scala:35: Expected 2 OUTPUT variables in the query
[error]       DatomicCompiler.query[Args2, Args3]("""
[error]                                    ^
[error] one error found
[error] (test:compile) Compilation failed
[error] Total time: 3 s, completed 18 oct. 2012 09:25:25