{"id":16701167,"url":"https://github.com/arnobl/dsl-demo","last_synced_at":"2025-04-05T04:17:29.877Z","repository":{"id":48871044,"uuid":"315281824","full_name":"arnobl/DSL-demo","owner":"arnobl","description":null,"archived":false,"fork":false,"pushed_at":"2021-12-03T07:34:56.000Z","size":71,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-10T12:16:49.170Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arnobl.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":"2020-11-23T10:40:49.000Z","updated_at":"2021-12-03T07:34:59.000Z","dependencies_parsed_at":"2022-09-06T21:40:33.148Z","dependency_job_id":null,"html_url":"https://github.com/arnobl/DSL-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobl%2FDSL-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobl%2FDSL-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobl%2FDSL-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobl%2FDSL-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnobl","download_url":"https://codeload.github.com/arnobl/DSL-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284956,"owners_count":20913704,"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","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":[],"created_at":"2024-10-12T18:29:17.822Z","updated_at":"2025-04-05T04:17:29.426Z","avatar_url":"https://github.com/arnobl.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Xtext in practices\n\nThis language defines arithmetical expressions (prefix notation) that can use constant values.\nExample:\n```\nval foo := 1\nval bar := 2\n\n+ 1 * bar bar\n```\n\n\nThe grammar is here:\n\n[`fr.insa.exp/src/fr/insa/exp/Exp.xtext`](/fr.insa.exp/src/fr/insa/exp/Exp.xtext)\n\nThe validator that checks the arithmetical expression is correct is here:\n\n[`fr.insa.exp/src/fr/insa/exp/validation/ExpValidator.java`](/fr.insa.exp/src/fr/insa/exp/validation/ExpValidator.java)\n\nThe generator that writes in a file the result of the expression:\n\n[`fr.insa.exp/src/fr/insa/exp/generator/ExpGenerator.xtend`](/fr.insa.exp/src/fr/insa/exp/generator/ExpGenerator.xtend)\n\nThe unit tests that test the grammar:\n\n[`fr.insa.exp.tests/src/fr/insa/exp/tests/ExpParsingTest.xtend`](/fr.insa.exp.tests/src/fr/insa/exp/tests/ExpParsingTest.xtend)\n\nThe customised outline:\n\n[`fr.insa.exp.ui/src/fr/insa/exp/ui/outline/ExpOutlineTreeProvider.java`](/fr.insa.exp.ui/src/fr/insa/exp/ui/outline/ExpOutlineTreeProvider.java)\n\nThe quick-fix features:\n\n[`fr.insa.exp.ui/src/fr/insa/exp/ui/quickfix/ExpQuickfixProvider.java`](/fr.insa.exp.ui/src/fr/insa/exp/ui/quickfix/ExpQuickfixProvider.java)\n\nThe content assist features:\n\n[`fr.insa.exp.ui/src/fr/insa/exp/ui/contentassist/ExpProposalProvider.java`](/fr.insa.exp.ui/src/fr/insa/exp/ui/contentassist/ExpProposalProvider.java)\n\nSetting the keywords colour:\n\n[`fr.insa.exp.ui/src/fr/insa/exp/ui/ExpUiModule.java`](/fr.insa.exp.ui/src/fr/insa/exp/ui/ExpUiModule.java)\n\n[`fr.insa.exp.ui/src/fr/insa/exp/ui/coloring/ExpHighlightingConfiguration.java`](/fr.insa.exp.ui/src/fr/insa/exp/ui/coloring/ExpHighlightingConfiguration.java) (to create)\n\nSemantic highlighting:\n\n[`fr.insa.exp.ui/src/fr/insa/exp/ui/ExpUiModule.java`](/fr.insa.exp.ui/src/fr/insa/exp/ui/ExpUiModule.java)\n\n[`fr.insa.exp.ui/src/fr/insa/exp/ui/coloring/ExpSemanticHighlightingCalculator.java`](/fr.insa.exp.ui/src/fr/insa/exp/ui/coloring/ExpSemanticHighlightingCalculator.java) (to create)\n\n[`fr.insa.exp.ui/src/fr/insa/exp/ui/coloring/ExpHighlightingConfiguration.java`](/fr.insa.exp.ui/src/fr/insa/exp/ui/coloring/ExpHighlightingConfiguration.java)\n\n\nManual cross-reference (scoping):\n\n[`fr.insa.exp/src/fr/insa/exp/scoping/ExpScopeProvider.java`](/fr.insa.exp/src/fr/insa/exp/scoping/ExpScopeProvider.java)\n\n\n\n# Tips and tricks\n\n## How to access the root object of my model?\n\n```java\nEObject rootElement = EcoreUtil2.getRootContainer(myModelElement);\n```\n\n\n## How to get all the instances of a given type contained in my model?\n\n```java\n// Getting the root of the model\nEObject rootElement = EcoreUtil2.getRootContainer(myModelElement);\n// Getting all the instances of MyModelObjectType in the model\nList\u003cMyModelObjectType\u003e objects = EcoreUtil2.getAllContentsOfType(rootElement, MyModelObjectType.class);\n```\n\n## Why my Xtext grammar rule does not generate a class?\n\n`MyRule: 'mytoken';`\n\nIn this example Xtext optimises the grammar: since `MyRule` contains tokens only (ie no rule access), it considers `MyRule` as a terminal (ie a lexer rule) and does not create a class `MyRule`.\n\nTo force the class creation, you have to write that:\n\n`MyRule: {MyRule} 'mytoken';`\n\nThis precises the name of the class to instantiate (this class does not exist yet, it is Xtext that generates it in the `src-gen` folder).\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnobl%2Fdsl-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnobl%2Fdsl-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnobl%2Fdsl-demo/lists"}