X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/63920aa5296a85edd9d734a65be22d9911358df2..75585a67831244a20e460b7336d440d4cabe3b41:/src/domtool.lex?ds=sidebyside diff --git a/src/domtool.lex b/src/domtool.lex index 5130ad9..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)); @@ -107,6 +115,7 @@ lineComment = #[^\n]*\n; "=" => (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)); @@ -117,6 +126,13 @@ lineComment = #[^\n]*\n; "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));