aboutsummaryrefslogtreecommitdiff
path: root/core/KicadNetParser.g4
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-08-01 08:20:23 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-08-01 08:20:23 +0200
commitbfeeac6e4889d1e9a1083b3c7efc59652981b168 (patch)
treea937d844a59da7c509685dcd1ddd9933772e526f /core/KicadNetParser.g4
parentc307e9f234e544386fa3ae53083c7510668e1716 (diff)
downloadkicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.gz
kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.bz2
kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.xz
kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.zip
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.
Diffstat (limited to 'core/KicadNetParser.g4')
-rw-r--r--core/KicadNetParser.g489
1 files changed, 89 insertions, 0 deletions
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
+ ;