Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ncstat/parser

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ncstat/parser

Static NC file parser

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@ncstat/parser

A tool lexing and parsing NC files for the purpose of static analysis

Try it out

npm i --save @ncstat/parser

or

yarn add @ncstat/parser

NcLexer

const { NcLexer } = require("@ncstat/parser");

const lexer = new NcLexer();
const sample = `%
O1234 (TEST PROGRAM)

N43 ( 1/4" [.250"] DRILL )
T43 M6
G00 G90 G54 X.75 Y.19
S2000 M3
G43 H1 Z1.
G98 G81 Z-.5631 R.1 F83.96
X5.
G80
M30
%`;

for (const token of lexer.tokens(sample)) {
  console.log(token);
}

//
// <type: PRG_DELIM, value: "%", text: "%", pos: 0, line: 1, column: 1>
// <type: NEWLINE, value: "\n", text: "\n", pos: 1, line: 1, column: 2>
// <type: PRG_NUMBER, value: 1234, text: "O1234", pos: 2, line: 2, column: 1>
// <type: COMMENT, value: "TEST PROGRAM", text: "(TEST PROGRAM)", pos: 8, line: 2, column: 7>
// <type: NEWLINE, value: "\n", text: "\n", pos: 22, line: 2, column: 21>
// <type: NEWLINE, value: "\n", text: "\n", pos: 23, line: 3, column: 1>
// <type: ADDRESS, value: 43, text: "N43", pos: 24, line: 4, column: 1>
// <type: COMMENT, value: "1/4\" [.250\"] DRILL", text: "( 1/4\" [.250\"] DRILL )", pos: 28, line: 4, column: 5>
// <type: NEWLINE, value: "\n", text: "\n", pos: 50, line: 4, column: 27>
// <type: ADDRESS, value: 43, text: "T43", pos: 51, line: 5, column: 1>
// <type: M_CODE, value: {"prefix":"M","value":6}, text: "M6", pos: 55, line: 5, column: 5>
// ...

FAQs

Package last updated on 08 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc