New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a simple reprap G-Code parser. #789
Open
Patola
wants to merge
2
commits into
rouge-ruby:master
Choose a base branch
from
Patola:master
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
; generated by Slic3r 1.3.0-dev on 2016-07-07 at 16:40:29 | ||
|
||
M104 S60 ; set temperature | ||
G28 ; home all X Y e Z | ||
G21 ;metric values | ||
G90 ;absolute positioning | ||
M107 ;start with the fan off | ||
G1 Z2 F210 | ||
G92 E0 ;zero the extruded length | ||
M117 MakerLinux S.A. | ||
M109 S60 ; set temperature and wait for it to be reached | ||
G21 ; set units to millimeters | ||
G90 ; use absolute coordinates | ||
M82 ; use absolute distances for extrusion | ||
G92 E0 | ||
G0 Z0.700 F4800.000 | ||
G1 X67.159 Y91.922 F4800.000 | ||
G1 F600 | ||
G1 X69.217 Y90.533 E0.69133 | ||
G1 X70.335 Y90.170 E1.01876 | ||
G1 X71.706 Y89.949 E1.40553 | ||
G1 X131.985 Y89.693 E18.19146 | ||
G92 E0 | ||
M104 S0 ; turn off temperature | ||
G28 X0 ; home X axis | ||
M84 ; disable motors | ||
M140 S0 ; turn off heated bed | ||
; filament used = 5172.5mm (16.2cm3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- # | ||
|
||
module Rouge | ||
module Lexers | ||
class GCode < RegexLexer | ||
tag 'gcode' | ||
aliases 'g-code', 'ngc' | ||
|
||
title "G-Code" | ||
desc 'A generic lexer for reprap/cnc g-code files' | ||
filenames '*.gco', '*.ngc', '*.gcode', '*.g' | ||
|
||
# short and sweet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is indeed short and sweet, but please remove |
||
state :root do | ||
rule /^N[0-9][0-9]*\s*/, Comment::Special | ||
rule /\;.*?\n/, Comment | ||
rule /\*[0-9][0-9]*\s*\;?/, Comment::Doc | ||
rule /^M117.*\n/, Keyword::Declaration | ||
rule /\s\s*/, Text::Whitespace | ||
rule /^G[0-9.][0-9.]*/, Keyword::Namespace | ||
rule /^M[0-9.][0-9.]*/, Keyword::Constant | ||
rule /[PSRTXYZJDHQW][+-]?[0-9.]*/, Keyword::Type | ||
rule /E[+-]?[0-9.]*/, Name::Variable | ||
rule /F[+-]?[0-9.]*/, Literal::String::Char | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- coding: utf-8 -*- # | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add '# frozen_string_literal: true' |
||
describe Rouge::Lexers::GCode do | ||
let(:subject) { Rouge::Lexers::GCode.new } | ||
|
||
describe 'guessing' do | ||
include Support::Guessing | ||
|
||
it 'guesses by filename' do | ||
assert_guess :filename => 'foo.gcode' | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add '# frozen_string_literal: true'