Giter Club home page Giter Club logo

iec61131-parser's Introduction

Build Status Maven Central

IEC61131 parsers

About

This is a ANTLRv4 grammar for IEC61131-3 languages. The main aim is to parse ST grammar.

Usage

Add maven dependency:

<dependency>
    <groupId>com.github.vlsi.iec61131</groupId>
    <artifactId>parser</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</dependency>

Sample

ANTLRInputStream is = new ANTLRInputStream("FUNCTION abc : BOOL VAR_TEMP temp: INT; END_VAR");
IEC61131Lexer lex = new IEC61131Lexer(is);
CommonTokenStream ts = new CommonTokenStream(lex);
IEC61131Parser p = new IEC61131Parser(ts);

IEC61131Parser.FunctionContext function = p.function();

Assert.assertEquals(function.name.getText(), "abc", "function name");
Assert.assertEquals(function.var_block().size(), 1, "1 block with variables");
IEC61131Parser.Var_blockContext varBlock = function.var_block(0);

Assert.assertEquals(varBlock.temp, true, "var_temp -> temp.true");
Assert.assertEquals(varBlock.variable_declaration().size(), 1, "1 variable");

IEC61131Parser.Variable_declarationContext var =
    varBlock.variable_declaration(0);
Assert.assertEquals(var.name.getText(), "temp", "variable name");
Assert.assertEquals(var.type.getText(), "INT", "variable type");

License

This library is distributed under terms of MIT license.

Changelog

v1.0.0

  • Initial version

Author

Vladimir Sitnikov [email protected]

iec61131-parser's People

Contributors

vlsi avatar

Watchers

James Cloos 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.