CSCE 434 Lecture 5

From Notes
Jump to navigation Jump to search

« previous | Wednesday, September 4, 2013 | next »


TA Office: HRBB 423C 3-4pm TWR

Project

Originally a 5-stage, semester-long project from Stanford.

Changed to 6 stages to allow for optimization.

Implement scanner for first part; preprocessor is bonus points. Relevant Files:

  • dppmain.cc
  • dpp.l
  • scanner.l

Read the GNU flex manual

TAMU { printf("Texas A&M University"); }
int { yylloc.first_line = 3; yylloc.first_column = 12;
      yylloc.last_line = 3; yylloc.last_column = 12;
      return T_Int; }

Default behavior is to print out any unrecognized text. There needs to be a "catch all" regex to recognize errors.

keep track of location as you go, and update location yylloc as above. Also update the following global vars.

Important Global vars:

  • yytext (actual scanned text of tokens)
  • yylval (actual value of token; see YYSTYPE)
  • yylloc (location in file)