Files
control-see/ldtext/Lexer.fsl

31 lines
769 B
Plaintext

{
open Parser
open FSharp.Text.Lexing
exception SyntaxError of string
let lexeme (lexbuf:LexBuffer<byte>) = System.Text.Encoding.ASCII.GetString lexbuf.Lexeme
}
// It's not necessary to name regexes like this, but it might
// make the rule(s) clearer.
let ident = ['_' 'a'-'z' 'A'-'Z' ]['_' 'a'-'z' 'A'-'Z' '.' '0'-'9']*
rule read =
parse
| ' '+ { read lexbuf }
| ident { IDENTIFIER (lexeme lexbuf) }
| '(' { LEFT_PAREN }
| ')' { RIGHT_PAREN }
| '[' { LEFT_BRACKET }
| ']' { RIGHT_BRACKET }
| ',' { COMMA }
| ';' { SEMICOLON }
| '?' { QUESTION_MARK }
| eof { EOF }
| _ { raise (SyntaxError (sprintf
"SyntaxError: Unexpected char: '%s' Line: %d Column: %d"
(lexeme lexbuf)
(lexbuf.StartPos.Line + 1)
lexbuf.StartPos.Column))}