Repository: pveyes/naskah Branch: master Commit: a60037c94fcb Files: 25 Total size: 48.3 KB Directory structure: gitextract_c3b19t87/ ├── .github/ │ └── workflows/ │ └── main.yml ├── .gitignore ├── Cargo.toml ├── LICENSE ├── README.md ├── demo/ │ ├── Cargo.toml │ ├── README.md │ ├── src/ │ │ └── lib.rs │ └── static/ │ ├── index.html │ └── style.css ├── parser/ │ ├── Cargo.toml │ └── src/ │ ├── ast.rs │ ├── expr.rs │ ├── identifier.rs │ ├── lib.rs │ ├── literal.rs │ ├── number.rs │ ├── statement.rs │ └── variable.rs ├── printer/ │ ├── Cargo.toml │ └── src/ │ ├── js.rs │ └── lib.rs ├── scripts/ │ └── build-demo.sh ├── src/ │ └── lib.rs └── vercel.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/main.yml ================================================ name: build on: push: branches: [master] pull_request: branches: [master] env: CARGO_TERM_COLOR: always jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build run: cargo build --verbose - name: Run tests run: cargo test --verbose demo: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build run: ./scripts/build-demo.sh - name: Deploy staging uses: amondnet/vercel-action@v19 if: github.event_name == 'pull_request' with: vercel-token: ${{ secrets.VERCEL_TOKEN }} vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} github-token: ${{ secrets.GITHUB_TOKEN }} - name: check production id: prod_or_not run: | if [ "$REF" == 'refs/head/master' ] then echo "::set-output name=vercel-args::--prod" else echo "::set-output name=vercel-args::" fi env: REF: ${{ github.ref }} - name: Deploy production uses: amondnet/vercel-action@v19 if: github.event_name == 'push' with: vercel-token: ${{ secrets.VERCEL_TOKEN }} vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} vercel-args: ${{ steps.prod_or_not.outputs.vercel-args }} github-token: ${{ secrets.GITHUB_TOKEN }} ================================================ FILE: .gitignore ================================================ /target **/*.rs.bk fixtures/ .DS_Store demo/static/worker/ demo/static/main.js demo/static/main.wasm .vercel ================================================ FILE: Cargo.toml ================================================ [package] name = "naskah" version = "0.1.0" authors = ["Fatih Kalifa "] repository = "https://github.com/pveyes/naskah" description = "Bahasa pemrograman dengan sintaks Bahasa Indonesia" license = "MIT" [workspace] members = [ "demo", "parser", "printer" ] [dependencies] ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2018 Fatih Kalifa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # naskah [![Actions Status](https://github.com/pveyes/naskah/workflows/build/badge.svg)](https://github.com/pveyes/naskah/actions) > Bahasa pemrograman dengan sintaks Bahasa Indonesia Demo: https://naskah.vercel.app/ ## Tipe data Saat ini hanya 4 tipe data yang didukung oleh naskah: - angka `123` - huruf `"hello"` - boolean `benar` / `salah` - kosong `kosong` ## Operator Operasi yang didukung oleh `naskah` adalah: - Penjumlahan `+` - Pengurangan `-` - Perkalian `*` - Pembagian `\` - Sisa pembagian `%` - Pangkat `^` Selain itu ada juga operasi untuk membandingkan dua variabel / tipe data - Sama dengan `==` - Tidak sama dengan `!=` - Lebih dari `>` - Kurang dari `<` ## Sintaks ### Deklarasi variabel ``` misal x = 4; misal y = x; ``` ### Percabangan ``` jika x == 2 { } jika x == kosong { } ``` Untuk kasus-kasus umum, naskah menyediakan sintaks khusus untuk pengecekan terhadap `kosong`, `benar` dan `salah`. Tidak perlu menulis operator `==`, cukup `x kosong`. ``` jika x kosong { } ``` ### Perulangan Naskah saat ini hanya mempunyai 1 tipe perulangan yang tidak pernah berhenti ``` ulang { } ``` Untuk berhenti di dalam perulangan, dapat menggunakan sintaks `berhenti;` ``` ulang { jika x > 2 { berhenti; } } ``` ## Lisensi Bahasa pemrograman Naskah terlisensi dibawah lisensi MIT. ================================================ FILE: demo/Cargo.toml ================================================ [package] name = "naskah-demo" version = "0.1.0" authors = ["Fatih Kalifa "] [lib] crate-type = ["cdylib", "rlib"] [dependencies] serde = "^1.0.80" serde_derive = "^1.0.80" yew = "0.17" web-sys = { version = "0.3.45", features = ['Window', 'Document', 'Element'] } wasm-bindgen = "0.2.67" printer = { path = "../printer" } ================================================ FILE: demo/README.md ================================================ # naskah-demo This demo is built in Rust using [Yew](https://github.com/DenisKolodin/yew) framework. ## Overview It consists of two entry point inside `src/bin/` - `main.rs` App entry point, component initialization and initial render - `worker.rs` Compiler run inside web worker Most of the time, we only need to watch & rebuild `main.rs`. But for any worker changes, we need to rebuild manually (see setup below). ## Setup Run this inside `demo` directory ```sh cargo install cargo-web # build worker script cargo web build --bin worker --target=wasm32-unknown-unknown --release # run app & watch for changes cargo web start --bin main --target=wasm32-unknown-unknown --release # visit [::1]:8000 open http://localhost:8000 ``` ================================================ FILE: demo/src/lib.rs ================================================ extern crate printer; extern crate wasm_bindgen; extern crate web_sys; extern crate yew; use wasm_bindgen::prelude::*; use yew::prelude::*; use printer::to_js; struct Model { link: ComponentLink, code: String, transpiled: String, } enum Msg { ChangeCode(String), } const EXAMPLE_CODE: &str = "misal x = 2 + 2; misal y = x > 2; jika y benar { x = x + 1; menang(); } "; impl Component for Model { type Message = Msg; type Properties = (); fn create(_: Self::Properties, link: ComponentLink) -> Self { Self { link, code: EXAMPLE_CODE.into(), transpiled: to_js(EXAMPLE_CODE.into()), } } fn update(&mut self, msg: Self::Message) -> ShouldRender { match msg { Msg::ChangeCode(v) => { self.transpiled = to_js(v.clone().into()); self.code = v; } } true } fn change(&mut self, _props: Self::Properties) -> ShouldRender { // Should only return "true" if new properties are different to // previously received properties. // This component has no properties so we will always return "false". false } fn view(&self) -> Html { html! { <>