Giter Club home page Giter Club logo

parser's Introduction

#Parser library


Simple command line parser (CLI) for Arduino/etc.

This project is at its initial stages of development, had little to no documentation, and is not really ready for public consumption

There are two parts to this "parser." First, it provides functions to read "line-at-a-time" input given a simple non-blocking single character input function (Serial.read() on Arduino.) Simple command-line editing (delete, erase line, retype) is provided, and the text is collected in an internal buffer until a newline is typed.

Second, the library provides functions for separating the line into simple "tokens" and interpretting several common types of tokens (keywords, numbers, simple fields.)


Basic operation

The basic flow using this library looks like:

parseReset();  // Reset the parser
parseGetLine(); // read a line of text
do {
   results = parseSomeTokenTypes(args);
   // act on results
} while (results != PARSER_EOL); // until end of line

###Details

void parseReset(void);

Zero and reset the internal buffers.

uint8_t parseGetline(void);

Read a line of text into the interal buffer. Returns the length of the line.

uint8_t parseGetline_nb(void);

A non-blocking version of the GetLine function. The function will always return instantly, with a value of 0 if a full line has not been read yet, or the length of the line if the read is complete.

char *parseToken(void);

"eat" the next token from the line buffer and return a pointer to the start of that token. Parsing a token is destructive of the line buffer; field separators are converted to nulls, and can't be retrieved. Most of the parse functions do their own parseToken; you can use the function when you want to get a text field without additional interpretation.

int parseNumber();

Parse a decimal number from the line buffer.

int8_t parseKeyword(const char PROGMEM *keys);

Parse a keyword. Given a space-separated list of keywords, return either the index of a matching keyword, or PARSER_NOMATCH.

parser's People

Contributors

westfw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.