Version française
Home     About     Download     Resources     Contact us    
Browse thread
CamlP4 lexer problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: dream.designer <vadim.shender@g...>
Subject: CamlP4 lexer problem
Hello everyone.

I'm trying to write a syntax extension that introduces two new tokens "[%"
and "%]". But I'm getting a syntax error if token ")" follows token "%]".
Could anybody help me please?

Here's the minimal syntax extension code that reproduces the issue:
===================================================================
open Camlp4.PreCast
open Syntax

EXTEND Gram
  expr:
    [ [ "[%"; e = expr LEVEL "simple"; "%]" -> e ] ] ;
END ;;
===================================================================

Usage sample:
===================================================================
# [% 5 %] ;;
- : int = 5

# ([% 5 %]) ;;
Characters 6-9:
  ([% 5 %]);;
        ^^^
Parse error: [expr level simple] expected after "[%" (in [expr])
===================================================================

Thanks in advance.

-- 
vadim.shender@gmail.com