Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
c2c54afd
Commit
c2c54afd
authored
Jan 07, 2015
by
POTTIER Francois
Browse files
Produce the function [terminal], which maps an integer code for a terminal
symbol to an [xsymbol].
parent
538a51d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
TODO
View file @
c2c54afd
* Possibly re-implement the function [symbol] using a packed
int array (going through [terminal] or [nonterminal] later).
Re-implement [production_defs], etc.
* Generate default printers for terminal and nonterminal.
Define printers for productions and items, parameterized
over printers for terminal and nonterminal.
...
...
src/tableBackend.ml
View file @
c2c54afd
...
...
@@ -746,6 +746,38 @@ let esymbol (symbol : Symbol.t) : expr =
let
xsymbol
(
symbol
:
Symbol
.
t
)
:
expr
=
EData
(
dataX
,
[
esymbol
symbol
])
(* ------------------------------------------------------------------------ *)
(* Produce a function that maps a terminal (represented as an integer code)
to its representation as an [xsymbol]. Include [error] but not [#], i.e.,
include all of the symbols which can appear in a production. *)
let
terminal
()
=
assert
Settings
.
inspection
;
let
t
=
"t"
in
define
(
"terminal"
,
EAnnot
(
EFun
([
PVar
t
]
,
EMatch
(
EVar
t
,
Terminal
.
mapx
(
fun
tok
->
{
branchpat
=
pint
(
Terminal
.
t2i
tok
);
branchbody
=
xsymbol
(
Symbol
.
T
tok
)
}
)
@
[
{
branchpat
=
PWildcard
;
branchbody
=
EComment
(
"This terminal symbol does not exist."
,
EApp
(
EVar
"assert"
,
[
efalse
])
)
}
]
)
)
,
type2scheme
(
arrow
tint
txsymbol
)
)
)
(* ------------------------------------------------------------------------ *)
(* Produce a function [symbol] that maps a state of type ['a lr1state]
(represented as an integer value) to a value of type ['a symbol]. *)
...
...
@@ -955,6 +987,10 @@ let program =
lr1state_redef
;
]
@
SIInclude
(
MVar
tables
)
::
(* only for [lhs] *)
SIValDefs
(
false
,
terminal
()
::
[]
)
::
SIValDefs
(
false
,
incoming_symbol_def
()
::
production_defs
()
::
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment