Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Commit b9c312b

Browse files
committed
Initial commit
0 parents  commit b9c312b

File tree

23 files changed

+907
-0
lines changed

23 files changed

+907
-0
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "bundler"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/main.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Main
2+
on:
3+
- push
4+
- pull_request_target
5+
jobs:
6+
ci:
7+
name: CI
8+
runs-on: ubuntu-latest
9+
env:
10+
CI: true
11+
steps:
12+
- uses: actions/checkout@master
13+
- uses: ruby/setup-ruby@v1
14+
with:
15+
bundler-cache: true
16+
ruby-version: '3.1'
17+
- name: Test
18+
run: |
19+
bundle exec rake test
20+
bundle exec rake stree:check
21+
automerge:
22+
name: AutoMerge
23+
needs: ci
24+
runs-on: ubuntu-latest
25+
if: github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]'
26+
steps:
27+
- uses: actions/github-script@v3
28+
with:
29+
script: |
30+
github.pulls.merge({
31+
owner: context.payload.repository.owner.login,
32+
repo: context.payload.repository.name,
33+
pull_number: context.payload.pull_request.number
34+
})

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
10+
test.bf

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
9+
## [0.1.0] - 2022-05-26
10+
11+
### Added
12+
13+
- 🎉 Initial release! 🎉
14+
15+
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-bf/compare/v0.1.0...HEAD
16+
[0.1.0]: https://github.com/ruby-syntax-tree/syntax_tree-bf/compare/30c324...v0.1.0

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gemspec

Gemfile.lock

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
PATH
2+
remote: .
3+
specs:
4+
syntax_tree-bf (0.1.0)
5+
prettier_print
6+
syntax_tree (>= 2.0.1)
7+
8+
GEM
9+
remote: https://rubygems.org/
10+
specs:
11+
docile (1.4.0)
12+
minitest (5.15.0)
13+
prettier_print (0.1.0)
14+
rake (13.0.6)
15+
simplecov (0.21.2)
16+
docile (~> 1.1)
17+
simplecov-html (~> 0.11)
18+
simplecov_json_formatter (~> 0.1)
19+
simplecov-html (0.12.3)
20+
simplecov_json_formatter (0.1.4)
21+
syntax_tree (2.7.1)
22+
prettier_print
23+
24+
PLATFORMS
25+
x86_64-darwin-21
26+
x86_64-linux
27+
28+
DEPENDENCIES
29+
bundler
30+
minitest
31+
rake
32+
simplecov
33+
syntax_tree-bf!
34+
35+
BUNDLED WITH
36+
2.3.6

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022-present Kevin Newton
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# SyntaxTree::Bf
2+
3+
[![Build Status](https://github.com/ruby-syntax-tree/syntax_tree-bf/actions/workflows/main.yml/badge.svg)](https://github.com/ruby-syntax-tree/syntax_tree-bf/actions/workflows/main.yml)
4+
[![Gem Version](https://img.shields.io/gem/v/syntax_tree-bf.svg)](https://rubygems.org/gems/syntax_tree-bf)
5+
6+
[Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) support for Brainf***.
7+
8+
## Installation
9+
10+
Add this line to your application's Gemfile:
11+
12+
```ruby
13+
gem "syntax_tree-bf"
14+
```
15+
16+
And then execute:
17+
18+
$ bundle install
19+
20+
Or install it yourself as:
21+
22+
$ gem install syntax_tree-bf
23+
24+
## Usage
25+
26+
From code:
27+
28+
```ruby
29+
require "syntax_tree/bf"
30+
31+
pp SyntaxTree::Bf.parse(source) # print out the AST
32+
puts SyntaxTree::Bf.format(source) # format the AST
33+
```
34+
35+
From the CLI:
36+
37+
```sh
38+
$ stree ast --plugins=bf file.bf
39+
(root
40+
(increment),
41+
...
42+
(increment),
43+
(loop
44+
(shift_right),
45+
...
46+
(decrement)
47+
),
48+
(shift_right),
49+
...
50+
(output)
51+
)
52+
```
53+
54+
or
55+
56+
```sh
57+
$ stree format --plugins=bf file.bf
58+
++++++++[
59+
>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-
60+
]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
61+
```
62+
63+
or
64+
65+
```sh
66+
$ stree write --plugins=bf file.bf
67+
file.bf 1ms
68+
```
69+
70+
## Contributing
71+
72+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-syntax-tree/syntax_tree-bf.
73+
74+
## License
75+
76+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Rakefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
require "bundler/gem_tasks"
4+
require "rake/testtask"
5+
require "syntax_tree/rake_tasks"
6+
7+
Rake::TestTask.new(:test) do |t|
8+
t.libs << "test"
9+
t.libs << "lib"
10+
t.test_files = FileList["test/**/*_test.rb"]
11+
end
12+
13+
source_files = FileList["{lib,test}/**/*.rb"]
14+
SyntaxTree::Rake::CheckTask.new { |t| t.source_files = source_files }
15+
SyntaxTree::Rake::WriteTask.new { |t| t.source_files = source_files }
16+
17+
task default: :test

exe/bf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env ruby
2+
3+
$:.unshift(File.expand_path("../lib", __dir__))
4+
require "syntax_tree/bf"
5+
6+
SyntaxTree::Bf::Evaluate.run(ARGF.read)

0 commit comments

Comments
 (0)