Skip to content

Commit 05452ab

Browse files
authored
Complete the initial LSH implementation (#624)
1 parent d1908b0 commit 05452ab

25 files changed

Lines changed: 1340 additions & 199 deletions

File tree

.vscode/launch.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"program": "${workspaceFolder}/target/debug/edit",
1111
"cwd": "${workspaceFolder}",
1212
"args": [
13-
"${workspaceFolder}/crates/edit/src/bin/edit/main.rs"
13+
"${workspaceFolder}/assets/highlighting-tests/markdown.md"
1414
],
1515
},
1616
{
@@ -23,7 +23,7 @@
2323
"program": "${workspaceFolder}/target/debug/edit",
2424
"cwd": "${workspaceFolder}",
2525
"args": [
26-
"${workspaceFolder}/crates/edit/src/bin/edit/main.rs"
26+
"${workspaceFolder}/assets/highlighting-tests/markdown.md"
2727
],
2828
},
2929
{
@@ -40,7 +40,7 @@
4040
"program": "${workspaceFolder}/target/debug/edit",
4141
"cwd": "${workspaceFolder}",
4242
"args": [
43-
"${workspaceFolder}/crates/edit/src/bin/edit/main.rs"
43+
"${workspaceFolder}/assets/highlighting-tests/markdown.md"
4444
],
4545
},
4646
{

assets/highlighting-tests/bash.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
3+
# This is a comment
4+
5+
readonly VAR1="Hello" # String literal
6+
VAR2=42 # Integer literal
7+
VAR3=$((VAR2 + 8)) # Arithmetic expansion
8+
VAR4=$(echo "World") # Command substitution
9+
10+
function greet() { # Function definition
11+
local name="$1" # Local variable, parameter expansion
12+
echo "${VAR1}, $name! $VAR4" # String, parameter expansion, variable
13+
}
14+
15+
greet "User" # Function call, string literal
16+
17+
if [[ $VAR2 -gt 40 && $VAR3 -eq 50 ]]; then # Conditional, test, operators
18+
echo "Numbers are correct" # String literal
19+
elif (( VAR2 < 40 )); then # Arithmetic test
20+
echo 'VAR2 is less than 40' # Single-quoted string
21+
else
22+
echo "Other case"
23+
fi
24+
25+
for i in {1..3}; do # Brace expansion, for loop
26+
echo "Loop $i" # String, variable
27+
done
28+
29+
case "$VAR4" in # Case statement
30+
World) echo "It's World";; # Pattern, string
31+
*) echo "Unknown";; # Wildcard
32+
esac
33+
34+
arr=(one two three) # Array
35+
echo "${arr[1]}" # Array access
36+
37+
declare -A assoc # Associative array
38+
assoc[key]="value"
39+
echo "${assoc[key]}"
40+
41+
# Here document
42+
cat <<EOF
43+
Multi-line
44+
string with $VAR1
45+
EOF
46+
47+
# Here string
48+
grep H <<< "$VAR1"
49+
50+
# Subshell
51+
(subshell_var=99; echo $subshell_var)
52+
53+
# Redirection
54+
echo "Redirected" > /dev/null
55+
56+
# Background job
57+
sleep 1 &
58+
59+
# Arithmetic assignment
60+
let VAR2+=1
61+
62+
# Process substitution
63+
diff <(echo foo) <(echo bar)
64+
65+
# Command grouping
66+
{ echo "Group 1"; echo "Group 2"; }
67+
68+
# Escaped characters
69+
echo "A quote: \" and a backslash: \\"
70+
71+
# End of file
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@echo off
2+
REM --- String, Variable, Label, Command, Operator, Number, Delimiter, Comment ---
3+
4+
:: Label
5+
:Start
6+
7+
:: Variable assignment and usage
8+
set "VAR1=Hello"
9+
set VAR2=World
10+
11+
:: String with spaces and special characters
12+
set "STR=Batch ^& CMD!"
13+
14+
:: Arithmetic operation (number, operator)
15+
set /a SUM=5+10
16+
17+
:: IF statement (keyword, operator, string, variable)
18+
if "%VAR1%"=="Hello" (
19+
echo %VAR1%, %VAR2%! %STR%
20+
) else (
21+
echo Not matched!
22+
)
23+
24+
:: FOR loop (keyword, variable, delimiter, string)
25+
for %%F in (*.bat) do (
26+
echo Found file: %%F
27+
)
28+
29+
:: CALL command (keyword, label)
30+
call :SubRoutine
31+
32+
:: GOTO command (keyword, label)
33+
goto :End
34+
35+
:: Subroutine with parameter
36+
:SubRoutine
37+
echo In subroutine with SUM=%SUM%
38+
goto :eof
39+
40+
:End
41+
REM End of script
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>HTML Syntax Test &amp; Demo</title>
8+
<!-- Comment with special chars: <>&"' -->
9+
<style>
10+
body {
11+
margin: 0;
12+
padding: 20px;
13+
}
14+
15+
.test {
16+
color: #ff0000;
17+
}
18+
</style>
19+
</head>
20+
21+
<body>
22+
<h1 id="main" class='header' data-value="123">Heading</h1>
23+
24+
<!-- Various elements -->
25+
<p>Text with &lt; &gt; &amp; &quot; &apos; &#65; &#x41; entities</p>
26+
<br />
27+
<hr>
28+
<img src="image.png" alt="Description" />
29+
30+
<!-- Attributes -->
31+
<input type="text" disabled required value="" data-custom="attr">
32+
<button onclick="test()">Click</button>
33+
34+
<!-- Nested elements -->
35+
<div>
36+
<span>Inline <strong>bold</strong> text</span>
37+
<ul>
38+
<li>Item 1</li>
39+
<li>Item 2</li>
40+
</ul>
41+
</div>
42+
43+
<!-- Script -->
44+
<script>
45+
function test() {
46+
return x < 10 && y > 5;
47+
}
48+
</script>
49+
</body>
50+
51+
</html>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# H1
2+
3+
## H2
4+
5+
### H3
6+
7+
#### H4
8+
9+
##### H5
10+
11+
###### H6
12+
13+
regular
14+
*italic*
15+
_italic_
16+
**bold**
17+
__bold__
18+
***bold italic***
19+
**_bold italic_**
20+
__*bold italic*__
21+
~~strikethrough~~
22+
`inline code`
23+
`` `literal` ``
24+
\*not\* \_italic\_ # not a heading
25+
26+
* Unordered item
27+
- Nested item
28+
* Third level
29+
* Task list:
30+
* [ ] To do
31+
* [x] Done
32+
* [ ] *Mixed* **formatting** with `code`
33+
1. Ordered can start anywhere
34+
2. …like here (intentional)
35+
1. Nested ordered
36+
2. Multiple paragraphs within a list item:
37+
Still the same item.
38+
39+
> A single-level quote
40+
>
41+
> > A nested quote with **bold** and `code`
42+
>
43+
> * List in a quote
44+
> * [Link in quote](#links)
45+
46+
Inline: [Example](https://example.com "Example Title")
47+
Reference: [Ref Link][ref] and [Another][another-ref]
48+
Relative: [This section](#tables)
49+
Footnote: [^note]
50+
[ref]: https://example.com
51+
[another-ref]: https://github.com
52+
[^note]: This is a footnote with **formatting** and a [link](https://github.com).
53+
54+
Inline: ![Alt text](https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png "GitHub Mark")
55+
Reference: ![Logo][logo-ref]
56+
[logo-ref]: https://github.githubassets.com/images/modules/logos_page/GitHub-Logo.png "GitHub Logo"
57+
58+
| Left | Center | Right |
59+
| :---------- | :--------: | ----: |
60+
| *italic* | `code` | 123 |
61+
| **bold** | ~~strike~~ | 4.56 |
62+
| [link][ref] | :tada: | `end` |
63+
64+
```bash
65+
# Shell
66+
echo "Hello, world" | tr a-z A-Z
67+
```
68+
69+
```json
70+
{
71+
"name": "gfm-kitchen-sink",
72+
"private": true,
73+
"scripts": { "test": "echo ok" }
74+
}
75+
```
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Single-line comment
2+
3+
<#
4+
Multi-line
5+
comment
6+
#>
7+
8+
function Get-SampleData {
9+
param(
10+
[string]$Name = "World", # String literal, parameter
11+
[int]$Count = 3
12+
)
13+
14+
$array = @(1, 2, 3) # Array literal
15+
$hashtable = @{ Key1 = 'Value1'; Key2 = 42 } # Hashtable literal
16+
17+
$nullVar = $null
18+
$boolTrue = $true
19+
$boolFalse = $false
20+
21+
$regexMatch = "abc123" -match '\d+' # Regex literal
22+
23+
for ($i = 0; $i -lt $Count; $i++) {
24+
Write-Host "Hello, $Name! Iteration: $i" # Variable interpolation, string
25+
}
26+
27+
if ($hashtable.Key2 -eq 42) {
28+
Write-Output "Hashtable value is 42"
29+
}
30+
elseif ($hashtable.Key2 -gt 40) {
31+
Write-Output "Hashtable value is greater than 40"
32+
}
33+
else {
34+
Write-Output "Hashtable value is less than or equal to 40"
35+
}
36+
37+
switch ($Name) {
38+
"World" { Write-Host "Default name used." }
39+
default { Write-Host "Custom name: $Name" }
40+
}
41+
42+
try {
43+
throw "An error occurred"
44+
}
45+
catch {
46+
Write-Warning $_
47+
}
48+
finally {
49+
Write-Verbose "Finally block executed"
50+
}
51+
52+
$script:globalVar = 99 # Scope modifier
53+
54+
# Here-String
55+
$hereString = @"
56+
This is a here-string.
57+
Name: $Name
58+
"@
59+
60+
return $hereString
61+
}
62+
63+
# Command invocation, pipeline, splatting
64+
$paramSplat = @{
65+
Name = 'PowerShell'
66+
Count = 2
67+
}
68+
Get-SampleData @paramSplat | Out-File -FilePath "./output.txt"
69+
70+
# Type literal, member access, method call
71+
[System.DateTime]::Now.ToString("yyyy-MM-dd")
72+
73+
# Subexpression
74+
Write-Host "2 + 2 = $($array[0] + $array[1])"
75+
76+
# Command substitution
77+
$pwdPath = $(Get-Location).Path
78+
Write-Host "Current directory: $pwdPath"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# General Settings
2+
[General]
3+
enabled = true
4+
debug = false
5+
log_level = info
6+
max_connections = 1000
7+
8+
[SSL]
9+
enabled = true
10+
cert_file = /etc/ssl/certs/server.crt
11+
key_file = /etc/ssl/private/server.key
12+
protocols = TLSv1.2, TLSv1.3 # Supported protocols: "TLSv1.2" and "TLSv1.3"
13+
cipher_suite = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256"

0 commit comments

Comments
 (0)