To all interested,

The problem lies in using the conjunction & directly between the if 
expression and the following expression.

If the If expression is surrounded by {} then the following expression 
is evaluated when the if does not produce &fail

Hence

if test then { expression1} else { &fail } & expression2

doesn't evaluate the expression2 if test produces a result

however

{if test then { expression1} else {&fail}} & expression2

does evaluate expression2 when test succeeds

On 07/12/2010 03:50 PM, Bruce & Breeanna Rennie wrote:
>    Ladies and Gentlemen,
>
> I am in the process of creating a PEG parser generator in Unicon. I have
> written some code that should be in a form that I can generate from
> other code.
>
> When the code is run, only the first part of the code is actually
> executed. From what I can see the next parts in the code should execute
> as it is using&
>
> The code is as follows
>
> procedure MatchComment()
>       return {
>           {
> # this is executed
>               if found.Push(tab(match("#"))) then {
>                   {
>                       found.Pop()
>                   }
>                   write("First Part of MatchComment()")
> # the result returned is "First Part of MatchComment()"
>               } else {
>                   write("FAIL")
> &fail
>               }&
>               {
> # this is not
>                   write("In MatchComment()")
>               }&
>               {
>                   while write({
>                       {
>                           if found.Push(not MatchEndOfLine()) then {
>                               {
>                                   found.Pop()
>                               }
>                           } else {
> &fail
>                           }&
>                           if found.Push(MatchDOT()) then {
>                               {
>                                   found.Pop()
>                               }
>                           } else {
> &fail
>                           }
>                       }
>                   }) do { }
>                   {
> &pos
>                   }
>               }&
>               if found.Push(MatchEndOfLine()) then {
>                   {
>                       found.Pop()
>                   }
>               } else {
> &fail
>               }
>           }
>       }
> end
>
>
> Does anyone see any problem with what is set up? I have run tracing and
> it shows that the only section outline above is being executed.
>
> The code is formatted this way to allow me to generate parsers from
> Templates for experimental purposes.
>
> regards
>
> Bruce Rennie
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Unicon-group mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/unicon-group


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to