Skip to content

Commit

Permalink
Merge pull request #163 from Yuta1004/develop
Browse files Browse the repository at this point in the history
Release v0.1.1
  • Loading branch information
Yuta1004 authored Sep 30, 2022
2 parents 8c14569 + 3597a88 commit b411189
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 67 deletions.
2 changes: 0 additions & 2 deletions .cargo/config.toml

This file was deleted.

8 changes: 3 additions & 5 deletions .github/actions/cache_cargo/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ runs:
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
2 changes: 1 addition & 1 deletion .github/actions/setup_libraries/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ runs:
run: sudo apt update
- name: Install libraries
shell: bash
run: sudo apt install pkg-config libdbus-1-dev libssl-dev libgtk-3-dev libsoup2.4-dev libwebkit2gtk-4.0-dev
run: sudo apt install libdbus-1-dev libgtk-3-dev libsoup2.4-dev libwebkit2gtk-4.0-dev
8 changes: 4 additions & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/setup_libraries
- uses: ./.github/actions/cache_cargo
- name: Make dist dir
run: mkdir -p tools/view/dist
- name: Build
run: cargo build
run: cargo build --all-targets

fmt:
runs-on: ubuntu-latest
Expand All @@ -39,8 +39,8 @@ jobs:
needs: cache
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/setup_libraries
- uses: ./.github/actions/cache_cargo
- name: Setup rustup
run: rustup component add clippy
- name: Make dist dir
Expand All @@ -53,8 +53,8 @@ jobs:
needs: cache
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/setup_libraries
- uses: ./.github/actions/cache_cargo
- name: Make dist dir
run: mkdir -p tools/view/dist
- name: Test
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sysdc"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

[dependencies]
Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SysDC

