yacc 질문

luftpalen의 이미지

간단한 컴파일러를 만들려고 하는데 모르는게 있어서 질문 올립니다.

예를 들어

program
: start_section statements
;

start_section
: START
;

statements
: instruction operand
| instruction operand statements

instruction : IDENTIFIER
operand : IDENTIFIER | IDENTIFIER ',' operand

이런게 있다고 하면
statements
: instruction operand <-- 이부분에서 instruction, operand 의 스트링을 알고 싶습니다.

예를 들어

ADD HAN,TWO 이런것을 넣을때 HAN과 TWO 라는 스트링을 알고싶은것이지요...
lex 와 yacc 를 써서 BNF 를 짰는데 막상 심볼테이블을 어디다 넣어야할런지 막막합니다