Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Jira
serverONAP JIRA
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-376

Reference Material

IntelliJ Ant plugin 

...

Findings

  • Antlr4 can replace regex with less and more readable code
  • Replacement of regex for CpsPathQuery fully replaced by fully compatible object generated using Antlr4 this commit: https://gerrit.onap.org/r/c/cps/+/121503
  • Needed to add explicit error rule for handling unexpected tokens (otherwise Antlr would ignore them):  ErrorCharacter : . ;
  • Current CPS code using regex is inconsistent and needless limited for single leave condition
  • Current code was lac re. @ for attribute names (fixed in https://gerrit.onap.org/r/c/cps/+/121503)
  • CpsPathQuerySpec did not cover all necessary possibilities (as used in some DB integration tests) This has now been addressed 
  • CpsDataPersistenceQueryDataNodeSpec contains some grammar tests that should be (are already) in  CpsPathQuerySpec
  • IntelliJ plugin very useful for quick testing and troubleshooting of grammar
  • Not sure of best way to refresh generated code (in IntelliJ) mvn clean install in cps-path-parser seems the surest way

To-Do

  • Check and Improve error handling
  • Re-use CpsPath Exception (wrap IllegalState exception)
  • Clean up, simplify rules and remove redundant legacy limitations
  • Consider using predefined xpath grammer: https://github.com/antlr/

...