Skip to content

wangp/tdop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Top-down operator precedence parsing

Learning about Pratt parsing. (A similar, if not the same, technique is used to parse Mercury terms, and is presumably common to Prolog systems.)

The toy grammar implemented is:

e --> NAME
    ; INTEGER
    ; name = e
    ; e ? e : e
    ; prefixop e
    ; e postfixop
    ; e infixop e
    ; e ( args )
    ; ( e )

args --> zero or more comma-separated e

prefixop --> + ; - ; !

postfixop --> !

infixop --> + ; - ; * ; / ; ^ ; < ; >

where < and > are non-associative.

This is a better introduction than most: Pratt Parsers: Expression Parsing Made Easy

Author

Peter Wang [email protected]

About

Top-down operator precedence parsing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published