pax_global_header 0000666 0000000 0000000 00000000064 13407513353 0014516 g ustar 00root root 0000000 0000000 52 comment=b6d499de4e8686cba51a8cf1d3eb537794910d29
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/ 0000775 0000000 0000000 00000000000 13407513353 0023066 5 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/.gitattributes 0000664 0000000 0000000 00000000234 13407513353 0025760 0 ustar 00root root 0000000 0000000 # https://git-scm.com/docs/gitattributes
# *.cir text eol=lf
# *.lib text eol=lf
# *.mod text eol=lf
*.py text eol=lf
*.rst text eol=lf
*.yml text eol=lf
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/.github/ 0000775 0000000 0000000 00000000000 13407513353 0024426 5 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/.github/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000006243 13407513353 0027232 0 ustar 00root root 0000000 0000000 # Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at @project_name@ at domain name @domain@. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/.github/CONTRIBUTING.md 0000664 0000000 0000000 00000000252 13407513353 0026656 0 ustar 00root root 0000000 0000000 @project_name@ is an open-source project, and relies on its community of users to keep getting better.
To read further, look at this page @project_url@/development.html
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/.github/ISSUE_TEMPLATE.md 0000664 0000000 0000000 00000000234 13407513353 0027132 0 ustar 00root root 0000000 0000000 ### Environment (OS, Python version, @project_name@ version, simulator)
### Expected Behaviour
### Actual Behaviour
### Steps to reproduce the behaviour
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/.github/PULL_REQUEST_TEMPLATE.md 0000664 0000000 0000000 00000000022 13407513353 0030221 0 ustar 00root root 0000000 0000000 To be written ...
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/.github/SUPPORT.md 0000664 0000000 0000000 00000000227 13407513353 0026125 0 ustar 00root root 0000000 0000000 There is no mailing list or forum actually, so you can either contact me or fill an issue on Github.
If you encounter an issue, please fill an issue.
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/.gitignore 0000664 0000000 0000000 00000000041 13407513353 0025051 0 ustar 00root root 0000000 0000000 *~
__pycache__
doc/sphinx/build/
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/GPL-V3.0.txt 0000664 0000000 0000000 00000104513 13407513353 0024701 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/ 0000775 0000000 0000000 00000000000 13407513353 0027052 5 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/GCode/ 0000775 0000000 0000000 00000000000 13407513353 0030033 5 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/GCode/Lexer.py 0000664 0000000 0000000 00000012670 13407513353 0031472 0 ustar 00root root 0000000 0000000 ####################################################################################################
#
# PythonicGCodeMachine - @licence_header_description@
# Copyright (C) 2018 Fabrice Salvaire
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
####################################################################################################
####################################################################################################
import re
import PythonicGCodeMachine.Lexer as lexer
####################################################################################################
class GCodeLexerError(ValueError):
pass
####################################################################################################
class GCodeLexer:
"""Class to implement a CGode lexer.
For references, see
* The NIST RS274NGC Interpreter — Version 3 — Appendix E. Production Rules for the RS274/NGC Language
* http://linuxcnc.org/docs/2.7/html/gcode/overview.html
"""
# List of token names.
tokens = (
'ABSOLUTE_VALUE',
'AND',
'ARC_COSINE',
'ARC_SINE',
'ARC_TANGENT',
'COSINE',
'DECIMAL_POINT',
'DIVIDED_BY',
'EQUAL_SIGN',
'EXCLUSIVE_OR',
'E_RAISED_TO',
'FIX_DOWN',
'FIX_UP',
'LEFT_BRACKET',
'LEFT_PARENTHESIS',
'MINUS',
'MODULO',
'NATURAL_LOG_OF',
'NON_EXCLUSIVE_OR',
'PARAMETER_SIGN',
'PLUS',
'POWER',
'RIGHT_BRACKET',
'RIGHT_PARENTHESIS',
'ROUND',
'SINE',
'SQUARE_ROOT',
'TANGENT',
'TIMES',
'A', 'B', 'C', 'D',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'P', 'Q', 'R', 'S', 'T',
'X', 'Y', 'Z',
'POSITIVE_INTEGER',
'POSITIVE_REAL',
'REAL',
'INLINE_COMMENT',
'EOF_COMMENT',
)
# Regular expression rules for simple tokens
t_ABSOLUTE_VALUE = r'abs'
t_AND = r'and'
t_ARC_COSINE = r'acos'
t_ARC_SINE = r'asin'
t_ARC_TANGENT = r'atan'
# t_BLOCK_DELETE = r'\/'
t_COSINE = r'cos'
t_DECIMAL_POINT = r'\.'
t_DIVIDED_BY = r'\/'
t_EQUAL_SIGN = r'='
t_EXCLUSIVE_OR = r'xor'
t_E_RAISED_TO = r'exp'
t_FIX_DOWN = r'fix'
t_FIX_UP = r'fup'
t_LEFT_BRACKET = r'\['
t_LEFT_PARENTHESIS = r'\('
t_MINUS = r'-'
t_MODULO = r'mod'
t_NATURAL_LOG_OF = r'ln'
t_NON_EXCLUSIVE_OR = r'or'
t_PARAMETER_SIGN = r'\#'
t_PLUS = r'\+'
t_POWER = r'\*\*'
t_RIGHT_BRACKET = r'\]'
t_RIGHT_PARENTHESIS = r'\)'
t_ROUND = r'round'
t_SINE = r'sin'
t_SQUARE_ROOT = r'sqrt'
t_TANGENT = r'tan'
t_TIMES = r'\*'
t_A = r'a'
T_B = r'b'
t_C = r'c'
t_D = r'd'
t_F = r'f'
t_G = r'g'
t_H = r'h'
t_I = r'i'
t_J = r'j'
t_K = r'k'
t_L = r'l'
t_M = r'm'
t_N = r'n'
t_P = r'p'
t_Q = r'q'
t_R = r'r'
t_S = r's'
t_T = r't'
t_X = r'x'
t_Y = r'y'
t_Z = r'z'
# def t_POSITIVE_INTEGER(self, t):
# r'\d+'
# t.value = int(t.value)
# return t
# def t_POSITIVE_REAL(self, t):
# r'\d*\.\d+'
# t.value = float(t.value)
# return t
def t_REAL(self, t):
# r'((-)?((\d*\.\d+)(E[\+-]?\d+)?|([1-9]\d*E[\+-]?\d+)))'
r'((-)?\d*(\.)?\d+)'
value = t.value
if '.' in value:
value = float(value)
if value > 0:
t.type = 'POSITIVE_REAL'
else:
t.type = 'REAL'
else:
value = int(value)
t.type = 'POSITIVE_INTEGER'
t.value = value
return t
def t_INLINE_COMMENT(self, t):
r'\([^\)]*\)'
value = t.value[1:-1]
position = value.find('(')
if position != -1:
raise GCodeLexerError(t.lexpos + position +1)
t.value = value
return t
def t_EOF_COMMENT(self, t):
r';.*'
t.value = t.value[1:]
return t
# Ignored characters (spaces and tabs)
t_ignore = ' \t'
def t_error(self, t):
'Error handling rule'
# t.lexer.skip(1)
# raise GCodeLexerError("Illegal character @{} '{}'".format(t.lexpos, t.value))
raise GCodeLexerError(t.lexpos)
##############################################
def __init__(self):
self._build()
##############################################
def _build(self, **kwargs):
"""Build the lexer"""
self._lexer = lexer.lex(
module=self,
reflags=int(re.VERBOSE + re.IGNORECASE),
**kwargs,
)
##############################################
def tokenize(self, data):
self._lexer.input(data)
while True:
token = self._lexer.token()
if not token:
break
yield token
__init__.py 0000664 0000000 0000000 00000000000 13407513353 0032053 0 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/GCode pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Lexer/ 0000775 0000000 0000000 00000000000 13407513353 0030131 5 ustar 00root root 0000000 0000000 __init__.py 0000664 0000000 0000000 00000123361 13407513353 0032171 0 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Lexer ####################################################################################################
#
# Forked from David Beazley Python Lex-Yacc
# http://www.dabeaz.com/ply/index.html
# https://github.com/dabeaz/ply
#
# Fork purpose : We just need a fast Py3 lexer
#
# ply: lex.py
#
# Copyright (C) 2001-2018
# David M. Beazley (Dabeaz LLC)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the David Beazley or Dabeaz LLC may be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
####################################################################################################
# __version__ = '3.11'
__tabversion__ = '3.10'
####################################################################################################
import copy
import inspect
import os
import re
import sys
import types
####################################################################################################
# This regular expression is used to match valid token names
_is_identifier = re.compile(r'^[a-zA-Z0-9_]+$')
####################################################################################################
# Exception thrown when invalid token encountered and no default error handler is defined.
class LexError(Exception):
def __init__(self, message, s):
self.args = (message,)
self.text = s
####################################################################################################
class LexToken(object):
"""Token class. This class is used to represent the tokens produced."""
def __str__(self):
return 'LexToken(%s,%r,%d,%d)' % (self.type, self.value, self.lineno, self.lexpos)
def __repr__(self):
return str(self)
####################################################################################################
class PlyLogger(object):
"""This object is a stand-in for a logging object created by the logging module."""
def __init__(self, f):
self.f = f
def critical(self, msg, *args, **kwargs):
self.f.write((msg % args) + '\n')
def warning(self, msg, *args, **kwargs):
self.f.write('WARNING: ' + (msg % args) + '\n')
def error(self, msg, *args, **kwargs):
self.f.write('ERROR: ' + (msg % args) + '\n')
info = critical
debug = critical
class NullLogger(object):
"""Null logger is used when no output is generated. Does nothing."""
def __getattribute__(self, name):
return self
def __call__(self, *args, **kwargs):
return self
####################################################################################################
class Lexer:
"""Class to implement the Lexing Engine
The following Lexer class implements the lexer runtime. There are only a few public methods and
attributes:
* input() - Store a new string in the lexer
* token() - Get the next token
* clone() - Clone the lexer
* lineno - Current line number
* lexpos - Current position in the input string
"""
##############################################
def __init__(self):
self.lexre = None # Master regular expression. This is a list of
# tuples (re, findex) where re is a compiled
# regular expression and findex is a list
# mapping regex group numbers to rules
self.lexretext = None # Current regular expression strings
self.lexstatere = {} # Dictionary mapping lexer states to master regexs
self.lexstateretext = {} # Dictionary mapping lexer states to regex strings
self.lexstaterenames = {} # Dictionary mapping lexer states to symbol names
self.lexstate = 'INITIAL' # Current lexer state
self.lexstatestack = [] # Stack of lexer states
self.lexstateinfo = None # State information
self.lexstateignore = {} # Dictionary of ignored characters for each state
self.lexstateerrorf = {} # Dictionary of error functions for each state
self.lexstateeoff = {} # Dictionary of eof functions for each state
self.lexreflags = 0 # Optional re compile flags
self.lexdata = None # Actual input data (as a string)
self.lexpos = 0 # Current position in input text
self.lexlen = 0 # Length of the input text
self.lexerrorf = None # Error rule (if any)
self.lexeoff = None # EOF rule (if any)
self.lextokens = None # List of valid tokens
self.lexignore = '' # Ignored characters
self.lexliterals = '' # Literal characters that can be passed through
self.lexmodule = None # Module
self.lineno = 1 # Current line number
self.lexoptimize = False # Optimized mode
##############################################
def clone(self, object=None):
c = copy.copy(self)
# If the object parameter has been supplied, it means we are attaching the
# lexer to a new object. In this case, we have to rebind all methods in
# the lexstatere and lexstateerrorf tables.
if object:
newtab = {}
for key, ritem in self.lexstatere.items():
newre = []
for cre, findex in ritem:
newfindex = []
for f in findex:
if not f or not f[0]:
newfindex.append(f)
continue
newfindex.append((getattr(object, f[0].__name__), f[1]))
newre.append((cre, newfindex))
newtab[key] = newre
c.lexstatere = newtab
c.lexstateerrorf = {}
for key, ef in self.lexstateerrorf.items():
c.lexstateerrorf[key] = getattr(object, ef.__name__)
c.lexmodule = object
return c
##############################################
def writetab(self, lextab, outputdir=''):
"""Write lexer information to a table file"""
if isinstance(lextab, types.ModuleType):
raise IOError("Won't overwrite existing lextab module")
basetabmodule = lextab.split('.')[-1]
filename = os.path.join(outputdir, basetabmodule) + '.py'
with open(filename, 'w') as tf:
tf.write('# %s.py. This file automatically created by PLY (version %s). Don\'t edit!\n' % (basetabmodule, __version__))
tf.write('_tabversion = %s\n' % repr(__tabversion__))
tf.write('_lextokens = set(%s)\n' % repr(tuple(sorted(self.lextokens))))
tf.write('_lexreflags = %s\n' % repr(int(self.lexreflags)))
tf.write('_lexliterals = %s\n' % repr(self.lexliterals))
tf.write('_lexstateinfo = %s\n' % repr(self.lexstateinfo))
# Rewrite the lexstatere table, replacing function objects with function names
tabre = {}
for statename, lre in self.lexstatere.items():
titem = []
for (pat, func), retext, renames in zip(lre, self.lexstateretext[statename], self.lexstaterenames[statename]):
titem.append((retext, _funcs_to_names(func, renames)))
tabre[statename] = titem
tf.write('_lexstatere = %s\n' % repr(tabre))
tf.write('_lexstateignore = %s\n' % repr(self.lexstateignore))
taberr = {}
for statename, ef in self.lexstateerrorf.items():
taberr[statename] = ef.__name__ if ef else None
tf.write('_lexstateerrorf = %s\n' % repr(taberr))
tabeof = {}
for statename, ef in self.lexstateeoff.items():
tabeof[statename] = ef.__name__ if ef else None
tf.write('_lexstateeoff = %s\n' % repr(tabeof))
##############################################
def readtab(self, tabfile, fdict):
"""Read lexer information from a tab file"""
if isinstance(tabfile, types.ModuleType):
lextab = tabfile
else:
exec('import %s' % tabfile)
lextab = sys.modules[tabfile]
if getattr(lextab, '_tabversion', '0.0') != __tabversion__:
raise ImportError('Inconsistent PLY version')
self.lextokens = lextab._lextokens
self.lexreflags = lextab._lexreflags
self.lexliterals = lextab._lexliterals
self.lextokens_all = self.lextokens | set(self.lexliterals)
self.lexstateinfo = lextab._lexstateinfo
self.lexstateignore = lextab._lexstateignore
self.lexstatere = {}
self.lexstateretext = {}
for statename, lre in lextab._lexstatere.items():
titem = []
txtitem = []
for pat, func_name in lre:
titem.append((re.compile(pat, lextab._lexreflags), _names_to_funcs(func_name, fdict)))
self.lexstatere[statename] = titem
self.lexstateretext[statename] = txtitem
self.lexstateerrorf = {}
for statename, ef in lextab._lexstateerrorf.items():
self.lexstateerrorf[statename] = fdict[ef]
self.lexstateeoff = {}
for statename, ef in lextab._lexstateeoff.items():
self.lexstateeoff[statename] = fdict[ef]
self.begin('INITIAL')
##############################################
def input(self, s):
"""Push a new string into the lexer"""
# Pull off the first character to see if s looks like a string
c = s[:1]
if not isinstance(c, (str, bytes)):
raise ValueError('Expected a string')
self.lexdata = s
self.lexpos = 0
self.lexlen = len(s)
##############################################
def begin(self, state):
"""Changes the lexing state"""
if state not in self.lexstatere:
raise ValueError('Undefined state')
self.lexre = self.lexstatere[state]
self.lexretext = self.lexstateretext[state]
self.lexignore = self.lexstateignore.get(state, '')
self.lexerrorf = self.lexstateerrorf.get(state, None)
self.lexeoff = self.lexstateeoff.get(state, None)
self.lexstate = state
##############################################
def push_state(self, state):
"""Changes the lexing state and saves old on stack"""
self.lexstatestack.append(self.lexstate)
self.begin(state)
##############################################
def pop_state(self):
"""Restores the previous state"""
self.begin(self.lexstatestack.pop())
##############################################
def current_state(self):
"""Returns the current lexing state"""
return self.lexstate
##############################################
def skip(self, n):
"""Skip ahead n characters"""
self.lexpos += n
##############################################
def token(self):
"""Return the next token from the Lexer
Note: This function has been carefully implemented to be as fast as possible. Don't make
changes unless you really know what you are doing
"""
# Make local copies of frequently referenced attributes
lexpos = self.lexpos
lexlen = self.lexlen
lexignore = self.lexignore
lexdata = self.lexdata
while lexpos < lexlen:
# This code provides some short-circuit code for whitespace, tabs, and other ignored characters
if lexdata[lexpos] in lexignore:
lexpos += 1
continue
# Look for a regular expression match
for lexre, lexindexfunc in self.lexre:
m = lexre.match(lexdata, lexpos)
if not m:
continue
# Create a token for return
tok = LexToken()
tok.value = m.group()
tok.lineno = self.lineno
tok.lexpos = lexpos
i = m.lastindex
func, tok.type = lexindexfunc[i]
if not func:
# If no token type was set, it's an ignored token
if tok.type:
self.lexpos = m.end()
return tok
else:
lexpos = m.end()
break
lexpos = m.end()
# If token is processed by a function, call it
tok.lexer = self # Set additional attributes useful in token rules
self.lexmatch = m
self.lexpos = lexpos
newtok = func(tok)
# Every function must return a token, if nothing, we just move to next token
if not newtok:
lexpos = self.lexpos # This is here in case user has updated lexpos.
lexignore = self.lexignore # This is here in case there was a state change
break
# Verify type of the token. If not in the token map, raise an error
if not self.lexoptimize:
if newtok.type not in self.lextokens_all:
raise LexError("%s:%d: Rule '%s' returned an unknown token type '%s'" % (
func.__code__.co_filename, func.__code__.co_firstlineno,
func.__name__, newtok.type), lexdata[lexpos:])
return newtok
else:
# No match, see if in literals
if lexdata[lexpos] in self.lexliterals:
tok = LexToken()
tok.value = lexdata[lexpos]
tok.lineno = self.lineno
tok.type = tok.value
tok.lexpos = lexpos
self.lexpos = lexpos + 1
return tok
# No match. Call t_error() if defined.
if self.lexerrorf:
tok = LexToken()
tok.value = self.lexdata[lexpos:]
tok.lineno = self.lineno
tok.type = 'error'
tok.lexer = self
tok.lexpos = lexpos
self.lexpos = lexpos
newtok = self.lexerrorf(tok)
if lexpos == self.lexpos:
# Error method didn't change text position at all. This is an error.
raise LexError("Scanning error. Illegal character '%s'" % (lexdata[lexpos]), lexdata[lexpos:])
lexpos = self.lexpos
if not newtok:
continue
return newtok
self.lexpos = lexpos
raise LexError("Illegal character '%s' at index %d" % (lexdata[lexpos], lexpos), lexdata[lexpos:])
if self.lexeoff:
tok = LexToken()
tok.type = 'eof'
tok.value = ''
tok.lineno = self.lineno
tok.lexpos = lexpos
tok.lexer = self
self.lexpos = lexpos
newtok = self.lexeoff(tok)
return newtok
self.lexpos = lexpos + 1
if self.lexdata is None:
raise RuntimeError('No input string given with input()')
return None
##############################################
# Iterator interface
def __iter__(self):
return self
def next(self):
t = self.token()
if t is None:
raise StopIteration
return t
__next__ = next
####################################################################################################
#
# Lex Builder
#
# The functions and classes below are used to collect lexing information
# and build a Lexer object from it.
#
####################################################################################################
####################################################################################################
def _get_regex(func):
"""Returns the regular expression assigned to a function either as a doc string or as a .regex
attribute attached by the @TOKEN decorator.
"""
return getattr(func, 'regex', func.__doc__)
####################################################################################################
def get_caller_module_dict(levels):
"""This function returns a dictionary containing all of the symbols defined within a caller further
down the call stack. This is used to get the environment associated with the yacc() call if
none was provided.
"""
f = sys._getframe(levels)
ldict = f.f_globals.copy()
if f.f_globals != f.f_locals:
ldict.update(f.f_locals)
return ldict
####################################################################################################
def _funcs_to_names(funclist, namelist):
"""Given a list of regular expression functions, this converts it to a list suitable for output to a
table file
"""
result = []
for f, name in zip(funclist, namelist):
if f and f[0]:
result.append((name, f[1]))
else:
result.append(f)
return result
####################################################################################################
def _names_to_funcs(namelist, fdict):
"""Given a list of regular expression function names, this converts it back to functions.
"""
result = []
for n in namelist:
if n and n[0]:
result.append((fdict[n[0]], n[1]))
else:
result.append(n)
return result
####################################################################################################
def _form_master_re(relist, reflags, ldict, toknames):
"""This function takes a list of all of the regex components and attempts to form the master regular
expression. Given limitations in the Python re module, it may be necessary to break the master
regex into separate expressions.
"""
if not relist:
return []
regex = '|'.join(relist)
try:
lexre = re.compile(regex, reflags)
# Build the index to function map for the matching engine
lexindexfunc = [None] * (max(lexre.groupindex.values()) + 1)
lexindexnames = lexindexfunc[:]
for f, i in lexre.groupindex.items():
handle = ldict.get(f, None)
if type(handle) in (types.FunctionType, types.MethodType):
lexindexfunc[i] = (handle, toknames[f])
lexindexnames[i] = f
elif handle is not None:
lexindexnames[i] = f
if f.find('ignore_') > 0:
lexindexfunc[i] = (None, None)
else:
lexindexfunc[i] = (None, toknames[f])
return [(lexre, lexindexfunc)], [regex], [lexindexnames]
except Exception:
m = int(len(relist)/2)
if m == 0:
m = 1
llist, lre, lnames = _form_master_re(relist[:m], reflags, ldict, toknames)
rlist, rre, rnames = _form_master_re(relist[m:], reflags, ldict, toknames)
return (llist+rlist), (lre+rre), (lnames+rnames)
####################################################################################################
def _statetoken(s, names):
"""Given a declaration name s of the form "t_" and a dictionary whose keys are state names, this
function returns a tuple (states,tokenname) where states is a tuple of state names and tokenname
is the name of the token. For example, calling this with s = "t_foo_bar_SPAM" might return
(('foo','bar'),'SPAM')
"""
parts = s.split('_')
for i, part in enumerate(parts[1:], 1):
if part not in names and part != 'ANY':
break
if i > 1:
states = tuple(parts[1:i])
else:
states = ('INITIAL',)
if 'ANY' in states:
states = tuple(names)
tokenname = '_'.join(parts[i:])
return (states, tokenname)
####################################################################################################
class LexerReflect(object):
"""This class represents information needed to build a lexer as extracted from a user's input file.
"""
##############################################
def __init__(self, ldict, log=None, reflags=0):
self.ldict = ldict
self.error_func = None
self.tokens = []
self.reflags = reflags
self.stateinfo = {'INITIAL': 'inclusive'}
self.modules = set()
self.error = False
self.log = PlyLogger(sys.stderr) if log is None else log
##############################################
def get_all(self):
"""Get all of the basic information"""
self.get_tokens()
self.get_literals()
self.get_states()
self.get_rules()
##############################################
def validate_all(self):
"""Validate all of the information"""
self.validate_tokens()
self.validate_literals()
self.validate_rules()
return self.error
##############################################
def get_tokens(self):
""" Get the tokens map"""
tokens = self.ldict.get('tokens', None)
if not tokens:
self.log.error('No token list is defined')
self.error = True
return
if not isinstance(tokens, (list, tuple)):
self.log.error('tokens must be a list or tuple')
self.error = True
return
if not tokens:
self.log.error('tokens is empty')
self.error = True
return
self.tokens = tokens
##############################################
def validate_tokens(self):
"""Validate the tokens"""
terminals = {}
for n in self.tokens:
if not _is_identifier.match(n):
self.log.error("Bad token name '%s'", n)
self.error = True
if n in terminals:
self.log.warning("Token '%s' multiply defined", n)
terminals[n] = 1
##############################################
def get_literals(self):
"""Get the literals specifier"""
self.literals = self.ldict.get('literals', '')
if not self.literals:
self.literals = ''
##############################################
def validate_literals(self):
"""Validate literals"""
try:
for c in self.literals:
if not isinstance(c, (str, bytes)) or len(c) > 1:
self.log.error('Invalid literal %s. Must be a single character', repr(c))
self.error = True
except TypeError:
self.log.error('Invalid literals specification. literals must be a sequence of characters')
self.error = True
##############################################
def get_states(self):
self.states = self.ldict.get('states', None)
# Build statemap
if self.states:
if not isinstance(self.states, (tuple, list)):
self.log.error('states must be defined as a tuple or list')
self.error = True
else:
for s in self.states:
if not isinstance(s, tuple) or len(s) != 2:
self.log.error("Invalid state specifier %s. Must be a tuple (statename,'exclusive|inclusive')", repr(s))
self.error = True
continue
name, statetype = s
if not isinstance(name, (str, bytes)):
self.log.error('State name %s must be a string', repr(name))
self.error = True
continue
if not (statetype == 'inclusive' or statetype == 'exclusive'):
self.log.error("State type for state %s must be 'inclusive' or 'exclusive'", name)
self.error = True
continue
if name in self.stateinfo:
self.log.error("State '%s' already defined", name)
self.error = True
continue
self.stateinfo[name] = statetype
##############################################
def get_rules(self):
"""Get all of the symbols with a t_ prefix and sort them into various categories (functions,
strings, error functions, and ignore characters)
"""
tsymbols = [f for f in self.ldict if f[:2] == 't_']
# Now build up a list of functions and a list of strings
self.toknames = {} # Mapping of symbols to token names
self.funcsym = {} # Symbols defined as functions
self.strsym = {} # Symbols defined as strings
self.ignore = {} # Ignore strings by state
self.errorf = {} # Error functions by state
self.eoff = {} # EOF functions by state
for s in self.stateinfo:
self.funcsym[s] = []
self.strsym[s] = []
if len(tsymbols) == 0:
self.log.error('No rules of the form t_rulename are defined')
self.error = True
return
for f in tsymbols:
t = self.ldict[f]
states, tokname = _statetoken(f, self.stateinfo)
self.toknames[f] = tokname
if hasattr(t, '__call__'):
if tokname == 'error':
for s in states:
self.errorf[s] = t
elif tokname == 'eof':
for s in states:
self.eoff[s] = t
elif tokname == 'ignore':
line = t.__code__.co_firstlineno
file = t.__code__.co_filename
self.log.error("%s:%d: Rule '%s' must be defined as a string", file, line, t.__name__)
self.error = True
else:
for s in states:
self.funcsym[s].append((f, t))
elif isinstance(t, (str, bytes)):
if tokname == 'ignore':
for s in states:
self.ignore[s] = t
if '\\' in t:
self.log.warning("%s contains a literal backslash '\\'", f)
elif tokname == 'error':
self.log.error("Rule '%s' must be defined as a function", f)
self.error = True
else:
for s in states:
self.strsym[s].append((f, t))
else:
self.log.error('%s not defined as a function or string', f)
self.error = True
# Sort the functions by line number
for f in self.funcsym.values():
f.sort(key=lambda x: x[1].__code__.co_firstlineno)
# Sort the strings by regular expression length
for s in self.strsym.values():
s.sort(key=lambda x: len(x[1]), reverse=True)
##############################################
def validate_rules(self):
""" Validate all of the t_rules collected"""
for state in self.stateinfo:
# Validate all rules defined by functions
for fname, f in self.funcsym[state]:
line = f.__code__.co_firstlineno
file = f.__code__.co_filename
module = inspect.getmodule(f)
self.modules.add(module)
tokname = self.toknames[fname]
if isinstance(f, types.MethodType):
reqargs = 2
else:
reqargs = 1
nargs = f.__code__.co_argcount
if nargs > reqargs:
self.log.error("%s:%d: Rule '%s' has too many arguments", file, line, f.__name__)
self.error = True
continue
if nargs < reqargs:
self.log.error("%s:%d: Rule '%s' requires an argument", file, line, f.__name__)
self.error = True
continue
if not _get_regex(f):
self.log.error("%s:%d: No regular expression defined for rule '%s'", file, line, f.__name__)
self.error = True
continue
try:
c = re.compile('(?P<%s>%s)' % (fname, _get_regex(f)), self.reflags)
if c.match(''):
self.log.error("%s:%d: Regular expression for rule '%s' matches empty string", file, line, f.__name__)
self.error = True
except re.error as e:
self.log.error("%s:%d: Invalid regular expression for rule '%s'. %s", file, line, f.__name__, e)
if '#' in _get_regex(f):
self.log.error("%s:%d. Make sure '#' in rule '%s' is escaped with '\\#'", file, line, f.__name__)
self.error = True
# Validate all rules defined by strings
for name, r in self.strsym[state]:
tokname = self.toknames[name]
if tokname == 'error':
self.log.error("Rule '%s' must be defined as a function", name)
self.error = True
continue
if tokname not in self.tokens and tokname.find('ignore_') < 0:
self.log.error("Rule '%s' defined for an unspecified token %s", name, tokname)
self.error = True
continue
try:
c = re.compile('(?P<%s>%s)' % (name, r), self.reflags)
if (c.match('')):
self.log.error("Regular expression for rule '%s' matches empty string", name)
self.error = True
except re.error as e:
self.log.error("Invalid regular expression for rule '%s'. %s", name, e)
if '#' in r:
self.log.error("Make sure '#' in rule '%s' is escaped with '\\#'", name)
self.error = True
if not self.funcsym[state] and not self.strsym[state]:
self.log.error("No rules defined for state '%s'", state)
self.error = True
# Validate the error function
efunc = self.errorf.get(state, None)
if efunc:
f = efunc
line = f.__code__.co_firstlineno
file = f.__code__.co_filename
module = inspect.getmodule(f)
self.modules.add(module)
if isinstance(f, types.MethodType):
reqargs = 2
else:
reqargs = 1
nargs = f.__code__.co_argcount
if nargs > reqargs:
self.log.error("%s:%d: Rule '%s' has too many arguments", file, line, f.__name__)
self.error = True
if nargs < reqargs:
self.log.error("%s:%d: Rule '%s' requires an argument", file, line, f.__name__)
self.error = True
for module in self.modules:
self.validate_module(module)
##############################################
def validate_module(self, module):
"""" This checks to see if there are duplicated t_rulename() functions or strings in the parser
input file. This is done using a simple regular expression match on each line in the
source code of the given module.
"""
try:
lines, linen = inspect.getsourcelines(module)
except IOError:
return
fre = re.compile(r'\s*def\s+(t_[a-zA-Z_0-9]*)\(')
sre = re.compile(r'\s*(t_[a-zA-Z_0-9]*)\s*=')
counthash = {}
linen += 1
for line in lines:
m = fre.match(line)
if not m:
m = sre.match(line)
if m:
name = m.group(1)
prev = counthash.get(name)
if not prev:
counthash[name] = linen
else:
filename = inspect.getsourcefile(module)
self.log.error('%s:%d: Rule %s redefined. Previously defined on line %d', filename, linen, name, prev)
self.error = True
linen += 1
####################################################################################################
#
# lex(module)
#
# Build all of the regular expression rules from definitions in the supplied module
def lex(module=None,
object=None,
debug=False,
optimize=False,
lextab='lextab',
reflags=int(re.VERBOSE),
nowarn=False,
outputdir=None,
debuglog=None,
errorlog=None,
):
if lextab is None:
lextab = 'lextab'
global lexer
ldict = None
stateinfo = {'INITIAL': 'inclusive'}
lexobj = Lexer()
lexobj.lexoptimize = optimize
global token, input
if errorlog is None:
errorlog = PlyLogger(sys.stderr)
if debug:
if debuglog is None:
debuglog = PlyLogger(sys.stderr)
# Get the module dictionary used for the lexer
if object:
module = object
# Get the module dictionary used for the parser
if module:
_items = [(k, getattr(module, k)) for k in dir(module)]
ldict = dict(_items)
# If no __file__ attribute is available, try to obtain it from the __module__ instead
if '__file__' not in ldict:
ldict['__file__'] = sys.modules[ldict['__module__']].__file__
else:
ldict = get_caller_module_dict(2)
# Determine if the module is package of a package or not.
# If so, fix the tabmodule setting so that tables load correctly
pkg = ldict.get('__package__')
if pkg and isinstance(lextab, str):
if '.' not in lextab:
lextab = pkg + '.' + lextab
# Collect parser information from the dictionary
linfo = LexerReflect(ldict, log=errorlog, reflags=reflags)
linfo.get_all()
if not optimize:
if linfo.validate_all():
raise SyntaxError("Can't build lexer")
if optimize and lextab:
try:
lexobj.readtab(lextab, ldict)
token = lexobj.token
input = lexobj.input
lexer = lexobj
return lexobj
except ImportError:
pass
# Dump some basic debugging information
if debug:
debuglog.info('lex: tokens = %r', linfo.tokens)
debuglog.info('lex: literals = %r', linfo.literals)
debuglog.info('lex: states = %r', linfo.stateinfo)
# Build a dictionary of valid token names
lexobj.lextokens = set()
for n in linfo.tokens:
lexobj.lextokens.add(n)
# Get literals specification
if isinstance(linfo.literals, (list, tuple)):
lexobj.lexliterals = type(linfo.literals[0])().join(linfo.literals)
else:
lexobj.lexliterals = linfo.literals
lexobj.lextokens_all = lexobj.lextokens | set(lexobj.lexliterals)
# Get the stateinfo dictionary
stateinfo = linfo.stateinfo
regexs = {}
# Build the master regular expressions
for state in stateinfo:
regex_list = []
# Add rules defined by functions first
for fname, f in linfo.funcsym[state]:
regex_list.append('(?P<%s>%s)' % (fname, _get_regex(f)))
if debug:
debuglog.info("lex: Adding rule %s -> '%s' (state '%s')", fname, _get_regex(f), state)
# Now add all of the simple rules
for name, r in linfo.strsym[state]:
regex_list.append('(?P<%s>%s)' % (name, r))
if debug:
debuglog.info("lex: Adding rule %s -> '%s' (state '%s')", name, r, state)
regexs[state] = regex_list
# Build the master regular expressions
if debug:
debuglog.info('lex: ==== MASTER REGEXS FOLLOW ====')
for state in regexs:
lexre, re_text, re_names = _form_master_re(regexs[state], reflags, ldict, linfo.toknames)
lexobj.lexstatere[state] = lexre
lexobj.lexstateretext[state] = re_text
lexobj.lexstaterenames[state] = re_names
if debug:
for i, text in enumerate(re_text):
debuglog.info("lex: state '%s' : regex[%d] = '%s'", state, i, text)
# For inclusive states, we need to add the regular expressions from the INITIAL state
for state, stype in stateinfo.items():
if state != 'INITIAL' and stype == 'inclusive':
lexobj.lexstatere[state].extend(lexobj.lexstatere['INITIAL'])
lexobj.lexstateretext[state].extend(lexobj.lexstateretext['INITIAL'])
lexobj.lexstaterenames[state].extend(lexobj.lexstaterenames['INITIAL'])
lexobj.lexstateinfo = stateinfo
lexobj.lexre = lexobj.lexstatere['INITIAL']
lexobj.lexretext = lexobj.lexstateretext['INITIAL']
lexobj.lexreflags = reflags
# Set up ignore variables
lexobj.lexstateignore = linfo.ignore
lexobj.lexignore = lexobj.lexstateignore.get('INITIAL', '')
# Set up error functions
lexobj.lexstateerrorf = linfo.errorf
lexobj.lexerrorf = linfo.errorf.get('INITIAL', None)
if not lexobj.lexerrorf:
errorlog.warning('No t_error rule is defined')
# Set up eof functions
lexobj.lexstateeoff = linfo.eoff
lexobj.lexeoff = linfo.eoff.get('INITIAL', None)
# Check state information for ignore and error rules
for s, stype in stateinfo.items():
if stype == 'exclusive':
if s not in linfo.errorf:
errorlog.warning("No error rule is defined for exclusive state '%s'", s)
if s not in linfo.ignore and lexobj.lexignore:
errorlog.warning("No ignore rule is defined for exclusive state '%s'", s)
elif stype == 'inclusive':
if s not in linfo.errorf:
linfo.errorf[s] = linfo.errorf.get('INITIAL', None)
if s not in linfo.ignore:
linfo.ignore[s] = linfo.ignore.get('INITIAL', '')
# Create global versions of the token() and input() functions
token = lexobj.token
input = lexobj.input
lexer = lexobj
# If in optimize mode, we write the lextab
if lextab and optimize:
if outputdir is None:
# If no output directory is set, the location of the output files
# is determined according to the following rules:
# - If lextab specifies a package, files go into that package directory
# - Otherwise, files go in the same directory as the specifying module
if isinstance(lextab, types.ModuleType):
srcfile = lextab.__file__
else:
if '.' not in lextab:
srcfile = ldict['__file__']
else:
parts = lextab.split('.')
pkgname = '.'.join(parts[:-1])
exec('import %s' % pkgname)
srcfile = getattr(sys.modules[pkgname], '__file__', '')
outputdir = os.path.dirname(srcfile)
try:
lexobj.writetab(lextab, outputdir)
if lextab in sys.modules:
del sys.modules[lextab]
except IOError as e:
errorlog.warning("Couldn't write lextab module %r. %s" % (lextab, e))
return lexobj
####################################################################################################
#
# runmain()
#
# This runs the lexer as a main program
# def runmain(lexer=None, data=None):
# if not data:
# try:
# filename = sys.argv[1]
# f = open(filename)
# data = f.read()
# f.close()
# except IndexError:
# sys.stdout.write('Reading from standard input (type EOF to end):\n')
# data = sys.stdin.read()
# if lexer:
# _input = lexer.input
# else:
# _input = input
# _input(data)
# if lexer:
# _token = lexer.token
# else:
# _token = token
# while True:
# tok = _token()
# if not tok:
# break
# sys.stdout.write('(%s,%r,%d,%d)\n' % (tok.type, tok.value, tok.lineno, tok.lexpos))
####################################################################################################
#
# @TOKEN(regex)
#
# This decorator function can be used to set the regex expression on a function
# when its docstring might need to be set in an alternative way
def TOKEN(r):
def set_regex(f):
if hasattr(r, '__call__'):
f.regex = _get_regex(r)
else:
f.regex = r
return f
return set_regex
# Alternative spelling of the TOKEN decorator
Token = TOKEN
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Machine/ 0000775 0000000 0000000 00000000000 13407513353 0030416 5 ustar 00root root 0000000 0000000 __init__.py 0000664 0000000 0000000 00000000000 13407513353 0032436 0 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Machine pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Machine/data/ 0000775 0000000 0000000 00000000000 13407513353 0031327 5 ustar 00root root 0000000 0000000 make-yaml.py 0000775 0000000 0000000 00000015631 13407513353 0033510 0 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Machine/data #! /usr/bin/env python3
####################################################################################################
import pathlib
import yaml
####################################################################################################
dst_path = pathlib.Path(__file__).parent
####################################################################################################
def split_columns(*columns):
return zip(*[x.strip().split('\n') for x in columns])
def write_yaml(filename, data):
dst_file = dst_path.joinpath(filename)
yaml_data = yaml.dump(data, default_flow_style=False)
with (open(dst_file, 'w')) as fh:
fh.write(yaml_data)
print('Dumped', dst_file)
####################################################################################################
# cf. Table 2. Default Parameter File
parameters = '''
5161
5162
5163
5164
5165
5166
5181
5182
5183
5184
5185
5186
5211
5212
5213
5214
5215
5216
5220
5221
5222
5223
5224
5225
5226
5241
5242
5243
5244
5245
5246
5261
5262
5263
5264
5265
5266
5281
5282
5283
5284
5285
5286
5301
5302
5303
5304
5305
5306
5321
5322
5323
5324
5325
5326
5341
5342
5343
5344
5345
5346
5361
5362
5363
5364
5365
5366
5381
5382
5383
5384
5385
5386
'''
values = '''
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
'''
comments = '''
G28 home X
G28 home Y
G28 home Z
G28 home A
G28 home B
G28 home C
G30 home X
G30 home Y
G30 home Z
G30 home A
G30 home B
G30 home C
G92 offset X
G92 offset Y
G92 offset Z
G92 offset A
G92 offset B
G92 offset C
coord. system number
coord. system 1 X
coord. system 1 Y
coord. system 1 Z
coord. system 1 A
coord. system 1 B
coord. system 1 C
coord. system 2 X
coord. system 2 Y
coord. system 2 Z
coord. system 2 A
coord. system 2 B
coord. system 2 C
coord. system 3 X
coord. system 3 Y
coord. system 3 Z
coord. system 3 A
coord. system 3 B
coord. system 3 C
coord. system 4 X
coord. system 4 Y
coord. system 4 Z
coord. system 4 A
coord. system 4 B
coord. system 4 C
coord. system 5 X
coord. system 5 Y
coord. system 5 Z
coord. system 5 A
coord. system 5 B
coord. system 5 C
coord. system 6 X
coord. system 6 Y
coord. system 6 Z
coord. system 6 A
coord. system 6 B
coord. system 6 C
coord. system 7 X
coord. system 7 Y
coord. system 7 Z
coord. system 7 A
coord. system 7 B
coord. system 7 C
coord. system 8 X
coord. system 8 Y
coord. system 8 Z
coord. system 8 A
coord. system 8 B
coord. system 8 C
coord. system 9 X
coord. system 9 Y
coord. system 9 Z
coord. system 9 A
coord. system 9 B
coord. system 9 C
'''
####################################################################################################
data = {}
for parameter, value, comment in split_columns(parameters, values, comments):
comment = comment.replace('coord.', 'coordinate')
data[int(parameter)] = dict(value=float(value), meaning=comment)
write_yaml('rs274-default-parameter-file.yaml', data)
####################################################################################################
# Table 3. Word-starting Letters
letters = '''
A
B
C
D
F
G
H
I
J
K
L
M
N
P
Q
R
S
T
X
Y
Z
'''
meanings = '''
A-axis of machine
B-axis of machine
C-axis of machine
tool radius compensation number
feedrate
general function (see Table 5)
tool length offset index
X-axis offset for arcs
X offset in G87 canned cycle
Y-axis offset for arcs
Y offset in G87 canned cycle
Z-axis offset for arcs
Z offset in G87 canned cycle
number of repetitions in canned cycles
key used with G10
miscellaneous function (see Table 7)
line number
dwell time in canned cycles
dwell time with G4
key used with G10
feed increment in G83 canned cycle
arc radius
canned cycle plane
spindle speed
tool selection
X-axis of machine
Y-axis of machine
Z-axis of machine
'''
####################################################################################################
data = {}
for letter, meaning in split_columns(letters, meanings):
data[letter] = dict(meaning=meaning)
write_yaml('rs274-word-starting-letter.yaml', data)
####################################################################################################
# Table 5. G Codes
# Table 7. M Codes
# 3.7 Other Input Codes
gcodes = '''
G0
G1
G2
G3
G4
G10
G17
G18
G19
G20
G21
G28
G30
G38.2
G40
G41
G42
G43
G49
G53
G54
G55
G56
G57
G58
G59
G59.1
G59.2
G59.3
G61
G61.1
G64
G80
G81
G82
G83
G84
G85
G86
G87
G88
G89
G90
G91
G92
G92.1
G92.2
G92.3
G93
G94
G98
G99
M0
M1
M2
M3
M4
M5
M6
M7
M8
M9
M30
M48
M49
M60
F
S
T
'''
meanings = '''
rapid positioning
linear interpolation
circular/helical interpolation (clockwise)
circular/helical interpolation (counterclockwise)
dwell
coordinate system origin setting
XY-plane selection
XZ-plane selection
YZ-plane selection
inch system selection
millimeter system selection
return to home
return to secondary home
straight probe
cancel cutter radius compensation
start cutter radius compensation left
start cutter radius compensation right
tool length offset (plus)
cancel tool length offset
motion in machine coordinate system
use preset work coordinate system 1
use preset work coordinate system 2
use preset work coordinate system 3
use preset work coordinate system 4
use preset work coordinate system 5
use preset work coordinate system 6
use preset work coordinate system 7
use preset work coordinate system 8
use preset work coordinate system 9
set path control mode: exact path
set path control mode: exact stop
set path control mode: continuous
cancel motion mode (including any canned cycle)
canned cycle: drilling
canned cycle: drilling with dwell
canned cycle: peck drilling
canned cycle: right hand tapping
canned cycle: boring, no dwell, feed out
canned cycle: boring, spindle stop, rapid out
canned cycle: back boring
canned cycle: boring, spindle stop, manual out
canned cycle: boring, dwell, feed out
absolute distance mode
incremental distance mode
offset coordinate systems and set parameters
cancel offset coordinate systems and set parameters to zero
cancel offset coordinate systems but do not reset parameters
apply parameters to offset coordinate systems
inverse time feed rate mode
units per minute feed rate mode
initial level return in canned cycles
R-point level return in canned cycles
program stop
optional program stop
program end
turn spindle clockwise
turn spindle counterclockwise
stop spindle turning
tool change
mist coolant on
flood coolant on
mist and flood coolant off
program end, pallet shuttle, and reset
enable speed and feed overrides
disable speed and feed overrides
pallet shuttle and program stop
set feed rate
set spindle speed
select tool
'''
####################################################################################################
data = {}
for gcode, meaning in split_columns(gcodes, meanings):
data[gcode] = dict(meaning=meaning)
write_yaml('rs274-gcodes.yaml', data)
rs274-default-parameter-file.yaml 0000664 0000000 0000000 00000007035 13407513353 0037337 0 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Machine/data 5161:
meaning: G28 home X
value: 0.0
5162:
meaning: G28 home Y
value: 0.0
5163:
meaning: G28 home Z
value: 0.0
5164:
meaning: G28 home A
value: 0.0
5165:
meaning: G28 home B
value: 0.0
5166:
meaning: G28 home C
value: 0.0
5181:
meaning: G30 home X
value: 0.0
5182:
meaning: G30 home Y
value: 0.0
5183:
meaning: G30 home Z
value: 0.0
5184:
meaning: G30 home A
value: 0.0
5185:
meaning: G30 home B
value: 0.0
5186:
meaning: G30 home C
value: 0.0
5211:
meaning: G92 offset X
value: 0.0
5212:
meaning: G92 offset Y
value: 0.0
5213:
meaning: G92 offset Z
value: 0.0
5214:
meaning: G92 offset A
value: 0.0
5215:
meaning: G92 offset B
value: 0.0
5216:
meaning: G92 offset C
value: 0.0
5220:
meaning: coordinate system number
value: 1.0
5221:
meaning: coordinate system 1 X
value: 0.0
5222:
meaning: coordinate system 1 Y
value: 0.0
5223:
meaning: coordinate system 1 Z
value: 0.0
5224:
meaning: coordinate system 1 A
value: 0.0
5225:
meaning: coordinate system 1 B
value: 0.0
5226:
meaning: coordinate system 1 C
value: 0.0
5241:
meaning: coordinate system 2 X
value: 0.0
5242:
meaning: coordinate system 2 Y
value: 0.0
5243:
meaning: coordinate system 2 Z
value: 0.0
5244:
meaning: coordinate system 2 A
value: 0.0
5245:
meaning: coordinate system 2 B
value: 0.0
5246:
meaning: coordinate system 2 C
value: 0.0
5261:
meaning: coordinate system 3 X
value: 0.0
5262:
meaning: coordinate system 3 Y
value: 0.0
5263:
meaning: coordinate system 3 Z
value: 0.0
5264:
meaning: coordinate system 3 A
value: 0.0
5265:
meaning: coordinate system 3 B
value: 0.0
5266:
meaning: coordinate system 3 C
value: 0.0
5281:
meaning: coordinate system 4 X
value: 0.0
5282:
meaning: coordinate system 4 Y
value: 0.0
5283:
meaning: coordinate system 4 Z
value: 0.0
5284:
meaning: coordinate system 4 A
value: 0.0
5285:
meaning: coordinate system 4 B
value: 0.0
5286:
meaning: coordinate system 4 C
value: 0.0
5301:
meaning: coordinate system 5 X
value: 0.0
5302:
meaning: coordinate system 5 Y
value: 0.0
5303:
meaning: coordinate system 5 Z
value: 0.0
5304:
meaning: coordinate system 5 A
value: 0.0
5305:
meaning: coordinate system 5 B
value: 0.0
5306:
meaning: coordinate system 5 C
value: 0.0
5321:
meaning: coordinate system 6 X
value: 0.0
5322:
meaning: coordinate system 6 Y
value: 0.0
5323:
meaning: coordinate system 6 Z
value: 0.0
5324:
meaning: coordinate system 6 A
value: 0.0
5325:
meaning: coordinate system 6 B
value: 0.0
5326:
meaning: coordinate system 6 C
value: 0.0
5341:
meaning: coordinate system 7 X
value: 0.0
5342:
meaning: coordinate system 7 Y
value: 0.0
5343:
meaning: coordinate system 7 Z
value: 0.0
5344:
meaning: coordinate system 7 A
value: 0.0
5345:
meaning: coordinate system 7 B
value: 0.0
5346:
meaning: coordinate system 7 C
value: 0.0
5361:
meaning: coordinate system 8 X
value: 0.0
5362:
meaning: coordinate system 8 Y
value: 0.0
5363:
meaning: coordinate system 8 Z
value: 0.0
5364:
meaning: coordinate system 8 A
value: 0.0
5365:
meaning: coordinate system 8 B
value: 0.0
5366:
meaning: coordinate system 8 C
value: 0.0
5381:
meaning: coordinate system 9 X
value: 0.0
5382:
meaning: coordinate system 9 Y
value: 0.0
5383:
meaning: coordinate system 9 Z
value: 0.0
5384:
meaning: coordinate system 9 A
value: 0.0
5385:
meaning: coordinate system 9 B
value: 0.0
5386:
meaning: coordinate system 9 C
value: 0.0
rs274-execution-order.yaml 0000664 0000000 0000000 00000001665 13407513353 0036137 0 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Machine/data # Table 8. Order of Execution
1: COMMENT # (includes message]
2: [G93, G94] # set feed rate mode (inverse time or per minute]
3: F # set feed rate
4: S # set spindle speed
5: T # select tool
6: M6 # change tool
7: [M3, M4, M5] # spindle on or off
8: [M7, M8, M9] # coolant on or off
9: [M48, M49] # enable or disable overrides
10: G4 # dwell
11: [G17, G18, G19] # set active plane
12: [G20, G21] # set length units
13: [G40, G41, G42] # cutter radius compensation on or off
14: [G43, G49] # cutter length compensation on or off
15: [G54, G55, G56, G57, G58, G59, G59.1, G59.2, G59.3] # coordinate system selection
16: [G61, G61.1, G64] # set path control mode
17: [G90, G91] # set distance mode
18: [G98, G99] # set retract mode
19: [G28, G30, G10, G92, G92.1, G92.2, G94] # home or change coordinate system data or set axis offsets
20: ['G0-G3', 'G80-G89', G53] # perform motion, as modified (possibly) by G53
21: [M0, M1, M2, M30, M60] # stop
rs274-gcodes.yaml 0000664 0000000 0000000 00000006217 13407513353 0034265 0 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Machine/data F:
meaning: set feed rate
G0:
meaning: rapid positioning
G1:
meaning: linear interpolation
G10:
meaning: coordinate system origin setting
G17:
meaning: XY-plane selection
G18:
meaning: XZ-plane selection
G19:
meaning: YZ-plane selection
G2:
meaning: circular/helical interpolation (clockwise)
G20:
meaning: inch system selection
G21:
meaning: millimeter system selection
G28:
meaning: return to home
G3:
meaning: circular/helical interpolation (counterclockwise)
G30:
meaning: return to secondary home
G38.2:
meaning: straight probe
G4:
meaning: dwell
G40:
meaning: cancel cutter radius compensation
G41:
meaning: start cutter radius compensation left
G42:
meaning: start cutter radius compensation right
G43:
meaning: tool length offset (plus)
G49:
meaning: cancel tool length offset
G53:
meaning: motion in machine coordinate system
G54:
meaning: use preset work coordinate system 1
G55:
meaning: use preset work coordinate system 2
G56:
meaning: use preset work coordinate system 3
G57:
meaning: use preset work coordinate system 4
G58:
meaning: use preset work coordinate system 5
G59:
meaning: use preset work coordinate system 6
G59.1:
meaning: use preset work coordinate system 7
G59.2:
meaning: use preset work coordinate system 8
G59.3:
meaning: use preset work coordinate system 9
G61:
meaning: 'set path control mode: exact path'
G61.1:
meaning: 'set path control mode: exact stop'
G64:
meaning: 'set path control mode: continuous'
G80:
meaning: cancel motion mode (including any canned cycle)
G81:
meaning: 'canned cycle: drilling'
G82:
meaning: 'canned cycle: drilling with dwell'
G83:
meaning: 'canned cycle: peck drilling'
G84:
meaning: 'canned cycle: right hand tapping'
G85:
meaning: 'canned cycle: boring, no dwell, feed out'
G86:
meaning: 'canned cycle: boring, spindle stop, rapid out'
G87:
meaning: 'canned cycle: back boring'
G88:
meaning: 'canned cycle: boring, spindle stop, manual out'
G89:
meaning: 'canned cycle: boring, dwell, feed out'
G90:
meaning: absolute distance mode
G91:
meaning: incremental distance mode
G92:
meaning: offset coordinate systems and set parameters
G92.1:
meaning: cancel offset coordinate systems and set parameters to zero
G92.2:
meaning: cancel offset coordinate systems but do not reset parameters
G92.3:
meaning: apply parameters to offset coordinate systems
G93:
meaning: inverse time feed rate mode
G94:
meaning: units per minute feed rate mode
G98:
meaning: initial level return in canned cycles
G99:
meaning: R-point level return in canned cycles
M0:
meaning: program stop
M1:
meaning: optional program stop
M2:
meaning: program end
M3:
meaning: turn spindle clockwise
M30:
meaning: program end, pallet shuttle, and reset
M4:
meaning: turn spindle counterclockwise
M48:
meaning: enable speed and feed overrides
M49:
meaning: disable speed and feed overrides
M5:
meaning: stop spindle turning
M6:
meaning: tool change
M60:
meaning: pallet shuttle and program stop
M7:
meaning: mist coolant on
M8:
meaning: flood coolant on
M9:
meaning: mist and flood coolant off
S:
meaning: set spindle speed
T:
meaning: select tool
rs274-modal-groups.yaml 0000664 0000000 0000000 00000001651 13407513353 0035427 0 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Machine/data # Table 4. Modal Groups
# The modal groups for G codes are
1: [G0, G1, G2, G3, G38.2, G80, G81, G82, G83, G84, G85, G86, G87, G88, G89]
2 : [G17, G18, G19] # plane selection
3 : [G90, G91] # distance mode
5 : [G93, G94] # feed rate mode
6 : [G20, G21] # units
7 : [G40, G41, G42] # cutter radius compensation
8 : [G43, G49] # tool length offset
10 : [G98, G99] # return mode in canned cycles
12 : [G54, G55, G56, G57, G58, G59, G59.1, G59.2, G59.3] # coordinate system selection
13 : [G61, G61.1, G64] # path control mode
# The modal groups for M codes are
4 : [M0, M1, M2, M30, M60] # stopping
6 : [M6] # tool change
7 : [M3, M4, M5] # spindle turning
8 : [M7, M8, M9] # coolant (special case: M7 and M8 may be active at the same time)
9 : [M48, M49] # enable/disable feed and speed override switches
# In addition to the above modal groups, there is a group for non-modal G codes
0 : [G4, G10, G28, G30, G53, G92, G92.1, G92.2, G92.3]
rs274-word-starting-letter.yaml 0000664 0000000 0000000 00000001447 13407513353 0037122 0 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/Machine/data A:
meaning: A-axis of machine
B:
meaning: B-axis of machine
C:
meaning: C-axis of machine
D:
meaning: tool radius compensation number
F:
meaning: feedrate
G:
meaning: general function (see Table 5)
H:
meaning: tool length offset index
I:
meaning: X-axis offset for arcs
J:
meaning: X offset in G87 canned cycle
K:
meaning: Y-axis offset for arcs
L:
meaning: Y offset in G87 canned cycle
M:
meaning: Z-axis offset for arcs
N:
meaning: Z offset in G87 canned cycle
P:
meaning: number of repetitions in canned cycles
Q:
meaning: key used with G10
R:
meaning: miscellaneous function (see Table 7)
S:
meaning: line number
T:
meaning: dwell time in canned cycles
X:
meaning: dwell time with G4
Y:
meaning: key used with G10
Z:
meaning: feed increment in G83 canned cycle
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/PythonicGCodeMachine/__init__.py 0000664 0000000 0000000 00000000000 13407513353 0031151 0 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/README.txt 0000664 0000000 0000000 00000001727 13407513353 0024573 0 ustar 00root root 0000000 0000000 .. -*- Mode: rst -*-
.. include:: project-links.txt
.. include:: abbreviation.txt
============
PythonicGCodeMachine
============
|Pypi License|
|Pypi Python Version|
|Pypi Version|
* Quick Link to `Production Branch `_
* Quick Link to `Devel Branch `_
Overview
========
What is PythonicGCodeMachine ?
---------------------
PythonicGCodeMachine is a Python module which implements ...
Where is the Documentation ?
----------------------------
The documentation is available on the |PythonicGCodeMachineHomePage|_.
What are the main features ?
----------------------------
* to be completed
How to install it ?
-------------------
Look at the `installation <@project_url@/installation.html>`_ section in the documentation.
Credits
=======
Authors: `Fabrice Salvaire `_
News
====
.. include:: news.txt
pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/unit-test/ 0000775 0000000 0000000 00000000000 13407513353 0025022 5 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/unit-test/GCode/ 0000775 0000000 0000000 00000000000 13407513353 0026003 5 ustar 00root root 0000000 0000000 pythonic-gcode-machine-b6d499de4e8686cba51a8cf1d3eb537794910d29/unit-test/GCode/test_Lexer.py 0000664 0000000 0000000 00000004321 13407513353 0030473 0 ustar 00root root 0000000 0000000 ####################################################################################################
#
# PythonicGCodeMachine - @licence_header_description@
# Copyright (C) 2018 Fabrice Salvaire
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
####################################################################################################
####################################################################################################
import unittest
####################################################################################################
from PythonicGCodeMachine.GCode.Lexer import GCodeLexer
####################################################################################################
class TestGCodeLexer(unittest.TestCase):
##############################################
def test_gcode_lexer(self):
lexer = GCodeLexer()
for gcode in (
'G0 X0 Y0 Z0',
'g0 x0 y0 z0',
'G0X0Y0Z0',
'N1 G0 X0 Y0 Z0',
'N2 G0 X1.0 Y0 Z0',
'N3.1 G0 X1.0 Y0 Z0',
'N3.1 G0 X1.0 Y0 Z0 ; a eof comment',
'N3.1 (comment 1) G0 (comment 2) X1.0 (comment 3) Y0 (comment 4) Z0 ; a eof comment',
):
tokens = lexer.tokenize(gcode)
print(gcode, list(tokens))
for gcode in (
'G0 (comment (wrong) 2) X0',
):
tokens = lexer.tokenize(gcode)
print(gcode, list(tokens))
####################################################################################################
if __name__ == '__main__':
unittest.main()