project_445_2015.pdf

Upload: anas-khan

Post on 27-Feb-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 project_445_2015.pdf

    1/4

    CS445_Compliers Project

    Fall of 2015 first Semester 1437

    The project has 3 parts mandatory and 1 part optional. The student

    should submit the requirements by 6th

    Dec 2015.

    Part1: (5 marks)

    In C++, you have to build a small lexical scanner that tokenize the text and determine the

    type of each token. The output is a text file has {the line number of a token, token, type}

    at each line. If token is not accepted by any RE then report a meaningful error {the line

    number of a token, token, error}. You should use regexp library in C++ that gives

    Boolean answer if the token pass the RE or not.

    Token types: KEYWORD, SPECIAL_SYMBOL, INT_NUM, FLOAT_NUM, ID,

    COMMENT. See Lexical conventions of Mini C in Part3.

    Example:

    Input:

    Int x=4;

    Output:

    1, int, KEYWORD1, x, ID1,=, SPECIAL_SYMBOL1,4, INT_NUM

    Part2: (8 marks)

    Develop C++ program has 3 options:

    1) Build an NFA from a given RE.

    2) Convert NFA in (1) into a DFA.

    3) Build DFA from RE directly.

    Part3: (7 marks)

    Develop a LR(1) parser using C++ to decide whether a given string can be derived from

    the below grammar. The output should be a derivation of the string, if derivable.

    (drawing a parse tree using C++ library is an optional (5 marks))

    SS

    1) S L=R

    2)

    S R

    3)

    L *R

  • 7/25/2019 project_445_2015.pdf

    2/4

    4)

    L id

    5)

    R L

    Part 3 Optional (10 marks)

    Build a Mini C compiler using flex and bison, the grammars and token

    with its RE are given.

  • 7/25/2019 project_445_2015.pdf

    3/4

  • 7/25/2019 project_445_2015.pdf

    4/4

    Submission Requirements:

    1) Project report:

    a.

    Introduction about compiler phases and the relation between the

    phases and the tasks required in the project.

    b. Description of Flex and Bison for Part3.

    c.

    Snapshot of the output with different inputs (correct and error).

    d. The code of all tasks.

    e.

    Learning materials and tools used in this project including the

    websites and textbooks.

    2)

    The code, input files, output files, and the report on a CD.