|
| 1 | +## Celma Lang |
| 2 | + |
| 3 | +Celma is a embedded language in Rust targeting simple parser construction. |
| 4 | +As already explained in the main README such language is processes during |
| 5 | +the Rust compilation stage. |
| 6 | + |
| 7 | +### V0 |
| 8 | + |
| 9 | +In the V0 the compilation is a direct style Parsec generation without any |
| 10 | +optimisations. |
| 11 | + |
| 12 | +### V1 |
| 13 | + |
| 14 | +This version target an aggressive and an efficient parser compilation. For this |
| 15 | +purpose the compilation follows a traditional control ans data flow and was |
| 16 | +mainly inspired by the paper [A Typed, Algebraic Approach to Parsing](https://www.cl.cam.ac.uk/~jdy22/papers/a-typed-algebraic-approach-to-parsing.pdf) |
| 17 | + |
| 18 | +#### Abstract syntax tree |
| 19 | + |
| 20 | +```rust |
| 21 | +#[derive(Clone, Debug, Eq, PartialEq)] |
| 22 | +pub enum ASTParsec { |
| 23 | + PIdent(String), |
| 24 | + PChar(char), |
| 25 | + PString(String), |
| 26 | + PBind(String, Box<ASTParsec>), |
| 27 | + PMap(Box<ASTParsec>, String), |
| 28 | + PSequence(Box<ASTParsec>, Box<ASTParsec>), |
| 29 | + PChoice(Box<ASTParsec>, Box<ASTParsec>), |
| 30 | + PNot(Box<ASTParsec>), |
| 31 | + PTry(Box<ASTParsec>), |
| 32 | + PCheck(Box<ASTParsec>), |
| 33 | + POptional(Box<ASTParsec>), |
| 34 | + PRepeat(bool, Box<ASTParsec>), |
| 35 | + PLookahead(Box<ASTParsec>), |
| 36 | +} |
| 37 | + |
| 38 | +#[derive(Clone, Debug, Eq, PartialEq)] |
| 39 | +pub struct ASTParsecRule { |
| 40 | + pub public: bool, |
| 41 | + pub name: String, |
| 42 | + pub input: String, |
| 43 | + pub returns: String, |
| 44 | + pub rule: Box<ASTParsec>, |
| 45 | +} |
| 46 | +``` |
0 commit comments