Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
1986-parsetools-Create-specs-for-leex-exported-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1986-parsetools-Create-specs-for-leex-exported-functions.patch of Package erlang
From 06bc39b45397ce85a7f13e722a62f4ad1507eafe Mon Sep 17 00:00:00 2001 From: Lukas Larsson <lukas@erlang.org> Date: Wed, 27 Sep 2023 17:03:30 +0200 Subject: [PATCH 06/10] parsetools: Create specs for leex exported functions --- lib/parsetools/doc/src/leex.xml | 46 +++-------------- lib/parsetools/src/leex.erl | 79 ++++++++++++++++++++++++++++++ lib/parsetools/test/leex_SUITE.erl | 2 +- 3 files changed, 86 insertions(+), 41 deletions(-) diff --git a/lib/parsetools/doc/src/leex.xml b/lib/parsetools/doc/src/leex.xml index 56c44caadb..12ecdc4368 100644 --- a/lib/parsetools/doc/src/leex.xml +++ b/lib/parsetools/doc/src/leex.xml @@ -152,9 +152,6 @@ </desc> </func> </funcs> - - - <funcs> <fsdescription> @@ -162,15 +159,9 @@ <p>The following functions are exported by the generated scanner.</p> </fsdescription> <func> - <name since="">Module:string(String) -> StringRet</name> - <name since="">Module:string(String, StartLoc) -> StringRet</name> + <name name="string" arity="1" since="" /> + <name name="string" arity="2" since="" /> <fsummary>Generated by Leex</fsummary> - <type> - <v>String = string()</v> - <v>StringRet = {ok,Tokens,EndLoc} | ErrorInfo</v> - <v>Tokens = [Token]</v> - <v>StartLoc = EndLoc = erl_anno:location()</v> - </type> <desc> <p>Scans <c>String</c> and returns all the tokens in it, or an error. <c>StartLoc</c> and <c>EndLoc</c> are either <c>erl_anno:line()</c> @@ -181,21 +172,9 @@ </func> <func> - <name since="">Module:token(Cont, Chars) -> {more,Cont1} | {done,TokenRet,RestChars} - </name> - <name since="">Module:token(Cont, Chars, StartLoc) -> {more,Cont1} - | {done,TokenRet,RestChars} - </name> + <name name="token" arity="2" since="" /> + <name name="token" arity="3" since="" /> <fsummary>Generated by Leex</fsummary> - <type> - <v>Cont = [] | Cont1</v> - <v>Cont1 = tuple()</v> - <v>Chars = RestChars = string() | eof</v> - <v>TokenRet = {ok, Token, EndLoc} - | {eof, EndLoc} - | ErrorInfo</v> - <v>StartLoc = EndLoc = erl_anno:location()</v> - </type> <desc> <p>This is a re-entrant call to try and scan one token from <c>Chars</c>. If there are enough characters in <c>Chars</c> @@ -216,22 +195,9 @@ io:request(InFile, {get_until,unicode,Prompt,Module,token,[Loc]}) </func> <func> - <name since="">Module:tokens(Cont, Chars) -> {more,Cont1} | {done,TokensRet,RestChars} - </name> - <name since="">Module:tokens(Cont, Chars, StartLoc) -> - {more,Cont1} | {done,TokensRet,RestChars} - </name> + <name name="tokens" arity="2" since="" /> + <name name="tokens" arity="3" since="" /> <fsummary>Generated by Leex</fsummary> - <type> - <v>Cont = [] | Cont1</v> - <v>Cont1 = tuple()</v> - <v>Chars = RestChars = string() | eof</v> - <v>TokensRet = {ok, Tokens, EndLoc} - | {eof, EndLoc} - | ErrorInfo</v> - <v>Tokens = [Token]</v> - <v>StartLoc = EndLoc = erl_anno:location()</v> - </type> <desc> <p>This is a re-entrant call to try and scan tokens from <c>Chars</c>. If there are enough characters in <c>Chars</c> diff --git a/lib/parsetools/src/leex.erl b/lib/parsetools/src/leex.erl index c5e61b8149..198958513f 100644 --- a/lib/parsetools/src/leex.erl +++ b/lib/parsetools/src/leex.erl @@ -65,6 +65,85 @@ -record(nfa_state, {no,edges=[],accept=noaccept}). -record(dfa_state, {no,nfa=[],trans=[],accept=noaccept}). +%%% +%%% Functions that generated scanner exports, +%%% only used for documentation purposes +%%% +-export([string/1, string/2, token/2, token/3, tokens/2, tokens/3]). +-spec string(String) -> StringRet when + String :: string(), + StringRet :: {ok, Tokens, EndLoc} | ErrorInfo, + Tokens :: [Token], + Token :: term(), + ErrorInfo :: {error, error_info(), erl_anno:location()}, + EndLoc :: erl_anno:location(). +string(_String) -> error(undef). +-spec string(String, StartLoc) -> StringRet when + String :: string(), + StringRet :: {ok, Tokens, EndLoc} | ErrorInfo, + Tokens :: [Token], + Token :: term(), + ErrorInfo :: {error, error_info(), erl_anno:location()}, + StartLoc :: erl_anno:location(), + EndLoc :: erl_anno:location(). +string(_String, _StartLoc) -> error(undef). +-spec token(Cont, Chars) -> + {more, Cont1} | {done, TokenRet, RestChars} when + Cont :: [] | Cont1, + Cont1 :: tuple(), + Chars :: string() | eof, + RestChars :: string() | eof, + TokenRet :: {ok, Token, EndLoc} | + {eof, EndLoc} | + ErrorInfo, + ErrorInfo :: {error, error_info(), erl_anno:location()}, + Token :: term(), + EndLoc :: erl_anno:location(). +token(_Cont, _Chars) -> error(undef). +-spec token(Cont, Chars, StartLoc) -> + {more, Cont1} | {done, TokenRet, RestChars} when + Cont :: [] | Cont1, + Cont1 :: tuple(), + Chars :: string() | eof, + RestChars :: string() | eof, + TokenRet :: {ok, Token, EndLoc} | + {eof, EndLoc} | + ErrorInfo, + ErrorInfo :: {error, error_info(), erl_anno:location()}, + Token :: term(), + StartLoc :: erl_anno:location(), + EndLoc :: erl_anno:location(). +token(_Cont, _Chars, _StartLoc) -> error(undef). +-spec tokens(Cont, Chars) -> + {more, Cont1} | {done, TokensRet, RestChars} when + Cont :: [] | Cont1, + Cont1 :: tuple(), + Chars :: string() | eof, + RestChars :: string() | eof, + TokensRet :: {ok, Tokens, EndLoc} | + {eof, EndLoc} | + ErrorInfo, + Tokens :: [Token], + Token :: term(), + ErrorInfo :: {error, error_info(), erl_anno:location()}, + EndLoc :: erl_anno:location(). +tokens(_Cont, _Chars) -> error(undef). +-spec tokens(Cont, Chars, StartLoc) -> + {more, Cont1} | {done, TokensRet, RestChars} when + Cont :: [] | Cont1, + Cont1 :: tuple(), + Chars :: string() | eof, + RestChars :: string() | eof, + TokensRet :: {ok, Tokens, EndLoc} | + {eof, EndLoc} | + ErrorInfo, + Tokens :: [Token], + Token :: term(), + ErrorInfo :: {error, error_info(), erl_anno:location()}, + StartLoc :: erl_anno:location(), + EndLoc :: erl_anno:location(). +tokens(_Cont, _Chars, _StartLoc) -> error(undef). + %%% %%% Exported functions %%% diff --git a/lib/parsetools/test/leex_SUITE.erl b/lib/parsetools/test/leex_SUITE.erl index 28142222f7..9f55eefbe3 100644 --- a/lib/parsetools/test/leex_SUITE.erl +++ b/lib/parsetools/test/leex_SUITE.erl @@ -780,7 +780,7 @@ escape_char($e) -> $\\e; %\\e = ESC escape_char($s) -> $\\s; %\\s = SPC escape_char($d) -> $\\d; %\\d = DEL escape_char(C) -> C. - ">>, + ">>, % " Dir = ?privdir, XrlFile = filename:join(Dir, "erlang_scan.xrl"), ok = file:write_file(XrlFile, Xrl), -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor