YACC grammar for a simple Shell

Source: Internet
Author: User
View code

%token  STRING%token  RIGHT_APPEND%%cmd:    fg_cmd   |    bg_cmd   ;bg_cmd: fg_cmd '&'      ;fg_cmd:    simple_cmd      |    pipe_cmd      ;simple_cmd:     /* empty command */          |     executable          |     executable input_redirection          |     input_redirection executable          |     executable output_redirection          |     output_redirection executable          |     executable input_redirection   output_redirection          |     input_redirection   executable  output_redirection          |     input_redirection   output_redirection  executable          |     executable  output_redirection   input_redirection          |     output_redirection   executable  input_redirection          |     output_redirection   input_redirection  executable          ;executable: STRING          | STRING executable;input_redirection:  '<' STRING;output_redirection:     overwrite_output_redirection                  |     append_output_redirection                  ;overwrite_output_redirection:   '>'  STRING ;append_output_redirection:      RIGHT_APPEND STRING ;pipe_cmd:   left_cmd '|' right_cmd        |   left_cmd '|' middle_cmd right_cmd        ;left_cmd:   executable        |   executable input_redirection        |   input_redirection executable         ;middle_cmd: executable '|'          | middle_cmd executable '|'          ;right_cmd:  executable           |  executable output_redirection         |  output_redirection executable          ;%%int main(int argc, char *argv[]){    yyparse();    return 0;}int yywrap(){    return 1;}int yyerror(char *msg){    printf("Error encountered: %s\n", msg);}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.