From bfeeac6e4889d1e9a1083b3c7efc59652981b168 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 1 Aug 2016 08:20:23 +0200 Subject: o Moving the generation logic to Python, embedding a Python interpreter with the help of pybind11. o Adding install configuration to CMake to make it easier to reuse the project later on. o Splitting out the examples into its own project to make it easier to test the whole installation setup and python/template loading. o Trying to reorganize the code a bit, not very much better yet. --- core/KicadNetParser.g4 | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 core/KicadNetParser.g4 (limited to 'core/KicadNetParser.g4') diff --git a/core/KicadNetParser.g4 b/core/KicadNetParser.g4 new file mode 100644 index 0000000..3971111 --- /dev/null +++ b/core/KicadNetParser.g4 @@ -0,0 +1,89 @@ +parser grammar KicadNetParser; + +options { + tokenVocab = KicadNetLexer; +} + +file: + form+ + ; + +form: + name #formName + | component #formComponent + | field #formField + | net #formNet + | node #formNode + | pinDecl #formDecl + | ref #formRef + | value #formValue + | libpart #formLibpart + | keyValue #formKeyValue + | string #formString + ; + +code: + '(' 'code' INTEGER ')' + ; + +component: + '(' 'comp' ref value libsource keyValue* ')' + ; + +field: + '(' 'field' name string ')' + ; + +name: + '(' 'name' string ')' + ; + +net: + '(' 'net' code name node+ ')' + ; + +node: + '(' 'node' ref pinRef ')' + ; + +pinRef: + '(' 'pin' INTEGER ')' + ; + +pinDecl: + '(' 'pin' '(' 'num' INTEGER ')' '(' 'name' string ')' '(' 'type' string ')' ')' + ; + +ref: + '(' 'ref' string ')' + ; + +value: + '(' 'value' string ')' + ; + +lib: + '(' 'lib' string ')' + ; + +part: + '(' 'part' string ')' + ; + +libpart: + '(' 'libpart' lib part keyValue* ')' + ; + +libsource: + '(' 'libsource' lib part ')' + ; + +keyValue: + '(' string form* ')' + ; + +string: + ID #stringId + | INTEGER #stringInt + | STRING #stringText + ; -- cgit v1.2.3