Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
83c3786
[+] init
shri-acha Nov 12, 2025
23fbf85
setup: added probable grammar
shri-acha Nov 20, 2025
6e3f5fc
chore: cleaup
shri-acha Nov 20, 2025
bbd154f
feat: added lexing
shri-acha Nov 20, 2025
e081d36
feat: added broken lexing
shri-acha Nov 20, 2025
5a529f1
refactor: refactored lexer as iterator
shri-acha Nov 21, 2025
c6ca308
feat: added location and character offset data on tokens
shri-acha Nov 21, 2025
2741d10
refactor: merge with main
shri-acha Nov 21, 2025
dfc740a
chore: run cargo fmt
Prabesh-Sharma Nov 21, 2025
01cee60
REFACTOR: removed unnecessary clone
Prabesh-Sharma Nov 21, 2025
c6d4aff
Feat: Add RP support to lexer
Prabesh-Sharma Nov 21, 2025
e9b7463
Feat: added hex support with H suffix
Prabesh-Sharma Nov 21, 2025
ea58a0f
feat: added test for lexer
shri-acha Nov 21, 2025
6cdeeea
chore: cargo fmt
shri-acha Nov 21, 2025
07a466e
feat: added buffered reading
shri-acha Nov 22, 2025
8906837
fix: fixed broken row count and introduced parser structs
shri-acha Nov 22, 2025
716a5a4
refactor: removed register pairs(they don't exist until 8086)
shri-acha Nov 24, 2025
f3a0f19
feat: finished implementation of the parser, wip for server
shri-acha Nov 24, 2025
bb184b9
feat: init server capability, wip add message dispatch loop
shri-acha Nov 25, 2025
cd1e770
add: lsp submodule
shri-acha Nov 28, 2025
d1bced1
chore: edit gitmodules
shri-acha Nov 28, 2025
0bea56d
chore: fixing submodule initialization
shri-acha Nov 28, 2025
f4e7e4c
chore: fixed submodule initialization
shri-acha Nov 28, 2025
f7abf03
chore: cleanup
shri-acha Nov 28, 2025
db6435a
feat: pattern matching and detection of requests
shri-acha Nov 29, 2025
e9bf65e
Feat: added dummy textDocument/completion
Prabesh-Sharma Nov 29, 2025
618bbd3
Chore: deleted debug.log
Prabesh-Sharma Nov 29, 2025
99d28ba
Refactor: downcasting
Prabesh-Sharma Nov 29, 2025
1fd70e2
feat: implemented dummy hover request
Prabesh-Sharma Nov 29, 2025
539177d
add: builder scaffold for lsp85
shri-acha Dec 1, 2025
fab7acb
merge
shri-acha Dec 1, 2025
c28ff30
refactor: replaced existing structure with builder lsp
shri-acha Dec 4, 2025
a379e35
feat: add and fix for completion options
shri-acha Dec 4, 2025
079d2ef
feat: added macro for handler routing lsp
shri-acha Dec 5, 2025
9a23fd9
fix: fixed broken macro rules
shri-acha Dec 5, 2025
7d90b7f
add: trial-instructions for completion
shri-acha Dec 5, 2025
4f759c6
refactor: description of completions
shri-acha Dec 5, 2025
f3cc414
chore: rustfmt
shri-acha Dec 5, 2025
44c37c4
refactor: got rid of unecessary clone
shri-acha Dec 6, 2025
8bfa8bf
Refactor: error handling
Prabesh-Sharma Dec 7, 2025
8f4a810
add: instructions for jmp variants and some other instructions
shri-acha Dec 8, 2025
f599e5a
refactor: bindings for wasmabi
shri-acha Dec 9, 2025
3e3abe8
feat: add wasm bindings for functions and macros
shri-acha Dec 10, 2025
0dcd683
chore: fixed up build for non-wasm build
shri-acha Dec 10, 2025
1e14c74
refactor/add: generated wasm bindings for methods
shri-acha Dec 10, 2025
8bc745b
feat: add common interface for bindings
shri-acha Dec 10, 2025
9ac3f55
Update README.md
shri-acha Dec 10, 2025
8167171
refactor: worked on adding library to create bindings
shri-acha Dec 12, 2025
f008593
fix: removed introduced new bindings handler wrapper
shri-acha Dec 17, 2025
22fb73b
Merge branch 'debjitbis08:master' into master
shri-acha Dec 17, 2025
e46686a
Remove lsp85 submodule
shri-acha Dec 17, 2025
2eeb3cb
Add 'lsp85/' from commit 'f00859312b2fe4b2f3a67a8e4c9f6f0d49060975'
shri-acha Dec 17, 2025
43e1e75
added: lsp85 as a subtree
shri-acha Dec 17, 2025
32aa788
init: lsp interface
shri-acha Dec 19, 2025
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
Empty file added .gitmodules
Empty file.
12 changes: 12 additions & 0 deletions src/lsp/interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Transport,LSPClient } from "@codemirror/lsp-client"



function WasmWebTransport(path: string): Promise<Transport> {
let handlers: ((value: string) => void)[] = []
let worker = new Worker(path);
worker.onmessage = e => { for (let h of handlers) h(e.data.toString()) }
return new Promise(resolve => {
worker.onopen = () => resolve()
})
}
2 changes: 2 additions & 0 deletions src/lsp/lsp85/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Cargo.lock
16 changes: 16 additions & 0 deletions src/lsp/lsp85/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[lib]
crate-type = ["cdylib", "rlib"]
path = "src/lib.rs"

[package]
name = "lsp85"
version = "0.1.0"
edition = "2024"