[![check](https://github.com/Yuta1004/SysDC/actions/workflows/check.yml/badge.svg?branch=master)](https://github.com/Yuta1004/SysDC/actions/workflows/check.yml)
![VERSILN-Badge](https://img.shields.io/github/v/release/Yuta1004/SysDC?style=flat)
![VERSION-Badge](https://img.shields.io/github/v/release/Yuta1004/SysDC?style=flat)

## 概要

Expand Down Expand Up @@ -47,8 +47,6 @@ $ ./sysdc parse example/box/*.def
Load: box.def
1 units loaded!
$ ./sysdc exec debug
$ ./sysdc exec json
$ ./sysdc exec view
Expand All @@ -65,11 +63,9 @@ $ ./sysdc exec view

```
./sysdc parse example/logger/**/*.def -o logger.sysdc
```
#### 引数

- INPUT: ファイル名
./sysdc parse example/logger/logger.def example/logger/std.def example/logger/std/*.def -o logger.sysdc
```

#### オプション

Expand All @@ -85,14 +81,12 @@ $ ./sysdc exec view
./sysdc exec json -i logger.sysdc
```

#### 引数

- TOOL: 実行するツール名

#### オプション

- -i / --input : 内部表現が保存されたファイル名 (省略した場合 `out.sysdc`)

**※ 詳細: [SysDC - 使用方法](https://sysdc.nakagamiyuta.dev/tutorial)**

## 構成

### src(cli) [bin]
Expand Down
2 changes: 1 addition & 1 deletion example/box/box.def
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module BoxModule {
}
}

proc changeSize(box: Box, w: i32, h: i32) {
proc change_size(box: Box, w: i32, h: i32) {
@modify box {
use w, h;
}
Expand Down
10 changes: 5 additions & 5 deletions example/logger/logger.def
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ unit logger;

from std import String;
from std.io import IO;
from std.time import TimeStamp, Time;
from std.time import Time, Timestamp;

module Logger {
proc info(msg: String) {
Expand All @@ -12,8 +12,8 @@ module Logger {
use timestamp;
}

@spawn timestamp: TimeStamp {
let now = Time.getNowTime();
@spawn timestamp: Timestamp {
let now = Time.get_now_time();
return now;
}
}
Expand All @@ -25,8 +25,8 @@ module Logger {
use timestamp;
}

@spawn timestamp: TimeStamp {
let now = Time.getNowTime();
@spawn timestamp: Timestamp {
let now = Time.get_now_time();
return now;
}
}
Expand Down
6 changes: 3 additions & 3 deletions example/logger/std/time.def
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
unit std.time;

data TimeStamp {}
data Timestamp {}

module Time {
func getNowTime() -> TimeStamp {
func get_now_time() -> Timestamp {
@return now
@spawn now: TimeStamp
@spawn now: Timestamp
}
}
2 changes: 1 addition & 1 deletion parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sysdc_parser"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

[dependencies]
Expand Down
16 changes: 5 additions & 11 deletions parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,13 @@ pub struct Parser {
impl Parser {
pub fn parse(&mut self, filename: String, program: &str) -> anyhow::Result<()> {
let tokenizer = Tokenizer::new(filename, program);
match UnitParser::parse(tokenizer) {
Ok(unit) => {
self.units.push(unit);
Ok(())
}
Err(err) => Err(err),
}
let system = UnitParser::parse(tokenizer)?;
self.units.push(system);
Ok(())
}

pub fn check(self) -> anyhow::Result<SysDCSystem> {
match check::check(unchecked::SysDCSystem::new(self.units)) {
Ok(system) => Ok(system),
Err(err) => Err(err),
}
let system = unchecked::SysDCSystem::new(self.units);
check::check(system)
}
}
20 changes: 11 additions & 9 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
mod parse;
mod exec;
mod tool;

use std::process::exit;

use clap::{AppSettings, Parser, Subcommand};

use exec::ExecCmd;
use parse::ParseCmd;

/// SysDC: System Definition Language and Tools
/// Programming Language aiming to support Software Design and Development
#[derive(Parser)]
#[clap(author, version, name = "subcommand")]
#[clap(author, version, name = "SysDC")]
#[clap(global_settings(&[AppSettings::DisableHelpSubcommand]))]
pub struct App {
#[clap(subcommand)]
Expand All @@ -20,18 +18,22 @@ pub struct App {
#[derive(Subcommand)]
#[allow(non_camel_case_types)]
enum AppSub {
/// Parse *.def files
parse(ParseCmd),
/// Parse files *.def into *sysdc
parse(parse::ParseCmd),

/// Execute a tool using a *.sysdc file
exec(exec::ExecCmd),

/// Execute tool
exec(ExecCmd),
/// Manage tools
tool(tool::ToolCmd),
}

impl App {
pub fn run() {
let result = match App::parse().sub {
AppSub::parse(cmd) => cmd.run(),
AppSub::exec(cmd) => cmd.run(),
AppSub::tool(cmd) => cmd.run(),
};
match result {
Ok(_) => exit(0),
Expand Down
5 changes: 2 additions & 3 deletions src/cli/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ enum ExecError {
}

#[derive(Parser)]
#[clap(name = "subcommand")]
pub struct ExecCmd {
#[clap(required = true)]
tool: String,
Expand All @@ -25,8 +24,8 @@ impl ExecCmd {
pub fn run(&self) -> anyhow::Result<()> {
let system = self.load_system()?;
match self.tool.as_str() {
"debug" => sysdc_tool_debug::exec(&system)?,
"json" => sysdc_tool_json::exec(&system)?,
"debug" => sysdc_tool_debug::exec(system)?,
"json" => sysdc_tool_json::exec(system)?,
"view" => sysdc_tool_view::exec(system)?,
t => return Err(ExecError::ToolNotFound(t.to_string()).into()),
}
Expand Down
1 change: 0 additions & 1 deletion src/cli/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use sysdc_parser::structure::SysDCSystem;
use sysdc_parser::Parser as SParser;

#[derive(Parser)]
#[clap(name = "subcommand")]
pub struct ParseCmd {
#[clap(required = true)]
input: Vec<String>,
Expand Down
24 changes: 24 additions & 0 deletions src/cli/tool.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
mod list;

use clap::{Parser, Subcommand};

#[derive(Parser)]
pub struct ToolCmd {
#[clap(subcommand)]
sub: ToolCmdSub,
}

#[derive(Subcommand)]
#[allow(non_camel_case_types)]
enum ToolCmdSub {
/// Print installed tools
list(list::ListCmd),
}

impl ToolCmd {
pub fn run(&self) -> anyhow::Result<()> {
match &self.sub {
ToolCmdSub::list(cmd) => cmd.run(),
}
}
}
13 changes: 13 additions & 0 deletions src/cli/tool/list.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use clap::Parser;

#[derive(Parser)]
pub struct ListCmd;

impl ListCmd {
pub fn run(&self) -> anyhow::Result<()> {
println!("* debug (v1.0.0) : Print a internal structure");
println!("* json (v1.0.1) : Convert a internal structure into JSON");
println!("* view (v0.1.0) : Graphically depict software design");
Ok(())
}
}
2 changes: 1 addition & 1 deletion tools/debug/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sysdc_tool_debug"
version = "1.0.0"
version = "1.0.1"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion tools/debug/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sysdc_parser::structure::SysDCSystem;

pub fn exec(system: &SysDCSystem) -> anyhow::Result<()> {
pub fn exec(system: SysDCSystem) -> anyhow::Result<()> {
println!("{:?}", system);
Ok(())
}
2 changes: 1 addition & 1 deletion tools/json/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sysdc_tool_json"
version = "1.0.1"
version = "1.0.2"
edition = "2021"

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions tools/json/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sysdc_parser::structure::SysDCSystem;

pub fn exec(system: &SysDCSystem) -> anyhow::Result<()> {
let serialized_system = serde_json::to_string(system)?;
pub fn exec(system: SysDCSystem) -> anyhow::Result<()> {
let serialized_system = serde_json::to_string(&system)?;
println!("{}", serialized_system);
Ok(())
}

0 comments on commit b411189

Please sign in to comment.