restructure done
This commit is contained in:
+3
-3
@@ -23,14 +23,14 @@
|
|||||||
| qid % Foo.Bar.baz
|
| qid % Foo.Bar.baz
|
||||||
| qcon % Foo.Bar.Baz
|
| qcon % Foo.Bar.Baz
|
||||||
| tvar % 'foo, 'foo_bar, '_'foo'_'bar'''
|
| tvar % 'foo, 'foo_bar, '_'foo'_'bar'''
|
||||||
% kwds ops and punct are all collapsed by
|
% kwds ops and sep are all collapsed by
|
||||||
% so_scan:scan down to eg {'contract', {420, 69}}
|
% so_scan:scan down to eg {'contract', {420, 69}}
|
||||||
% where {420, 69} is the source location
|
% where {420, 69} is the source location
|
||||||
% these are three different parsers
|
% these are three different parsers
|
||||||
| kwd % contract, interface, payable, etc
|
| kwd % contract, interface, payable, etc
|
||||||
| op % "=!<>+-*/:&|?~@^"
|
| op % "=!<>+-*/:&|?~@^"
|
||||||
| punct % ".." | oneof(",.;()[]{}")
|
| sep % ".." | oneof(",.;()[]{}")
|
||||||
% kwds and punct are kind of the same thing
|
% kwds and sep are kind of the same thing
|
||||||
% but i'll keep them separate now for my own sanity. ok
|
% but i'll keep them separate now for my own sanity. ok
|
||||||
% i guess op or symbol or whatever is fine.
|
% i guess op or symbol or whatever is fine.
|
||||||
%
|
%
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ slurp_ct_impls([#gsc_token{string = ":", type = op},
|
|||||||
slurp_ct_impls(_) ->
|
slurp_ct_impls(_) ->
|
||||||
reject.
|
reject.
|
||||||
|
|
||||||
slurp_ct_impls2([#gsc_token{string = ",", type = punct},
|
slurp_ct_impls2([#gsc_token{string = ",", type = sep},
|
||||||
#gsc_token{string = Con1, type = con}
|
#gsc_token{string = Con1, type = con}
|
||||||
| Rest],
|
| Rest],
|
||||||
Acc) ->
|
Acc) ->
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
-export([
|
-export([
|
||||||
smr_sf_ws/0,
|
smr_sf_ws/0,
|
||||||
smr_sf_op/0,
|
smr_sf_op/0,
|
||||||
smr_sf_punct/0,
|
smr_sf_sep/0,
|
||||||
smr_sf_id/0,
|
smr_sf_id/0,
|
||||||
smr_sf_con/0,
|
smr_sf_con/0,
|
||||||
smr_sf_qid/0,
|
smr_sf_qid/0,
|
||||||
@@ -175,7 +175,7 @@ match(Matcher, Source) ->
|
|||||||
% -export([
|
% -export([
|
||||||
% smr_sf_ws/0,
|
% smr_sf_ws/0,
|
||||||
% smr_sf_op/0,
|
% smr_sf_op/0,
|
||||||
% smr_sf_punct/0,
|
% smr_sf_sep/0,
|
||||||
% smr_sf_id/0,
|
% smr_sf_id/0,
|
||||||
% smr_sf_con/0,
|
% smr_sf_con/0,
|
||||||
% smr_sf_qid/0,
|
% smr_sf_qid/0,
|
||||||
@@ -224,7 +224,7 @@ smr_sf_op() ->
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
-spec smr_sf_punct() -> string_matcher().
|
-spec smr_sf_sep() -> string_matcher().
|
||||||
% @doc
|
% @doc
|
||||||
% String matcher for parens/braces
|
% String matcher for parens/braces
|
||||||
%
|
%
|
||||||
@@ -233,7 +233,7 @@ smr_sf_op() ->
|
|||||||
% , {"\\.\\.|[,.;()\\[\\]{}]", symbol()}
|
% , {"\\.\\.|[,.;()\\[\\]{}]", symbol()}
|
||||||
% @end
|
% @end
|
||||||
|
|
||||||
smr_sf_punct() ->
|
smr_sf_sep() ->
|
||||||
M_DotDotOp = smr_string(".."),
|
M_DotDotOp = smr_string(".."),
|
||||||
M_PunctChars = smr_oneofchars(",.;()[]{}"),
|
M_PunctChars = smr_oneofchars(",.;()[]{}"),
|
||||||
smr_union([M_DotDotOp, M_PunctChars]).
|
smr_union([M_DotDotOp, M_PunctChars]).
|
||||||
|
|||||||
+6
-6
@@ -254,7 +254,7 @@ token_shapes_parse_order() ->
|
|||||||
lists:flatten([
|
lists:flatten([
|
||||||
% comments and whitespace
|
% comments and whitespace
|
||||||
lcom, bcom, ws,
|
lcom, bcom, ws,
|
||||||
punct,
|
sep,
|
||||||
% literals
|
% literals
|
||||||
char, string, int16, int10, bytes,
|
char, string, int16, int10, bytes,
|
||||||
ak, ct, sg,
|
ak, ct, sg,
|
||||||
@@ -264,7 +264,7 @@ token_shapes_parse_order() ->
|
|||||||
% keywords need to be parsed ahead of ids
|
% keywords need to be parsed ahead of ids
|
||||||
kwd, id,
|
kwd, id,
|
||||||
con,
|
con,
|
||||||
% ops [=, =>, >>], punctuation (parens/braces)
|
% ops [=, =>, >>], sepuation (parens/braces)
|
||||||
op
|
op
|
||||||
]).
|
]).
|
||||||
|
|
||||||
@@ -597,7 +597,7 @@ slurp_token_of_shape(ws, Pos, SrcStr) ->
|
|||||||
str = WS},
|
str = WS},
|
||||||
{tokmatch, Token, Rest}
|
{tokmatch, Token, Rest}
|
||||||
end;
|
end;
|
||||||
% KEYWORDS, OPERATORS, PUNCTUATION: kwd, op, punct
|
% KEYWORDS, OPERATORS, PUNCTUATION: kwd, op, sep
|
||||||
%
|
%
|
||||||
% all the kwds are valid ids, so we match as an id and then check if it's a
|
% all the kwds are valid ids, so we match as an id and then check if it's a
|
||||||
% kwd
|
% kwd
|
||||||
@@ -629,10 +629,10 @@ slurp_token_of_shape(op, Pos, SrcStr) ->
|
|||||||
no_strmatch ->
|
no_strmatch ->
|
||||||
no_tokmatch
|
no_tokmatch
|
||||||
end;
|
end;
|
||||||
slurp_token_of_shape(punct, Pos, SrcStr) ->
|
slurp_token_of_shape(sep, Pos, SrcStr) ->
|
||||||
case gsc_strmatch:match(gsc_strmatch:smr_sf_punct(), SrcStr) of
|
case gsc_strmatch:match(gsc_strmatch:smr_sf_sep(), SrcStr) of
|
||||||
{strmatch, Str, Rest} ->
|
{strmatch, Str, Rest} ->
|
||||||
Token = #tk{shape = punct, pos = Pos, str = Str},
|
Token = #tk{shape = sep, pos = Pos, str = Str},
|
||||||
{tokmatch, Token, Rest};
|
{tokmatch, Token, Rest};
|
||||||
no_strmatch ->
|
no_strmatch ->
|
||||||
no_tokmatch
|
no_tokmatch
|
||||||
|
|||||||
+3
-3
@@ -299,7 +299,7 @@ pass_types() ->
|
|||||||
[lcom, % ak_AB// breaks out of id
|
[lcom, % ak_AB// breaks out of id
|
||||||
bcom, % ak_AB/* breaks out of id
|
bcom, % ak_AB/* breaks out of id
|
||||||
ws, % ak_AB\t breaks out of id
|
ws, % ak_AB\t breaks out of id
|
||||||
punct, % ak_AB{ breaks out of id
|
sep, % ak_AB{ breaks out of id
|
||||||
string, % ak_AB" breaks out of id
|
string, % ak_AB" breaks out of id
|
||||||
bytes, % ak_AB# breaks out of id
|
bytes, % ak_AB# breaks out of id
|
||||||
ak,ct,sg, % ak_ABak [akctsg] all in base58 alphabet
|
ak,ct,sg, % ak_ABak [akctsg] all in base58 alphabet
|
||||||
@@ -335,13 +335,13 @@ to_so_token(#tk{shape = SfTokenType,
|
|||||||
%
|
%
|
||||||
% {contract, {420, 69}}
|
% {contract, {420, 69}}
|
||||||
%-----------------------
|
%-----------------------
|
||||||
% kwds ops and punct are all collapsed by
|
% kwds ops and sep are all collapsed by
|
||||||
% so_scan:scan down to eg {'contract', {420, 69}}
|
% so_scan:scan down to eg {'contract', {420, 69}}
|
||||||
% where {420, 69} is the source location
|
% where {420, 69} is the source location
|
||||||
% these are three different parsers
|
% these are three different parsers
|
||||||
Sym when Sym =:= kwd;
|
Sym when Sym =:= kwd;
|
||||||
Sym =:= op;
|
Sym =:= op;
|
||||||
Sym =:= punct ->
|
Sym =:= sep ->
|
||||||
Symbol = list_to_atom(SfTokenStr),
|
Symbol = list_to_atom(SfTokenStr),
|
||||||
{true, {Symbol, Pos}};
|
{true, {Symbol, Pos}};
|
||||||
%------------------------------------
|
%------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user