Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Parser Output3-28-2011Opening DiscussionMinute essay comments:What does asInstanceOf[] do?Parser usage.Default Parser OutputStrings match themselves.RegEx and tokens give strings.P~Q gives back ~(p,q), where p and q are the matches of P and Q.P | Q gives either p or q.rep(P) or repsep(P,seperator) give a list of p values.opt(P) gives an Option, either Some(p) or None.Specifying OutputYou can override the default of P by using P ^^ f. The f is a function (or partial function) that takes the normal output of P.The output you get is f(p).Example uses:floatingPointNumber ^^ (_.toDouble)“true” ^^ (x=>true)“(“~ident~”,”~ident~”)” ^^ { case “(“~i1~”,”~i2~”)” => (i1,i2) }Ignoring Parts of the ParseIn something like the last example shown, there are strings that are part of the parse that really don't impact the result.When you have this type of situation you can use ~> or <~ instead of just ~. The aprse result will only include what the arrow points to.“(“~>ident~”,”~ident<~”)” ^^ { case i1~”,”~i2 => (i1,i2) }Our CodeLet's work on putting this type of functionality in our formula code.We had the parser, but we want to parse to a tree similar to what we produced with the recursive parser we wrote ourselves.With that we can make this alternate code functional.Minute EssayWhat questions do you have about parsers, regex, or grammars?Next class we do spatial trees.IcP #7 is next class.Spring classes and Web


View Full Document

TRINITY CSCI 1321 - Parser Output

Documents in this Course
Recursion

Recursion

11 pages

Iterators

Iterators

10 pages

Actors

Actors

9 pages

Recursion

Recursion

15 pages

Recursion

Recursion

10 pages

Threads

Threads

7 pages

Trees

Trees

11 pages

Load more
Download Parser Output
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Parser Output and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Parser Output 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?