an ad- and malware-blocking script for Linux
Minimal X screenshot utility
Universal translater for encodings
APU Timetable CLI
Fruit grading classification using Keras
Upload your codes here by 8:30 AM, Nov 18, 2018. The repository name should be your team name.
Demo of object tracking and motion tracking to detect boxes
Pull request review commentrust-unofficial/patterns
+# Interpreter++## Description++If a problem occurs very often and requires long and repetitive steps to solve it,+then the problem instances might be expressed in a simple+language and inerpreter object could solve it by+interpreting the sentences written in this simple language.+Basically, for any kind of problems we define a domain+language, then define a grammar for this language and+design interpreter solving problem instances.++## Motivation++Imagine that our work is translating simple mathematical expressions into+[assembly language](https://en.wikipedia.org/wiki/Assembly_language)+(more simple and low level programming language).+For simplicity, our expressions consists of ten digits `0`,...,`9`,+four operations `+, -, /, *` and a pair of parenthesis `(, )`.+For example, expression `2 + 4` could be translated into++```ignore+mov eax, 2+mov ebx, 4+add eax, ebx+```++Our goal is to automate translating into assembly instructions+using the Interpreter design pattern. In other words, we want simply+provide the Interpreter with an expressions and get Assembly+language output. For example++```rust, ignore+x.interpret("7+3*(2-1)", &output);+```++We don't claim that output assembly code is exactly what modern compilers generate,+but it at least computes the expression correctly.+It is simpy an example of using Interpreter pattern.++## Solution 1++The grammar for a set of expressions over `0,...,9, +,-,*,/,(,)` is
@MarcoIeni Sure, I can explain, but I think we shouldn't go beyond simply mentioning what a CFG is and that expr
, terms...
and factor
are the result of grammar transformation. In any case strong knowledge of CS is still needed :-D . I don't mind detailed explanation of CFG and related topics, but to what extend?
comment created time in 11 hours
Pull request review commentrust-unofficial/patterns
+# Interpreter++## Description++If a problem occurs very often and requires long and repetitive steps to solve it,+then the problem instances might be expressed in a simple+language and inerpreter object could solve it by+interpreting the sentences written in this simple language.+Basically, for any kind of problems we define a domain+language, then define a grammar for this language and+design interpreter solving problem instances.++## Motivation++Imagine that our work is translating simple mathematical expressions into+[assembly language](https://en.wikipedia.org/wiki/Assembly_language)+(more simple and low level programming language).+For simplicity, our expressions consists of ten digits `0`,...,`9`,+four operations `+, -, /, *` and a pair of parenthesis `(, )`.+For example, expression `2 + 4` could be translated into++```ignore+mov eax, 2+mov ebx, 4+add eax, ebx+```++Our goal is to automate translating into assembly instructions+using the Interpreter design pattern. In other words, we want simply+provide the Interpreter with an expressions and get Assembly+language output. For example++```rust, ignore+x.interpret("7+3*(2-1)", &output);+```++We don't claim that output assembly code is exactly what modern compilers generate,+but it at least computes the expression correctly.+It is simpy an example of using Interpreter pattern.++## Solution 1++The grammar for a set of expressions over `0,...,9, +,-,*,/,(,)` is
Should we give a brief explanation about what a grammar is? And explain this example in particular?
For example why both exp
and term
are necessary.
Otherwise this chapter is readable only by people with a MSc degree in computer science 😅
comment created time in 11 hours
Pull request review commentrust-unofficial/patterns
+# Interpreter++## Description++If a problem occurs very often and requires long and repetitive steps to solve it,+then the problem instances might be expressed in a simple+language and inerpreter object could solve it by+interpreting the sentences written in this simple language.+Basically, for any kind of problems we define a domain+language, then define a grammar for this language and+design interpreter solving problem instances.++## Motivation++Imagine that our work is translating simple mathematical expressions into+[assembly language](https://en.wikipedia.org/wiki/Assembly_language)+(more simple and low level programming language).+For simplicity, our expressions consists of ten digits `0`,...,`9`,+four operations `+, -, /, *` and a pair of parenthesis `(, )`.+For example, expression `2 + 4` could be translated into++```ignore+mov eax, 2+mov ebx, 4+add eax, ebx+```++Our goal is to automate translating into assembly instructions+using the Interpreter design pattern. In other words, we want simply+provide the Interpreter with an expressions and get Assembly+language output. For example++```rust, ignore+x.interpret("7+3*(2-1)", &output);+```++We don't claim that output assembly code is exactly what modern compilers generate,+but it at least computes the expression correctly.+It is simpy an example of using Interpreter pattern.+
sure
comment created time in 11 hours
Pull request review commentrust-unofficial/patterns
+# Interpreter++## Description++If a problem occurs very often and requires long and repetitive steps to solve it,+then the problem instances might be expressed in a simple+language and inerpreter object could solve it by+interpreting the sentences written in this simple language.+Basically, for any kind of problems we define a domain+language, then define a grammar for this language and+design interpreter solving problem instances.++## Motivation++Imagine that our work is translating simple mathematical expressions into+[assembly language](https://en.wikipedia.org/wiki/Assembly_language)+(more simple and low level programming language).+For simplicity, our expressions consists of ten digits `0`,...,`9`,+four operations `+, -, /, *` and a pair of parenthesis `(, )`.+For example, expression `2 + 4` could be translated into++```ignore+mov eax, 2+mov ebx, 4+add eax, ebx+```++Our goal is to automate translating into assembly instructions+using the Interpreter design pattern. In other words, we want simply+provide the Interpreter with an expressions and get Assembly+language output. For example++```rust, ignore+x.interpret("7+3*(2-1)", &output);+```++We don't claim that output assembly code is exactly what modern compilers generate,+but it at least computes the expression correctly.+It is simpy an example of using Interpreter pattern.++## Solution 1++The grammar for a set of expressions over `0,...,9, +,-,*,/,(,)` is++```ignore+exp -> exp + term+exp -> exp - term+exp -> term+term -> term * factor+term -> term / factor+term -> factor+factor -> ( exp )+factor -> 0 | 1| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
factor -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
comment created time in 11 hours
Pull request review commentrust-unofficial/patterns
+# Interpreter++## Description++If a problem occurs very often and requires long and repetitive steps to solve it,+then the problem instances might be expressed in a simple+language and inerpreter object could solve it by+interpreting the sentences written in this simple language.+Basically, for any kind of problems we define a domain+language, then define a grammar for this language and+design interpreter solving problem instances.++## Motivation++Imagine that our work is translating simple mathematical expressions into+[assembly language](https://en.wikipedia.org/wiki/Assembly_language)+(more simple and low level programming language).+For simplicity, our expressions consists of ten digits `0`,...,`9`,+four operations `+, -, /, *` and a pair of parenthesis `(, )`.+For example, expression `2 + 4` could be translated into++```ignore+mov eax, 2+mov ebx, 4+add eax, ebx+```++Our goal is to automate translating into assembly instructions+using the Interpreter design pattern. In other words, we want simply+provide the Interpreter with an expressions and get Assembly+language output. For example++```rust, ignore+x.interpret("7+3*(2-1)", &output);+```++We don't claim that output assembly code is exactly what modern compilers generate,+but it at least computes the expression correctly.+It is simpy an example of using Interpreter pattern.+
This is confusing, I had to read it multiple times. Couldn't we just delete it? I don't think it's necessary. It's pretty clear that this is an example and we are not building a modern compiler in my opinion :stuck_out_tongue: What do you think?
comment created time in 12 hours
Pull request review commentrust-unofficial/patterns
+# Interpreter++## Description++If a problem occurs very often and requires long and repetitive steps to solve it,+then the problem instances might be expressed in a simple+language and inerpreter object could solve it by+interpreting the sentences written in this simple language.+Basically, for any kind of problems we define a domain+language, then define a grammar for this language and+design interpreter solving problem instances.++## Motivation++Imagine that our work is translating simple mathematical expressions into+[assembly language](https://en.wikipedia.org/wiki/Assembly_language)+(more simple and low level programming language).+For simplicity, our expressions consists of ten digits `0`,...,`9`,+four operations `+, -, /, *` and a pair of parenthesis `(, )`.+For example, expression `2 + 4` could be translated into++```ignore+mov eax, 2+mov ebx, 4+add eax, ebx+```++Our goal is to automate translating into assembly instructions+using the Interpreter design pattern. In other words, we want simply+provide the Interpreter with an expressions and get Assembly
provide the Interpreter with an expression and get Assembly
comment created time in 12 hours
Pull request review commentrust-unofficial/patterns
+# Interpreter++## Description++If a problem occurs very often and requires long and repetitive steps to solve it,+then the problem instances might be expressed in a simple+language and inerpreter object could solve it by
language and an interpreter object could solve it by
comment created time in 12 hours
push eventrust-unofficial/patterns
commit sha 14c8fca7de808992536e4ff5aba22bb3ba7e1588
deploy: 84bf81a47f09119e1109bdacfbaaf554a65aa579
push time in 12 hours
pull request commentrust-unofficial/patterns
Add note about delegation crates to Deref anti-pattern
Thank you :)
comment created time in 12 hours
push eventrust-unofficial/patterns
commit sha 84bf81a47f09119e1109bdacfbaaf554a65aa579
Add delegation crates to See Also in Deref anti-pattern (#215)
push time in 12 hours
PR merged rust-unofficial/patterns
Closes https://github.com/rust-unofficial/patterns/issues/192
pr closed time in 12 hours
issue closedrust-unofficial/patterns
Deref polymorphism could refer to delegation crates
The chapter about the Deref polymorphism anti-pattern could mention crates that help with trait/method delegation, such as https://docs.rs/delegate/0.5.1/delegate/ or https://lib.rs/crates/ambassador.
If you agree, I can send a PR.
closed time in 12 hours
KobzolPull request review commentrust-unofficial/patterns
Add note about delegation crates to Deref anti-pattern
conversion between arbitrary types. ## See also -[Collections are smart pointers idiom](../idioms/deref.md).--[Documentation for `Deref` trait](https://doc.rust-lang.org/std/ops/trait.Deref.html).+- [Collections are smart pointers idiom](../idioms/deref.md).+- Delegation crates for less boilerplate like [delegate](https://crates.io/crates/delegate) or + [ambassador](https://crates.io/crates/ambassador)
- Delegation crates for less boilerplate like [delegate](https://crates.io/crates/delegate)
or [ambassador](https://crates.io/crates/ambassador)
comment created time in 12 hours
pull request commentrust-unofficial/patterns
Add note about delegation crates to Deref anti-pattern
I think that it's fine, as long as the crates are mentioned, it doesn't matter to me where.
comment created time in 12 hours
Pull request review commentrust-unofficial/patterns
Add note about delegation crates to Deref anti-pattern
conversion between arbitrary types. ## See also -[Collections are smart pointers idiom](../idioms/deref.md).--[Documentation for `Deref` trait](https://doc.rust-lang.org/std/ops/trait.Deref.html).+- [Collections are smart pointers idiom](../idioms/deref.md).+- Delegation crates for less boilerplate like [delegate](https://crates.io/crates/delegate) or [ambassador](https://crates.io/crates/ambassador)
- Delegation crates for less boilerplate like [delegate](https://crates.io/crates/delegate) or
[ambassador](https://crates.io/crates/ambassador)
comment created time in 12 hours
pull request commentrust-unofficial/patterns
Add note about delegation crates to Deref anti-pattern
Like this i mean, what do you both think of it @pickfire & @Kobzol
comment created time in 12 hours
pull request commentrust-unofficial/patterns
Add note about delegation crates to Deref anti-pattern
Hmm, I would actually just put the two links into the See also
section, as we did it with other recommendations (i guess)
comment created time in 13 hours
push eventxhebox/noname-linux
commit sha f8406adc1cb8809ddc6d7f7f78d3c48a344be180
update Signed-off-by: xhe <xw897002528@gmail.com>
push time in 14 hours
push eventxhebox/noname-linux
commit sha f434e4637762f8505495bf43064913c90a0be1e4
update Signed-off-by: xhe <xw897002528@gmail.com>
push time in 14 hours
Pull request review commentrust-unofficial/patterns
+# Interpreter++## Description++If a problem occurs very often and requires long and repetitive steps to solve it,+then the problem instances might be expressed in a simple+language and inerpreter object could solve it by+interpreting the sentences written in this simple language.+Basically, for any kind of problems we define a domain+language, then define a grammar for this language and+design interpreter solving problem instances.++## Motivation++Imagine that our work is translating simple mathematical expressions into+[assembly language](https://en.wikipedia.org/wiki/Assembly_language)+(more simple and low level programming language).+For simplicity, our expressions consists of ten digits `0`,...,`9`,+four operations `+, -, /, *` and a pair of parenthesis `(, )`.+For example, expression `2 + 4` could be translated into++```ignore+mov eax, 2+mov ebx, 4+add eax, ebx+```++Our goal is to automate translating into assembly instructions+using the Interpreter design pattern. In other words, we want simply+provide the Interpreter with an expressions and get Assembly+language output. For example++```rust, ignore+x.interpret("7+3*(2-1)", &output);+```++We don't claim that output assembly code is exactly what modern compilers generate,+but it at least computes the expression correctly.+It is simpy an example of using Interpreter pattern.++## Solution 1++The grammar for a set of expressions over `0,...,9, +,-,*,/,(,)` is++```ignore+exp -> exp + term+exp -> exp - term+exp -> term+term -> term * factor+term -> term / factor+term -> factor+factor -> ( exp )+factor -> 0 | 1| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9+```++Our first approach is a standard one, simple implementation of+a recursive descent parser. The following code+doesn't have `struct` abstraction in order to keep code short.+The code panics when expression is syntactically wrong+(unbalanced parentheses or missing digit/operator for example).++```rust+fn token(input: &[u8], cur: usize) -> char {+ if cur < input.len() {+ input[cur] as char+ } else {+ '$' // End of line+ }+}++fn single_expr(input: &[u8], cur: &mut usize, out: &mut Vec<String>) {+ expr(input, cur, out);++ let ch = token(input, *cur);+ if ch != '$' {+ panic!("Unexpected symbol '{}', at {}", ch, *cur);+ }+}++fn expr(input: &[u8], cur: &mut usize, out: &mut Vec<String>) {+ term(input, cur, out);++ loop {+ let ch = token(input, *cur);+ if ch == '$' || (ch != '+' && ch != '-') {+ break;+ } else {+ *cur += 1;+ term(input, cur, out);+ translate(ch, out);+ }+ }+}++fn term(input: &[u8], cur: &mut usize, out: &mut Vec<String>) {+ factor(input, cur, out);++ loop {+ let ch = token(input, *cur);+ if ch == '$' || (ch != '*' && ch != '/') {+ break;+ } else {+ *cur += 1;+ factor(input, cur, out);+ translate(ch, out);+ }+ }+}++fn factor(input: &[u8], cur: &mut usize, out: &mut Vec<String>) {+ let ch = token(input, *cur);++ if ch.is_digit(10) {+ out.push(format!("push {}", ch));+ } else if ch == '(' {+ *cur += 1;+ expr(input, cur, out);++ let ch = token(input, *cur);+ if ch != ')' {+ panic!("Missing ')' at {}", *cur);+ }+ } else {+ panic!("Unexpected symbol '{}', at {}", ch, *cur);+ }++ *cur += 1;+}++fn translate(ch: char, out: &mut Vec<String>) {+ out.push(String::from("pop ebx"));
For example, I might need to do additional scan over instructions, or simple compute number of instructions,..etc.
comment created time in 15 hours
Pull request review commentrust-unofficial/patterns
+# Interpreter++## Description++If a problem occurs very often and requires long and repetitive steps to solve it,+then the problem instances might be expressed in a simple+language and inerpreter object could solve it by+interpreting the sentences written in this simple language.+Basically, for any kind of problems we define a domain+language, then define a grammar for this language and+design interpreter solving problem instances.++## Motivation++Imagine that our work is translating simple mathematical expressions into+[assembly language](https://en.wikipedia.org/wiki/Assembly_language)+(more simple and low level programming language).+For simplicity, our expressions consists of ten digits `0`,...,`9`,+four operations `+, -, /, *` and a pair of parenthesis `(, )`.+For example, expression `2 + 4` could be translated into++```ignore+mov eax, 2+mov ebx, 4+add eax, ebx+```++Our goal is to automate translating into assembly instructions+using the Interpreter design pattern. In other words, we want simply+provide the Interpreter with an expressions and get Assembly+language output. For example++```rust, ignore+x.interpret("7+3*(2-1)", &output);+```++We don't claim that output assembly code is exactly what modern compilers generate,+but it at least computes the expression correctly.+It is simpy an example of using Interpreter pattern.++## Solution 1++The grammar for a set of expressions over `0,...,9, +,-,*,/,(,)` is++```ignore+exp -> exp + term+exp -> exp - term+exp -> term+term -> term * factor+term -> term / factor+term -> factor+factor -> ( exp )+factor -> 0 | 1| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9+```++Our first approach is a standard one, simple implementation of+a recursive descent parser. The following code+doesn't have `struct` abstraction in order to keep code short.+The code panics when expression is syntactically wrong+(unbalanced parentheses or missing digit/operator for example).++```rust+fn token(input: &[u8], cur: usize) -> char {+ if cur < input.len() {+ input[cur] as char+ } else {+ '$' // End of line+ }+}++fn single_expr(input: &[u8], cur: &mut usize, out: &mut Vec<String>) {+ expr(input, cur, out);++ let ch = token(input, *cur);+ if ch != '$' {+ panic!("Unexpected symbol '{}', at {}", ch, *cur);+ }+}++fn expr(input: &[u8], cur: &mut usize, out: &mut Vec<String>) {+ term(input, cur, out);++ loop {+ let ch = token(input, *cur);+ if ch == '$' || (ch != '+' && ch != '-') {+ break;+ } else {+ *cur += 1;+ term(input, cur, out);+ translate(ch, out);+ }+ }+}++fn term(input: &[u8], cur: &mut usize, out: &mut Vec<String>) {+ factor(input, cur, out);++ loop {+ let ch = token(input, *cur);+ if ch == '$' || (ch != '*' && ch != '/') {+ break;+ } else {+ *cur += 1;+ factor(input, cur, out);+ translate(ch, out);+ }+ }+}++fn factor(input: &[u8], cur: &mut usize, out: &mut Vec<String>) {+ let ch = token(input, *cur);++ if ch.is_digit(10) {+ out.push(format!("push {}", ch));+ } else if ch == '(' {+ *cur += 1;+ expr(input, cur, out);++ let ch = token(input, *cur);+ if ch != ')' {+ panic!("Missing ')' at {}", *cur);+ }+ } else {+ panic!("Unexpected symbol '{}', at {}", ch, *cur);+ }++ *cur += 1;+}++fn translate(ch: char, out: &mut Vec<String>) {+ out.push(String::from("pop ebx"));
@pickfire because I store each instruction as a separate entry in a vector.
comment created time in 15 hours
push eventNerdyPepper/eva
commit sha 3f52f6f2ce8408350fcdc180d416e63dd627d93f
Document `_`
push time in 16 hours
PR merged NerdyPepper/eva
pr closed time in 16 hours
issue commentrust-unofficial/patterns
@simonsan I also looked through a couple of frameworks written in Rust. Many of them use thiserror
.
comment created time in 17 hours
PR opened NerdyPepper/eva
pr created time in a day
PR opened rust-unofficial/patterns
Closes https://github.com/rust-unofficial/patterns/issues/192
pr created time in a day
pull request commentrust-unofficial/patterns
@simonsan decided not go far without people's feedaback :-)
comment created time in a day
pull request commentrust-unofficial/patterns
@simonsan of course. I'll make changes as I get feedbacks.
Ok ;-) wasn't sure if it's still WIP hence I thought I'd ask. Will take a look into it today/tomorrow. 👍🏽
comment created time in a day