├── .gitignore ├── README.md ├── pom.xml └── src └── main ├── java ├── check │ └── Check.java ├── dao │ ├── IfcData.java │ ├── IfcFileLoader.java │ ├── IfcMetaData.java │ ├── ResultItem.java │ └── SchemaFileLoader.java ├── model │ ├── Attribute.java │ ├── Element.java │ ├── Entity.java │ ├── IfcFile.java │ └── InverseInfo.java ├── parser │ ├── ExpressGrammar.tokens │ ├── ExpressGrammarBaseVisitor.java │ ├── ExpressGrammarLexer.java │ ├── ExpressGrammarLexer.tokens │ ├── ExpressGrammarParser.java │ ├── ExpressGrammarVisitor.java │ ├── STEPGrammar.tokens │ ├── STEPGrammarBaseVisitor.java │ ├── STEPGrammarLexer.java │ ├── STEPGrammarParser.java │ └── STEPGrammarVisitor.java ├── rule │ ├── BaseRule.java │ ├── ColorRule.java │ ├── ColorSystem.java │ ├── DirectionRule.java │ ├── ExistRule.java │ └── PropertyRule.java └── util │ ├── AntlrUtil.java │ ├── ConfigReader.java │ ├── IfcDirection.java │ ├── IfcVersion.java │ ├── Inverse.java │ └── StringConverter.java └── resources ├── ExpressGrammar.g4 ├── IFC2X3.exp ├── IFC4X1.exp ├── STEPGrammar.g4 ├── colors.txt ├── excluded.txt ├── ifc4.exp └── inverse.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | target/ 3 | *.iml 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IfcGraph 2 | a project which converts IFC files to graphs in Neo4j 3 | 4 | # How to use 5 | 1. install Neo4j database 6 | 7 | 2. edit databaseDirectory in IfcData.java to the db path you want the ifc model to save 8 | 9 | 3. run main function in IfcData.java (remember to edit your ifc file path) 10 | - do it when db is closed 11 | 12 | 4. start neo4j and enjoy your ifc graph! 13 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | ifc-graph 8 | ifc-graph 9 | 1.0-SNAPSHOT 10 | 11 | 12 | org.neo4j.driver 13 | neo4j-java-driver 14 | 1.6.3 15 | 16 | 17 | org.antlr 18 | antlr4-runtime 19 | 4.7.1 20 | 21 | 22 | org.neo4j 23 | neo4j 24 | 3.4.10 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/java/check/Check.java: -------------------------------------------------------------------------------- 1 | package check; 2 | 3 | 4 | import org.neo4j.graphdb.Direction; 5 | import org.neo4j.graphdb.GraphDatabaseService; 6 | import org.neo4j.graphdb.factory.GraphDatabaseFactory; 7 | import rule.ColorRule; 8 | import rule.ColorSystem; 9 | import rule.DirectionRule; 10 | import rule.ExistRule; 11 | import util.ConfigReader; 12 | 13 | import java.io.File; 14 | import java.io.IOException; 15 | import java.util.List; 16 | 17 | public class Check { 18 | static final File databaseDirectory = new File( "D:\\Program Files\\neo4j-community-3.4.10\\data\\databases\\ifc23t.db" ); 19 | GraphDatabaseService db; 20 | 21 | public Check() { 22 | db = new GraphDatabaseFactory().newEmbeddedDatabase(databaseDirectory); 23 | } 24 | 25 | public void checkColor(String systemName, int red, int green, int blue) { 26 | String ruleContent = systemName+ " 的表面颜色为 ("+red+","+green+","+blue+")"; 27 | ColorRule color = new ColorRule(db, ruleContent, red, green, blue); 28 | //color.test(); 29 | color.checkColorForSystem(systemName); 30 | } 31 | 32 | public void checkExist(String code) { 33 | String ruleContent = "构件分类编码:"+code+"是否建模"; 34 | ExistRule exist = new ExistRule(db, ruleContent, code); 35 | System.out.println(exist.checkExistForCode().status); 36 | 37 | } 38 | 39 | public void checkExistForName(String name) { 40 | String ruleContent = "构件名称:"+name+"是否建模"; 41 | ExistRule exist = new ExistRule(db, ruleContent, name); 42 | System.out.println(exist.checkExistForName().status); 43 | 44 | 45 | } 46 | 47 | public void checkFlowDirection() { 48 | String ruleContent = "angle"; 49 | DirectionRule rule = new DirectionRule(db, ruleContent, 90); 50 | rule.checkDirection(); 51 | } 52 | 53 | public static void main(String[] args) throws IOException { 54 | long timestamp1 = System.currentTimeMillis(); 55 | 56 | Check checker = new Check(); 57 | checker.checkFlowDirection(); 58 | 59 | long timestamp2 = System.currentTimeMillis(); 60 | 61 | System.out.println("时间:"+(timestamp2-timestamp1)); 62 | //checker. 63 | // List colors = ConfigReader.readColorConfig(); 64 | // for (ColorSystem color : colors) { 65 | // checker.checkColor(color.systemName,color.red,color.green,color.blue); 66 | // } 67 | // 68 | // long timestamp2 = System.currentTimeMillis(); 69 | // System.out.println("时间:"+(timestamp2-timestamp1)); 70 | // System.out.println("规则:"+colors.size()); 71 | 72 | //checker.checkExist("10.10.20.09.20.20.30"); 73 | 74 | // checker.checkExist("30.30.10.72.10"); 75 | // checker.checkExist("10.10.20.69.05"); 76 | // checker.checkExist("10.10.70.20"); 77 | // checker.checkExist("10.10.30.03.09.12.05"); 78 | // checker.checkExist("10.10.40.10.10.30"); 79 | // checker.checkExist("10.10.40.30.12"); 80 | // checker.checkExist("10.10.10.90.15.54"); 81 | // checker.checkExist("30.40.55"); 82 | // checker.checkExist("30.40.20"); 83 | // checker.checkExist("30.30.05.89"); 84 | // checker.checkExist("10.10.20.03.09.20"); 85 | // checker.checkExist("10.10.60.15.15"); 86 | // checker.checkExist("10.10.50.01"); 87 | 88 | //checker.checkExistForName("粗装踢脚"); 89 | //checker.checkColor("SAS_送风系统",0,153,255); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/dao/IfcData.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import model.*; 4 | import model.Entity; 5 | import org.neo4j.graphdb.*; 6 | import org.neo4j.graphdb.factory.GraphDatabaseFactory; 7 | import org.neo4j.graphdb.schema.IndexDefinition; 8 | import org.neo4j.graphdb.schema.Schema; 9 | import org.neo4j.io.fs.FileUtils; 10 | 11 | import javax.management.relation.Relation; 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.util.*; 15 | import java.util.regex.Matcher; 16 | import java.util.regex.Pattern; 17 | 18 | import static org.neo4j.helpers.collection.Iterators.loop; 19 | 20 | 21 | public class IfcData { 22 | private static File databaseDirectory = new File( "D:\\Program Files\\neo4j-community-3.4.10\\data\\databases\\ifc23t.db" ); 23 | GraphDatabaseService graphDb; 24 | 25 | private IfcFile ifcFile = null; 26 | 27 | public IfcData(String filePath) throws IOException{ 28 | ifcFile = IfcFileLoader.loadIFC(filePath); 29 | } 30 | 31 | public void createDb() throws IOException 32 | { 33 | //FileUtils.deleteRecursively( databaseDirectory ); 34 | 35 | // START SNIPPET: startDb 36 | graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( databaseDirectory ); 37 | 38 | registerShutdownHook( graphDb ); 39 | long startTime=System.currentTimeMillis(); 40 | createIndexForLineId(); 41 | insertAll(ifcFile.getElementList(), ifcFile.getEntityMap()); 42 | long midTime=System.currentTimeMillis(); 43 | CreateRelation(); 44 | CreateInverseRelation(); 45 | long endTime=System.currentTimeMillis(); 46 | System.out.println("插入节点"+(midTime-startTime)); 47 | System.out.println("建立关系"+(endTime-midTime)); 48 | } 49 | 50 | // /** 51 | // * insert element to database 52 | // * @param ele element(object) to be inserted 53 | // * @param ent entity(class) that the element belongs to 54 | // */ 55 | // private void insert(Element ele, Entity ent) { 56 | // if (ele == null || ent == null || ele.getAttrs().size() != ent.getAttributes().size()) 57 | // throw new IllegalArgumentException(); 58 | // 59 | // try ( Transaction tx = graphDb.beginTx() ) 60 | // { 61 | // 62 | // Node dataNode = graphDb.createNode(); 63 | // String labelName = ent.getName(); 64 | // Label enlabel = Label.label(labelName); 65 | // dataNode.addLabel(enlabel); 66 | // dataNode.addLabel(Label.label("Element")); 67 | // 68 | // int lineId = ele.getLineID(); 69 | // dataNode.setProperty("lineId", lineId); 70 | // 71 | // List attrsElement = ele.getAttrs(); 72 | // List attrsEntity = ent.getAttributes(); 73 | // 74 | // for (int i = 0; i < attrsElement.size(); i++) { 75 | // String attr_name = attrsEntity.get(i).getName(); 76 | // String attr_value = attrsElement.get(i); 77 | // dataNode.setProperty(attr_name, attr_value); 78 | // } 79 | // tx.success(); 80 | // } 81 | // } 82 | 83 | private void insertAll(List elementList, Map map) { 84 | if (elementList == null || map == null) 85 | throw new IllegalArgumentException(); 86 | 87 | try ( Transaction tx = graphDb.beginTx() ) 88 | { 89 | for (Element ele: elementList) { 90 | Entity ent = map.get(ele.getIfcType()); 91 | 92 | if (ent == null) continue; 93 | 94 | Node dataNode = graphDb.createNode(); 95 | 96 | String labelName = ent.getName(); 97 | Label enlabel = Label.label(labelName); 98 | dataNode.addLabel(enlabel); 99 | dataNode.addLabel(Label.label("Element")); 100 | 101 | int lineId = ele.getLineID(); 102 | dataNode.setProperty("lineId", lineId); 103 | 104 | List attrsElement = ele.getAttrs(); 105 | List attrsEntity = ent.getAttributes(); 106 | 107 | for (int i = 0; i < attrsElement.size(); i++) { 108 | String attr_name = attrsEntity.get(i).getName(); 109 | String attr_value = attrsElement.get(i); 110 | dataNode.setProperty(attr_name, attr_value); 111 | } 112 | 113 | dataNode.setProperty("IfcType", labelName); 114 | } 115 | 116 | tx.success(); 117 | } 118 | } 119 | 120 | private boolean isMatch(String value) { 121 | if (value == null) throw new IllegalArgumentException(); 122 | 123 | value = value.replaceAll(" ", ""); 124 | //Pattern pattern = Pattern.compile("#[0-9]+|\\((#[0-9]+,)*#[0-9]+\\)"); 125 | Pattern pattern = Pattern.compile("#[0-9]+"); 126 | Matcher matcher = pattern.matcher(value); 127 | 128 | if (matcher.matches()) return true; 129 | 130 | if (value.startsWith("(") && value.endsWith(")")) { 131 | value = value.replaceAll("\\(|\\)", ""); 132 | String[] parts = value.split(","); 133 | for (String part: parts) { 134 | matcher = pattern.matcher(part); 135 | if (!matcher.matches()) return false; 136 | } 137 | return true; 138 | } 139 | 140 | return false; 141 | } 142 | 143 | private List getMatchList(String value) { 144 | if (value == null) throw new IllegalArgumentException(); 145 | 146 | List result = new ArrayList<>(); 147 | 148 | Pattern pattern = Pattern.compile("#[0-9]+"); 149 | Matcher matcher = pattern.matcher(value); 150 | while (matcher.find()) { 151 | String str = matcher.group(); 152 | result.add(str); 153 | } 154 | return result; 155 | } 156 | 157 | private void CreateRelation() { 158 | try ( Transaction tx = graphDb.beginTx() ) { 159 | Label label = Label.label("Element"); 160 | for (Node node : loop(graphDb.findNodes(label))) { 161 | Iterator propsIter = node.getPropertyKeys().iterator(); 162 | 163 | 164 | while (propsIter.hasNext()) { 165 | String key = propsIter.next(); 166 | Object value = node.getProperty(key); 167 | 168 | if (value instanceof String && isMatch((String) value)) { 169 | //System.out.println(value); 170 | List matched = getMatchList((String) value); 171 | 172 | for (String matchedId: matched) { 173 | Node nodeToConnect = findNodeByLineId(matchedId); 174 | //System.out.println(key); 175 | // some ifc instances is excluded i.e. IfcCurve 176 | if (nodeToConnect != null) { 177 | node.createRelationshipTo(nodeToConnect, RelationshipType.withName(key)); 178 | //RelationshipType.withName(key); 179 | } 180 | } 181 | } 182 | } 183 | } 184 | tx.success(); 185 | } 186 | 187 | } 188 | 189 | private void CreateInverseRelation() { 190 | Set inverseInfos = ifcFile.getInverseInfoSet(); 191 | 192 | for (InverseInfo info: inverseInfos) { 193 | 194 | try (Transaction tx = graphDb.beginTx()) { 195 | Iterator iter = graphDb.findNodes(Label.label(info.ifcRelType)); 196 | while (iter.hasNext()) { 197 | Node node = iter.next(); 198 | 199 | Iterable rels = node.getRelationships(RelationshipType.withName(info.attrName)); 200 | Iterable rels2 = node.getRelationships(RelationshipType.withName(info.attrNameOther)); 201 | 202 | //direction1 inverse created 203 | if (!info.invName.equals("None")) { 204 | for (Relationship rel : rels) { 205 | Node startNode = rel.getEndNode(); 206 | for (Relationship rel2: rels2) { 207 | Node endNode = rel2.getEndNode(); 208 | startNode.createRelationshipTo(endNode, RelationshipType.withName(info.invName)); 209 | } 210 | } 211 | } 212 | 213 | //direction2 inverse created 214 | if (!info.invNameOther.equals("None")) { 215 | for (Relationship rel: rels2) { 216 | Node startNode = rel.getEndNode(); 217 | for (Relationship rel2: rels) { 218 | Node endNode = rel2.getEndNode(); 219 | startNode.createRelationshipTo(endNode, RelationshipType.withName(info.invNameOther)); 220 | } 221 | } 222 | } 223 | 224 | //delete IfcRelation Node 225 | Iterable all_rels = node.getRelationships(); 226 | for (Relationship rel: all_rels) rel.delete(); 227 | node.delete(); 228 | 229 | tx.success(); 230 | 231 | } 232 | } 233 | } 234 | } 235 | 236 | private Node findNodeByLineId(String matched) { 237 | matched = matched.replaceAll("#", ""); 238 | int lineID = Integer.parseInt(matched); 239 | Label label = Label.label("Element"); 240 | 241 | try (Transaction tx = graphDb.beginTx(); ResourceIterator ele = graphDb.findNodes( label, "lineId", lineID )) { 242 | Node first = null; 243 | if ( ele.hasNext() ) 244 | { 245 | first = ele.next(); 246 | } 247 | ele.close(); 248 | tx.success(); 249 | return first; 250 | } 251 | } 252 | 253 | private void createIndexForLineId() { 254 | IndexDefinition indexDefinition; 255 | Label element = Label.label("Element"); 256 | try ( Transaction tx = graphDb.beginTx() ) 257 | { 258 | Schema schema = graphDb.schema(); 259 | indexDefinition = schema.indexFor( element ) 260 | .on( "lineId" ) 261 | .create(); 262 | tx.success(); 263 | System.out.println("index success"); 264 | } 265 | } 266 | 267 | 268 | 269 | public void shutDown() 270 | { 271 | System.out.println(); 272 | System.out.println( "Shutting down database ..." ); 273 | // START SNIPPET: shutdownServer 274 | graphDb.shutdown(); 275 | // END SNIPPET: shutdownServer 276 | } 277 | 278 | // START SNIPPET: shutdownHook 279 | private static void registerShutdownHook( final GraphDatabaseService graphDb ) 280 | { 281 | // Registers a shutdown hook for the Neo4j instance so that it 282 | // shuts down nicely when the VM exits (even if you "Ctrl-C" the 283 | // running application). 284 | Runtime.getRuntime().addShutdownHook( new Thread() 285 | { 286 | @Override 287 | public void run() 288 | { 289 | graphDb.shutdown(); 290 | } 291 | } ); 292 | } 293 | 294 | public static void main(String[] args) throws IOException { 295 | //String path = "src\\main\\resources\\ifc4.exp"; 296 | long startTime=System.currentTimeMillis(); 297 | //IfcData meta = new IfcData("E:\\1万达\\model-update\\WDGC-Q-PL-B01-n.ifc"); 298 | //IfcData meta = new IfcData("E:\\1万达\\model-update\\WDGC-Q-AC-B01-update.ifc"); 299 | IfcData meta = new IfcData("E:\\1万达\\模型\\SampleHouse2.ifc"); 300 | //IfcData meta = new IfcData("E:\\1万达\\模型\\WDGC-Q-AR-B01.ifc"); 301 | //IfcData meta = new IfcData("E:\\1万达\\模型\\WDGC-Q-EL-B01-ELC.ifc"); 302 | //IfcData meta = new IfcData("E:\\\\1labdata\\\\IFC文件\\\\qhzf.ifc"); 303 | long midTime=System.currentTimeMillis(); 304 | System.out.println("加载文件"+(midTime-startTime)); 305 | //IfcData meta = new IfcData("E:\\\\1labdata\\\\IFC文件\\\\qhzf.ifc"); 99176ms 306 | meta.createDb(); 307 | long endTime=System.currentTimeMillis(); //获取结束时间 308 | System.out.println("程序运行时间: "+(endTime-startTime)+"ms"); 309 | meta.shutDown(); 310 | 311 | } 312 | } 313 | -------------------------------------------------------------------------------- /src/main/java/dao/IfcFileLoader.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import model.Element; 4 | import model.Entity; 5 | import model.IfcFile; 6 | import model.InverseInfo; 7 | import org.antlr.v4.runtime.tree.ParseTree; 8 | import parser.STEPGrammarBaseVisitor; 9 | import parser.STEPGrammarParser; 10 | import util.*; 11 | 12 | 13 | import java.io.*; 14 | import java.util.*; 15 | 16 | import static util.AntlrUtil.getSTEPGrammarParser; 17 | 18 | public class IfcFileLoader extends STEPGrammarBaseVisitor { 19 | private Element curElement = null; 20 | private List elementList = new ArrayList<>(); 21 | private String modelName; 22 | private IfcVersion schemaType; 23 | private List entityList; 24 | private Map entityMap = new HashMap(); 25 | private Set exclude; 26 | private Set inverseInfos; 27 | 28 | public int cnt = 0; 29 | 30 | public IfcFileLoader() throws IOException{ 31 | 32 | exclude = ConfigReader.readExcluded(); 33 | inverseInfos = ConfigReader.readInverseConfig(); 34 | 35 | } 36 | 37 | public static IfcFile loadIFC(String filePath) throws IOException{ 38 | 39 | String header = getStepHeader(filePath); 40 | 41 | STEPGrammarParser parser = getSTEPGrammarParser(header); 42 | ParseTree tree = parser.header(); 43 | 44 | IfcFileLoader loader = new IfcFileLoader(); 45 | loader.visit(tree); 46 | parseDataLine(filePath, loader); 47 | IfcFile file = new IfcFile(loader.modelName, loader.schemaType, loader.elementList, loader.entityMap, loader.inverseInfos); 48 | 49 | return file; 50 | } 51 | 52 | public static void parseDataLine(String filePath, IfcFileLoader loader) throws IOException { 53 | File file = new File(filePath); 54 | BufferedReader reader = new BufferedReader(new FileReader(file)); 55 | String line; 56 | while ((line = reader.readLine()) != null) 57 | { 58 | line = line.trim(); 59 | if(line.startsWith("#")) { 60 | STEPGrammarParser parser = getSTEPGrammarParser(line); 61 | ParseTree tree = parser.dataLine(); 62 | loader.visit(tree); 63 | } 64 | } 65 | } 66 | 67 | public static String getStepHeader(String filePath) throws IOException { 68 | 69 | File file = new File(filePath); 70 | BufferedReader reader = new BufferedReader(new FileReader(file)); 71 | String line; 72 | String header = ""; 73 | while ((line = reader.readLine()) != null) 74 | { 75 | line = line.trim(); 76 | if (line.endsWith("ENDSEC;")) 77 | break; 78 | header += line; 79 | } 80 | int startIndex = header.indexOf("HEADER;"); 81 | header = header.substring(startIndex); 82 | header = header + "ENDSEC;"; 83 | return header; 84 | } 85 | 86 | 87 | 88 | @Override 89 | public Void visitFilename(STEPGrammarParser.FilenameContext ctx) { 90 | modelName = ctx.STRING().getText(); 91 | return null; 92 | } 93 | 94 | @Override 95 | public Void visitFileschema(STEPGrammarParser.FileschemaContext ctx){ 96 | String schemaName = ctx.STRING().getText().toUpperCase(); 97 | IfcMetaData metaData = null; 98 | if (schemaName.equals("\'IFC2X3\'")) { 99 | SchemaFileLoader schema = SchemaFileLoader.getSchemaLoader("src\\main\\resources\\IFC2X3.exp"); 100 | entityList = schema.getEntityList(); 101 | schemaType = IfcVersion.IFC2X3; 102 | 103 | metaData = new IfcMetaData(entityList, schema.getSelectType()); 104 | } 105 | if (schemaName.equals("\'IFC4\'")) { 106 | SchemaFileLoader schema = SchemaFileLoader.getSchemaLoader("src\\main\\resources\\ifc4.exp"); 107 | entityList = schema.getEntityList(); 108 | schemaType = IfcVersion.IFC4; 109 | 110 | metaData = new IfcMetaData(entityList, schema.getSelectType()); 111 | } 112 | if (schemaName.equals("\'IFC4X1\'")) { 113 | SchemaFileLoader schema = SchemaFileLoader.getSchemaLoader("src\\main\\resources\\IFC4X1.exp"); 114 | entityList = schema.getEntityList(); 115 | schemaType = IfcVersion.IFC4X1; 116 | 117 | metaData = new IfcMetaData(entityList, schema.getSelectType()); 118 | } 119 | try { 120 | metaData.createDb(); 121 | metaData.shutDown(); 122 | } catch (IOException ex) { 123 | ex.printStackTrace(); 124 | } 125 | 126 | for (Entity entity: entityList) { 127 | entityMap.put(entity.getName().toUpperCase(), entity); 128 | } 129 | return null; 130 | } 131 | 132 | @Override 133 | public Void visitDataLine(STEPGrammarParser.DataLineContext ctx) { 134 | 135 | int lineId = Integer.parseInt(ctx.INT().getText()); 136 | String type = ctx.typedListArgument().NAME().getText(); 137 | 138 | if (exclude.contains(type)) return null; 139 | 140 | cnt++; 141 | curElement = new Element(type, lineId); 142 | 143 | int childCnt = ctx.typedListArgument().argumentList().getChildCount(); 144 | for (int i = 0; i < childCnt; i++) { 145 | String attr = ctx.typedListArgument().argumentList().getChild(i).getText(); 146 | if (!attr.equals(",")) { 147 | //unwrap IFCTEXT, IFCREAL等基本类型 148 | if (attr.startsWith("IFC")) { 149 | attr = StringConverter.unwrap_primitive(attr); 150 | } else if (attr.startsWith("'")) { 151 | try { 152 | attr = attr.substring(1, attr.length() - 1); 153 | attr = StringConverter.decode(attr); 154 | } catch (Exception e) { 155 | 156 | } 157 | } 158 | curElement.addAttribute(attr); 159 | } 160 | } 161 | 162 | Entity entity = entityMap.get(type); 163 | if (!curElement.isValid(entity)) { 164 | System.out.println("lineID:"+curElement.getLineID()+" type:"+curElement.getIfcType()); 165 | System.out.println("elementAttrCount:"+curElement.getAttrs().size()+" entityAttrCount:"+entity.getAttributes().size()); 166 | } else { 167 | elementList.add(curElement); 168 | } 169 | return null; 170 | } 171 | 172 | 173 | 174 | public static void main(String[] args) throws IOException { 175 | IfcFile file = loadIFC("E:\\1labdata\\IFC文件\\us.ifc"); 176 | System.out.println(); 177 | 178 | } 179 | 180 | } 181 | -------------------------------------------------------------------------------- /src/main/java/dao/IfcMetaData.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import org.neo4j.graphdb.*; 4 | import org.neo4j.graphdb.factory.GraphDatabaseFactory; 5 | import org.neo4j.io.fs.FileUtils; 6 | import model.Entity; 7 | import model.Attribute; 8 | 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.util.HashMap; 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | /** 16 | * used for insert ifc class graph into neo4j 17 | */ 18 | public class IfcMetaData { 19 | 20 | private List entityList = null; 21 | Map selectType = null; 22 | 23 | private static final File databaseDirectory = new File( "D:\\Program Files\\neo4j-community-3.4.10\\data\\databases\\ifc23t.db" ); 24 | 25 | // START SNIPPET: vars 26 | GraphDatabaseService graphDb; 27 | 28 | private enum RelTypes implements RelationshipType 29 | { 30 | HAS_ATTR, 31 | SUBTYPE_OF, 32 | LINK_TO 33 | } 34 | 35 | 36 | public IfcMetaData(String filePath) { 37 | try { 38 | SchemaFileLoader fileLoader = SchemaFileLoader.getSchemaLoader(filePath); 39 | entityList = fileLoader.getEntityList(); 40 | selectType = fileLoader.getSelectType(); 41 | } catch (Exception e) { 42 | e.printStackTrace(); 43 | } 44 | } 45 | 46 | public IfcMetaData(List entityList, Map selectType) { 47 | this.entityList = entityList; 48 | this.selectType = selectType; 49 | } 50 | 51 | void createDb() throws IOException 52 | { 53 | FileUtils.deleteRecursively( databaseDirectory ); 54 | 55 | // START SNIPPET: startDb 56 | graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( databaseDirectory ); 57 | registerShutdownHook( graphDb ); 58 | 59 | Map nodeIndex = new HashMap(); 60 | 61 | // START SNIPPET: transaction 62 | try ( Transaction tx = graphDb.beginTx() ) 63 | { 64 | for (Entity entity: entityList) { 65 | Node entityNode = graphDb.createNode(); 66 | //create index 67 | nodeIndex.put(entity.getName(), entityNode.getId()); 68 | //set label 69 | Label enlabel = Label.label("Node"); 70 | entityNode.addLabel(enlabel); 71 | //set properties 72 | List attrs = entity.getAttributes(); 73 | entityNode.setProperty("name", entity.getName()); 74 | //entityNode.setProperty("version", entity.getVersion()); 75 | 76 | 77 | for (Attribute attr: attrs) { 78 | Node attrNode = graphDb.createNode(); 79 | Label attrlabel = Label.label("Attribute"); 80 | attrNode.addLabel(attrlabel); 81 | attrNode.setProperty("name", attr.getName()); 82 | attrNode.setProperty("index", attr.getIndex()); 83 | entityNode.createRelationshipTo(attrNode, RelTypes.HAS_ATTR); 84 | } 85 | } 86 | 87 | for (Entity entity: entityList) { 88 | if (entity.getParent() == null) continue; 89 | Long nodeId = nodeIndex.get(entity.getName()); 90 | Long nodeParentId = nodeIndex.get(entity.getParentName()); 91 | Node node = graphDb.getNodeById(nodeId); 92 | Node nodeParent = graphDb.getNodeById(nodeParentId); 93 | node.createRelationshipTo(nodeParent, RelTypes.SUBTYPE_OF); 94 | 95 | Iterable rels = node.getRelationships(Direction.OUTGOING, RelTypes.HAS_ATTR); 96 | 97 | for (Relationship rel: rels) { 98 | Node attr = rel.getEndNode(); 99 | String attrName = (String) attr.getProperty("name"); 100 | String type = entity.findAttr(attrName).getType(); 101 | //如果这个属性引用了一个entity,建立这个关系 102 | Long typeNodeId = nodeIndex.get(type); 103 | if (typeNodeId != null) { 104 | Node connected = graphDb.getNodeById(typeNodeId); 105 | attr.createRelationshipTo(connected, RelTypes.LINK_TO); 106 | } 107 | //如果这个属性应用了一个**select TYPE,建立属于TYPE的关系 108 | if (type.endsWith("Select")) { 109 | String[] types = selectType.get(type); 110 | for (String atype: types) { 111 | Long typeId = nodeIndex.get(atype); 112 | if (typeId != null) { 113 | Node connected = graphDb.getNodeById(typeId); 114 | attr.createRelationshipTo(connected, RelTypes.LINK_TO); 115 | } 116 | } 117 | } 118 | 119 | } 120 | } 121 | // START SNIPPET: transaction 122 | tx.success(); 123 | } 124 | } 125 | 126 | 127 | void shutDown() 128 | { 129 | System.out.println(); 130 | System.out.println( "Shutting down database ..." ); 131 | // START SNIPPET: shutdownServer 132 | graphDb.shutdown(); 133 | // END SNIPPET: shutdownServer 134 | } 135 | 136 | // START SNIPPET: shutdownHook 137 | private static void registerShutdownHook( final GraphDatabaseService graphDb ) 138 | { 139 | // Registers a shutdown hook for the Neo4j instance so that it 140 | // shuts down nicely when the VM exits (even if you "Ctrl-C" the 141 | // running application). 142 | Runtime.getRuntime().addShutdownHook( new Thread() 143 | { 144 | @Override 145 | public void run() 146 | { 147 | graphDb.shutdown(); 148 | } 149 | } ); 150 | } 151 | 152 | 153 | public static void main(String[] args) throws IOException { 154 | String path = "src\\main\\resources\\ifc4.exp"; 155 | IfcMetaData meta = new IfcMetaData(path); 156 | 157 | meta.createDb(); 158 | meta.shutDown(); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/main/java/dao/ResultItem.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | public class ResultItem { 4 | public String ruleContent; 5 | public int ifcLineId; 6 | public String ifcType; 7 | public boolean status; 8 | 9 | public ResultItem(String ruleContent, int ifcLineId, String ifcType, boolean status) { 10 | this.ruleContent = ruleContent; 11 | this.ifcLineId = ifcLineId; 12 | this.ifcType = ifcType; 13 | this.status = status; 14 | } 15 | 16 | public String toString() { 17 | String[] rules = ruleContent.split(" "); 18 | return ifcLineId+" "+ifcType+" "+rules[0]+" "+rules[2]; 19 | //return ruleContent+" "+ifcType+" "+ifcLineId+" "+status; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/dao/SchemaFileLoader.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import model.InverseInfo; 4 | import org.antlr.v4.runtime.CharStream; 5 | import org.antlr.v4.runtime.CharStreams; 6 | import org.antlr.v4.runtime.CommonTokenStream; 7 | import org.antlr.v4.runtime.tree.ParseTree; 8 | import parser.*; 9 | import model.Attribute; 10 | import model.Entity; 11 | 12 | import java.util.*; 13 | 14 | public class SchemaFileLoader extends ExpressGrammarBaseVisitor { 15 | 16 | private Entity curEntity; 17 | private List entityList = new LinkedList<>(); 18 | private Map selectType = new HashMap<>(); 19 | //private Set inverseInfos = new HashSet<>(); 20 | 21 | /** 22 | * 23 | * @param filePath file path of ifc schema file(.exp) 24 | * @return list of entities 25 | */ 26 | public static SchemaFileLoader getSchemaLoader(String filePath) { 27 | try { 28 | 29 | CharStream input = CharStreams.fromFileName(filePath); 30 | 31 | ExpressGrammarLexer lexer = new ExpressGrammarLexer(input); 32 | CommonTokenStream tokens = new CommonTokenStream(lexer); 33 | ExpressGrammarParser parser = new ExpressGrammarParser(tokens); 34 | ParseTree tree = parser.schema(); 35 | 36 | 37 | SchemaFileLoader loader = new SchemaFileLoader(); 38 | loader.visit(tree); 39 | loader.getDerivedAttributes(); 40 | return loader; 41 | 42 | } catch (Exception e) { 43 | e.printStackTrace(); 44 | } 45 | return null; 46 | } 47 | 48 | public List getEntityList() { 49 | return entityList; 50 | } 51 | 52 | public Map getSelectType() { return selectType;} 53 | 54 | //public Set getInverseInfos() {return inverseInfos;} 55 | 56 | private void getDerivedAttributes() { 57 | Map entityMap = new HashMap(); 58 | Set visited = new HashSet<>(); 59 | 60 | for (Entity entity: entityList) { 61 | entityMap.put(entity.getName(), entity); 62 | } 63 | for (Entity entity: entityList) { 64 | if (entity.getParentName() != null) { 65 | Entity parent = entityMap.get(entity.getParentName()); 66 | entity.setParent(parent); 67 | } 68 | } 69 | for (Entity entity: entityList) { 70 | findDerivedAttribute(entity, visited); 71 | } 72 | for (Entity entity: entityList) { 73 | List attrList = entity.getAttributes(); 74 | for (int i = 0; i < attrList.size(); i++) { 75 | attrList.get(i).SetIndex(i); 76 | } 77 | } 78 | } 79 | 80 | private void findDerivedAttribute(Entity entity, Set visited) { 81 | if (visited.contains(entity.getName())) return; 82 | 83 | visited.add(entity.getName()); 84 | if (entity.getParent() == null) return; 85 | Entity parent = entity.getParent(); 86 | findDerivedAttribute(parent, visited); 87 | List parent_attr = parent.getAttributes(); 88 | for (int i = parent_attr.size()-1; i >= 0; i--) { 89 | // do not copy reference, new an attribute here 90 | Attribute new_attr = new Attribute(parent_attr.get(i).getName()); 91 | new_attr.SetType(parent_attr.get(i).getType()); 92 | entity.getAttributes().add(0, new_attr); 93 | } 94 | } 95 | 96 | @Override 97 | public Void visitBeginEntity(ExpressGrammarParser.BeginEntityContext ctx) { 98 | curEntity = new Entity(ctx.NAME().getText()); 99 | entityList.add(curEntity); 100 | return null; 101 | } 102 | 103 | @Override 104 | public Void visitSubtype(ExpressGrammarParser.SubtypeContext ctx) { 105 | curEntity.setParentName(ctx.NAME().getText()); 106 | return null; 107 | } 108 | 109 | @Override 110 | public Void visitAttr(ExpressGrammarParser.AttrContext ctx) { 111 | String attr = ctx.getText(); 112 | int indexOfComma = attr.indexOf(':'); 113 | String typeInfo = attr.substring(indexOfComma+1); 114 | int indexOfType = typeInfo.indexOf("Ifc"); 115 | String type = "primitive"; 116 | if (indexOfType != -1) 117 | type = typeInfo.substring(indexOfType); 118 | 119 | curEntity.addAttribute(ctx.NAME().getText(), type); 120 | 121 | return null; 122 | } 123 | 124 | @Override 125 | /** 126 | * parse select type: 127 | * TYPE IfcActorSelect = SELECT 128 | * (IfcOrganization 129 | * ,IfcPerson 130 | * ,IfcPersonAndOrganization); 131 | * END_TYPE; 132 | */ 133 | public Void visitType(ExpressGrammarParser.TypeContext ctx) { 134 | if (ctx.SELECT() != null) { 135 | String nameList = ctx.nameList().getText(); 136 | nameList = nameList.substring(1, nameList.length()-1); 137 | String[] names = nameList.split(","); 138 | selectType.put(ctx.NAME().getText(), names); 139 | } 140 | return null; 141 | } 142 | 143 | // public Void visitInverseSentence(ExpressGrammarParser.InverseSentenceContext ctx) { 144 | // String inv = ctx.NAME(0).getText(); 145 | // String reltype = ctx.NAME(1).getText(); 146 | // String attr = ctx.NAME(2).getText(); 147 | // InverseInfo info = new InverseInfo(reltype, attr, inv); 148 | // inverseInfos.add(info); 149 | // return null; 150 | // } 151 | 152 | 153 | 154 | 155 | public static void main(String[] args) { 156 | 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/main/java/model/Attribute.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | public class Attribute { 4 | private String name; 5 | private int index = -1; 6 | private String type; 7 | 8 | //default attribute is direct and has no index 9 | public Attribute(String name) { 10 | this.name = name; 11 | } 12 | 13 | public String getName() { 14 | return name; 15 | } 16 | 17 | public int getIndex() { 18 | return index; 19 | } 20 | 21 | public String getType() { return type; } 22 | 23 | 24 | public void SetIndex(int index) { 25 | this.index = index; 26 | } 27 | 28 | public void SetType(String type) { 29 | this.type = type; 30 | } 31 | 32 | 33 | public String toString() { 34 | String str = ""; 35 | str += "{name:"+name+","; 36 | str += "index:"+index+"}"; 37 | return str; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/model/Element.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Element { 7 | 8 | private String ifcType; 9 | private int lineID; 10 | private List attrs; 11 | 12 | public Element(String type, int lineID) { 13 | this.ifcType = type; 14 | this.lineID = lineID; 15 | this.attrs = new ArrayList<>(); 16 | } 17 | 18 | public String getIfcType() { 19 | return ifcType; 20 | } 21 | 22 | public void addAttribute(String attr) { 23 | attrs.add(attr); 24 | } 25 | 26 | public int getLineID() { 27 | return lineID; 28 | } 29 | 30 | public List getAttrs() { 31 | return attrs; 32 | } 33 | 34 | public boolean isValid(Entity entity) { 35 | if (entity.getAttributes().size() != attrs.size()) return false; 36 | return true; 37 | } 38 | 39 | public String toString() { 40 | String res = ""; 41 | res += "type: "+ifcType+' '; 42 | res += "line: "+lineID+" ["; 43 | for (String attr: attrs) { 44 | res += attr+","; 45 | } 46 | res += "]"; 47 | return res; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/model/Entity.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Entity { 7 | private String name; 8 | private String version; 9 | private String parentName; 10 | private Entity parent; 11 | private List attributes = new ArrayList(); 12 | 13 | public Entity(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public Entity getParent() { 22 | return parent; 23 | } 24 | 25 | public String getParentName() { 26 | return parentName; 27 | } 28 | 29 | public String getVersion() { 30 | return version; 31 | } 32 | 33 | public List getAttributes() { 34 | return attributes; 35 | } 36 | 37 | public void setParent(Entity parent) { 38 | this.parent = parent; 39 | } 40 | 41 | public void setParentName(String parent) { 42 | this.parentName = parent; 43 | } 44 | 45 | public void addAttribute(String attr, String type) { 46 | Attribute attribute = new Attribute(attr); 47 | attribute.SetType(type); 48 | attributes.add(attribute); 49 | } 50 | 51 | public Attribute findAttr(String attrName) { 52 | for (Attribute attr : attributes) { 53 | if (attr.getName().equals(attrName)) return attr; 54 | } 55 | return null; 56 | } 57 | 58 | public String toString() { 59 | String str = name+" "+version+" "+parentName+'\n'; 60 | String attrs = ""; 61 | for (Attribute attr: attributes) { 62 | attrs += attr + " "; 63 | } 64 | return str+attrs+'\n'; 65 | } 66 | } -------------------------------------------------------------------------------- /src/main/java/model/IfcFile.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | 4 | import util.IfcVersion; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.Set; 9 | 10 | 11 | public class IfcFile { 12 | private final String modelName; 13 | private final IfcVersion version; 14 | //ifc instances 15 | private final List elementList; 16 | //ifc classes 17 | private final Map entityMap; 18 | //ifc inverseInfo 19 | private final Set inverseInfoSet; 20 | public IfcFile(String modelName, IfcVersion version, List elements, Map entityMap, Set inverseInfoSet) { 21 | this.modelName = modelName; 22 | this.version = version; 23 | this.elementList = elements; 24 | this.entityMap = entityMap; 25 | this.inverseInfoSet = inverseInfoSet; 26 | } 27 | 28 | public List getElementList() { 29 | return elementList; 30 | } 31 | 32 | public Map getEntityMap() { 33 | return entityMap; 34 | } 35 | 36 | public Set getInverseInfoSet() { return inverseInfoSet; } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/model/InverseInfo.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | /** 4 | * RelationObject will connect objects 5 | */ 6 | public class InverseInfo { 7 | public String ifcRelType; 8 | public String attrName; 9 | public String invName; 10 | public String attrNameOther; 11 | public String invNameOther; 12 | 13 | public InverseInfo(String ifcRelType, String attrName, String invName, String attrNameOther, String invNameOther) { 14 | this.ifcRelType = ifcRelType; 15 | this.attrName = attrName; 16 | this.invName = invName; 17 | this.attrNameOther = attrNameOther; 18 | this.invNameOther = invNameOther; 19 | } 20 | 21 | public boolean equals(Object inv) { 22 | if (inv == null) return false; 23 | if (this == inv) return true; 24 | if (!(inv instanceof InverseInfo)) 25 | return false; 26 | 27 | return ((this.ifcRelType).equals(((InverseInfo)inv).ifcRelType) 28 | && (this.attrName).equals(((InverseInfo)inv).attrName) 29 | && (this.invName).equals(((InverseInfo)inv).invName)); 30 | } 31 | 32 | public int hashCode() { 33 | return ifcRelType.hashCode()*17+attrName.hashCode()*13+invName.hashCode(); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/parser/ExpressGrammar.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | T__10=11 12 | T__11=12 13 | T__12=13 14 | T__13=14 15 | T__14=15 16 | T__15=16 17 | T__16=17 18 | T__17=18 19 | T__18=19 20 | T__19=20 21 | T__20=21 22 | T__21=22 23 | T__22=23 24 | T__23=24 25 | WS=25 26 | BLOCK_COMMENT=26 27 | INT=27 28 | SCHEMA=28 29 | END_SCHEMA=29 30 | TYPE=30 31 | END_TYPE=31 32 | ENTITY=32 33 | END_ENTITY=33 34 | FUNCTION=34 35 | END_FUNCTION=35 36 | RULE=36 37 | END_RULE=37 38 | SUBTYPE_OF=38 39 | SUPERTYPE_OF=39 40 | ONEOF=40 41 | ABSTRACT=41 42 | OPTIONAL=42 43 | FIXED=43 44 | OF=44 45 | SET=45 46 | ARRAY=46 47 | LIST=47 48 | BOOLEAN=48 49 | REAL=49 50 | INTEGER=50 51 | BINARY=51 52 | NUMBER=52 53 | STRING=53 54 | ENUMERATION=54 55 | SELECT=55 56 | WHERE=56 57 | DERIVE=57 58 | UNIQUE=58 59 | INVERSE=59 60 | SELF_=60 61 | FOR=61 62 | NAME=62 63 | ';'=1 64 | '('=2 65 | ')'=3 66 | ':'=4 67 | '['=5 68 | '?'=6 69 | ']'=7 70 | ','=8 71 | '='=9 72 | '.'=10 73 | ':='=11 74 | '<'=12 75 | '>'=13 76 | '\\'=14 77 | '/'=15 78 | '|'=16 79 | '*'=17 80 | '\''=18 81 | '"'=19 82 | '!'=20 83 | '-'=21 84 | '+'=22 85 | '{'=23 86 | '}'=24 87 | 'SCHEMA'=28 88 | 'END_SCHEMA;'=29 89 | 'TYPE'=30 90 | 'END_TYPE;'=31 91 | 'ENTITY'=32 92 | 'END_ENTITY;'=33 93 | 'FUNCTION'=34 94 | 'END_FUNCTION;'=35 95 | 'RULE'=36 96 | 'END_RULE;'=37 97 | 'SUBTYPE OF'=38 98 | 'SUPERTYPE OF'=39 99 | 'ONEOF'=40 100 | 'ABSTRACT'=41 101 | 'OPTIONAL'=42 102 | 'FIXED'=43 103 | 'OF'=44 104 | 'SET'=45 105 | 'ARRAY'=46 106 | 'LIST'=47 107 | 'BOOLEAN'=48 108 | 'REAL'=49 109 | 'INTEGER'=50 110 | 'BINARY'=51 111 | 'NUMBER'=52 112 | 'STRING'=53 113 | 'ENUMERATION'=54 114 | 'SELECT'=55 115 | 'WHERE'=56 116 | 'DERIVE'=57 117 | 'UNIQUE'=58 118 | 'INVERSE'=59 119 | 'SELF\\'=60 120 | 'FOR'=61 121 | -------------------------------------------------------------------------------- /src/main/java/parser/ExpressGrammarBaseVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from F:/JavaWorkSpace/IfcGraph/src/main/resources\ExpressGrammar.g4 by ANTLR 4.7 2 | package parser; 3 | import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; 4 | 5 | /** 6 | * This class provides an empty implementation of {@link ExpressGrammarVisitor}, 7 | * which can be extended to create a visitor which only needs to handle a subset 8 | * of the available methods. 9 | * 10 | * @param The return type of the visit operation. Use {@link Void} for 11 | * operations with no return type. 12 | */ 13 | public class ExpressGrammarBaseVisitor extends AbstractParseTreeVisitor implements ExpressGrammarVisitor { 14 | /** 15 | * {@inheritDoc} 16 | * 17 | *

