tuga 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4166c22839eeaca0798af2aec537756558066bb3
4
+ data.tar.gz: ddf07cc668f9d34d126f0e3f1e42771f275b9ab3
5
+ SHA512:
6
+ metadata.gz: 7a00b7d2cd44d93fcea10749e71951951bcef859be6580385777cc2daa20cf4f2fcf4b86cc289a1374bc0ad5b930c94f194d812d5900f95aab72167f40a6bc0b
7
+ data.tar.gz: 7aa81d25b972c63827c8bdd65739b03b9f5460756909a78d65840f40b9f82a7181708604bf47ff6ab9ee38550352255d88854fb99d42567d59d99e0537bd4958
@@ -0,0 +1,11 @@
1
+ # Unix-style newlines with a newline ending every file
2
+ [*]
3
+ end_of_line = lf
4
+ insert_final_newline = true
5
+ max_line_length = 120
6
+ trim_trailing_whitespace = true
7
+
8
+ # 2 space indentation
9
+ [*.rb]
10
+ indent_style = space
11
+ indent_size = 2
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /Gemfile.lock
7
+ /measurements/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
@@ -0,0 +1,33 @@
1
+ # Use this file to configure the Overcommit hooks you wish to use. This will
2
+ # extend the default configuration defined in:
3
+ # https://github.com/sds/overcommit/blob/master/config/default.yml
4
+ #
5
+ # At the topmost level of this YAML file is a key representing type of hook
6
+ # being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
7
+ # customize each hook, such as whether to only run it on certain files (via
8
+ # `include`), whether to only display output if it fails (via `quiet`), etc.
9
+ #
10
+ # For a complete list of hooks, see:
11
+ # https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
12
+ #
13
+ # For a complete list of options that you can use to customize hooks, see:
14
+ # https://github.com/sds/overcommit#configuration
15
+ #
16
+ # Uncomment the following lines to make the configuration take effect.
17
+
18
+ PreCommit:
19
+ RuboCop:
20
+ enabled: true
21
+ on_warn: fail # Treat all warnings as failures
22
+
23
+ # TrailingWhitespace:
24
+ # enabled: true
25
+ # exclude:
26
+ # - '**/db/structure.sql' # Ignore trailing whitespace in generated files
27
+ #
28
+ #PostCheckout:
29
+ # ALL: # Special hook name that customizes all hooks of this type
30
+ # quiet: true # Change all post-checkout hooks to only display output on failure
31
+ #
32
+ # IndexTags:
33
+ # enabled: true # Generate a tags file with `ctags` each time HEAD changes
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,32 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ DisplayCopNames: true
5
+ NewCops: enable
6
+
7
+ # ----------------------- Layout ----------------------
8
+
9
+ Layout:
10
+ Max: 120
11
+
12
+ # ---------------------- Metrics ----------------------
13
+
14
+ Metrics/BlockLength:
15
+ Exclude:
16
+ - spec/**/*_spec.rb
17
+ - tuga.gemspec
18
+
19
+ # ----------------------- RSpec -----------------------
20
+
21
+ RSpec/ExampleLength:
22
+ Enabled: false
23
+
24
+ # ------------------- Security/Eval -------------------
25
+ Security/Eval:
26
+ Exclude:
27
+ - bin/tuga
28
+
29
+ # ----------------------- Style -----------------------
30
+
31
+ Style/FrozenStringLiteralComment:
32
+ Enabled: false
@@ -0,0 +1 @@
1
+ ruby 2.4.10
@@ -0,0 +1,20 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.4.10
6
+ before_install: gem install bundler -v 2.1.4
7
+
8
+ before_script:
9
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
10
+ - chmod +x ./cc-test-reporter
11
+ - ./cc-test-reporter before-build
12
+
13
+ script:
14
+ - bundle exec bundle-audit
15
+ - bundle exec rspec
16
+ - bundle exec rubocop
17
+ - bundle exec rake yard:junk
18
+
19
+ after_script:
20
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
@@ -0,0 +1 @@
1
+ --plugin junk
@@ -0,0 +1,22 @@
1
+ threshold: 100
2
+ rules:
3
+ ApiTag::Presence:
4
+ enabled: true
5
+ ApiTag::Inclusion:
6
+ enabled: true
7
+ ApiTag::ProtectedMethod:
8
+ enabled: true
9
+ ApiTag::PrivateMethod:
10
+ enabled: true
11
+ ExampleTag:
12
+ enabled: true
13
+ ReturnTag:
14
+ enabled: true
15
+ Summary::Presence:
16
+ enabled: true
17
+ Summary::Length:
18
+ enabled: false
19
+ Summary::Delimiter:
20
+ enabled: true
21
+ Summary::SingleLine:
22
+ enabled: false
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at wilson.dsigns@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tuga.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ guard :bundler do
2
+ watch('tuga.gemspec')
3
+ end
4
+
5
+ guard :bundler_audit, run_on_start: true do
6
+ watch('Gemfile.lock')
7
+ end
8
+
9
+ group :tests do
10
+ guard :rspec, all_on_start: true, cmd: 'COVERAGE=false bundle exec rspec --format progress' do
11
+ watch(%r{^spec/.+_spec\.rb$})
12
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
13
+ watch('spec/spec_helper.rb') { 'spec' }
14
+ end
15
+ end
16
+
17
+ guard :rubocop do
18
+ watch(/.+\.rb$/)
19
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
20
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Wilson Silva
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.
@@ -0,0 +1,70 @@
1
+ # Tuga
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/tuga.svg)](https://badge.fury.io/rb/tuga)
4
+ [![Build Status](https://travis-ci.org/wilsonsilva/tuga.svg?branch=master)](https://travis-ci.org/wilsonsilva/tuga)
5
+ [![Security](https://hakiri.io/github/wilsonsilva/tuga/master.svg)](https://hakiri.io/github/wilsonsilva/tuga/master)
6
+ [![Inline docs](http://inch-ci.org/github/wilsonsilva/tuga.svg?branch=master)](http://inch-ci.org/github/wilsonsilva/tuga)
7
+
8
+ A Portuguese script programming language meant for educational purposes.
9
+
10
+ ## Requirements
11
+
12
+ The gem requires the version 2.4 of the Ruby programming language. It won't work with later versions yet.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'tuga'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle install
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install tuga
29
+
30
+ ## Usage
31
+
32
+ ```
33
+ tuga soure_code.pt
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies, configure git hooks and create support files.
39
+
40
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ The health and maintainability of the codebase is ensured through a set of
43
+ Rake tasks to test, lint and audit the gem for security vulnerabilities and documentation:
44
+
45
+ ```
46
+ rake bundle:audit # Checks for vulnerable versions of gems
47
+ rake qa # Test, lint and perform security and documentation audits
48
+ rake rubocop # Lint the codebase with RuboCop
49
+ rake rubocop:auto_correct # Auto-correct RuboCop offenses
50
+ rake spec # Run RSpec code examples
51
+ rake verify_measurements # Verify that yardstick coverage is at least 100%
52
+ rake yard # Generate YARD Documentation
53
+ rake yard:junk # Check the junk in your YARD Documentation
54
+ rake yardstick_measure # Measure docs in lib/**/*.rb with yardstick
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wilsonsilva/tuga. This project is intended to
60
+ be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
61
+ [code of conduct](https://github.com/wilsonsilva/tuga/blob/master/CODE_OF_CONDUCT.md).
62
+
63
+ ## License
64
+
65
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
66
+
67
+ ## Code of Conduct
68
+
69
+ Everyone interacting in the Tuga project's codebases, issue trackers, chat rooms and mailing lists is expected to
70
+ ollow the [code of conduct](https://github.com/wilsonsilva/tuga/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,37 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'bundler/audit/task'
3
+ require 'rspec/core/rake_task'
4
+ require 'rubocop/rake_task'
5
+ require 'yaml'
6
+ require 'yard/rake/yardoc_task'
7
+ require 'yard-junk/rake'
8
+ require 'yardstick/rake/measurement'
9
+ require 'yardstick/rake/verify'
10
+
11
+ yardstick_options = YAML.load_file('.yardstick.yml')
12
+
13
+ Bundler::Audit::Task.new
14
+ RuboCop::RakeTask.new
15
+ RSpec::Core::RakeTask.new(:spec)
16
+ YARD::Rake::YardocTask.new
17
+ YardJunk::Rake.define_task
18
+ Yardstick::Rake::Measurement.new(:yardstick_measure, yardstick_options)
19
+ Yardstick::Rake::Verify.new
20
+
21
+ task default: :spec
22
+
23
+ # Remove the report on rake clobber
24
+ CLEAN.include('measurements', 'doc', '.yardoc', 'tmp')
25
+
26
+ # Delete these files and folders when running rake clobber.
27
+ CLOBBER.include('coverage', '.rspec_status')
28
+
29
+ desc 'Run spec with coverage'
30
+ task :coverage do
31
+ ENV['COVERAGE'] = 'true'
32
+ Rake::Task['spec'].execute
33
+ `open coverage/index.html`
34
+ end
35
+
36
+ desc 'Test, lint and perform security and documentation audits'
37
+ task qa: %w[spec rubocop yard:junk verify_measurements bundle:audit]
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'pry'
5
+ require 'tuga'
6
+
7
+ Pry.start
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ if ! which overcommit >/dev/null; then
9
+ echo 'The gem overcommit is not installed. It is necessary to lint the git history through git hooks.'
10
+ echo 'Please install overcommit and run this script again.'
11
+ exit 1
12
+ fi
13
+
14
+ overcommit --install
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'tuga/transpiler'
5
+ require 'rubygems'
6
+
7
+ if ARGV.nil?
8
+ puts <<~ERRO
9
+ Código fonte não especificado. A sintaxe correta é:
10
+
11
+ tuga ficheiro_codigo_fonte.pt
12
+ ERRO
13
+ else
14
+ ARGV.each do |file_path|
15
+ next unless file_path
16
+
17
+ unless Gem::Requirement.new('~> 2.4.0').satisfied_by?(Gem::Version.new(RUBY_VERSION))
18
+ raise 'O requisito mínimo para executar é Ruby 2.4'
19
+ end
20
+
21
+ transpiler = Tuga::Transpiler.new
22
+ tuga_code = File.read(File.expand_path(file_path, File.dirname(__FILE__)), encoding: 'utf-8')
23
+ ruby_code = transpiler.to_ruby tuga_code
24
+
25
+ eval ruby_code
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+ require 'tuga/transpiler'
2
+ require 'tuga/version'
3
+
4
+ # Encapsulates all the code of the gem in a meaningful namespace.
5
+ module Tuga
6
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tuga/core_ext/array'
4
+ require 'tuga/core_ext/class'
5
+ require 'tuga/core_ext/enumerator'
6
+ require 'tuga/core_ext/integer'
7
+ require 'tuga/core_ext/kernel'
8
+ require 'tuga/core_ext/module'
9
+ require 'tuga/core_ext/range'
10
+ require 'tuga/core_ext/string'
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Portuguese translations
4
+ class Array
5
+ alias inverter reverse
6
+ alias ultimo last
7
+ alias primeiro first
8
+ alias cada each
9
+ alias cada_com_indice each_with_index
10
+ alias comprimento length
11
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Portuguese translations
4
+ class Class
5
+ alias novo new
6
+ alias nova new
7
+ alias criar new
8
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Portuguese translations
4
+ class Enumerator
5
+ alias tirar take
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Portuguese translations
4
+ class Integer
5
+ alias vezes times
6
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Portuguese translations
4
+ module Kernel
5
+ alias escrever puts
6
+ alias provocar raise
7
+ alias dormir sleep
8
+ alias esperar sleep
9
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Portuguese translations
4
+ class Module
5
+ alias acessor_de_attributos attr_accessor
6
+ alias extender extend
7
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Portuguese translations
4
+ class Range
5
+ alias cada each
6
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Portuguese translations
4
+ class String
5
+ alias inverter reverse
6
+ alias comprimento length
7
+ alias capitalizar capitalize
8
+ alias com_maiuscula capitalize
9
+ alias com_letra_maiuscula capitalize
10
+ alias com_maiusculas upcase
11
+ alias com_letras_maiusculas upcase
12
+ alias com_minusculas downcase
13
+ alias com_letras_minusculas downcase
14
+ alias centrar center
15
+ alias mastigar chomp
16
+ alias substituir replace
17
+ alias inspecionar inspect
18
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyParserStuff
4
+ # Language patches to Ruby Parser
5
+ class Keyword
6
+ keywords = [
7
+ ['fim', %i[kEND kEND], :expr_end],
8
+ ['definir', %i[kDEF kDEF], :expr_fname],
9
+ ['resgatar', %i[kRESCUE kRESCUE_MOD], :expr_mid],
10
+ ['produzir', %i[kYIELD kYIELD], :expr_arg],
11
+ ['sujeito', %i[kSELF kSELF], :expr_end],
12
+ ['falso', %i[kFALSE kFALSE], :expr_end],
13
+ ['tentar_novamente', %i[kRETRY kRETRY], :expr_end],
14
+ ['retornar', %i[kRETURN kRETURN], :expr_mid],
15
+ ['verdadeiro', %i[kTRUE kTRUE], :expr_end],
16
+ ['definido?', %i[kDEFINED kDEFINED], :expr_arg],
17
+ ['indefinir', %i[kUNDEF kUNDEF], :expr_fname],
18
+ ['quebrar', %i[kBREAK kBREAK], :expr_mid],
19
+ ['nulo', %i[kNIL kNIL], :expr_end],
20
+ ['seguinte', %i[kNEXT kNEXT], :expr_mid],
21
+ ['refazer', %i[kREDO kREDO], :expr_end],
22
+ ['classe', %i[kCLASS kCLASS], :expr_class],
23
+ ['alias', %i[kALIAS kALIAS], :expr_fname],
24
+ ['garantir', %i[kENSURE kENSURE], :expr_beg],
25
+ ['senão', %i[kELSE kELSE], :expr_beg],
26
+ ['então', %i[kTHEN kTHEN], :expr_beg],
27
+ ['fazer', %i[kDO kDO], :expr_beg],
28
+ ['início', %i[kBEGIN kBEGIN], :expr_beg]
29
+ ]
30
+
31
+ expression_keywords = [
32
+ ['e', %i[kAND kAND], :expr_beg],
33
+ ['várias_opções', %i[kCASE kCASE], :expr_beg],
34
+ ['senão_se', %i[kELSIF kELSIF], :expr_beg],
35
+ ['por_cada', %i[kFOR kFOR], :expr_beg],
36
+ ['se', %i[kIF kIF_MOD], :expr_beg],
37
+ ['na', %i[kIN kIN], :expr_beg],
38
+ ['em', %i[kIN kIN], :expr_beg],
39
+ ['módulo', %i[kMODULE kMODULE], :expr_beg],
40
+ ['grupo', %i[kMODULE kMODULE], :expr_beg],
41
+ ['ou', %i[kOR kOR], :expr_beg],
42
+ ['excepto_se', %i[kUNLESS kUNLESS_MOD], :expr_beg],
43
+ ['até_que', %i[kUNTIL kUNTIL_MOD], :expr_beg],
44
+ ['quando', %i[kWHEN kWHEN], :expr_beg],
45
+ ['enquanto', %i[kWHILE kWHILE_MOD], :expr_beg]
46
+ ]
47
+
48
+ internal_keywords = [
49
+ ['END', %i[klEND klEND], :expr_end],
50
+ ['BEGIN', %i[klBEGIN klBEGIN], :expr_end],
51
+ ['super', %i[kSUPER kSUPER], :expr_arg],
52
+ ['__FILE__', %i[k__FILE__ k__FILE__], :expr_end],
53
+ ['__LINE__', %i[k__LINE__ k__LINE__], :expr_end],
54
+ ['__ENCODING__', %i[k__ENCODING__ k__ENCODING__], :expr_end]
55
+ ]
56
+
57
+ argument_keywords = [
58
+ ['não', %i[kNOT kNOT], :expr_beg]
59
+ ]
60
+
61
+ original_verbosity = $VERBOSE
62
+ $VERBOSE = nil
63
+
64
+ all_keywords = [
65
+ keywords,
66
+ expression_keywords,
67
+ internal_keywords,
68
+ argument_keywords
69
+ ].flatten(1).map { |args| KWtable.new(*args) }
70
+
71
+ WORDLIST18 = Hash[*all_keywords.map { |o| [o.name, o] }.flatten]
72
+ WORDLIST19 = Hash[*all_keywords.map { |o| [o.name, o] }.flatten]
73
+
74
+ $VERBOSE = original_verbosity
75
+
76
+ WORDLIST18.delete '__ENCODING__'
77
+
78
+ expression_keywords.each do |k|
79
+ WORDLIST19[k[0]] = WORDLIST19[k[0]].dup
80
+ WORDLIST19[k[0]].state = :expr_value
81
+ end
82
+
83
+ argument_keywords.each do |k|
84
+ WORDLIST19[k[0]] = WORDLIST19[k[0]].dup
85
+ WORDLIST19[k[0]].state = :expr_arg
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ruby2ruby'
4
+ require 'ruby_parser'
5
+ require 'tuga/ruby_parser_patches'
6
+
7
+ module Tuga
8
+ # Transpiles Tuga code to Ruby
9
+ class Transpiler
10
+ INITIAL_CODE = "# encoding: utf-8\nrequire \"tuga/core_ext\"\n"
11
+
12
+ def initialize
13
+ @ruby_2_ruby = Ruby2Ruby.new
14
+ @ruby_parser = RubyParser.new
15
+ end
16
+
17
+ def to_ruby(tuga_code)
18
+ sexp = ruby_parser.process("# encoding: utf-8\n#{tuga_code}")
19
+ ruby_code = ruby_2_ruby.process(sexp)
20
+
21
+ "#{INITIAL_CODE}#{ruby_code}"
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :ruby_2_ruby, :ruby_parser
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Tuga
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,51 @@
1
+ require_relative 'lib/tuga/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'tuga'
5
+ spec.version = Tuga::VERSION
6
+ spec.authors = ['Wilson Silva']
7
+ spec.email = ['me@wilsonsilva.net']
8
+
9
+ spec.summary = 'A Portuguese script programming language.'
10
+ spec.description = 'A Portuguese script programming language meant for educational purposes.'
11
+ spec.homepage = 'https://github.com/willsonsilva/tuga'
12
+ spec.license = 'MIT'
13
+ spec.required_ruby_version = Gem::Requirement.new('~> 2.4.0')
14
+
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+ spec.metadata['source_code_uri'] = 'https://github.com/willsonsilva/tuga'
17
+ spec.metadata['changelog_uri'] = 'https://github.com/wilsonsilva/tuga/blob/master/CHANGELOG.md'
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+
25
+ spec.bindir = 'bin'
26
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ # These versions of the parsers and transpilers are compatible with Ruby 2.4. Recent versions are not.
30
+ spec.add_dependency 'ruby2ruby', '= 2.4.4'
31
+ spec.add_dependency 'ruby_parser', '= 3.12.0'
32
+
33
+ spec.add_development_dependency 'bundler', '~> 2.0'
34
+ spec.add_development_dependency 'bundler-audit', '~> 0.6'
35
+ spec.add_development_dependency 'guard', '~> 2.16'
36
+ spec.add_development_dependency 'guard-bundler', '~> 3.0'
37
+ spec.add_development_dependency 'guard-bundler-audit', '~> 0.1'
38
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
39
+ spec.add_development_dependency 'guard-rubocop', '~> 1.3'
40
+ spec.add_development_dependency 'overcommit', '~> 0.53'
41
+ spec.add_development_dependency 'pry', '~> 0.13'
42
+ spec.add_development_dependency 'rake', '~> 10.0'
43
+ spec.add_development_dependency 'rspec', '~> 3.0'
44
+ spec.add_development_dependency 'rubocop', '~> 0.85'
45
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.39'
46
+ spec.add_development_dependency 'simplecov', '~> 0.18'
47
+ spec.add_development_dependency 'simplecov-console', '~> 0.7'
48
+ spec.add_development_dependency 'yard', '~> 0.9'
49
+ spec.add_development_dependency 'yard-junk', '~> 0.0.7'
50
+ spec.add_development_dependency 'yardstick', '~> 0.9'
51
+ end
metadata ADDED
@@ -0,0 +1,363 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tuga
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wilson Silva
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby2ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.4.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.4.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby_parser
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.12.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.12.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler-audit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-bundler-audit
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard-rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.3'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.3'
139
+ - !ruby/object:Gem::Dependency
140
+ name: overcommit
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.53'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.53'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.13'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.13'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rake
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '10.0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '10.0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rspec
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '3.0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '3.0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubocop
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '0.85'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '0.85'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rubocop-rspec
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '1.39'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '1.39'
223
+ - !ruby/object:Gem::Dependency
224
+ name: simplecov
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '0.18'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '0.18'
237
+ - !ruby/object:Gem::Dependency
238
+ name: simplecov-console
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '0.7'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '0.7'
251
+ - !ruby/object:Gem::Dependency
252
+ name: yard
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '0.9'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '0.9'
265
+ - !ruby/object:Gem::Dependency
266
+ name: yard-junk
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: 0.0.7
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: 0.0.7
279
+ - !ruby/object:Gem::Dependency
280
+ name: yardstick
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '0.9'
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '0.9'
293
+ description: A Portuguese script programming language meant for educational purposes.
294
+ email:
295
+ - me@wilsonsilva.net
296
+ executables:
297
+ - console
298
+ - setup
299
+ - tuga
300
+ extensions: []
301
+ extra_rdoc_files: []
302
+ files:
303
+ - ".editorconfig"
304
+ - ".gitignore"
305
+ - ".overcommit.yml"
306
+ - ".rspec"
307
+ - ".rubocop.yml"
308
+ - ".tool-versions"
309
+ - ".travis.yml"
310
+ - ".yardopts"
311
+ - ".yardstick.yml"
312
+ - CHANGELOG.md
313
+ - CODE_OF_CONDUCT.md
314
+ - Gemfile
315
+ - Guardfile
316
+ - LICENSE.txt
317
+ - README.md
318
+ - Rakefile
319
+ - bin/console
320
+ - bin/setup
321
+ - bin/tuga
322
+ - lib/tuga.rb
323
+ - lib/tuga/core_ext.rb
324
+ - lib/tuga/core_ext/array.rb
325
+ - lib/tuga/core_ext/class.rb
326
+ - lib/tuga/core_ext/enumerator.rb
327
+ - lib/tuga/core_ext/integer.rb
328
+ - lib/tuga/core_ext/kernel.rb
329
+ - lib/tuga/core_ext/module.rb
330
+ - lib/tuga/core_ext/range.rb
331
+ - lib/tuga/core_ext/string.rb
332
+ - lib/tuga/ruby_parser_patches.rb
333
+ - lib/tuga/transpiler.rb
334
+ - lib/tuga/version.rb
335
+ - tuga.gemspec
336
+ homepage: https://github.com/willsonsilva/tuga
337
+ licenses:
338
+ - MIT
339
+ metadata:
340
+ homepage_uri: https://github.com/willsonsilva/tuga
341
+ source_code_uri: https://github.com/willsonsilva/tuga
342
+ changelog_uri: https://github.com/wilsonsilva/tuga/blob/master/CHANGELOG.md
343
+ post_install_message:
344
+ rdoc_options: []
345
+ require_paths:
346
+ - lib
347
+ required_ruby_version: !ruby/object:Gem::Requirement
348
+ requirements:
349
+ - - "~>"
350
+ - !ruby/object:Gem::Version
351
+ version: 2.4.0
352
+ required_rubygems_version: !ruby/object:Gem::Requirement
353
+ requirements:
354
+ - - ">="
355
+ - !ruby/object:Gem::Version
356
+ version: '0'
357
+ requirements: []
358
+ rubyforge_project:
359
+ rubygems_version: 2.6.14.4
360
+ signing_key:
361
+ specification_version: 4
362
+ summary: A Portuguese script programming language.
363
+ test_files: []