Open marcomaggi opened 11 years ago
When defining a parser with the library (nausicaa parser-tools lalr) and the grammar below:
(nausicaa parser-tools lalr)
(define make-parser (lalr.lalr-parser (lalr.output-value: #t) (lalr.expect: 0) (lalr.terminals: '(NUM ;precedence 0 (left: ADD SUB) ;precedence 1 (left: MUL DIV) ;precedence 2 (nonassoc: UADD) ;precedence 3 (nonassoc: USUB))) ;precedence 4 (lalr.rules: '((EXPR ;;These are the offending rules. (ADD EXPR (prec: UADD)) : (list $1 $2) (SUB EXPR (prec: USUB)) : (list $1 $2) (EXPR ADD EXPR) : (list $2 $1 $3) (EXPR SUB EXPR) : (list $2 $1 $3) (EXPR MUL EXPR) : (list $2 $1 $3) (EXPR DIV EXPR) : (list $2 $1 $3) (NUM) : $1)))))
the rules defining the unary + and unary - operators do not handle correctly the prec: qualifier. This results in the sequence:
+
-
prec:
SUB ONE MUL TWO
to be parsed as (- (* 1 2)) rather than (* (- 1) 2)).
(- (* 1 2))
(* (- 1) 2))
Notice that the same unary operators definition works fine when used in the parser generated by tests/make-lalr-calc.sps.
tests/make-lalr-calc.sps
When defining a parser with the library
(nausicaa parser-tools lalr)
and the grammar below:the rules defining the unary
+
and unary-
operators do not handle correctly theprec:
qualifier. This results in the sequence:to be parsed as
(- (* 1 2))
rather than(* (- 1) 2))
.