The default implementation returns the result of calling 18 | * {@link #visitChildren} on {@code ctx}.

19 | */ 20 | @Override public T visitSchema(ExpressGrammarParser.SchemaContext ctx) { return visitChildren(ctx); } 21 | /** 22 | * {@inheritDoc} 23 | * 24 | *

The default implementation returns the result of calling 25 | * {@link #visitChildren} on {@code ctx}.

26 | */ 27 | @Override public T visitBeginSchema(ExpressGrammarParser.BeginSchemaContext ctx) { return visitChildren(ctx); } 28 | /** 29 | * {@inheritDoc} 30 | * 31 | *

The default implementation returns the result of calling 32 | * {@link #visitChildren} on {@code ctx}.

33 | */ 34 | @Override public T visitEntity(ExpressGrammarParser.EntityContext ctx) { return visitChildren(ctx); } 35 | /** 36 | * {@inheritDoc} 37 | * 38 | *

The default implementation returns the result of calling 39 | * {@link #visitChildren} on {@code ctx}.

40 | */ 41 | @Override public T visitBeginEntity(ExpressGrammarParser.BeginEntityContext ctx) { return visitChildren(ctx); } 42 | /** 43 | * {@inheritDoc} 44 | * 45 | *

The default implementation returns the result of calling 46 | * {@link #visitChildren} on {@code ctx}.

47 | */ 48 | @Override public T visitEntityType(ExpressGrammarParser.EntityTypeContext ctx) { return visitChildren(ctx); } 49 | /** 50 | * {@inheritDoc} 51 | * 52 | *

The default implementation returns the result of calling 53 | * {@link #visitChildren} on {@code ctx}.

54 | */ 55 | @Override public T visitSubtype(ExpressGrammarParser.SubtypeContext ctx) { return visitChildren(ctx); } 56 | /** 57 | * {@inheritDoc} 58 | * 59 | *

The default implementation returns the result of calling 60 | * {@link #visitChildren} on {@code ctx}.

61 | */ 62 | @Override public T visitSupertypeOf(ExpressGrammarParser.SupertypeOfContext ctx) { return visitChildren(ctx); } 63 | /** 64 | * {@inheritDoc} 65 | * 66 | *

The default implementation returns the result of calling 67 | * {@link #visitChildren} on {@code ctx}.

68 | */ 69 | @Override public T visitAttr(ExpressGrammarParser.AttrContext ctx) { return visitChildren(ctx); } 70 | /** 71 | * {@inheritDoc} 72 | * 73 | *

The default implementation returns the result of calling 74 | * {@link #visitChildren} on {@code ctx}.

75 | */ 76 | @Override public T visitCollectionOf(ExpressGrammarParser.CollectionOfContext ctx) { return visitChildren(ctx); } 77 | /** 78 | * {@inheritDoc} 79 | * 80 | *

The default implementation returns the result of calling 81 | * {@link #visitChildren} on {@code ctx}.

82 | */ 83 | @Override public T visitCollectionArgPart(ExpressGrammarParser.CollectionArgPartContext ctx) { return visitChildren(ctx); } 84 | /** 85 | * {@inheritDoc} 86 | * 87 | *

The default implementation returns the result of calling 88 | * {@link #visitChildren} on {@code ctx}.

89 | */ 90 | @Override public T visitBeginNameList(ExpressGrammarParser.BeginNameListContext ctx) { return visitChildren(ctx); } 91 | /** 92 | * {@inheritDoc} 93 | * 94 | *

The default implementation returns the result of calling 95 | * {@link #visitChildren} on {@code ctx}.

96 | */ 97 | @Override public T visitEndNameList(ExpressGrammarParser.EndNameListContext ctx) { return visitChildren(ctx); } 98 | /** 99 | * {@inheritDoc} 100 | * 101 | *

The default implementation returns the result of calling 102 | * {@link #visitChildren} on {@code ctx}.

103 | */ 104 | @Override public T visitNameList(ExpressGrammarParser.NameListContext ctx) { return visitChildren(ctx); } 105 | /** 106 | * {@inheritDoc} 107 | * 108 | *

The default implementation returns the result of calling 109 | * {@link #visitChildren} on {@code ctx}.

110 | */ 111 | @Override public T visitNames(ExpressGrammarParser.NamesContext ctx) { return visitChildren(ctx); } 112 | /** 113 | * {@inheritDoc} 114 | * 115 | *

The default implementation returns the result of calling 116 | * {@link #visitChildren} on {@code ctx}.

117 | */ 118 | @Override public T visitTypeName(ExpressGrammarParser.TypeNameContext ctx) { return visitChildren(ctx); } 119 | /** 120 | * {@inheritDoc} 121 | * 122 | *

The default implementation returns the result of calling 123 | * {@link #visitChildren} on {@code ctx}.

124 | */ 125 | @Override public T visitType(ExpressGrammarParser.TypeContext ctx) { return visitChildren(ctx); } 126 | /** 127 | * {@inheritDoc} 128 | * 129 | *

The default implementation returns the result of calling 130 | * {@link #visitChildren} on {@code ctx}.

131 | */ 132 | @Override public T visitInversePart(ExpressGrammarParser.InversePartContext ctx) { return visitChildren(ctx); } 133 | /** 134 | * {@inheritDoc} 135 | * 136 | *

The default implementation returns the result of calling 137 | * {@link #visitChildren} on {@code ctx}.

138 | */ 139 | @Override public T visitInverseSentence(ExpressGrammarParser.InverseSentenceContext ctx) { return visitChildren(ctx); } 140 | /** 141 | * {@inheritDoc} 142 | * 143 | *

The default implementation returns the result of calling 144 | * {@link #visitChildren} on {@code ctx}.

145 | */ 146 | @Override public T visitDerivePart(ExpressGrammarParser.DerivePartContext ctx) { return visitChildren(ctx); } 147 | /** 148 | * {@inheritDoc} 149 | * 150 | *

The default implementation returns the result of calling 151 | * {@link #visitChildren} on {@code ctx}.

152 | */ 153 | @Override public T visitDeriveOverrideSentence(ExpressGrammarParser.DeriveOverrideSentenceContext ctx) { return visitChildren(ctx); } 154 | /** 155 | * {@inheritDoc} 156 | * 157 | *

The default implementation returns the result of calling 158 | * {@link #visitChildren} on {@code ctx}.

159 | */ 160 | @Override public T visitDeriveSentence(ExpressGrammarParser.DeriveSentenceContext ctx) { return visitChildren(ctx); } 161 | /** 162 | * {@inheritDoc} 163 | * 164 | *

The default implementation returns the result of calling 165 | * {@link #visitChildren} on {@code ctx}.

166 | */ 167 | @Override public T visitUniquePart(ExpressGrammarParser.UniquePartContext ctx) { return visitChildren(ctx); } 168 | /** 169 | * {@inheritDoc} 170 | * 171 | *

The default implementation returns the result of calling 172 | * {@link #visitChildren} on {@code ctx}.

173 | */ 174 | @Override public T visitUniqueSentence(ExpressGrammarParser.UniqueSentenceContext ctx) { return visitChildren(ctx); } 175 | /** 176 | * {@inheritDoc} 177 | * 178 | *

The default implementation returns the result of calling 179 | * {@link #visitChildren} on {@code ctx}.

180 | */ 181 | @Override public T visitWherePart(ExpressGrammarParser.WherePartContext ctx) { return visitChildren(ctx); } 182 | /** 183 | * {@inheritDoc} 184 | * 185 | *

The default implementation returns the result of calling 186 | * {@link #visitChildren} on {@code ctx}.

187 | */ 188 | @Override public T visitWhereSentence(ExpressGrammarParser.WhereSentenceContext ctx) { return visitChildren(ctx); } 189 | /** 190 | * {@inheritDoc} 191 | * 192 | *

The default implementation returns the result of calling 193 | * {@link #visitChildren} on {@code ctx}.

194 | */ 195 | @Override public T visitFunction(ExpressGrammarParser.FunctionContext ctx) { return visitChildren(ctx); } 196 | /** 197 | * {@inheritDoc} 198 | * 199 | *

The default implementation returns the result of calling 200 | * {@link #visitChildren} on {@code ctx}.

201 | */ 202 | @Override public T visitTherule(ExpressGrammarParser.TheruleContext ctx) { return visitChildren(ctx); } 203 | /** 204 | * {@inheritDoc} 205 | * 206 | *

The default implementation returns the result of calling 207 | * {@link #visitChildren} on {@code ctx}.

208 | */ 209 | @Override public T visitCommonKeyword(ExpressGrammarParser.CommonKeywordContext ctx) { return visitChildren(ctx); } 210 | /** 211 | * {@inheritDoc} 212 | * 213 | *

The default implementation returns the result of calling 214 | * {@link #visitChildren} on {@code ctx}.

215 | */ 216 | @Override public T visitCommonSentence(ExpressGrammarParser.CommonSentenceContext ctx) { return visitChildren(ctx); } 217 | /** 218 | * {@inheritDoc} 219 | * 220 | *

The default implementation returns the result of calling 221 | * {@link #visitChildren} on {@code ctx}.

222 | */ 223 | @Override public T visitTypeSingleKeyword(ExpressGrammarParser.TypeSingleKeywordContext ctx) { return visitChildren(ctx); } 224 | /** 225 | * {@inheritDoc} 226 | * 227 | *

The default implementation returns the result of calling 228 | * {@link #visitChildren} on {@code ctx}.

229 | */ 230 | @Override public T visitTypeArrayKeyword(ExpressGrammarParser.TypeArrayKeywordContext ctx) { return visitChildren(ctx); } 231 | /** 232 | * {@inheritDoc} 233 | * 234 | *

The default implementation returns the result of calling 235 | * {@link #visitChildren} on {@code ctx}.

236 | */ 237 | @Override public T visitTypeKeyword(ExpressGrammarParser.TypeKeywordContext ctx) { return visitChildren(ctx); } 238 | /** 239 | * {@inheritDoc} 240 | * 241 | *

The default implementation returns the result of calling 242 | * {@link #visitChildren} on {@code ctx}.

243 | */ 244 | @Override public T visitInnerKeyword(ExpressGrammarParser.InnerKeywordContext ctx) { return visitChildren(ctx); } 245 | /** 246 | * {@inheritDoc} 247 | * 248 | *

The default implementation returns the result of calling 249 | * {@link #visitChildren} on {@code ctx}.

250 | */ 251 | @Override public T visitSign(ExpressGrammarParser.SignContext ctx) { return visitChildren(ctx); } 252 | } -------------------------------------------------------------------------------- /src/main/java/parser/ExpressGrammarLexer.java: -------------------------------------------------------------------------------- 1 | // Generated from F:/JavaWorkSpace/IfcGraph/src/main/resources\ExpressGrammar.g4 by ANTLR 4.7 2 | package parser; 3 | import org.antlr.v4.runtime.Lexer; 4 | import org.antlr.v4.runtime.CharStream; 5 | import org.antlr.v4.runtime.Token; 6 | import org.antlr.v4.runtime.TokenStream; 7 | import org.antlr.v4.runtime.*; 8 | import org.antlr.v4.runtime.atn.*; 9 | import org.antlr.v4.runtime.dfa.DFA; 10 | import org.antlr.v4.runtime.misc.*; 11 | 12 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 13 | public class ExpressGrammarLexer extends Lexer { 14 | static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } 15 | 16 | protected static final DFA[] _decisionToDFA; 17 | protected static final PredictionContextCache _sharedContextCache = 18 | new PredictionContextCache(); 19 | public static final int 20 | T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, 21 | T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, 22 | T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, 23 | WS=25, BLOCK_COMMENT=26, INT=27, SCHEMA=28, END_SCHEMA=29, TYPE=30, END_TYPE=31, 24 | ENTITY=32, END_ENTITY=33, FUNCTION=34, END_FUNCTION=35, RULE=36, END_RULE=37, 25 | SUBTYPE_OF=38, SUPERTYPE_OF=39, ONEOF=40, ABSTRACT=41, OPTIONAL=42, FIXED=43, 26 | OF=44, SET=45, ARRAY=46, LIST=47, BOOLEAN=48, REAL=49, INTEGER=50, BINARY=51, 27 | NUMBER=52, STRING=53, ENUMERATION=54, SELECT=55, WHERE=56, DERIVE=57, 28 | UNIQUE=58, INVERSE=59, SELF_=60, FOR=61, NAME=62; 29 | public static String[] channelNames = { 30 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN" 31 | }; 32 | 33 | public static String[] modeNames = { 34 | "DEFAULT_MODE" 35 | }; 36 | 37 | public static final String[] ruleNames = { 38 | "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", 39 | "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", 40 | "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "WS", "BLOCK_COMMENT", 41 | "INT", "SCHEMA", "END_SCHEMA", "TYPE", "END_TYPE", "ENTITY", "END_ENTITY", 42 | "FUNCTION", "END_FUNCTION", "RULE", "END_RULE", "SUBTYPE_OF", "SUPERTYPE_OF", 43 | "ONEOF", "ABSTRACT", "OPTIONAL", "FIXED", "OF", "SET", "ARRAY", "LIST", 44 | "BOOLEAN", "REAL", "INTEGER", "BINARY", "NUMBER", "STRING", "ENUMERATION", 45 | "SELECT", "WHERE", "DERIVE", "UNIQUE", "INVERSE", "SELF_", "FOR", "NAME" 46 | }; 47 | 48 | private static final String[] _LITERAL_NAMES = { 49 | null, "';'", "'('", "')'", "':'", "'['", "'?'", "']'", "','", "'='", "'.'", 50 | "':='", "'<'", "'>'", "'\\'", "'/'", "'|'", "'*'", "'''", "'\"'", "'!'", 51 | "'-'", "'+'", "'{'", "'}'", null, null, null, "'SCHEMA'", "'END_SCHEMA;'", 52 | "'TYPE'", "'END_TYPE;'", "'ENTITY'", "'END_ENTITY;'", "'FUNCTION'", "'END_FUNCTION;'", 53 | "'RULE'", "'END_RULE;'", "'SUBTYPE OF'", "'SUPERTYPE OF'", "'ONEOF'", 54 | "'ABSTRACT'", "'OPTIONAL'", "'FIXED'", "'OF'", "'SET'", "'ARRAY'", "'LIST'", 55 | "'BOOLEAN'", "'REAL'", "'INTEGER'", "'BINARY'", "'NUMBER'", "'STRING'", 56 | "'ENUMERATION'", "'SELECT'", "'WHERE'", "'DERIVE'", "'UNIQUE'", "'INVERSE'", 57 | "'SELF\\'", "'FOR'" 58 | }; 59 | private static final String[] _SYMBOLIC_NAMES = { 60 | null, null, null, null, null, null, null, null, null, null, null, null, 61 | null, null, null, null, null, null, null, null, null, null, null, null, 62 | null, "WS", "BLOCK_COMMENT", "INT", "SCHEMA", "END_SCHEMA", "TYPE", "END_TYPE", 63 | "ENTITY", "END_ENTITY", "FUNCTION", "END_FUNCTION", "RULE", "END_RULE", 64 | "SUBTYPE_OF", "SUPERTYPE_OF", "ONEOF", "ABSTRACT", "OPTIONAL", "FIXED", 65 | "OF", "SET", "ARRAY", "LIST", "BOOLEAN", "REAL", "INTEGER", "BINARY", 66 | "NUMBER", "STRING", "ENUMERATION", "SELECT", "WHERE", "DERIVE", "UNIQUE", 67 | "INVERSE", "SELF_", "FOR", "NAME" 68 | }; 69 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 70 | 71 | /** 72 | * @deprecated Use {@link #VOCABULARY} instead. 73 | */ 74 | @Deprecated 75 | public static final String[] tokenNames; 76 | static { 77 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 78 | for (int i = 0; i < tokenNames.length; i++) { 79 | tokenNames[i] = VOCABULARY.getLiteralName(i); 80 | if (tokenNames[i] == null) { 81 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 82 | } 83 | 84 | if (tokenNames[i] == null) { 85 | tokenNames[i] = ""; 86 | } 87 | } 88 | } 89 | 90 | @Override 91 | @Deprecated 92 | public String[] getTokenNames() { 93 | return tokenNames; 94 | } 95 | 96 | @Override 97 | 98 | public Vocabulary getVocabulary() { 99 | return VOCABULARY; 100 | } 101 | 102 | 103 | public ExpressGrammarLexer(CharStream input) { 104 | super(input); 105 | _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 106 | } 107 | 108 | @Override 109 | public String getGrammarFileName() { return "ExpressGrammar.g4"; } 110 | 111 | @Override 112 | public String[] getRuleNames() { return ruleNames; } 113 | 114 | @Override 115 | public String getSerializedATN() { return _serializedATN; } 116 | 117 | @Override 118 | public String[] getChannelNames() { return channelNames; } 119 | 120 | @Override 121 | public String[] getModeNames() { return modeNames; } 122 | 123 | @Override 124 | public ATN getATN() { return _ATN; } 125 | 126 | public static final String _serializedATN = 127 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2@\u01da\b\1\4\2\t"+ 128 | "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ 129 | "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ 130 | "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ 131 | "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ 132 | "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+ 133 | ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+ 134 | "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+ 135 | "\4>\t>\4?\t?\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3\b\3"+ 136 | "\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3\f\3\r\3\r\3\16\3\16\3\17\3\17\3\20"+ 137 | "\3\20\3\21\3\21\3\22\3\22\3\23\3\23\3\24\3\24\3\25\3\25\3\26\3\26\3\27"+ 138 | "\3\27\3\30\3\30\3\31\3\31\3\32\6\32\u00b2\n\32\r\32\16\32\u00b3\3\32\3"+ 139 | "\32\3\33\3\33\3\33\3\33\7\33\u00bc\n\33\f\33\16\33\u00bf\13\33\3\33\3"+ 140 | "\33\3\33\3\33\3\33\3\34\3\34\3\34\7\34\u00c9\n\34\f\34\16\34\u00cc\13"+ 141 | "\34\5\34\u00ce\n\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36\3\36\3\36"+ 142 | "\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37"+ 143 | "\3 \3 \3 \3 \3 \3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3!\3!\3\"\3\"\3\"\3\"\3"+ 144 | "\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3#\3#\3#\3#\3$\3$\3$\3$"+ 145 | "\3$\3$\3$\3$\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&"+ 146 | "\3&\3&\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3"+ 147 | "(\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3*\3*\3*\3*\3*\3*\3*\3*\3*\3+\3"+ 148 | "+\3+\3+\3+\3+\3+\3+\3+\3,\3,\3,\3,\3,\3,\3-\3-\3-\3.\3.\3.\3.\3/\3/\3"+ 149 | "/\3/\3/\3/\3\60\3\60\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3\61\3\61\3\61"+ 150 | "\3\61\3\62\3\62\3\62\3\62\3\62\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\63"+ 151 | "\3\64\3\64\3\64\3\64\3\64\3\64\3\64\3\65\3\65\3\65\3\65\3\65\3\65\3\65"+ 152 | "\3\66\3\66\3\66\3\66\3\66\3\66\3\66\3\67\3\67\3\67\3\67\3\67\3\67\3\67"+ 153 | "\3\67\3\67\3\67\3\67\3\67\38\38\38\38\38\38\38\39\39\39\39\39\39\3:\3"+ 154 | ":\3:\3:\3:\3:\3:\3;\3;\3;\3;\3;\3;\3;\3<\3<\3<\3<\3<\3<\3<\3<\3=\3=\3"+ 155 | "=\3=\3=\3=\3>\3>\3>\3>\3?\6?\u01d7\n?\r?\16?\u01d8\3\u00bd\2@\3\3\5\4"+ 156 | "\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22"+ 157 | "#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C"+ 158 | "#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67m8o9q:s;u{?}@\3\2\6\5\2\13\f\17\17\"\"\3\2\63;\3\2\62;\6\2\62;C\\aac|\2\u01de"+ 160 | "\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2"+ 161 | "\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2"+ 162 | "\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2"+ 163 | "\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2"+ 164 | "\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3"+ 165 | "\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2"+ 166 | "\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2"+ 167 | "U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3"+ 168 | "\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2"+ 169 | "\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2"+ 170 | "{\3\2\2\2\2}\3\2\2\2\3\177\3\2\2\2\5\u0081\3\2\2\2\7\u0083\3\2\2\2\t\u0085"+ 171 | "\3\2\2\2\13\u0087\3\2\2\2\r\u0089\3\2\2\2\17\u008b\3\2\2\2\21\u008d\3"+ 172 | "\2\2\2\23\u008f\3\2\2\2\25\u0091\3\2\2\2\27\u0093\3\2\2\2\31\u0096\3\2"+ 173 | "\2\2\33\u0098\3\2\2\2\35\u009a\3\2\2\2\37\u009c\3\2\2\2!\u009e\3\2\2\2"+ 174 | "#\u00a0\3\2\2\2%\u00a2\3\2\2\2\'\u00a4\3\2\2\2)\u00a6\3\2\2\2+\u00a8\3"+ 175 | "\2\2\2-\u00aa\3\2\2\2/\u00ac\3\2\2\2\61\u00ae\3\2\2\2\63\u00b1\3\2\2\2"+ 176 | "\65\u00b7\3\2\2\2\67\u00cd\3\2\2\29\u00cf\3\2\2\2;\u00d6\3\2\2\2=\u00e2"+ 177 | "\3\2\2\2?\u00e7\3\2\2\2A\u00f1\3\2\2\2C\u00f8\3\2\2\2E\u0104\3\2\2\2G"+ 178 | "\u010d\3\2\2\2I\u011b\3\2\2\2K\u0120\3\2\2\2M\u012a\3\2\2\2O\u0135\3\2"+ 179 | "\2\2Q\u0142\3\2\2\2S\u0148\3\2\2\2U\u0151\3\2\2\2W\u015a\3\2\2\2Y\u0160"+ 180 | "\3\2\2\2[\u0163\3\2\2\2]\u0167\3\2\2\2_\u016d\3\2\2\2a\u0172\3\2\2\2c"+ 181 | "\u017a\3\2\2\2e\u017f\3\2\2\2g\u0187\3\2\2\2i\u018e\3\2\2\2k\u0195\3\2"+ 182 | "\2\2m\u019c\3\2\2\2o\u01a8\3\2\2\2q\u01af\3\2\2\2s\u01b5\3\2\2\2u\u01bc"+ 183 | "\3\2\2\2w\u01c3\3\2\2\2y\u01cb\3\2\2\2{\u01d1\3\2\2\2}\u01d6\3\2\2\2\177"+ 184 | "\u0080\7=\2\2\u0080\4\3\2\2\2\u0081\u0082\7*\2\2\u0082\6\3\2\2\2\u0083"+ 185 | "\u0084\7+\2\2\u0084\b\3\2\2\2\u0085\u0086\7<\2\2\u0086\n\3\2\2\2\u0087"+ 186 | "\u0088\7]\2\2\u0088\f\3\2\2\2\u0089\u008a\7A\2\2\u008a\16\3\2\2\2\u008b"+ 187 | "\u008c\7_\2\2\u008c\20\3\2\2\2\u008d\u008e\7.\2\2\u008e\22\3\2\2\2\u008f"+ 188 | "\u0090\7?\2\2\u0090\24\3\2\2\2\u0091\u0092\7\60\2\2\u0092\26\3\2\2\2\u0093"+ 189 | "\u0094\7<\2\2\u0094\u0095\7?\2\2\u0095\30\3\2\2\2\u0096\u0097\7>\2\2\u0097"+ 190 | "\32\3\2\2\2\u0098\u0099\7@\2\2\u0099\34\3\2\2\2\u009a\u009b\7^\2\2\u009b"+ 191 | "\36\3\2\2\2\u009c\u009d\7\61\2\2\u009d \3\2\2\2\u009e\u009f\7~\2\2\u009f"+ 192 | "\"\3\2\2\2\u00a0\u00a1\7,\2\2\u00a1$\3\2\2\2\u00a2\u00a3\7)\2\2\u00a3"+ 193 | "&\3\2\2\2\u00a4\u00a5\7$\2\2\u00a5(\3\2\2\2\u00a6\u00a7\7#\2\2\u00a7*"+ 194 | "\3\2\2\2\u00a8\u00a9\7/\2\2\u00a9,\3\2\2\2\u00aa\u00ab\7-\2\2\u00ab.\3"+ 195 | "\2\2\2\u00ac\u00ad\7}\2\2\u00ad\60\3\2\2\2\u00ae\u00af\7\177\2\2\u00af"+ 196 | "\62\3\2\2\2\u00b0\u00b2\t\2\2\2\u00b1\u00b0\3\2\2\2\u00b2\u00b3\3\2\2"+ 197 | "\2\u00b3\u00b1\3\2\2\2\u00b3\u00b4\3\2\2\2\u00b4\u00b5\3\2\2\2\u00b5\u00b6"+ 198 | "\b\32\2\2\u00b6\64\3\2\2\2\u00b7\u00b8\7*\2\2\u00b8\u00b9\7,\2\2\u00b9"+ 199 | "\u00bd\3\2\2\2\u00ba\u00bc\13\2\2\2\u00bb\u00ba\3\2\2\2\u00bc\u00bf\3"+ 200 | "\2\2\2\u00bd\u00be\3\2\2\2\u00bd\u00bb\3\2\2\2\u00be\u00c0\3\2\2\2\u00bf"+ 201 | "\u00bd\3\2\2\2\u00c0\u00c1\7,\2\2\u00c1\u00c2\7+\2\2\u00c2\u00c3\3\2\2"+ 202 | "\2\u00c3\u00c4\b\33\2\2\u00c4\66\3\2\2\2\u00c5\u00ce\7\62\2\2\u00c6\u00ca"+ 203 | "\t\3\2\2\u00c7\u00c9\t\4\2\2\u00c8\u00c7\3\2\2\2\u00c9\u00cc\3\2\2\2\u00ca"+ 204 | "\u00c8\3\2\2\2\u00ca\u00cb\3\2\2\2\u00cb\u00ce\3\2\2\2\u00cc\u00ca\3\2"+ 205 | "\2\2\u00cd\u00c5\3\2\2\2\u00cd\u00c6\3\2\2\2\u00ce8\3\2\2\2\u00cf\u00d0"+ 206 | "\7U\2\2\u00d0\u00d1\7E\2\2\u00d1\u00d2\7J\2\2\u00d2\u00d3\7G\2\2\u00d3"+ 207 | "\u00d4\7O\2\2\u00d4\u00d5\7C\2\2\u00d5:\3\2\2\2\u00d6\u00d7\7G\2\2\u00d7"+ 208 | "\u00d8\7P\2\2\u00d8\u00d9\7F\2\2\u00d9\u00da\7a\2\2\u00da\u00db\7U\2\2"+ 209 | "\u00db\u00dc\7E\2\2\u00dc\u00dd\7J\2\2\u00dd\u00de\7G\2\2\u00de\u00df"+ 210 | "\7O\2\2\u00df\u00e0\7C\2\2\u00e0\u00e1\7=\2\2\u00e1<\3\2\2\2\u00e2\u00e3"+ 211 | "\7V\2\2\u00e3\u00e4\7[\2\2\u00e4\u00e5\7R\2\2\u00e5\u00e6\7G\2\2\u00e6"+ 212 | ">\3\2\2\2\u00e7\u00e8\7G\2\2\u00e8\u00e9\7P\2\2\u00e9\u00ea\7F\2\2\u00ea"+ 213 | "\u00eb\7a\2\2\u00eb\u00ec\7V\2\2\u00ec\u00ed\7[\2\2\u00ed\u00ee\7R\2\2"+ 214 | "\u00ee\u00ef\7G\2\2\u00ef\u00f0\7=\2\2\u00f0@\3\2\2\2\u00f1\u00f2\7G\2"+ 215 | "\2\u00f2\u00f3\7P\2\2\u00f3\u00f4\7V\2\2\u00f4\u00f5\7K\2\2\u00f5\u00f6"+ 216 | "\7V\2\2\u00f6\u00f7\7[\2\2\u00f7B\3\2\2\2\u00f8\u00f9\7G\2\2\u00f9\u00fa"+ 217 | "\7P\2\2\u00fa\u00fb\7F\2\2\u00fb\u00fc\7a\2\2\u00fc\u00fd\7G\2\2\u00fd"+ 218 | "\u00fe\7P\2\2\u00fe\u00ff\7V\2\2\u00ff\u0100\7K\2\2\u0100\u0101\7V\2\2"+ 219 | "\u0101\u0102\7[\2\2\u0102\u0103\7=\2\2\u0103D\3\2\2\2\u0104\u0105\7H\2"+ 220 | "\2\u0105\u0106\7W\2\2\u0106\u0107\7P\2\2\u0107\u0108\7E\2\2\u0108\u0109"+ 221 | "\7V\2\2\u0109\u010a\7K\2\2\u010a\u010b\7Q\2\2\u010b\u010c\7P\2\2\u010c"+ 222 | "F\3\2\2\2\u010d\u010e\7G\2\2\u010e\u010f\7P\2\2\u010f\u0110\7F\2\2\u0110"+ 223 | "\u0111\7a\2\2\u0111\u0112\7H\2\2\u0112\u0113\7W\2\2\u0113\u0114\7P\2\2"+ 224 | "\u0114\u0115\7E\2\2\u0115\u0116\7V\2\2\u0116\u0117\7K\2\2\u0117\u0118"+ 225 | "\7Q\2\2\u0118\u0119\7P\2\2\u0119\u011a\7=\2\2\u011aH\3\2\2\2\u011b\u011c"+ 226 | "\7T\2\2\u011c\u011d\7W\2\2\u011d\u011e\7N\2\2\u011e\u011f\7G\2\2\u011f"+ 227 | "J\3\2\2\2\u0120\u0121\7G\2\2\u0121\u0122\7P\2\2\u0122\u0123\7F\2\2\u0123"+ 228 | "\u0124\7a\2\2\u0124\u0125\7T\2\2\u0125\u0126\7W\2\2\u0126\u0127\7N\2\2"+ 229 | "\u0127\u0128\7G\2\2\u0128\u0129\7=\2\2\u0129L\3\2\2\2\u012a\u012b\7U\2"+ 230 | "\2\u012b\u012c\7W\2\2\u012c\u012d\7D\2\2\u012d\u012e\7V\2\2\u012e\u012f"+ 231 | "\7[\2\2\u012f\u0130\7R\2\2\u0130\u0131\7G\2\2\u0131\u0132\7\"\2\2\u0132"+ 232 | "\u0133\7Q\2\2\u0133\u0134\7H\2\2\u0134N\3\2\2\2\u0135\u0136\7U\2\2\u0136"+ 233 | "\u0137\7W\2\2\u0137\u0138\7R\2\2\u0138\u0139\7G\2\2\u0139\u013a\7T\2\2"+ 234 | "\u013a\u013b\7V\2\2\u013b\u013c\7[\2\2\u013c\u013d\7R\2\2\u013d\u013e"+ 235 | "\7G\2\2\u013e\u013f\7\"\2\2\u013f\u0140\7Q\2\2\u0140\u0141\7H\2\2\u0141"+ 236 | "P\3\2\2\2\u0142\u0143\7Q\2\2\u0143\u0144\7P\2\2\u0144\u0145\7G\2\2\u0145"+ 237 | "\u0146\7Q\2\2\u0146\u0147\7H\2\2\u0147R\3\2\2\2\u0148\u0149\7C\2\2\u0149"+ 238 | "\u014a\7D\2\2\u014a\u014b\7U\2\2\u014b\u014c\7V\2\2\u014c\u014d\7T\2\2"+ 239 | "\u014d\u014e\7C\2\2\u014e\u014f\7E\2\2\u014f\u0150\7V\2\2\u0150T\3\2\2"+ 240 | "\2\u0151\u0152\7Q\2\2\u0152\u0153\7R\2\2\u0153\u0154\7V\2\2\u0154\u0155"+ 241 | "\7K\2\2\u0155\u0156\7Q\2\2\u0156\u0157\7P\2\2\u0157\u0158\7C\2\2\u0158"+ 242 | "\u0159\7N\2\2\u0159V\3\2\2\2\u015a\u015b\7H\2\2\u015b\u015c\7K\2\2\u015c"+ 243 | "\u015d\7Z\2\2\u015d\u015e\7G\2\2\u015e\u015f\7F\2\2\u015fX\3\2\2\2\u0160"+ 244 | "\u0161\7Q\2\2\u0161\u0162\7H\2\2\u0162Z\3\2\2\2\u0163\u0164\7U\2\2\u0164"+ 245 | "\u0165\7G\2\2\u0165\u0166\7V\2\2\u0166\\\3\2\2\2\u0167\u0168\7C\2\2\u0168"+ 246 | "\u0169\7T\2\2\u0169\u016a\7T\2\2\u016a\u016b\7C\2\2\u016b\u016c\7[\2\2"+ 247 | "\u016c^\3\2\2\2\u016d\u016e\7N\2\2\u016e\u016f\7K\2\2\u016f\u0170\7U\2"+ 248 | "\2\u0170\u0171\7V\2\2\u0171`\3\2\2\2\u0172\u0173\7D\2\2\u0173\u0174\7"+ 249 | "Q\2\2\u0174\u0175\7Q\2\2\u0175\u0176\7N\2\2\u0176\u0177\7G\2\2\u0177\u0178"+ 250 | "\7C\2\2\u0178\u0179\7P\2\2\u0179b\3\2\2\2\u017a\u017b\7T\2\2\u017b\u017c"+ 251 | "\7G\2\2\u017c\u017d\7C\2\2\u017d\u017e\7N\2\2\u017ed\3\2\2\2\u017f\u0180"+ 252 | "\7K\2\2\u0180\u0181\7P\2\2\u0181\u0182\7V\2\2\u0182\u0183\7G\2\2\u0183"+ 253 | "\u0184\7I\2\2\u0184\u0185\7G\2\2\u0185\u0186\7T\2\2\u0186f\3\2\2\2\u0187"+ 254 | "\u0188\7D\2\2\u0188\u0189\7K\2\2\u0189\u018a\7P\2\2\u018a\u018b\7C\2\2"+ 255 | "\u018b\u018c\7T\2\2\u018c\u018d\7[\2\2\u018dh\3\2\2\2\u018e\u018f\7P\2"+ 256 | "\2\u018f\u0190\7W\2\2\u0190\u0191\7O\2\2\u0191\u0192\7D\2\2\u0192\u0193"+ 257 | "\7G\2\2\u0193\u0194\7T\2\2\u0194j\3\2\2\2\u0195\u0196\7U\2\2\u0196\u0197"+ 258 | "\7V\2\2\u0197\u0198\7T\2\2\u0198\u0199\7K\2\2\u0199\u019a\7P\2\2\u019a"+ 259 | "\u019b\7I\2\2\u019bl\3\2\2\2\u019c\u019d\7G\2\2\u019d\u019e\7P\2\2\u019e"+ 260 | "\u019f\7W\2\2\u019f\u01a0\7O\2\2\u01a0\u01a1\7G\2\2\u01a1\u01a2\7T\2\2"+ 261 | "\u01a2\u01a3\7C\2\2\u01a3\u01a4\7V\2\2\u01a4\u01a5\7K\2\2\u01a5\u01a6"+ 262 | "\7Q\2\2\u01a6\u01a7\7P\2\2\u01a7n\3\2\2\2\u01a8\u01a9\7U\2\2\u01a9\u01aa"+ 263 | "\7G\2\2\u01aa\u01ab\7N\2\2\u01ab\u01ac\7G\2\2\u01ac\u01ad\7E\2\2\u01ad"+ 264 | "\u01ae\7V\2\2\u01aep\3\2\2\2\u01af\u01b0\7Y\2\2\u01b0\u01b1\7J\2\2\u01b1"+ 265 | "\u01b2\7G\2\2\u01b2\u01b3\7T\2\2\u01b3\u01b4\7G\2\2\u01b4r\3\2\2\2\u01b5"+ 266 | "\u01b6\7F\2\2\u01b6\u01b7\7G\2\2\u01b7\u01b8\7T\2\2\u01b8\u01b9\7K\2\2"+ 267 | "\u01b9\u01ba\7X\2\2\u01ba\u01bb\7G\2\2\u01bbt\3\2\2\2\u01bc\u01bd\7W\2"+ 268 | "\2\u01bd\u01be\7P\2\2\u01be\u01bf\7K\2\2\u01bf\u01c0\7S\2\2\u01c0\u01c1"+ 269 | "\7W\2\2\u01c1\u01c2\7G\2\2\u01c2v\3\2\2\2\u01c3\u01c4\7K\2\2\u01c4\u01c5"+ 270 | "\7P\2\2\u01c5\u01c6\7X\2\2\u01c6\u01c7\7G\2\2\u01c7\u01c8\7T\2\2\u01c8"+ 271 | "\u01c9\7U\2\2\u01c9\u01ca\7G\2\2\u01cax\3\2\2\2\u01cb\u01cc\7U\2\2\u01cc"+ 272 | "\u01cd\7G\2\2\u01cd\u01ce\7N\2\2\u01ce\u01cf\7H\2\2\u01cf\u01d0\7^\2\2"+ 273 | "\u01d0z\3\2\2\2\u01d1\u01d2\7H\2\2\u01d2\u01d3\7Q\2\2\u01d3\u01d4\7T\2"+ 274 | "\2\u01d4|\3\2\2\2\u01d5\u01d7\t\5\2\2\u01d6\u01d5\3\2\2\2\u01d7\u01d8"+ 275 | "\3\2\2\2\u01d8\u01d6\3\2\2\2\u01d8\u01d9\3\2\2\2\u01d9~\3\2\2\2\b\2\u00b3"+ 276 | "\u00bd\u00ca\u00cd\u01d8\3\b\2\2"; 277 | public static final ATN _ATN = 278 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 279 | static { 280 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 281 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 282 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 283 | } 284 | } 285 | } -------------------------------------------------------------------------------- /src/main/java/parser/ExpressGrammarLexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | T__10=11 12 | T__11=12 13 | T__12=13 14 | T__13=14 15 | T__14=15 16 | T__15=16 17 | T__16=17 18 | T__17=18 19 | T__18=19 20 | T__19=20 21 | T__20=21 22 | T__21=22 23 | T__22=23 24 | T__23=24 25 | WS=25 26 | BLOCK_COMMENT=26 27 | INT=27 28 | SCHEMA=28 29 | END_SCHEMA=29 30 | TYPE=30 31 | END_TYPE=31 32 | ENTITY=32 33 | END_ENTITY=33 34 | FUNCTION=34 35 | END_FUNCTION=35 36 | RULE=36 37 | END_RULE=37 38 | SUBTYPE_OF=38 39 | SUPERTYPE_OF=39 40 | ONEOF=40 41 | ABSTRACT=41 42 | OPTIONAL=42 43 | FIXED=43 44 | OF=44 45 | SET=45 46 | ARRAY=46 47 | LIST=47 48 | BOOLEAN=48 49 | REAL=49 50 | INTEGER=50 51 | BINARY=51 52 | NUMBER=52 53 | STRING=53 54 | ENUMERATION=54 55 | SELECT=55 56 | WHERE=56 57 | DERIVE=57 58 | UNIQUE=58 59 | INVERSE=59 60 | SELF_=60 61 | FOR=61 62 | NAME=62 63 | ';'=1 64 | '('=2 65 | ')'=3 66 | ':'=4 67 | '['=5 68 | '?'=6 69 | ']'=7 70 | ','=8 71 | '='=9 72 | '.'=10 73 | ':='=11 74 | '<'=12 75 | '>'=13 76 | '\\'=14 77 | '/'=15 78 | '|'=16 79 | '*'=17 80 | '\''=18 81 | '"'=19 82 | '!'=20 83 | '-'=21 84 | '+'=22 85 | '{'=23 86 | '}'=24 87 | 'SCHEMA'=28 88 | 'END_SCHEMA;'=29 89 | 'TYPE'=30 90 | 'END_TYPE;'=31 91 | 'ENTITY'=32 92 | 'END_ENTITY;'=33 93 | 'FUNCTION'=34 94 | 'END_FUNCTION;'=35 95 | 'RULE'=36 96 | 'END_RULE;'=37 97 | 'SUBTYPE OF'=38 98 | 'SUPERTYPE OF'=39 99 | 'ONEOF'=40 100 | 'ABSTRACT'=41 101 | 'OPTIONAL'=42 102 | 'FIXED'=43 103 | 'OF'=44 104 | 'SET'=45 105 | 'ARRAY'=46 106 | 'LIST'=47 107 | 'BOOLEAN'=48 108 | 'REAL'=49 109 | 'INTEGER'=50 110 | 'BINARY'=51 111 | 'NUMBER'=52 112 | 'STRING'=53 113 | 'ENUMERATION'=54 114 | 'SELECT'=55 115 | 'WHERE'=56 116 | 'DERIVE'=57 117 | 'UNIQUE'=58 118 | 'INVERSE'=59 119 | 'SELF\\'=60 120 | 'FOR'=61 121 | -------------------------------------------------------------------------------- /src/main/java/parser/ExpressGrammarVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from F:/JavaWorkSpace/IfcGraph/src/main/resources\ExpressGrammar.g4 by ANTLR 4.7 2 | package parser; 3 | import org.antlr.v4.runtime.tree.ParseTreeVisitor; 4 | 5 | /** 6 | * This interface defines a complete generic visitor for a parse tree produced 7 | * by {@link ExpressGrammarParser}. 8 | * 9 | * @param The return type of the visit operation. Use {@link Void} for 10 | * operations with no return type. 11 | */ 12 | public interface ExpressGrammarVisitor extends ParseTreeVisitor { 13 | /** 14 | * Visit a parse tree produced by {@link ExpressGrammarParser#schema}. 15 | * @param ctx the parse tree 16 | * @return the visitor result 17 | */ 18 | T visitSchema(ExpressGrammarParser.SchemaContext ctx); 19 | /** 20 | * Visit a parse tree produced by {@link ExpressGrammarParser#beginSchema}. 21 | * @param ctx the parse tree 22 | * @return the visitor result 23 | */ 24 | T visitBeginSchema(ExpressGrammarParser.BeginSchemaContext ctx); 25 | /** 26 | * Visit a parse tree produced by {@link ExpressGrammarParser#entity}. 27 | * @param ctx the parse tree 28 | * @return the visitor result 29 | */ 30 | T visitEntity(ExpressGrammarParser.EntityContext ctx); 31 | /** 32 | * Visit a parse tree produced by {@link ExpressGrammarParser#beginEntity}. 33 | * @param ctx the parse tree 34 | * @return the visitor result 35 | */ 36 | T visitBeginEntity(ExpressGrammarParser.BeginEntityContext ctx); 37 | /** 38 | * Visit a parse tree produced by {@link ExpressGrammarParser#entityType}. 39 | * @param ctx the parse tree 40 | * @return the visitor result 41 | */ 42 | T visitEntityType(ExpressGrammarParser.EntityTypeContext ctx); 43 | /** 44 | * Visit a parse tree produced by the {@code subtype} 45 | * labeled alternative in {@link ExpressGrammarParser#subtypeOf}. 46 | * @param ctx the parse tree 47 | * @return the visitor result 48 | */ 49 | T visitSubtype(ExpressGrammarParser.SubtypeContext ctx); 50 | /** 51 | * Visit a parse tree produced by {@link ExpressGrammarParser#supertypeOf}. 52 | * @param ctx the parse tree 53 | * @return the visitor result 54 | */ 55 | T visitSupertypeOf(ExpressGrammarParser.SupertypeOfContext ctx); 56 | /** 57 | * Visit a parse tree produced by the {@code attr} 58 | * labeled alternative in {@link ExpressGrammarParser#entityArgument}. 59 | * @param ctx the parse tree 60 | * @return the visitor result 61 | */ 62 | T visitAttr(ExpressGrammarParser.AttrContext ctx); 63 | /** 64 | * Visit a parse tree produced by {@link ExpressGrammarParser#collectionOf}. 65 | * @param ctx the parse tree 66 | * @return the visitor result 67 | */ 68 | T visitCollectionOf(ExpressGrammarParser.CollectionOfContext ctx); 69 | /** 70 | * Visit a parse tree produced by {@link ExpressGrammarParser#collectionArgPart}. 71 | * @param ctx the parse tree 72 | * @return the visitor result 73 | */ 74 | T visitCollectionArgPart(ExpressGrammarParser.CollectionArgPartContext ctx); 75 | /** 76 | * Visit a parse tree produced by {@link ExpressGrammarParser#beginNameList}. 77 | * @param ctx the parse tree 78 | * @return the visitor result 79 | */ 80 | T visitBeginNameList(ExpressGrammarParser.BeginNameListContext ctx); 81 | /** 82 | * Visit a parse tree produced by {@link ExpressGrammarParser#endNameList}. 83 | * @param ctx the parse tree 84 | * @return the visitor result 85 | */ 86 | T visitEndNameList(ExpressGrammarParser.EndNameListContext ctx); 87 | /** 88 | * Visit a parse tree produced by {@link ExpressGrammarParser#nameList}. 89 | * @param ctx the parse tree 90 | * @return the visitor result 91 | */ 92 | T visitNameList(ExpressGrammarParser.NameListContext ctx); 93 | /** 94 | * Visit a parse tree produced by {@link ExpressGrammarParser#names}. 95 | * @param ctx the parse tree 96 | * @return the visitor result 97 | */ 98 | T visitNames(ExpressGrammarParser.NamesContext ctx); 99 | /** 100 | * Visit a parse tree produced by {@link ExpressGrammarParser#typeName}. 101 | * @param ctx the parse tree 102 | * @return the visitor result 103 | */ 104 | T visitTypeName(ExpressGrammarParser.TypeNameContext ctx); 105 | /** 106 | * Visit a parse tree produced by {@link ExpressGrammarParser#type}. 107 | * @param ctx the parse tree 108 | * @return the visitor result 109 | */ 110 | T visitType(ExpressGrammarParser.TypeContext ctx); 111 | /** 112 | * Visit a parse tree produced by {@link ExpressGrammarParser#inversePart}. 113 | * @param ctx the parse tree 114 | * @return the visitor result 115 | */ 116 | T visitInversePart(ExpressGrammarParser.InversePartContext ctx); 117 | /** 118 | * Visit a parse tree produced by {@link ExpressGrammarParser#inverseSentence}. 119 | * @param ctx the parse tree 120 | * @return the visitor result 121 | */ 122 | T visitInverseSentence(ExpressGrammarParser.InverseSentenceContext ctx); 123 | /** 124 | * Visit a parse tree produced by {@link ExpressGrammarParser#derivePart}. 125 | * @param ctx the parse tree 126 | * @return the visitor result 127 | */ 128 | T visitDerivePart(ExpressGrammarParser.DerivePartContext ctx); 129 | /** 130 | * Visit a parse tree produced by {@link ExpressGrammarParser#deriveOverrideSentence}. 131 | * @param ctx the parse tree 132 | * @return the visitor result 133 | */ 134 | T visitDeriveOverrideSentence(ExpressGrammarParser.DeriveOverrideSentenceContext ctx); 135 | /** 136 | * Visit a parse tree produced by {@link ExpressGrammarParser#deriveSentence}. 137 | * @param ctx the parse tree 138 | * @return the visitor result 139 | */ 140 | T visitDeriveSentence(ExpressGrammarParser.DeriveSentenceContext ctx); 141 | /** 142 | * Visit a parse tree produced by {@link ExpressGrammarParser#uniquePart}. 143 | * @param ctx the parse tree 144 | * @return the visitor result 145 | */ 146 | T visitUniquePart(ExpressGrammarParser.UniquePartContext ctx); 147 | /** 148 | * Visit a parse tree produced by {@link ExpressGrammarParser#uniqueSentence}. 149 | * @param ctx the parse tree 150 | * @return the visitor result 151 | */ 152 | T visitUniqueSentence(ExpressGrammarParser.UniqueSentenceContext ctx); 153 | /** 154 | * Visit a parse tree produced by {@link ExpressGrammarParser#wherePart}. 155 | * @param ctx the parse tree 156 | * @return the visitor result 157 | */ 158 | T visitWherePart(ExpressGrammarParser.WherePartContext ctx); 159 | /** 160 | * Visit a parse tree produced by {@link ExpressGrammarParser#whereSentence}. 161 | * @param ctx the parse tree 162 | * @return the visitor result 163 | */ 164 | T visitWhereSentence(ExpressGrammarParser.WhereSentenceContext ctx); 165 | /** 166 | * Visit a parse tree produced by {@link ExpressGrammarParser#function}. 167 | * @param ctx the parse tree 168 | * @return the visitor result 169 | */ 170 | T visitFunction(ExpressGrammarParser.FunctionContext ctx); 171 | /** 172 | * Visit a parse tree produced by {@link ExpressGrammarParser#therule}. 173 | * @param ctx the parse tree 174 | * @return the visitor result 175 | */ 176 | T visitTherule(ExpressGrammarParser.TheruleContext ctx); 177 | /** 178 | * Visit a parse tree produced by {@link ExpressGrammarParser#commonKeyword}. 179 | * @param ctx the parse tree 180 | * @return the visitor result 181 | */ 182 | T visitCommonKeyword(ExpressGrammarParser.CommonKeywordContext ctx); 183 | /** 184 | * Visit a parse tree produced by {@link ExpressGrammarParser#commonSentence}. 185 | * @param ctx the parse tree 186 | * @return the visitor result 187 | */ 188 | T visitCommonSentence(ExpressGrammarParser.CommonSentenceContext ctx); 189 | /** 190 | * Visit a parse tree produced by {@link ExpressGrammarParser#typeSingleKeyword}. 191 | * @param ctx the parse tree 192 | * @return the visitor result 193 | */ 194 | T visitTypeSingleKeyword(ExpressGrammarParser.TypeSingleKeywordContext ctx); 195 | /** 196 | * Visit a parse tree produced by {@link ExpressGrammarParser#typeArrayKeyword}. 197 | * @param ctx the parse tree 198 | * @return the visitor result 199 | */ 200 | T visitTypeArrayKeyword(ExpressGrammarParser.TypeArrayKeywordContext ctx); 201 | /** 202 | * Visit a parse tree produced by {@link ExpressGrammarParser#typeKeyword}. 203 | * @param ctx the parse tree 204 | * @return the visitor result 205 | */ 206 | T visitTypeKeyword(ExpressGrammarParser.TypeKeywordContext ctx); 207 | /** 208 | * Visit a parse tree produced by {@link ExpressGrammarParser#innerKeyword}. 209 | * @param ctx the parse tree 210 | * @return the visitor result 211 | */ 212 | T visitInnerKeyword(ExpressGrammarParser.InnerKeywordContext ctx); 213 | /** 214 | * Visit a parse tree produced by {@link ExpressGrammarParser#sign}. 215 | * @param ctx the parse tree 216 | * @return the visitor result 217 | */ 218 | T visitSign(ExpressGrammarParser.SignContext ctx); 219 | } -------------------------------------------------------------------------------- /src/main/java/parser/STEPGrammar.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | WS=11 12 | BLOCK_COMMENT=12 13 | LINE_COMMENT=13 14 | NONDEF=14 15 | OVERRIDE=15 16 | BOOLEAN=16 17 | INT=17 18 | NEGINT=18 19 | INTEXP=19 20 | FLOAT=20 21 | ENUM=21 22 | STRING=22 23 | ISOSTEPSTART=23 24 | ISOSTEPEND=24 25 | HEADER=25 26 | DATA=26 27 | ENDSEC=27 28 | NAME=28 29 | 'FILE_DESCRIPTION'=1 30 | '('=2 31 | ')'=3 32 | ';'=4 33 | 'FILE_NAME'=5 34 | ','=6 35 | 'FILE_SCHEMA'=7 36 | '#'=8 37 | '='=9 38 | '()'=10 39 | '$'=14 40 | '*'=15 41 | 'HEADER;'=25 42 | 'DATA;'=26 43 | 'ENDSEC;'=27 44 | -------------------------------------------------------------------------------- /src/main/java/parser/STEPGrammarBaseVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from F:/JavaWorkSpace/IfcGraph/src/main/resources\STEPGrammar.g4 by ANTLR 4.7 2 | package parser; 3 | import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; 4 | 5 | /** 6 | * This class provides an empty implementation of {@link STEPGrammarVisitor}, 7 | * which can be extended to create a visitor which only needs to handle a subset 8 | * of the available methods. 9 | * 10 | * @param The return type of the visit operation. Use {@link Void} for 11 | * operations with no return type. 12 | */ 13 | public class STEPGrammarBaseVisitor extends AbstractParseTreeVisitor implements STEPGrammarVisitor { 14 | /** 15 | * {@inheritDoc} 16 | * 17 | *

