mirror of
https://github.com/fluencelabs/lalrpop
synced 2025-04-24 18:52:16 +00:00
Convert all CRLF line endings to LF.
This commit is contained in:
parent
0c67bbed06
commit
802ac11a20
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -1,3 +1,3 @@
|
|||||||
* text=auto
|
* text=auto
|
||||||
|
|
||||||
lalrpop/src/parser/lrgrammar.lalrpop text eol=lf
|
lalrpop/src/parser/lrgrammar.lalrpop text eol=lf
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,157 +1,157 @@
|
|||||||
%{
|
%{
|
||||||
/*
|
/*
|
||||||
* scan.l
|
* scan.l
|
||||||
*
|
*
|
||||||
* lex input file for pascal scanner
|
* lex input file for pascal scanner
|
||||||
*
|
*
|
||||||
* extensions: to ways to spell "external" and "->" ok for "^".
|
* extensions: to ways to spell "external" and "->" ok for "^".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
int line_no = 1;
|
int line_no = 1;
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
A [aA]
|
A [aA]
|
||||||
B [bB]
|
B [bB]
|
||||||
C [cC]
|
C [cC]
|
||||||
D [dD]
|
D [dD]
|
||||||
E [eE]
|
E [eE]
|
||||||
F [fF]
|
F [fF]
|
||||||
G [gG]
|
G [gG]
|
||||||
H [hH]
|
H [hH]
|
||||||
I [iI]
|
I [iI]
|
||||||
J [jJ]
|
J [jJ]
|
||||||
K [kK]
|
K [kK]
|
||||||
L [lL]
|
L [lL]
|
||||||
M [mM]
|
M [mM]
|
||||||
N [nN]
|
N [nN]
|
||||||
O [oO]
|
O [oO]
|
||||||
P [pP]
|
P [pP]
|
||||||
Q [qQ]
|
Q [qQ]
|
||||||
R [rR]
|
R [rR]
|
||||||
S [sS]
|
S [sS]
|
||||||
T [tT]
|
T [tT]
|
||||||
U [uU]
|
U [uU]
|
||||||
V [vV]
|
V [vV]
|
||||||
W [wW]
|
W [wW]
|
||||||
X [xX]
|
X [xX]
|
||||||
Y [yY]
|
Y [yY]
|
||||||
Z [zZ]
|
Z [zZ]
|
||||||
NQUOTE [^']
|
NQUOTE [^']
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
{A}{N}{D} return(AND);
|
{A}{N}{D} return(AND);
|
||||||
{A}{R}{R}{A}{Y} return(ARRAY);
|
{A}{R}{R}{A}{Y} return(ARRAY);
|
||||||
{C}{A}{S}{E} return(CASE);
|
{C}{A}{S}{E} return(CASE);
|
||||||
{C}{O}{N}{S}{T} return(CONST);
|
{C}{O}{N}{S}{T} return(CONST);
|
||||||
{D}{I}{V} return(DIV);
|
{D}{I}{V} return(DIV);
|
||||||
{D}{O} return(DO);
|
{D}{O} return(DO);
|
||||||
{D}{O}{W}{N}{T}{O} return(DOWNTO);
|
{D}{O}{W}{N}{T}{O} return(DOWNTO);
|
||||||
{E}{L}{S}{E} return(ELSE);
|
{E}{L}{S}{E} return(ELSE);
|
||||||
{E}{N}{D} return(END);
|
{E}{N}{D} return(END);
|
||||||
{E}{X}{T}{E}{R}{N} |
|
{E}{X}{T}{E}{R}{N} |
|
||||||
{E}{X}{T}{E}{R}{N}{A}{L} return(EXTERNAL);
|
{E}{X}{T}{E}{R}{N}{A}{L} return(EXTERNAL);
|
||||||
{F}{O}{R} return(FOR);
|
{F}{O}{R} return(FOR);
|
||||||
{F}{O}{R}{W}{A}{R}{D} return(FORWARD);
|
{F}{O}{R}{W}{A}{R}{D} return(FORWARD);
|
||||||
{F}{U}{N}{C}{T}{I}{O}{N} return(FUNCTION);
|
{F}{U}{N}{C}{T}{I}{O}{N} return(FUNCTION);
|
||||||
{G}{O}{T}{O} return(GOTO);
|
{G}{O}{T}{O} return(GOTO);
|
||||||
{I}{F} return(IF);
|
{I}{F} return(IF);
|
||||||
{I}{N} return(IN);
|
{I}{N} return(IN);
|
||||||
{L}{A}{B}{E}{L} return(LABEL);
|
{L}{A}{B}{E}{L} return(LABEL);
|
||||||
{M}{O}{D} return(MOD);
|
{M}{O}{D} return(MOD);
|
||||||
{N}{I}{L} return(NIL);
|
{N}{I}{L} return(NIL);
|
||||||
{N}{O}{T} return(NOT);
|
{N}{O}{T} return(NOT);
|
||||||
{O}{F} return(OF);
|
{O}{F} return(OF);
|
||||||
{O}{R} return(OR);
|
{O}{R} return(OR);
|
||||||
{O}{T}{H}{E}{R}{W}{I}{S}{E} return(OTHERWISE);
|
{O}{T}{H}{E}{R}{W}{I}{S}{E} return(OTHERWISE);
|
||||||
{P}{A}{C}{K}{E}{D} return(PACKED);
|
{P}{A}{C}{K}{E}{D} return(PACKED);
|
||||||
{B}{E}{G}{I}{N} return(PBEGIN);
|
{B}{E}{G}{I}{N} return(PBEGIN);
|
||||||
{F}{I}{L}{E} return(PFILE);
|
{F}{I}{L}{E} return(PFILE);
|
||||||
{P}{R}{O}{C}{E}{D}{U}{R}{E} return(PROCEDURE);
|
{P}{R}{O}{C}{E}{D}{U}{R}{E} return(PROCEDURE);
|
||||||
{P}{R}{O}{G}{R}{A}{M} return(PROGRAM);
|
{P}{R}{O}{G}{R}{A}{M} return(PROGRAM);
|
||||||
{R}{E}{C}{O}{R}{D} return(RECORD);
|
{R}{E}{C}{O}{R}{D} return(RECORD);
|
||||||
{R}{E}{P}{E}{A}{T} return(REPEAT);
|
{R}{E}{P}{E}{A}{T} return(REPEAT);
|
||||||
{S}{E}{T} return(SET);
|
{S}{E}{T} return(SET);
|
||||||
{T}{H}{E}{N} return(THEN);
|
{T}{H}{E}{N} return(THEN);
|
||||||
{T}{O} return(TO);
|
{T}{O} return(TO);
|
||||||
{T}{Y}{P}{E} return(TYPE);
|
{T}{Y}{P}{E} return(TYPE);
|
||||||
{U}{N}{T}{I}{L} return(UNTIL);
|
{U}{N}{T}{I}{L} return(UNTIL);
|
||||||
{V}{A}{R} return(VAR);
|
{V}{A}{R} return(VAR);
|
||||||
{W}{H}{I}{L}{E} return(WHILE);
|
{W}{H}{I}{L}{E} return(WHILE);
|
||||||
{W}{I}{T}{H} return(WITH);
|
{W}{I}{T}{H} return(WITH);
|
||||||
[a-zA-Z]([a-zA-Z0-9])+ return(IDENTIFIER);
|
[a-zA-Z]([a-zA-Z0-9])+ return(IDENTIFIER);
|
||||||
|
|
||||||
":=" return(ASSIGNMENT);
|
":=" return(ASSIGNMENT);
|
||||||
'({NQUOTE}|'')+' return(CHARACTER_STRING);
|
'({NQUOTE}|'')+' return(CHARACTER_STRING);
|
||||||
":" return(COLON);
|
":" return(COLON);
|
||||||
"," return(COMMA);
|
"," return(COMMA);
|
||||||
[0-9]+ return(DIGSEQ);
|
[0-9]+ return(DIGSEQ);
|
||||||
"." return(DOT);
|
"." return(DOT);
|
||||||
".." return(DOTDOT);
|
".." return(DOTDOT);
|
||||||
"=" return(EQUAL);
|
"=" return(EQUAL);
|
||||||
">=" return(GE);
|
">=" return(GE);
|
||||||
">" return(GT);
|
">" return(GT);
|
||||||
"[" return(LBRAC);
|
"[" return(LBRAC);
|
||||||
"<=" return(LE);
|
"<=" return(LE);
|
||||||
"(" return(LPAREN);
|
"(" return(LPAREN);
|
||||||
"<" return(LT);
|
"<" return(LT);
|
||||||
"-" return(MINUS);
|
"-" return(MINUS);
|
||||||
"<>" return(NOTEQUAL);
|
"<>" return(NOTEQUAL);
|
||||||
"+" return(PLUS);
|
"+" return(PLUS);
|
||||||
"]" return(RBRAC);
|
"]" return(RBRAC);
|
||||||
[0-9]+"."[0-9]+ return(REALNUMBER);
|
[0-9]+"."[0-9]+ return(REALNUMBER);
|
||||||
")" return(RPAREN);
|
")" return(RPAREN);
|
||||||
";" return(SEMICOLON);
|
";" return(SEMICOLON);
|
||||||
"/" return(SLASH);
|
"/" return(SLASH);
|
||||||
"*" return(STAR);
|
"*" return(STAR);
|
||||||
"**" return(STARSTAR);
|
"**" return(STARSTAR);
|
||||||
"->" |
|
"->" |
|
||||||
"^" return(UPARROW);
|
"^" return(UPARROW);
|
||||||
|
|
||||||
"(*" |
|
"(*" |
|
||||||
"{" { register int c;
|
"{" { register int c;
|
||||||
while ((c = input()))
|
while ((c = input()))
|
||||||
{
|
{
|
||||||
if (c == '}')
|
if (c == '}')
|
||||||
break;
|
break;
|
||||||
else if (c == '*')
|
else if (c == '*')
|
||||||
{
|
{
|
||||||
if ((c = input()) == ')')
|
if ((c = input()) == ')')
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
unput (c);
|
unput (c);
|
||||||
}
|
}
|
||||||
else if (c == '\n')
|
else if (c == '\n')
|
||||||
line_no++;
|
line_no++;
|
||||||
else if (c == 0)
|
else if (c == 0)
|
||||||
commenteof();
|
commenteof();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ \t\f] ;
|
[ \t\f] ;
|
||||||
|
|
||||||
\n line_no++;
|
\n line_no++;
|
||||||
|
|
||||||
. { fprintf (stderr,
|
. { fprintf (stderr,
|
||||||
"'%c' (0%o): illegal charcter at line %d\n",
|
"'%c' (0%o): illegal charcter at line %d\n",
|
||||||
yytext[0], yytext[0], line_no);
|
yytext[0], yytext[0], line_no);
|
||||||
}
|
}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
commenteof()
|
commenteof()
|
||||||
{
|
{
|
||||||
fprintf (stderr, "unexpected EOF inside comment at line %d\n",
|
fprintf (stderr, "unexpected EOF inside comment at line %d\n",
|
||||||
line_no);
|
line_no);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
yywrap ()
|
yywrap ()
|
||||||
{
|
{
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
|||||||
LALRPOP support conditional compilation of public non-terminal declarations via `#[cfg(feature = "FEATUERE")]` attributes.
|
LALRPOP support conditional compilation of public non-terminal declarations via `#[cfg(feature = "FEATUERE")]` attributes.
|
||||||
If run in a build script LALRPOP will automatically pickup the features from `cargo` and use those. Alternatively an explicit set of features can be set using the `Configuration` type.
|
If run in a build script LALRPOP will automatically pickup the features from `cargo` and use those. Alternatively an explicit set of features can be set using the `Configuration` type.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[cfg(feature = "FEATURE")]
|
#[cfg(feature = "FEATURE")]
|
||||||
pub MyRule : () = {
|
pub MyRule : () = {
|
||||||
...
|
...
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
@ -8,7 +8,7 @@ workspace = ".."
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
diff = "0.1.9"
|
diff = "0.1.9"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
|
|
||||||
[dependencies.lalrpop-util]
|
[dependencies.lalrpop-util]
|
||||||
path = "../lalrpop-util"
|
path = "../lalrpop-util"
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,58 +1,58 @@
|
|||||||
// Need this for rusty_peg
|
// Need this for rusty_peg
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
// I hate this lint.
|
// I hate this lint.
|
||||||
#![allow(unused_parens)]
|
#![allow(unused_parens)]
|
||||||
// The builtin tests don't cover the CLI and so forth, and it's just
|
// The builtin tests don't cover the CLI and so forth, and it's just
|
||||||
// too darn annoying to try and make them do so.
|
// too darn annoying to try and make them do so.
|
||||||
#![cfg_attr(test, allow(dead_code))]
|
#![cfg_attr(test, allow(dead_code))]
|
||||||
|
|
||||||
extern crate ascii_canvas;
|
extern crate ascii_canvas;
|
||||||
extern crate atty;
|
extern crate atty;
|
||||||
extern crate bit_set;
|
extern crate bit_set;
|
||||||
extern crate diff;
|
extern crate diff;
|
||||||
extern crate ena;
|
extern crate ena;
|
||||||
extern crate itertools;
|
extern crate itertools;
|
||||||
#[cfg_attr(any(feature = "test", test), macro_use)]
|
#[cfg_attr(any(feature = "test", test), macro_use)]
|
||||||
extern crate lalrpop_util;
|
extern crate lalrpop_util;
|
||||||
extern crate petgraph;
|
extern crate petgraph;
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
extern crate regex_syntax;
|
extern crate regex_syntax;
|
||||||
extern crate sha2;
|
extern crate sha2;
|
||||||
extern crate string_cache;
|
extern crate string_cache;
|
||||||
extern crate term;
|
extern crate term;
|
||||||
extern crate unicode_xid;
|
extern crate unicode_xid;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
// hoist the modules that define macros up earlier
|
// hoist the modules that define macros up earlier
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod rust;
|
mod rust;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod log;
|
mod log;
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
mod build;
|
mod build;
|
||||||
mod collections;
|
mod collections;
|
||||||
mod file_text;
|
mod file_text;
|
||||||
mod grammar;
|
mod grammar;
|
||||||
mod kernel_set;
|
mod kernel_set;
|
||||||
mod lexer;
|
mod lexer;
|
||||||
mod lr1;
|
mod lr1;
|
||||||
mod message;
|
mod message;
|
||||||
mod normalize;
|
mod normalize;
|
||||||
mod parser;
|
mod parser;
|
||||||
mod session;
|
mod session;
|
||||||
mod tls;
|
mod tls;
|
||||||
mod tok;
|
mod tok;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod generate;
|
mod generate;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_util;
|
mod test_util;
|
||||||
|
|
||||||
pub use api::process_root;
|
pub use api::process_root;
|
||||||
pub use api::process_root_unconditionally;
|
pub use api::process_root_unconditionally;
|
||||||
pub use api::Configuration;
|
pub use api::Configuration;
|
||||||
use ascii_canvas::style;
|
use ascii_canvas::style;
|
||||||
|
@ -1,84 +1,84 @@
|
|||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use grammar::parse_tree::*;
|
use grammar::parse_tree::*;
|
||||||
use grammar::pattern::*;
|
use grammar::pattern::*;
|
||||||
use lalrpop_util;
|
use lalrpop_util;
|
||||||
use tok;
|
use tok;
|
||||||
|
|
||||||
#[cfg(not(any(feature = "test", test)))]
|
#[cfg(not(any(feature = "test", test)))]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod lrgrammar;
|
mod lrgrammar;
|
||||||
|
|
||||||
#[cfg(any(feature = "test", test))]
|
#[cfg(any(feature = "test", test))]
|
||||||
lalrpop_mod!(
|
lalrpop_mod!(
|
||||||
// ---------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------
|
||||||
// NOTE: Run `cargo build -p lalrpop` once before running `cargo test` to create this file
|
// NOTE: Run `cargo build -p lalrpop` once before running `cargo test` to create this file
|
||||||
// ---------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
lrgrammar,
|
lrgrammar,
|
||||||
"/src/parser/lrgrammar.rs"
|
"/src/parser/lrgrammar.rs"
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test;
|
mod test;
|
||||||
|
|
||||||
pub enum Top {
|
pub enum Top {
|
||||||
Grammar(Grammar),
|
Grammar(Grammar),
|
||||||
Pattern(Pattern<TypeRef>),
|
Pattern(Pattern<TypeRef>),
|
||||||
MatchMapping(TerminalString),
|
MatchMapping(TerminalString),
|
||||||
TypeRef(TypeRef),
|
TypeRef(TypeRef),
|
||||||
GrammarWhereClauses(Vec<WhereClause<TypeRef>>),
|
GrammarWhereClauses(Vec<WhereClause<TypeRef>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ParseError<'input> = lalrpop_util::ParseError<usize, tok::Tok<'input>, tok::Error>;
|
pub type ParseError<'input> = lalrpop_util::ParseError<usize, tok::Tok<'input>, tok::Error>;
|
||||||
|
|
||||||
macro_rules! parser {
|
macro_rules! parser {
|
||||||
($input: expr, $offset: expr, $pat: ident, $tok: ident) => {{
|
($input: expr, $offset: expr, $pat: ident, $tok: ident) => {{
|
||||||
let input = $input;
|
let input = $input;
|
||||||
let tokenizer =
|
let tokenizer =
|
||||||
iter::once(Ok((0, tok::Tok::$tok, 0))).chain(tok::Tokenizer::new(input, $offset));
|
iter::once(Ok((0, tok::Tok::$tok, 0))).chain(tok::Tokenizer::new(input, $offset));
|
||||||
lrgrammar::TopParser::new()
|
lrgrammar::TopParser::new()
|
||||||
.parse(input, tokenizer)
|
.parse(input, tokenizer)
|
||||||
.map(|top| match top {
|
.map(|top| match top {
|
||||||
Top::$pat(x) => x,
|
Top::$pat(x) => x,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
})
|
})
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_grammar<'input>(input: &'input str) -> Result<Grammar, ParseError<'input>> {
|
pub fn parse_grammar<'input>(input: &'input str) -> Result<Grammar, ParseError<'input>> {
|
||||||
let mut grammar = try!(parser!(input, 0, Grammar, StartGrammar));
|
let mut grammar = try!(parser!(input, 0, Grammar, StartGrammar));
|
||||||
|
|
||||||
// find a unique prefix that does not appear anywhere in the input
|
// find a unique prefix that does not appear anywhere in the input
|
||||||
while input.contains(&grammar.prefix) {
|
while input.contains(&grammar.prefix) {
|
||||||
grammar.prefix.push('_');
|
grammar.prefix.push('_');
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(grammar)
|
Ok(grammar)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_pattern<'input>(
|
fn parse_pattern<'input>(
|
||||||
input: &'input str,
|
input: &'input str,
|
||||||
offset: usize,
|
offset: usize,
|
||||||
) -> Result<Pattern<TypeRef>, ParseError<'input>> {
|
) -> Result<Pattern<TypeRef>, ParseError<'input>> {
|
||||||
parser!(input, offset, Pattern, StartPattern)
|
parser!(input, offset, Pattern, StartPattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_match_mapping<'input>(
|
fn parse_match_mapping<'input>(
|
||||||
input: &'input str,
|
input: &'input str,
|
||||||
offset: usize,
|
offset: usize,
|
||||||
) -> Result<MatchMapping, ParseError<'input>> {
|
) -> Result<MatchMapping, ParseError<'input>> {
|
||||||
parser!(input, offset, MatchMapping, StartMatchMapping)
|
parser!(input, offset, MatchMapping, StartMatchMapping)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn parse_type_ref<'input>(input: &'input str) -> Result<TypeRef, ParseError<'input>> {
|
pub fn parse_type_ref<'input>(input: &'input str) -> Result<TypeRef, ParseError<'input>> {
|
||||||
parser!(input, 0, TypeRef, StartTypeRef)
|
parser!(input, 0, TypeRef, StartTypeRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn parse_where_clauses<'input>(
|
pub fn parse_where_clauses<'input>(
|
||||||
input: &'input str,
|
input: &'input str,
|
||||||
) -> Result<Vec<WhereClause<TypeRef>>, ParseError<'input>> {
|
) -> Result<Vec<WhereClause<TypeRef>>, ParseError<'input>> {
|
||||||
parser!(input, 0, GrammarWhereClauses, StartGrammarWhereClauses)
|
parser!(input, 0, GrammarWhereClauses, StartGrammarWhereClauses)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user