[Attempto] Are arithmetic expressions typed?
Tobias Kuhn
t.kuhn at gmx.ch
Wed Jun 3 14:38:37 CEST 2009
These three files contain basically all the secrets of ACE including the bugs :)
But don't hesitate to post questions to the mailing list! You don't have to go into the depths of
the parser implementation before sending a message to the mailing list.
Tobias
Joshua TAYLOR wrote:
> Ah, thanks! That answers it perfectly. Before I ask any similar
> questions in the future, I'll try to check those files first. (Looking
> at them in retrospect, I can see the "sem!datatype!number" and
> "sem!datatype!string" which would have probably answered my question.)
>
> Joshua
>
> On Wed, Jun 3, 2009 at 3:39 AM, Tobias Kuhn <t.kuhn at gmx.ch> wrote:
>> Hi Joshua,
>>
>> ACE uses "&" for string concatenation and this can be used only for strings.
>> "+" is interpreted as addition and needs numbers. (Maybe we could be more
>> permissive in this respect.)
>>
>> The syntax report is underspecified in this (and some other) respects.
>> Actually, the only complete specification of ACE is the parser itself that
>> is represented by the files grammar.fit, grammar_functionwords.fit, and
>> grammar_contentwords.fit. The syntax report can be automatically generated
>> out of the comments within these files.
>>
>> I hope this answers your question.
>>
>>
>> Tobias
>>
>>
>> Joshua TAYLOR wrote:
>>> Sorry to throw so much at you all at once, but I'm just working my way
>>> through the DRS report.
>>> In the syntax specification, arithmetic terms do not seem to typed.
>>> I.e., "abc" + 2 would be a valid arithmetic term, by the parse:
>>>
>>> term -> term1 -> term2 (term1_tail)
>>> term2 -> term3 -> atomicTerm -> string (i.e., "abc")
>>> term1_tail -> + term1
>>> term1 -> term2 (term1_tail)
>>> term2 -> term3 - > atomicTerm -> Integer (i.e., 2)
>>>
>>> However, following are some examples about which combinations of
>>> expressions and operators actually work. To summarize before the
>>> examples,
>>>
>>> string & string : OK
>>> string & integer : ERROR
>>> integer & integer : ERROR
>>> integer + integer : OK
>>> string + integer : ERROR
>>> string + string : ERROR
>>>
>>> Here are the examples.
>>>
>>> == string & string is OK
>>>
>>> CL-USER 112 > (ape :text "John, compute \"abc\" & \"2\"!" :solo 'drs)
>>> "drs([], [command(drs([A], [predicate(A, compute, named('John'),
>>> expr(&, string(abc), string(2)))-1/3]))])"
>>>
>>> == string & integer is not OK
>>>
>>> CL-USER 113 > (ape :text "John, compute \"abc\" & 2!" :solo 'drs)
>>> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
>>>
>>> <messages>
>>> <message
>>> importance=\"error\"
>>> type=\"sentence\"
>>> sentence=\"1\"
>>> token=\"8\"
>>> value=\"John, compute "abc" & <> 2!\"
>>> repair=\"Commas must be followed by 'and' or 'or', or must occur
>>> at specified positions in lists, sets and commands.\"/>
>>> <message
>>> importance=\"error\"
>>> type=\"sentence\"
>>> sentence=\"1\"
>>> token=\"8\"
>>> value=\"John, compute "abc" & <> 2!\"
>>> repair=\"This is the first sentence that was not ACE. The sign
>>> <> indicates the position where parsing failed.\"/>
>>> </messages>"
>>>
>>> == neither is integer & integer OK
>>>
>>> CL-USER 114 > (ape :text "John, compute 1 & 2!" :solo 'drs)
>>> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
>>>
>>> <messages>
>>> <message
>>> importance=\"error\"
>>> type=\"sentence\"
>>> sentence=\"1\"
>>> token=\"5\"
>>> value=\"John, compute 1 <> & 2!\"
>>> repair=\"Commas must be followed by 'and' or 'or', or must occur
>>> at specified positions in lists, sets and commands.\"/>
>>> <message
>>> importance=\"error\"
>>> type=\"sentence\"
>>> sentence=\"1\"
>>> token=\"5\"
>>> value=\"John, compute 1 <> & 2!\"
>>> repair=\"This is the first sentence that was not ACE. The sign
>>> <> indicates the position where parsing failed.\"/>
>>> </messages>"
>>>
>>> == integer + integer is OK
>>>
>>> CL-USER 115 > (ape :text "John, compute 1 + 2!" :solo 'drs)
>>> "drs([], [command(drs([A], [predicate(A, compute, named('John'),
>>> expr(+, int(1), int(2)))-1/3]))])"
>>>
>>> == string + integer is not OK
>>>
>>> CL-USER 116 > (ape :text "John, compute \"abc\" + 2!" :solo 'drs)
>>> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
>>>
>>> <messages>
>>> <message
>>> importance=\"error\"
>>> type=\"sentence\"
>>> sentence=\"1\"
>>> token=\"7\"
>>> value=\"John, compute "abc" <> + 2!\"
>>> repair=\"Commas must be followed by 'and' or 'or', or must occur
>>> at specified positions in lists, sets and commands.\"/>
>>> <message
>>> importance=\"error\"
>>> type=\"sentence\"
>>> sentence=\"1\"
>>> token=\"7\"
>>> value=\"John, compute "abc" <> + 2!\"
>>> repair=\"This is the first sentence that was not ACE. The sign
>>> <> indicates the position where parsing failed.\"/>
>>> </messages>"
>>>
>>> == string + string is not OK
>>>
>>> CL-USER 117 > (ape :text "John, compute \"abc\" + \"2\"!" :solo 'drs)
>>> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
>>>
>>> <messages>
>>> <message
>>> importance=\"error\"
>>> type=\"sentence\"
>>> sentence=\"1\"
>>> token=\"7\"
>>> value=\"John, compute "abc" <> + "2"!\"
>>> repair=\"Commas must be followed by 'and' or 'or', or must occur
>>> at specified positions in lists, sets and commands.\"/>
>>> <message
>>> importance=\"error\"
>>> type=\"sentence\"
>>> sentence=\"1\"
>>> token=\"7\"
>>> value=\"John, compute "abc" <> + "2"!\"
>>> repair=\"This is the first sentence that was not ACE. The sign
>>> <> indicates the position where parsing failed.\"/>
>>> </messages>"
>>>
>>> None of these are urgent, I'm just reporting things as I discover them.
>>> Best regards,
>>> Joshua
>>> _______________________________________________
>>> attempto mailing list
>>> attempto at lists.ifi.uzh.ch
>>> https://lists.ifi.uzh.ch/listinfo/attempto
>>>
>
>
>
More information about the attempto
mailing list