The default implementation returns the result of calling 18 | * {@link #visitChildren} on {@code ctx}.

19 | */ 20 | @Override public T visitIfcFile(STEPGrammarParser.IfcFileContext ctx) { return visitChildren(ctx); } 21 | /** 22 | * {@inheritDoc} 23 | * 24 | *

The default implementation returns the result of calling 25 | * {@link #visitChildren} on {@code ctx}.

26 | */ 27 | @Override public T visitHeader(STEPGrammarParser.HeaderContext ctx) { return visitChildren(ctx); } 28 | /** 29 | * {@inheritDoc} 30 | * 31 | *

The default implementation returns the result of calling 32 | * {@link #visitChildren} on {@code ctx}.

33 | */ 34 | @Override public T visitFiledescipt(STEPGrammarParser.FiledesciptContext ctx) { return visitChildren(ctx); } 35 | /** 36 | * {@inheritDoc} 37 | * 38 | *

The default implementation returns the result of calling 39 | * {@link #visitChildren} on {@code ctx}.

40 | */ 41 | @Override public T visitFilename(STEPGrammarParser.FilenameContext ctx) { return visitChildren(ctx); } 42 | /** 43 | * {@inheritDoc} 44 | * 45 | *

The default implementation returns the result of calling 46 | * {@link #visitChildren} on {@code ctx}.

47 | */ 48 | @Override public T visitFileschema(STEPGrammarParser.FileschemaContext ctx) { return visitChildren(ctx); } 49 | /** 50 | * {@inheritDoc} 51 | * 52 | *

The default implementation returns the result of calling 53 | * {@link #visitChildren} on {@code ctx}.

54 | */ 55 | @Override public T visitData(STEPGrammarParser.DataContext ctx) { return visitChildren(ctx); } 56 | /** 57 | * {@inheritDoc} 58 | * 59 | *

The default implementation returns the result of calling 60 | * {@link #visitChildren} on {@code ctx}.

61 | */ 62 | @Override public T visitDataLine(STEPGrammarParser.DataLineContext ctx) { return visitChildren(ctx); } 63 | /** 64 | * {@inheritDoc} 65 | * 66 | *

The default implementation returns the result of calling 67 | * {@link #visitChildren} on {@code ctx}.

68 | */ 69 | @Override public T visitTypedListArgument(STEPGrammarParser.TypedListArgumentContext ctx) { return visitChildren(ctx); } 70 | /** 71 | * {@inheritDoc} 72 | * 73 | *

The default implementation returns the result of calling 74 | * {@link #visitChildren} on {@code ctx}.

75 | */ 76 | @Override public T visitArgument(STEPGrammarParser.ArgumentContext ctx) { return visitChildren(ctx); } 77 | /** 78 | * {@inheritDoc} 79 | * 80 | *

The default implementation returns the result of calling 81 | * {@link #visitChildren} on {@code ctx}.

82 | */ 83 | @Override public T visitListArgument(STEPGrammarParser.ListArgumentContext ctx) { return visitChildren(ctx); } 84 | /** 85 | * {@inheritDoc} 86 | * 87 | *

The default implementation returns the result of calling 88 | * {@link #visitChildren} on {@code ctx}.

89 | */ 90 | @Override public T visitArgumentList(STEPGrammarParser.ArgumentListContext ctx) { return visitChildren(ctx); } 91 | } -------------------------------------------------------------------------------- /src/main/java/parser/STEPGrammarLexer.java: -------------------------------------------------------------------------------- 1 | // Generated from F:/JavaWorkSpace/IfcGraph/src/main/resources\STEPGrammar.g4 by ANTLR 4.7 2 | package parser; 3 | import org.antlr.v4.runtime.Lexer; 4 | import org.antlr.v4.runtime.CharStream; 5 | import org.antlr.v4.runtime.*; 6 | import org.antlr.v4.runtime.atn.*; 7 | import org.antlr.v4.runtime.dfa.DFA; 8 | 9 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 10 | public class STEPGrammarLexer extends Lexer { 11 | static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } 12 | 13 | protected static final DFA[] _decisionToDFA; 14 | protected static final PredictionContextCache _sharedContextCache = 15 | new PredictionContextCache(); 16 | public static final int 17 | T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, 18 | T__9=10, WS=11, BLOCK_COMMENT=12, LINE_COMMENT=13, NONDEF=14, OVERRIDE=15, 19 | BOOLEAN=16, INT=17, NEGINT=18, INTEXP=19, FLOAT=20, ENUM=21, STRING=22, 20 | ISOSTEPSTART=23, ISOSTEPEND=24, HEADER=25, DATA=26, ENDSEC=27, NAME=28; 21 | public static String[] channelNames = { 22 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN" 23 | }; 24 | 25 | public static String[] modeNames = { 26 | "DEFAULT_MODE" 27 | }; 28 | 29 | public static final String[] ruleNames = { 30 | "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", 31 | "T__9", "WS", "BLOCK_COMMENT", "LINE_COMMENT", "NONDEF", "OVERRIDE", "BOOLEAN", 32 | "INT", "NEGINT", "INTEXP", "FLOAT", "EXP", "ENUM", "STRING", "ISOSTEPSTART", 33 | "ISOSTEPEND", "HEADER", "DATA", "ENDSEC", "NAME" 34 | }; 35 | 36 | private static final String[] _LITERAL_NAMES = { 37 | null, "'FILE_DESCRIPTION'", "'('", "')'", "';'", "'FILE_NAME'", "','", 38 | "'FILE_SCHEMA'", "'#'", "'='", "'()'", null, null, null, "'$'", "'*'", 39 | null, null, null, null, null, null, null, null, null, "'HEADER;'", "'DATA;'", 40 | "'ENDSEC;'" 41 | }; 42 | private static final String[] _SYMBOLIC_NAMES = { 43 | null, null, null, null, null, null, null, null, null, null, null, "WS", 44 | "BLOCK_COMMENT", "LINE_COMMENT", "NONDEF", "OVERRIDE", "BOOLEAN", "INT", 45 | "NEGINT", "INTEXP", "FLOAT", "ENUM", "STRING", "ISOSTEPSTART", "ISOSTEPEND", 46 | "HEADER", "DATA", "ENDSEC", "NAME" 47 | }; 48 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 49 | 50 | /** 51 | * @deprecated Use {@link #VOCABULARY} instead. 52 | */ 53 | @Deprecated 54 | public static final String[] tokenNames; 55 | static { 56 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 57 | for (int i = 0; i < tokenNames.length; i++) { 58 | tokenNames[i] = VOCABULARY.getLiteralName(i); 59 | if (tokenNames[i] == null) { 60 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 61 | } 62 | 63 | if (tokenNames[i] == null) { 64 | tokenNames[i] = ""; 65 | } 66 | } 67 | } 68 | 69 | @Override 70 | @Deprecated 71 | public String[] getTokenNames() { 72 | return tokenNames; 73 | } 74 | 75 | @Override 76 | 77 | public Vocabulary getVocabulary() { 78 | return VOCABULARY; 79 | } 80 | 81 | 82 | public STEPGrammarLexer(CharStream input) { 83 | super(input); 84 | _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 85 | } 86 | 87 | @Override 88 | public String getGrammarFileName() { return "STEPGrammar.g4"; } 89 | 90 | @Override 91 | public String[] getRuleNames() { return ruleNames; } 92 | 93 | @Override 94 | public String getSerializedATN() { return _serializedATN; } 95 | 96 | @Override 97 | public String[] getChannelNames() { return channelNames; } 98 | 99 | @Override 100 | public String[] getModeNames() { return modeNames; } 101 | 102 | @Override 103 | public ATN getATN() { return _ATN; } 104 | 105 | public static final String _serializedATN = 106 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\36\u012a\b\1\4\2"+ 107 | "\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4"+ 108 | "\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22"+ 109 | "\t\22\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31"+ 110 | "\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\3\2\3\2\3\2\3"+ 111 | "\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\4\3\4"+ 112 | "\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\b\3\b\3\b\3"+ 113 | "\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\n\3\n\3\13\3\13\3\13\3\f"+ 114 | "\6\fu\n\f\r\f\16\fv\3\f\3\f\3\r\3\r\3\r\3\r\7\r\177\n\r\f\r\16\r\u0082"+ 115 | "\13\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\7\16\u008d\n\16\f\16\16"+ 116 | "\16\u0090\13\16\3\16\3\16\3\17\3\17\3\20\3\20\3\21\3\21\3\21\3\21\3\21"+ 117 | "\3\21\5\21\u009e\n\21\3\22\3\22\3\22\7\22\u00a3\n\22\f\22\16\22\u00a6"+ 118 | "\13\22\5\22\u00a8\n\22\3\23\3\23\3\23\3\24\3\24\5\24\u00af\n\24\3\24\3"+ 119 | "\24\3\25\3\25\6\25\u00b5\n\25\r\25\16\25\u00b6\3\25\5\25\u00ba\n\25\3"+ 120 | "\25\3\25\5\25\u00be\n\25\3\25\3\25\7\25\u00c2\n\25\f\25\16\25\u00c5\13"+ 121 | "\25\3\25\5\25\u00c8\n\25\5\25\u00ca\n\25\3\26\3\26\5\26\u00ce\n\26\3\26"+ 122 | "\7\26\u00d1\n\26\f\26\16\26\u00d4\13\26\3\27\3\27\3\27\3\27\3\30\3\30"+ 123 | "\3\30\3\30\7\30\u00de\n\30\f\30\16\30\u00e1\13\30\3\30\3\30\3\31\3\31"+ 124 | "\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31\7\31\u00ef\n\31\f\31\16\31\u00f2"+ 125 | "\13\31\3\31\5\31\u00f5\n\31\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3"+ 126 | "\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\7\32\u0108\n\32\f\32\16\32"+ 127 | "\u010b\13\32\3\32\5\32\u010e\n\32\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3"+ 128 | "\33\3\34\3\34\3\34\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3"+ 129 | "\35\3\36\6\36\u0127\n\36\r\36\16\36\u0128\3\u0080\2\37\3\3\5\4\7\5\t\6"+ 130 | "\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24"+ 131 | "\'\25)\26+\2-\27/\30\61\31\63\32\65\33\67\349\35;\36\3\2\13\5\2\13\f\17"+ 132 | "\17\"\"\4\2\f\f\17\17\3\2\63;\3\2\62;\4\2GGgg\4\2--//\3\2))\4\2//\62;"+ 133 | "\6\2\62;C\\aac|\2\u013e\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2"+ 134 | "\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25"+ 135 | "\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2"+ 136 | "\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2-\3\2\2"+ 137 | "\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3"+ 138 | "\2\2\2\2;\3\2\2\2\3=\3\2\2\2\5N\3\2\2\2\7P\3\2\2\2\tR\3\2\2\2\13T\3\2"+ 139 | "\2\2\r^\3\2\2\2\17`\3\2\2\2\21l\3\2\2\2\23n\3\2\2\2\25p\3\2\2\2\27t\3"+ 140 | "\2\2\2\31z\3\2\2\2\33\u0088\3\2\2\2\35\u0093\3\2\2\2\37\u0095\3\2\2\2"+ 141 | "!\u009d\3\2\2\2#\u00a7\3\2\2\2%\u00a9\3\2\2\2\'\u00ae\3\2\2\2)\u00c9\3"+ 142 | "\2\2\2+\u00cb\3\2\2\2-\u00d5\3\2\2\2/\u00d9\3\2\2\2\61\u00f4\3\2\2\2\63"+ 143 | "\u010d\3\2\2\2\65\u010f\3\2\2\2\67\u0117\3\2\2\29\u011d\3\2\2\2;\u0126"+ 144 | "\3\2\2\2=>\7H\2\2>?\7K\2\2?@\7N\2\2@A\7G\2\2AB\7a\2\2BC\7F\2\2CD\7G\2"+ 145 | "\2DE\7U\2\2EF\7E\2\2FG\7T\2\2GH\7K\2\2HI\7R\2\2IJ\7V\2\2JK\7K\2\2KL\7"+ 146 | "Q\2\2LM\7P\2\2M\4\3\2\2\2NO\7*\2\2O\6\3\2\2\2PQ\7+\2\2Q\b\3\2\2\2RS\7"+ 147 | "=\2\2S\n\3\2\2\2TU\7H\2\2UV\7K\2\2VW\7N\2\2WX\7G\2\2XY\7a\2\2YZ\7P\2\2"+ 148 | "Z[\7C\2\2[\\\7O\2\2\\]\7G\2\2]\f\3\2\2\2^_\7.\2\2_\16\3\2\2\2`a\7H\2\2"+ 149 | "ab\7K\2\2bc\7N\2\2cd\7G\2\2de\7a\2\2ef\7U\2\2fg\7E\2\2gh\7J\2\2hi\7G\2"+ 150 | "\2ij\7O\2\2jk\7C\2\2k\20\3\2\2\2lm\7%\2\2m\22\3\2\2\2no\7?\2\2o\24\3\2"+ 151 | "\2\2pq\7*\2\2qr\7+\2\2r\26\3\2\2\2su\t\2\2\2ts\3\2\2\2uv\3\2\2\2vt\3\2"+ 152 | "\2\2vw\3\2\2\2wx\3\2\2\2xy\b\f\2\2y\30\3\2\2\2z{\7\61\2\2{|\7,\2\2|\u0080"+ 153 | "\3\2\2\2}\177\13\2\2\2~}\3\2\2\2\177\u0082\3\2\2\2\u0080\u0081\3\2\2\2"+ 154 | "\u0080~\3\2\2\2\u0081\u0083\3\2\2\2\u0082\u0080\3\2\2\2\u0083\u0084\7"+ 155 | ",\2\2\u0084\u0085\7\61\2\2\u0085\u0086\3\2\2\2\u0086\u0087\b\r\2\2\u0087"+ 156 | "\32\3\2\2\2\u0088\u0089\7\61\2\2\u0089\u008a\7\61\2\2\u008a\u008e\3\2"+ 157 | "\2\2\u008b\u008d\n\3\2\2\u008c\u008b\3\2\2\2\u008d\u0090\3\2\2\2\u008e"+ 158 | "\u008c\3\2\2\2\u008e\u008f\3\2\2\2\u008f\u0091\3\2\2\2\u0090\u008e\3\2"+ 159 | "\2\2\u0091\u0092\b\16\2\2\u0092\34\3\2\2\2\u0093\u0094\7&\2\2\u0094\36"+ 160 | "\3\2\2\2\u0095\u0096\7,\2\2\u0096 \3\2\2\2\u0097\u0098\7\60\2\2\u0098"+ 161 | "\u0099\7V\2\2\u0099\u009e\7\60\2\2\u009a\u009b\7\60\2\2\u009b\u009c\7"+ 162 | "H\2\2\u009c\u009e\7\60\2\2\u009d\u0097\3\2\2\2\u009d\u009a\3\2\2\2\u009e"+ 163 | "\"\3\2\2\2\u009f\u00a8\7\62\2\2\u00a0\u00a4\t\4\2\2\u00a1\u00a3\t\5\2"+ 164 | "\2\u00a2\u00a1\3\2\2\2\u00a3\u00a6\3\2\2\2\u00a4\u00a2\3\2\2\2\u00a4\u00a5"+ 165 | "\3\2\2\2\u00a5\u00a8\3\2\2\2\u00a6\u00a4\3\2\2\2\u00a7\u009f\3\2\2\2\u00a7"+ 166 | "\u00a0\3\2\2\2\u00a8$\3\2\2\2\u00a9\u00aa\7/\2\2\u00aa\u00ab\5#\22\2\u00ab"+ 167 | "&\3\2\2\2\u00ac\u00af\5#\22\2\u00ad\u00af\5%\23\2\u00ae\u00ac\3\2\2\2"+ 168 | "\u00ae\u00ad\3\2\2\2\u00af\u00b0\3\2\2\2\u00b0\u00b1\5+\26\2\u00b1(\3"+ 169 | "\2\2\2\u00b2\u00b4\7\60\2\2\u00b3\u00b5\t\5\2\2\u00b4\u00b3\3\2\2\2\u00b5"+ 170 | "\u00b6\3\2\2\2\u00b6\u00b4\3\2\2\2\u00b6\u00b7\3\2\2\2\u00b7\u00b9\3\2"+ 171 | "\2\2\u00b8\u00ba\5+\26\2\u00b9\u00b8\3\2\2\2\u00b9\u00ba\3\2\2\2\u00ba"+ 172 | "\u00ca\3\2\2\2\u00bb\u00be\5#\22\2\u00bc\u00be\5%\23\2\u00bd\u00bb\3\2"+ 173 | "\2\2\u00bd\u00bc\3\2\2\2\u00be\u00bf\3\2\2\2\u00bf\u00c3\7\60\2\2\u00c0"+ 174 | "\u00c2\t\5\2\2\u00c1\u00c0\3\2\2\2\u00c2\u00c5\3\2\2\2\u00c3\u00c1\3\2"+ 175 | "\2\2\u00c3\u00c4\3\2\2\2\u00c4\u00c7\3\2\2\2\u00c5\u00c3\3\2\2\2\u00c6"+ 176 | "\u00c8\5+\26\2\u00c7\u00c6\3\2\2\2\u00c7\u00c8\3\2\2\2\u00c8\u00ca\3\2"+ 177 | "\2\2\u00c9\u00b2\3\2\2\2\u00c9\u00bd\3\2\2\2\u00ca*\3\2\2\2\u00cb\u00cd"+ 178 | "\t\6\2\2\u00cc\u00ce\t\7\2\2\u00cd\u00cc\3\2\2\2\u00cd\u00ce\3\2\2\2\u00ce"+ 179 | "\u00d2\3\2\2\2\u00cf\u00d1\t\5\2\2\u00d0\u00cf\3\2\2\2\u00d1\u00d4\3\2"+ 180 | "\2\2\u00d2\u00d0\3\2\2\2\u00d2\u00d3\3\2\2\2\u00d3,\3\2\2\2\u00d4\u00d2"+ 181 | "\3\2\2\2\u00d5\u00d6\7\60\2\2\u00d6\u00d7\5;\36\2\u00d7\u00d8\7\60\2\2"+ 182 | "\u00d8.\3\2\2\2\u00d9\u00df\7)\2\2\u00da\u00de\n\b\2\2\u00db\u00dc\7)"+ 183 | "\2\2\u00dc\u00de\7)\2\2\u00dd\u00da\3\2\2\2\u00dd\u00db\3\2\2\2\u00de"+ 184 | "\u00e1\3\2\2\2\u00df\u00dd\3\2\2\2\u00df\u00e0\3\2\2\2\u00e0\u00e2\3\2"+ 185 | "\2\2\u00e1\u00df\3\2\2\2\u00e2\u00e3\7)\2\2\u00e3\60\3\2\2\2\u00e4\u00e5"+ 186 | "\7U\2\2\u00e5\u00e6\7V\2\2\u00e6\u00e7\7G\2\2\u00e7\u00e8\7R\2\2\u00e8"+ 187 | "\u00f5\7=\2\2\u00e9\u00ea\7K\2\2\u00ea\u00eb\7U\2\2\u00eb\u00ec\7Q\2\2"+ 188 | "\u00ec\u00f0\3\2\2\2\u00ed\u00ef\t\t\2\2\u00ee\u00ed\3\2\2\2\u00ef\u00f2"+ 189 | "\3\2\2\2\u00f0\u00ee\3\2\2\2\u00f0\u00f1\3\2\2\2\u00f1\u00f3\3\2\2\2\u00f2"+ 190 | "\u00f0\3\2\2\2\u00f3\u00f5\7=\2\2\u00f4\u00e4\3\2\2\2\u00f4\u00e9\3\2"+ 191 | "\2\2\u00f5\62\3\2\2\2\u00f6\u00f7\7G\2\2\u00f7\u00f8\7P\2\2\u00f8\u00f9"+ 192 | "\7F\2\2\u00f9\u00fa\7U\2\2\u00fa\u00fb\7V\2\2\u00fb\u00fc\7G\2\2\u00fc"+ 193 | "\u00fd\7R\2\2\u00fd\u010e\7=\2\2\u00fe\u00ff\7G\2\2\u00ff\u0100\7P\2\2"+ 194 | "\u0100\u0101\7F\2\2\u0101\u0102\7/\2\2\u0102\u0103\7K\2\2\u0103\u0104"+ 195 | "\7U\2\2\u0104\u0105\7Q\2\2\u0105\u0109\3\2\2\2\u0106\u0108\t\t\2\2\u0107"+ 196 | "\u0106\3\2\2\2\u0108\u010b\3\2\2\2\u0109\u0107\3\2\2\2\u0109\u010a\3\2"+ 197 | "\2\2\u010a\u010c\3\2\2\2\u010b\u0109\3\2\2\2\u010c\u010e\7=\2\2\u010d"+ 198 | "\u00f6\3\2\2\2\u010d\u00fe\3\2\2\2\u010e\64\3\2\2\2\u010f\u0110\7J\2\2"+ 199 | "\u0110\u0111\7G\2\2\u0111\u0112\7C\2\2\u0112\u0113\7F\2\2\u0113\u0114"+ 200 | "\7G\2\2\u0114\u0115\7T\2\2\u0115\u0116\7=\2\2\u0116\66\3\2\2\2\u0117\u0118"+ 201 | "\7F\2\2\u0118\u0119\7C\2\2\u0119\u011a\7V\2\2\u011a\u011b\7C\2\2\u011b"+ 202 | "\u011c\7=\2\2\u011c8\3\2\2\2\u011d\u011e\7G\2\2\u011e\u011f\7P\2\2\u011f"+ 203 | "\u0120\7F\2\2\u0120\u0121\7U\2\2\u0121\u0122\7G\2\2\u0122\u0123\7E\2\2"+ 204 | "\u0123\u0124\7=\2\2\u0124:\3\2\2\2\u0125\u0127\t\n\2\2\u0126\u0125\3\2"+ 205 | "\2\2\u0127\u0128\3\2\2\2\u0128\u0126\3\2\2\2\u0128\u0129\3\2\2\2\u0129"+ 206 | "<\3\2\2\2\31\2v\u0080\u008e\u009d\u00a4\u00a7\u00ae\u00b6\u00b9\u00bd"+ 207 | "\u00c3\u00c7\u00c9\u00cd\u00d2\u00dd\u00df\u00f0\u00f4\u0109\u010d\u0128"+ 208 | "\3\b\2\2"; 209 | public static final ATN _ATN = 210 | new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 211 | static { 212 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 213 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 214 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 215 | } 216 | } 217 | } -------------------------------------------------------------------------------- /src/main/java/parser/STEPGrammarParser.java: -------------------------------------------------------------------------------- 1 | // Generated from F:/JavaWorkSpace/IfcGraph/src/main/resources\STEPGrammar.g4 by ANTLR 4.7 2 | package parser; 3 | import org.antlr.v4.runtime.atn.*; 4 | import org.antlr.v4.runtime.dfa.DFA; 5 | import org.antlr.v4.runtime.*; 6 | import org.antlr.v4.runtime.tree.*; 7 | import java.util.List; 8 | 9 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 10 | public class STEPGrammarParser extends Parser { 11 | static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } 12 | 13 | protected static final DFA[] _decisionToDFA; 14 | protected static final PredictionContextCache _sharedContextCache = 15 | new PredictionContextCache(); 16 | public static final int 17 | T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, 18 | T__9=10, WS=11, BLOCK_COMMENT=12, LINE_COMMENT=13, NONDEF=14, OVERRIDE=15, 19 | BOOLEAN=16, INT=17, NEGINT=18, INTEXP=19, FLOAT=20, ENUM=21, STRING=22, 20 | ISOSTEPSTART=23, ISOSTEPEND=24, HEADER=25, DATA=26, ENDSEC=27, NAME=28; 21 | public static final int 22 | RULE_ifcFile = 0, RULE_header = 1, RULE_headerLine = 2, RULE_data = 3, 23 | RULE_dataLine = 4, RULE_typedListArgument = 5, RULE_argument = 6, RULE_listArgument = 7, 24 | RULE_argumentList = 8; 25 | public static final String[] ruleNames = { 26 | "ifcFile", "header", "headerLine", "data", "dataLine", "typedListArgument", 27 | "argument", "listArgument", "argumentList" 28 | }; 29 | 30 | private static final String[] _LITERAL_NAMES = { 31 | null, "'FILE_DESCRIPTION'", "'('", "')'", "';'", "'FILE_NAME'", "','", 32 | "'FILE_SCHEMA'", "'#'", "'='", "'()'", null, null, null, "'$'", "'*'", 33 | null, null, null, null, null, null, null, null, null, "'HEADER;'", "'DATA;'", 34 | "'ENDSEC;'" 35 | }; 36 | private static final String[] _SYMBOLIC_NAMES = { 37 | null, null, null, null, null, null, null, null, null, null, null, "WS", 38 | "BLOCK_COMMENT", "LINE_COMMENT", "NONDEF", "OVERRIDE", "BOOLEAN", "INT", 39 | "NEGINT", "INTEXP", "FLOAT", "ENUM", "STRING", "ISOSTEPSTART", "ISOSTEPEND", 40 | "HEADER", "DATA", "ENDSEC", "NAME" 41 | }; 42 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 43 | 44 | /** 45 | * @deprecated Use {@link #VOCABULARY} instead. 46 | */ 47 | @Deprecated 48 | public static final String[] tokenNames; 49 | static { 50 | tokenNames = new String[_SYMBOLIC_NAMES.length]; 51 | for (int i = 0; i < tokenNames.length; i++) { 52 | tokenNames[i] = VOCABULARY.getLiteralName(i); 53 | if (tokenNames[i] == null) { 54 | tokenNames[i] = VOCABULARY.getSymbolicName(i); 55 | } 56 | 57 | if (tokenNames[i] == null) { 58 | tokenNames[i] = ""; 59 | } 60 | } 61 | } 62 | 63 | @Override 64 | @Deprecated 65 | public String[] getTokenNames() { 66 | return tokenNames; 67 | } 68 | 69 | @Override 70 | 71 | public Vocabulary getVocabulary() { 72 | return VOCABULARY; 73 | } 74 | 75 | @Override 76 | public String getGrammarFileName() { return "STEPGrammar.g4"; } 77 | 78 | @Override 79 | public String[] getRuleNames() { return ruleNames; } 80 | 81 | @Override 82 | public String getSerializedATN() { return _serializedATN; } 83 | 84 | @Override 85 | public ATN getATN() { return _ATN; } 86 | 87 | public STEPGrammarParser(TokenStream input) { 88 | super(input); 89 | _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 90 | } 91 | public static class IfcFileContext extends ParserRuleContext { 92 | public TerminalNode ISOSTEPSTART() { return getToken(STEPGrammarParser.ISOSTEPSTART, 0); } 93 | public TerminalNode ISOSTEPEND() { return getToken(STEPGrammarParser.ISOSTEPEND, 0); } 94 | public TerminalNode EOF() { return getToken(STEPGrammarParser.EOF, 0); } 95 | public HeaderContext header() { 96 | return getRuleContext(HeaderContext.class,0); 97 | } 98 | public DataContext data() { 99 | return getRuleContext(DataContext.class,0); 100 | } 101 | public IfcFileContext(ParserRuleContext parent, int invokingState) { 102 | super(parent, invokingState); 103 | } 104 | @Override public int getRuleIndex() { return RULE_ifcFile; } 105 | @Override 106 | public T accept(ParseTreeVisitor visitor) { 107 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitIfcFile(this); 108 | else return visitor.visitChildren(this); 109 | } 110 | } 111 | 112 | public final IfcFileContext ifcFile() throws RecognitionException { 113 | IfcFileContext _localctx = new IfcFileContext(_ctx, getState()); 114 | enterRule(_localctx, 0, RULE_ifcFile); 115 | int _la; 116 | try { 117 | enterOuterAlt(_localctx, 1); 118 | { 119 | setState(18); 120 | match(ISOSTEPSTART); 121 | setState(20); 122 | _errHandler.sync(this); 123 | _la = _input.LA(1); 124 | if (_la==HEADER) { 125 | { 126 | setState(19); 127 | header(); 128 | } 129 | } 130 | 131 | setState(23); 132 | _errHandler.sync(this); 133 | _la = _input.LA(1); 134 | if (_la==DATA) { 135 | { 136 | setState(22); 137 | data(); 138 | } 139 | } 140 | 141 | setState(25); 142 | match(ISOSTEPEND); 143 | setState(26); 144 | match(EOF); 145 | } 146 | } 147 | catch (RecognitionException re) { 148 | _localctx.exception = re; 149 | _errHandler.reportError(this, re); 150 | _errHandler.recover(this, re); 151 | } 152 | finally { 153 | exitRule(); 154 | } 155 | return _localctx; 156 | } 157 | 158 | public static class HeaderContext extends ParserRuleContext { 159 | public List headerLine() { 160 | return getRuleContexts(HeaderLineContext.class); 161 | } 162 | public HeaderLineContext headerLine(int i) { 163 | return getRuleContext(HeaderLineContext.class,i); 164 | } 165 | public HeaderContext(ParserRuleContext parent, int invokingState) { 166 | super(parent, invokingState); 167 | } 168 | @Override public int getRuleIndex() { return RULE_header; } 169 | @Override 170 | public T accept(ParseTreeVisitor visitor) { 171 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitHeader(this); 172 | else return visitor.visitChildren(this); 173 | } 174 | } 175 | 176 | public final HeaderContext header() throws RecognitionException { 177 | HeaderContext _localctx = new HeaderContext(_ctx, getState()); 178 | enterRule(_localctx, 2, RULE_header); 179 | int _la; 180 | try { 181 | enterOuterAlt(_localctx, 1); 182 | { 183 | setState(28); 184 | match(HEADER); 185 | setState(32); 186 | _errHandler.sync(this); 187 | _la = _input.LA(1); 188 | while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__4) | (1L << T__6))) != 0)) { 189 | { 190 | { 191 | setState(29); 192 | headerLine(); 193 | } 194 | } 195 | setState(34); 196 | _errHandler.sync(this); 197 | _la = _input.LA(1); 198 | } 199 | setState(35); 200 | match(ENDSEC); 201 | } 202 | } 203 | catch (RecognitionException re) { 204 | _localctx.exception = re; 205 | _errHandler.reportError(this, re); 206 | _errHandler.recover(this, re); 207 | } 208 | finally { 209 | exitRule(); 210 | } 211 | return _localctx; 212 | } 213 | 214 | public static class HeaderLineContext extends ParserRuleContext { 215 | public HeaderLineContext(ParserRuleContext parent, int invokingState) { 216 | super(parent, invokingState); 217 | } 218 | @Override public int getRuleIndex() { return RULE_headerLine; } 219 | 220 | public HeaderLineContext() { } 221 | public void copyFrom(HeaderLineContext ctx) { 222 | super.copyFrom(ctx); 223 | } 224 | } 225 | public static class FilenameContext extends HeaderLineContext { 226 | public TerminalNode STRING() { return getToken(STEPGrammarParser.STRING, 0); } 227 | public ArgumentListContext argumentList() { 228 | return getRuleContext(ArgumentListContext.class,0); 229 | } 230 | public FilenameContext(HeaderLineContext ctx) { copyFrom(ctx); } 231 | @Override 232 | public T accept(ParseTreeVisitor visitor) { 233 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitFilename(this); 234 | else return visitor.visitChildren(this); 235 | } 236 | } 237 | public static class FileschemaContext extends HeaderLineContext { 238 | public TerminalNode STRING() { return getToken(STEPGrammarParser.STRING, 0); } 239 | public FileschemaContext(HeaderLineContext ctx) { copyFrom(ctx); } 240 | @Override 241 | public T accept(ParseTreeVisitor visitor) { 242 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitFileschema(this); 243 | else return visitor.visitChildren(this); 244 | } 245 | } 246 | public static class FiledesciptContext extends HeaderLineContext { 247 | public ArgumentListContext argumentList() { 248 | return getRuleContext(ArgumentListContext.class,0); 249 | } 250 | public FiledesciptContext(HeaderLineContext ctx) { copyFrom(ctx); } 251 | @Override 252 | public T accept(ParseTreeVisitor visitor) { 253 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitFiledescipt(this); 254 | else return visitor.visitChildren(this); 255 | } 256 | } 257 | 258 | public final HeaderLineContext headerLine() throws RecognitionException { 259 | HeaderLineContext _localctx = new HeaderLineContext(_ctx, getState()); 260 | enterRule(_localctx, 4, RULE_headerLine); 261 | try { 262 | setState(58); 263 | _errHandler.sync(this); 264 | switch (_input.LA(1)) { 265 | case T__0: 266 | _localctx = new FiledesciptContext(_localctx); 267 | enterOuterAlt(_localctx, 1); 268 | { 269 | setState(37); 270 | match(T__0); 271 | setState(38); 272 | match(T__1); 273 | setState(39); 274 | argumentList(); 275 | setState(40); 276 | match(T__2); 277 | setState(41); 278 | match(T__3); 279 | } 280 | break; 281 | case T__4: 282 | _localctx = new FilenameContext(_localctx); 283 | enterOuterAlt(_localctx, 2); 284 | { 285 | setState(43); 286 | match(T__4); 287 | setState(44); 288 | match(T__1); 289 | setState(45); 290 | match(STRING); 291 | setState(46); 292 | match(T__5); 293 | setState(47); 294 | argumentList(); 295 | setState(48); 296 | match(T__2); 297 | setState(49); 298 | match(T__3); 299 | } 300 | break; 301 | case T__6: 302 | _localctx = new FileschemaContext(_localctx); 303 | enterOuterAlt(_localctx, 3); 304 | { 305 | setState(51); 306 | match(T__6); 307 | setState(52); 308 | match(T__1); 309 | setState(53); 310 | match(T__1); 311 | setState(54); 312 | match(STRING); 313 | setState(55); 314 | match(T__2); 315 | setState(56); 316 | match(T__2); 317 | setState(57); 318 | match(T__3); 319 | } 320 | break; 321 | default: 322 | throw new NoViableAltException(this); 323 | } 324 | } 325 | catch (RecognitionException re) { 326 | _localctx.exception = re; 327 | _errHandler.reportError(this, re); 328 | _errHandler.recover(this, re); 329 | } 330 | finally { 331 | exitRule(); 332 | } 333 | return _localctx; 334 | } 335 | 336 | public static class DataContext extends ParserRuleContext { 337 | public List dataLine() { 338 | return getRuleContexts(DataLineContext.class); 339 | } 340 | public DataLineContext dataLine(int i) { 341 | return getRuleContext(DataLineContext.class,i); 342 | } 343 | public DataContext(ParserRuleContext parent, int invokingState) { 344 | super(parent, invokingState); 345 | } 346 | @Override public int getRuleIndex() { return RULE_data; } 347 | @Override 348 | public T accept(ParseTreeVisitor visitor) { 349 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitData(this); 350 | else return visitor.visitChildren(this); 351 | } 352 | } 353 | 354 | public final DataContext data() throws RecognitionException { 355 | DataContext _localctx = new DataContext(_ctx, getState()); 356 | enterRule(_localctx, 6, RULE_data); 357 | int _la; 358 | try { 359 | enterOuterAlt(_localctx, 1); 360 | { 361 | setState(60); 362 | match(DATA); 363 | setState(64); 364 | _errHandler.sync(this); 365 | _la = _input.LA(1); 366 | while (_la==T__7) { 367 | { 368 | { 369 | setState(61); 370 | dataLine(); 371 | } 372 | } 373 | setState(66); 374 | _errHandler.sync(this); 375 | _la = _input.LA(1); 376 | } 377 | setState(67); 378 | match(ENDSEC); 379 | } 380 | } 381 | catch (RecognitionException re) { 382 | _localctx.exception = re; 383 | _errHandler.reportError(this, re); 384 | _errHandler.recover(this, re); 385 | } 386 | finally { 387 | exitRule(); 388 | } 389 | return _localctx; 390 | } 391 | 392 | public static class DataLineContext extends ParserRuleContext { 393 | public TerminalNode INT() { return getToken(STEPGrammarParser.INT, 0); } 394 | public TypedListArgumentContext typedListArgument() { 395 | return getRuleContext(TypedListArgumentContext.class,0); 396 | } 397 | public DataLineContext(ParserRuleContext parent, int invokingState) { 398 | super(parent, invokingState); 399 | } 400 | @Override public int getRuleIndex() { return RULE_dataLine; } 401 | @Override 402 | public T accept(ParseTreeVisitor visitor) { 403 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitDataLine(this); 404 | else return visitor.visitChildren(this); 405 | } 406 | } 407 | 408 | public final DataLineContext dataLine() throws RecognitionException { 409 | DataLineContext _localctx = new DataLineContext(_ctx, getState()); 410 | enterRule(_localctx, 8, RULE_dataLine); 411 | try { 412 | enterOuterAlt(_localctx, 1); 413 | { 414 | setState(69); 415 | match(T__7); 416 | setState(70); 417 | match(INT); 418 | setState(71); 419 | match(T__8); 420 | setState(72); 421 | typedListArgument(); 422 | setState(73); 423 | match(T__3); 424 | } 425 | } 426 | catch (RecognitionException re) { 427 | _localctx.exception = re; 428 | _errHandler.reportError(this, re); 429 | _errHandler.recover(this, re); 430 | } 431 | finally { 432 | exitRule(); 433 | } 434 | return _localctx; 435 | } 436 | 437 | public static class TypedListArgumentContext extends ParserRuleContext { 438 | public TerminalNode NAME() { return getToken(STEPGrammarParser.NAME, 0); } 439 | public ArgumentListContext argumentList() { 440 | return getRuleContext(ArgumentListContext.class,0); 441 | } 442 | public TypedListArgumentContext(ParserRuleContext parent, int invokingState) { 443 | super(parent, invokingState); 444 | } 445 | @Override public int getRuleIndex() { return RULE_typedListArgument; } 446 | @Override 447 | public T accept(ParseTreeVisitor visitor) { 448 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitTypedListArgument(this); 449 | else return visitor.visitChildren(this); 450 | } 451 | } 452 | 453 | public final TypedListArgumentContext typedListArgument() throws RecognitionException { 454 | TypedListArgumentContext _localctx = new TypedListArgumentContext(_ctx, getState()); 455 | enterRule(_localctx, 10, RULE_typedListArgument); 456 | try { 457 | setState(83); 458 | _errHandler.sync(this); 459 | switch ( getInterpreter().adaptivePredict(_input,5,_ctx) ) { 460 | case 1: 461 | enterOuterAlt(_localctx, 1); 462 | { 463 | setState(75); 464 | match(NAME); 465 | setState(76); 466 | match(T__1); 467 | setState(77); 468 | match(T__2); 469 | } 470 | break; 471 | case 2: 472 | enterOuterAlt(_localctx, 2); 473 | { 474 | setState(78); 475 | match(NAME); 476 | setState(79); 477 | match(T__1); 478 | setState(80); 479 | argumentList(); 480 | setState(81); 481 | match(T__2); 482 | } 483 | break; 484 | } 485 | } 486 | catch (RecognitionException re) { 487 | _localctx.exception = re; 488 | _errHandler.reportError(this, re); 489 | _errHandler.recover(this, re); 490 | } 491 | finally { 492 | exitRule(); 493 | } 494 | return _localctx; 495 | } 496 | 497 | public static class ArgumentContext extends ParserRuleContext { 498 | public TerminalNode INT() { return getToken(STEPGrammarParser.INT, 0); } 499 | public TypedListArgumentContext typedListArgument() { 500 | return getRuleContext(TypedListArgumentContext.class,0); 501 | } 502 | public TerminalNode NEGINT() { return getToken(STEPGrammarParser.NEGINT, 0); } 503 | public TerminalNode INTEXP() { return getToken(STEPGrammarParser.INTEXP, 0); } 504 | public TerminalNode FLOAT() { return getToken(STEPGrammarParser.FLOAT, 0); } 505 | public TerminalNode STRING() { return getToken(STEPGrammarParser.STRING, 0); } 506 | public TerminalNode BOOLEAN() { return getToken(STEPGrammarParser.BOOLEAN, 0); } 507 | public TerminalNode ENUM() { return getToken(STEPGrammarParser.ENUM, 0); } 508 | public TerminalNode OVERRIDE() { return getToken(STEPGrammarParser.OVERRIDE, 0); } 509 | public TerminalNode NONDEF() { return getToken(STEPGrammarParser.NONDEF, 0); } 510 | public ListArgumentContext listArgument() { 511 | return getRuleContext(ListArgumentContext.class,0); 512 | } 513 | public ArgumentContext(ParserRuleContext parent, int invokingState) { 514 | super(parent, invokingState); 515 | } 516 | @Override public int getRuleIndex() { return RULE_argument; } 517 | @Override 518 | public T accept(ParseTreeVisitor visitor) { 519 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitArgument(this); 520 | else return visitor.visitChildren(this); 521 | } 522 | } 523 | 524 | public final ArgumentContext argument() throws RecognitionException { 525 | ArgumentContext _localctx = new ArgumentContext(_ctx, getState()); 526 | enterRule(_localctx, 12, RULE_argument); 527 | int _la; 528 | try { 529 | setState(90); 530 | _errHandler.sync(this); 531 | switch (_input.LA(1)) { 532 | case T__7: 533 | enterOuterAlt(_localctx, 1); 534 | { 535 | setState(85); 536 | match(T__7); 537 | setState(86); 538 | match(INT); 539 | } 540 | break; 541 | case NAME: 542 | enterOuterAlt(_localctx, 2); 543 | { 544 | setState(87); 545 | typedListArgument(); 546 | } 547 | break; 548 | case NONDEF: 549 | case OVERRIDE: 550 | case BOOLEAN: 551 | case INT: 552 | case NEGINT: 553 | case INTEXP: 554 | case FLOAT: 555 | case ENUM: 556 | case STRING: 557 | enterOuterAlt(_localctx, 3); 558 | { 559 | setState(88); 560 | _la = _input.LA(1); 561 | if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NONDEF) | (1L << OVERRIDE) | (1L << BOOLEAN) | (1L << INT) | (1L << NEGINT) | (1L << INTEXP) | (1L << FLOAT) | (1L << ENUM) | (1L << STRING))) != 0)) ) { 562 | _errHandler.recoverInline(this); 563 | } 564 | else { 565 | if ( _input.LA(1)==Token.EOF ) matchedEOF = true; 566 | _errHandler.reportMatch(this); 567 | consume(); 568 | } 569 | } 570 | break; 571 | case T__1: 572 | case T__9: 573 | enterOuterAlt(_localctx, 4); 574 | { 575 | setState(89); 576 | listArgument(); 577 | } 578 | break; 579 | default: 580 | throw new NoViableAltException(this); 581 | } 582 | } 583 | catch (RecognitionException re) { 584 | _localctx.exception = re; 585 | _errHandler.reportError(this, re); 586 | _errHandler.recover(this, re); 587 | } 588 | finally { 589 | exitRule(); 590 | } 591 | return _localctx; 592 | } 593 | 594 | public static class ListArgumentContext extends ParserRuleContext { 595 | public ArgumentListContext argumentList() { 596 | return getRuleContext(ArgumentListContext.class,0); 597 | } 598 | public ListArgumentContext(ParserRuleContext parent, int invokingState) { 599 | super(parent, invokingState); 600 | } 601 | @Override public int getRuleIndex() { return RULE_listArgument; } 602 | @Override 603 | public T accept(ParseTreeVisitor visitor) { 604 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitListArgument(this); 605 | else return visitor.visitChildren(this); 606 | } 607 | } 608 | 609 | public final ListArgumentContext listArgument() throws RecognitionException { 610 | ListArgumentContext _localctx = new ListArgumentContext(_ctx, getState()); 611 | enterRule(_localctx, 14, RULE_listArgument); 612 | try { 613 | setState(97); 614 | _errHandler.sync(this); 615 | switch (_input.LA(1)) { 616 | case T__9: 617 | enterOuterAlt(_localctx, 1); 618 | { 619 | setState(92); 620 | match(T__9); 621 | } 622 | break; 623 | case T__1: 624 | enterOuterAlt(_localctx, 2); 625 | { 626 | setState(93); 627 | match(T__1); 628 | setState(94); 629 | argumentList(); 630 | setState(95); 631 | match(T__2); 632 | } 633 | break; 634 | default: 635 | throw new NoViableAltException(this); 636 | } 637 | } 638 | catch (RecognitionException re) { 639 | _localctx.exception = re; 640 | _errHandler.reportError(this, re); 641 | _errHandler.recover(this, re); 642 | } 643 | finally { 644 | exitRule(); 645 | } 646 | return _localctx; 647 | } 648 | 649 | public static class ArgumentListContext extends ParserRuleContext { 650 | public List argument() { 651 | return getRuleContexts(ArgumentContext.class); 652 | } 653 | public ArgumentContext argument(int i) { 654 | return getRuleContext(ArgumentContext.class,i); 655 | } 656 | public ArgumentListContext(ParserRuleContext parent, int invokingState) { 657 | super(parent, invokingState); 658 | } 659 | @Override public int getRuleIndex() { return RULE_argumentList; } 660 | @Override 661 | public T accept(ParseTreeVisitor visitor) { 662 | if ( visitor instanceof STEPGrammarVisitor ) return ((STEPGrammarVisitor)visitor).visitArgumentList(this); 663 | else return visitor.visitChildren(this); 664 | } 665 | } 666 | 667 | public final ArgumentListContext argumentList() throws RecognitionException { 668 | ArgumentListContext _localctx = new ArgumentListContext(_ctx, getState()); 669 | enterRule(_localctx, 16, RULE_argumentList); 670 | int _la; 671 | try { 672 | enterOuterAlt(_localctx, 1); 673 | { 674 | setState(99); 675 | argument(); 676 | setState(104); 677 | _errHandler.sync(this); 678 | _la = _input.LA(1); 679 | while (_la==T__5) { 680 | { 681 | { 682 | setState(100); 683 | match(T__5); 684 | setState(101); 685 | argument(); 686 | } 687 | } 688 | setState(106); 689 | _errHandler.sync(this); 690 | _la = _input.LA(1); 691 | } 692 | } 693 | } 694 | catch (RecognitionException re) { 695 | _localctx.exception = re; 696 | _errHandler.reportError(this, re); 697 | _errHandler.recover(this, re); 698 | } 699 | finally { 700 | exitRule(); 701 | } 702 | return _localctx; 703 | } 704 | 705 | public static final String _serializedATN = 706 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\36n\4\2\t\2\4\3\t"+ 707 | "\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\3\2\3\2\5\2"+ 708 | "\27\n\2\3\2\5\2\32\n\2\3\2\3\2\3\2\3\3\3\3\7\3!\n\3\f\3\16\3$\13\3\3\3"+ 709 | "\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3"+ 710 | "\4\3\4\3\4\3\4\3\4\5\4=\n\4\3\5\3\5\7\5A\n\5\f\5\16\5D\13\5\3\5\3\5\3"+ 711 | "\6\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\5\7V\n\7\3\b\3"+ 712 | "\b\3\b\3\b\3\b\5\b]\n\b\3\t\3\t\3\t\3\t\3\t\5\td\n\t\3\n\3\n\3\n\7\ni"+ 713 | "\n\n\f\n\16\nl\13\n\3\n\2\2\13\2\4\6\b\n\f\16\20\22\2\3\3\2\20\30\2p\2"+ 714 | "\24\3\2\2\2\4\36\3\2\2\2\6<\3\2\2\2\b>\3\2\2\2\nG\3\2\2\2\fU\3\2\2\2\16"+ 715 | "\\\3\2\2\2\20c\3\2\2\2\22e\3\2\2\2\24\26\7\31\2\2\25\27\5\4\3\2\26\25"+ 716 | "\3\2\2\2\26\27\3\2\2\2\27\31\3\2\2\2\30\32\5\b\5\2\31\30\3\2\2\2\31\32"+ 717 | "\3\2\2\2\32\33\3\2\2\2\33\34\7\32\2\2\34\35\7\2\2\3\35\3\3\2\2\2\36\""+ 718 | "\7\33\2\2\37!\5\6\4\2 \37\3\2\2\2!$\3\2\2\2\" \3\2\2\2\"#\3\2\2\2#%\3"+ 719 | "\2\2\2$\"\3\2\2\2%&\7\35\2\2&\5\3\2\2\2\'(\7\3\2\2()\7\4\2\2)*\5\22\n"+ 720 | "\2*+\7\5\2\2+,\7\6\2\2,=\3\2\2\2-.\7\7\2\2./\7\4\2\2/\60\7\30\2\2\60\61"+ 721 | "\7\b\2\2\61\62\5\22\n\2\62\63\7\5\2\2\63\64\7\6\2\2\64=\3\2\2\2\65\66"+ 722 | "\7\t\2\2\66\67\7\4\2\2\678\7\4\2\289\7\30\2\29:\7\5\2\2:;\7\5\2\2;=\7"+ 723 | "\6\2\2<\'\3\2\2\2<-\3\2\2\2<\65\3\2\2\2=\7\3\2\2\2>B\7\34\2\2?A\5\n\6"+ 724 | "\2@?\3\2\2\2AD\3\2\2\2B@\3\2\2\2BC\3\2\2\2CE\3\2\2\2DB\3\2\2\2EF\7\35"+ 725 | "\2\2F\t\3\2\2\2GH\7\n\2\2HI\7\23\2\2IJ\7\13\2\2JK\5\f\7\2KL\7\6\2\2L\13"+ 726 | "\3\2\2\2MN\7\36\2\2NO\7\4\2\2OV\7\5\2\2PQ\7\36\2\2QR\7\4\2\2RS\5\22\n"+ 727 | "\2ST\7\5\2\2TV\3\2\2\2UM\3\2\2\2UP\3\2\2\2V\r\3\2\2\2WX\7\n\2\2X]\7\23"+ 728 | "\2\2Y]\5\f\7\2Z]\t\2\2\2[]\5\20\t\2\\W\3\2\2\2\\Y\3\2\2\2\\Z\3\2\2\2\\"+ 729 | "[\3\2\2\2]\17\3\2\2\2^d\7\f\2\2_`\7\4\2\2`a\5\22\n\2ab\7\5\2\2bd\3\2\2"+ 730 | "\2c^\3\2\2\2c_\3\2\2\2d\21\3\2\2\2ej\5\16\b\2fg\7\b\2\2gi\5\16\b\2hf\3"+ 731 | "\2\2\2il\3\2\2\2jh\3\2\2\2jk\3\2\2\2k\23\3\2\2\2lj\3\2\2\2\13\26\31\""+ 732 | " The return type of the visit operation. Use {@link Void} for 10 | * operations with no return type. 11 | */ 12 | public interface STEPGrammarVisitor extends ParseTreeVisitor { 13 | /** 14 | * Visit a parse tree produced by {@link STEPGrammarParser#ifcFile}. 15 | * @param ctx the parse tree 16 | * @return the visitor result 17 | */ 18 | T visitIfcFile(STEPGrammarParser.IfcFileContext ctx); 19 | /** 20 | * Visit a parse tree produced by {@link STEPGrammarParser#header}. 21 | * @param ctx the parse tree 22 | * @return the visitor result 23 | */ 24 | T visitHeader(STEPGrammarParser.HeaderContext ctx); 25 | /** 26 | * Visit a parse tree produced by the {@code filedescipt} 27 | * labeled alternative in {@link STEPGrammarParser#headerLine}. 28 | * @param ctx the parse tree 29 | * @return the visitor result 30 | */ 31 | T visitFiledescipt(STEPGrammarParser.FiledesciptContext ctx); 32 | /** 33 | * Visit a parse tree produced by the {@code filename} 34 | * labeled alternative in {@link STEPGrammarParser#headerLine}. 35 | * @param ctx the parse tree 36 | * @return the visitor result 37 | */ 38 | T visitFilename(STEPGrammarParser.FilenameContext ctx); 39 | /** 40 | * Visit a parse tree produced by the {@code fileschema} 41 | * labeled alternative in {@link STEPGrammarParser#headerLine}. 42 | * @param ctx the parse tree 43 | * @return the visitor result 44 | */ 45 | T visitFileschema(STEPGrammarParser.FileschemaContext ctx); 46 | /** 47 | * Visit a parse tree produced by {@link STEPGrammarParser#data}. 48 | * @param ctx the parse tree 49 | * @return the visitor result 50 | */ 51 | T visitData(STEPGrammarParser.DataContext ctx); 52 | /** 53 | * Visit a parse tree produced by {@link STEPGrammarParser#dataLine}. 54 | * @param ctx the parse tree 55 | * @return the visitor result 56 | */ 57 | T visitDataLine(STEPGrammarParser.DataLineContext ctx); 58 | /** 59 | * Visit a parse tree produced by {@link STEPGrammarParser#typedListArgument}. 60 | * @param ctx the parse tree 61 | * @return the visitor result 62 | */ 63 | T visitTypedListArgument(STEPGrammarParser.TypedListArgumentContext ctx); 64 | /** 65 | * Visit a parse tree produced by {@link STEPGrammarParser#argument}. 66 | * @param ctx the parse tree 67 | * @return the visitor result 68 | */ 69 | T visitArgument(STEPGrammarParser.ArgumentContext ctx); 70 | /** 71 | * Visit a parse tree produced by {@link STEPGrammarParser#listArgument}. 72 | * @param ctx the parse tree 73 | * @return the visitor result 74 | */ 75 | T visitListArgument(STEPGrammarParser.ListArgumentContext ctx); 76 | /** 77 | * Visit a parse tree produced by {@link STEPGrammarParser#argumentList}. 78 | * @param ctx the parse tree 79 | * @return the visitor result 80 | */ 81 | T visitArgumentList(STEPGrammarParser.ArgumentListContext ctx); 82 | } -------------------------------------------------------------------------------- /src/main/java/rule/BaseRule.java: -------------------------------------------------------------------------------- 1 | package rule; 2 | 3 | import org.neo4j.graphdb.*; 4 | import org.neo4j.graphdb.traversal.*; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | import static org.neo4j.graphdb.RelationshipType.withName; 10 | 11 | public class BaseRule { 12 | 13 | 14 | // public static TraversalDescription findPaths(List path, GraphDatabaseService db) 15 | // { 16 | // final ArrayList orderedPathContext = new ArrayList<>(); 17 | // for (String linkName: path) { 18 | // orderedPathContext.add(withName(linkName)); 19 | // } 20 | // TraversalDescription td = db.traversalDescription() 21 | // .breadthFirst() 22 | // .evaluator( new Evaluator() 23 | // { 24 | // @Override 25 | // public Evaluation evaluate(final Path path ) 26 | // { 27 | // if ( path.length() == 0 ) 28 | // { 29 | // return Evaluation.EXCLUDE_AND_CONTINUE; 30 | // } 31 | // RelationshipType expectedType = orderedPathContext.get( path.length() - 1 ); 32 | // boolean isExpectedType = path.lastRelationship() 33 | // .isType( expectedType ); 34 | // boolean included = path.length() == orderedPathContext.size() && isExpectedType; 35 | // boolean continued = path.length() < orderedPathContext.size() && isExpectedType; 36 | // return Evaluation.of( included, continued ); 37 | // } 38 | // } ) 39 | // .uniqueness( Uniqueness.NODE_PATH ); 40 | // return td; 41 | // } 42 | 43 | public static TraversalDescription findPathsDFS(List path, GraphDatabaseService db) 44 | { 45 | final ArrayList orderedPathContext = new ArrayList<>(); 46 | for (String linkName: path) { 47 | orderedPathContext.add(withName(linkName)); 48 | } 49 | TraversalDescription td = db.traversalDescription() 50 | .depthFirst() 51 | .evaluator( new Evaluator() 52 | { 53 | @Override 54 | public Evaluation evaluate( final Path path ) 55 | { 56 | if ( path.length() == 0 ) 57 | { 58 | return Evaluation.EXCLUDE_AND_CONTINUE; 59 | } 60 | RelationshipType expectedType = orderedPathContext.get( path.length() - 1 ); 61 | boolean isExpectedType = path.lastRelationship() 62 | .isType( expectedType ); 63 | boolean included = path.length() == orderedPathContext.size() && isExpectedType; 64 | boolean continued = path.length() < orderedPathContext.size() && isExpectedType; 65 | return Evaluation.of( included, continued ); 66 | } 67 | } ) 68 | .uniqueness( Uniqueness.NODE_PATH ); 69 | return td; 70 | } 71 | 72 | public static List getEndNodes(TraversalDescription td, Node a, GraphDatabaseService db) { 73 | List endNodes = new ArrayList(); 74 | try ( Transaction transaction = db.beginTx() ) 75 | { 76 | 77 | Traverser traverser = td.traverse( a ); 78 | for ( Path path : traverser ) 79 | { 80 | Node endNode = path.endNode(); 81 | endNodes.add(endNode); 82 | } 83 | return endNodes; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/rule/ColorRule.java: -------------------------------------------------------------------------------- 1 | package rule; 2 | 3 | import java.io.File; 4 | import java.util.*; 5 | 6 | import dao.ResultItem; 7 | import org.neo4j.cypher.internal.frontend.v2_3.ast.functions.Str; 8 | import org.neo4j.graphdb.*; 9 | import org.neo4j.graphdb.factory.GraphDatabaseFactory; 10 | import org.neo4j.graphdb.traversal.*; 11 | 12 | import javax.management.relation.Relation; 13 | import javax.swing.plaf.synth.SynthTextAreaUI; 14 | 15 | import static org.neo4j.graphdb.RelationshipType.withName; 16 | 17 | public class ColorRule { 18 | private GraphDatabaseService db; 19 | private int red; 20 | private int blue; 21 | private int green; 22 | 23 | public String ruleContent; 24 | 25 | public ColorRule(GraphDatabaseService db, String ruleContent, int red, int green, int blue) { 26 | this.db = db; 27 | this.ruleContent = ruleContent; 28 | this.red = red; 29 | this.green = green; 30 | this.blue = blue; 31 | } 32 | 33 | public void checkColorForSystem(String systemName) { 34 | 35 | //path to find color 36 | List colorPath = Arrays.asList("Representation","Representations","Items","StyledByItem","Styles","Styles","SurfaceColour"); 37 | TraversalDescription traverseColor = BaseRule.findPathsDFS(colorPath, db); 38 | 39 | List colorPath2 = Arrays.asList("HasCoverings","Representation","Representations","Items","StyledByItem","Styles","Styles","SurfaceColour"); 40 | //List colorPath2 = Arrays.asList("RelatedObjects","RelatingMaterial","RepresentedMaterial","Representations","Items","Styles","Styles","Styles","SurfaceColour"); 41 | TraversalDescription traverseColor2 = BaseRule.findPathsDFS(colorPath2, db); 42 | 43 | //List colorPath3 = Arrays.asList( "RelatedObjects","RelatingMaterial","RepresentedMaterial","Representations","Items","Styles","Styles","Styles","SurfaceColour"); 44 | List colorPath3 = Arrays.asList("Representation","Representations","Items","MappingSource", "MappedRepresentation","Items","StyledByItem","Styles","Styles","SurfaceColour"); 45 | TraversalDescription traverseColor3 = BaseRule.findPathsDFS(colorPath3, db); 46 | 47 | Set distributionElements = new HashSet<>(); 48 | 49 | //find distribution elements 50 | try (Transaction tx = db.beginTx()) { 51 | ResourceIterator nodeIter = db.findNodes( Label.label("IfcSystem"), "ObjectType", systemName ); 52 | while (nodeIter.hasNext()) { 53 | Node system = nodeIter.next(); 54 | Iterable rels = system.getRelationships(RelationshipType.withName("IsGroupedBy")); 55 | for (Relationship rel : rels) { 56 | if (!rel.getEndNode().hasLabel(Label.label("IfcDistributionPort"))) { 57 | distributionElements.add(rel.getEndNode()); 58 | //rel.getEndNode().getRelationships() 59 | } 60 | } 61 | } 62 | tx.success(); 63 | } 64 | //System.out.println(distributionElements.size()); 65 | for (Node node: distributionElements) { 66 | List colorNodes = BaseRule.getEndNodes(traverseColor, node, db); 67 | if (colorNodes.size() > 0) { 68 | checkSingle(node, colorNodes.get(0)); 69 | } else { 70 | List colorNodesForCovering = BaseRule.getEndNodes(traverseColor2, node, db); 71 | if (colorNodesForCovering.size() > 0) { 72 | checkSingle(node, colorNodesForCovering.get(0)); 73 | } else { 74 | List colorNodesForMaterial = BaseRule.getEndNodes(traverseColor3, node, db); 75 | if (colorNodesForMaterial.size() > 0) { 76 | checkSingle(node, colorNodesForMaterial.get(0)); 77 | } else { 78 | // try (Transaction tx=db.beginTx()) { 79 | // int ans = (int) node.getProperty("lineId"); 80 | // String type = (String) node.getProperty("IfcType"); 81 | // System.out.println(ans+" "+type); 82 | // tx.success(); 83 | // } 84 | 85 | System.out.println("not found"); 86 | } 87 | } 88 | 89 | } 90 | } 91 | } 92 | 93 | public void test() { 94 | try ( Transaction tx = db.beginTx() ){ 95 | Node cui1Node = db.findNode(Label.label("Element"), "lineId", 407511); 96 | 97 | TraversalDescription td = db.traversalDescription() 98 | .breadthFirst() 99 | .evaluator(Evaluators.toDepth(10)) 100 | .evaluator( 101 | new Evaluator() 102 | { 103 | @Override 104 | public Evaluation evaluate(final Path path ) 105 | { 106 | if ( path.length() == 0 ) 107 | { 108 | return Evaluation.EXCLUDE_AND_CONTINUE; 109 | } 110 | String type = ( String) path.endNode().getProperty("IfcType"); 111 | 112 | Relationship relationship = path.lastRelationship(); 113 | 114 | long id2 = relationship.getStartNodeId(); 115 | long id3 = path.endNode().getId(); 116 | 117 | System.out.println(type+" "+path.length()); 118 | //System.out.println(id1+" "+id2+" "+id3); 119 | 120 | if (id2 == id3 || relationship.isType(RelationshipType.withName("ContainedInStructure")) || relationship.isType(RelationshipType.withName("IsGroupedBy")) || relationship.isType(RelationshipType.withName("ObjectTypeOf"))) 121 | return Evaluation.EXCLUDE_AND_PRUNE; 122 | else if (type.equals("IfcFacetedBrep")) 123 | return Evaluation.INCLUDE_AND_PRUNE; 124 | else 125 | return Evaluation.EXCLUDE_AND_CONTINUE; 126 | } 127 | } 128 | ) 129 | .uniqueness( Uniqueness.NODE_PATH ); 130 | 131 | 132 | Traverser traverser = td.traverse( cui1Node ); 133 | PathPrinter pathPrinter = new PathPrinter( "lineId" ); 134 | String output = ""; 135 | 136 | for ( Path path : traverser ) 137 | { 138 | output += Paths.pathToString( path, pathPrinter ) + "\n"; 139 | } 140 | System.out.println(output); 141 | 142 | 143 | tx.success(); 144 | } 145 | } 146 | 147 | private ResultItem checkSingle(Node distribution, Node color) { 148 | ResultItem item = null; 149 | try (Transaction tx = db.beginTx()) { 150 | String colorRed = (String) color.getProperty("Red"); 151 | double red = Double.parseDouble(colorRed); 152 | 153 | String colorGreen = (String) color.getProperty("Green"); 154 | double green = Double.parseDouble(colorGreen); 155 | 156 | String colorBlue = (String) color.getProperty("Blue"); 157 | double blue = Double.parseDouble(colorBlue); 158 | 159 | int ifcLineId = (int) distribution.getProperty("lineId"); 160 | String ifcType = (String) distribution.getProperty("IfcType"); 161 | 162 | boolean status = false; 163 | 164 | if (Math.round(red*255) == this.red && Math.round(green*255) == this.green && Math.round(blue*255) == this.blue) 165 | status = true; 166 | 167 | //System.out.println("test"); 168 | 169 | item = new ResultItem(ruleContent, ifcLineId, ifcType, status); 170 | //if (!item.status) 171 | // System.out.println(item + " (" + Math.round(red*255) + "," + Math.round(green*255) + "," + Math.round(blue*255)+")"); 172 | tx.success(); 173 | } 174 | return item; 175 | } 176 | 177 | 178 | String printPaths( TraversalDescription td, Node A ) 179 | { 180 | try ( Transaction transaction = db.beginTx() ) 181 | { 182 | String output = ""; 183 | // START SNIPPET: printPath 184 | Traverser traverser = td.traverse( A ); 185 | PathPrinter pathPrinter = new PathPrinter( "lineId" ); 186 | for ( Path path : traverser ) 187 | { 188 | output += Paths.pathToString( path, pathPrinter )+"\n"; 189 | } 190 | // END SNIPPET: printPath 191 | output += "\n"; 192 | return output; 193 | } 194 | } 195 | 196 | // START SNIPPET: pathPrinter 197 | static class PathPrinter implements Paths.PathDescriptor 198 | { 199 | private final String nodePropertyKey; 200 | 201 | public PathPrinter( String nodePropertyKey ) 202 | { 203 | this.nodePropertyKey = nodePropertyKey; 204 | } 205 | 206 | @Override 207 | public String nodeRepresentation( Path path, Node node ) 208 | { 209 | return "(" + node.getProperty( nodePropertyKey, "" ) + ")"; 210 | } 211 | 212 | @Override 213 | public String relationshipRepresentation( Path path, Node from, Relationship relationship ) 214 | { 215 | String prefix = "--", suffix = "--"; 216 | if ( from.equals( relationship.getEndNode() ) ) 217 | { 218 | prefix = "<--"; 219 | } 220 | else 221 | { 222 | suffix = "-->"; 223 | } 224 | return prefix + "[" + relationship.getType().name() + "]" + suffix; 225 | } 226 | } 227 | 228 | public void shutdownGraph() 229 | { 230 | try 231 | { 232 | if ( db != null ) 233 | { 234 | db.shutdown(); 235 | } 236 | } 237 | finally 238 | { 239 | db = null; 240 | } 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /src/main/java/rule/ColorSystem.java: -------------------------------------------------------------------------------- 1 | package rule; 2 | 3 | public class ColorSystem { 4 | public String systemName; 5 | public int red; 6 | public int green; 7 | public int blue; 8 | public ColorSystem(String systemName, int red, int green, int blue) { 9 | this.systemName = systemName; 10 | this.red = red; 11 | this.green = green; 12 | this.blue = blue; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/rule/DirectionRule.java: -------------------------------------------------------------------------------- 1 | package rule; 2 | 3 | import org.neo4j.codegen.bytecode.If; 4 | import org.neo4j.graphdb.*; 5 | import org.neo4j.graphdb.traversal.TraversalDescription; 6 | import util.IfcDirection; 7 | import util.Inverse; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | public class DirectionRule { 14 | 15 | private GraphDatabaseService db; 16 | private double angle; 17 | 18 | 19 | public String ruleContent; 20 | 21 | public DirectionRule(GraphDatabaseService db, String ruleContent, double angle) { 22 | this.db = db; 23 | this.ruleContent = ruleContent; 24 | this.angle = angle; 25 | } 26 | 27 | public void checkDirection() { 28 | 29 | List fittings = new ArrayList<>(); 30 | try (Transaction tx = db.beginTx()) { 31 | ResourceIterator iter = db.findNodes(Label.label("IfcFlowFitting")); 32 | 33 | while (iter.hasNext()) { 34 | Node fitting = iter.next(); 35 | fittings.add(fitting); 36 | } 37 | tx.success(); 38 | } 39 | for (Node fitting: fittings) checkFlowFitting(fitting); 40 | } 41 | 42 | private void checkFlowFitting(Node fitting) { 43 | List segments = getRelatedSegment(fitting); 44 | System.out.println("check"); 45 | 46 | if (segments.size() != 2) return; 47 | 48 | IfcDirection segment1 = getDirection(getExtrudedSolid(segments.get(0))); 49 | IfcDirection segment2 = getDirection(getExtrudedSolid(segments.get(1))); 50 | 51 | //System.out.println(segment1); 52 | //System.out.println(segment2); 53 | 54 | double acos = IfcDirection.innerProduct(segment1, segment2); 55 | //System.out.println(360-Math.acos(angle)*180); 56 | double angle = Math.acos(acos)*180/Math.PI; 57 | 58 | if (Math.round(angle) == 0) { 59 | return; 60 | } 61 | 62 | if (Math.round(angle) != this.angle && Math.round(angle) != this.angle-1) { 63 | //System.out.println(angle); 64 | System.out.println(Math.round(angle)); 65 | } 66 | 67 | } 68 | 69 | private IfcDirection getDirection(Node extruded) { 70 | //try (Transaction tx = db.beginTx()) { 71 | IfcDirection trueDir = getDirectionOfExtruded(extruded); 72 | //System.out.println(trueDir); 73 | 74 | IfcDirection zDir = getZaxis(extruded); 75 | //System.out.println(zDir); 76 | 77 | IfcDirection xDir = getXaxis(extruded); 78 | //System.out.println(xDir); 79 | 80 | IfcDirection yDir = IfcDirection.crossProduct(xDir, zDir); 81 | 82 | double[][] inv = Inverse.invert(xDir, yDir, zDir); 83 | 84 | trueDir.translate(inv); 85 | 86 | 87 | return trueDir; 88 | 89 | 90 | 91 | //Node zAxis = extruded.getSingleRelationship(RelationshipType.withName("Position"), Direction.OUTGOING).getEndNode(); 92 | //.getSingleRelationship(RelationshipType.withName("Axis"), Direction.OUTGOING).getEndNode(); 93 | //Node xAxis = extruded.getSingleRelationship(RelationshipType.withName("Position"), Direction.OUTGOING).getEndNode(); 94 | //.getSingleRelationship(RelationshipType.withName("RefDirection"), Direction.OUTGOING).getEndNode(); 95 | // tx.success(); 96 | //} 97 | 98 | } 99 | 100 | private IfcDirection getZaxis(Node extruded) { 101 | IfcDirection defaultDir = new IfcDirection(0.0,0.0,1.0); 102 | try (Transaction tx = db.beginTx()){ 103 | Relationship zAxis = extruded.getSingleRelationship(RelationshipType.withName("Position"), Direction.OUTGOING); 104 | if (zAxis == null) return defaultDir; 105 | Relationship zz = zAxis.getEndNode().getSingleRelationship(RelationshipType.withName("Axis"), Direction.OUTGOING); 106 | if (zz == null) return defaultDir; 107 | Node direction = zz.getEndNode(); 108 | IfcDirection direct = getDirectionFromNode(direction); 109 | tx.success();; 110 | return direct; 111 | } 112 | //Node zAxis = extruded.getSingleRelationship(RelationshipType.withName("Position"), Direction.OUTGOING).getEndNode( 113 | } 114 | 115 | private IfcDirection getXaxis(Node extruded) { 116 | IfcDirection defaultDir = new IfcDirection(1.0,0.0,0.0); 117 | try (Transaction tx = db.beginTx()){ 118 | Relationship zAxis = extruded.getSingleRelationship(RelationshipType.withName("Position"), Direction.OUTGOING); 119 | if (zAxis == null) return defaultDir; 120 | Relationship zz = zAxis.getEndNode().getSingleRelationship(RelationshipType.withName("RefDirection"), Direction.OUTGOING); 121 | if (zz == null) return defaultDir; 122 | Node direction = zz.getEndNode(); 123 | IfcDirection direct = getDirectionFromNode(direction); 124 | tx.success();; 125 | return direct; 126 | } 127 | } 128 | 129 | 130 | private IfcDirection getDirectionOfExtruded(Node extruded) { 131 | IfcDirection dir = new IfcDirection(0.0, 0.0, 1.0); 132 | try (Transaction tx = db.beginTx()) { 133 | Relationship dirRel = extruded.getSingleRelationship(RelationshipType.withName("ExtrudedDirection"), Direction.OUTGOING); 134 | if (dirRel == null) return dir; 135 | Node direction = dirRel.getEndNode(); 136 | IfcDirection direct = getDirectionFromNode(direction); 137 | tx.success(); 138 | return direct; 139 | } 140 | } 141 | 142 | private IfcDirection getDirectionFromNode(Node ifcdirection) { 143 | try (Transaction tx = db.beginTx()) { 144 | String dir = (String) ifcdirection.getProperty("DirectionRatios"); 145 | tx.success(); 146 | return IfcDirection.parseFromString(dir); 147 | } 148 | } 149 | 150 | private List getRelatedSegment(Node fitting) { 151 | List dirPath = Arrays.asList("HasPorts","ConnectedTo","ContainedIn"); 152 | TraversalDescription traverseDir = BaseRule.findPathsDFS(dirPath, db); 153 | return BaseRule.getEndNodes(traverseDir, fitting, db); 154 | } 155 | 156 | private Node getExtrudedSolid(Node segment) { 157 | List geoPath = Arrays.asList("Representation", "Representations","Items"); 158 | TraversalDescription traverseGeo = BaseRule.findPathsDFS(geoPath, db); 159 | List nodes = BaseRule.getEndNodes(traverseGeo, segment, db); 160 | if (nodes.size() != 1) return null; 161 | return nodes.get(0); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /src/main/java/rule/ExistRule.java: -------------------------------------------------------------------------------- 1 | package rule; 2 | 3 | import dao.ResultItem; 4 | import org.neo4j.graphdb.*; 5 | import org.neo4j.graphdb.traversal.TraversalDescription; 6 | 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | 12 | public class ExistRule { 13 | 14 | private GraphDatabaseService db; 15 | private String code; 16 | 17 | public String ruleContent; 18 | 19 | public ExistRule(GraphDatabaseService db, String ruleContent, String code) { 20 | this.db = db; 21 | this.ruleContent = ruleContent; 22 | this.code = code; 23 | } 24 | 25 | public ResultItem checkExistForCode() { 26 | List properties = new ArrayList<>(); 27 | ResultItem item = new ResultItem(ruleContent, 0, "", false); 28 | try (Transaction tx = db.beginTx()) { 29 | ResourceIterator iter = db.findNodes(Label.label("IfcPropertySingleValue"), "Name", "构件分类编码"); 30 | while (iter.hasNext()) { 31 | Node singleProperty = iter.next(); 32 | String trueCode = (String) singleProperty.getProperty("NominalValue"); 33 | if (trueCode.startsWith(code)) { 34 | properties.add(singleProperty); 35 | System.out.println(trueCode); 36 | } 37 | } 38 | tx.success(); 39 | } 40 | if (properties.size() == 0) return item; 41 | 42 | System.out.println(properties.size()); 43 | 44 | List existPath = Arrays.asList("HasProperties","HasPropertySets","HasAssignments"); 45 | List existPath2 = Arrays.asList("HasProperties","IsDefinedBy"); 46 | TraversalDescription traverseExist = BaseRule.findPathsDFS(existPath, db); 47 | TraversalDescription traverseExist2 = BaseRule.findPathsDFS(existPath2, db); 48 | for (Node node: properties) { 49 | List endNodes = BaseRule.getEndNodes(traverseExist, node, db); 50 | if (endNodes.size() > 0) { 51 | item = new ResultItem(ruleContent, 0, "", true); 52 | return item; 53 | } 54 | } 55 | for (Node node: properties) { 56 | List endNodes = BaseRule.getEndNodes(traverseExist2, node, db); 57 | if (endNodes.size() > 0) { 58 | item = new ResultItem(ruleContent, 0, "", true); 59 | return item; 60 | } 61 | } 62 | 63 | return item; 64 | } 65 | 66 | public ResultItem checkExistForName() { 67 | List properties = new ArrayList<>(); 68 | ResultItem item = new ResultItem(ruleContent, 0, "", false); 69 | try (Transaction tx = db.beginTx()) { 70 | ResourceIterator iter = db.findNodes(Label.label("IfcPropertySingleValue"), "Name", "类型"); 71 | while (iter.hasNext()) { 72 | Node singleProperty = iter.next(); 73 | String trueCode = (String) singleProperty.getProperty("NominalValue"); 74 | if (trueCode.startsWith(code)) { 75 | properties.add(singleProperty); 76 | System.out.println(trueCode); 77 | } 78 | } 79 | tx.success(); 80 | } 81 | if (properties.size() == 0) return item; 82 | return new ResultItem(ruleContent, 0, "", true); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/rule/PropertyRule.java: -------------------------------------------------------------------------------- 1 | package rule; 2 | 3 | import org.neo4j.driver.v1.*; 4 | 5 | import static org.neo4j.driver.v1.Values.parameters; 6 | 7 | public class PropertyRule implements AutoCloseable { 8 | 9 | private final Driver driver; 10 | 11 | public PropertyRule( String uri, String user, String password ) 12 | { 13 | driver = GraphDatabase.driver( uri, AuthTokens.basic( user, password ) ); 14 | } 15 | 16 | @Override 17 | public void close() throws Exception { 18 | 19 | } 20 | 21 | public void printGreeting( final String message ) 22 | { 23 | try ( Session session = driver.session() ) 24 | { 25 | String greeting = session.writeTransaction( new TransactionWork() 26 | { 27 | @Override 28 | public String execute( Transaction tx ) 29 | { 30 | StatementResult result = tx.run( "CREATE (a:Greeting) " + 31 | "SET a.message = $message " + 32 | "RETURN a.message + ', from node ' + id(a)", 33 | parameters( "message", message ) ); 34 | return result.single().get( 0 ).asString(); 35 | } 36 | } ); 37 | System.out.println( greeting ); 38 | } 39 | } 40 | 41 | public static void main( String... args ) throws Exception 42 | { 43 | try ( PropertyRule greeter = new PropertyRule( "bolt://localhost:7687", "neo4j", "660329" ) ) 44 | { 45 | greeter.printGreeting( "hello, world" ); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/util/AntlrUtil.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import org.antlr.v4.runtime.CharStream; 4 | import org.antlr.v4.runtime.CharStreams; 5 | import org.antlr.v4.runtime.CommonTokenStream; 6 | import parser.STEPGrammarLexer; 7 | import parser.STEPGrammarParser; 8 | 9 | public class AntlrUtil { 10 | public static STEPGrammarParser getSTEPGrammarParser(String text) { 11 | CharStream input = CharStreams.fromString(text); 12 | STEPGrammarLexer lexer = new STEPGrammarLexer(input); 13 | CommonTokenStream tokens = new CommonTokenStream(lexer); 14 | STEPGrammarParser parser = new STEPGrammarParser(tokens); 15 | return parser; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/util/ConfigReader.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import model.InverseInfo; 4 | import rule.ColorSystem; 5 | 6 | import java.io.BufferedReader; 7 | import java.io.FileReader; 8 | import java.io.IOException; 9 | import java.util.ArrayList; 10 | import java.util.HashSet; 11 | import java.util.List; 12 | import java.util.Set; 13 | 14 | public class ConfigReader { 15 | 16 | public static String path = "src\\main\\resources\\excluded.txt"; 17 | public static String inversePath = "src\\main\\resources\\inverse.txt"; 18 | public static String colorPath = "src\\main\\resources\\colors.txt"; 19 | 20 | public static Set readExcluded() throws IOException { 21 | BufferedReader reader = new BufferedReader(new FileReader(path)); 22 | String line = null; 23 | 24 | Set set = new HashSet<>(); 25 | 26 | try { 27 | while((line = reader.readLine()) != null) { 28 | if (line.startsWith("IFC")) set.add(line); 29 | } 30 | 31 | return set; 32 | } finally { 33 | reader.close(); 34 | } 35 | } 36 | 37 | public static Set readInverseConfig() throws IOException { 38 | BufferedReader reader = new BufferedReader(new FileReader(inversePath)); 39 | String line = null; 40 | 41 | Set set = new HashSet<>(); 42 | 43 | try { 44 | while((line = reader.readLine()) != null) { 45 | String[] subs = line.split(" "); 46 | InverseInfo info = new InverseInfo(subs[0], subs[1], subs[2], subs[3], subs[4]); 47 | set.add(info); 48 | } 49 | 50 | return set; 51 | } finally { 52 | reader.close(); 53 | } 54 | } 55 | 56 | public static List readColorConfig() throws IOException { 57 | BufferedReader reader = new BufferedReader(new FileReader(colorPath)); 58 | String line = null; 59 | 60 | List list = new ArrayList<>(); 61 | 62 | try { 63 | while((line = reader.readLine()) != null) { 64 | String[] subs = line.split(" "); 65 | int red = Integer.parseInt(subs[1]); 66 | int green = Integer.parseInt(subs[2]); 67 | int blue = Integer.parseInt(subs[3]); 68 | ColorSystem info = new ColorSystem(subs[0],red, green, blue); 69 | list.add(info); 70 | } 71 | 72 | return list; 73 | } finally { 74 | reader.close(); 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/util/IfcDirection.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import org.neo4j.graphdb.Node; 4 | 5 | import java.util.regex.Matcher; 6 | import java.util.regex.Pattern; 7 | 8 | public class IfcDirection { 9 | public double x; 10 | public double y; 11 | public double z; 12 | public static final double eps = 0.0001; 13 | public IfcDirection(double x, double y, double z) { 14 | this.x = x; 15 | this.y = y; 16 | this.z = z; 17 | } 18 | 19 | public void translate(double[][] trans) { 20 | double nx = x*trans[0][0] + y*trans[1][0] + z*trans[2][0]; 21 | double ny = x*trans[0][1] + y*trans[1][1] + z*trans[2][1]; 22 | double nz = x*trans[0][2] + y*trans[1][2] + z*trans[2][2]; 23 | x = nx; 24 | y = ny; 25 | z = nz; 26 | } 27 | 28 | public static IfcDirection parseFromString(String s) { 29 | String pattern = "\\(([0-9|.|e|E|\\-]*),([0-9|.|e|E|\\-]*),([0-9|.|e|E|\\-]*)\\)"; 30 | Pattern r = Pattern.compile(pattern); 31 | Matcher m = r.matcher(s); 32 | if (m.find()) { 33 | double x = Double.parseDouble(m.group(1)); 34 | //if (x < eps) x = 0.0; 35 | double y = Double.parseDouble(m.group(2)); 36 | //if (y < eps) y = 0.0; 37 | double z = Double.parseDouble(m.group(3)); 38 | //if (z < eps) z = 0.0; 39 | return new IfcDirection(x, y, z); 40 | } 41 | return null; 42 | } 43 | 44 | public static IfcDirection crossProduct(IfcDirection dir1, IfcDirection dir2) { 45 | if (dir1 == null || dir2 == null ) return null; 46 | double x = dir1.y*dir2.z-dir2.y*dir1.z; 47 | double y = dir2.x*dir1.z-dir1.x*dir2.z; 48 | double z = dir1.x*dir2.y-dir2.x*dir1.y; 49 | double len = x*x + y*y + z*z; 50 | return new IfcDirection(x/Math.sqrt(len), y/Math.sqrt(len), z/Math.sqrt(len)); 51 | } 52 | 53 | public static double innerProduct(IfcDirection dir1, IfcDirection dir2) { 54 | double inner = dir1.x*dir2.x+dir1.y*dir2.y+dir1.z*dir2.z; 55 | return inner/(length(dir1)*length(dir2)); 56 | } 57 | 58 | public static double length(IfcDirection dir) { 59 | double square = dir.x*dir.x+dir.y*dir.y+dir.z*dir.z; 60 | return Math.sqrt(square); 61 | } 62 | 63 | public String toString() { 64 | return x+" "+y+" "+z; 65 | } 66 | 67 | public static void main(String[] args) { 68 | IfcDirection.parseFromString("(-8.68965671290933E-6,-1.,0.)"); 69 | 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/util/IfcVersion.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | public enum IfcVersion { 4 | IFC2X3, 5 | IFC4, 6 | IFC4X1 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/util/Inverse.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Inverse 6 | { 7 | public static void main(String argv[]) 8 | { 9 | IfcDirection x = new IfcDirection(-1.0, 0, 0); 10 | IfcDirection y = new IfcDirection(0.0, 0.0, -1.0); 11 | IfcDirection z = new IfcDirection(0.0, 1.0, 0.0); 12 | 13 | double[][] d = invert(x, y, z); 14 | int n = 3; 15 | 16 | System.out.println("The inverse is: "); 17 | for (int i=0; i=0; --j) 61 | { 62 | x[j][i] = b[index[j]][i]; 63 | for (int k=j+1; k c1) c1 = c0; 93 | } 94 | c[i] = c1; 95 | } 96 | 97 | // Search the pivoting element from each column 98 | int k = 0; 99 | for (int j=0; j pi1) 107 | { 108 | pi1 = pi0; 109 | k = i; 110 | } 111 | } 112 | 113 | // Interchange rows according to the pivoting order 114 | int itmp = index[j]; 115 | index[j] = index[k]; 116 | index[k] = itmp; 117 | for (int i=j+1; i 3 | * Creative Commons Public Licence. Some Rights Reserved.
4 | * http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | * If you use this code, please send a message to one of the
6 | * authors: eike.tauscher@uni-weimar.de
7 | * jan.tulke@hochtief.de
8 | */ 9 | 10 | package util; 11 | 12 | import java.nio.ByteBuffer; 13 | import java.nio.CharBuffer; 14 | import java.nio.charset.CharacterCodingException; 15 | import java.nio.charset.Charset; 16 | import java.nio.charset.CharsetDecoder; 17 | import java.nio.charset.CharsetEncoder; 18 | import java.util.regex.Matcher; 19 | import java.util.regex.Pattern; 20 | 21 | /** 22 | * This class is a service class providing methods for decoding and encoding 23 | * strings according to ISO-10303-21. 24 | * This class is provided as-is with no warranty.
25 | *
26 | * The class GuidCompressor is part of the OPEN IFC JAVA TOOLBOX package. 27 | * Copyright: CCPL BY-NC-SA 3.0 (cc) 2008 Eike Tauscher, Jan Tulke
28 | *
29 | * The OPEN IFC JAVA TOOLBOX package itself (except this class) is licensed 30 | * under
31 | * Creative Commons 33 | * Attribution-Non-Commercial- Share Alike 3.0 Germany.
34 | * Please visit http://www.openifctools.com for more 36 | * information.
37 | * 38 | * @author Jan Tulke 39 | * @version 1.0 - 24.07.2009 40 | * 41 | */ 42 | public class StringConverter 43 | { 44 | private static final String codePage = "ABCDEFGHI"; 45 | 46 | /** 47 | * Decodes a given string. All mechanisms according to ISO-10303-21 48 | * (�6.3.3.1-�6.3.3.3) are supported and are selected automatically. 49 | * 50 | * @param string 51 | * String to be decoded 52 | * @return decoded string 53 | * @throws CharacterCodingException 54 | */ 55 | public static String decode(String string) throws CharacterCodingException 56 | { 57 | // Beim decoden eine eigene Exception werfen 58 | // Testen ob bei decoding von 8859 character auch in einem der Bereiche 59 | // 32/126 160/254 liegt 60 | // sonst exception werfen 61 | 62 | CharsetDecoder decoderIso8859_1 = Charset.forName("ISO-8859-1").newDecoder(); 63 | CharsetDecoder decoderUTF16 = Charset.forName("UTF-16BE").newDecoder(); 64 | CharsetDecoder decoderUTF32 = Charset.forName("UTF-32").newDecoder(); 65 | CharsetDecoder decoder = null; 66 | boolean extendedCodePage = false; 67 | String decodedString = new String(); 68 | char[] characterArray = string.toCharArray(); 69 | int codePoint; 70 | int index = -1; 71 | while (index < characterArray.length - 1) 72 | { 73 | index++; 74 | codePoint = Character.codePointAt(characterArray, index); 75 | if (codePoint < 32 || codePoint > 126){ 76 | CharacterCodingException e = new CharacterCodingException(); 77 | throw e; 78 | } 79 | 80 | // single apostroph is encoded as two consecutive apostrophes 81 | if (characterArray[index] == '\'') 82 | { 83 | decodedString += "\'"; 84 | index++; 85 | } else if (characterArray[index] == '\\') 86 | { 87 | index++; 88 | if (characterArray[index] == '\\') 89 | { // not a control sequence but a normal back slash 90 | decodedString += "\\"; 91 | } else if (characterArray[index] == 'S') 92 | { 93 | index++; 94 | if (extendedCodePage) 95 | decodedString = decodedString.concat(decoder.decode(buffer("" + characterArray[++index])) 96 | .toString()); 97 | else 98 | decodedString = decodedString.concat(new String(Character.toChars(Character.codePointAt( 99 | characterArray, ++index) + 128))); 100 | } else if (characterArray[index] == 'P') 101 | { 102 | index++; 103 | int page = codePage.indexOf(characterArray[index]) + 1; 104 | Charset charset = Charset.forName("ISO-8859-" + page); 105 | decoder = charset.newDecoder(); 106 | extendedCodePage = true; 107 | index++; 108 | } else if (characterArray[index] == 'X') 109 | { 110 | index++; 111 | if (characterArray[index] == '\\') 112 | { 113 | int[] codePoints = new int[1]; 114 | codePoints[0] = Integer.decode("0x" + characterArray[++index] + characterArray[++index]); 115 | decodedString = decodedString.concat(decoderIso8859_1.decode(buffer(codePoints)).toString()); 116 | } else if (characterArray[index] == '2') 117 | { 118 | index++; 119 | // UTF-16BE (UCS-2) 120 | int[] codePoints; 121 | do 122 | { 123 | codePoints = new int[2]; 124 | codePoints[0] = Integer.decode("0x" + characterArray[++index] + characterArray[++index]); 125 | codePoints[1] = Integer.decode("0x" + characterArray[++index] + characterArray[++index]); 126 | decodedString = decodedString.concat(decoderUTF16.decode(buffer(codePoints)).toString()); 127 | } while (characterArray[index + 1] != '\\'); // \X0\ is 128 | // the 129 | // end 130 | // signal 131 | index += 4; // . Second HEX-number is optional. 132 | } else if (characterArray[index] == '4') 133 | { 134 | index++; 135 | // UTF32 (UCS-4) 136 | int[] codePoints; 137 | do 138 | { 139 | codePoints = new int[4]; 140 | codePoints[0] = Integer.decode("0x" + characterArray[++index] + characterArray[++index]); 141 | codePoints[1] = Integer.decode("0x" + characterArray[++index] + characterArray[++index]); 142 | codePoints[2] = Integer.decode("0x" + characterArray[++index] + characterArray[++index]); 143 | codePoints[3] = Integer.decode("0x" + characterArray[++index] + characterArray[++index]); 144 | decodedString = decodedString.concat(decoderUTF32.decode(buffer(codePoints)).toString()); 145 | } while (characterArray[index + 1] != '\\'); // \X0\ is 146 | // the 147 | // end 148 | // signal 149 | index += 4; 150 | } 151 | } 152 | } else 153 | decodedString = decodedString.concat(new String(Character.toChars(characterArray[index]))); 154 | } 155 | return decodedString; 156 | } 157 | 158 | /** 159 | * Converts the given string into a ByteBuffer 160 | * 161 | * @param string 162 | * String to be converted 163 | * @return ByteBuffer representing the given String 164 | */ 165 | private static ByteBuffer buffer(String string) 166 | { 167 | byte[] bytes = string.getBytes(); 168 | bytes[0] += 128; 169 | ByteBuffer buffer = ByteBuffer.allocate(bytes.length); 170 | buffer.put(bytes); 171 | buffer.rewind(); 172 | return buffer; 173 | } 174 | 175 | /** 176 | * Converts an array of int into a ByteBuffer. 177 | * 178 | * @param numbers 179 | * array of int to be converted 180 | * @return ByteBuffer �quivalent to the input int[] 181 | */ 182 | private static ByteBuffer buffer(int[] numbers) 183 | { 184 | ByteBuffer buffer = ByteBuffer.allocate(numbers.length); 185 | for (int n : numbers) 186 | { 187 | byte b = (byte) n; 188 | buffer.put(b); 189 | } 190 | buffer.rewind(); 191 | return buffer; 192 | } 193 | 194 | /** 195 | * Converts a byte value into an int 196 | * 197 | * @param b 198 | * byte value to be conerted 199 | * @return �quivalent int value 200 | */ 201 | private static int byteToInt(byte b) 202 | { 203 | return b & 0xFF; 204 | } 205 | 206 | /** 207 | * Encodes the given string with the basic alphabet according to 208 | * ISO-10303-21. The encoding mechanismen is chosen automatically in the 209 | * following order: ISO-8859-1, -2, ... , -9, UTF-16BE, UTF-32 In addition 210 | * apostrophs and backslaches are doubled. Encoding according to 211 | * ISO-10303-21 $6.3.3.3 is not supported. 212 | * 213 | * @param string 214 | * String to be encoded 215 | * @return endcoded string 216 | */ 217 | public static String autoencode(String string) 218 | { 219 | CharsetDecoder decoder8859_1 = Charset.forName("ISO-8859-1").newDecoder(); 220 | 221 | CharsetEncoder encoder8859_1 = Charset.forName("ISO-8859-1").newEncoder(); 222 | CharsetEncoder encoder8859_2 = Charset.forName("ISO-8859-2").newEncoder(); 223 | CharsetEncoder encoder8859_3 = Charset.forName("ISO-8859-3").newEncoder(); 224 | CharsetEncoder encoder8859_4 = Charset.forName("ISO-8859-4").newEncoder(); 225 | CharsetEncoder encoder8859_5 = Charset.forName("ISO-8859-5").newEncoder(); 226 | CharsetEncoder encoder8859_6 = Charset.forName("ISO-8859-6").newEncoder(); 227 | CharsetEncoder encoder8859_7 = Charset.forName("ISO-8859-7").newEncoder(); 228 | CharsetEncoder encoder8859_8 = Charset.forName("ISO-8859-8").newEncoder(); 229 | CharsetEncoder encoder8859_9 = Charset.forName("ISO-8859-9").newEncoder(); 230 | CharsetEncoder encoderUTF16 = Charset.forName("UTF-16BE").newEncoder(); 231 | 232 | CharsetEncoder encoder = encoder8859_1; 233 | 234 | final int _ISO8859_1 = 1; 235 | final int _ISO8859_2 = 2; 236 | final int _ISO8859_3 = 3; 237 | final int _ISO8859_4 = 4; 238 | final int _ISO8859_5 = 5; 239 | final int _ISO8859_6 = 6; 240 | final int _ISO8859_7 = 7; 241 | final int _ISO8859_8 = 8; 242 | final int _ISO8859_9 = 9; 243 | final int _UTF16 = 11; 244 | final int _UTF32 = 12; 245 | int status = _ISO8859_1; // thus if only _ISO8859_1 is used there will 246 | // be no opening clause 247 | 248 | String openingClause = ""; 249 | String closingClause = ""; 250 | 251 | boolean encodingFailed; 252 | String encodedString = new String(); 253 | 254 | CharBuffer charBuffer; 255 | ByteBuffer byteBuffer; 256 | byte _byte; 257 | int codePoint; 258 | char[] characterArray = string.toCharArray(); 259 | char[] currentCharacter; 260 | int index = -1; 261 | while (index < characterArray.length - 1) 262 | { 263 | encodingFailed = false; 264 | index++; 265 | 266 | codePoint = Character.codePointAt(characterArray, index); 267 | if (codePoint > 65535) 268 | { 269 | // 4 byte encoding is necessary 270 | if (status == _UTF32) 271 | { 272 | openingClause = ""; 273 | } else 274 | { 275 | status = _UTF32; 276 | encodedString += closingClause; 277 | openingClause += "\\X4\\"; 278 | closingClause = "\\X0\\"; 279 | } 280 | encodedString += openingClause; 281 | encodedString += String.format("%1$08X", codePoint); 282 | index++; // because two characters are used for the encoding of 283 | // supplementary characters 284 | continue; 285 | } 286 | 287 | // single apostrophe is encoded as two consecutive apostrophes 288 | if (characterArray[index] == '\'') 289 | encodedString += "\'\'"; 290 | // a single backslash is encoded as two consecutive backslashes 291 | else if (characterArray[index] == '\\') 292 | encodedString += "\\\\"; 293 | // do encoding for other characters 294 | else 295 | { 296 | try 297 | { 298 | currentCharacter = new char[] { characterArray[index] }; 299 | charBuffer = CharBuffer.wrap(currentCharacter); 300 | 301 | if (status <= _ISO8859_9 && encoder.canEncode(currentCharacter[0])) 302 | { 303 | openingClause = ""; 304 | } else if (encoder8859_1.canEncode(currentCharacter[0])) 305 | { 306 | status = _ISO8859_1; 307 | encodedString += closingClause; 308 | openingClause = "\\PA\\"; 309 | closingClause = ""; 310 | encoder = encoder8859_1; 311 | } else if (encoder8859_2.canEncode(currentCharacter[0])) 312 | { 313 | status = _ISO8859_2; 314 | encodedString += closingClause; 315 | openingClause = "\\PB\\"; 316 | closingClause = ""; 317 | encoder = encoder8859_2; 318 | } else if (encoder8859_3.canEncode(currentCharacter[0])) 319 | { 320 | status = _ISO8859_3; 321 | encodedString += closingClause; 322 | openingClause = "\\PC\\"; 323 | closingClause = ""; 324 | encoder = encoder8859_3; 325 | } else if (encoder8859_4.canEncode(currentCharacter[0])) 326 | { 327 | status = _ISO8859_4; 328 | encodedString += closingClause; 329 | openingClause = "\\PD\\"; 330 | closingClause = ""; 331 | encoder = encoder8859_4; 332 | } else if (encoder8859_5.canEncode(currentCharacter[0])) 333 | { 334 | status = _ISO8859_5; 335 | encodedString += closingClause; 336 | openingClause = "\\PE\\"; 337 | closingClause = ""; 338 | encoder = encoder8859_5; 339 | } else if (encoder8859_6.canEncode(currentCharacter[0])) 340 | { 341 | status = _ISO8859_6; 342 | encodedString += closingClause; 343 | openingClause = "\\PF\\"; 344 | closingClause = ""; 345 | encoder = encoder8859_6; 346 | } else if (encoder8859_7.canEncode(currentCharacter[0])) 347 | { 348 | status = _ISO8859_7; 349 | encodedString += closingClause; 350 | openingClause = "\\PG\\"; 351 | closingClause = ""; 352 | encoder = encoder8859_7; 353 | } else if (encoder8859_8.canEncode(currentCharacter[0])) 354 | { 355 | status = _ISO8859_8; 356 | encodedString += closingClause; 357 | openingClause = "\\PH\\"; 358 | closingClause = ""; 359 | encoder = encoder8859_8; 360 | } else if (encoder8859_9.canEncode(currentCharacter[0])) 361 | { 362 | status = _ISO8859_9; 363 | encodedString += closingClause; 364 | openingClause = "\\PI\\"; 365 | closingClause = ""; 366 | encoder = encoder8859_9; 367 | } else 368 | { 369 | encodingFailed = true; 370 | } 371 | 372 | if (!encodingFailed && status <= _ISO8859_9) // ISO 8859 373 | // encoding 374 | // may be 375 | // possible 376 | // accoriding 377 | // to 378 | // ISO-10303-21 379 | // �6.3.3.1 380 | { 381 | // System.out.println(encoder.charset().displayName()); 382 | 383 | byteBuffer = encoder.encode(charBuffer); 384 | _byte = byteBuffer.get(); 385 | 386 | if (byteToInt(_byte) >= 31 && byteToInt(_byte) <= 126) 387 | { 388 | encodedString += currentCharacter[0]; // no opening 389 | // clause 390 | // needed 391 | // because 392 | // ISO8859_1 393 | // is 394 | // default 395 | } else if (byteToInt(_byte) >= 160 && byteToInt(_byte) <= 254) 396 | { // what about 255? can't be encoded! 397 | byteBuffer = ByteBuffer.allocate(1); 398 | _byte -= 128; 399 | byteBuffer.put(_byte); 400 | byteBuffer.rewind(); 401 | // characters for code point 32-126 are the same for 402 | // all parts of ISO 8859 403 | encodedString += openingClause; 404 | encodedString += "\\S\\" + decoder8859_1.decode(byteBuffer); 405 | } else 406 | { 407 | encodingFailed = true; // to be encoded as 2 or 4 408 | // byte 409 | } 410 | } 411 | 412 | if (encodingFailed) 413 | { 414 | // encoding with 2 byte (UTF16) 415 | charBuffer.rewind(); 416 | if (status == _UTF16) 417 | { 418 | openingClause = ""; 419 | } else 420 | { 421 | status = _UTF16; 422 | encodedString += closingClause; 423 | openingClause += "\\X2\\"; 424 | closingClause = "\\X0\\"; 425 | encoder = encoderUTF16; 426 | } 427 | byteBuffer = encoder.encode(charBuffer); 428 | encodedString += openingClause; 429 | for (byte b : byteBuffer.array()) 430 | { 431 | encodedString += String.format("%1$02X", b); 432 | } 433 | } // EOIF 434 | }// EOTry 435 | catch (CharacterCodingException e) 436 | { 437 | e.printStackTrace(); 438 | } 439 | }// EOElse 440 | }// EOWhile 441 | encodedString += closingClause; 442 | return encodedString; 443 | } 444 | 445 | // /** 446 | // * Encodes the given string according to ISO-10303-21 $6.3.3.1. All 447 | // * characters must be included in the character set of the selected part of 448 | // * ISO-8859. 449 | // * 450 | // * @param string 451 | // * String to be encoded 452 | // * @param part 453 | // * Part of ISO-8859 which contains all characters of the given 454 | // * string (one of 1-9) 455 | // * @return encoded string 456 | // * @throws CharacterCodingException 457 | // */ 458 | // public static String encode_ISO8859(String string, int part) throws CharacterCodingException 459 | // { 460 | // if (part < 1 || part > 9) 461 | // return null; 462 | // CharsetEncoder encoder = Charset.forName("ISO-8859-" + part).newEncoder(); 463 | // CharsetDecoder decoder = Charset.forName("ISO-8859-1").newDecoder(); 464 | // 465 | // String encodedString = ""; 466 | // char[] characterArray = string.toCharArray(); 467 | // ByteBuffer byteBuffer; 468 | // CharBuffer charBuffer; 469 | // char[] currentCharacter; 470 | // int index = -1; 471 | // byte _byte; 472 | // 473 | // encodedString += "\\P" + codePage.charAt(part - 1) + "\\"; 474 | // while (index < characterArray.length - 1) 475 | // { 476 | // index++; 477 | // currentCharacter = new char[] { characterArray[index] }; 478 | // charBuffer = CharBuffer.wrap(currentCharacter); 479 | // byteBuffer = encoder.encode(charBuffer); 480 | // _byte = byteBuffer.get(); 481 | // 482 | // if (byteToInt(_byte) >= 31 && byteToInt(_byte) <= 126) 483 | // { 484 | // encodedString += currentCharacter[0]; 485 | // } else if (byteToInt(_byte) >= 160 && byteToInt(_byte) <= 254) 486 | // { // what about 255? can't be encoded! 487 | // byteBuffer = ByteBuffer.allocate(1); 488 | // _byte -= 128; 489 | // byteBuffer.put(_byte); 490 | // byteBuffer.rewind(); 491 | // // characters for code point 32-126 are the same for all parts 492 | // // of ISO 8859 493 | // encodedString += "\\S\\" + decoder.decode(byteBuffer); 494 | // } 495 | // } 496 | // return encodedString; 497 | // } 498 | 499 | /** 500 | * Encodes the given string as two-octet representation (2byte) according to 501 | * ISO-10303-21 $6.3.3.2 Only Unicode characters contained in the Basic 502 | * Multilingual Plane (BMP) can be encoded. 503 | * 504 | * @param string 505 | * String to be encoded 506 | * @return encoded string 507 | * @throws CharacterCodingException 508 | */ 509 | public static String encode_2byte(String string) throws CharacterCodingException 510 | { 511 | CharsetEncoder encoder = Charset.forName("UTF-16BE").newEncoder(); 512 | String encodedString = ""; 513 | char[] characterArray = string.toCharArray(); 514 | ByteBuffer byteBuffer; 515 | CharBuffer charBuffer; 516 | char[] currentCharacter; 517 | int index = -1; 518 | 519 | encodedString += "\\X2\\"; 520 | while (index < characterArray.length - 1) 521 | { 522 | index++; 523 | currentCharacter = new char[] { characterArray[index] }; 524 | charBuffer = CharBuffer.wrap(currentCharacter); 525 | byteBuffer = encoder.encode(charBuffer); 526 | for (byte b : byteBuffer.array()) 527 | { 528 | encodedString += String.format("%1$02X", b); 529 | } 530 | } 531 | encodedString += "\\X0\\"; 532 | return encodedString; 533 | } 534 | 535 | /** 536 | * Encodes the given string as four-octet representation (4byte) according 537 | * to ISO-10303-21 $6.3.3.2 All Unicode characters can be encoded 538 | * 539 | * @param string 540 | * String to be encoded 541 | * @return encoded string 542 | * @throws CharacterCodingException 543 | */ 544 | public static String encode_4byte(String string) throws CharacterCodingException 545 | { 546 | String encodedString = ""; 547 | char[] characterArray = string.toCharArray(); 548 | int index = -1; 549 | int codePoint; 550 | encodedString += "\\X4\\"; 551 | 552 | while (index < characterArray.length - 1) 553 | { 554 | index++; 555 | codePoint = Character.codePointAt(characterArray, index); 556 | if (codePoint > 65535) 557 | index++; 558 | // 4 byte encoding 559 | encodedString += String.format("%1$08X", codePoint); 560 | } 561 | encodedString += "\\X0\\"; 562 | 563 | return encodedString; 564 | } 565 | 566 | /** 567 | * Encodes the given character as one byte with a value between 0 and 255 568 | * according to ISO-10303-21 $6.3.3.3 All Unicode characters can be encoded 569 | * 570 | * @param c 571 | * character to be encoded 572 | * @return encoded string 573 | */ 574 | public static String encode_8bit(char c) 575 | { 576 | char[] _char = new char[] { c }; 577 | int i = Character.codePointAt(_char, 0); 578 | if (i > 255) 579 | return null; 580 | return "\\X\\" + String.format("%1$02X", i); 581 | } 582 | 583 | public static String unwrap_primitive(String str) { 584 | Pattern pattern = Pattern.compile("^IFC[A-Z]+\\((.*)\\)$"); 585 | Matcher matcher = pattern.matcher(str); 586 | if (matcher.find()) { 587 | String content = matcher.group(1); 588 | if (content.startsWith("'")) { 589 | content = content.substring(1, content.length() - 1); 590 | try { 591 | content = decode(content); 592 | }catch (Exception e) { 593 | 594 | } 595 | } 596 | return content; 597 | } 598 | return str; 599 | } 600 | 601 | 602 | public static void main(String[] args) { 603 | String result = unwrap_primitive("IFCLENGTHMEASURE(0.)"); 604 | System.out.println(result); 605 | } 606 | 607 | 608 | } 609 | -------------------------------------------------------------------------------- /src/main/resources/ExpressGrammar.g4: -------------------------------------------------------------------------------- 1 | grammar ExpressGrammar; 2 | 3 | 4 | /* 5 | * Parser Rules 6 | */ 7 | 8 | // schema 9 | schema 10 | : beginSchema (entity | type | function | therule )* END_SCHEMA 11 | ; 12 | 13 | beginSchema 14 | : SCHEMA NAME ';' 15 | ; 16 | 17 | 18 | 19 | // entity 20 | entity 21 | : beginEntity (entityType | entityArgument | inversePart | derivePart | wherePart | uniquePart )+ END_ENTITY 22 | ; 23 | 24 | beginEntity 25 | : ENTITY NAME 26 | ; 27 | 28 | 29 | entityType 30 | : (subtypeOf|supertypeOf)* ';' 31 | ; 32 | 33 | subtypeOf 34 | : SUBTYPE_OF '(' NAME ')' # subtype 35 | ; 36 | 37 | supertypeOf 38 | : ABSTRACT? SUPERTYPE_OF '(' NAME ')' 39 | | ABSTRACT? SUPERTYPE_OF '(' ONEOF nameList ')' 40 | ; 41 | 42 | entityArgument 43 | : NAME ':' OPTIONAL? ( typeName | collectionOf typeName | collectionOf collectionArgPart) # attr 44 | ; 45 | 46 | 47 | 48 | collectionOf 49 | : typeArrayKeyword ('[' INT ':' (INT | '?' | NAME) ']') OF UNIQUE? 50 | ; 51 | 52 | collectionArgPart 53 | :(collectionOf typeName | collectionOf collectionArgPart) 54 | ; 55 | 56 | beginNameList 57 | : '(' 58 | ; 59 | 60 | endNameList 61 | : ')' 62 | ; 63 | 64 | nameList 65 | : beginNameList endNameList | beginNameList names endNameList 66 | ; 67 | 68 | names 69 | : names ',' NAME 70 | | NAME 71 | ; 72 | 73 | 74 | // type 75 | typeName 76 | : NAME ('(' INT ')')? 77 | | typeSingleKeyword ('(' INT ')')? 78 | ; 79 | 80 | type 81 | : 82 | TYPE NAME '=' 83 | ( 84 | typeName 85 | | 86 | collectionOf typeName 87 | | 88 | collectionOf collectionArgPart 89 | | 90 | ENUMERATION OF nameList 91 | | 92 | SELECT nameList 93 | ) 94 | FIXED? 95 | ';' 96 | wherePart* 97 | END_TYPE; 98 | 99 | 100 | 101 | // INVERSE 102 | 103 | inversePart 104 | : INVERSE inverseSentence+ 105 | ; 106 | 107 | inverseSentence 108 | : (NAME ':' (collectionOf)? NAME FOR NAME ';') 109 | ; 110 | 111 | // DERIVE 112 | 113 | 114 | derivePart 115 | : DERIVE (deriveSentence | ov=deriveOverrideSentence )+ 116 | ; 117 | 118 | deriveOverrideSentence 119 | : ('SELF\\')* NAME '.' NAME ':' typeName ':=' commonSentence 120 | ; 121 | 122 | deriveSentence 123 | : NAME ':' ( typeName | collectionArgPart ) ':=' commonSentence 124 | ; 125 | 126 | 127 | //UNIQUE 128 | 129 | uniquePart 130 | : UNIQUE uniqueSentence+ 131 | ; 132 | 133 | uniqueSentence 134 | : NAME ':' NAME (',' NAME)* ';' 135 | ; 136 | 137 | //WNERE 138 | 139 | wherePart 140 | : WHERE whereSentence+ 141 | ; 142 | 143 | whereSentence 144 | : NAME ':' commonSentence 145 | ; 146 | 147 | 148 | // other 149 | 150 | 151 | function 152 | : FUNCTION NAME (commonKeyword|commonSentence)+ END_FUNCTION 153 | ; 154 | 155 | therule 156 | : RULE NAME (commonKeyword|commonSentence)+ END_RULE 157 | ; 158 | 159 | commonKeyword 160 | : (WHERE|DERIVE|UNIQUE|INVERSE) 161 | ; 162 | 163 | commonSentence 164 | : (NAME | INT | sign | innerKeyword)+ ';' 165 | ; 166 | 167 | typeSingleKeyword : 168 | BOOLEAN| 169 | REAL| 170 | INTEGER| 171 | BINARY| 172 | NUMBER| 173 | STRING 174 | ; 175 | 176 | typeArrayKeyword : 177 | SET| 178 | ARRAY| 179 | LIST 180 | ; 181 | 182 | typeKeyword : 183 | typeSingleKeyword| 184 | typeArrayKeyword| 185 | ENUMERATION OF| 186 | SELECT 187 | ; 188 | 189 | innerKeyword : 190 | ONEOF| 191 | ABSTRACT| 192 | OPTIONAL| 193 | OF| 194 | FIXED| 195 | SELF_| 196 | FOR | 197 | typeKeyword 198 | ; 199 | 200 | sign : 201 | '[' | ']' | '<' | '>' | ',' | '.' | '\\' | '/' | '|' | '=' | '*' | '\'' | '"' | '?' | '!' | '-' | '+' | '{' | '}' | ':' | '(' | ')' | ':=' 202 | ; 203 | 204 | /* 205 | * Lexer Rules 206 | */ 207 | 208 | WS : [ \t\r\n]+ -> skip ; 209 | 210 | BLOCK_COMMENT 211 | : '(*' .*? '*)' -> skip 212 | ; 213 | 214 | INT : '0' | [1-9] [0-9]* ; 215 | 216 | SCHEMA : 'SCHEMA'; 217 | END_SCHEMA : 'END_SCHEMA;'; 218 | 219 | TYPE : 'TYPE'; 220 | END_TYPE : 'END_TYPE;'; 221 | 222 | ENTITY : 'ENTITY'; 223 | END_ENTITY : 'END_ENTITY;'; 224 | 225 | FUNCTION : 'FUNCTION'; 226 | END_FUNCTION : 'END_FUNCTION;'; 227 | 228 | RULE : 'RULE'; 229 | END_RULE : 'END_RULE;'; 230 | 231 | 232 | 233 | 234 | SUBTYPE_OF : 'SUBTYPE OF'; 235 | SUPERTYPE_OF : 'SUPERTYPE OF'; 236 | 237 | ONEOF : 'ONEOF'; 238 | ABSTRACT : 'ABSTRACT'; 239 | OPTIONAL : 'OPTIONAL'; 240 | FIXED : 'FIXED'; 241 | OF : 'OF'; 242 | 243 | SET : 'SET'; 244 | ARRAY : 'ARRAY'; 245 | LIST : 'LIST'; 246 | 247 | BOOLEAN : 'BOOLEAN'; 248 | REAL : 'REAL'; 249 | INTEGER : 'INTEGER'; 250 | BINARY : 'BINARY'; 251 | NUMBER : 'NUMBER'; 252 | 253 | STRING : 'STRING'; 254 | ENUMERATION : 'ENUMERATION'; 255 | SELECT : 'SELECT'; 256 | 257 | 258 | WHERE : 'WHERE'; 259 | DERIVE : 'DERIVE'; 260 | UNIQUE : 'UNIQUE'; 261 | INVERSE : 'INVERSE'; 262 | 263 | SELF_ : 'SELF\\'; 264 | FOR : 'FOR'; 265 | 266 | NAME : [0-9a-zA-Z_]+ ; 267 | -------------------------------------------------------------------------------- /src/main/resources/STEPGrammar.g4: -------------------------------------------------------------------------------- 1 | grammar STEPGrammar; 2 | 3 | 4 | /* 5 | * Parser Rules 6 | */ 7 | 8 | ifcFile 9 | : ISOSTEPSTART (header)? (data)? ISOSTEPEND EOF 10 | ; 11 | 12 | 13 | //header 14 | 15 | header 16 | : 'HEADER;' (headerLine)* 'ENDSEC;' 17 | ; 18 | 19 | 20 | headerLine 21 | : 'FILE_DESCRIPTION' '(' argumentList ')' ';' #filedescipt 22 | | 'FILE_NAME' '(' STRING ',' argumentList ')' ';' #filename 23 | | 'FILE_SCHEMA' '(''(' STRING ')'')' ';' #fileschema 24 | ; 25 | 26 | 27 | 28 | //data 29 | 30 | data 31 | : 'DATA;' (dataLine)* 'ENDSEC;' 32 | ; 33 | 34 | dataLine 35 | : 36 | '#' INT '=' typedListArgument ';' 37 | ; 38 | 39 | typedListArgument 40 | : NAME '(' ')' 41 | | NAME '(' argumentList ')' 42 | ; 43 | 44 | 45 | //argument 46 | 47 | argument 48 | : '#' INT 49 | | typedListArgument 50 | | (INT|NEGINT|INTEXP|FLOAT|STRING|BOOLEAN|ENUM|OVERRIDE|NONDEF) 51 | | listArgument 52 | ; 53 | 54 | 55 | listArgument 56 | : '()' 57 | | '(' argumentList ')' 58 | ; 59 | 60 | 61 | argumentList 62 | : argument (',' argument)* 63 | ; 64 | /* 65 | * Lexer Rules 66 | */ 67 | 68 | WS : [ \t\r\n]+ -> skip ; 69 | 70 | 71 | BLOCK_COMMENT 72 | : '/*' .*? '*/' -> skip 73 | ; 74 | LINE_COMMENT 75 | : '//' ~[\r\n]* -> skip 76 | ; 77 | 78 | NONDEF : '$'; 79 | OVERRIDE : '*'; 80 | 81 | 82 | BOOLEAN : '.T.' | '.F.' ; 83 | 84 | 85 | INT : '0' | [1-9] [0-9]* ; // no leading zeros 86 | 87 | NEGINT : '-' INT; // negtive int 88 | 89 | INTEXP : (INT|NEGINT) EXP ; 90 | 91 | FLOAT : 92 | '.' [0-9]+ EXP? // .35E-9 93 | | (INT|NEGINT) '.' [0-9]* EXP? // 1.35, 1.35E-9, 0.3, -4.5, 1.E-5 94 | ; 95 | 96 | fragment EXP : [Ee] [+\-]? [0-9]* ; // \- since - means "range" inside [...] 97 | 98 | 99 | 100 | ENUM : '.' NAME '.' ; 101 | 102 | STRING : '\'' ((~[']) | '\'\'' )* '\'' ; 103 | 104 | 105 | 106 | ISOSTEPSTART : 'STEP;' | 'ISO' [0-9\-]* ';'; 107 | ISOSTEPEND : 'ENDSTEP;' | 'END-ISO'[0-9\-]* ';'; 108 | 109 | HEADER : 'HEADER;'; 110 | DATA : 'DATA;'; 111 | ENDSEC : 'ENDSEC;'; 112 | 113 | 114 | 115 | NAME : [0-9a-zA-Z_]+ ; 116 | 117 | -------------------------------------------------------------------------------- /src/main/resources/colors.txt: -------------------------------------------------------------------------------- 1 | RAS_回风系统 255 0 255 2 | FAS_新风系统 0 255 0 3 | SAS_送风系统 0 153 255 4 | PAS_加压送风系统 153 204 255 5 | SA/MUS_送风兼补风系统 153 204 255 6 | SSS_消防补风系统 153 204 255 7 | KMS_厨房补风系统 153 204 255 8 | MUS_补风系统 153 204 255 9 | EAS_排风系统 255 204 122 10 | AEA_事故排风系统 255 204 122 11 | SES_排烟系统 255 204 0 12 | EA/SES_排风兼排烟系统 255 80 80 13 | KES_排油烟系统 204 0 0 14 | CSS_空调冷冻水供水系 0 153 255 15 | CRS_空调冷冻水回水系统 0 102 204 16 | CS_冷凝水系统 102 204 255 17 | CTS_冷却水供水系统 0 153 255 18 | CTR_冷却水回水系统 0 102 204 19 | CHS_空调冷热水供水系统 0 153 255 20 | CHR_空调冷热水回水系 0 102 204 21 | EWS_膨胀水系 128 128 0 22 | HSS_热水供水系统 255 255 153 23 | HRS_热水回水系统 255 255 0 24 | PRS_定压系统 255 204 0 25 | MUS_补水系 0 153 255 26 | WACS_热风幕供水系 255 255 153 27 | WACR_热风幕回水系 255 255 0 28 | SWS_软化水系统 255 204 0 29 | RSS_供暖供水管系统 255 255 153 30 | RRS_供暖回水管系统 255 255 0 31 | FHS_地板辐射采暖系统 255 153 0 32 | DS_排水系统 204 153 0 33 | CWS_自来水管系统 0 255 0 34 | RRS_二次侧供暖回水管系 255 255 0 35 | RSS_二次侧供暖供水管系统 255 255 153 36 | TWS_生活给水系统 0 255 0 37 | CWIS_冷却补水系统 0 255 0 38 | NWS_市政直供给水系统 0 255 0 39 | PWSS_加压给水系统 0 255 0 40 | SHSWS_太阳能热水供水系统 255 153 102 41 | SHBWS_太阳能热水回水管系统 255 153 102 42 | HRS_一次侧热水回水系统 255 153 102 43 | HSS_热水供水系统 255 153 102 44 | DHWS_生活热水系统 255 153 102 45 | HRS_热水回水系统 255 153 102 46 | KPWS_厨房压力废水系统 153 102 0 47 | GWS_重力废水系统 153 102 0 48 | KGWS_厨房重力废水系统 153 102 0 49 | PWWS_压力废水系统 153 102 0 50 | KSS_厨房污水系统 204 153 0 51 | PSS_压力污水系统 204 153 0 52 | GSS_污水排水系统 204 153 0 53 | ODS_室外排水系统 204 153 0 54 | VLS_通气系统 255 255 255 55 | SRDS_虹吸雨水系统 0 128 0 56 | PFRDS_压力雨水系统 0 128 0 57 | GSDS_重力雨水系统 0 128 0 58 | ORWS_室外雨水系统 0 128 0 59 | FHS_室内消火栓系统 255 0 0 60 | AWCFWS_自动水炮灭火给水系统 255 0 0 61 | ASS_自动喷淋系统 255 0 0 62 | PPCSWPS_窗玻璃防护冷却系统给水系统 255 0 0 63 | OFFS_室外消防系统 255 0 0 64 | GFES_气体灭火系统 255 0 0 65 | HVEPS_高压配电系统 255 0 255 66 | ELVS_应急低压配电系统 255 102 255 67 | FA_消防弱电系统 255 102 255 68 | NLVS_普通低压配电系统 255 153 255 69 | LTS_照明系统 255 204 255 70 | EMS_电力控制系统 255 178 255 71 | LTS_照明系统 255 128 255 72 | GCS_综合布线系统 0 153 255 73 | WCIS_弱电综合系统 0 204 255 74 | UPS_弱电供电电源系统 0 255 255 75 | PFSS_客流统计系统 51 51 255 -------------------------------------------------------------------------------- /src/main/resources/excluded.txt: -------------------------------------------------------------------------------- 1 | IFC2DCOMPOSITECURVE 2 | IFCACTIONREQUEST 3 | IFCANGULARDIMENSION 4 | IFCANNOTATION 5 | IFCANNOTATIONCURVEOCCURRENCE 6 | IFCANNOTATIONFILLAREA 7 | IFCANNOTATIONFILLAREAOCCURRENCE 8 | IFCANNOTATIONOCCURRENCE 9 | IFCANNOTATIONSURFACE 10 | IFCANNOTATIONSURFACEOCCURRENCE 11 | IFCANNOTATIONSYMBOLOCCURRENCE 12 | IFCANNOTATIONTEXTOCCURRENCE 13 | IFCAPPLIEDVALUE 14 | IFCAPPLIEDVALUERELATIONSHIP 15 | IFCAPPROVAL 16 | IFCAPPROVALACTORRELATIONSHIP 17 | IFCAPPROVALPROPERTYRELATIONSHIP 18 | IFCAPPROVALRELATIONSHIP 19 | IFCBEZIERCURVE 20 | IFCBLOBTEXTURE 21 | IFCBLOCK 22 | IFCBOUNDARYCONDITION 23 | IFCBOUNDARYEDGECONDITION 24 | IFCBOUNDARYFACECONDITION 25 | IFCBOUNDARYNODECONDITION 26 | IFCBOUNDARYNODECONDITIONWARPING 27 | IFCBOUNDEDCURVE 28 | IFCBOUNDEDSURFACE 29 | IFCBOUNDINGBOX 30 | IFCBOXEDHALFSPACE 31 | IFCBSPLINECURVE 32 | //IFCCARTESIANPOINT 33 | IFCCARTESIANTRANSFORMATIONOPERATOR 34 | IFCCARTESIANTRANSFORMATIONOPERATOR2D 35 | IFCCARTESIANTRANSFORMATIONOPERATOR2DNONUNIFORM 36 | IFCCARTESIANTRANSFORMATIONOPERATOR3D 37 | IFCCARTESIANTRANSFORMATIONOPERATOR3DNONUNIFORM 38 | IFCCENTERLINEPROFILEDEF 39 | IFCCHAMFEREDGEFEATURE 40 | IFCCIRCLE 41 | IFCCLOSEDSHELL 42 | IFCCOMPOSITECURVE 43 | IFCCOMPOSITECURVESEGMENT 44 | IFCCONDITION 45 | IFCCONDITIONCRITERION 46 | IFCCONIC 47 | IFCCONNECTEDFACESET 48 | IFCCONNECTIONCURVEGEOMETRY 49 | IFCCONNECTIONGEOMETRY 50 | IFCCONNECTIONPOINTECCENTRICITY 51 | IFCCONNECTIONPOINTGEOMETRY 52 | IFCCONNECTIONPORTGEOMETRY 53 | IFCCONNECTIONSURFACEGEOMETRY 54 | IFCCONSTRAINT 55 | IFCCONSTRAINTAGGREGATIONRELATIONSHIP 56 | IFCCONSTRAINTCLASSIFICATIONRELATIONSHIP 57 | IFCCONSTRAINTRELATIONSHIP 58 | IFCCONSTRUCTIONEQUIPMENTRESOURCE 59 | IFCCONSTRUCTIONMATERIALRESOURCE 60 | IFCCONSTRUCTIONPRODUCTRESOURCE 61 | IFCCONSTRUCTIONRESOURCE 62 | IFCCONTEXTDEPENDENTUNIT 63 | IFCCONTROL 64 | IFCCONVERSIONBASEDUNIT 65 | IFCCOORDINATEDUNIVERSALTIMEOFFSET 66 | IFCCREWRESOURCE 67 | IFCCSGPRIMITIVE3D 68 | IFCCSGSOLID 69 | IFCCURRENCYRELATIONSHIP 70 | IFCCURVE 71 | IFCCURVEBOUNDEDPLANE 72 | IFCDEFINEDSYMBOL 73 | IFCDIAMETERDIMENSION 74 | IFCDIMENSIONALEXPONENTS 75 | IFCDIMENSIONCALLOUTRELATIONSHIP 76 | IFCDIMENSIONCURVE 77 | IFCDIMENSIONCURVEDIRECTEDCALLOUT 78 | IFCDIMENSIONCURVETERMINATOR 79 | IFCDIMENSIONPAIR 80 | IFCDRAUGHTINGCALLOUT 81 | IFCDRAUGHTINGCALLOUTRELATIONSHIP 82 | IFCDRAUGHTINGPREDEFINEDCOLOUR 83 | IFCDRAUGHTINGPREDEFINEDCURVEFONT 84 | IFCDRAUGHTINGPREDEFINEDTEXTFONT 85 | IFCEDGE 86 | IFCEDGECURVE 87 | IFCEDGEFEATURE 88 | IFCEDGELOOP 89 | IFCELEMENTARYSURFACE 90 | IFCELLIPSE 91 | IFCELLIPSEPROFILEDEF 92 | IFCENERGYPROPERTIES 93 | IFCENVIRONMENTALIMPACTVALUE 94 | IFCEQUIPMENTELEMENT 95 | IFCEXTERNALLYDEFINEDHATCHSTYLE 96 | IFCEXTERNALLYDEFINEDSURFACESTYLE 97 | IFCEXTERNALLYDEFINEDSYMBOL 98 | IFCEXTERNALLYDEFINEDTEXTFONT 99 | IFCEXTERNALREFERENCE 100 | IFCFACE 101 | IFCFACEBOUND 102 | IFCFACEOUTERBOUND 103 | IFCFACESURFACE 104 | IFCFAILURECONNECTIONCONDITION 105 | IFCFEATUREELEMENTADDITION 106 | IFCFEATUREELEMENTSUBTRACTION 107 | IFCFUELPROPERTIES 108 | IFCGEOMETRICCURVESET 109 | IFCGEOMETRICREPRESENTATIONCONTEXT 110 | IFCGEOMETRICREPRESENTATIONITEM 111 | IFCGEOMETRICREPRESENTATIONSUBCONTEXT 112 | IFCGEOMETRICSET 113 | IFCGRIDPLACEMENT 114 | IFCHYGROSCOPICMATERIALPROPERTIES 115 | IFCIMAGETEXTURE 116 | IFCINVENTORY 117 | IFCIRREGULARTIMESERIES 118 | IFCIRREGULARTIMESERIESVALUE 119 | IFCLABORRESOURCE 120 | IFCLIBRARYINFORMATION 121 | IFCLIBRARYREFERENCE 122 | IFCLIGHTDISTRIBUTIONDATA 123 | IFCLIGHTINTENSITYDISTRIBUTION 124 | IFCLIGHTSOURCE 125 | IFCLIGHTSOURCEAMBIENT 126 | IFCLIGHTSOURCEDIRECTIONAL 127 | IFCLIGHTSOURCEGONIOMETRIC 128 | IFCLIGHTSOURCEPOSITIONAL 129 | IFCLIGHTSOURCESPOT 130 | IFCLINE 131 | IFCLINEARDIMENSION 132 | IFCLOCALTIME 133 | IFCLOOP 134 | IFCLSHAPEPROFILEDEF 135 | IFCMANIFOLDSOLIDBREP 136 | IFCMONETARYUNIT 137 | IFCOBJECTIVE 138 | IFCOBJECTPLACEMENT 139 | IFCOFFSETCURVE2D 140 | IFCOFFSETCURVE3D 141 | IFCONEDIRECTIONREPEATFACTOR 142 | IFCOPENSHELL 143 | IFCORDERACTION 144 | IFCORIENTEDEDGE 145 | IFCOWNERHISTORY 146 | IFCPATH 147 | IFCPERFORMANCEHISTORY 148 | IFCPERMEABLECOVERINGPROPERTIES 149 | IFCPERMIT 150 | IFCPIXELTEXTURE 151 | IFCPLACEMENT 152 | IFCPLANARBOX 153 | IFCPLANAREXTENT 154 | IFCPLANE 155 | IFCPOINT 156 | IFCPOINTONCURVE 157 | IFCPOINTONSURFACE 158 | IFCPOLYLINE 159 | IFCPOLYLOOP 160 | IFCPREDEFINEDCURVEFONT 161 | IFCPREDEFINEDDIMENSIONSYMBOL 162 | IFCPREDEFINEDITEM 163 | IFCPREDEFINEDPOINTMARKERSYMBOL 164 | IFCPREDEFINEDSYMBOL 165 | IFCPREDEFINEDTERMINATORSYMBOL 166 | IFCPREDEFINEDTEXTFONT 167 | IFCPRODUCTREPRESENTATION 168 | IFCPRODUCTSOFCOMBUSTIONPROPERTIES 169 | IFCPROJECTIONCURVE 170 | IFCPROJECTORDER 171 | IFCPROJECTORDERRECORD 172 | IFCPROPERTYCONSTRAINTRELATIONSHIP 173 | IFCRATIONALBEZIERCURVE 174 | IFCRECTANGULARPYRAMID 175 | IFCRECTANGULARTRIMMEDSURFACE 176 | IFCREFERENCESVALUEDOCUMENT 177 | IFCREGULARTIMESERIES 178 | IFCRELAXATION 179 | IFCREPRESENTATIONCONTEXT 180 | IFCREPRESENTATIONITEM 181 | IFCRESOURCE 182 | IFCREVOLVEDAREASOLID 183 | IFCRIBPLATEPROFILEPROPERTIES 184 | IFCRIGHTCIRCULARCONE 185 | IFCRIGHTCIRCULARCYLINDER 186 | IFCROUNDEDEDGEFEATURE 187 | IFCSECTIONEDSPINE 188 | IFCSERVICELIFE 189 | IFCSERVICELIFEFACTOR 190 | IFCSHAPEASPECT 191 | IFCSHELLBASEDSURFACEMODEL 192 | IFCSLIPPAGECONNECTIONCONDITION 193 | IFCSOLIDMODEL 194 | IFCSOUNDPROPERTIES 195 | IFCSOUNDVALUE 196 | IFCSPHERE 197 | IFCSUBCONTRACTRESOURCE 198 | IFCSUBEDGE 199 | IFCSURFACE 200 | IFCSURFACECURVESWEPTAREASOLID 201 | IFCSURFACEOFLINEAREXTRUSION 202 | IFCSURFACEOFREVOLUTION 203 | IFCSWEPTAREASOLID 204 | IFCSWEPTDISKSOLID 205 | IFCSWEPTSURFACE 206 | IFCTABLE 207 | IFCTABLEROW 208 | IFCTERMINATORSYMBOL 209 | IFCTEXTLITERAL 210 | IFCTEXTLITERALWITHEXTENT 211 | IFCTEXTSTYLE 212 | IFCTEXTSTYLEFONTMODEL 213 | IFCTEXTSTYLEFORDEFINEDFONT 214 | IFCTEXTSTYLETEXTMODEL 215 | IFCTEXTSTYLEWITHBOXCHARACTERISTICS 216 | IFCTEXTURECOORDINATE 217 | IFCTEXTURECOORDINATEGENERATOR 218 | IFCTEXTUREMAP 219 | IFCTEXTUREVERTEX 220 | IFCTIMESERIES 221 | IFCTIMESERIESREFERENCERELATIONSHIP 222 | IFCTIMESERIESSCHEDULE 223 | IFCTIMESERIESVALUE 224 | IFCTOPOLOGICALREPRESENTATIONITEM 225 | IFCTOPOLOGYREPRESENTATION 226 | IFCTRIMMEDCURVE 227 | IFCTUBEBUNDLETYPE 228 | IFCTWODIRECTIONREPEATFACTOR 229 | IFCUSHAPEPROFILEDEF 230 | IFCVECTOR 231 | IFCVERTEX 232 | IFCVERTEXBASEDTEXTUREMAP 233 | IFCVERTEXLOOP 234 | IFCVERTEXPOINT 235 | IFCVIRTUALGRIDINTERSECTION -------------------------------------------------------------------------------- /src/main/resources/inverse.txt: -------------------------------------------------------------------------------- 1 | IfcStyledItem Item StyledByItem Styles None 2 | IfcRelContainedInSpatialStructure RelatingStructure ContainsElements RelatedElements ContainedInStructure 3 | IfcRelAssignsToGroup RelatingGroup IsGroupedBy RelatedObjects HasAssignments 4 | IfcRelDefinesByProperties RelatingPropertyDefinition PropertyDefinitionOf RelatedObjects IsDefinedBy 5 | IfcRelDefinesByType RelatingType ObjectTypeOf RelatedObjects HasAssignments 6 | IfcRelAggregates RelatingObject IsDecomposedBy RelatedObjects Decomposes 7 | IfcRelCoversBldgElements RelatingBuildingElement HasCoverings RelatedCoverings Covers 8 | IfcRelConnectsPortToElement RelatingPort ContainedIn RelatedElement HasPorts 9 | IfcRelConnectsPorts RelatingPort ConnectedTo RelatedPort ConnectedFrom --------------------------------------------------------------------------------