Lines Matching refs:ps

71 struct parser_state	ps;
121 ps.p_stack[0] = stmt; /* this is the parser's stack */
122 ps.last_nl = true; /* this is true if the last thing scanned was
124 ps.last_token = semicolon;
158 had_eof = ps.in_decl = ps.decl_on_line = break_comma = false;
160 ps.in_or_st = false;
161 ps.bl_line = true;
163 di_stack[ps.dec_nest = 0] = 0;
164 ps.want_blank = ps.in_stmt = ps.ind_stmt = false;
166 scase = ps.pcase = false;
187 ps.ljust_decl = 0; /* -ndj */
188 ps.com_ind = 33; /* -c33 */
190 ps.ind_size = 8; /* -i8 */
192 ps.decl_indent = 16; /* -di16 */
193 ps.local_decl_indent = -1; /* if this is not set to some nonnegative value
195 * ps.decl_ind */
196 ps.indent_parameters = 1; /* -ip */
197 ps.decl_com_ind = 0; /* if this is not set to some positive value
199 * ps.com_ind */
202 ps.unindent_displace = 0; /* -d0 */
203 ps.case_indent = 0; /* -cli0 */
209 ps.leave_comma = 1; /* -nbc */
298 ps.ind_level = ps.i_l_follow = col / opt.ind_size;
309 type_code = lexi(&ps); /* lexi reads one token. The actual
320 while (ps.search_brace) {
411 ps.search_brace = false;
439 ps.search_brace = false; /* stop looking for start of
487 transient_state = ps;
491 ps = transient_state;
501 if (ps.tos > 1) /* check for balanced braces */
506 ps.out_lines, ps.out_coms);
508 (1.0 * ps.com_lines) / code_lines);
525 ps.want_blank = false; /* dont insert blank at line start */
528 ps.in_stmt = true; /* turn on flag which causes an extra level of
541 ps.want_blank = false;
561 ps.use_ff = true; /* a form feed is treated much like a newline */
563 ps.want_blank = false;
567 if (ps.last_token != comma || ps.p_l_follow > 0
568 || !opt.leave_comma || ps.block_init || !break_comma || s_com != e_com) {
570 ps.want_blank = false;
577 if (++ps.p_l_follow == nitems(ps.paren_indents)) {
579 nitems(ps.paren_indents));
580 ps.p_l_follow--;
584 else if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent &&
585 ps.procname[0] == '\0' && ps.paren_level == 0) {
588 ps.dumped_decl_indent = true;
590 else if (ps.want_blank &&
591 ((ps.last_token != ident && ps.last_token != funcname) ||
596 ps.keyword + opt.Bill_Shannon > 2))
598 ps.want_blank = false;
600 ps.paren_indents[ps.p_l_follow - 1] = count_spaces_until(1, s_code, e_code) - 1;
601 if (sp_sw && ps.p_l_follow == 1 && opt.extra_expression_indent
602 && ps.paren_indents[0] < 2 * opt.ind_size)
603 ps.paren_indents[0] = 2 * opt.ind_size;
604 if (ps.in_or_st && *token == '(' && ps.tos <= 2) {
611 ps.in_or_st = false; /* turn off flag for structure decl or
615 if (ps.keyword == 1 || ps.keyword == 2)
616 ps.not_cast_mask |= 1 << ps.p_l_follow;
620 if (ps.cast_mask & (1 << ps.p_l_follow) & ~ps.not_cast_mask) {
621 ps.last_u_d = true;
622 ps.cast_mask &= (1 << ps.p_l_follow) - 1;
623 ps.want_blank = opt.space_after_cast;
625 ps.want_blank = true;
626 ps.not_cast_mask &= (1 << ps.p_l_follow) - 1;
627 if (--ps.p_l_follow < 0) {
628 ps.p_l_follow = 0;
632 ps.paren_level = ps.p_l_follow; /* then indent it */
636 if (sp_sw && (ps.p_l_follow == 0)) { /* check for end of if
640 ps.last_u_d = true; /* inform lexi that a following
642 ps.in_stmt = false; /* dont use stmt continuation
647 ps.search_brace = opt.btype_2; /* this should ensure that
654 if (!ps.dumped_decl_indent && ps.in_decl && !ps.block_init &&
655 ps.procname[0] == '\0' && ps.paren_level == 0) {
665 ps.dumped_decl_indent = true;
667 else if (ps.want_blank)
677 ps.want_blank = false;
685 if (ps.want_blank)
690 ps.want_blank = true;
696 ps.want_blank = true;
703 if (ps.want_blank)
706 ps.want_blank = true;
716 if (ps.want_blank)
719 ps.want_blank = true;
722 if (ps.in_or_st) {
724 ps.want_blank = false;
727 ps.in_stmt = false; /* seeing a label does not imply we are in a
742 force_nl = ps.pcase = scase; /* ps.pcase will be used by
748 ps.want_blank = false;
752 if (ps.dec_nest == 0)
753 ps.in_or_st = false;/* we are not in an initialization or
757 if (ps.last_token == rparen)
758 ps.in_parameter_declaration = 0;
759 ps.cast_mask = 0;
760 ps.not_cast_mask = 0;
761 ps.block_init = 0;
762 ps.block_init_level = 0;
763 ps.just_saw_decl--;
765 if (ps.in_decl && s_code == e_code && !ps.block_init &&
766 !ps.dumped_decl_indent && ps.paren_level == 0) {
769 ps.dumped_decl_indent = true;
772 ps.in_decl = (ps.dec_nest > 0); /* if we were in a first level
776 if ((!sp_sw || hd_type != forstmt) && ps.p_l_follow > 0) {
784 ps.p_l_follow = 0;
792 ps.want_blank = true;
793 ps.in_stmt = (ps.p_l_follow > 0); /* we are no longer in the
803 ps.in_stmt = false; /* dont indent the {} */
804 if (!ps.block_init)
807 else if (ps.block_init_level <= 0)
808 ps.block_init_level = 1;
810 ps.block_init_level++;
812 if (s_code != e_code && !ps.block_init) {
815 ps.want_blank = false;
817 else if (ps.in_parameter_declaration && !ps.in_or_st) {
818 ps.i_l_follow = 0;
822 ps.want_blank = false;
824 ps.want_blank = true;
827 if (ps.in_parameter_declaration)
830 if (ps.p_l_follow > 0) { /* check for preceding unbalanced
833 ps.p_l_follow = 0;
837 ps.ind_level = ps.i_l_follow;
841 ps.ind_stmt = false; /* dont put extra indentation on line
843 if (ps.in_decl && ps.in_or_st) { /* this is either a structure
845 di_stack[ps.dec_nest] = dec_ind;
846 if (++ps.dec_nest == nitems(di_stack)) {
849 ps.dec_nest--;
854 ps.decl_on_line = false; /* we can't be in the middle of
859 && ps.in_parameter_declaration)
861 ps.in_parameter_declaration = 0;
862 ps.in_decl = false;
866 if (ps.want_blank) /* put a blank before '{' if '{' is not at
869 ps.want_blank = false;
871 ps.just_saw_decl = 0;
875 if (ps.p_stack[ps.tos] == decl && !ps.block_init) /* semicolons can be
879 if (ps.p_l_follow) {/* check for unclosed if, for, else. */
881 ps.p_l_follow = 0;
884 ps.just_saw_decl = 0;
885 ps.block_init_level--;
886 if (s_code != e_code && !ps.block_init) { /* '}' must be first on
893 ps.want_blank = true;
894 ps.in_stmt = ps.ind_stmt = false;
895 if (ps.dec_nest > 0) { /* we are in multi-level structure
897 dec_ind = di_stack[--ps.dec_nest];
898 if (ps.dec_nest == 0 && !ps.in_parameter_declaration)
899 ps.just_saw_decl = 2;
900 ps.in_decl = true;
904 ps.search_brace = opt.cuddle_else && ps.p_stack[ps.tos] == ifhead
905 && ps.il[ps.tos] >= ps.ind_level;
906 if (ps.tos <= 1 && opt.blanklines_after_procs && ps.dec_nest <= 0)
928 ps.in_stmt = false;
934 ps.want_blank = false;
945 ps.want_blank = false;
959 if (ps.p_l_follow > 0)
964 if (ps.last_token == rparen && ps.tos <= 1) {
967 ps.want_blank = 0;
970 if (ps.in_parameter_declaration && opt.indent_parameters && ps.dec_nest == 0) {
971 ps.ind_level = ps.i_l_follow = 1;
972 ps.ind_stmt = 0;
974 ps.in_or_st = true; /* this might be a structure or initialization
976 ps.in_decl = ps.decl_on_line = ps.last_token != type_def;
977 if ( /* !ps.in_or_st && */ ps.dec_nest <= 0)
978 ps.just_saw_decl = 2;
982 if (ps.ind_level == 0 || ps.dec_nest > 0) {
995 if (ps.in_decl) {
997 ps.in_decl = false;
1002 else if (ps.want_blank) {
1005 ps.want_blank = false;
1007 else if (!ps.block_init && !ps.dumped_decl_indent &&
1008 ps.paren_level == 0) { /* if we are in a declaration, we
1011 ps.dumped_decl_indent = true;
1012 ps.want_blank = false;
1015 else if (sp_sw && ps.p_l_follow == 0) {
1018 ps.last_u_d = true;
1019 ps.in_stmt = false;
1027 if (ps.want_blank)
1033 ps.want_blank = true;
1041 if (ps.want_blank)
1046 ps.want_blank = false;
1052 ps.want_blank = false; /* dont put a blank after a period */
1056 ps.want_blank = (s_code != e_code); /* only put blank after comma
1059 if (ps.in_decl && ps.procname[0] == '\0' && !ps.block_init &&
1060 !ps.dumped_decl_indent && ps.paren_level == 0) {
1063 ps.dumped_decl_indent = true;
1066 if (ps.p_l_follow == 0) {
1067 if (ps.block_init_level <= 0)
1068 ps.block_init = 0;
1165 ps.pcase = false;
1171 state_stack[ifdef_level++] = ps;
1180 match_state[ifdef_level - 1] = ps;
1181 ps = state_stack[ifdef_level - 1];
1229 ps.last_token = type_code;
1287 if ((ps.ind_level * opt.ind_size) % opt.tabsize != 0) {
1288 pos += (ps.ind_level * opt.ind_size) % opt.tabsize;
1289 cur_dec_ind += (ps.ind_level * opt.ind_size) % opt.tabsize;
1305 if (e_code == startpos && ps.want_blank) {
1307 ps.want_blank = false;