-
Overview
- Use case - notify slack with time management
-
Project idea
- Time management with no extra costs
- On-premise project
-
Alternatives
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // iota enumerator gives an effective way in go language | |
| // to use constants in enum-like constructs | |
| const ( | |
| none = iota | |
| plus | |
| mul | |
| ) | |
| // enum-like map of operator token keys and iota values defined above | |
| var precendences = map[string]int{ | |
| token.PLUS: plus, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func led(left ast.Node, operator token.Token, right ast.Node) *ast.Node { | |
| return &ast.Node{Left: &left, Token: &operator, Right: &right} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Node struct { | |
| Token *token.Token | |
| Left *Node | |
| Right *Node | |
| } | |
| // string representation | |
| // 1 * 2 + 3 -> {+,{*,{1},{2}},{3}} | |
| func (n *Node) ToString() string { | |
| res := "{" + n.Token.Literal | |
| if n.Left != nil { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tree := p.lexer.Tokens(). | |
| Scan(func(_ context.Context, acc interface{}, elem interface{}) (interface{}, error) { | |
| it, isIterator := acc.(iterator) | |
| next := elem.(token.Token) | |
| if !isIterator || it.left == nil { | |
| // null denotation | |
| return nud(acc, next), nil | |
| } | |
| if it.operator != nil { | |
| var prevIt *iterator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func nud(acc interface{}, next token.Token) iterator { | |
| // Node{Token: token.Token{Type: token.PLUS, Literal: "+"}, Left: &Node{Token: token.Token{Type: token.INT, Literal: "2"}}} | |
| node := ast.Node{Token: &next} | |
| it := iterator{nud: &node} | |
| accIt, isIt := acc.(iterator) | |
| if isIt { | |
| // { , {... } | |
| node.Left = accIt.nud | |
| // save current stack | |
| it.stack = accIt.stack |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| "os/user" | |
| "pizzascript/repl" | |
| ) | |
| func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package repl | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "io" | |
| "pizzascript/eval" | |
| "pizzascript/lexer" | |
| "pizzascript/parser" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package token | |
| type TokenType string | |
| type Token struct { | |
| Type TokenType | |
| Literal string | |
| } | |
| const ( | |
| // Literals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package lexer | |
| import ( | |
| "fmt" | |
| "strings" | |
| "pizzascript/token" | |
| "github.com/reactivex/rxgo/v2" | |
| ) | |
| type Lexer struct { | |
| input string |
NewerOlder