Subversion Repositories Vertical

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

%{
/*
 * $Id: eagle_yacc.y,v 1.1.1.1 2003/11/04 23:34:56 mjames Exp $ 
 *
 * $Log: eagle_yacc.y,v $
 *
 *  */




#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "expression.h"
#include "generic.h"
#include "database.h"


#ident "@(#)$Header: C:/cvsroot/Vert03/protel_src/protel_yacc.y,v 1.1.1.1 2003/11/04 23:34:56 mjames Exp $"


static char text_buff[1024];

static socket_t * current_chip;
static char curr_net_nam[MAXIDLEN];

%}
%union { char * string; }
%token SPC NL LBRK RBRK LB2 RB2 MINUS ASTERISK
%token PROTEL NETLIST VERSION
%token <string> ASTRING

%start version
%%
protelfile : version objects;

version : PROTEL SPC NETLIST  SPC VERSION NL; 

objects   : objects object
          | object
                  ;


object    : component_obj
          | net_obj
                  | /*empty */
                  ;



component_obj : LBRK ASTRING NL comp_ident NL  ASTRING NL  comp_value  NL ASTRING NL comp_type NL skip_lines ASTERISK NL RBRK NL { free_lex_strings(); };


comp_ident:  ASTRING {current_chip = find_socket(Ident,$1,Create,&socket_head); };

comp_type :  ASTRING {
                set_socket(current_chip,Type,$1) ; /* same type as Ident so can pick up later */ };

comp_value : ASTRING { 
                set_socket(current_chip,Value,$1); };


net_obj   : LB2 NL net_ident NL pin_list RB2 NL;


pin_list  : pin_list socket_pin 
          | socket_pin
          | /* Moths */
          ;

net_ident : ASTRING { strcpy(curr_net_nam,$1); free_lex_strings(); }
          | ASTRING MINUS ASTRING { sprintf(curr_net_nam,"%s-%s",$1,$3); };



skip_line : NL
          | SPC NL
          ;
                  
skip_lines: skip_lines skip_line
           | skip_line
           | /* Nothing */
           ;

                   


socket_pin : socket_ident MINUS ASTRING NL { define_pin(&routed_list,
                              current_chip,
                              curr_net_nam,BIDIR,0,$3,
                              default_vhdl_datatype,NULL); };


socket_ident:  ASTRING { current_chip = find_socket(Ident,$1,Create,&socket_head);
          set_socket(current_chip,Type,$1) ; /* same type as Ident so can pick up later */
   };


%%

/* defining lineno here */

int lineno;
extern char * yytext;

int yyerror(char * x)
  {
  int token;
  printf("-- Error --> %s near string (%s) at line %d\n",x,yytext,lineno);
/*  for(token = yylex();token >= 0 && token!=NL;token = yylex()); */
  return 1;
  }

int yywrap(void)
  {
  return 1;
  }