{"id":29230424,"url":"https://github.com/morichan/fescue","last_synced_at":"2025-08-29T13:32:59.628Z","repository":{"id":57734248,"uuid":"115557739","full_name":"Morichan/fescue","owner":"Morichan","description":"Feature Elements Section of Class in UML Extraction","archived":false,"fork":false,"pushed_at":"2018-10-26T09:48:59.000Z","size":475,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-03T13:54:11.769Z","etag":null,"topics":["antlr4","antlr4-grammar","class-diagram","japanese","java9","master-thesis","uml"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Morichan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-27T21:08:51.000Z","updated_at":"2019-01-13T00:59:03.000Z","dependencies_parsed_at":"2022-09-26T22:10:58.147Z","dependency_job_id":null,"html_url":"https://github.com/Morichan/fescue","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/Morichan/fescue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morichan%2Ffescue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morichan%2Ffescue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morichan%2Ffescue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morichan%2Ffescue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morichan","download_url":"https://codeload.github.com/Morichan/fescue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morichan%2Ffescue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272692568,"owners_count":24977378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["antlr4","antlr4-grammar","class-diagram","japanese","java9","master-thesis","uml"],"created_at":"2025-07-03T13:36:49.185Z","updated_at":"2025-08-29T13:32:59.595Z","avatar_url":"https://github.com/Morichan.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![fescue_logo_mini](https://user-images.githubusercontent.com/20200292/35912038-d45a7a86-0c3e-11e8-8b4c-d660d0d6db48.png)\r\n\r\n\r\n\r\n|Main|Develop|\r\n|:--:|:--:|\r\n|[![Build Status](https://travis-ci.org/Morichan/fescue.svg?branch=master)](https://travis-ci.org/Morichan/fescue)|[![Build Status](https://travis-ci.org/Morichan/fescue.svg?branch=develop)](https://travis-ci.org/Morichan/fescue)|\r\n|[![codecov](https://codecov.io/gh/Morichan/fescue/branch/master/graph/badge.svg)](https://codecov.io/gh/Morichan/fescue)|[![codecov](https://codecov.io/gh/Morichan/fescue/branch/develop/graph/badge.svg)](https://codecov.io/gh/Morichan/fescue)|\r\n|![GitHub last commit (master)](https://img.shields.io/github/last-commit/Morichan/fescue/master.svg)|![GitHub last commit (develop)](https://img.shields.io/github/last-commit/Morichan/fescue/develop.svg)|\r\n\r\n[![license](https://img.shields.io/github/license/Morichan/fescue.svg)](LICENSE)\r\n\r\n[![Java version](https://img.shields.io/badge/java-9+-4c7e9f.svg)](https://www.java.com/en/)\r\n[![JUnit version](https://img.shields.io/badge/junit-5+-dc524a.svg)](http://junit.org/junit5/)\r\n[![Gradle version](https://img.shields.io/badge/gradle-4.4+-007042.svg)](https://gradle.org/docs/)\r\n[![ANTLR version](https://img.shields.io/badge/antlr-4+-ec312e.svg)](http://junit.org/junit5/)\r\n\r\n[![GitHub tag](https://img.shields.io/github/tag/Morichan/fescue.svg)](https://github.com/Morichan/fescue/tags)\r\n[![GitHub release](https://img.shields.io/github/release/Morichan/fescue/all.svg)](https://github.com/Morichan/fescue/releases)\r\n[![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed-raw/Morichan/fescue.svg)](https://github.com/Morichan/fescue/pulls?q=is%3Apr+is%3Aclosed)\r\n\r\n\r\n\r\n# fescue\r\n\r\nThe grammar file of Attribute and Operation in UML Class Diagram using [ANTLR v4](https://github.com/antlr/antlr4).\r\nAnd, the Feature Elements Section of Class in UML Extraction library that uses the parser generated based on the grammar file.\r\n\r\n[ANTLR v4](https://github.com/antlr/antlr4)を利用した、UMLのクラス図における、属性と操作の文法ファイル、およびそれを元に生成した構文解析機を利用する属性と操作の要素抽出ライブラリです。\r\n\r\n\r\n\r\n# Build Process\r\n\r\nWindows and Linux (and other?)\r\n\r\nGradle version \u003e= 4.2.1\r\n\r\n```sh\r\n$ git clone https://github.com/Morichan/fescue\r\n$ cd ./fescue\r\n$ gradle build\r\n$ ls ./build/libs/\r\nfescue-2.1.1.jar\r\n```\r\n\r\n\r\n\r\n# How to Use\r\n\r\nBy Maven\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n  \u003cgroupId\u003eio.github.morichan\u003c/groupId\u003e\r\n  \u003cartifactId\u003efescue\u003c/artifactId\u003e\r\n  \u003cversion\u003e2.1.1\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\nBy Gradle\r\n\r\n```gradle\r\napply plugin: 'java'\r\n\r\nrepositories {\r\n    mavenCentral()\r\n}\r\n\r\ndependencies {\r\n    compile 'io.github.morichan:fescue:2.1.1'\r\n}\r\n```\r\n\r\nExplain how to use each file and its function.\r\n\r\n各ファイルの使い方と機能について説明します。\r\n\r\n## ClassFeature.g4\r\n\r\nIt is put on `src/main/antlr/ClassFeature.g4` .\r\n\r\nWhen you enter a sentence of the Attribute in UML Class Diagram, it generates a syntax tree.\r\nPlease refer to [ANTLR v4](https://github.com/antlr/antlr4) for usage and how to make a syntax analyzer.\r\n\r\nUMLのクラス図における属性の文章を入力すると、構文木を生成します。\r\n使い方および構文解析機の作り方については、[ANTLR v4](https://github.com/antlr/antlr4)を参考にしてください。\r\n\r\n![Feature's Class Diagram](https://github.com/Morichan/fescue/blob/master/documents/feature_class_diagram.svg)\r\n\r\n## fescue-2.1.1.jar\r\n\r\nEach element extractor of the Attribute and the Operation using the above syntactic analyzer.\r\n\r\n上記の構文解析機を利用した、属性および操作の各要素抽出器です。\r\n\r\n```java\r\nimport io.github.morichan.fescue.sculptor.OperationSculptor;\r\nimport io.github.morichan.fescue.feature.Operation;\r\nimport io.github.morichan.fescue.sculptor.AttributeSculptor;\r\nimport io.github.morichan.fescue.feature.Attribute;\r\n\r\n/**\r\n * \u003cp\u003e How to use the fescue, which the Class Feature like the Attribute and Operation \u003c/p\u003e\r\n *\r\n * \u003cp\u003e How to Compile \u003c/p\u003e\r\n *\r\n * \u003cpre\u003e\r\n *     {@code\r\n *     $ javac -encoding utf8 -classpath .;fescue-2.1.1.jar Main.java\r\n *     $ java -classpath .;fescue-2.1.1.jar;antlr-4.7.1-complete.jar Main\r\n *     }\r\n * \u003c/pre\u003e\r\n *\r\n * \u003cp\u003e Result \u003c/p\u003e\r\n *\r\n * \u003cpre\u003e\r\n *     {@code\r\n *     - number : int\r\n *     number\r\n *     int\r\n *\r\n *     + setNumber(number : int) : void\r\n *     setNumber\r\n *     void\r\n *     }\r\n * \u003c/pre\u003e\r\n */\r\nclass Main {\r\n\r\n    public static void main(String[] args) {\r\n        printAttribute();\r\n        printOperation();\r\n    }\r\n\r\n    private static void printAttribute() {\r\n        AttributeSculptor sculptor = new AttributeSculptor();\r\n        Attribute attribute;\r\n\r\n        sculptor.parse(\"- number : int\");\r\n        attribute = sculptor.carve();\r\n\r\n        System.out.println(attribute); // \"- number : int\"\r\n        System.out.println(attribute.getName()); // \"number\"\r\n        System.out.println(attribute.getType()); // \"int\"\r\n\r\n        System.out.println(); // newline char\r\n    }\r\n\r\n    private static void printOperation() {\r\n        OperationSculptor sculptor = new OperationSculptor();\r\n        Operation operation;\r\n\r\n        sculptor.parse(\"+ setNumber(number : int) : void\");\r\n        operation = sculptor.carve();\r\n\r\n        System.out.println(operation); // \"+ setNumber(number : int) : void\"\r\n        System.out.println(operation.getName()); // \"setNumber\"\r\n        System.out.println(operation.getReturnType()); // \"void\"\r\n    }\r\n}\r\n```\r\n\r\n各クラスのJavadocやテストコードに使用例や対応構文を書いていますので、そちらもご覧ください。\r\n\r\n\r\n\r\n# Grammar: 文法\r\n\r\nそれぞれの文法、および各要素について説明します。\r\n元となる文法は「UML2.0仕様書 2.1対応」 (ISBN: 978-4274066634) を参考にしました。\r\n詳細は`/src/main/antlr/ClassFeature.g4`をご覧ください。\r\n\r\n## Attribute: 属性\r\n\r\n属性の文法は次の通りです。\r\n\r\n```EBNF\r\n\u003cproperty\u003e ::= [\u003cvisibility\u003e] ['/'] \u003cname\u003e [':' \u003cprop-type\u003e] ['[' \u003cmultiplicity\u003e ']'] ['=' \u003cdefault\u003e] ['{' \u003cprop-modifier\u003e [',' \u003cprop-modifier\u003e]*'}']\r\n```\r\n\r\n### 各要素の説明\r\n\r\n* visibility: 可視性（例、`'+', '-'`）\r\n* '/': 派生\r\n* name: 属性名\r\n* prop-type: 型\r\n* multiplicity: 多重度（例、`'*', '0 .. 1'`）\r\n* default: 既定値（例、`'true', '3 + x'`）\r\n* prop-modifier: プロパティ（例、`'readOnly', 'subsets instance'`）\r\n\r\n### 入力例と出力結果\r\n\r\n```text\r\n- projectId : char [0 .. *] = id + 001 {readOnly, subsets id}\r\n```\r\n\r\n\r\n```elisp\r\n(property\r\n    (visibility -)\r\n    (name projectId)\r\n    (propType (type : (primitiveType char)))\r\n    (multiplicityRange [ (lower (integerLiteral 0)) .. (upper *) ])\r\n    (defaultValue = (expression (expression id) + (expression (literal (integerLiteral 001)))))\r\n    (propModifiers (properties { (propModifier readOnly) , (propModifier subsets (propertyName (name id))) })))\r\n```\r\n\r\n![example_attribute](https://user-images.githubusercontent.com/20200292/35249331-eb8265e2-0014-11e8-84ec-0b27b0325618.PNG)\r\n\r\n## Operation: 操作\r\n\r\n操作の文法は次の通りです。\r\n\r\n```EBNF\r\n\u003coperation\u003e ::= [\u003cvisibility\u003e] \u003cname\u003e '(' \u003cparameter-list\u003e ')' [':' \u003creturn-type\u003e] ['{' \u003coper-property\u003e [',' \u003coper-property\u003e]* '}']\r\n\r\n\u003cparameter-list\u003e ::= \u003cparameter\u003e [',' \u003cparameter\u003e]*\r\n\u003cparameter\u003e ::= [\u003cdirection\u003e] \u003cparameter-name\u003e ':' \u003ctype-expression\u003e ['[' \u003cmultiplicity\u003e ']'] ['=' \u003cdefault'\u003e] ['{' \u003cparam-property\u003e [',' \u003cparam-property\u003e]* '}']\r\n```\r\n\r\n### 各要素の説明\r\n\r\n* visibility: 可視性（例、`'+', '-'`）\r\n* name: 操作名\r\n* parameter-list: パラメータリスト\r\n    * parameter: パラメータ\r\n    * direction: 方向（例、`'in', 'out', 'return'`）\r\n    * parameter-name: パラメータ名\r\n    * type-expression: パラメータの型\r\n    * multiplicity: 多重度（属性のmultiplicityと同じ）\r\n    * default: パラメータの既定値\r\n    * param-property: パラメータのプロパティ（表記の定義なし）\r\n* return-type: 戻り値を持っている場合はその型\r\n* oper-property: プロパティ（例、`'query', 'redefines method()'`）\r\n\r\n### 入力例と出力結果\r\n\r\n```text\r\n+ selectProjectData(in projectId : char [*] = \"hogehoge001\", data : Data [(lowCount - 1)..*] = getDataList(dataId, count).get(Project.number) {readOnly}) : Data {query, redefines selectProjectDataImpl}\r\n```\r\n\r\n```elisp\r\n(operation\r\n    (visibility +)\r\n    (name selectProjectData)\r\n    (parameterList\r\n        (\r\n            (parameter\r\n                (direction in)\r\n                (parameterName (name projectId))\r\n                (typeExpression (type : (primitiveType char)))\r\n                (multiplicityRange [ (upper *) ])\r\n                (defaultValue = (expression (literal \"hogehoge001\")))) ,\r\n            (parameter\r\n                (parameterName (name data))\r\n                (typeExpression (type : Data))\r\n                (multiplicityRange\r\n                    [\r\n                        (lower (valueSpecification ( (expression (expression lowCount) - (expression (literal (integerLiteral 1)))) )))\r\n                        ..\r\n                        (upper *)\r\n                    ])\r\n                (defaultValue =\r\n                    (expression\r\n                        (expression\r\n                            (expression\r\n                                (expression getDataList)\r\n                                (arguments ( (expressionList (expression dataId) , (expression count)) )))\r\n                            .\r\n                            get)\r\n                        (arguments ( (expressionList (expression (expression Project) . number)) ))))\r\n                (paramProperties (properties { (propModifier readOnly) })))\r\n        ))\r\n    (returnType (type : Data))\r\n    (operProperties { (operProperty query) , (operProperty redefines (operName (name selectProjectDataImpl))) }))\r\n```\r\n\r\n![example_operation](https://user-images.githubusercontent.com/20200292/36794366-76f3f2fe-1ce3-11e8-9dd6-9a670f347e7a.png)\r\n\r\n\r\n\r\n# Unsupported Contents: 未対応内容\r\n\r\n構文解析機、またはそれを利用したツールの未対応内容について説明します。\r\n\r\n## 文法ファイルにおける未対応内容\r\n\r\n### 多重度の下限および上限の間に記述する範囲演算子（`'..'`）と下限または上限と間のスペース無しによる解析ミス\r\n\r\n多重度を記述する際に、`'[0..1]'`のように下限および上限と範囲演算子`'..'`の間にスペースを挿入しない場合、構文解析機が正しい構文木を生成できません。\r\nJarファイルの方を利用する場合は、文字列置換により間にスペースを挿入する（`'[0..1]' -\u003e '[0 .. 1]'`）ため、問題ありません。\r\nまた、文法ファイルのみを使う場合でも、間にスペースを挿入することで利用できます。\r\n\r\nこれはANTLR側の問題の可能性もあるため、現在対応は保留です。\r\n\r\n## 共通する未対応内容\r\n\r\n### UML2.5.1との定義文法の差異\r\n\r\nUML2.5.1では、属性および操作の定義文法が異なります。\r\n最新のバージョンでの記述法を用いることができません。\r\n影響範囲などについては検証中です。\r\n\r\n### 属性のprop-modifierおよび操作のoper-propertyとparam-propertyにおけるOCL文法\r\n\r\nOCLの文法を記述していないため、次の3つにOCLを記述しても正しい構文木を生成できません。\r\n\r\n* 属性のプロパティ (prop-modifier)\r\n* 操作のプロパティ (oper-property)\r\n* 操作のパラメータのプロパティ (param-property)\r\n\r\nただし、文字列をそのまま出力することは可能です。\r\nもしOCL文法の構文解析機があれば、そちらを利用して構文解析することをオススメします。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorichan%2Ffescue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorichan%2Ffescue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorichan%2Ffescue/lists"}