Skip to content

Releases: ehwan/RustyLR

v1.3.0

10 Aug 12:32
Compare
Choose a tag to compare

Full Changelog: v1.2.0...v1.3.0

make parse error messages much readable

Sample error message:

error: Invalid Terminal: '*'
Expected one of: ' ', '(', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
-------------------------------Backtracing state--------------------------------
M -> M '*' • M
-----------------------------------Prev state-----------------------------------
M -> M • '*' M
-----------------------------------Prev state-----------------------------------
A -> • A '+' A
A -> A '+' • A
A -> • M
M -> • M '*' M
-----------------------------------Prev state-----------------------------------
A -> A • '+' A
-----------------------------------Prev state-----------------------------------
A -> • A '+' A
E -> • A
Augmented -> • E '\0'

v1.2.0

10 Aug 07:13
Compare
Choose a tag to compare

Full Changelog: v1.1.0...v1.2.0

Add support for regex character set, range pattern

%token lparen '(';
%token rparen ')';
%token zero '0';
...
%token nine '9';

A: [zero-nine]+; // zero to nine

B: [^lparen rparen]; // any token except lparen and rparen

C: [lparen rparen one-nine]*; // lparen and rparen, and one to nine

Note that in range pattern [first-last], the range is constructed by the order of the %token directives, not by the actual value of the token. If you define tokens in the following order:

%token one '1';
%token two '2';
...
%token zero '0';
%token nine '9';

The range [zero-nine] will be ['0', '9'], not ['0'-'9'].

v1.1.0

08 Aug 06:34
Compare
Choose a tag to compare

Full Changelog: v1.0.0...v1.1.0

macro generates an enum for non-terminal symbols.

  • name of generated enum is <StartSymbol>NonTerminals
  • enum holds every non terminal symbols in the CFGs.
  • it may contains auto-generated rules ( e.g. Augmented, or for '+', '*', '?' pattern )

v1.0.0

07 Aug 14:58
Compare
Choose a tag to compare

Full Changelog: v0.12.1...v1.0.0

variables in reduce action now takes the value itself, include terminal

%tokentype char;
%token plus ... ;
A(i32): A plus {
    println!( "A is i32: {}", A );
    println!( "plus is char: {}", plus ); // not a reference `&char`
}
;
  • removed slice capture
  • you can use Vec as <RuleType> manually.
  • remove TermData, NonTermData

Reduce action can be omitted if the production rule has only one token data

// <RuleType> not defined for 'Ws0'
Ws0: ... ; 

// 'Number' will be used.
// since Number is the only token that holds data
A(i32): Ws0 Number Ws0;
  • bootstrapped new syntax
  • fix calculator example following new syntax
  • return Err if RuleType is defined but action is not defined

v0.12.1

06 Aug 14:45
Compare
Choose a tag to compare

Full Changelog: v0.11.2...v0.12.1

Add syntax to support regex pattern partially

  • support * (zero or more), + (one or more), ? (zero or one)

Example:

E : A plus? a2=A*
  {
    println!("Value of 1st A: {}", A.value); // i32
    println!("Slice of 1st A: {:?}", A.slice);
    println!("Value of 2nd As: {:?}", a2.value); // Vec<i32>
    println!("Slice of 2nd As: {:?}", a2.slice);

    if let plus.slice.len() == 0 {
        // plus is not captured
    }else {
        // plus is captured
    }
  }
  ;

For regex pattern, <RuleType> will be modified by following:

Pattern Non-Terminal
<RuleType>=T
Non-Terminal
<RuleType>=(not defined)
Terminal
'*' Vec<T> (not defined) (not defined)
'+' Vec<T> (not defined) (not defined)
'?' Option<T> (not defined) (not defined)

fix some HashMap to BTreeMap for consistent output

  • same output for same input.
  • HashMap was randomizing the id of state, tokens

v0.11.2

06 Aug 06:36
Compare
Choose a tag to compare

Full Changelog: v0.10.0...v0.11.2

  • manually expand macros of bootstrap to avoid deep-recursive dependency
  • add lr1_runtime!, lalr1_runtime! macro.
    - This call grammar.build() on runtime
    - The generated code will be about 1/10 in size ( rust-analyzer dies a lot due to TONS of code generated by former macro )

v0.10.0

05 Aug 12:25
Compare
Choose a tag to compare

Full Changelog: v0.9.0...v0.10.0

Bootstrapped proc-macro line parser.

cargo's version control is simply amazing

  • add %moduleprefix syntax for future bootstrapping

v0.9.0

05 Aug 03:02
Compare
Choose a tag to compare

Full Changelog: v0.8.0...v0.9.0

  • Add support for custom error type in reduce action. String will be used if not set.
%error <ErrType>;
...

A: token0 token1 token2 {
  return Err( <ErrType>::new() );
};
match parser.feed( ... ) {
    Ok(_) => {},
    Err(e) => {
        match e {
            rysty_lr::ParseError::ReduceAction( err_from_action ) => { ... }
            _ => {}
        }
    }
}
  • clean some doc comments

v0.8.0

04 Aug 07:30
Compare
Choose a tag to compare

Full Changelog: v0.7.2...v0.8.0

Fixed syntax for capturing token data into variable.

  • s0, s1, ... v0, v1, ... are removed
  • can access data by its name directly
  • can remap the variable name
M(i32) : M star m2=M { *M * *m2 }
      | P { *P }
      ;
  • fixed eof as reserved keyword

v0.7.2

03 Aug 09:28
Compare
Choose a tag to compare

Full Changelog: v0.7.0...v0.7.2

  • add more error checking and emit compile_error
    • check if <RuleType> is enclosed with parenthesis '(' and ')'
    • check if <ReduceAction> is enclosed with braces '{' and '}'
  • removed unnecessary clone()
  • moved all trait bounds in impl to each functions
  • add documents about proc-macro syntax in README