Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vlsi/iec61131-parser

Parsers for IEC 61131-3 grammar
https://github.com/vlsi/iec61131-parser

Last synced: 2 days ago
JSON representation

Parsers for IEC 61131-3 grammar

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/vlsi/iec61131-parser.svg?branch=master)](https://travis-ci.org/vlsi/iec61131-parser)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.vlsi.iec61131/parser/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.vlsi.iec61131/parser)

IEC61131 parsers
================

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

Usage
-----

Add maven dependency:
```xml

com.github.vlsi.iec61131
parser
1.0.0-SNAPSHOT

```

Sample
------

```java
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