Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Raphaël Cauderlier
Sigmaid
Commits
d72f856b
Commit
d72f856b
authored
Jun 27, 2014
by
Raphaël Cauderlier
Browse files
Solve shift/reduce conflict in the lexer
parent
08702e51
Changes
2
Hide whitespace changes
Inline
Side-by-side
lexer.mll
View file @
d72f856b
...
...
@@ -3,11 +3,14 @@
exception
Unexpected_char
of
char
}
let
id
=
[
'
a'
-
'
z'
]
[
'
a'
-
'
z'
'
A'
-
'
Z'
'
_'
'
0
'
-
'
9
'
]
*
in
rule
token
=
parse
|
[
'
'
'\t'
]
{
token
lexbuf
}
|
'\n'
{
token
lexbuf
}
|
'.'
([
'
a'
-
'
z'
]
[
'
a'
-
'
z'
'
A'
-
'
Z'
'
_'
'
0
'
-
'
9
'
]
*
as
s
)
"<="
{
UPDATE
(
s
)
}
|
'.'
([
'
a'
-
'
z'
]
[
'
a'
-
'
z'
'
A'
-
'
Z'
'
_'
'
0
'
-
'
9
'
]
*
as
s
)
{
SELECT
(
s
)
}
|
'.'
(
id
as
s
)
"<="
{
UPDATE
(
s
)
}
|
'.'
(
id
as
s
)
{
SELECT
(
s
)
}
|
'.'
(
is
as
s
)
":="
{
FUPD
(
s
)
}
|
'
[
'
{
LBRACK
}
|
'
]
'
{
RBRACK
}
|
'
:
'
{
COLUMN
}
...
...
@@ -17,7 +20,6 @@ rule token = parse
|
"ς"
{
SIGMA
}
|
'
=
'
{
EQUAL
}
|
"::="
{
DEF
}
|
":="
{
FUPD
}
|
'.'
{
DOT
}
|
"->"
{
ARR
}
|
"λ"
{
LAMBDA
}
...
...
@@ -25,7 +27,7 @@ rule token = parse
|
"let"
{
VAR
(
Parsing
.
rhs_start_pos
1
)
}
|
"check"
{
CHECK
(
Parsing
.
rhs_start_pos
1
)
}
|
"norm"
{
NORM
(
Parsing
.
rhs_start_pos
1
)
}
|
[
'
a'
-
'
z'
]
[
'
a'
-
'
z'
'
A'
-
'
Z'
'
_'
'
0
'
-
'
9
'
]
*
as
s
{
ID
(
s
)
}
|
id
as
s
{
ID
(
s
)
}
|
[
'
A'
-
'
Z'
]
[
'
a'
-
'
z'
'
A'
-
'
Z'
'
_'
'
0
'
-
'
9
'
]
*
as
s
{
CID
(
s
)
}
|
_
as
c
{
raise
(
Unexpected_char
c
)
}
|
eof
{
raise
End_of_file
}
parser.mly
View file @
d72f856b
...
...
@@ -20,8 +20,8 @@
Base
.
labels
:=
insert1
l'
!
Base
.
labels
;
l'
%
}
%
token
<
string
>
ID
CID
SELECT
UPDATE
%
token
LBRACK
RBRACK
COLUMN
SEMICOLUMN
LPAR
RPAR
SIGMA
EQUAL
DEF
DOT
FUPD
%
token
<
string
>
ID
CID
SELECT
UPDATE
FUPD
%
token
LBRACK
RBRACK
COLUMN
SEMICOLUMN
LPAR
RPAR
SIGMA
EQUAL
DEF
DOT
%
token
LAMBDA
ARR
%
token
<
Lexing
.
position
>
TYPE
VAR
CHECK
NORM
...
...
@@ -63,7 +63,7 @@ term: obj { $1 }
|
LAMBDA
LPAR
ID
COLUMN
ty
RPAR
obj
{
Abst
(
Id
(
$
3
)
,
$
5
,
$
7
)}
|
obj
SELECT
{
Select
(
$
1
,
label
(
$
2
))
}
|
obj
UPDATE
meth
{
Update
(
$
1
,
label
(
$
2
)
,
$
3
)
}
|
obj
DOT
ID
FUPD
term
{
Field_update
(
$
1
,
label
(
$
3
)
,
$
5
)
}
|
obj
FUPD
term
{
Field_update
(
$
1
,
label
(
$
2
)
,
$
3
)
}
;
meth
:
SIGMA
LPAR
ID
COLUMN
ty
RPAR
term
{
Method
(
Id
(
$
3
)
,
$
5
,
$
7
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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