%{ /* * Describe me. * * Mike Markowski * mm@udel.edu */ #include #include #include %} %left '+' '-' %left '*' '/' '%' %left UMINUS %left '^' %nonassoc '(' ')' %union { char *string; double number; } %token ANCHOR AT ATTRIBUTES BACK BOTTOM CENTER CIRCULAR CM COLOR CURSOR E ENG EQUATION %token FALSE FILENAME FN FOLD FONT FORMAT FP FRONT GAP INCH INCHES LABEL LEFT %token LENGTH LINE MATERIAL MIN MM MORE NOTATION NUMBER NUMBERLINE ON ONLY PI POSITION %token RANGE REDUCER RIGHT SCALE SCIENTIFIC SEGMENT SLIDE SLIDERULE STATOR %token STEP STRAIGHT STRING SYMBOL TEXT THICKNESS TICKS TO TOP TRUE WIDTH ZOOM %start sliderule %% sliderule: SLIDERULE name attrs ; name : STRING STRING sruleType /* Manufacturer model sruleType. */ ; sruleType: STRAIGHT | CIRCULAR ; attrs : attrs attr | attr ; attr : cursorBlock | ruleAttrBlock | segmentBlock | symAttrBlock | textAttrBlock ; ruleAttrBlock: ATTRIBUTES ruleAttr ';' | ATTRIBUTES '{' ruleAttrs '}' ; ruleAttrs: ruleAttrs ruleAttr ';' | ruleAttr ';' ; ruleAttr: MATERIAL STRING /* Material of construction. */ | COLOR STRING /* Color of rule. */ | LENGTH expr units /* Length, cm or in. */ | WIDTH expr units /* Width, cm or in. */ | AT location | MIN GAP expr units /* Smallest graduation len. */ ; textAttrBlock: TEXT NUMBER textAttr ';' | TEXT NUMBER '{' textAttrs '}' ; textAttrs: textAttrs textAttr ';' | textAttr ';' ; textAttr: FONT STRING /* Font for tick mark labels. */ | FORMAT STRING /* C style??? E.g., "< %d" for CI.*/ | POSITION position /* Position of numbering. */ | COLOR STRING /* Color of font. */ | NOTATION notStyle /* Numbering notation. */ | MIN GAP expr units /* Min. gap between adjacent text. */ | MORE numbers /* Additional numbering. */ | ONLY numbers /* Over-ride default scheme. */ ; position: LEFT | RIGHT | CENTER | ON ; notStyle: SCIENTIFIC | FP | ENG ; symAttrBlock: SYMBOL symAttr ';' | SYMBOL '{' symAttrs '}' ; symAttrs: symAttrs symAttr ';' | symAttr ';' ; symAttr : FILENAME STRING /* File name of image. */ | LINE '(' expr ',' expr ',' expr ',' expr ')' | POSITION position /* Position of numbering. */ | SCALE '(' expr ',' expr ')' ; segmentBlock: SEGMENT segType STRING segment ';' | SEGMENT segType STRING '{' segments '}' ; segments: segments segment ';' | segment ';' ; segType : STATOR | SLIDE ; segment : side scaleBlock ; side : FRONT | BACK ; scaleBlock: SCALE STRING scaleAttr ';' | SCALE STRING '{' scaleAttrs '}' ; units : INCH | INCHES | CM | MM ; scaleAttrs: scaleAttrs scaleAttr ';' | scaleAttr ';' ; scaleAttr: EQUATION expr /* Defines the scale! */ | labelBlock /* Special symbols, titles. */ | tickBlock | FOLD AT expr /* Scales like CF/M. */ | RANGE expr expr /* Range lower, higher. */ | AT location /* Offset from top. */ | ANCHOR direction /* Bottom of ticks. */ | NUMBERLINE /* Draw number line. */ ; direction: BOTTOM | CENTER /* Is this ever used? */ | TOP ; tickBlock: TICKS tickAttr ';' | TICKS '{' tickAttrs '}' ; tickAttrs: tickAttrs tickAttr ';' | tickAttr ';' ; tickAttr: MORE location /* Additional ticks. */ | ONLY location /* Use only these ticks. */ | RANGE expr expr | RANGE expr ',' expr | REDUCER expr /* 3/4 or 2/3 seems typical. */ | THICKNESS expr units /* Important to make large rules. */ | COLOR STRING | ZOOM boolean /* Flag. Can/can't add ticks when zooming in. */ ; boolean : TRUE | FALSE ; labelBlock: LABEL STRING labelAttr ';' | LABEL STRING '{' labelAttrs '}' ; labelAttrs: labelAttrs labelAttr ';' | labelAttr ';' ; labelAttr: AT location | FONT STRING | COLOR STRING ; location: '(' expr ',' expr ')' units /* Location is (x,y). */ | '(' expr expr ')' units /* Location is (x,y). */ ; numbers : numberRange | numberList ; numberRange: expr TO expr STEP expr ; numberList: numberList expr | numberList ',' expr | expr ; expr : '(' expr ')' | NUMBER | E | PI | '-' expr %prec UMINUS | expr '*' expr | expr '/' expr | expr '%' expr | expr '+' expr | expr '-' expr | expr '^' expr | FN '(' args ')' ; args : /* Null. */ | args ',' expr | expr ; cursorBlock: CURSOR ; %%