On Sun, Mar 04, 2012 at 04:16:37PM +0100, Ralf Hemmecke wrote:
>> I am trying to compose a Spad function parseCall which parses from a
>> String a function call, for a certain restricted set of functions,
>> with parsing domain descriptions and the corresponding argument
>> descriptions, and a package call description -- given all in one String.
>
> OK, so you want a function:
>
> parseCall: String -> String
> that takes a string parses it, calls the respective FriCAS function and
> returns the result as a string?
1) I separate the two stages. parseCall prepares everything for applying
the needed standard function who's name is parsed at the top.
The remaining stage is simpler.
2) First, a string is broken to lexemes : LexList ==> List String.
I am going to try the format
------------------------------------------------------------
LexList ==> List String
PackageDescr ==> Product(Lexeme, Type)
ParseCallRes ==> Record(callName : Lexeme,
callDomConstrs : List DomainConstruction,
callDoms : List Type,
callArgs : List Any,
callPack : PackageDescr,
callRemLexs : LexList)
...
parseCall(lexemes : LexList) : ParseCallRes == ...
-- <call> ::= ( <fName> <domInputs> <argInputs> <packageInput> )
------------------------------------------------------------
The result is something ready to apply the specified Spad function to
the specified arguments, including their domains and including
possible package name and parameter values for the package.
There is chosen for this a finite set of the standard functions f =
"factor", "gcd", ... -- may be, 20-40 of them.
One of them will be applied after parsing.
Each of them has a fixed signature, but the call includes the
specification for each argument domain. Each of these domains has a
construction composed of INT, Fraction, UP, POLY, ResidueRing
-- several of them. It can be exxtende, bu it is fixed for each month.
<domInputs> is the input for such domain.
parseCall parses a symbolic domain construction, and also the very
domain. These data are used further in parsing the arguments of the
call.
There are possible variants.
> Look, for parseCall, you handle all the things inside parseCall, and
> there why would you need other types (INT, Fraction, SUP) as the ones
> that are already provided by FriCAS. I don't get that point.
I also do not understand you.
For example, 'factor' can be applied to f : UP(x, D),
where D can be constructed by an arbitrary many compositions of
various domain constructors. D may be Z = INT, Fraction Z,
(Fraction Z)[y]/(y^2 - 2) -- a residue ring,
and so on.
All this must be parsed from zero, from lexemes.
parseCall needs to find all this from
<call> ::= lexemes :=
"(" <fName> <domInputs> <argInputs> <packageInput> ")"
First to parse from lexemes : what is this D.
After D is found, the parser can parse the lexemes for f, with
taking each _coefficient input_ to a correct domain D.
For example, to parse a fraction coefficient from ["(" "Fr" <a> <b> ")"],
one needs to apply (a/b) :: Fraction D', where D' is correctly found,
and a, b : D' are parsed from <a>, <b>.
Neither the needed domains nor the coefficients are known initially,
only lexemes : LexList are given.
Besides `factor' there are possible several other functions, very
polymorphic ones.
> Of course, if your expression is composed from subexpressions, you have
> to do all that recursively. But I somehow don't see why one would have
> to introduce a Union type like your proposed DomConstr.
Because there is a fixed finite set of the standard domain constructors
of whiwch a goal domain is built. So, a domain construction DomConstr is
a Tree which edges are these constructors. This is expressed as
`domain' + tagged union + % (recursion)
-- as you have kindly explained.
What is wrong here?
Regards,
------
Sergei
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.