~cypheon/kicad2spice

ref: 96e390bc4f914314da98ecdfd7bd775e620563e2 kicad2spice/lib/parse_sexp.mly -rw-r--r-- 434 bytes
96e390bc — Johann Rudloff Implement correct pin order according to field "Spice_Node_Sequence" 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
%token LPAREN
%token RPAREN
%token <string> QUOTED_STRING
%token <string> UNQUOTED_STRING
%token EOF

%start <Sexp.t> main

%{
  open Sexp
%}

%%

main:
  | e=sexp; EOF; { e }
  | error {
    Printf.printf "sexp parsing error:%d\n" $startpos.pos_lnum;
    Atom "fail"
  }

sexp:
  | LPAREN; id=atom; params=list(sexp); RPAREN; { Sexp (id, params) }
  | a=atom; { a }

atom:
  | s=QUOTED_STRING {Atom s}
  | s=UNQUOTED_STRING {Atom s}