X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/42198578566be256bbdebf22757f41edef4aa6ee..c9731b9b3ee43c4c8d82c31009a5870a01d3acfa:/src/domtool.lex diff --git a/src/domtool.lex b/src/domtool.lex index 91af342..80c06c7 100644 --- a/src/domtool.lex +++ b/src/domtool.lex @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*) + *) (* Lexer for Domtool configuration files *) @@ -54,7 +54,7 @@ val strStart = ref 0 %% %header (functor DomtoolLexFn(structure Tokens : Domtool_TOKENS)); %full -%s COMMENT STRING; +%s COMMENT STRING DOC; id = [a-z_][A-Za-z0-9_]*; cid = [A-Z][A-Za-z0-9_]*; @@ -92,6 +92,14 @@ lineComment = #[^\n]*\n; str := #"\n" :: !str; continue()); . => (str := String.sub (yytext, 0) :: !str; continue()); + "{{" => (YYBEGIN DOC; strStart := yypos; str := []; continue()); + "}}" => (YYBEGIN INITIAL; + Tokens.DOC (String.implode (List.rev (!str)), !strStart, yypos + 1)); + "\n" => (lineNum := !lineNum + 1; + linePos := yypos :: ! linePos; + str := #"\n" :: !str; continue()); + . => (str := String.sub (yytext, 0) :: !str; continue()); + "(" => (Tokens.LPAREN (yypos, yypos + size yytext)); ")" => (Tokens.RPAREN (yypos, yypos + size yytext)); @@ -103,16 +111,30 @@ lineComment = #[^\n]*\n; "->" => (Tokens.ARROW (yypos, yypos + size yytext)); "=>" => (Tokens.DARROW (yypos, yypos + size yytext)); + "<-" => (Tokens.LARROW (yypos, yypos + size yytext)); "=" => (Tokens.EQ (yypos, yypos + size yytext)); "," => (Tokens.COMMA (yypos, yypos + size yytext)); + "\\\\" => (Tokens.BSLASHBSLASH (yypos, yypos + size yytext)); "\\" => (Tokens.BSLASH (yypos, yypos + size yytext)); ":" => (Tokens.COLON (yypos, yypos + size yytext)); ";" => (Tokens.SEMI (yypos, yypos + size yytext)); + "^" => (Tokens.CARET (yypos, yypos + size yytext)); + "!" => (Tokens.BANG (yypos, yypos + size yytext)); + "&" => (Tokens.AND (yypos, yypos + size yytext)); "let" => (Tokens.LET (yypos, yypos + size yytext)); "in" => (Tokens.IN (yypos, yypos + size yytext)); "end" => (Tokens.END (yypos, yypos + size yytext)); + "with" => (Tokens.WITH (yypos, yypos + size yytext)); + "where" => (Tokens.WHERE (yypos, yypos + size yytext)); + + "extern" => (Tokens.EXTERN (yypos, yypos + size yytext)); + "type" => (Tokens.TYPE (yypos, yypos + size yytext)); + "val" => (Tokens.VAL (yypos, yypos + size yytext)); + "context" => (Tokens.CONTEXT (yypos, yypos + size yytext)); + + "Root" => (Tokens.ROOT (yypos, yypos + size yytext)); {id} => (Tokens.SYMBOL (yytext, yypos, yypos + size yytext)); {cid} => (Tokens.CSYMBOL (yytext, yypos, yypos + size yytext));