gnghskhn / recursive-ascent

Automatically exported from code.google.com/p/recursive-ascent
0 stars 0 forks source link

Incorrect order in literals matching. #93

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
let genLiteral (str : string) posStart posEnd =
    match str.ToLower() with
    | "+" -> ``L 835`` (posStart, posEnd)
    | "+=" -> ``L 836`` (posStart, posEnd)

The second pattern is never match. 
Semms, that strings should be reversed ordered by length.

Original issue reported on code.google.com by polubelo...@gmail.com on 3 Jul 2013 at 11:18

GoogleCodeExporter commented 8 years ago
Dmitriy,

Seems, that problem is not in getLiteral function. We want to write in lexer 
something like this:

rule token = perse
| ident {some code for ident|kwd|else processing}
| "/*" {some code for comments processing}
| '\'' {some code for literal processing}
| _ {getLiteral lexbuf} 

And in grammar we want to use literals with common prefix. E.g. 

expr : expr '=' expr
strange_expr : ident '=>' expr 
(*
NOT
strange_expr : ident '=' '>' expr 
this case is works fine 
*)

Is it possible?

Original comment by rsdpisuy@gmail.com on 3 Jul 2013 at 7:21