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

[UI] Adds CodeMirror as editor #4479

Merged
merged 133 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
4b1f83d
add code mirror and themes
jpelay Sep 7, 2023
b528d6a
read only editors set up to be ace editor
jpelay Sep 11, 2023
88ddd96
advances in changing the editor height
jpelay Sep 12, 2023
ee38836
add todo comment
jpelay Sep 12, 2023
1b0f129
resizing the editor
jpelay Sep 12, 2023
363abb5
add some more functions
jpelay Sep 13, 2023
853a909
adds clearSelection method
jpelay Sep 13, 2023
ee91c10
adds event listener function
jpelay Sep 13, 2023
37f9b27
add trim trailing whitespace function again
jpelay Sep 13, 2023
81f3c76
functions for setting the contents and read mode of the editor
jpelay Sep 13, 2023
5b36a4e
adds remove trailing whitespace function
jpelay Sep 13, 2023
5ce010d
adding direction in the style of Code Mirror parent element
jpelay Sep 13, 2023
c0c66a8
Merge branch 'main' of github.com:hedyorg/hedy into add-codemirror
jpelay Sep 15, 2023
56bbac0
Merge branch 'main' of github.com:hedyorg/hedy into add-codemirror
jpelay Sep 20, 2023
9b92b19
adds stubble of markers functions
jpelay Sep 19, 2023
dd9d44b
adds highlight error functionality
jpelay Sep 20, 2023
5f9da81
change error styling and add clearErrors function
jpelay Sep 21, 2023
0ac1d73
add mark for single word
jpelay Sep 21, 2023
884ffb7
change some variable names
jpelay Sep 22, 2023
41c1fce
adding debugger decoration
jpelay Sep 22, 2023
91ee2fd
Merge branch 'main' of github.com:hedyorg/hedy into add-codemirror
jpelay Sep 25, 2023
6c131ab
move decorations to their own file
jpelay Sep 25, 2023
7440a28
add deactivate line decoration
jpelay Sep 25, 2023
ca96e00
delete unnecesary function from interface
jpelay Sep 25, 2023
f3b8b7b
use breakpoint gutter uin codemirror
jpelay Sep 25, 2023
d6cdfd0
delete unused method
jpelay Sep 25, 2023
4e66eb5
remove breakpoints from interface
jpelay Sep 28, 2023
dd9c8ac
get active contents in app.ts
jpelay Sep 28, 2023
834cd1e
add functon to get active contents in code mirror
jpelay Sep 28, 2023
2d66098
adadpt debugging file to code mirror
jpelay Sep 28, 2023
359db63
automatic js files
jpelay Sep 28, 2023
ba3cbbb
Merge branch 'main' of github.com:hedyorg/hedy into add-codemirror
jpelay Sep 28, 2023
5bfda6f
remove reference to ace range from interface
jpelay Sep 29, 2023
e9b263e
add decoration for incorrect lines in code mirror
jpelay Sep 29, 2023
e5f3e7d
fix editor not being reset to proper height
jpelay Sep 29, 2023
20f8339
automatic js files
jpelay Sep 29, 2023
1fa6ea1
adding click event to editor
jpelay Sep 29, 2023
02a2ee2
get the error given the line in skip faukty
jpelay Sep 29, 2023
0ad7371
removing unnecessary field
jpelay Sep 29, 2023
00b35d0
add event listener only for code mirror
jpelay Sep 29, 2023
17c455a
remove unused import
jpelay Sep 29, 2023
1381b50
resize editor box
jpelay Sep 29, 2023
f9d940c
fix cliking of skip faulty lines
jpelay Sep 29, 2023
d13e2f7
remove todo comment
jpelay Sep 29, 2023
f804398
add click event to ace editor too
jpelay Oct 2, 2023
83d84d9
explicitly configure code mirror
jpelay Oct 2, 2023
4d7813a
remove bracket matching configuration
jpelay Oct 2, 2023
0e22b59
remove unused imports
jpelay Oct 2, 2023
57185b7
Merge branch 'main' of github.com:hedyorg/hedy into add-codemirror
jpelay Oct 4, 2023
d9a3b78
adding syntax highlighting for level 1 english
jpelay Oct 4, 2023
e3d2352
grammar 2 work in progress
jpelay Oct 9, 2023
001454c
fixing level 2 grammar
jpelay Oct 13, 2023
801dbef
updating grammars
jpelay Oct 13, 2023
ada1923
level 5 grammar
jpelay Oct 16, 2023
32828a3
level 6 syntax highlighting
jpelay Oct 16, 2023
c5c7ddb
allowing numbers in condition
jpelay Oct 16, 2023
4ec4e4d
grammar for level 7
jpelay Oct 16, 2023
11bb1f2
add level 8 grammar
jpelay Oct 17, 2023
da05994
modigying strings for level 7
jpelay Oct 17, 2023
8e06207
level 9, 10 and 11
jpelay Oct 17, 2023
c685390
files for level 8 to 11
jpelay Oct 17, 2023
cd27523
syntax for level 12
jpelay Oct 19, 2023
4863b94
level 13 grammar
jpelay Oct 19, 2023
78613b1
temp code just to try out the parsers as i do them
jpelay Oct 19, 2023
b2add53
fixing level 13 grammar
jpelay Oct 20, 2023
70c5c9c
level 14
jpelay Oct 20, 2023
852f818
level 15 grammar
jpelay Oct 20, 2023
de215eb
level 16 grammar
jpelay Oct 20, 2023
c4a1926
level 17 grammar
jpelay Oct 20, 2023
f94a924
level 18 syntax
jpelay Oct 20, 2023
fd454c2
adding translation features to level 18
jpelay Oct 24, 2023
03f9f3b
support for switching levels
jpelay Oct 24, 2023
f18733f
level2 grammar
jpelay Oct 25, 2023
192216e
fixing level 1 grammar
jpelay Oct 25, 2023
39eaa82
fix styling for text in level 1
jpelay Oct 25, 2023
fca8eef
now we can extend and specialze keywords
jpelay Oct 25, 2023
a480e86
fixing level 2 grammar
jpelay Oct 25, 2023
7deba90
level 3 grammar
jpelay Nov 6, 2023
141e3f6
language 4 grammar
jpelay Nov 6, 2023
02d1367
level 5
jpelay Nov 7, 2023
08ffff3
level 6 grammar
jpelay Nov 7, 2023
1d440f8
level 7 grammar
jpelay Nov 7, 2023
5f947e9
level 7 grammar
jpelay Nov 7, 2023
c82c6c4
level 8 parser
jpelay Nov 7, 2023
e134efd
level 11 grammar
jpelay Nov 7, 2023
e54fd31
level 11 grammar
jpelay Nov 7, 2023
5d7e825
level 12
jpelay Nov 7, 2023
c13476d
level 13
jpelay Nov 7, 2023
1dc6651
level 14
jpelay Nov 7, 2023
53400d8
level 15
jpelay Nov 7, 2023
c08b115
level 16 and 17
jpelay Nov 7, 2023
cfe62f3
proper generation of typescript
jpelay Nov 7, 2023
6c85418
Merge branch 'main' of github.com:hedyorg/hedy into add-codemirror
jpelay Nov 7, 2023
d2b2f2d
Update app.ts
jpelay Nov 7, 2023
a8655a3
adding monokai theme
jpelay Nov 8, 2023
6751289
fix error with call
jpelay Nov 8, 2023
90414b6
Merge branch 'main' of github.com:hedyorg/hedy into add-codemirror
jpelay Nov 8, 2023
d951e60
properly handle decorations for partial debug lines
jpelay Nov 8, 2023
c9c854c
adapt try button test to code mirror
jpelay Nov 8, 2023
49c2991
more tests
jpelay Nov 8, 2023
9be3619
debugger tests
jpelay Nov 9, 2023
fbd3135
Update debugger.cy.js
jpelay Nov 9, 2023
5e4bc54
editor box and language drowpdown tests
jpelay Nov 9, 2023
c6497e0
Update syntax_highlighting.cy.js
jpelay Nov 9, 2023
d7e1917
programs page test
jpelay Nov 9, 2023
fd1fc12
script to generate grammars
jpelay Nov 9, 2023
b301e63
fixes level 2 grammar and adds level 9 grammar
jpelay Nov 9, 2023
0fa4d12
removing debug console logs
jpelay Nov 9, 2023
4270e05
decoration for placehodler
jpelay Nov 10, 2023
e816ef0
better bash script for generating grammars
jpelay Nov 13, 2023
327a549
remove todo comment
jpelay Nov 13, 2023
f4c94fd
method for skip faulty handler
jpelay Nov 13, 2023
31c814a
remove console logs
jpelay Nov 13, 2023
b47089a
ace editor 1-indexed
jpelay Nov 13, 2023
b88e113
proper tag type
jpelay Nov 13, 2023
1267e5a
reduce repetion of style tags
jpelay Nov 13, 2023
ba4d244
remove unused interface
jpelay Nov 13, 2023
100fff3
remove console log
jpelay Nov 13, 2023
539e6b7
automatically generated parsers
jpelay Nov 13, 2023
1366e85
Merge branch 'main' into add-codemirror
jpelay Nov 13, 2023
ad45da3
fix int not being highlighted
jpelay Nov 13, 2023
083447a
Merge branch 'add-codemirror' of github.com:jpelay/hedy into add-code…
jpelay Nov 13, 2023
971081c
test for level 1 parser
jpelay Nov 14, 2023
9cb0b70
Implement multi level tester
jpelay Nov 14, 2023
49d3277
fix single level tester
jpelay Nov 14, 2023
99594be
Merge branch 'main' of github.com:hedyorg/hedy into add-codemirror
jpelay Nov 14, 2023
7008d64
improve redabilty of level 1 tester and fix error tests
jpelay Nov 14, 2023
1725bca
tests level 2 and stub of level 6
jpelay Nov 14, 2023
bfc4e33
rename files
jpelay Nov 14, 2023
b3d647c
adding default value for language in tester
jpelay Nov 14, 2023
e52d943
error test for level 2
jpelay Nov 14, 2023
78186af
fix to list
jpelay Nov 14, 2023
588a610
level 3 tests
jpelay Nov 14, 2023
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 build-tools/heroku/generate-grammars-and-js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ python3 ../../content/yaml_to_lark_utils.py
echo '-----> Creating python prefixes for TypeScript'
./generate-prefixes-ts

