27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/doc/LICENSE-MIT.txt:
--------------------------------------------------------------------------------
1 | Permission is hereby granted, free of charge, to any
2 | person obtaining a copy of this software and associated
3 | documentation files (the "Software"), to deal in the
4 | Software without restriction, including without
5 | limitation the rights to use, copy, modify, merge,
6 | publish, distribute, sublicense, and/or sell copies of
7 | the Software, and to permit persons to whom the Software
8 | is furnished to do so, subject to the following
9 | conditions:
10 |
11 | The above copyright notice and this permission notice
12 | shall be included in all copies or substantial portions
13 | of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 | DEALINGS IN THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Theorvolt
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/repl/repl.rs:
--------------------------------------------------------------------------------
1 | use crate::eval::eval::{eval_return, Env, Object};
2 | use crate::lexer::lexer::Lexer;
3 | use crate::parser::parser::parse;
4 | use ::std::io::Write;
5 | use std::io;
6 | use std::process;
7 |
8 | use colored::*;
9 |
10 | const PROMPT: &str = "( ᴜ ω ᴜ )⭜";
11 |
12 | pub fn start() {
13 | println!("uwu *nuzzles* wewcome to uwucode! Is for me..? 🥺👉👈");
14 | let mut env = Env::new();
15 | loop {
16 | print!("{} ", PROMPT.truecolor(255, 69, 0));
17 | std::io::stdout().flush().expect("Flushing failed");
18 | let mut user_in: String = String::new();
19 | io::stdin().read_line(&mut user_in).expect("Could not read");
20 | let mut lexer = Lexer::new(&user_in as &str);
21 | let mut token_vec = lexer.lex();
22 |
23 | let parsed = parse(&mut token_vec);
24 |
25 | let evaluated = match eval_return(parsed, &mut env) {
26 | Object::Terminate => {
27 | println!("{}", Object::Terminate);
28 | process::exit(69);
29 | }
30 | val => val,
31 | };
32 | println!("{}", evaluated);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/doc/theme.js:
--------------------------------------------------------------------------------
1 | var themes=document.getElementById("theme-choices");var themePicker=document.getElementById("theme-picker");function showThemeButtonState(){themes.style.display="block";themePicker.style.borderBottomRightRadius="0";themePicker.style.borderBottomLeftRadius="0"}function hideThemeButtonState(){themes.style.display="none";themePicker.style.borderBottomRightRadius="3px";themePicker.style.borderBottomLeftRadius="3px"}function switchThemeButtonState(){if(themes.style.display==="block"){hideThemeButtonState()}else{showThemeButtonState()}};function handleThemeButtonsBlur(e){var active=document.activeElement;var related=e.relatedTarget;if(active.id!=="themePicker"&&(!active.parentNode||active.parentNode.id!=="theme-choices")&&(!related||(related.id!=="themePicker"&&(!related.parentNode||related.parentNode.id!=="theme-choices")))){hideThemeButtonState()}}themePicker.onclick=switchThemeButtonState;themePicker.onblur=handleThemeButtonsBlur;["ayu","dark","light"].forEach(function(item){var but=document.createElement('button');but.textContent=item;but.onclick=function(el){switchTheme(currentTheme,mainTheme,item,true)};but.onblur=handleThemeButtonsBlur;themes.appendChild(but)})
--------------------------------------------------------------------------------
/src/repl/interpreter.rs:
--------------------------------------------------------------------------------
1 | use crate::eval::eval::{eval_return_single, Env, Object};
2 | use crate::lexer::lexer::Lexer;
3 | use crate::parser::parser::parse;
4 | use std::fs;
5 | use std::process;
6 |
7 | pub fn file_interpret(file_name: &str) {
8 | println!("uwu *nuzzles* wewcome to uwucode! Is for me..? 🥺👉👈");
9 | let mut env = Env::new();
10 |
11 | let file_str = match fs::read_to_string(file_name) {
12 | Ok(val) => val,
13 | Err(_) => panic!("File not found, or unreadable"),
14 | };
15 |
16 | let mut lexer = Lexer::new(&file_str);
17 | let mut token_vec = lexer.lex();
18 |
19 | let parsed = parse(&mut token_vec);
20 | /*
21 | Match action, i.e Print, Terminate, or Exit
22 | */
23 | for parsed_expr in parsed.iter() {
24 | match eval_return_single(parsed_expr, &mut env) {
25 | Object::Terminate => {
26 | println!("{}", Object::Terminate);
27 | process::exit(69);
28 | }
29 | Object::Print(value) => {
30 | println!("{}", value);
31 | }
32 | _ => print!(""),
33 | };
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main.rs:
--------------------------------------------------------------------------------
1 | //! # What is uwucode?
2 | //! uwucode is an atrocity. In all seriousness, uwucode is a satirical programming language that incorporates egirl slang to make it nearly unreadable. Take for example the following:
3 | //! ```
4 | //! owo hehexd = 1;
5 | //! uwu nya(lel) {nuzzles (lel==hehexd) {sugoi hehexd;} rawr {sugoi lel*nya(lel-hehexd);};};
6 | //! nya(5); // -> 120
7 | //! ```
8 | //! Of course, one may recognize this is a recursive implementation of the factorial function, however it looks like a mess to anyone else.
9 |
10 | mod eval;
11 | mod lexer;
12 | mod parser;
13 | mod repl;
14 | mod tests;
15 | mod token;
16 | use std::env;
17 |
18 | /// uwucode takes in the following arguments:
19 | /// repl | open
20 | /// # repl
21 | /// Opens a REPl to evaluate uwucode. Takes in no additional arguments.
22 | ///
23 | /// # open
24 | /// Takes in one argument, which is the filepath.
25 | fn main() {
26 | let args: Vec = env::args().collect();
27 | match args[1].as_ref() {
28 | "repl" => repl::repl::start(),
29 | "open" => repl::interpreter::file_interpret(args[2].as_ref()),
30 |
31 | val => panic!("{} is not a recognized argument", val),
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/tests/token_test.rs:
--------------------------------------------------------------------------------
1 | #[cfg(test)]
2 | mod tests {
3 | use crate::token::token::*;
4 |
5 | #[test]
6 | fn test_lookup_ident() {
7 | struct TestingStruct {
8 | token_vec: Vec,
9 | }
10 | let inputs: Vec<&str> = vec![
11 | "uwu", "owo", "nuzzles", "dab", "rawr", "sugoi", "truwu", "fowose", "Hello!",
12 | ];
13 |
14 | let tests: TestingStruct = TestingStruct {
15 | token_vec: vec![
16 | Token::FUNCTION,
17 | Token::LET,
18 | Token::IF,
19 | Token::ELIF,
20 | Token::ELSE,
21 | Token::RETURN,
22 | Token::TRUE,
23 | Token::FALSE,
24 | Token::IDENT(String::from("Hello!")),
25 | ],
26 | };
27 | // You may ask, what the hell is the resultant iterator here?? Tbh, I'm not sure as well...
28 | // In all seriousness,unlike Python, zip is a method for tying iterators, where the argument (not self!) is the second element.
29 | // Diagram: A.iter().zip(B.iter()) -> iter(a,b).
30 | for (input, test) in inputs.iter().zip(tests.token_vec.iter()) {
31 | assert_eq!(&lookup_ident(input), test);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/doc/search-index.js:
--------------------------------------------------------------------------------
1 | var searchIndex = JSON.parse('{\
2 | "main":{"doc":"","i":[],"p":[]},\
3 | "token":{"doc":"","i":[[0,"token","token","token docs",null,null],[4,"Token","token::token","",null,null],[13,"ILLEGAL","","",0,null],[13,"EOF","","",0,null],[13,"IDENT","","",0,null],[13,"ASSIGN","","",0,null],[13,"PLUS","","",0,null],[13,"MINUS","","",0,null],[13,"ASTERISK","","",0,null],[13,"SLASH","","",0,null],[13,"EQ","","",0,null],[13,"LEQ","","",0,null],[13,"LE","","",0,null],[13,"GEQ","","",0,null],[13,"GE","","",0,null],[13,"NEQ","","",0,null],[13,"COMMA","","",0,null],[13,"SEMICOLON","","",0,null],[13,"LPAR","","",0,null],[13,"RPAR","","",0,null],[13,"LBRA","","",0,null],[13,"RBRA","","",0,null],[13,"BANG","","",0,null],[13,"FUNCTION","","",0,null],[13,"LET","","",0,null],[13,"RETURN","","",0,null],[13,"IF","","",0,null],[13,"ELIF","","",0,null],[13,"ELSE","","",0,null],[13,"INT","","",0,null],[13,"STRING","","",0,null],[13,"TRUE","","",0,null],[13,"FALSE","","",0,null],[5,"lookup_ident","","",null,[[],["token",4]]],[11,"from","","",0,[[]]],[11,"into","","",0,[[]]],[11,"to_owned","","",0,[[]]],[11,"clone_into","","",0,[[]]],[11,"borrow","","",0,[[]]],[11,"borrow_mut","","",0,[[]]],[11,"try_from","","",0,[[],["result",4]]],[11,"try_into","","",0,[[],["result",4]]],[11,"type_id","","",0,[[],["typeid",3]]],[11,"clone","","",0,[[],["token",4]]],[11,"eq","","",0,[[["token",4]]]],[11,"ne","","",0,[[["token",4]]]],[11,"fmt","","",0,[[["formatter",3]],["result",6]]]],"p":[[4,"Token"]]}\
4 | }');
5 | addSearchOptions(searchIndex);initSearch(searchIndex);
--------------------------------------------------------------------------------
/src/eval/env.rs:
--------------------------------------------------------------------------------
1 | //! Handles the scoping of functions and various contexts.
2 | use crate::eval::eval::Object;
3 | use std::collections::HashMap;
4 |
5 | /// Scopes contain bound variables and expressions.
6 | #[derive(Clone)]
7 | pub struct Env {
8 | pub space: HashMap,
9 | pub enclosing: Option>, // Pointer to a scope or nothing.
10 | }
11 |
12 | impl Env {
13 | /// Instantiates a new environment object with no outer scope.
14 | pub fn new() -> Self {
15 | Env {
16 | space: HashMap::new(),
17 | enclosing: None,
18 | }
19 | }
20 |
21 | /// Defines a variable/function in the current scope.
22 | pub fn set(&mut self, key: String, value: Object) {
23 | self.space.insert(key, value);
24 | }
25 |
26 | /// Recursively attempts to get a variable/functions value.
27 | pub fn get(&self, key: &str) -> Option
17 |
18 |
19 | # Table of Contents
20 |
21 | 1. [What is uwucode?](#what-is-uwucode?)
22 | 1. [Technical details](##technical-details)
23 |
24 | 2. [Getting started](#getting-started)
25 | 1. [Cargo requirements](##cargo-requirements)
26 | 2. [Building](##build-instructions)
27 |
28 | 3. [Writing with uwucode](#writing-with-uwucode)
29 | 1. [Syntax](##syntax)
30 |
31 | 4. [Future plans](#future-plans)
32 |
33 | 5. [Contributing](#contributing)
34 |
35 | 6. [License](#license)
36 |
37 | 7. [Contact](#contact)
38 |
39 | 8. [Extra](#extra)
40 | 1. [Why?](#why?)
41 |
42 | 9. [Acknowledgements](#acknowledgements)
43 |
44 |
45 |
46 | # What is uwucode?
47 |
48 | uwucode is an interpreted language written in Rust and consists of a nonsensical grammar for keywords, for instance uwu and owo are used for function and variable declarations respectively. While the language itself brings no unique features, the code used to interpret the language is good for beginners who wish to learn about language design.
49 |
50 | ## Technical details
51 |
52 | TBA.
53 |
54 |
55 | # Getting Started
56 |
57 | To get a local copy up and running follow these simple steps.
58 |
59 | ## Cargo requirements
60 |
61 | The toml file contains information on any dependencies which are automatically fetched.
62 |
63 | ## Build Instructions
64 |
65 | 1. Use Cargo to build uwucode.
66 | ```
67 | cargo build
68 | ```
69 | 2. Done.
70 |
71 |
72 | # Writing with uwucode
73 |
74 | Note: uwucode output often contains characters (emojis and colored text) that may not be readable by some terminals.
75 |
76 | Upon building uwucode, one may open a REPL by passing in the argument repl as follows:
77 | ```
78 | uwucode repl
79 | ```
80 |
81 | Alternatively, you can execute a file by using the open argument, supplying a file path, for instance:
82 | ```
83 | uwucode open example.uwu
84 | ```
85 |
86 | ## Syntax
87 |
88 | uwucode does not enforce typing and is interpreted. It is also independent of whitespace, which means indenting and spaces don't matter, but you must terminate the end of a statement. To define a variable, one would write:
89 |
90 | ```owo var = value :3```
91 |
92 | For the sake of reference, `:3` can be replaced with `;`. For defining functions, the keyword `uwu` is utilised:
93 |
94 | ```
95 | uwu square(x) {sugoi x*x;};
96 | ```
97 |
98 | There are more examples in the examples folder, however a list of all keywords include:
99 |
100 | * owo - let
101 | * uwu - define
102 | * sugoi - return
103 | * nuzzles - if
104 | * dab - elif
105 | * rawr - else
106 | * truwu - true
107 | * fowose - false
108 |
109 | As of now, there are also three builtins:
110 |
111 | * quwuit - Takes in zero arguments, terminates the program.
112 | * len - Returns the length of a string.
113 | * dprint - Takes in one argument, prints the object.
114 |
115 | _For more examples, please refer to the [Documentation](https://github.com/Theorvolt/uwucode/doc)_
116 |
117 |
118 |
119 | # Roadmap
120 |
121 | TBD, but there's a lot I have in mind. As of now, a few things that will come are:
122 |
123 | * while loops
124 | * a more robust interpreter
125 | * inputs
126 | * basic logical operations
127 | * compilation to bytecode
128 |
129 | # Contributing
130 |
131 | You forfeit any right to sue me should your sanity disappear while contributing to this code. Follow standard procedure if you wish to contribute, i.e fork->commit->pull request. You can also ask for a feature in the issues section.
132 |
133 |
134 | # License
135 |
136 | Distributed under the MIT License. See `LICENSE` for more information.
137 |
138 |
139 | # Contact
140 |
141 | Sai kumar Murali krishnan - [LinkedIn](https://www.linkedin.com/in/sai-kumar-murali-krishnan/) - theorvoltbusiness@gmail.com
142 |
143 | Project Link: [https://github.com/Theorvolt/uwucode](https://github.com/Theorvolt/uwucode)
144 |
145 |
146 | # Extra
147 |
148 | ## Why?
149 |
150 | The inspiration for this language came about since a friend of mine had made a relatively simple gag language primarily using the letter X [over here](https://github.com/lduck11007/x/). I also wanted to learn a bit about language design and manually designing a parser was a painful but worthwhile experience. As for the actual language itself, we found it a funny idea to write docstrings in uwu speak, something I intend to add in the future. Either way, this language serves no practical use but is a great way to break into language design. I highly recommend checking out the following: [https://interpreterbook.com/](https://interpreterbook.com/).
151 |
152 | # Acknowledgements
153 |
154 | * Thanks to Satya for inspiration on keywords for the language and designing the logo.
155 | *
156 | *
157 |
158 |
159 |
--------------------------------------------------------------------------------
/src/doc/src/main/eval/env.rs.html:
--------------------------------------------------------------------------------
1 | env.rs.html -- source
2 |
3 |
90 |
--------------------------------------------------------------------------------
/src/doc/ayu.css:
--------------------------------------------------------------------------------
1 | body{background-color:#0f1419;color:#c5c5c5;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){color:white;}h1.fqn{border-bottom-color:#5c6773;}h1.fqn a{color:#fff;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod){border-bottom-color:#5c6773;}h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant){border:none;}.in-band{background-color:#0f1419;}.invisible{background:rgba(0,0,0,0);}code{color:#ffb454;}h3>code,h4>code,h5>code{color:#e6e1cf;}pre>code{color:#e6e1cf;}span code{color:#e6e1cf;}.docblock a>code{color:#39AFD7 !important;}.docblock code,.docblock-short code{background-color:#191f26;}pre{color:#e6e1cf;background-color:#191f26;}.sidebar{background-color:#14191f;}.logo-container.rust-logo>img{filter:drop-shadow(1px 0 0px #fff) drop-shadow(0 1px 0 #fff) drop-shadow(-1px 0 0 #fff) drop-shadow(0 -1px 0 #fff);}*{scrollbar-color:#5c6773 transparent;}.sidebar{scrollbar-color:#5c6773 transparent;}::-webkit-scrollbar-track{background-color:transparent;}::-webkit-scrollbar-thumb{background-color:#5c6773;}.sidebar::-webkit-scrollbar-track{background-color:transparent;}.sidebar::-webkit-scrollbar-thumb{background-color:#5c6773;}.sidebar .current{background-color:transparent;color:#ffb44c;}.source .sidebar{background-color:#0f1419;}.sidebar .location{border-color:#000;background-color:#0f1419;color:#fff;}.sidebar-elems .location{color:#ff7733;}.sidebar-elems .location a{color:#fff;}.sidebar .version{border-bottom-color:#424c57;}.sidebar-title{border-top-color:#5c6773;border-bottom-color:#5c6773;}.block a:hover{background:transparent;color:#ffb44c;}.line-numbers span{color:#5c6773;}.line-numbers .line-highlighted{color:#708090;background-color:rgba(255,236,164,0.06);padding-right:4px;border-right:1px solid #ffb44c;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom-color:#5c6773;}.docblock table,.docblock table td,.docblock table th{border-color:#5c6773;}.content .method .where,.content .fn .where,.content .where.fmt-newline{color:#c5c5c5;}.content .highlighted{color:#000 !important;background-color:#c6afb3;}.content .highlighted a,.content .highlighted span{color:#000 !important;}.content .highlighted{background-color:#c6afb3;}.search-results a{color:#0096cf;}.search-results a span.desc{color:#c5c5c5;}.content .stability::before{color:#ccc;}.content span.foreigntype,.content a.foreigntype{color:#ef57ff;}.content span.union,.content a.union{color:#98a01c;}.content span.constant,.content a.constant,.content span.static,.content a.static{color:#6380a0;}.content span.primitive,.content a.primitive{color:#32889b;}.content span.traitalias,.content a.traitalias{color:#57d399;}.content span.keyword,.content a.keyword{color:#de5249;}.content span.externcrate,.content span.mod,.content a.mod{color:#acccf9;}.content span.struct,.content a.struct{color:#ffa0a5;}.content span.enum,.content a.enum{color:#99e0c9;}.content span.trait,.content a.trait{color:#39AFD7;}.content span.type,.content a.type{color:#cfbcf5;}.content span.fn,.content a.fn,.content span.method,.content a.method,.content span.tymethod,.content a.tymethod,.content .fnname{color:#fdd687;}.content span.attr,.content a.attr,.content span.derive,.content a.derive,.content span.macro,.content a.macro{color:#a37acc;}pre.rust .comment{color:#788797;}pre.rust .doccomment{color:#a1ac88;}nav:not(.sidebar){border-bottom-color:#424c57;}nav.main .current{border-top-color:#5c6773;border-bottom-color:#5c6773;}nav.main .separator{border:1px solid #5c6773;}a{color:#c5c5c5;}.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow),.docblock-short a:not(.srclink):not(.test-arrow),.stability a{color:#39AFD7;}.collapse-toggle{color:#999;}#crate-search{color:#c5c5c5;background-color:#141920;box-shadow:0 0 0 1px #424c57,0 0 0 2px transparent;border-color:#424c57;}.search-input{color:#ffffff;background-color:#141920;box-shadow:0 0 0 1px #424c57,0 0 0 2px transparent;transition:box-shadow 150ms ease-in-out;}#crate-search+.search-input:focus{box-shadow:0 0 0 1px #148099,0 0 0 2px transparent;}.search-focus:disabled{color:#929292;}.module-item .stab{color:#000;}.stab.unstable,.stab.deprecated,.stab.portability{color:#c5c5c5;background:#314559 !important;border-style:none !important;border-radius:4px;padding:3px 6px 3px 6px;}.stab.portability>code{color:#e6e1cf;background-color:transparent;}#help>div{background:#14191f;box-shadow:0px 6px 20px 0px black;border:none;border-radius:4px;}.since{color:grey;}tr.result span.primitive::after,tr.result span.keyword::after{color:#788797;}.line-numbers :target{background-color:transparent;}pre.rust .number,pre.rust .string{color:#b8cc52;}pre.rust .kw,pre.rust .kw-2,pre.rust .prelude-ty,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .op,pre.rust .lifetime{color:#ff7733;}pre.rust .macro,pre.rust .macro-nonterminal{color:#a37acc;}pre.rust .question-mark{color:#ff9011;}pre.rust .self{color:#36a3d9;font-style:italic;}pre.rust .attribute{color:#e6e1cf;}pre.rust .attribute .ident,pre.rust .attribute .op{color:#e6e1cf;}.example-wrap>pre.line-number{color:#5c67736e;border:none;}a.test-arrow{font-size:100%;color:#788797;border-radius:4px;background-color:rgba(57,175,215,0.09);}a.test-arrow:hover{background-color:rgba(57,175,215,0.368);color:#c5c5c5;}.toggle-label{color:#999;}:target>code,:target>.in-band{background:rgba(255,236,164,0.06);border-right:3px solid rgba(255,180,76,0.85);}pre.compile_fail{border-left:2px solid rgba(255,0,0,.4);}pre.compile_fail:hover,.information:hover+pre.compile_fail{border-left:2px solid #f00;}pre.should_panic{border-left:2px solid rgba(255,0,0,.4);}pre.should_panic:hover,.information:hover+pre.should_panic{border-left:2px solid #f00;}pre.ignore{border-left:2px solid rgba(255,142,0,.6);}pre.ignore:hover,.information:hover+pre.ignore{border-left:2px solid #ff9200;}.tooltip.compile_fail{color:rgba(255,0,0,.5);}.information>.compile_fail:hover{color:#f00;}.tooltip.should_panic{color:rgba(255,0,0,.5);}.information>.should_panic:hover{color:#f00;}.tooltip.ignore{color:rgba(255,142,0,.6);}.information>.ignore:hover{color:#ff9200;}.search-failed a{color:#39AFD7;}.tooltip .tooltiptext{background-color:#314559;color:#c5c5c5;border:1px solid #5c6773;}.tooltip .tooltiptext::after{border-color:transparent #314559 transparent transparent;}.notable-traits-tooltiptext{background-color:#314559;border-color:#5c6773;}#titles>div.selected{background-color:#141920 !important;border-bottom:1px solid #ffb44c !important;border-top:none;}#titles>div:not(.selected){background-color:transparent !important;border:none;}#titles>div:hover{border-bottom:1px solid rgba(242,151,24,0.3);}#titles>div>div.count{color:#888;}.content .highlighted.mod,.content .highlighted.externcrate{}.search-input:focus{}.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro{}.content .highlighted.trait{}.content span.struct,.content a.struct,.block a.current.struct{}#titles>div:hover,#titles>div.selected{}.content .highlighted.traitalias{}.content span.type,.content a.type,.block a.current.type{}.content span.union,.content a.union,.block a.current.union{}.content .highlighted.foreigntype{}pre.rust .lifetime{}.content .highlighted.primitive{}.content .highlighted.constant,.content .highlighted.static{}.stab.unstable{}.content .highlighted.fn,.content .highlighted.method,.content .highlighted.tymethod{}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){}.content span.enum,.content a.enum,.block a.current.enum{}.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static{}.content span.keyword,.content a.keyword,.block a.current.keyword{}pre.rust .comment{}.content .highlighted.enum{}.content .highlighted.struct{}.content .highlighted.keyword{}.content span.traitalias,.content a.traitalias,.block a.current.traitalias{}.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname{}pre.rust .kw{}pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident{}.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype{}pre.rust .doccomment{}.stab.deprecated{}.content .highlighted.attr,.content .highlighted.derive,.content .highlighted.macro{}.stab.portability{}.content .highlighted.union{}.content span.primitive,.content a.primitive,.block a.current.primitive{}.content span.externcrate,.content span.mod,.content a.mod,.block a.current.mod{}.content .highlighted.type{}pre.rust .kw-2,pre.rust .prelude-ty{}.content span.trait,.content a.trait,.block a.current.trait{}@media (max-width:700px){.sidebar-menu{background-color:#14191f;border-bottom-color:#5c6773;border-right-color:#5c6773;}.sidebar-elems{background-color:#14191f;border-right-color:#5c6773;}#sidebar-filler{background-color:#14191f;border-bottom-color:#5c6773;}}kbd{color:#c5c5c5;background-color:#314559;border-color:#5c6773;border-bottom-color:#5c6773;box-shadow-color:#c6cbd1;}#theme-picker,#settings-menu,.help-button{border-color:#5c6773;background-color:#0f1419;color:#fff;}#theme-picker>img,#settings-menu>img{filter:invert(100);}#theme-picker:hover,#theme-picker:focus,#settings-menu:hover,#settings-menu:focus,.help-button:hover,.help-button:focus{border-color:#e0e0e0;}#theme-choices{border-color:#5c6773;background-color:#0f1419;}#theme-choices>button:not(:first-child){border-top-color:#5c6773;}#theme-choices>button:hover,#theme-choices>button:focus{background-color:rgba(110,110,110,0.33);}@media (max-width:700px){#theme-picker{background:#0f1419;}}#all-types{background-color:#14191f;}#all-types:hover{background-color:rgba(70,70,70,0.33);}.search-results td span.alias{color:#c5c5c5;}.search-results td span.grey{color:#999;}#sidebar-toggle{background-color:#14191f;}#sidebar-toggle:hover{background-color:rgba(70,70,70,0.33);}#source-sidebar{background-color:#14191f;}#source-sidebar>.title{color:#fff;border-bottom-color:#5c6773;}div.files>a:hover,div.name:hover{background-color:#14191f;color:#ffb44c;}div.files>.selected{background-color:#14191f;color:#ffb44c;}.setting-line>.title{border-bottom-color:#5c6773;}input:checked+.slider{background-color:#ffb454 !important;}
--------------------------------------------------------------------------------
/src/doc/LICENSE-APACHE.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/src/parser/parser.rs:
--------------------------------------------------------------------------------
1 | //! Handles the parsing of tokens that come from the lexer.
2 | use crate::parser::ast::{is_builtin, Expr, Operator, Precedence, Prefix, Statement};
3 | use crate::token::token::Token;
4 |
5 | /// The parse function turns a vector of tokens into a vector of statements. This is done by grouping them into one of several categories.
6 | ///
7 | /// # Parse categories
8 | /// - Let (define)
9 | /// - Function (define)
10 | /// - Right brace (end body)
11 | /// - Return (return statement)
12 | /// - EOF (end of file)
13 | /// - Expressions (everything else)
14 | pub fn parse(input: &mut Vec) -> Vec {
15 | let mut statements = vec![];
16 |
17 | // Process each statement here
18 | loop {
19 | let top_token = match input.last() {
20 | Some(token) => token,
21 | None => panic!("Vec list found empty."),
22 | };
23 |
24 | match top_token {
25 | Token::EOF => break, // We've reached the end of line or file
26 | Token::LET => parse_let(input, &mut statements), // Define a variable
27 | Token::FUNCTION => parse_function(input, &mut statements), // Define a function
28 | Token::RBRA => break, // We've reached the end of an enclosing
29 | Token::RETURN => parse_return(input, &mut statements), // We've hit a return statement
30 | _ => statements.push(Statement::Expression(parse_expression(
31 | input,
32 | Precedence::Lowest,
33 | ))), // Deal with an expression
34 | }
35 |
36 | // Since the subcalls modify the vector of tokens, we should reach a semicolon at the end.
37 | assert_eq!(input.pop(), Some(Token::SEMICOLON));
38 | }
39 |
40 | return statements;
41 | }
42 |
43 | /// Parses let statement by resolving an identifier name and an expression.
44 | ///
45 | /// # Technical information
46 | /// The function effectively transforms a line with a let statement into a let expression.
47 | fn parse_let(input: &mut Vec, statements: &mut Vec) {
48 | assert_eq!(input.pop(), Some(Token::LET)); // Sanity check
49 |
50 | // wtfs going on here lol, double enum extraction
51 | let var_name: String = match input.pop() {
52 | Some(Token::IDENT(var)) => var,
53 | _ => panic!("String type not found for variable name."),
54 | };
55 |
56 | // We're at = stage
57 | assert_eq!(input.pop(), Some(Token::ASSIGN));
58 | // Now we're at the expression eval stage, leave it to parse expr
59 | let value = parse_expression(input, Precedence::Lowest);
60 | statements.push(Statement::Let {
61 | name: var_name,
62 | value,
63 | });
64 | }
65 |
66 | fn parse_return(input: &mut Vec, statements: &mut Vec) {
67 | /*
68 | Let's have a look at our Return enum now. Return {value:Expr} which means
69 | we need to just parse the expression.
70 | */
71 | assert_eq!(input.pop(), Some(Token::RETURN));
72 | // Now evaluate the expression
73 | let value = parse_expression(input, Precedence::Lowest);
74 | statements.push(Statement::Return { value });
75 | }
76 |
77 | /// Parses a function definition, which consists of statements from the other categories.
78 | ///
79 | /// # Technical Information
80 | /// The ideal structure of a function takes the following form:
81 | /// DEFINE function_name(args..) {
82 | /// body
83 | /// }
84 | /// This means that each argument and the body have to be individually parsed.
85 | ///
86 | fn parse_function(input: &mut Vec, statements: &mut Vec) {
87 | assert_eq!(input.pop(), Some(Token::FUNCTION));
88 |
89 | // Next thing is the function name, add it in
90 | let func_name: String = match input.pop() {
91 | Some(Token::IDENT(name)) => name,
92 | a => panic!(
93 | "String not found for the function name, instead found {:?}",
94 | a
95 | ),
96 | };
97 |
98 | // Now we're at args, first thing is the LPAR
99 | assert_eq!(input.pop(), Some(Token::LPAR));
100 |
101 | // Read arguments
102 | let mut parameters = vec![];
103 |
104 | loop {
105 | match input.pop() {
106 | Some(Token::RPAR) => break,
107 | Some(Token::IDENT(var)) => {
108 | // Find an arg, add then proceed
109 | parameters.push(var); // push to vec list
110 | // Either separate the argument, finish reading or panic.
111 | match input.pop() {
112 | Some(Token::RPAR) => break,
113 | Some(Token::COMMA) => continue,
114 | _ => panic!("Object after parameter was not comma or bracket"),
115 | };
116 | }
117 | _ => panic!("Object after param was not comma or bracket"),
118 | }
119 | }
120 |
121 | // Parse the body
122 | assert_eq!(input.pop(), Some(Token::LBRA)); // {
123 | let body = parse(input); // will return code of inside
124 | assert_eq!(input.pop(), Some(Token::RBRA)); // }
125 |
126 | statements.push(Statement::Define {
127 | func_name,
128 | func: Expr::Function { parameters, body },
129 | });
130 | }
131 |
132 | /// Parses most expressions that involve primitives, operators or basic conditionals.
133 | ///
134 | /// # Technical Information
135 | ///
136 | fn parse_expression(input: &mut Vec, precedence: Precedence) -> Expr {
137 | let mut left_expr = match input.pop() {
138 | Some(val) => {
139 | match val {
140 | // This is a Token type
141 | // Primitives
142 | Token::INT(value) => Expr::Integer(value),
143 | Token::TRUE => Expr::Boolean(true),
144 | Token::FALSE => Expr::Boolean(false),
145 | Token::IDENT(value) => {
146 | // for implementing builtin, do a logic check here
147 | if input.last() == Some(&Token::LPAR) {
148 | input.pop();
149 | let mut args = vec![];
150 |
151 | loop {
152 | match input.last() {
153 | Some(Token::RPAR) => {
154 | input.pop();
155 | break;
156 | }
157 | None => panic!("weird stuff happened"),
158 | _ => args.push(parse_expression(input, Precedence::Lowest)),
159 | }
160 |
161 | match input.pop() {
162 | Some(Token::RPAR) => break,
163 | Some(Token::COMMA) => continue,
164 | _ => panic!("Unexpected parameter"),
165 | }
166 | }
167 | if is_builtin(&value as &str) {
168 | Expr::Builtin {
169 | function_name: value,
170 | arguments: args,
171 | }
172 | } else {
173 | Expr::Call {
174 | function: Box::new(Expr::Variable(value)),
175 | arguments: args,
176 | }
177 | }
178 | } else {
179 | Expr::Variable(value)
180 | }
181 | }
182 | Token::STRING(value) => Expr::String(value),
183 |
184 | // Prefix types [A B]
185 | Token::BANG => Expr::Prefix {
186 | prefix: Prefix::Bang,
187 | value: Box::new(parse_expression(input, Precedence::Prefix)),
188 | },
189 |
190 | Token::MINUS => Expr::Prefix {
191 | prefix: Prefix::Minus,
192 | value: Box::new(parse_expression(input, Precedence::Prefix)),
193 | },
194 |
195 | // conditional
196 | Token::IF => {
197 | assert_eq!(Some(Token::LPAR), input.pop());
198 | let condition = parse_expression(input, Precedence::Lowest);
199 | assert_eq!(Some(Token::RPAR), input.pop());
200 |
201 | // Parse body
202 | assert_eq!(Some(Token::LBRA), input.pop());
203 | let consequence = parse(input);
204 | assert_eq!(Some(Token::RBRA), input.pop());
205 |
206 | let alternative = if input.last() == Some(&Token::ELSE) {
207 | // ELSE CONDITION
208 | input.pop();
209 | assert_eq!(Some(Token::LBRA), input.pop());
210 | let alternative = parse(input);
211 | assert_eq!(Some(Token::RBRA), input.pop());
212 | alternative
213 | } else {
214 | // No alternative
215 | Vec::new()
216 | };
217 |
218 | Expr::If {
219 | condition: Box::new(condition),
220 | consequence,
221 | alternative,
222 | }
223 | }
224 |
225 | // while, control flow 1
226 | Token::WHILE => {
227 | // While (THING) { do thing}
228 | assert_eq!(Some(Token::LPAR), input.pop());
229 | let condition = parse_expression(input, Precedence::Lowest);
230 | assert_eq!(Some(Token::RPAR), input.pop());
231 |
232 | // Parse body
233 | assert_eq!(Some(Token::LBRA), input.pop());
234 | let instruction = parse(input);
235 | assert_eq!(Some(Token::RBRA), input.pop());
236 |
237 | Expr::While {
238 | condition: Box::new(condition),
239 | instruction,
240 | }
241 | }
242 |
243 | // Error
244 | _ => panic!("Parser error: Not recognized!"),
245 | }
246 | }
247 | _ => panic!("The vector is empty"),
248 | };
249 |
250 | // Depending on whether we have a prefix/infix expression, we need to modify evaluation order.
251 | while precedence < input.last().unwrap().priority() {
252 | left_expr = parse_infix(left_expr, input);
253 | }
254 |
255 | left_expr
256 | }
257 |
258 | /// Parses expressions involving an operator in the middle, for instance a OP b.
259 | ///
260 | /// # Technical Information
261 | /// The left token is passed in, then the right token is popped, which results in a new infix expression, with pointers to the left and right expressions.
262 | fn parse_infix(left: Expr, input: &mut Vec) -> Expr {
263 | let next_token = match input.pop() {
264 | Some(value) => value,
265 | None => panic!("Empty list..."),
266 | };
267 |
268 | let operator = match next_token {
269 | Token::PLUS => Operator::Plus,
270 | Token::MINUS => Operator::Minus,
271 | Token::SLASH => Operator::Divide,
272 | Token::MOD => Operator::Modulo,
273 | Token::ASTERISK => Operator::Multiply,
274 | Token::LEQ => Operator::LessThanEqual,
275 | Token::LE => Operator::LessThan,
276 | Token::GEQ => Operator::GreaterThanEqual,
277 | Token::GR => Operator::GreaterThan,
278 | Token::EQ => Operator::Equals,
279 | Token::NEQ => Operator::NotEquals,
280 | _ => panic!("parse infix called on invalid operator"),
281 | };
282 |
283 | Expr::Infix {
284 | left: Box::new(left),
285 | operator,
286 | right: Box::new(parse_expression(input, next_token.priority())),
287 | }
288 | }
289 |
--------------------------------------------------------------------------------
/src/doc/src/main/parser/ast.rs.html:
--------------------------------------------------------------------------------
1 | ast.rs.html -- source
2 |
3 |