|
-
Feb 15th, 2003, 07:58 AM
#1
Thread Starter
transcendental analytic
Anyone a parser expert?
If I have to eliminate left recursion then wouldn't all operators become right associative? How do i get around this?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 15th, 2003, 09:05 AM
#2
Frenzied Member
If you perform full recursive descent parsing - to the level of unary operators, as you 'back out' you do not lose left or right associative properties.
If you are working with natural language, forget it. No descent parser will ever work correctly, because the rules change on the fly as a function of antecedence and hermaneutic analysis.
What the heck are you doing? Writing another compiler?
-
Feb 15th, 2003, 09:37 AM
#3
Thread Starter
transcendental analytic
i'm basically writing a compiler that compiles its own rules, and yes i'm thinking about using it for natural languages as well.
I need to preserve the associative properties, if I use full recursive descent parsing, how does this affect parsing of natural languages?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 16th, 2003, 02:55 PM
#4
Thread Starter
transcendental analytic
problem with recursion
Say If I have these rules
A -> A + i
A -> i
where i can be any numeric, and the parser finds 1*2
How do you prevent the infinite recursion, it would apply A -> A + i wouldn't it? I want it to die and say that the expression cannot be parsed.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 16th, 2003, 03:48 PM
#5
Something I've just noticed. In what way would A + i fit into the expression 2*3?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 17th, 2003, 11:41 AM
#6
Thread Starter
transcendental analytic
well i shouldn't have said apply, I have a parser tree that looks like this:
A
|_(A)
|...|_+
|.......|_i
|_i
(A) is expanded with A here.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 17th, 2003, 01:02 PM
#7
Oh, so it's not that you can't parse the source, but that your tree would blow up to infinity?
Well, isn't that the same as "self-referencing statements are not statements"? I remember a discussion somewhere 
Anyway, you must make sure that the A inside the definition of A isn't expanded but is instead a reference.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 17th, 2003, 01:58 PM
#8
Thread Starter
transcendental analytic
it is. Left recursion isn't suppose to work in regular top-down parsers, but how i'm going to avoid it with a full-backup recursive descent parser is still a mystery to me
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 17th, 2003, 03:53 PM
#9
Frenzied Member
You said yes to natural language. That means no to a full descent parser of any kind unless:
You have a parser that maintains a state table, and a key table
From my class notes on this stuff from 20+ years ago:
A Table-Driven Finite-State Parser routine is a general-
purpose, table-driven parser implemented as a finite-state
automaton. It parses a string and returns a message
indicating whether or not the input string is parseable -
ie., valid under the given rule set.
You need finite states & keys to be able to:
1. generate your own parsing rules ie., key table additions.
2. implement parsing natural language
In other words, run the automaton first, then parse based on the state-table. A two pass parse. (sorry for the alliteration) 
The key table 'remembers' the antecedents for you. The state table allows you to navigate. You can use these in phase II.
-
Feb 17th, 2003, 04:14 PM
#10
Thread Starter
transcendental analytic
The key table 'remembers' the antecedents for you. The state table allows you to navigate. You can use these in phase II.
I'm not going to implement support for antecedents or anything that is even close to natural languages yet. Besides this should not be a concern for the parser, but will be implemented on a higher level. When the parser compiles the program, it transform the expression as each rule is a function, supplied by the user, thus you could pretty much do anything in a natural language.
What i need now is support for right/left associative expressions.. How do i go avoiding the recursion problem?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|