echo '-----> Generating the lezer parsers'
./generate-lezer-parsers

echo '-----> Compiling TypeScript'
./generate-typescript
9 changes: 9 additions & 0 deletions build-tools/heroku/generate-lezer-parsers
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -eu

# Generate the lezer parsers from the grammars specified in highlighting/lezer-grammars/
for grammarFile in ../../highlighting/lezer-grammars/level*.grammar ; do
baseName=$(basename "$grammarFile")
tsFile=${baseName%.grammar}-parser.ts
npx lezer-generator --typeScript "$grammarFile" -o ../../static/js/lezer-parsers/$tsFile
done
34 changes: 34 additions & 0 deletions highlighting/lezer-grammars/level1.grammar
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@top Program { eol* (Command eol+)* Command? }
Command {
Print | Ask | Echo | Turtle | ErrorInvalid
}
Print { print+ Text+ }
Ask { ask+ Text+ }
Echo { echo+ Text* }

Turtle[@isGroup=turtle] {
Forward { forward+ Text } |
Turn { turn+ Text } |
Color { color+ Text }
}

ErrorInvalid[@dynamicPrecedence=-10] { Text+ }

@external extend { Text } extendKeyword from "./tokens" {
print[@name="print"],
forward[@name="forward"],
turn[@name="turn"],
echo[@name="echo"],
ask[@name="ask"],
color[@name="color"]
}


