Skip to content

Commit

Permalink
Enhance flx_pkgconfig, allow shellscript in fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
skaller committed Nov 26, 2017
1 parent 384c45d commit 46d71c1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
14 changes: 0 additions & 14 deletions doc/tutorial/hello.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,4 @@ into C++, compiles the program, and runs it. All the generated files
are cached in the .felix/cache subdirectory of your $HOME directory
on Unix like systems, and $USERPROFILE on Windows.

Test felix:

.. code-block:: felix
var x = \alpha \(x^2\)
Test xfelix:

.. code-block:: xfelix
var x = \alpha \(x^2\)

42 changes: 31 additions & 11 deletions src/packages/flx_pkgconfig.fdoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,33 @@ class FlxPkgConfig_core

proc pre_incr:&lex_iterator = "++*$1;";

fun lexit(ini:lex_iterator, finish:lex_iterator): lex_iterator * string =
union token_t = Str of string | Cmd of string | Eos;

fun lexit(ini:lex_iterator, finish:lex_iterator): lex_iterator * token_t=
{
//println$ "lexit input='" + string_between(ini,finish)+"'";

var start = ini;

// already at end
if start == finish do
return start, "";
return start, Eos;

// eat white space
elif *start == char(' ') do
++start;
while start != finish and *start == char(' ') do ++start; done;
return start,"";
return start,Eos;

// double quoted string
elif *start == char('"') do
++start;
p1 := start;
while start != finish and *start != char('"') do ++start; done;
if start == finish do
return start,string_between(p1,start);
return start,Str (string_between(p1,start));
else
return start+1,string_between(p1, start);
return start+1,Str (string_between(p1, start));
done;

// single quoted string
Expand All @@ -85,16 +87,27 @@ class FlxPkgConfig_core
p2 := start;
while start != finish and *start != char("'") do ++start; done;
if start == finish do
return start,string_between(p2,start);
return start,Str (string_between(p2,start));
else
return start+1,string_between(p2, start);
return start+1,Str (string_between(p2, start));
done;

elif *start == char("`") do
++start;
p3 := start;
while start != finish and *start != char("`") do ++start; done;
if start == finish do
return start,Cmd (string_between(p3,start));
else
return start+1,Cmd (string_between(p3, start));
done;


done;
// identifier
p3 := start;
p4 := start;
while start != finish and *start != char(" ") do ++start; done;
return start,string_between(p3,start);
return start,Str (string_between(p4,start));
}

fun lexstr(s':string): list[string] =
Expand All @@ -106,10 +119,17 @@ class FlxPkgConfig_core
var words = Empty[string];
while current != finish do
match lexit(current,finish) with
| next,lexeme =>
| next,token=>
{
current = next;
if lexeme != "" do words = Cons(lexeme,words); done;
match token with
| Eos => ;
| Str lexeme => if lexeme != "" perform words = Cons(lexeme,words);
| Cmd cmd =>
var res,s = System::get_stdout cmd;
var recres = lexstr s.strip;
words = rev recres + words;
endmatch;
}
endmatch;
done
Expand Down

0 comments on commit 46d71c1

Please sign in to comment.