17ec681f3Smrg1. Introduction to rules-ng-ng text format 27ec681f3Smrg 37ec681f3SmrgThis-specification defines a text format that can be converted to and from rules-ng-ng XML. 47ec681f3SmrgIt is intended to allow to create rules-ng-ng files with much less typing and with a more readable text. 57ec681f3Smrgxml2text can convert rules-ng-ng XML to this text format 67ec681f3Smrgtext2xml can convert this text format to rules-ng-ng XML 77ec681f3Smrg 87ec681f3SmrgThis specification is an addendum to the rules-ng-ng specification and assumes familiarity with it. 97ec681f3Smrg 107ec681f3Smrg2. Format 117ec681f3Smrg 127ec681f3Smrg2.1. Line format 137ec681f3Smrg 147ec681f3SmrgThe initial indentation of a line is divided by 8 and the result determines the position in the document structure (similar to the Python language). 157ec681f3SmrgA "//" anywhere in the line causes the rest to be converted to an XML comment (like C++) 167ec681f3SmrgA line starting with ":" creates a <doc> tag with the rest of the line (excluding anything starting with //). 177ec681f3SmrgThe content of multiple lines starting with ":" is merged in a single <doc> tag. 187ec681f3Smrg 197ec681f3Smrg2.2. Tokenization 207ec681f3Smrg 217ec681f3SmrgThe line is then tokenized. 227ec681f3SmrgToken are generally continuous strings on non-whitespace characters, with some exceptions 237ec681f3SmrgSome characters (such as ":", "=" and "-") form a single-character token. 247ec681f3SmrgText within double quotes generates a <brief> tag. 257ec681f3SmrgAny token formatted as ATTR(VALUE) generates an ATTR="VALUE" attribute. No whitespace allowed between ATTR and the '(' character. 267ec681f3SmrgAny token formatted as (VALUE) generates a variants="VALUE" attribute. 277ec681f3SmrgAny token formatted as (VARSET=VALUE) generates a varset="VARSET" variants="VALUE" attribute. 287ec681f3Smrg 297ec681f3Smrg2.3. Special token sequences 307ec681f3Smrg 317ec681f3SmrgThese sequences are recognized and extracted before matching the line format: 327ec681f3Smrg 337ec681f3Smrg: NUM 347ec681f3Smrg set REGLIKE to regNUM 357ec681f3Smrg you must specify a type if the reg is anonymous 367ec681f3Smrg the : is recognized only if it is the third or successive token (and not the last) to avoid ambiguity with bitfields and generic tags 377ec681f3Smrg 387ec681f3Smrg{ STRIDE } 397ec681f3Smrg stride="STRIDE" attribute 407ec681f3Smrg 417ec681f3Smrg[ LENGTH ] 427ec681f3Smrg length="LENGTH" attribute 437ec681f3Smrg 447ec681f3Smrg!FLAGS 457ec681f3Smrg access="FLAGS" 467ec681f3Smrg no whitespace allowed after '!' 477ec681f3Smrg 487ec681f3Smrg:= 497ec681f3Smrg at the end of the line 507ec681f3Smrg set REGLIKE to "stripe" 517ec681f3Smrg 527ec681f3Smrg= 537ec681f3Smrg at the end of the line 547ec681f3Smrg set REGLIKE to "array" 557ec681f3Smrg 567ec681f3Smrginline 577ec681f3Smrg at the beginning of the line 587ec681f3Smrg inline="yes" attribute 597ec681f3Smrg 607ec681f3Smrg2.4. Line patterns 617ec681f3Smrg 627ec681f3SmrgThe following line patterns are understood. 637ec681f3SmrgOnly word tokens are used to match lines. 647ec681f3SmrgAll tokens with special meaning are treated separately as described above. 657ec681f3Smrg[FOO] means that FOO is optional 667ec681f3Smrg 677ec681f3Smrg#import "FILE" 687ec681f3Smrg <import file="FILE"/> 697ec681f3Smrg 707ec681f3Smrg#pragma regNUM 717ec681f3Smrg REGLIKE is now set by default to regNUM instead of reg32 727ec681f3Smrg 737ec681f3Smrg@TAG [NAME] 747ec681f3Smrg <TAG name="NAME"/> 757ec681f3Smrg use this if there are no children 767ec681f3Smrg 777ec681f3SmrgTAG [NAME] : 787ec681f3Smrg <TAG name="NAME"> 797ec681f3Smrg use this if there are children 807ec681f3Smrg 817ec681f3SmrgTOKEN 827ec681f3Smrg <value value="TOKEN" /> if inside a reg or enum and TOKEN starts with a digit 837ec681f3Smrg <value name="TOKEN" /> if inside a reg or enum and TOKEN does not start with a digit 847ec681f3Smrg <REGLIKE offset="TOKEN" /> otherwise 857ec681f3Smrg 867ec681f3SmrgPOS NAME 877ec681f3Smrg <bitfield low="POS" high="POS" name="NAME"/> if inside a reg or bitset 887ec681f3Smrg <REGLIKE offset="POS" name="NAME"> otherwise 897ec681f3Smrg 907ec681f3SmrgLOW - HIGH NAME [TYPE] 917ec681f3Smrg <bitfield low="LOW" high="HIGH" name="NAME" type="TYPE"/> 927ec681f3Smrg 937ec681f3SmrgVALUE = NAME 947ec681f3Smrg <value value="VALUE" name="NAME"/> 957ec681f3Smrg 967ec681f3Smrguse WHAT NAME 977ec681f3Smrg <use-WHAT name="NAME" /> 987ec681f3Smrg 997ec681f3SmrgOFFSET NAME [TYPE] 1007ec681f3Smrg <REGLIKE offset="OFFSET" name="NAME" type="TYPE"> 1017ec681f3Smrg 102