[dependencies]
lsp-server = "0.7.9"
lsp-types = "0.97.0"
serde = { version = "1", features = ["derive"] }
serde-wasm-bindgen = "0.6.5"
serde_json = "1"
wasm-bindgen = "0.2.106"
22 changes: 22 additions & 0 deletions src/lsp/lsp85/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
```
[ CodeMirror Editor ]
LSPClient (browser)
│ JSON-RPC
▼ postMessage
┌──────────────────────────┐
│ WebWorker (JS) │
│ - Handles LSP messages │
│ - Calls WASM functions │
└───────────┬──────────────┘
[ WASM Module ]
- completion()
- hover()
- parsing logic
```
(x) - Code completions
<img width="1404" height="325" alt="image" src="https://github.com/user-attachments/assets/68892087-4392-4610-8b7b-7c574700e58e" />
() Populate for all the instructions
216 changes: 216 additions & 0 deletions src/lsp/lsp85/src/frontend/lexer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
use crate::frontend::token::{Location, Token, TokenType};

#[derive(Debug)]
pub struct Lexer {
pub source: String, // source string
pub ch: char, // current literal
pub curr_position: usize, // current position
pub read_position: usize, // next position
pub location: Location, // current location
}

impl Lexer {
pub fn new(source: String, line_no: usize) -> Self {
Self {
ch: source.chars().nth(0).expect("source of size <1?"),
curr_position: 0,
read_position: 1,
location: Location {
row: line_no,
col: 0,
},
source: source,
}
}
}

impl Iterator for Lexer {
type Item = Token;
fn next(&mut self) -> Option<Token> {
match self.ch {
c if self.ch.is_alphabetic() => {
// identifier
return Some(self.read_identifier());
}
c if self.ch.is_numeric() => {
return Some(self.read_immediate());
}
',' => {
self.consume();
return Some(Token::new(
1,
TokenType::COMMA_DELIM,
self.location,
String::from(','),
));
}
' ' => {
self.consume();
return self.next();
}
'\n' => {
self.consume();
let buf_token = Some(Token::new(
1,
TokenType::EOL,
self.location,
String::from('\n'),
));
self.location.col = 0;
self.location.row += 1;

return buf_token;
}
'\0' => {
return None;
}
_ => {
self.consume();
return Some(Token::new(
1,
TokenType::ILLEGAL,
self.location,
String::from('\0'),
));
}
}
}
}
impl Lexer {
pub fn consume(&mut self) {
if self.read_position >= self.source.len() {
self.ch = '\0';
} else {
self.ch = self.source.chars().nth(self.read_position).unwrap_or(' ');
}
self.curr_position = self.read_position;
self.read_position = self.curr_position + 1;
self.location.col += 1;
}
pub fn read_identifier(&mut self) -> Token {
let mut identifier_buf = String::from("");
while self.ch.is_alphabetic() {
identifier_buf += &self.ch.to_string();
self.consume();
}
return Token::new(
identifier_buf.len(),
get_identifier_token(&identifier_buf),
self.location,
identifier_buf,
);
}
pub fn read_immediate(&mut self) -> Token {
let mut immediate_buf = String::from("");

//Support for hex digits
while self.ch.is_ascii_hexdigit() {
immediate_buf += &self.ch.to_string();
self.consume();
}

//H suffix handling Eg: 123AH
if self.ch == 'H' {
immediate_buf += &self.ch.to_string();
self.consume();
}
return Token::new(
immediate_buf.len(),
TokenType::IMM_VALUE,
self.location,
immediate_buf,
);
}
}
fn get_identifier_token(identifier_lit: &String) -> TokenType {
match identifier_lit.as_str() {
"ADD" | "SUB" | "MOV" | "MVI" | "LXI" | "PUSH" | "POP" | "INR" | "DCR" | "DAD" | "LDAX"
| "STAX" => {
return TokenType::OPERATION;
}
"A" | "B" | "C" | "D" | "E" | "PSW" | "H" | "L" | "SP" => {
return TokenType::REGISTER;
}
_ => {
return TokenType::ILLEGAL;
}
}
}

#[cfg(test)]
mod tests {

use super::Lexer;
use crate::frontend::token::{Location, Token, TokenType};
#[test]
fn imm_test() {
let source = String::from("MVI A,05H\n");
let mut l = Lexer::new(source, 0);
let mut tokens: Vec<Token> = vec![];
for token in l {
tokens.push(token);
}

assert_eq!(
vec![
Token::new(
3,
TokenType::OPERATION,
Location::new(0, 3),
"MVI".to_string()
),
Token::new(1, TokenType::REGISTER, Location::new(0, 5), "A".to_string()),
Token::new(
1,
TokenType::COMMA_DELIM,
Location::new(0, 6),
",".to_string()
),
Token::new(
3,
TokenType::IMM_VALUE,
Location::new(0, 9),
"05H".to_string()
),
Token::new(1, TokenType::EOL, Location::new(0, 10), "\n".to_string())
],
tokens
);
}

#[test]
fn reg_pair() {
let source = String::from("MVI A,SP\n");
let mut l = Lexer::new(source, 0);
let mut tokens: Vec<Token> = vec![];
for token in l {
tokens.push(token);
}

assert_eq!(
vec![
Token::new(
3,
TokenType::OPERATION,
Location::new(0, 3),
"MVI".to_string()
),
Token::new(1, TokenType::REGISTER, Location::new(0, 5), "A".to_string()),
Token::new(
1,
TokenType::COMMA_DELIM,
Location::new(0, 6),
",".to_string()
),
Token::new(
2,
TokenType::REGISTER,
Location::new(0, 8),
"SP".to_string()
),
Token::new(1, TokenType::EOL, Location::new(0, 9), "\n".to_string())
],
tokens
);
}
}
4 changes: 4 additions & 0 deletions src/lsp/lsp85/src/frontend/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod lexer;
pub mod parser;
pub mod token;
pub mod utils;
Loading