Skip to content

Feature/ruby support update#18

Open
NoorFatima-code wants to merge 3 commits into
QuantumLogicsLabs:mainfrom
NoorFatima-code:feature/ruby-support-update
Open

Feature/ruby support update#18
NoorFatima-code wants to merge 3 commits into
QuantumLogicsLabs:mainfrom
NoorFatima-code:feature/ruby-support-update

Conversation

@NoorFatima-code

@NoorFatima-code NoorFatima-code commented Jul 18, 2026

Copy link
Copy Markdown

Ruby Support — Major Update
What it was before
Originally, the applyRubyDialect() function was very basic. It only handled:

puts and print (Ruby's print commands)
if / elsif / else / unless / while / until
def (function definitions) — but only with simple names
end (closing a block)
nil (Ruby's "empty value")

Everything else in Ruby — method names with ?/!, different loop styles, classes, error handling — wasn't supported at all. Because of this, more than 12 out of the Ruby test files were crashing.
What's been added now

Method names containing ? or !
Ruby commonly uses names like prime?, zero?, save!. These used to crash the transpiler. Now they're safely renamed (e.g. prime? → prime_q) so the system can understand them. Care was also taken so normal text (like "Hello, World!") doesn't get mistakenly treated as a method name.
Ruby's different loop styles
5.times do |i|
(1..100).each do |n|
array.each do |x|
array.each_with_index do |x, i|
a.upto(b) do
a.downto(b) do
loop do (infinite loop)
Any generic something do |x| ... end pattern

All of these now convert correctly.
3. case/when/else (Ruby's switch statement)
Previously not supported at all. Now it correctly converts into an if-else chain.
4. Classes
class Animal, class Dog < Animal (inheritance) — now convert into the correct format.
5. attr_reader / attr_accessor / attr_writer
For now, these are commented out (proper support planned for the future).
6. @variable (instance variables)
Previously not supported. Now converts into the correct format.
7. raise (throwing errors)
Previously not supported at all. Now converts into the correct syntax.
8. begin / rescue / end (error handling)
Our system doesn't support try/catch yet. So this is now safely skipped — the normal code still runs, only the error-handling part is skipped (turned into a comment), so it doesn't crash.
9. ClassName.new(...)
Previously not supported. Now converts into the correct constructor-call format.
10. File.exist?
Turned out the system uses a different actual name for this, so it's now matched correctly.
11. Modifier if/unless
One-line conditions like break unless swapped now convert correctly too.
12. .length / .size
Previously this sometimes incorrectly matched the whole line. Now it only matches the correct part.

Screenshot 2026-07-18 123532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant