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 ;