alpha test
This commit is contained in:
+36
-10
@@ -1,8 +1,14 @@
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
|
||||
use lspower::jsonrpc::Result;
|
||||
use lspower::lsp::{self, *};
|
||||
use lspower::{Client, LanguageServer, LspService, Server};
|
||||
use lspower::{Client, LanguageServer};
|
||||
use lspower;
|
||||
|
||||
use crate::lexer::LexerState;
|
||||
use crate::transpiler::Transpiler;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Backend {
|
||||
client: Client,
|
||||
@@ -44,14 +50,34 @@ impl LanguageServer for Backend {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn run_lsp_server() {
|
||||
let stdin = tokio::io::stdin();
|
||||
let stdout = tokio::io::stdout();
|
||||
// #[tokio::main]
|
||||
// pub async fn run_lsp_server() {
|
||||
// let stdin = tokio::io::stdin();
|
||||
// let stdout = tokio::io::stdout();
|
||||
|
||||
let (service, messages) = LspService::new(|client| Backend { client });
|
||||
Server::new(stdin, stdout)
|
||||
.interleave(messages)
|
||||
.serve(service)
|
||||
.await;
|
||||
// let (service, messages) = LspService::new(|client| Backend { client });
|
||||
// Server::new(stdin, stdout)
|
||||
// .interleave(messages)
|
||||
// .serve(service)
|
||||
// .await;
|
||||
// }
|
||||
|
||||
pub fn run_lsp_server() {
|
||||
let mut options = Transpiler {
|
||||
auto_mut: true,
|
||||
auto_macro: true,
|
||||
auto_pub: false,
|
||||
macros: vec![String::from("println")],
|
||||
modnum: 0,
|
||||
var_match: String::from("x"),
|
||||
var_state: LexerState { line: 4, column: 4 },
|
||||
matched_vars: HashMap::new()
|
||||
};
|
||||
let file_content = fs::read_to_string("main.wt")
|
||||
.expect("Error reading file");
|
||||
let _ = options.transpile(file_content.to_string(),
|
||||
0,
|
||||
LexerState { line: 1, column: 0 },
|
||||
);
|
||||
println!("{:?}", options.matched_vars);
|
||||
}
|
||||
+3
-2
@@ -6,7 +6,7 @@ mod lsp;
|
||||
use std::{fs, path::Path};
|
||||
use clap::Parser;
|
||||
use lexer::LexerState;
|
||||
use transpiler::Options;
|
||||
use transpiler::Transpiler;
|
||||
|
||||
use crate::lsp::run_lsp_server;
|
||||
|
||||
@@ -36,7 +36,8 @@ fn main() {
|
||||
fs::remove_dir_all("build").expect("err rm build");
|
||||
}
|
||||
fs::create_dir("build").expect("error making build");
|
||||
let transpiled_code = transpiler::transpile(file_content, 0, LexerState { line: 1, column: 0 }, &mut Options::default());
|
||||
let mut trsp = Transpiler::default();
|
||||
let transpiled_code = trsp.transpile(file_content, 0, LexerState { line: 1, column: 0 });
|
||||
|
||||
match args.rust {
|
||||
Some(ref rust_file_name) => {
|
||||
|
||||
+676
-649
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user