Source code parser for the Junon language to be easily used in community projects
Read the description at first. As the way of the rust-analyzer project, this crate has to be used for your projects to easily parse a Junon source code. You will not have to update your own parser when the Junon language will change because this crate will be updated following the language's changes.
To add this crate in your project, you have to open the "Cargo.toml" file and add the following content :
[dependencies]
jup = { git = "https://github.com/junon-corp/jup" }
-
To "translate" source code to series of tokens (All tokens are defined here) :
From a file path :
let example = Path::new("example.ju"); let mut tokenizer = Tokenizer::from_path(example).unwrap(); tokenizer.run(); let tokens: Vec<Token> = tokenizer.tokenized();
From direct source code :
let file_content = "..."; let mut tokenizer = Tokenizer::from_source_code(&file_content); tokenizer.run(); let tokens: Vec<Token> = tokenizer.tokenized();
-
From the tokenized source code, we can transform these tokens to elements (All elements are defined here) :
let mut parser = Parser::new(tokens.clone()); parser.run(); let elements = parser.parsed();
tokens is defined in the above example.
Not all tokens are implemented, you can add your own tokens following the Junon language and make a pull request to add them. Tokens will be added in the same time of juc progress.