Previous Up Next

Module Parser (Yacc)

The header contains a few auxiliary function.
moduleSymbol=Mtsymbol.Symbol

A standard component of the token type is information about the position of the lexical entity corresponding to the token. The corresponding type lexposition is exported from the module for the abstract syntax.


%token< Absynt.lexpositionנint >INT
%token< Absynt.lexpositionנstring >IDENT
%token< Absynt.lexpositionנstring >STRING
%token< Absynt.lexposition >SEMICOLONCOLONCOMMADOTEQ
%token< Absynt.lexposition >UNDERSCORE
%token< Absynt.lexposition >LPARENRPARENLBRACKETRBRACKETLBRACERBRACE
%token< Absynt.lexposition >ARROWQSTATESTATESISTATESSYMBOLSRULES
%tokenEOL
%tokenEOF
%tokenEOP

———- lowest precedence first ———-
%rightSEMICOLON

%startmain/∗ the entry point ∗/
%type< Absynt.qindexAbsynt.mtt >main
%type< Absynt.qindexAbsynt.mtt >mtt
%type< (Absynt.qindexAbsynt.state)list >states
%type< (Absynt.qindexAbsynt.state)list >slist
%type< Absynt.qindexAbsynt.state >state
%type< Absynt.ssignature >sarlist
%type< Absynt.symbolנint >sar
%type< Absynt.qindexAbsynt.rule >rule
%type< Absynt.qindexAbsynt.rulelist >rulelist
%type< Absynt.qindexAbsynt.term >term
%type< (Absynt.qindexAbsynt.term)list >termlist

main::=mttEOF{ $1 }

mtt::=IDENTEQ
LBRACKET
symbols
COMMA
states
COMMA
istates
COMMA
rules
RBRACKET{ ((Symbol.symbol_of_string(snd$1)),([],$4),$6,$8,$10) }

states::=STATESEQLBRACERBRACE{ [] }
STATESEQLBRACEstateslist{ $4::$5 }

istates::=ISTATESEQLBRACERBRACE{ [] }
ISTATESEQLBRACEstateslist{ $4::$5 }

symbols::=SYMBOLSEQLBRACERBRACE{ [] }
SYMBOLSEQLBRACEsarsarlist{ $4::$5 }

rules::=RULESEQLBRACERBRACE{ [] }
RULESEQLBRACErulerulelist{ $4::$5 }

slist::=RBRACE{ [] }
COMMAstateslist{ $2::$3 }

state::=QSTATEUNDERSCOREqindex{ Absynt.Q(snd$3) }

qindex::=INT{ $1 }

sarlist::=RBRACE{ [] }
COMMAsarsarlist{ $2::$3 }

sar::=LPARENIDENTCOMMAINTRPAREN{ (Symbol.symbol_of_string(snd$2),(snd$4)) }

rulelist::=RBRACE{ [] }
COMMArulerulelist{ $2::$3 }

rule::=termARROWterm{ ($1,$3) }

termlist::=RPAREN{ [] }
COMMAtermtermlist{ $2::$3 }

term::=var{ Absynt.V$1 }
stateLPARENtermRPAREN{ Absynt.QT($1,$3,[]) }
IDENTLPARENRPAREN{ Absynt.T(Symbol.symbol_of_string(snd$1),[]) }
IDENTLPARENtermtermlist{ Absynt.T(Symbol.symbol_of_string(snd$1),$3::$4) }

var::=IDENTUNDERSCOREINT{ ((Symbol.symbol_of_string"x"),(snd$3)) }



Previous Up Next