-
Notifications
You must be signed in to change notification settings - Fork 157
ANTLR Usage
We use antlr4 in two places:
- generating UCUM lexer/parser
- generating FHIRPath lexer/parser and visitor
Steps to regenerate:
-
Download the latest antlr4 "Complete Java binaries jar" from https://www.antlr.org/download.html
-
(Optional) Follow their getting started doc to set up an alias for
antlr4
-
Execute antlr4 with the proper options for our two projects
Sample commands that generate the java classes, replace tabs with spaces, and move them to the proper locations:
antlr4 -no-listener -package org.linuxforhealth.fhir.model.ucum fhir-model/UCUM.g4
&& sed -i.bak $'s/\t/ /g' fhir-model/UCUM*.java && mv
fhir-model/UCUM*.java fhir-model/src/main/java/org/linuxforhealth/fhir/model/ucum/
antlr4 -visitor -no-listener -package org.linuxforhealth.fhir.path fhir-path/FHIRPath.g4 &&
sed -i.bak $'s/\t/ /g' fhir-path/FHIRPath*.java && mv
fhir-path/FHIRPath*.java fhir-path/src/main/java/org/linuxforhealth/fhir/path/
- Add our copyright / license header (required to pass checkstyle rules) and save the files with "organize imports" and "strip trailing whitespace" save actions to reduce noise in the PR
FHIR® is the registered trademark of HL7 and is used with the permission of HL7. Use of the FHIR trademark does not constitute endorsement of this product by HL7.
IBM and the IBM logo are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on ibm.com/trademark.