Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inside peg.d the ParseTree change to a mixin template #302

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ac5be36
Inside peg.d the ParseTree change to a mixin template
bitcuits May 29, 2021
510d894
WIP:
bitcuits May 31, 2021
d89af29
WIP: Correction error in the unittest
bitcuits May 31, 2021
838ee0b
WIP: Unittest passed except for doTest
bitcuits May 31, 2021
b1ebfd2
WIP: doTest compile time test passed
bitcuits May 31, 2021
59a7b5b
WIP: compile time debug printout removed
bitcuits May 31, 2021
7eadf44
WIP: parses unittest
bitcuits Jun 1, 2021
1568b56
WIP: ParseTree scaffold is now move to it's own module pegged.parsetree
bitcuits Jun 1, 2021
a0e9b2f
WIP: GrammarOptions now it the grammar generator
bitcuits Jun 1, 2021
23140c6
WIP: forgot to add the pegged/parsetree.d module
bitcuits Jun 1, 2021
183a7d1
WIP: maxEnd syntax error corrected
bitcuits Jun 1, 2021
bb9b0a0
WIP: getUpto syntax error corrected
bitcuits Jun 1, 2021
4e86f03
WIP: grammar generator now imports isParseTree
bitcuits Jun 2, 2021
3c16ea9
WIP: Dynamic parser changed to support costume ParseTree
bitcuits Jun 2, 2021
c0ca51f
WIP: Dynamic grammar is now change to take a ParseTree meta type
bitcuits Jun 2, 2021
4b516d4
WIP: Dynamic parsre support function has been change to work on Parse…
bitcuits Jun 2, 2021
ec6ea23
WIP: Dynamic parsre support function has been change to work on Parse…
bitcuits Jun 2, 2021
e5f837b
WIP: Some compile time printouts removed
bitcuits Jun 2, 2021
3f3a117
WIP: All the lexer functions have been moved into the ParseCollection…
bitcuits Jun 3, 2021
b9d43db
The lexer patter has been moved into the ParseTree using the
bitcuits Jun 3, 2021
358153e
WIP: Problems in dynamic grammar concerning use of costume ParseTree
bitcuits Jun 3, 2021
9576258
WIP: dynamic.peg is now moved into a static struct
bitcuits Jun 9, 2021
ac6472f
WIP: Dynamic peg is now moved into a struct called DynamicPeg and mus…
bitcuits Jun 10, 2021
b770594
WIP: CTE debug printout removed
bitcuits Jun 10, 2021
c78d673
makefile updated to included addtinal source files
bitcuits Jun 10, 2021
ab150e6
WIP: pegged/tester/grammartester.d is changed to @safe
bitcuits Jun 10, 2021
aca0dda
introstion.d is change to be @safe
bitcuits Jun 10, 2021
6ce8996
make target added to run all examples
bitcuits Jun 10, 2021
238b3a1
.done added to .gitignore
bitcuits Jun 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,12 @@ build/*

.vscode/

# Emacs
*#
*.parked

# Pegged self generator
pegged/dev/peggedgrammar

# Test .done
.done
2 changes: 2 additions & 0 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"pegged/peg.d",
"pegged/grammar.d",
"pegged/parser.d",
"pegged/parsetree.d",
"pegged/defaultparsetree.d",
"pegged/introspection.d",
"pegged/tohtml.d",
"pegged/dynamic/grammar.d",
Expand Down
1 change: 1 addition & 0 deletions examples/arithmetic/src/pegged/examples/arithmetic.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module pegged.examples.arithmetic;
import std.conv: to;

import pegged.grammar;
import pegged.defaultparsetree : ParseTree = DefaultParseTree;

mixin(grammar(`
# Arithmetic grammar with variable terminal
Expand Down
6 changes: 4 additions & 2 deletions examples/c/src/pegged/examples/cparser.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module pegged.examples.cparser;

import pegged.grammar;

struct C
@safe struct C
{
enum names = [`TranslationUnit`:true, `ExternalDeclaration`:true, `FunctionDefinition`:true, `PrimaryExpression`:true,
`PostfixExpression`:true, `ArgumentExpressionList`:true, `UnaryExpression`:true, `IncrementExpression`:true, `PlusPlus`:true,
Expand All @@ -21,7 +21,9 @@ struct C
`Keyword`:true, `Spacing`:true, `Comment`:true, `StringLiteral`:true, `DQChar`:true, `EscapeSequence`:true, `CharLiteral`:true, `IntegerLiteral`:true,
`Integer`:true, `IntegerSuffix`:true, `FloatLiteral`:true, `Sign`:true];

mixin decimateTree;
import pegged.defaultparsetree : ParseTree = DefaultParseTree;
mixin decimateTree!ParseTree;
mixin DefaultPatters!ParseTree;

static ParseTree TranslationUnit(ParseTree p)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/parameterized/src/pegged/examples/parameterized.d
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ unittest
A <- Parameterized.LineComment
"));

ParseTree p5 = ParamTest5("// This is a comment!
auto p5 = ParamTest5("// This is a comment!
This is not a comment.
End.");
assert(p5.successful);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module pegged.examples.simple_arithmetic;
import std.conv: to;

import pegged.grammar;

import pegged.defaultparsetree : ParseTree = DefaultParseTree;
mixin(grammar(`
Arithmetic:
Term < Factor (Add / Sub)*
Expand Down
42 changes: 39 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@
include setup.mk

all:
if [ -x /usr/bin/dmd ]; then \
dmd -w -wi -O -release -noboundscheck -lib -oflibpegged.a pegged/peg.d pegged/grammar.d pegged/parser.d pegged/introspection.d pegged/dynamic/grammar.d pegged/dynamic/peg.d; \
dmd -w -wi -O -release -noboundscheck -lib -oflibpegged.a $(DFILES); \
elif [ -x /usr/bin/ldc2 ]; then \
ldc2 -w -wi -O2 -release -boundscheck=off -c -of=libpegged.a pegged/peg.d pegged/grammar.d pegged/parser.d pegged/dynamic/grammar.d pegged/dynamic/peg.d; \
ldc2 -w -wi -O2 -release -boundscheck=off -c -of=libpegged.a $(DFILES); \
elif [ -x /usr/bin/gdc ]; then \
gdc -Wall -O2 -frelease -fbounds-check=off -c -olibpegged.a pegged/peg.d pegged/grammar.d pegged/parser.d pegged/dynamic/grammar.d pegged/dynamic/peg.d; \
gdc -Wall -O2 -frelease -fbounds-check=off -c -olibpegged.a $(DFILES); \
fi

clean:
rm -f libpegged.a

info:
@echo "DFILES = $(DFILES)"

ALL_PEG:=${shell find examples -maxdepth 1 -type d -not -path examples}

define Pegs
$1/.done:
cd $1; dub test
touch $1/.done

endef

${foreach DONE,$(ALL_PEG), ${eval ${call Pegs,$(DONE)}}}

DO_ALL := ${addsuffix /.done,$(ALL_PEG)}

test-all: $(DO_ALL)

test-clean:
rm -f $(DO_ALL)

export DO_ALL_PEG=${foreach DONE,$(ALL_PEG), ${call Pegs,$(DONE)}}


CALL_PEG:=${call Pegs,c}}

export CALL_PEG

show:
@echo "$$CALL_PEG"
@echo "$$DO_ALL_PEG"
@echo $(ALL_PEG)
@echo $(DO_ALL)
32 changes: 32 additions & 0 deletions pegged/defaultparsetree.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
This module contaits functions and parameter for ParseTree data element
*/
module pegged.defaultparsetree;

