Results of 1 - 1 of about 826 for $1 (0.065 sec.)
- Example (Wisent Parser Development)
- #score: 5500
- @digest: 0ec13eae3e97e4feee890957e7531148
- @id: 244028
- @mdate: 2024-01-18T13:18:02Z
- @size: 3475
- @type: text/html
- content-type: text/html; charset=utf-8
- dc.title: gnu.org
- description: Example (Wisent Parser Development)
- distribution: global
- generator: makeinfo
- icbm: 42.256233,-71.006581
- keywords: Example (Wisent Parser Development)
- resource-type: document
- viewport: width=device-width,initial-scale=1
- #keywords: nonassoc (7884), progn (3352), wisent (3254), exp (2616), grammar (2163), associativity (2001), expt (1824), exponentiation (1256), infix (1165), negation (1082), neg (1038), bison (694), semantic (497), precedence (442), left (390), terminals (341), comparison (290), arithmetic (276), format (256), compiling (238), num (212), expressions (192), example (168), line (138), terminal (138), error (130), input (128), number (116), development (113), right (101), details (94), like (57)
- Next: Compiling a grammar , Previous: Grammar format , Up: Wisent Grammar [ Contents ][ Index ] 2.2 Example Here is an example to parse simple infix arithmetic expressions. See (bison)Infix Calc , in the Bison manual for details. '( ;; Terminals (NUM) ;; Terminal associativity & precedence ((nonassoc ?=) (left ?- ?+) (left ?* ?/) (left NEG) (right ?^)) ;; Rules (input ((line)) ((input line) (format "%s %s" $1 $2)) ) (line ((?;) (progn ";")) ((exp ?;) (format "%s;" $1)) ((error ?;) (progn "Error;"))) ) (exp ((NUM) (string-to-number $1)) ((exp ?= exp) (= $1 $3)) ((exp ?+ exp) (+ $1 $3)) ((exp ?- exp) (- $1 $3)) ((exp ?* exp) (* $1 $3)) ((exp ?/ exp) (/ $1 $3)) ((?- exp) [NEG] (- $2)) ((exp ?^ exp) (expt $1 $3)) ((?\( exp ?\)) (progn $2)) ) ) In the bison-like WY format (see How to use Wisent with Semantic ) the grammar looks like this: %token <number> NUM %nonassoc '=' ;; comparison %left '-' '+' %left '*' '/' %left NEG ;; negation--unary minus %right '^' ;; exponentiation %% input: line | input line (format "%s %s" $1 $2) ; line: ';' {";"} | exp ';' (format "%s;" $1) | error ';' {"Error;"} ; exp: NUM (string-to-number $1) | exp '=' exp (= $1 $3) | exp '+' exp (+ $1 $3) | exp '-' exp (- $1 $3) | exp '*' exp (* $1 $3) | exp '/' exp (/ $1 $3) | '-' exp %prec NEG (- $2) | exp '^' exp (expt $1 $3) | '(' exp ')' {$2} ; %%
...
-
http://www.gnu.org/savannah-checkouts/gnu/emacs/manual/html_node/wisent/Example.html
- [detail]
- [similar]
PREV
NEXT