@tokens {
Comment { "#" ![\n]* }
eol { "\n" }
space { " " }
Text { ![\n #]+ }
}

@skip { Comment | space }
118 changes: 118 additions & 0 deletions highlighting/lezer-grammars/level10.grammar
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
@top Program { eol* (Command eol+)* Command? }
Command {
Assign | AssignList | Ask | Clear |Print | Turtle | Sleep | Add | Remove| If | Else | Repeat | For | ErrorInvalid
}

@local tokens {
singleQuoteStringEnd { "'" | "\n" }
@else singleQuoteStringContent
}

@skip {} {
singleQuotedString { "'" (singleQuoteStringContent)* singleQuoteStringEnd }
}

@local tokens {
doubleQuoteStringEnd { '"' | "\n" }
@else doubleQuoteStringContent
}

@skip {} {
doubleQuotedString { '"' (doubleQuoteStringContent)* doubleQuoteStringEnd }
}

String { doubleQuotedString | singleQuotedString }

Print { print ( String | ListAccess | Expression )+ }
Ask { Text (is+ | Op<"=">) ask+ ( String | ListAccess | Expression )+ }

AssignList { Text (is+ | Op<"=">) (Text+ | Int ) ~ambig (Comma (Text+ | Int ))+ } // comma doesn't really parse well if it is not separated by spaces
Assign { Text (is+ | Op<"=">) (Expression ~ambig | ListAccess)+ }
Sleep { sleep+ (Expression | ListAccess )? }
ListAccess { Text at+ (random+ | Text) }
Add { add+ Text toList+ Text }
Remove { remove+ Text from+ Text }
Clear { clear+ }

Turtle[@isGroup=turtle] {
Forward { forward+ (Expression | ListAccess ) } |
Turn { turn+ (Expression | ListAccess ) } |
Color { color+ (Expression | ListAccess) }
}

If { ifs+ Condition }
Else { elses+ }

Condition {
EqualityCheck { Text is+ (String | Expression | pressed+) } |
InListCheck { Text ins+ Text } |
NotInListCheck { Text not_in+ Text }
}

Repeat { repeat+ (Int | Text) times+ }

For { fors+ Text ins+ Text }

ErrorInvalid[@dynamicPrecedence=-10] { Text+ }

Op<expr> { expr }

binaryExpression {
Expression !times Op<"*" | "/"> Expression |
Expression !plus Op<"+" | "-"> Expression
}

Expression {
Int |
Text |
binaryExpression
}

@precedence {
times @left,
plus @right
}

@external specialize { Text } specializeKeyword from "./tokens" {
ask[@name="ask"],
at[@name="at"],
random[@name="random"],
ifs[@name="if"],
pressed[@name="pressed"],
elses[@name="else"]
}

@external extend { Text } extendKeyword from "./tokens" {
print[@name="print"],
forward[@name="forward"],
turn[@name="turn"],
color[@name="color"],
sleep[@name="sleep"],
is[@name="is"],
add[@name="add"],
from[@name="from"],
remove[@name="remove"],
toList[@name="toList"],
clear[@name="clear"],
ins[@name="in"],
not_in[@name="not_in"],
repeat[@name="repeat"],
times[@name="times"],
fors[@name="for"]
}

@tokens {
@precedence {
Int,
Text
}
Comment { "#" ![\n]* }
eol { "\n" }
Comma { $[,،,、] } // every language comma is valid here
Text { ![^\n,،,、 '"#+\-*/=]+ } // a little bit of a hack not to parse commas never, but lezer adds them as error nodes, so it still
space { " " }
digit { $[٠١٢٣٤٥٦٧٨٩۰۱۲۳۴۵۶۷۸۹0123456789] } // latin, arab and pa_PK (Panjabi) scripts
Int { digit+ }
}

@skip { Comment | space }
120 changes: 120 additions & 0 deletions highlighting/lezer-grammars/level11.grammar
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
@top Program { eol* (Command eol+)* Command? }
Command {
Assign | AssignList | Ask | Clear |Print | Turtle | Sleep | Add | Remove| If | Else | Repeat | For | ErrorInvalid
}

@local tokens {
singleQuoteStringEnd { "'" | "\n" }
@else singleQuoteStringContent
}

@skip {} {
singleQuotedString { "'" (singleQuoteStringContent)* singleQuoteStringEnd }
}

@local tokens {
doubleQuoteStringEnd { '"' | "\n" }
@else doubleQuoteStringContent
}

@skip {} {
doubleQuotedString { '"' (doubleQuoteStringContent)* doubleQuoteStringEnd }
}

String { doubleQuotedString | singleQuotedString }

Print { print+ ( String | ListAccess | Expression )+ }
Ask { Text (is+ | Op<"=">) ask+ ( String | ListAccess | Expression )+ }

AssignList { Text (is+ | Op<"=">) (Text+ | Int ) ~ambig (Comma (Text+ | Int ))+ } // comma doesn't really parse well if it is not separated by spaces
Assign { Text (is+ | Op<"=">) (Expression ~ambig | ListAccess)+ }
Sleep { sleep+ (Expression | ListAccess )? }
ListAccess { Text at+ (random+ | Text) }
Add { add+ Text toList+ Text }
Remove { remove+ Text from+ Text }
Clear { clear+ }

Turtle[@isGroup=turtle] {
Forward { forward+ (Expression | ListAccess ) } |
Turn { turn+ (Expression | ListAccess ) } |
Color { color+ (Expression | ListAccess) }
}

If { ifs+ Condition }
Else { elses+ }

Condition {
EqualityCheck { Text is+ (String | Expression | pressed+) } |
InListCheck { Text ins+ Text } |
NotInListCheck { Text not_in+ Text }
}

Repeat { repeat+ (Int | Text) times+ }

For { fors+ Text ins+ (Text | range+ (Text | Int) to+ (Text | Int)) }

ErrorInvalid[@dynamicPrecedence=-10] { Text+ }

Op<expr> { expr }

binaryExpression {
Expression !times Op<"*" | "/"> Expression |
Expression !plus Op<"+" | "-"> Expression
}

Expression {
Int |
Text |
binaryExpression
}

@precedence {
times @left,
plus @right
}

@external specialize { Text } specializeKeyword from "./tokens" {
ask[@name="ask"],
at[@name="at"],
random[@name="random"],
ifs[@name="if"],
pressed[@name="pressed"],
elses[@name="else"]
}

@external extend { Text } extendKeyword from "./tokens" {
print[@name="print"],
forward[@name="forward"],
turn[@name="turn"],
color[@name="color"],
sleep[@name="sleep"],
is[@name="is"],
add[@name="add"],
from[@name="from"],
remove[@name="remove"],
toList[@name="toList"],
clear[@name="clear"],
ins[@name="in"],
not_in[@name="not_in"],
repeat[@name="repeat"],
times[@name="times"],
fors[@name="for"],
to[@name="to"],
range[@name="range"]
}

@tokens {
@precedence {
Int,
Text
}
Comment { "#" ![\n]* }
eol { "\n" }
Comma { $[,،,、] } // every language comma is valid here
Text { ![^\n,،,、 '"#+\-*/=]+ } // a little bit of a hack not to parse commas never, but lezer adds them as error nodes, so it still
space { " " }
digit { $[٠١٢٣٤٥٦٧٨٩۰۱۲۳۴۵۶۷۸۹0123456789] } // latin, arab and pa_PK (Panjabi) scripts
Int { digit+ }
}

@skip { Comment | space }
Loading
Loading