Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Question on Grammar Specification
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
LogicProgrammer  
View profile  
 More options Nov 18 2009, 7:32 pm
From: LogicProgrammer <logicprogram...@gmail.com>
Date: Wed, 18 Nov 2009 16:32:19 -0800 (PST)
Local: Wed, Nov 18 2009 7:32 pm
Subject: Re: Question on Grammar Specification
Also, I understand how to parse a single string, but what I want to
parse an entire file?

Suppose that I had a rule which says something like this:

STATEMENT ::= TERM [, TERM]* '.'

i.e - a statement is a comma-delimited sequence of 1 or more terms
followed by period. And a program is defined as one or more
statements:

PROGRAM ::= STATEMENT+

On a successful parse I would like to get a list of all of the
"statement objects".

How would I attempt something like this?

Thanks again.

On Nov 18, 5:15 pm, LogicProgrammer <logicprogram...@gmail.com> wrote:

> Also if I want the the results of a parse to be represented as a
> string object, am I correct that I would append '> str' to the end of
> the corresponding grammar rule?

> On Nov 18, 5:13 pm, LogicProgrammer <logicprogram...@gmail.com> wrote:

> > Hi All,

> > I'm attempting to define a grammar for a simple logic programming
> > language. The initial portion of the EBNF is as follows:
> > (comments follow a %)

> > OBJECT    :== a-z[a-zA-Z0-9]*     %alpha-numeric string which begins
> > with a lower case letter
> > VARIABLE :== A-Z[a-zA-Z0-9]*    %alpha-numeric string which begins
> > with an uppercase letter
> > FUNC        :== OBJECT
> > TERM       :== OBJECT | VARIABLE | FUNC ( TERM [, TERM]* ) % term is
> > either an object, variable, or a function symbol of arity >= 1 -
> > parenthesis are literal tokens

> > PRED :== OBJECT
> > PREDSYM :== PRED | PRED ( TERM [, TERM]* )

> > To my understanding I should be able to use LEPL along the following
> > lines:

> > OBJECT = Token('[a-z][a-zA-Z0-9]*')
> > VARIABLE = Token('[A-Z][a-zA-Z0-9]+')
> > FUNC = OBJECT
> > TERM = Delayed()
> > TERM += OBJECT | VARIABLE | FUNC & '(' & TERM & ZeroOrMore(',' & TERM)
> > & ')'

> > etc.

> > For some reason though (probably a stupid mistake on my part) this
> > fails to parse the following:

> > parser = TERM.parse_string
> > TERM.parse("p(X)")

> > Am I doing something completely wrong?

> > Thank you kindly,
> > Gregory Gelfond


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.