-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR: code review #1
Open
jbessi
wants to merge
122
commits into
before-pse
Choose a base branch
from
main
base: before-pse
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
122 commits
Select commit
Hold shift + click to select a range
6a51261
Add parser
PurpleAnanas 265a9bf
Add Monaco
PurpleAnanas 1475b78
Create new_parser.pegjs
PurpleAnanas 2fc0ee2
Create variables.json
PurpleAnanas 27b9df8
Create new_parser.js
PurpleAnanas a2f730c
Add files via upload
PurpleAnanas acfe21b
Create grammatik_idee
PurpleAnanas 85b1fbc
Delete Parser directory
andrinM 62f7028
Add files via upload
andrinM 3443c84
added the latest version of the peggy parser
4fa55c0
Imported the Monaco Editor
Zediwan baeb60e
Updated README.md
Zediwan 7451df9
Updated README.md
Zediwan 7ace582
Renamed the Monaco Folder
Zediwan 8312e60
Modified test file
oliolioli 15af0c8
Removed old test file
oliolioli e5e3274
Cleaned up repo /src/__test__
oliolioli 7c8b218
Deleted file
PurpleAnanas 05d8275
Moved parser to Peggy
PurpleAnanas 1b0e0c3
adapted a file
PurpleAnanas 7deeaff
Modified and adapted tests in medcodelogic.test.tsx
oliolioli cd596be
Merge branch 'main' of https://github.com/eonum/mcl-editor into main
oliolioli a678d75
file deleted
PurpleAnanas cbc8e16
Changed tests
oliolioli 190880c
Merge branch 'main' of https://github.com/eonum/mcl-editor into main
oliolioli ad67b93
changed reference
PurpleAnanas 3262e01
Merge branch 'main' of https://github.com/eonum/mcl-editor
PurpleAnanas 632816e
dummer Fehlerr korrigiert
PurpleAnanas 9256aa5
Added exports
oliolioli 5eda42b
parser erzeugt
PurpleAnanas bb3bfc2
Refactored all the element lists in the monaco editor
Zediwan ce06742
Updated tooltips for variables
Zediwan 233a732
Added a few helpfull links to the README
Zediwan c43f071
Deleted deprecated infoParser.js
Zediwan 3216513
Added comments
Zediwan 8f68700
Removed the old ReadMe and moved the contents into README
Zediwan 294a04b
Updated README
Zediwan 742a0b6
Added functions to export, to test
oliolioli f2f3b6d
Merged READMEs
oliolioli 1a7d304
test for new branch
b60873e
fixed bugs
PurpleAnanas cbc0177
Merge branch 'main' of https://github.com/eonum/mcl-editor
PurpleAnanas e0c0e7c
merged Peggy and Monaco, cleaned up repo
bd4319a
added error report, added testcases
b42b12b
Removed an empty line
Zediwan fa5ad7b
Merge branch 'main' into AndrinBranch
andrinM ccd023d
Merge pull request #12 from eonum/AndrinBranch
andrinM d26945f
Errors are now being shown
Zediwan d8790af
A Submit button is implemented, that is pressable if no error is thrown
Zediwan 5db82a8
Updated README
Zediwan 2cd6185
Added documentation to the parseInput method
Zediwan 813a90e
Bugfix in the parseInput method
Zediwan a1e1626
Added inline documentation for checkContent
Zediwan a8aaf15
Added documentation to the checkContent
Zediwan 21e9f3b
Merge branch 'main' into master
Zediwan 6dd9b2f
Merge pull request #15 from eonum/master
Zediwan b483410
isInTable() update, rule inList updated
8b3b436
isInTable() update, rule inList updated
0b036e3
updated file bundle.js for in table and in list function
4c17e54
updated in list and in table function
372bbcd
Merge pull request #16 from eonum/AndrinBranche
andrinM 3b611c7
added ''for date and removed '' in code
3e7db5f
Fixed the "error not defined" bug
Zediwan 11a62bb
Fixed a bug where documentation was being loaded for undocumentet ele…
Zediwan 7d69970
extracted functions from the grammar
2f1ada8
implemented correct colors
DavidRichardGit 1ccbd97
added empty functions.test.js file
e2bda7b
Added default test in new functions.test.js
oliolioli ae69bdd
Cleaned directory
oliolioli 1bad1db
Added and changed tests
oliolioli 4513b5e
Fixed broken merged Readme
oliolioli e06b94f
Tried to get several tests running
oliolioli 5062f84
Commented functions.js
oliolioli bccdd1b
Typos
oliolioli 2e45d47
Added function tests
oliolioli cd59bbe
Added function tests
oliolioli 53d8f9f
Added tests to test the functions in functions.js, variables in
oliolioli ab68e8b
accepted README changes
623fba7
restore .gitgnore, remove files & folders stated in .gitignore
jbessi 302045d
Changed Variable names to match conventions
Zediwan 36efe19
Removed minimap
Zediwan 54ce3a0
Improved function loading in code editor
Zediwan 24d09f9
Improved readabillity of completionItemProvider
Zediwan e983a71
Improved readabillity of hoverProvider
Zediwan 02598cc
Tooltips now show translation and documentation
Zediwan 58e95ab
Deleted Links
Zediwan 8a038a3
Deleted Depricated Test.js
Zediwan 99c4f15
yarn.lock file
jbessi f525dd2
Merge branch 'main' of github.com:eonum/mcl-editor
jbessi fce06ac
Merge branch 'main' into AndrinBranche
andrinM 6510567
Merge pull request #35 from eonum/AndrinBranche
andrinM d01ece9
Submit Button now displays error message
Zediwan 958b572
Removed decorative element on the right of the editor
Zediwan cf05480
Readded gitignore
oliolioli 277f246
Added jest
oliolioli 9f87109
Added jest
oliolioli 64377ef
Refactored and improved the checkContent method
Zediwan 5b498bf
added documentation for functions.js
5f6886b
Merge branch 'main' of https://github.com/eonum/mcl-editor
0c2dc38
Refactored Eventelistener to sumbit button and checkContent method
Zediwan 85fa333
Referenced issue in todo
Zediwan 0d34669
updated hover-tooltips to only show for exact matches
Zediwan b11ae53
Updated Operators supported by the editor
Zediwan 9b1ab39
Removed Type Keywords
Zediwan e02e18e
updated signature of inlist and intable
Zediwan 2ee45c5
Completion Items are now presented if they contain the substring
Zediwan e410625
Improved insertion of functions to show variables
Zediwan 912e7cd
Added detail, documentation to keywords
Zediwan fcd126d
Removed deprecated method markErrors
Zediwan cec6cd8
updated README parser section)
725497a
bugfixes
DavidRichardGit 7cb2146
visual enhancements
DavidRichardGit 1221b70
Cleaned up comments and worked on tests
oliolioli d54c7b8
Added and reangered tests
oliolioli b6611c7
Rearranged README
oliolioli ae0bb84
Rearranged README
oliolioli 5800a2b
Added Testkonzept
oliolioli 3f02757
update Grammar
PurpleAnanas f07aa65
Merge branch 'main' of https://github.com/eonum/mcl-editor
PurpleAnanas 85cf50f
Update setup
DavidRichardGit b7afe78
updated README
724158f
Update testkonzept.md
oliolioli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"liveServer.settings.port": 5501 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,54 @@ | ||
# README Medcodelogic Editor | ||
|
||
## Brief description | ||
This medcodelogic parser is based on **Peggy** (https://github.com/peggyjs/peggy), a javascript parser. The frontend is made with codeeditor **Monaco** (https://microsoft.github.io/monaco-editor/monarch.html). | ||
|
||
The parser is generated by Peggy, based on a grammar. The current medcodelogic grammar rules are to be found in **medcodelogic.pegjs**. | ||
Based on this rules the parser can be generated using the following commands (make sure peggy is installed globally): | ||
|
||
## Parsing with Peggy ## | ||
Create the parser.js from your grammar: | ||
|
||
`$peggy medcodelogic.pegjs` | ||
|
||
### Testing peggy locally ### | ||
Parsing with Peggy can be tested locally without further installation: | ||
|
||
`$peggy -test foo` | ||
|
||
Actually the two peggy components are to be found in /src/: | ||
- **medcodelogic.js** (the generated parser) | ||
- **medcodelogic.pegjs** (the grammar) | ||
|
||
## Testing with jest ## | ||
This project uses **jest** (https://jestjs.io) for testing. All test-suites reside in their own subdirectory in `/src/__test_`. | ||
|
||
There exists two scripts, found under: /src/__test__/ | ||
- **medcodelogic.test.js** (tests the parsing functions) | ||
- **functions.test.js** (tests the imports from tables.json and variables.json) | ||
|
||
These test scripts can be run easily as follows: | ||
|
||
`yarn test` or individually using `yarn test /src/__test__/functions.test.js` | ||
|
||
|
||
## Frontend / GUI ## | ||
The current HTML file takes a string as input, hands it over to the parser. The returned output is either a string (when parsed successfully) or an exception with an error warning. | ||
|
||
The generated parser can be used as an object in JS. But for use in the browser we had to bundle it. Therefore we used Webpack. All the necessary configurations are to be found in the webpack.config.js. | ||
If you want to use the function .parse from the bundled file (bundle.js) use Parser.parse(). We only use the .parse() function. This function is exported (see webpack.config.js). | ||
The script for the bundle (the actual parser) needs to be initialized in main.html _before_ the loader of code editor Monaco. | ||
|
||
If you change something in the grammar (medcodelogic.pegjs) run `peggy src/Peggy/medcodelogic.pegjs` after your changes. This will generate a new parser (medcodelogic.js). Then use `yarn run build` to bundle the parser. Make sure to delete the old bundle.js file in the Monaco directory and replace the newly generated bundle.js file in the folder "/Monaco". | ||
|
||
Alternativlely you can run **src/deploy.sh** to execute both the peggy and the build command. | ||
|
||
|
||
### Submit the parsed result / further integration ### | ||
The submit button is disabled as long as there is no content or an error. Pressing the submit button will log the valid content into the console. | ||
|
||
|
||
## Libraries | ||
- Peggy for parser (use typescript) https://github.com/peggyjs/peggy. | ||
- Codemirror https://codemirror.net/ or Monaco editor https://microsoft.github.io/monaco-editor/. | ||
- Integrate Editor in react app (using typescript). | ||
- Bootstrap for styling. | ||
|
||
## Coding conventions / requirements | ||
|
@@ -14,32 +57,52 @@ | |
- Compile time constants (not keyword const) are always uppercase. | ||
- All components reside in their own subdirectory in `/src/Components`. | ||
- All services reside in their own subdirectory in `/src/Services`. | ||
- All test-suites reside in their own subdirectory in `/src/__test_`. | ||
- Every method has its own documentation written in Javadoc. | ||
- Write everything in English (comments, variable names, function names, ...). | ||
- Use self declaring code (f.e. method & variable names). | ||
|
||
## Setup | ||
### Monaco Editor | ||
|
||
Running the `/Monaco/main.html` requires the "live server" extension. | ||
#### Live Server Installation | ||
Open VSCode and type in `live server` in the extension search bar (Ctrl + Shift + X) and click install. | ||
|
||
Alternatively: | ||
Open VSCode, type ctrl+P, and then type: | ||
`ext install ritwickdey.liveserver` | ||
|
||
After Installation right click the main.html file and select `Open with Live Server` to run it. | ||
|
||
### Development | ||
Use `yarn` command to install all packages and dependencies from package.json. | ||
Use `yarn start` to start local dev server. | ||
### Production | ||
|
||
### Testing | ||
We use jest and puppeteer for our tests. Since we use typescript, we also need babel for transformation. | ||
#### Prerequisites | ||
You should be good to go after running `yarn`. | ||
#### Config | ||
All the configuration for jest, puppeteer and babel are specified in the files jest.config.js, jest-puppeteer.config.js | ||
and babel.config.js in the root folder and can be adapted to your needs. Since we do UI tests, we need a running server. | ||
This is implemented via jest-puppeteer config file server block `server: { command: "yarn run startHeadlessTestPort"}` and | ||
corresponding scripts in package.json | ||
`"test": "jest --runInBand"` and `"startHeadlessOnTestPort": "BROWSER=none PORT=$npm_package_config_testPort yarn start"`. | ||
#### Run tests | ||
Use `yarn test` to start headless server and tests. You can also just test single suites using | ||
`yarn test /path/to/test/file`. Currently the port is set to `localhost:8080` in package.json. | ||
|
||
|
||
## Contact | ||
For further question: | ||
- [[email protected]]([email protected]) -> eonum contact | ||
- [eonum.ch/de/kontakt/](https://eonum.ch/de/kontakt/) -> eonum website | ||
|
||
## Monaco | ||
- See [this](https://microsoft.github.io/monaco-editor/typedoc/enums/languages.CompletionItemKind.html) for additional information about the CompletionItemKind | ||
- See [this](https://microsoft.github.io/monaco-editor/typedoc/interfaces/languages.CompletionItem.html#documentation) for additional information about CompletionItems | ||
|
||
|
||
## Some theory: Parsing Expression Grammar (PEG) ## | ||
PEG (Parsing Expression Grammar)**: In computer science, a parsing expression grammar (PEG) is a type of analytic formal grammar, i.e. it describes a formal language in terms of a set of rules for recognizing strings in the language. https://en.wikipedia.org/wiki/Parsing_expression_grammar | ||
|
||
- Each parsing function conceptually takes an **input string as its argument**, and yields one of the following results: | ||
**success**, in which the function may optionally move forward or consume one or more characters of the input string supplied to it, or | ||
**failure**, in which case no input is consumed. | ||
- The fundamental difference between context-free grammars and parsing expression grammars is that the **PEG's choice operator is ordered**. If the first alternative succeeds, the second alternative is ignored. | ||
|
||
Some good tutorials are to be found here: | ||
- Beginning to parse with Peggy https://coderwall.com/p/316gba/beginning-parsers-with-peg-js (easy beginner tutorial for simple grammar) | ||
- Some simple grammar examples: https://tomassetti.me/a-peggy-js-tutorial/ | ||
- Some good examples of simple grammar rules: https://peggyjs.org/documentation.html#grammar-syntax-and-semantics | ||
|
||
To start or to test simple grammar, you can start online in the following parsing sandbox: https://peggyjs.org/ |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a section under Setup for Monaco-Editor and again a Monaco section here?