y
' are considered
to contain yacc source and processed accordingly.
CScout processes yacc files as follows:
y.tab.h
macro definitions.
%union
construct are defined as
members of the YYSTYPE
union
typedef
.
These are then considered to be accessed in all
%type
and the precedence specification constructs,
as well as the
explicit type specification through the $<tag>#
construct.
yyerrok
,
YYABORT
,
YYACCEPT
, etc)
are defined.
Feel free to define anything required to silence CScout
as a macro in the workspace definition file.
#define
d in the resulting C file)
and the corresponding macro definitions in the y.tab.h
file.
These are two separate macro definitions that happen to be the same.
CScout can not possibly recognise those, so if you change the
name of a terminal token in the yacc file you should also
change it in a C file where you refer to it.
CScout is designed to process well-formed modern-style yacc files. All rules must be terminated with a semicolon (apparently this is optional in the original yacc version). The accepted grammar appears below.
body: defs '%%' rules tail ; tail: /* Empty */ | '%%' c_code ; defs: /* Empty */ | defs def ; def: '%start' IDENTIFIER | '%union' '{' member_declaration_list '}' | '%{' c_code '%}' | rword name_list_declaration ; rword: '%token' | '%left' | '%right' | '%nonassoc' | '%type' ; tag: /* Empty: union tag is optional */ | '<' IDENTIFIER '>' ; name_list_declaration: tag name_number | name_list_declaration opt_comma name_number ; opt_comma: /* Empty */ | ',' ; name_number: name | name INT_CONST ; name: IDENTIFIER | CHAR_LITERAL ; /* rules section */ rules: rule | rules rule ; rule: IDENTIFIER ':' rule_body_list ';' ; rule_body_list: rule_body | rule_body_list '|' rule_body ; rule_body: id_action_list prec ; id_action_list: /* Empty */ | id_action_list name | id_action_list '{' c_code '}' ; prec: /* Empty */ | '%prec' name | '%prec' name '{' c_code '}' ; variable: '$$' | '$' INT_CONST | '$-' INT_CONST { $$ = basic(b_int); } | '$<' IDENTIFIER '>' variable_suffix { $$ = $3; } ; variable_suffix: '$' | INT_CONST | '-' INT_CONST ;
Contents | « Previous Next (Regular Expression Syntax) » |