Skip to content
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
wants to merge 122 commits into
base: before-pse
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
6a51261
Add parser
PurpleAnanas Apr 3, 2023
265a9bf
Add Monaco
PurpleAnanas Apr 3, 2023
1475b78
Create new_parser.pegjs
PurpleAnanas Apr 30, 2023
2fc0ee2
Create variables.json
PurpleAnanas Apr 30, 2023
27b9df8
Create new_parser.js
PurpleAnanas Apr 30, 2023
a2f730c
Add files via upload
PurpleAnanas Apr 30, 2023
acfe21b
Create grammatik_idee
PurpleAnanas Apr 30, 2023
85b1fbc
Delete Parser directory
andrinM May 3, 2023
62f7028
Add files via upload
andrinM May 3, 2023
3443c84
added the latest version of the peggy parser
May 3, 2023
4fa55c0
Imported the Monaco Editor
Zediwan May 3, 2023
baeb60e
Updated README.md
Zediwan May 3, 2023
7451df9
Updated README.md
Zediwan May 3, 2023
7ace582
Renamed the Monaco Folder
Zediwan May 3, 2023
8312e60
Modified test file
oliolioli May 3, 2023
15af0c8
Removed old test file
oliolioli May 3, 2023
e5e3274
Cleaned up repo /src/__test__
oliolioli May 3, 2023
7c8b218
Deleted file
PurpleAnanas May 3, 2023
05d8275
Moved parser to Peggy
PurpleAnanas May 3, 2023
1b0e0c3
adapted a file
PurpleAnanas May 3, 2023
7deeaff
Modified and adapted tests in medcodelogic.test.tsx
oliolioli May 3, 2023
cd596be
Merge branch 'main' of https://github.com/eonum/mcl-editor into main
oliolioli May 3, 2023
a678d75
file deleted
PurpleAnanas May 3, 2023
cbc8e16
Changed tests
oliolioli May 3, 2023
190880c
Merge branch 'main' of https://github.com/eonum/mcl-editor into main
oliolioli May 3, 2023
ad67b93
changed reference
PurpleAnanas May 3, 2023
3262e01
Merge branch 'main' of https://github.com/eonum/mcl-editor
PurpleAnanas May 3, 2023
632816e
dummer Fehlerr korrigiert
PurpleAnanas May 3, 2023
9256aa5
Added exports
oliolioli May 3, 2023
5eda42b
parser erzeugt
PurpleAnanas May 3, 2023
bb3bfc2
Refactored all the element lists in the monaco editor
Zediwan May 3, 2023
ce06742
Updated tooltips for variables
Zediwan May 3, 2023
233a732
Added a few helpfull links to the README
Zediwan May 3, 2023
c43f071
Deleted deprecated infoParser.js
Zediwan May 3, 2023
3216513
Added comments
Zediwan May 3, 2023
8f68700
Removed the old ReadMe and moved the contents into README
Zediwan May 5, 2023
294a04b
Updated README
Zediwan May 5, 2023
742a0b6
Added functions to export, to test
oliolioli May 8, 2023
f2f3b6d
Merged READMEs
oliolioli May 8, 2023
1a7d304
test for new branch
May 8, 2023
b60873e
fixed bugs
PurpleAnanas May 8, 2023
cbc0177
Merge branch 'main' of https://github.com/eonum/mcl-editor
PurpleAnanas May 8, 2023
e0c0e7c
merged Peggy and Monaco, cleaned up repo
May 9, 2023
bd4319a
added error report, added testcases
May 9, 2023
b42b12b
Removed an empty line
Zediwan May 9, 2023
fa5ad7b
Merge branch 'main' into AndrinBranch
andrinM May 9, 2023
ccd023d
Merge pull request #12 from eonum/AndrinBranch
andrinM May 9, 2023
d26945f
Errors are now being shown
Zediwan May 9, 2023
d8790af
A Submit button is implemented, that is pressable if no error is thrown
Zediwan May 9, 2023
5db82a8
Updated README
Zediwan May 9, 2023
2cd6185
Added documentation to the parseInput method
Zediwan May 9, 2023
813a90e
Bugfix in the parseInput method
Zediwan May 9, 2023
a1e1626
Added inline documentation for checkContent
Zediwan May 9, 2023
a8aaf15
Added documentation to the checkContent
Zediwan May 9, 2023
21e9f3b
Merge branch 'main' into master
Zediwan May 9, 2023
6dd9b2f
Merge pull request #15 from eonum/master
Zediwan May 9, 2023
b483410
isInTable() update, rule inList updated
May 9, 2023
8b3b436
isInTable() update, rule inList updated
May 9, 2023
0b036e3
updated file bundle.js for in table and in list function
May 10, 2023
4c17e54
updated in list and in table function
May 10, 2023
372bbcd
Merge pull request #16 from eonum/AndrinBranche
andrinM May 10, 2023
3b611c7
added ''for date and removed '' in code
May 10, 2023
3e7db5f
Fixed the "error not defined" bug
Zediwan May 10, 2023
11a62bb
Fixed a bug where documentation was being loaded for undocumentet ele…
Zediwan May 10, 2023
7d69970
extracted functions from the grammar
May 10, 2023
2f1ada8
implemented correct colors
DavidRichardGit May 10, 2023
1ccbd97
added empty functions.test.js file
May 10, 2023
e2bda7b
Added default test in new functions.test.js
oliolioli May 10, 2023
ae69bdd
Cleaned directory
oliolioli May 10, 2023
1bad1db
Added and changed tests
oliolioli May 10, 2023
4513b5e
Fixed broken merged Readme
oliolioli May 10, 2023
e06b94f
Tried to get several tests running
oliolioli May 10, 2023
5062f84
Commented functions.js
oliolioli May 10, 2023
bccdd1b
Typos
oliolioli May 10, 2023
2e45d47
Added function tests
oliolioli May 10, 2023
cd59bbe
Added function tests
oliolioli May 10, 2023
53d8f9f
Added tests to test the functions in functions.js, variables in
oliolioli May 10, 2023
ab68e8b
accepted README changes
May 14, 2023
623fba7
restore .gitgnore, remove files & folders stated in .gitignore
jbessi May 15, 2023
302045d
Changed Variable names to match conventions
Zediwan May 15, 2023
36efe19
Removed minimap
Zediwan May 15, 2023
54ce3a0
Improved function loading in code editor
Zediwan May 16, 2023
24d09f9
Improved readabillity of completionItemProvider
Zediwan May 16, 2023
e983a71
Improved readabillity of hoverProvider
Zediwan May 16, 2023
02598cc
Tooltips now show translation and documentation
Zediwan May 16, 2023
58e95ab
Deleted Links
Zediwan May 17, 2023
8a038a3
Deleted Depricated Test.js
Zediwan May 17, 2023
99c4f15
yarn.lock file
jbessi May 17, 2023
f525dd2
Merge branch 'main' of github.com:eonum/mcl-editor
jbessi May 17, 2023
fce06ac
Merge branch 'main' into AndrinBranche
andrinM May 17, 2023
6510567
Merge pull request #35 from eonum/AndrinBranche
andrinM May 17, 2023
d01ece9
Submit Button now displays error message
Zediwan May 17, 2023
958b572
Removed decorative element on the right of the editor
Zediwan May 17, 2023
cf05480
Readded gitignore
oliolioli May 17, 2023
277f246
Added jest
oliolioli May 17, 2023
9f87109
Added jest
oliolioli May 17, 2023
64377ef
Refactored and improved the checkContent method
Zediwan May 17, 2023
5b498bf
added documentation for functions.js
May 17, 2023
5f6886b
Merge branch 'main' of https://github.com/eonum/mcl-editor
May 17, 2023
0c2dc38
Refactored Eventelistener to sumbit button and checkContent method
Zediwan May 17, 2023
85fa333
Referenced issue in todo
Zediwan May 18, 2023
0d34669
updated hover-tooltips to only show for exact matches
Zediwan May 18, 2023
b11ae53
Updated Operators supported by the editor
Zediwan May 18, 2023
9b1ab39
Removed Type Keywords
Zediwan May 18, 2023
e02e18e
updated signature of inlist and intable
Zediwan May 18, 2023
2ee45c5
Completion Items are now presented if they contain the substring
Zediwan May 18, 2023
e410625
Improved insertion of functions to show variables
Zediwan May 18, 2023
912e7cd
Added detail, documentation to keywords
Zediwan May 19, 2023
fcd126d
Removed deprecated method markErrors
Zediwan May 19, 2023
cec6cd8
updated README parser section)
May 20, 2023
725497a
bugfixes
DavidRichardGit May 21, 2023
7cb2146
visual enhancements
DavidRichardGit May 21, 2023
1221b70
Cleaned up comments and worked on tests
oliolioli May 21, 2023
d54c7b8
Added and reangered tests
oliolioli May 21, 2023
b6611c7
Rearranged README
oliolioli May 21, 2023
ae0bb84
Rearranged README
oliolioli May 21, 2023
5800a2b
Added Testkonzept
oliolioli May 21, 2023
3f02757
update Grammar
PurpleAnanas May 22, 2023
f07aa65
Merge branch 'main' of https://github.com/eonum/mcl-editor
PurpleAnanas May 22, 2023
85cf50f
Update setup
DavidRichardGit May 23, 2023
b7afe78
updated README
May 30, 2023
724158f
Update testkonzept.md
oliolioli Feb 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

95 changes: 79 additions & 16 deletions README.md
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
Expand All @@ -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
Copy link
Collaborator Author

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?

- 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/
6 changes: 0 additions & 6 deletions babel.config.js

This file was deleted.

Loading