Merge branch 'erg-lang:main' into patch-1

This commit is contained in:
Cai Bingjun 2022-08-17 21:38:20 +08:00 committed by GitHub
commit 2e4c48a2f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1317 additions and 2 deletions

2
.gitattributes vendored
View file

@ -2,3 +2,5 @@
* text=auto
flake.lock linguist-generated=true
*.er linguist-language=Python

View file

@ -0,0 +1,27 @@
# General
Respect others.
Do not say mean things or show contempt, even if there is a difference in skill.
Do not be aggressive in disagreements.
Do not deny any identity of the other person.
Do not post anything that is severely offensive to others.
Do not spam, fish or troll.
If you see someone who you think is violating this Code of Conduct, please contact the [administrator](moderation.erglang@gmail.com) immediately. We will take appropriate action.
## Development
Requests are always welcome, but please keep in mind that they will not always be accepted. Many issues have trade-offs.
Don't intercept issues that others have been assigned (Check assignees on GitHub). If it is considered too difficult for one person to handle it, we will call for more support.
Before proposing a new feature, consider whether that feature could be easily solved by combining existing features.
Please write code in a style that is standardized by the Erg team and languages.
> This document is released under the [CC BY 4.0 license](https://creativecommons.org/licenses/by/4.0/). You may freely cite, modify, and redistribute it.

View file

@ -0,0 +1,27 @@
# 全般
他者を尊重しましょう。
スキルに差があっても、意地悪なことを言ったり侮蔑したりしてはいけません。
意見の相違があっても、攻撃的になってはいけません。
他者のいかなるアイデンティティも否定してはいけません。
他者をひどく不快にする投稿をしないでください。
スパム、釣り、荒らし行為を行わないでください。
この行動規範に違反していると思われる人物を見かけた場合、すぐに[管理者](moderation.erglang@gmail.com)に連絡してください。然るべき処置を行います。
## 開発・実装に関して
リクエストは常に受け付けますが、常に採用されるとは限らないと心に留めておいてください。多くの問題には、トレードオフが存在します。
他者がアサインされたイシューを横取りするのはやめましょう(GitHubでassigneesを確認してください)。一人では手に余ると判断された場合は、さらに応援を募ります。
機能の提案をする前に、その機能が既存の機能を組み合わせて容易に解決できないか考えてください。
Ergチームや言語で標準とされるスタイルのコードを書いてください。
> この文書はCC BYライセンスで公開されます。自由に引用、改変、再配布して構いません。

51
Cargo.lock generated
View file

@ -2,6 +2,17 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "erg"
version = "0.2.5"
@ -14,6 +25,9 @@ dependencies = [
[[package]]
name = "erg_common"
version = "0.2.5"
dependencies = [
"atty",
]
[[package]]
name = "erg_compiler"
@ -29,3 +43,40 @@ version = "0.2.5"
dependencies = [
"erg_common",
]
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "libc"
version = "0.2.132"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View file

@ -203,3 +203,5 @@ If you have any questions, please feel free to ask them on the [Discord channel]
Erg is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See [LICENSE-APACHE](./LICENSE-APACHE), [LICENSE-MIT](./LICENSE-MIT) for details.
For credits about third party crates, see [THIRD_PARTY_CREDITS.md](./THIRD_PARTY_CREDITS.md).

View file

@ -199,3 +199,5 @@ nix build
Ergは、MITライセンスとApache2.0ライセンスのデュアルライセンスで配布されています。
詳しくは[LICENSE-APACHE](./LICENSE-APACHE), [LICENSE-MIT](./LICENSE-MIT)をご覧ください。
サードパーティーの依存ライブラリのクレジットについては、[THIRD_PARTY_CREDITS.md](./THIRD_PARTY_CREDITS.md) (英語) をご覧ください。

1195
THIRD_PARTY_CREDITS.md Normal file

File diff suppressed because it is too large Load diff

View file

@ -16,6 +16,7 @@ debug = []
japanese = []
[dependencies]
atty = "0.2.14"
[lib]
path = "lib.rs"

View file

@ -4,7 +4,7 @@
use std::env;
use std::env::consts::{ARCH, OS};
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::io::{BufRead, BufReader, Read, stdin};
use std::process;
use crate::lazy::Lazy;
@ -143,7 +143,15 @@ pub struct ErgConfig {
impl Default for ErgConfig {
#[inline]
fn default() -> Self {
Self::new("exec", 1, false, None, 10, Input::REPL, "<module>", 2)
let is_stdin_piped: bool = atty::isnt(atty::Stream::Stdin);
let input = if is_stdin_piped {
let mut buffer = String::new();
stdin().read_to_string(&mut buffer).unwrap();
Input::Pipe(Str::from(buffer))
} else {
Input::REPL
};
Self::new("exec", 1, false, None, 10, input, "<module>", 2)
}
}