import std.traits : isType, ReturnType, ForeachType, isCallable, Unqual;

private import pegged.peg : ParseCollectionsM;
private import pegged.dynamic.peg : DynamicPeg;
import pegged.parsetree : isParseTree, ParseTreeM;
/**
The basic parse tree, as used throughout the project.
You can define your own parse tree node, but respect the basic layout.
Example:
struct MyParseTree {
mixin ParseTreeM;
... My own stuff
}
*/

struct DefaultParseTree {
mixin ParseTreeM;
mixin ParseCollectionsM;
alias DPEG=DynamicPeg!(ParseTree);
// mixin DynamicParseCollectionsM;

}

//mixin DynmicParseCollectionM!(ParseTree);


static assert(isParseTree!DefaultParseTree);
11 changes: 11 additions & 0 deletions pegged/dev/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

DCFALGS+=-I../../
DCFALGS+=-I../../examples/peggedgrammar/src/
LDFLAGS+=../../libpegged.a
DFILES+=../../examples/peggedgrammar/src/pegged/examples/peggedgrammar.d

all:
dmd $(DCFALGS) $(DFILES) regenerate.d $(LDFLAGS)

clean:
rm -f regenerate
2 changes: 1 addition & 1 deletion pegged/dev/regenerate.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module pegged.dev.regenerate;

import pegged.grammar;
import pegged.examples.peggedgrammar;
import pegged.examples.testergrammar;
//import pegged.examples.testergrammar;

void main()
{
Expand Down
Loading