aboutsummaryrefslogtreecommitdiff
path: root/core/KicadNetParser.g4
diff options
context:
space:
mode:
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
+ ;