inc-commits Mailing List for INC's Not C
Status: Alpha
Brought to you by:
chandlerc
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(42) |
Jul
(41) |
Aug
(36) |
Sep
(4) |
Oct
|
Nov
(6) |
Dec
(9) |
|---|
|
From: <cha...@us...> - 2007-12-06 09:17:39
|
Revision: 156
http://inc.svn.sourceforge.net/inc/?rev=156&view=rev
Author: chandlerc
Date: 2007-12-06 01:17:41 -0800 (Thu, 06 Dec 2007)
Log Message:
-----------
Consolidated the primary terminals into a single file.
Added Paths:
-----------
docs/trunk/terminals_grammar.ebnf
Removed Paths:
-------------
docs/trunk/label_symbol_grammar.ebnf
docs/trunk/whitespace_grammar.ebnf
Property Changed:
----------------
docs/trunk/
Property changes on: docs/trunk
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2007-12-02 22:01:40.098000050 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
+ timestamp: 2007-12-05 23:13:13.733000040 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
Name: bzr:file-ids
-
+ terminals_grammar.ebnf whitespace_grammar.e-20071201053828-tr6wn64j4skhhnch-12
Name: bzr:revision-id:v3-trunk1
- 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
19 cha...@gm...-20071202021531-suy3dl0y7fsv5vba
20 cha...@gm...-20071202220422-5gzgxc96nsxq9rqh
21 cha...@gm...-20071202221139-84s6t24e8zwugb1w
22 cha...@gm...-20071203030140-rjl9ucshodeik4c6
+ 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
19 cha...@gm...-20071202021531-suy3dl0y7fsv5vba
20 cha...@gm...-20071202220422-5gzgxc96nsxq9rqh
21 cha...@gm...-20071202221139-84s6t24e8zwugb1w
22 cha...@gm...-20071203030140-rjl9ucshodeik4c6
23 cha...@gm...-20071206041313-7oy4vw7y1v9gpo9f
Deleted: docs/trunk/label_symbol_grammar.ebnf
===================================================================
--- docs/trunk/label_symbol_grammar.ebnf 2007-12-03 03:02:47 UTC (rev 155)
+++ docs/trunk/label_symbol_grammar.ebnf 2007-12-06 09:17:41 UTC (rev 156)
@@ -1,3 +0,0 @@
-label = /_*[a-zA-Z][a-zA-Z0-9_]*/ ;
-symbol = /[=+-*\/\\%^&|!<>?:#$]+/ ;
-
Copied: docs/trunk/terminals_grammar.ebnf (from rev 155, docs/trunk/whitespace_grammar.ebnf)
===================================================================
--- docs/trunk/terminals_grammar.ebnf (rev 0)
+++ docs/trunk/terminals_grammar.ebnf 2007-12-06 09:17:41 UTC (rev 156)
@@ -0,0 +1,13 @@
+label = /_*[a-zA-Z][a-zA-Z0-9_]*/ ;
+symbol = /[=+-*\/\\%^&|!<>?:#$]+/ ;
+
+(* strict whitespace disallowing new lines *)
+ws only = /[ \t]+/ ;
+
+(* strict newline break *)
+newline
+ = /[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+/ ;
+
+(* default permissive whitespace interpretation *)
+ws = ws only | newline ;
+
Deleted: docs/trunk/whitespace_grammar.ebnf
===================================================================
--- docs/trunk/whitespace_grammar.ebnf 2007-12-03 03:02:47 UTC (rev 155)
+++ docs/trunk/whitespace_grammar.ebnf 2007-12-06 09:17:41 UTC (rev 156)
@@ -1,11 +0,0 @@
-(* strict whitespace disallowing new lines *)
-ws only = /[ \t]+/ ;
-
-(* strict newline break *)
-newline
- = /[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+/ ;
-
-(* default permissive whitespace interpretation *)
-ws = ws only | newline ;
-
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-12-03 03:02:43
|
Revision: 155
http://inc.svn.sourceforge.net/inc/?rev=155&view=rev
Author: chandlerc
Date: 2007-12-02 19:02:47 -0800 (Sun, 02 Dec 2007)
Log Message:
-----------
Forgot about this update to the syntax. Dr. Torgersen will be thrilled.
Modified Paths:
--------------
docs/trunk/block_grammar.ebnf
Property Changed:
----------------
docs/trunk/
Property changes on: docs/trunk
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2007-12-02 17:11:39.522000074 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
+ timestamp: 2007-12-02 22:01:40.098000050 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
Name: bzr:revision-id:v3-trunk1
- 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
19 cha...@gm...-20071202021531-suy3dl0y7fsv5vba
20 cha...@gm...-20071202220422-5gzgxc96nsxq9rqh
21 cha...@gm...-20071202221139-84s6t24e8zwugb1w
+ 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
19 cha...@gm...-20071202021531-suy3dl0y7fsv5vba
20 cha...@gm...-20071202220422-5gzgxc96nsxq9rqh
21 cha...@gm...-20071202221139-84s6t24e8zwugb1w
22 cha...@gm...-20071203030140-rjl9ucshodeik4c6
Modified: docs/trunk/block_grammar.ebnf
===================================================================
--- docs/trunk/block_grammar.ebnf 2007-12-02 22:13:29 UTC (rev 154)
+++ docs/trunk/block_grammar.ebnf 2007-12-03 03:02:47 UTC (rev 155)
@@ -11,7 +11,10 @@
scope block = "scope" , newline , block , "end" , newline ;
local declaration = variable declaration , newline ;
-variable declaration = type , ws only , label ;
+variable declaration
+ = "let", ws , label ,
+ { [ ws ] , "," , [ ws ] , label } , ws , [ "," ] , [ ws ] ,
+ "be" , ws , type ;
type = atomic type
| vector type
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-12-02 22:13:24
|
Revision: 154
http://inc.svn.sourceforge.net/inc/?rev=154&view=rev
Author: chandlerc
Date: 2007-12-02 14:13:29 -0800 (Sun, 02 Dec 2007)
Log Message:
-----------
Finished new multi-block-style syntax for the loops. Now a full loop structure
can be written as:
loop
pre
// ...
begin
// ...
post
// ...
broken
// ...
finished
// ...
end
Modified Paths:
--------------
docs/trunk/loop_grammar.ebnf
Property Changed:
----------------
docs/trunk/
Property changes on: docs/trunk
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2007-12-02 17:04:22.598000050 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
+ timestamp: 2007-12-02 17:11:39.522000074 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
Name: bzr:revision-id:v3-trunk1
- 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
19 cha...@gm...-20071202021531-suy3dl0y7fsv5vba
20 cha...@gm...-20071202220422-5gzgxc96nsxq9rqh
+ 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
19 cha...@gm...-20071202021531-suy3dl0y7fsv5vba
20 cha...@gm...-20071202220422-5gzgxc96nsxq9rqh
21 cha...@gm...-20071202221139-84s6t24e8zwugb1w
Modified: docs/trunk/loop_grammar.ebnf
===================================================================
--- docs/trunk/loop_grammar.ebnf 2007-12-02 22:13:23 UTC (rev 153)
+++ docs/trunk/loop_grammar.ebnf 2007-12-02 22:13:29 UTC (rev 154)
@@ -1,22 +1,12 @@
loop block
= "loop" , newline ,
- [ ( pre statement | pre block ) ] ,
- block , newline ,
- [ ( post statement | post block ) ] ,
- [ ( broken statement | broken block ) ] ,
- [ ( done statement | done block ) ] ,
+ [ [ pre block ] , "begin" ] , block , newline , [ post block ] ,
+ [ broken block ] , [ finished block ] ,
"end" , newline ;
-pre statement = "pre" , ws , statement ;
-pre block = "pre" , newline , block , "end" , newline ;
+pre block = "pre" , newline , block , newline ;
+post block = "post" , newline , block , newline ;
+broken block = "broken" , newline , block , newline ;
+finished block = "finished" , newline , block , newline ;
-broken statement = "broken" , ws , statement ;
-broken block = "broken" , newline , block , "end" , newline ;
-finished statement = "finished" , ws , statement ;
-finished block = "finished" , newline , block , "end" , newline ;
-
-post statement = "post" , ws , statement ;
-post block = "post" , newline , block , "end" , newline ;
-
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-12-02 22:13:18
|
Revision: 153
http://inc.svn.sourceforge.net/inc/?rev=153&view=rev
Author: chandlerc
Date: 2007-12-02 14:13:23 -0800 (Sun, 02 Dec 2007)
Log Message:
-----------
New procedural syntax, and some grammar re-working. Somewhat tighter and less
repetitive now.
Modified Paths:
--------------
docs/trunk/object_def_grammar.ebnf
docs/trunk/procedural_def_grammar.ebnf
Property Changed:
----------------
docs/trunk/
Property changes on: docs/trunk
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2007-12-01 21:15:31.716000080 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
+ timestamp: 2007-12-02 17:04:22.598000050 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
Name: bzr:revision-id:v3-trunk1
- 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
19 cha...@gm...-20071202021531-suy3dl0y7fsv5vba
+ 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
19 cha...@gm...-20071202021531-suy3dl0y7fsv5vba
20 cha...@gm...-20071202220422-5gzgxc96nsxq9rqh
Modified: docs/trunk/object_def_grammar.ebnf
===================================================================
--- docs/trunk/object_def_grammar.ebnf 2007-12-02 22:13:17 UTC (rev 152)
+++ docs/trunk/object_def_grammar.ebnf 2007-12-02 22:13:23 UTC (rev 153)
@@ -1,12 +1,12 @@
object definition
- = [ ws ] , "object" , ws , object name , newline ,
+ = [ newline ] , "object" , ws only , object name , newline ,
object inheritance, object body , "end" , newline ;
object name = label, { "." , label };
object inheritance
- = { [ ws ] , "extends" , ws , type name ,
- { [ ws ] , "," , ws , type name } , [ ws ] , [ "," ] , newline } ;
+ = { "extends" , ws , type name , { [ ws ] , "," , [ ws ] , type name } ,
+ [ ws ] , [ "," ] , newline } ;
object body = { object section } ;
object section = [ "singleton" , ws ] , object data
@@ -25,21 +25,17 @@
object procedures
= "procedures" , newline ,
- { ( procedure definition | procedure declaration ) } ,
- "end" , newline ;
+ { ( procedural definition | procedural declaration ) } , "end" , newline ;
functions definition
= "functions" , newline ,
- { ( function definition | function declaration ) } ,
- "end" , newline ;
+ { ( procedural definition | procedural declaration ) } , "end" , newline ;
mutations definition
= "mutations" , newline ,
- { ( mutation definition | mutation declaration ) },
- "end" , newline ;
+ { ( mutop definition | mutop declaration ) }, "end" , newline ;
operations definition
= "operations" , newline ,
- { ( operation definition | operation declaration ) } ,
- "end" , newline ;
+ { ( mutop definition | mutop declaration ) } , "end" , newline ;
Modified: docs/trunk/procedural_def_grammar.ebnf
===================================================================
--- docs/trunk/procedural_def_grammar.ebnf 2007-12-02 22:13:17 UTC (rev 152)
+++ docs/trunk/procedural_def_grammar.ebnf 2007-12-02 22:13:23 UTC (rev 153)
@@ -1,35 +1,21 @@
-procedure definition
- = "def" , ws only , label , newline ,
- [ parameter specification ] , block , "end" , newline ;
+procedural definition
+ = "def" , ws only , label , newline ,
+ [ [ parameter specification ] , "begin" , newline ] ,
+ block , "end" , newline ;
-function definition
- = "def" , ws only , label , newline ,
- [ parameter specification ] , block , "end" , newline ;
-
-mutation definition
+mutop definition
= "def" , ws only , mutop descriptor , newline ,
- [ parameter specification ] , block , "end" , newline ;
+ parameter specification , "begin" , newline ,
+ block , "end" , newline ;
-operation definition
- = "def" , ws only , mutop descriptor , newline ,
- [ parameter specification ] , block , "end" , newline ;
-
-procedure declaration
+procedural declaration
= "declare" , ws only , label , newline ,
- [ parameter specification ] , "end" , newline ;
+ [ parameter specification , "end" , newline ] ;
-function declaration
- = "declare" , ws only , label , newline ,
- [ parameter specification ] , "end" , newline ;
-
-mutation declaration
+mutop declaration
= "declare" , ws only , mutop descriptor , newline ,
- [ parameter specification ] , "end" , newline ;
+ parameter specification , "end" , newline ;
-operation declaration
- = "declare" , ws only , mutop descriptor , newline ,
- [ parameter specification ] , "end" , newline ;
-
mutop descriptor = mutop type, ws only , ( label | symbol ) ;
mutop type = [ "left" , ws only ] , "unary"
| "right", ws only , "unary"
@@ -37,7 +23,7 @@
| "right" , [ ws only , "binary" ] ;
parameter specification
- = "params" , newline , { parameter declaration } , "end" , newline ;
+ = "params" , newline , { parameter declaration } ;
parameter declaration
= [ ( "in" , [ ws only , "out" ] | "out" ) , ws only ] ,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-12-02 22:13:13
|
Revision: 152
http://inc.svn.sourceforge.net/inc/?rev=152&view=rev
Author: chandlerc
Date: 2007-12-02 14:13:17 -0800 (Sun, 02 Dec 2007)
Log Message:
-----------
Added declaration support to the grammar.
Modified Paths:
--------------
docs/trunk/object_def_grammar.ebnf
docs/trunk/procedural_def_grammar.ebnf
Property Changed:
----------------
docs/trunk/
Property changes on: docs/trunk
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2007-12-01 08:39:55.984999895 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: thesis
+ timestamp: 2007-12-01 21:15:31.716000080 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
Name: bzr:revision-id:v3-trunk1
- 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
+ 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
19 cha...@gm...-20071202021531-suy3dl0y7fsv5vba
Modified: docs/trunk/object_def_grammar.ebnf
===================================================================
--- docs/trunk/object_def_grammar.ebnf 2007-12-02 22:13:11 UTC (rev 151)
+++ docs/trunk/object_def_grammar.ebnf 2007-12-02 22:13:17 UTC (rev 152)
@@ -24,14 +24,22 @@
| "insert" , ws only , label , newline ;
object procedures
- = "procedures" , newline , { procedure definition } , "end" , newline ;
+ = "procedures" , newline ,
+ { ( procedure definition | procedure declaration ) } ,
+ "end" , newline ;
functions definition
- = "functions" , newline , { function definition } , "end" , newline ;
+ = "functions" , newline ,
+ { ( function definition | function declaration ) } ,
+ "end" , newline ;
mutations definition
- = "mutations" , newline , { mutation definition }, "end" , newline ;
+ = "mutations" , newline ,
+ { ( mutation definition | mutation declaration ) },
+ "end" , newline ;
operations definition
- = "operations" , newline , { operation definition }, "end" , newline ;
+ = "operations" , newline ,
+ { ( operation definition | operation declaration ) } ,
+ "end" , newline ;
Modified: docs/trunk/procedural_def_grammar.ebnf
===================================================================
--- docs/trunk/procedural_def_grammar.ebnf 2007-12-02 22:13:11 UTC (rev 151)
+++ docs/trunk/procedural_def_grammar.ebnf 2007-12-02 22:13:17 UTC (rev 152)
@@ -14,6 +14,22 @@
= "def" , ws only , mutop descriptor , newline ,
[ parameter specification ] , block , "end" , newline ;
+procedure declaration
+ = "declare" , ws only , label , newline ,
+ [ parameter specification ] , "end" , newline ;
+
+function declaration
+ = "declare" , ws only , label , newline ,
+ [ parameter specification ] , "end" , newline ;
+
+mutation declaration
+ = "declare" , ws only , mutop descriptor , newline ,
+ [ parameter specification ] , "end" , newline ;
+
+operation declaration
+ = "declare" , ws only , mutop descriptor , newline ,
+ [ parameter specification ] , "end" , newline ;
+
mutop descriptor = mutop type, ws only , ( label | symbol ) ;
mutop type = [ "left" , ws only ] , "unary"
| "right", ws only , "unary"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-12-02 22:13:06
|
Revision: 151
http://inc.svn.sourceforge.net/inc/?rev=151&view=rev
Author: chandlerc
Date: 2007-12-02 14:13:11 -0800 (Sun, 02 Dec 2007)
Log Message:
-----------
Make the figures look good and integrate with the thesis.
Modified Paths:
--------------
docs/trunk/whitespace_grammar.ebnf
Property Changed:
----------------
docs/trunk/
Property changes on: docs/trunk
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2007-12-01 02:55:18.654999971 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
+ timestamp: 2007-12-01 08:39:55.984999895 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: thesis
Name: bzr:revision-id:v3-trunk1
- 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
+ 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
18 cha...@gm...-20071201133955-nz0xvn6ua8yr86on
Modified: docs/trunk/whitespace_grammar.ebnf
===================================================================
--- docs/trunk/whitespace_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
+++ docs/trunk/whitespace_grammar.ebnf 2007-12-02 22:13:11 UTC (rev 151)
@@ -2,7 +2,8 @@
ws only = /[ \t]+/ ;
(* strict newline break *)
-newline = /[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+/ ;
+newline
+ = /[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+/ ;
(* default permissive whitespace interpretation *)
ws = ws only | newline ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-12-01 07:56:41
|
Revision: 150
http://inc.svn.sourceforge.net/inc/?rev=150&view=rev
Author: chandlerc
Date: 2007-11-30 23:56:33 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
Lots of work here. Tremendous cleaning to be <80cols so we can make things a
bit more legible in the printed form, and lots of cleaning to make things more
correct and/or better organized.
Modified Paths:
--------------
docs/trunk/block_grammar.ebnf
docs/trunk/expression_grammar.ebnf
docs/trunk/if_grammar.ebnf
docs/trunk/immediate_grammar.ebnf
docs/trunk/label_symbol_grammar.ebnf
docs/trunk/loop_grammar.ebnf
docs/trunk/name_grammar.ebnf
docs/trunk/object_def_grammar.ebnf
docs/trunk/procedural_def_grammar.ebnf
docs/trunk/statement_grammar.ebnf
docs/trunk/whitespace_grammar.ebnf
Property Changed:
----------------
docs/trunk/
Property changes on: docs/trunk
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2007-12-01 00:38:34.858999968 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
+ timestamp: 2007-12-01 02:55:18.654999971 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
Name: bzr:file-ids
- expression_grammar.ebnf expression_grammar.e-20071201053828-tr6wn64j4skhhnch-2
name_grammar.ebnf name_grammar.ebnf-20071201053828-tr6wn64j4skhhnch-7
object_def_grammar.ebnf object_def_grammar.e-20071201053828-tr6wn64j4skhhnch-8
immediate_grammar.ebnf immediate_grammar.eb-20071201053828-tr6wn64j4skhhnch-4
label_symbol_grammar.ebnf label_symbol_grammar-20071201053828-tr6wn64j4skhhnch-5
loop_grammar.ebnf loop_grammar.ebnf-20071201053828-tr6wn64j4skhhnch-6
procedural_def_grammar.ebnf procedural_def_gramm-20071201053828-tr6wn64j4skhhnch-9
statement_grammar.ebnf statement_grammar.eb-20071201053828-tr6wn64j4skhhnch-11
whitespace_grammar.ebnf whitespace_grammar.e-20071201053828-tr6wn64j4skhhnch-12
program_grammar.ebnf program_grammar.ebnf-20071201053828-tr6wn64j4skhhnch-10
if_grammar.ebnf if_grammar.ebnf-20071201053828-tr6wn64j4skhhnch-3
block_grammar.ebnf block_grammar.ebnf-20071201053828-tr6wn64j4skhhnch-1
+
Name: bzr:revision-id:v3-trunk1
- 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
+ 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
17 cha...@gm...-20071201075518-aou1va120wpwg85h
Modified: docs/trunk/block_grammar.ebnf
===================================================================
--- docs/trunk/block_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/block_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,4 +1,3 @@
-
block = { block entry } ;
block entry = flow control
| scope block
@@ -9,20 +8,29 @@
| if block
| loop block ;
+scope block = "scope" , newline , block , "end" , newline ;
+
local declaration = variable declaration , newline ;
+variable declaration = type , ws only , label ;
-variable declaration = type , ws only , label ;
-type = atomic type | vector type | pointer type | type name ;
+type = atomic type
+ | vector type
+ | pointer type
+ | type name ;
+
atomic type = integer type | floating point type;
integer type = "int" , [ "<" , ws , precision , ws , ">" ] ;
floating point type = "float" , [ "<" , ws , precision , ws , ">" ] ;
precision = immediate integer ;
-vector type = "vector" , "<" , ws , size , ws , "x" , ws , atomic type , ws , ">" ;
-pointer type = "pointer" , "<" , ws , [ dimension , [ ws ] , "d" , ws ] , type , ws , ">" ;
+vector type
+ = "vector" , "<" , ws , size , ws , "x" , ws , atomic type , ws , ">" ;
+
+pointer type
+ = "pointer" , "<" , ws , [ dimension , ws , "d" , ws ] , type , ws , ">" ;
+
+size = immediate integer ;
dimension = immediate integer ;
-type name = [ "." ] , "." , label , { "." , label } ;
+type name = label , { "." , label } ;
-scope block = "scope" , newline , block , "end" , newline ;
-
Modified: docs/trunk/expression_grammar.ebnf
===================================================================
--- docs/trunk/expression_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/expression_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,20 +1,23 @@
-
-(* this is the way we want to parse exprs... we pick the first
- matching alternative to resolve any ambiguities. *)
-expression =
- | "(" , [ ws ] , symbol , [ ws ] , expression , [ ws ] , ")"
- | "(" , [ ws ] , label , ws , label , [ ws ] , ")"
- | "(" , [ ws ] , label , ws , expression , [ ws ] , ")"
- | "(" , [ ws ] , expression , [ ws ] , symbol , [ ws ] , ")"
- | "(" , [ ws ] , expression , [ ws ] , symbol , [ ws ] , expression , [ ws ] , ")"
- | "(" , [ ws ] , expression , ws , label , [ ws ] , ")"
- | "(" , [ ws ] , expression , ws , label , ws , expression , [ ws ] , ")"
- | immediate
+expression = immediate
| "self"
+ | name
| function call
- | name ;
+ | operation ;
-function call = name , "(" , [ ws ] , [ function call parameters ] , [ ws ] , ")" ;
-function call parameters = expression , { [ ws ] , "," , ws , expression } , [ ws ] , [ "," ] ;
+operation
+ = "(" , [ ws ] , symbol , [ ws ] , expression , [ ws ] , ")"
+ | "(" , [ ws ] , label , ws , label , [ ws ] , ")"
+ | "(" , [ ws ] , label , ws , expression , [ ws ] , ")"
+ | "(" , [ ws ] , expression , [ ws ] , symbol , [ ws ] , ")"
+ | "(" , [ ws ] , expression , [ ws ] , symbol , [ ws ] ,
+ expression , [ ws ] , ")"
+ | "(" , [ ws ] , expression , ws , label , [ ws ] , ")"
+ | "(" , [ ws ] , expression , ws , label , ws , expression , [ ws ] , ")" ;
+function call
+ = name , "(" , [ ws ] , [ function call parameters ] , [ ws ] , ")" ;
+function call parameters
+ = expression , { [ ws ] , "," , ws , expression } , [ ws ] , [ "," ] ;
+
+
Modified: docs/trunk/if_grammar.ebnf
===================================================================
--- docs/trunk/if_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/if_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,8 +1,9 @@
+if statement
+ = "if" , ws , expression , ws , "then" , ws , statement
-if statement = "if" , ws , expression , ws , "then" , ws , statement
+if block
+ = "if" , ws , expression , newline , block ,
+ [ "elif" , ws , expression , newline , block ] ,
+ [ "else" , ws , newline , block ] ,
+ "end" , newline ;
-if block = "if" , ws , expression , newline , block ,
- [ "elif" , ws , expression , newline , block ] ,
- [ "else" , ws , newline , block ] ,
- "end" , newline ;
-
Modified: docs/trunk/immediate_grammar.ebnf
===================================================================
--- docs/trunk/immediate_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/immediate_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,4 +1,8 @@
+immediate = immediate integer
+ | immediate float
+ | immediate vector ;
+
immediate integer = immediate integer decimal
| immediate integer binary
| immediate integer octal
@@ -9,13 +13,36 @@
immediate integer octal = /-?0o[0-7]+/ ;
immediate integer hexadecimal = /-?0x[0-9a-fA-F]+/ ;
-immediate = immediate decimal
- | immediate binary
- | immediate octal
- | immediate hexadecimal ;
+immediate float = immediate float decimal
+ | immediate float binary
+ | immediate float octal
+ | immediate float hexadecimal ;
-immediate decimal = /-?(0|[1-9][0-9]*)([.,][0-9]+)?([eEpP][-+]?(0|[1-9][0-9]*))?/ ;
-immediate binary = /-?0b[01]+([.,][01]+)?([eEpP][-+]?[01]+)?/ ;
-immediate octal = /-?0o[0-7]+([.,][0-7]+)?([eEpP][-+]?[0-7]+)?/ ;
-immediate hexadecimal = /-?0x[0-9a-fA-F]+([.,][0-9a-fA-F]+)?([pP][-+]?[0-9a-fA-F]+)?/ ;
+immediate float decimal
+ = /-?(0|[1-9][0-9]*)([.,][0-9]+)?([eEpP][-+]?(0|[1-9][0-9]*))?/ ;
+immediate float binary
+ = /-?0b[01]+([.,][01]+)?([eEpP][-+]?[01]+)?/ ;
+
+immediate float octal
+ = /-?0o[0-7]+([.,][0-7]+)?([eEpP][-+]?[0-7]+)?/ ;
+
+immediate float hexadecimal
+ = /-?0x[0-9a-fA-F]+([.,][0-9a-fA-F]+)?([pP][-+]?[0-9a-fA-F]+)?/ ;
+
+immediate vector = immediate integer vector
+ | immediate float vector
+ | immediate character vector ;
+
+immediate integer vector
+ = "{" , [ ws ] , immediate integer ,
+ { [ ws ] , "," , [ ws ] , immediate integer } ,
+ [ ws ] , [ "," ] , [ ws ] , "}" ;
+
+immediate float vector
+ = "{" , [ ws ] , immediate float ,
+ { [ ws ] , "," , [ ws ] , immediate float } ,
+ [ ws ] , [ "," ] , [ ws ] , "}" ;
+
+immediate character vector = /".*?(?<!\\)"/
+
Modified: docs/trunk/label_symbol_grammar.ebnf
===================================================================
--- docs/trunk/label_symbol_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/label_symbol_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,4 +1,3 @@
-
label = /_*[a-zA-Z][a-zA-Z0-9_]*/ ;
symbol = /[=+-*\/\\%^&|!<>?:#$]+/ ;
Modified: docs/trunk/loop_grammar.ebnf
===================================================================
--- docs/trunk/loop_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/loop_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,22 +1,22 @@
+loop block
+ = "loop" , newline ,
+ [ ( pre statement | pre block ) ] ,
+ block , newline ,
+ [ ( post statement | post block ) ] ,
+ [ ( broken statement | broken block ) ] ,
+ [ ( done statement | done block ) ] ,
+ "end" , newline ;
-loop block = "loop" , newline ,
- [ ( pre statement | pre block ) ] ,
- "body" , newline , block , "end" , newline ,
- [ ( broken statement | broken block ) ] ,
- [ ( done statement | done block ) ] ,
- [ ( post statement | post block ) ] ,
- "end" , newline ;
-
-pre statement = "pre:" , ws , statement ;
+pre statement = "pre" , ws , statement ;
pre block = "pre" , newline , block , "end" , newline ;
-broken statement = "broken:" , ws , statement ;
+broken statement = "broken" , ws , statement ;
broken block = "broken" , newline , block , "end" , newline ;
-done statement = "done:" , ws , statement ;
-done block = "done" , newline , block , "end" , newline ;
+finished statement = "finished" , ws , statement ;
+finished block = "finished" , newline , block , "end" , newline ;
-post statement = "post:" , ws , statement ;
+post statement = "post" , ws , statement ;
post block = "post" , newline , block , "end" , newline ;
Modified: docs/trunk/name_grammar.ebnf
===================================================================
--- docs/trunk/name_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/name_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,4 +1,3 @@
-
name = label
| compound name ;
@@ -6,12 +5,13 @@
| dereferenced name
| indexed name ;
-(* this almost works, but the "(" creates an ambiguity with expressions!!! damn *)
internal name = label
| "(" , [ ws ] , compound name , [ ws ] , ")"
scoped name = [ [ "." ] , "." ] , internal name , { "." , label } ;
dereferenced name = "@" , internal name ;
-indexed name = internal name , "[" , [ ws ] , expression , { [ ws ] , "," , expression } , [ ws ] , [ "," ] , [ ws ] , "]" ;
+indexed name
+ = internal name , "[" , [ ws ] , expression ,
+ { [ ws ] , "," , expression } , [ ws ] , [ "," ] , [ ws ] , "]" ;
Modified: docs/trunk/object_def_grammar.ebnf
===================================================================
--- docs/trunk/object_def_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/object_def_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,14 +1,18 @@
+object definition
+ = [ ws ] , "object" , ws , object name , newline ,
+ object inheritance, object body , "end" , newline ;
-object definition = [ ws ] , "object" , ws , object name , newline ,
- object inheritance, object body , "end" , newline ;
+object name = label, { "." , label };
-object name = label, { "." , label };
-object inheritance = { [ ws ] , "extends" , ws , type name , { [ ws ] , "," , ws , type name } , [ ws ] , [ "," ] , newline } ;
+object inheritance
+ = { [ ws ] , "extends" , ws , type name ,
+ { [ ws ] , "," , ws , type name } , [ ws ] , [ "," ] , newline } ;
+
object body = { object section } ;
object section = [ "singleton" , ws ] , object data
| object layout
- | [ "singleton" , ws ] , object procs
- | [ "singleton" , ws ] , object funcs
+ | [ "singleton" , ws ] , object procedures
+ | [ "singleton" , ws ] , object functions
| [ "singleton" , ws ] , object mutators
| [ "singleton" , ws ] , object operators ;
@@ -19,15 +23,15 @@
object layout entry = label , newline
| "insert" , ws only , label , newline ;
-object procs = "procedures" , newline , { object procedure } , "end" , newline ;
-object procedure = "def" , ws only , label , newline , procedure , "end" , newline ;
+object procedures
+ = "procedures" , newline , { procedure definition } , "end" , newline ;
-object funcs = "functions" , newline , { object function } , "end" , newline ;
-object function = "def" , ws only , label , newline , function , "end" , newline ;
+functions definition
+ = "functions" , newline , { function definition } , "end" , newline ;
-object mutators = "mutators" , newline , { object mutator }, "end" , newline ;
-object mutator = "def" , ws only , mutop descriptor , newline , mutator , "end" , newline ;
+mutations definition
+ = "mutations" , newline , { mutation definition }, "end" , newline ;
-object operators = "operators" , newline , { object operator }, "end" , newline ;
-object operator = "def" , ws only , mutop descriptor , newline , operator , "end" , newline ;
+operations definition
+ = "operations" , newline , { operation definition }, "end" , newline ;
Modified: docs/trunk/procedural_def_grammar.ebnf
===================================================================
--- docs/trunk/procedural_def_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/procedural_def_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,28 +1,30 @@
+procedure definition
+ = "def" , ws only , label , newline ,
+ [ parameter specification ] , block , "end" , newline ;
-object procs = "procedures" , newline , { object procedure } , "end" , newline ;
-object procedure = "def" , ws only , label , newline , procedure , "end" , newline ;
+function definition
+ = "def" , ws only , label , newline ,
+ [ parameter specification ] , block , "end" , newline ;
-object funcs = "functions" , newline , { object function } , "end" , newline ;
-object function = "def" , ws only , label , newline , function , "end" , newline ;
+mutation definition
+ = "def" , ws only , mutop descriptor , newline ,
+ [ parameter specification ] , block , "end" , newline ;
-object mutators = "mutators" , newline , { object mutator }, "end" , newline ;
-object mutator = "def" , ws only , mutop descriptor , newline , mutator , "end" , newline ;
+operation definition
+ = "def" , ws only , mutop descriptor , newline ,
+ [ parameter specification ] , block , "end" , newline ;
-object operators = "operators" , newline , { object operator }, "end" , newline ;
-object operator = "def" , ws only , mutop descriptor , newline , operator , "end" , newline ;
-
mutop descriptor = mutop type, ws only , ( label | symbol ) ;
mutop type = [ "left" , ws only ] , "unary"
| "right", ws only , "unary"
| [ "left" ] , [ ws only , "binary" ]
| "right" , [ ws only , "binary" ] ;
-procedure = [ parameter specification ] , block ;
-function = [ parameter specification ] , block ;
-mutation = [ parameter specification ] , block ;
-operation = [ parameter specification ] , block ;
+parameter specification
+ = "params" , newline , { parameter declaration } , "end" , newline ;
-parameter specification = "params" , newline , { parameter declaration } , "end" , newline ;
-parameter declaration = [ ( "input" | "output" ) , ws only ] , variable declaration , newline ;
+parameter declaration
+ = [ ( "in" , [ ws only , "out" ] | "out" ) , ws only ] ,
+ variable declaration , newline ;
Modified: docs/trunk/statement_grammar.ebnf
===================================================================
--- docs/trunk/statement_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/statement_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,17 +1,21 @@
-
-statement = procedure call , newline
+statement = procedure call , newline
| mutation , newline
| loop control , newline ;
loop control = "break"
| "done" ;
-procedure call = name , "(" , ws , [ procedure call parameters ] , ws , ")" , newline ;
-procedure call parameters = procedure call parameter , { [ ws ] , "," , ws , procedure call parameter } , [ ws ] , [ "," ] ;
-procedure call parameter = [ procedure call parameter modifier , ws ] , expression ;
-procedure call parameter modifier = "in"
- | "out"
- | "in" , ws , "out";
+procedure call
+ = name , "(" , ws , [ procedure call parameters ] , ws , ")" , newline ;
+
+procedure call parameters
+ = procedure call parameter ,
+ { [ ws ] , "," , ws , procedure call parameter } , [ ws ] , [ "," ] ;
+
+procedure call parameter
+ = [ ( "in" , [ ws , "out" ] | "out" ) , ws ] , expression ;
-mutation = expression , ws , ( label | symbol ) , ws , expression ;
+mutation
+ = expression , ws , label , ws , expression ;
+ | expression , [ ws ] , symbol , [ ws ] , expression ;
Modified: docs/trunk/whitespace_grammar.ebnf
===================================================================
--- docs/trunk/whitespace_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
+++ docs/trunk/whitespace_grammar.ebnf 2007-12-01 07:56:33 UTC (rev 150)
@@ -1,14 +1,10 @@
-
-(* matches just white space, not end of line *)
+(* strict whitespace disallowing new lines *)
ws only = /[ \t]+/ ;
-(* a preferred and more inclusive view of white space *)
-ws = /([ \t]+|[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+)/ ;
+(* strict newline break *)
+newline = /[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+/ ;
-(* newline matches space to the end of the line, and any blank lines
- following, and any space at the start of the next non-blank line.
- We also use the "correct" Unicode definition of a line terminator.
- Take that compatibility! *)
-newline = /[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+/ ;
+(* default permissive whitespace interpretation *)
+ws = ws only | newline ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-12-01 06:21:04
|
Revision: 149
http://inc.svn.sourceforge.net/inc/?rev=149&view=rev
Author: chandlerc
Date: 2007-11-30 22:21:08 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
Add factored grammar files. Should have been copied with history from
grammar.ebnf, but that apparently is the one leg up SVN has on BZR.
Added Paths:
-----------
docs/trunk/block_grammar.ebnf
docs/trunk/expression_grammar.ebnf
docs/trunk/if_grammar.ebnf
docs/trunk/immediate_grammar.ebnf
docs/trunk/label_symbol_grammar.ebnf
docs/trunk/loop_grammar.ebnf
docs/trunk/name_grammar.ebnf
docs/trunk/object_def_grammar.ebnf
docs/trunk/procedural_def_grammar.ebnf
docs/trunk/program_grammar.ebnf
docs/trunk/statement_grammar.ebnf
docs/trunk/whitespace_grammar.ebnf
Property Changed:
----------------
docs/trunk/
Property changes on: docs/trunk
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2007-12-01 00:15:58.611999989 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: thesis
+ timestamp: 2007-12-01 00:38:34.858999968 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: inc_docs
Name: bzr:file-ids
-
+ expression_grammar.ebnf expression_grammar.e-20071201053828-tr6wn64j4skhhnch-2
name_grammar.ebnf name_grammar.ebnf-20071201053828-tr6wn64j4skhhnch-7
object_def_grammar.ebnf object_def_grammar.e-20071201053828-tr6wn64j4skhhnch-8
immediate_grammar.ebnf immediate_grammar.eb-20071201053828-tr6wn64j4skhhnch-4
label_symbol_grammar.ebnf label_symbol_grammar-20071201053828-tr6wn64j4skhhnch-5
loop_grammar.ebnf loop_grammar.ebnf-20071201053828-tr6wn64j4skhhnch-6
procedural_def_grammar.ebnf procedural_def_gramm-20071201053828-tr6wn64j4skhhnch-9
statement_grammar.ebnf statement_grammar.eb-20071201053828-tr6wn64j4skhhnch-11
whitespace_grammar.ebnf whitespace_grammar.e-20071201053828-tr6wn64j4skhhnch-12
program_grammar.ebnf program_grammar.ebnf-20071201053828-tr6wn64j4skhhnch-10
if_grammar.ebnf if_grammar.ebnf-20071201053828-tr6wn64j4skhhnch-3
block_grammar.ebnf block_grammar.ebnf-20071201053828-tr6wn64j4skhhnch-1
Name: bzr:revision-id:v3-trunk1
- 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
+ 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
16 cha...@gm...-20071201053834-pbtg22vzacylq3vc
Added: docs/trunk/block_grammar.ebnf
===================================================================
--- docs/trunk/block_grammar.ebnf (rev 0)
+++ docs/trunk/block_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,28 @@
+
+block = { block entry } ;
+block entry = flow control
+ | scope block
+ | local declaration
+ | statement ;
+
+flow control = if statement
+ | if block
+ | loop block ;
+
+local declaration = variable declaration , newline ;
+
+variable declaration = type , ws only , label ;
+type = atomic type | vector type | pointer type | type name ;
+atomic type = integer type | floating point type;
+integer type = "int" , [ "<" , ws , precision , ws , ">" ] ;
+floating point type = "float" , [ "<" , ws , precision , ws , ">" ] ;
+precision = immediate integer ;
+vector type = "vector" , "<" , ws , size , ws , "x" , ws , atomic type , ws , ">" ;
+pointer type = "pointer" , "<" , ws , [ dimension , [ ws ] , "d" , ws ] , type , ws , ">" ;
+dimension = immediate integer ;
+
+type name = [ "." ] , "." , label , { "." , label } ;
+
+scope block = "scope" , newline , block , "end" , newline ;
+
+
Added: docs/trunk/expression_grammar.ebnf
===================================================================
--- docs/trunk/expression_grammar.ebnf (rev 0)
+++ docs/trunk/expression_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,20 @@
+
+(* this is the way we want to parse exprs... we pick the first
+ matching alternative to resolve any ambiguities. *)
+expression =
+ | "(" , [ ws ] , symbol , [ ws ] , expression , [ ws ] , ")"
+ | "(" , [ ws ] , label , ws , label , [ ws ] , ")"
+ | "(" , [ ws ] , label , ws , expression , [ ws ] , ")"
+ | "(" , [ ws ] , expression , [ ws ] , symbol , [ ws ] , ")"
+ | "(" , [ ws ] , expression , [ ws ] , symbol , [ ws ] , expression , [ ws ] , ")"
+ | "(" , [ ws ] , expression , ws , label , [ ws ] , ")"
+ | "(" , [ ws ] , expression , ws , label , ws , expression , [ ws ] , ")"
+ | immediate
+ | "self"
+ | function call
+ | name ;
+
+function call = name , "(" , [ ws ] , [ function call parameters ] , [ ws ] , ")" ;
+function call parameters = expression , { [ ws ] , "," , ws , expression } , [ ws ] , [ "," ] ;
+
+
Added: docs/trunk/if_grammar.ebnf
===================================================================
--- docs/trunk/if_grammar.ebnf (rev 0)
+++ docs/trunk/if_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,8 @@
+
+if statement = "if" , ws , expression , ws , "then" , ws , statement
+
+if block = "if" , ws , expression , newline , block ,
+ [ "elif" , ws , expression , newline , block ] ,
+ [ "else" , ws , newline , block ] ,
+ "end" , newline ;
+
Added: docs/trunk/immediate_grammar.ebnf
===================================================================
--- docs/trunk/immediate_grammar.ebnf (rev 0)
+++ docs/trunk/immediate_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,21 @@
+
+immediate integer = immediate integer decimal
+ | immediate integer binary
+ | immediate integer octal
+ | immediate integer hexadecimal ;
+
+immediate integer decimal = /-?(0|[1-9][0-9]*)/ ;
+immediate integer binary = /-?0b[01]+/ ;
+immediate integer octal = /-?0o[0-7]+/ ;
+immediate integer hexadecimal = /-?0x[0-9a-fA-F]+/ ;
+
+immediate = immediate decimal
+ | immediate binary
+ | immediate octal
+ | immediate hexadecimal ;
+
+immediate decimal = /-?(0|[1-9][0-9]*)([.,][0-9]+)?([eEpP][-+]?(0|[1-9][0-9]*))?/ ;
+immediate binary = /-?0b[01]+([.,][01]+)?([eEpP][-+]?[01]+)?/ ;
+immediate octal = /-?0o[0-7]+([.,][0-7]+)?([eEpP][-+]?[0-7]+)?/ ;
+immediate hexadecimal = /-?0x[0-9a-fA-F]+([.,][0-9a-fA-F]+)?([pP][-+]?[0-9a-fA-F]+)?/ ;
+
Added: docs/trunk/label_symbol_grammar.ebnf
===================================================================
--- docs/trunk/label_symbol_grammar.ebnf (rev 0)
+++ docs/trunk/label_symbol_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,4 @@
+
+label = /_*[a-zA-Z][a-zA-Z0-9_]*/ ;
+symbol = /[=+-*\/\\%^&|!<>?:#$]+/ ;
+
Added: docs/trunk/loop_grammar.ebnf
===================================================================
--- docs/trunk/loop_grammar.ebnf (rev 0)
+++ docs/trunk/loop_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,22 @@
+
+loop block = "loop" , newline ,
+ [ ( pre statement | pre block ) ] ,
+ "body" , newline , block , "end" , newline ,
+ [ ( broken statement | broken block ) ] ,
+ [ ( done statement | done block ) ] ,
+ [ ( post statement | post block ) ] ,
+ "end" , newline ;
+
+pre statement = "pre:" , ws , statement ;
+pre block = "pre" , newline , block , "end" , newline ;
+
+broken statement = "broken:" , ws , statement ;
+broken block = "broken" , newline , block , "end" , newline ;
+
+done statement = "done:" , ws , statement ;
+done block = "done" , newline , block , "end" , newline ;
+
+post statement = "post:" , ws , statement ;
+post block = "post" , newline , block , "end" , newline ;
+
+
Added: docs/trunk/name_grammar.ebnf
===================================================================
--- docs/trunk/name_grammar.ebnf (rev 0)
+++ docs/trunk/name_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,17 @@
+
+name = label
+ | compound name ;
+
+compound name = scoped name
+ | dereferenced name
+ | indexed name ;
+
+(* this almost works, but the "(" creates an ambiguity with expressions!!! damn *)
+internal name = label
+ | "(" , [ ws ] , compound name , [ ws ] , ")"
+
+scoped name = [ [ "." ] , "." ] , internal name , { "." , label } ;
+dereferenced name = "@" , internal name ;
+indexed name = internal name , "[" , [ ws ] , expression , { [ ws ] , "," , expression } , [ ws ] , [ "," ] , [ ws ] , "]" ;
+
+
Added: docs/trunk/object_def_grammar.ebnf
===================================================================
--- docs/trunk/object_def_grammar.ebnf (rev 0)
+++ docs/trunk/object_def_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,33 @@
+
+object definition = [ ws ] , "object" , ws , object name , newline ,
+ object inheritance, object body , "end" , newline ;
+
+object name = label, { "." , label };
+object inheritance = { [ ws ] , "extends" , ws , type name , { [ ws ] , "," , ws , type name } , [ ws ] , [ "," ] , newline } ;
+object body = { object section } ;
+object section = [ "singleton" , ws ] , object data
+ | object layout
+ | [ "singleton" , ws ] , object procs
+ | [ "singleton" , ws ] , object funcs
+ | [ "singleton" , ws ] , object mutators
+ | [ "singleton" , ws ] , object operators ;
+
+object data = "data" , newline , { object data member } , "end" , newline ;
+object data member = variable declaration , newline ;
+
+object layout = "layout" , newline , object layout entry , "end" , newline ;
+object layout entry = label , newline
+ | "insert" , ws only , label , newline ;
+
+object procs = "procedures" , newline , { object procedure } , "end" , newline ;
+object procedure = "def" , ws only , label , newline , procedure , "end" , newline ;
+
+object funcs = "functions" , newline , { object function } , "end" , newline ;
+object function = "def" , ws only , label , newline , function , "end" , newline ;
+
+object mutators = "mutators" , newline , { object mutator }, "end" , newline ;
+object mutator = "def" , ws only , mutop descriptor , newline , mutator , "end" , newline ;
+
+object operators = "operators" , newline , { object operator }, "end" , newline ;
+object operator = "def" , ws only , mutop descriptor , newline , operator , "end" , newline ;
+
Added: docs/trunk/procedural_def_grammar.ebnf
===================================================================
--- docs/trunk/procedural_def_grammar.ebnf (rev 0)
+++ docs/trunk/procedural_def_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,28 @@
+
+object procs = "procedures" , newline , { object procedure } , "end" , newline ;
+object procedure = "def" , ws only , label , newline , procedure , "end" , newline ;
+
+object funcs = "functions" , newline , { object function } , "end" , newline ;
+object function = "def" , ws only , label , newline , function , "end" , newline ;
+
+object mutators = "mutators" , newline , { object mutator }, "end" , newline ;
+object mutator = "def" , ws only , mutop descriptor , newline , mutator , "end" , newline ;
+
+object operators = "operators" , newline , { object operator }, "end" , newline ;
+object operator = "def" , ws only , mutop descriptor , newline , operator , "end" , newline ;
+
+mutop descriptor = mutop type, ws only , ( label | symbol ) ;
+mutop type = [ "left" , ws only ] , "unary"
+ | "right", ws only , "unary"
+ | [ "left" ] , [ ws only , "binary" ]
+ | "right" , [ ws only , "binary" ] ;
+
+procedure = [ parameter specification ] , block ;
+function = [ parameter specification ] , block ;
+mutation = [ parameter specification ] , block ;
+operation = [ parameter specification ] , block ;
+
+parameter specification = "params" , newline , { parameter declaration } , "end" , newline ;
+parameter declaration = [ ( "input" | "output" ) , ws only ] , variable declaration , newline ;
+
+
Added: docs/trunk/program_grammar.ebnf
===================================================================
--- docs/trunk/program_grammar.ebnf (rev 0)
+++ docs/trunk/program_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,8 @@
+
+(* programs are themselves an object, with only two valid sections,
+ and other objects defined within the program object. *)
+program = { object definition | program section } ;
+program section = object data
+ | object procs
+ | object funcs ;
+
Added: docs/trunk/statement_grammar.ebnf
===================================================================
--- docs/trunk/statement_grammar.ebnf (rev 0)
+++ docs/trunk/statement_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,17 @@
+
+statement = procedure call , newline
+ | mutation , newline
+ | loop control , newline ;
+
+loop control = "break"
+ | "done" ;
+
+procedure call = name , "(" , ws , [ procedure call parameters ] , ws , ")" , newline ;
+procedure call parameters = procedure call parameter , { [ ws ] , "," , ws , procedure call parameter } , [ ws ] , [ "," ] ;
+procedure call parameter = [ procedure call parameter modifier , ws ] , expression ;
+procedure call parameter modifier = "in"
+ | "out"
+ | "in" , ws , "out";
+
+mutation = expression , ws , ( label | symbol ) , ws , expression ;
+
Added: docs/trunk/whitespace_grammar.ebnf
===================================================================
--- docs/trunk/whitespace_grammar.ebnf (rev 0)
+++ docs/trunk/whitespace_grammar.ebnf 2007-12-01 06:21:08 UTC (rev 149)
@@ -0,0 +1,14 @@
+
+(* matches just white space, not end of line *)
+ws only = /[ \t]+/ ;
+
+(* a preferred and more inclusive view of white space *)
+ws = /([ \t]+|[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+)/ ;
+
+(* newline matches space to the end of the line, and any blank lines
+ following, and any space at the start of the next non-blank line.
+ We also use the "correct" Unicode definition of a line terminator.
+ Take that compatibility! *)
+newline = /[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+/ ;
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-12-01 06:20:57
|
Revision: 148
http://inc.svn.sourceforge.net/inc/?rev=148&view=rev
Author: chandlerc
Date: 2007-11-30 22:21:00 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
Big updated of the syntax chapter to include initial dips into the EBNF
grammar.
Modified Paths:
--------------
docs/trunk/grammar.ebnf
Property Changed:
----------------
docs/trunk/
Property changes on: docs/trunk
___________________________________________________________________
Name: bzr:revision-info
+ timestamp: 2007-12-01 00:15:58.611999989 -0500
committer: Chandler Carruth <cha...@gm...>
properties:
branch-nick: thesis
Name: bzr:file-ids
+
Name: bzr:revision-id:v3-trunk1
+ 15 cha...@gm...-20071201051558-mfus2lpqjl0wy2ck
Modified: docs/trunk/grammar.ebnf
===================================================================
--- docs/trunk/grammar.ebnf 2007-11-27 02:53:40 UTC (rev 147)
+++ docs/trunk/grammar.ebnf 2007-12-01 06:21:00 UTC (rev 148)
@@ -179,10 +179,10 @@
immediate octal = /-?0o[0-7]+([.,][0-7]+)?([eEpP][-+]?[0-7]+)?/ ;
immediate hexadecimal = /-?0x[0-9a-fA-F]+([.,][0-9a-fA-F]+)?([pP][-+]?[0-9a-fA-F]+)?/ ;
-(* matches just white space, not end of line, but forces there to be _some_ white space *)
+(* matches just white space, not end of line *)
ws only = /[ \t]+/ ;
-(* a more wholistic view of white space, we prefer this where ever possible *)
+(* a preferred and more inclusive view of white space *)
ws = /([ \t]+|[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+)/ ;
(* newline matches space to the end of the line, and any blank lines
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-11-27 02:53:34
|
Revision: 147
http://inc.svn.sourceforge.net/inc/?rev=147&view=rev
Author: chandlerc
Date: 2007-11-26 18:53:40 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
No reason to forbid program level side-effect free functions. These should
probably never appear in large-scale applications, but could be extremely
useful in both libraries and small-scale simulations and utility apps.
Modified Paths:
--------------
docs/trunk/grammar.ebnf
Modified: docs/trunk/grammar.ebnf
===================================================================
--- docs/trunk/grammar.ebnf 2007-11-26 23:43:33 UTC (rev 146)
+++ docs/trunk/grammar.ebnf 2007-11-27 02:53:40 UTC (rev 147)
@@ -4,7 +4,8 @@
and other objects defined within the program object. *)
program = { object definition | program section } ;
program section = object data
- | object procs ;
+ | object procs
+ | object funcs ;
object definition = [ ws ] , "object" , ws , object name , newline ,
object inheritance, object body , "end" , newline ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-11-26 23:43:29
|
Revision: 146
http://inc.svn.sourceforge.net/inc/?rev=146&view=rev
Author: chandlerc
Date: 2007-11-26 15:43:33 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
Always use type name system to refer to type objects directly.
Modified Paths:
--------------
docs/trunk/grammar.ebnf
Modified: docs/trunk/grammar.ebnf
===================================================================
--- docs/trunk/grammar.ebnf 2007-11-26 23:17:10 UTC (rev 145)
+++ docs/trunk/grammar.ebnf 2007-11-26 23:43:33 UTC (rev 146)
@@ -10,7 +10,7 @@
object inheritance, object body , "end" , newline ;
object name = label, { "." , label };
-object inheritance = { [ ws ] , "extends" , ws , name , { [ ws ] , "," , ws , name } , [ ws ] , [ "," ] , newline } ;
+object inheritance = { [ ws ] , "extends" , ws , type name , { [ ws ] , "," , ws , type name } , [ ws ] , [ "," ] , newline } ;
object body = { object section } ;
object section = [ "singleton" , ws ] , object data
| object layout
@@ -103,7 +103,7 @@
pointer type = "pointer" , "<" , ws , [ dimension , [ ws ] , "d" , ws ] , type , ws , ">" ;
dimension = immediate integer ;
-type name = [ [ "." ] , "." ] , label , { "." , label } ;
+type name = [ "." ] , "." , label , { "." , label } ;
statement = procedure call , newline
| mutation , newline
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-11-26 23:17:06
|
Revision: 145
http://inc.svn.sourceforge.net/inc/?rev=145&view=rev
Author: chandlerc
Date: 2007-11-26 15:17:10 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
Gross error in the type structure, had no concept of scope for type names.
Modified Paths:
--------------
docs/trunk/grammar.ebnf
Modified: docs/trunk/grammar.ebnf
===================================================================
--- docs/trunk/grammar.ebnf 2007-11-26 21:09:04 UTC (rev 144)
+++ docs/trunk/grammar.ebnf 2007-11-26 23:17:10 UTC (rev 145)
@@ -94,7 +94,7 @@
local declaration = variable declaration , newline ;
variable declaration = type , ws only , label ;
-type = atomic type | vector type | pointer type | label ;
+type = atomic type | vector type | pointer type | type name ;
atomic type = integer type | floating point type;
integer type = "int" , [ "<" , ws , precision , ws , ">" ] ;
floating point type = "float" , [ "<" , ws , precision , ws , ">" ] ;
@@ -103,6 +103,8 @@
pointer type = "pointer" , "<" , ws , [ dimension , [ ws ] , "d" , ws ] , type , ws , ">" ;
dimension = immediate integer ;
+type name = [ [ "." ] , "." ] , label , { "." , label } ;
+
statement = procedure call , newline
| mutation , newline
| loop control , newline ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-11-26 21:09:00
|
Revision: 144
http://inc.svn.sourceforge.net/inc/?rev=144&view=rev
Author: chandlerc
Date: 2007-11-26 13:09:04 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
Cleaning up parameter specification based on work with thesis.
Modified Paths:
--------------
docs/trunk/grammar.ebnf
Modified: docs/trunk/grammar.ebnf
===================================================================
--- docs/trunk/grammar.ebnf 2007-11-26 20:29:02 UTC (rev 143)
+++ docs/trunk/grammar.ebnf 2007-11-26 21:09:04 UTC (rev 144)
@@ -38,29 +38,19 @@
object operators = "operators" , newline , { object operator }, "end" , newline ;
object operator = "def" , ws only , mutop descriptor , newline , operator , "end" , newline ;
-procedure = [ procedure params ] , block ;
-procedure params = "params" , newline , { procedure param } , "end" , newline ;
-procedure param = [ ( "input" | "output" ) , ws ] , variable declaration , newline ;
-
-function = [ function params ] , block ;
-function params = "params" , newline , { function param } , "end" , newline ;
-function param = [ ( "input" | "output" ) , ws ] , variable declaration , newline ;
-
mutop descriptor = mutop type, ws only , ( label | symbol ) ;
mutop type = [ "left" , ws only ] , "unary"
| "right", ws only , "unary"
| [ "left" ] , [ ws only , "binary" ]
| "right" , [ ws only , "binary" ] ;
-mutator = mutator parameters , block ;
-mutator parameters = "param" , ws , variable declaration , newline
- | "lparam" , ws , variable declaration , newline ,
- "rparam" , ws , variable declaration , newline ;
+procedure = [ parameter specification ] , block ;
+function = [ parameter specification ] , block ;
+mutation = [ parameter specification ] , block ;
+operation = [ parameter specification ] , block ;
-operator = operator parameters , block ;
-operator parameters = "param" , ws , variable declaration , newline
- | "lparam" , ws , variable declaration , newline ,
- "rparam" , ws , variable declaration , newline ;
+parameter specification = "params" , newline , { parameter declaration } , "end" , newline ;
+parameter declaration = [ ( "input" | "output" ) , ws only ] , variable declaration , newline ;
block = { block entry } ;
block entry = flow control
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-11-26 20:29:45
|
Revision: 143
http://inc.svn.sourceforge.net/inc/?rev=143&view=rev
Author: chandlerc
Date: 2007-11-26 12:29:02 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
Merged divergent changes (i hope).
Modified Paths:
--------------
docs/trunk/grammar.ebnf
Modified: docs/trunk/grammar.ebnf
===================================================================
--- docs/trunk/grammar.ebnf 2007-11-24 20:48:54 UTC (rev 142)
+++ docs/trunk/grammar.ebnf 2007-11-26 20:29:02 UTC (rev 143)
@@ -3,7 +3,7 @@
(* programs are themselves an object, with only two valid sections,
and other objects defined within the program object. *)
program = { object definition | program section } ;
-program section = object attrs
+program section = object data
| object procs ;
object definition = [ ws ] , "object" , ws , object name , newline ,
@@ -12,31 +12,31 @@
object name = label, { "." , label };
object inheritance = { [ ws ] , "extends" , ws , name , { [ ws ] , "," , ws , name } , [ ws ] , [ "," ] , newline } ;
object body = { object section } ;
-object section = object data
+object section = [ "singleton" , ws ] , object data
| object layout
- | object procs
- | object funcs
- | object mutators
- | object operators ;
+ | [ "singleton" , ws ] , object procs
+ | [ "singleton" , ws ] , object funcs
+ | [ "singleton" , ws ] , object mutators
+ | [ "singleton" , ws ] , object operators ;
-object data = [ "singleton" , ws ] , "data" , newline , { object data member } , "end" , newline ;
+object data = "data" , newline , { object data member } , "end" , newline ;
object data member = variable declaration , newline ;
-object layout = [ "singleton" , ws ] , "layout" , newline , object layout entry , "end" , newline ;
+object layout = "layout" , newline , object layout entry , "end" , newline ;
object layout entry = label , newline
- | "insert" , ws , label , newline ;
+ | "insert" , ws only , label , newline ;
-object procs = [ "singleton" , ws ] , "procedures" , newline , { object procedure } , "end" , newline ;
-object procedure = "def" , ws , label , newline , procedure , "end" , newline ;
+object procs = "procedures" , newline , { object procedure } , "end" , newline ;
+object procedure = "def" , ws only , label , newline , procedure , "end" , newline ;
-object funcs = [ "singleton" , ws ] , "functions" , newline , { object function } , "end" , newline ;
-object function = "def" , ws , label , newline , function , "end" , newline ;
+object funcs = "functions" , newline , { object function } , "end" , newline ;
+object function = "def" , ws only , label , newline , function , "end" , newline ;
-object mutators = [ "singleton" , ws ] , "mutators" , newline , { object mutator }, "end" , newline ;
-object mutator = "def" , ws , mutop descriptor , newline , mutator , "end" , newline ;
+object mutators = "mutators" , newline , { object mutator }, "end" , newline ;
+object mutator = "def" , ws only , mutop descriptor , newline , mutator , "end" , newline ;
-object operators = [ "singleton" , ws ] , "operators" , newline , { object operator }, "end" , newline ;
-object operator = "def" , ws , mutop descriptor , newline , operator , "end" , newline ;
+object operators = "operators" , newline , { object operator }, "end" , newline ;
+object operator = "def" , ws only , mutop descriptor , newline , operator , "end" , newline ;
procedure = [ procedure params ] , block ;
procedure params = "params" , newline , { procedure param } , "end" , newline ;
@@ -46,11 +46,11 @@
function params = "params" , newline , { function param } , "end" , newline ;
function param = [ ( "input" | "output" ) , ws ] , variable declaration , newline ;
-mutop descriptor = mutop type, mutop token ;
-mutop type = [ "left" , ws ] , "unary"
- | "right", ws , "unary"
- | [ "left" ] , [ ws , "binary" ]
- | "right" , [ ws , "binary" ] ;
+mutop descriptor = mutop type, ws only , ( label | symbol ) ;
+mutop type = [ "left" , ws only ] , "unary"
+ | "right", ws only , "unary"
+ | [ "left" ] , [ ws only , "binary" ]
+ | "right" , [ ws only , "binary" ] ;
mutator = mutator parameters , block ;
mutator parameters = "param" , ws , variable declaration , newline
@@ -103,15 +103,15 @@
local declaration = variable declaration , newline ;
-variable declaration = type , ws , label ;
+variable declaration = type , ws only , label ;
type = atomic type | vector type | pointer type | label ;
atomic type = integer type | floating point type;
integer type = "int" , [ "<" , ws , precision , ws , ">" ] ;
floating point type = "float" , [ "<" , ws , precision , ws , ">" ] ;
-precision = immediate ;
+precision = immediate integer ;
vector type = "vector" , "<" , ws , size , ws , "x" , ws , atomic type , ws , ">" ;
pointer type = "pointer" , "<" , ws , [ dimension , [ ws ] , "d" , ws ] , type , ws , ">" ;
-dimension = immediate ;
+dimension = immediate integer ;
statement = procedure call , newline
| mutation , newline
@@ -123,9 +123,11 @@
procedure call = name , "(" , ws , [ procedure call parameters ] , ws , ")" , newline ;
procedure call parameters = procedure call parameter , { [ ws ] , "," , ws , procedure call parameter } , [ ws ] , [ "," ] ;
procedure call parameter = [ procedure call parameter modifier , ws ] , expression ;
-procedure call parameter modifier = "in" | "out" ;
+procedure call parameter modifier = "in"
+ | "out"
+ | "in" , ws , "out";
-mutation = expression , ws , mutop token , ws , expression ;
+mutation = expression , ws , ( label | symbol ) , ws , expression ;
(* this is the way we want to parse exprs... we pick the first
matching alternative to resolve any ambiguities. *)
@@ -147,7 +149,7 @@
name = label
| compound name ;
-inheritance
+
compound name = scoped name
| dereferenced name
| indexed name ;
@@ -161,10 +163,19 @@
indexed name = internal name , "[" , [ ws ] , expression , { [ ws ] , "," , expression } , [ ws ] , [ "," ] , [ ws ] , "]" ;
-mutop token = label | symbol ;
label = /_*[a-zA-Z][a-zA-Z0-9_]*/ ;
symbol = /[=+-*\/\\%^&|!<>?:#$]+/ ;
+immediate integer = immediate integer decimal
+ | immediate integer binary
+ | immediate integer octal
+ | immediate integer hexadecimal ;
+
+immediate integer decimal = /-?(0|[1-9][0-9]*)/ ;
+immediate integer binary = /-?0b[01]+/ ;
+immediate integer octal = /-?0o[0-7]+/ ;
+immediate integer hexadecimal = /-?0x[0-9a-fA-F]+/ ;
+
immediate = immediate decimal
| immediate binary
| immediate octal
@@ -176,8 +187,11 @@
immediate hexadecimal = /-?0x[0-9a-fA-F]+([.,][0-9a-fA-F]+)?([pP][-+]?[0-9a-fA-F]+)?/ ;
(* matches just white space, not end of line, but forces there to be _some_ white space *)
-ws = /[ \t]+/ ;
+ws only = /[ \t]+/ ;
+(* a more wholistic view of white space, we prefer this where ever possible *)
+ws = /([ \t]+|[ \t]*((\n|\r|\r\n|\U+0085|\U+000C|\U+2028|\U+2029)[ \t]*)+)/ ;
+
(* newline matches space to the end of the line, and any blank lines
following, and any space at the start of the next non-blank line.
We also use the "correct" Unicode definition of a line terminator.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-11-24 20:48:49
|
Revision: 142
http://inc.svn.sourceforge.net/inc/?rev=142&view=rev
Author: chandlerc
Date: 2007-11-24 12:48:54 -0800 (Sat, 24 Nov 2007)
Log Message:
-----------
Lots of edits on the grammar to bring it closer to the thesis.
Modified Paths:
--------------
docs/trunk/grammar.ebnf
Modified: docs/trunk/grammar.ebnf
===================================================================
--- docs/trunk/grammar.ebnf 2007-09-24 04:47:00 UTC (rev 141)
+++ docs/trunk/grammar.ebnf 2007-11-24 20:48:54 UTC (rev 142)
@@ -12,41 +12,39 @@
object name = label, { "." , label };
object inheritance = { [ ws ] , "extends" , ws , name , { [ ws ] , "," , ws , name } , [ ws ] , [ "," ] , newline } ;
object body = { object section } ;
-object section = object attrs
+object section = object data
| object layout
| object procs
| object funcs
| object mutators
| object operators ;
-object attrs = "attrs" , newline , { object attribute } , "end" , newline ;
-object attribute = variable declaration , newline ;
+object data = [ "singleton" , ws ] , "data" , newline , { object data member } , "end" , newline ;
+object data member = variable declaration , newline ;
-object layout = "layout" , newline , object layout entry , "end" , newline ;
+object layout = [ "singleton" , ws ] , "layout" , newline , object layout entry , "end" , newline ;
object layout entry = label , newline
| "insert" , ws , label , newline ;
-object procs = "procs" , newline , { object procedure } , "end" , newline ;
+object procs = [ "singleton" , ws ] , "procedures" , newline , { object procedure } , "end" , newline ;
object procedure = "def" , ws , label , newline , procedure , "end" , newline ;
-object funcs = "funcs" , newline , { object function } , "end" , newline ;
+object funcs = [ "singleton" , ws ] , "functions" , newline , { object function } , "end" , newline ;
object function = "def" , ws , label , newline , function , "end" , newline ;
-object mutators = "mutators" , newline , { object mutator }, "end" , newline ;
+object mutators = [ "singleton" , ws ] , "mutators" , newline , { object mutator }, "end" , newline ;
object mutator = "def" , ws , mutop descriptor , newline , mutator , "end" , newline ;
-object operators = "operators" , newline , { object operator }, "end" , newline ;
+object operators = [ "singleton" , ws ] , "operators" , newline , { object operator }, "end" , newline ;
object operator = "def" , ws , mutop descriptor , newline , operator , "end" , newline ;
-procedure = [ procedure inputs ] , [ procedure outputs ] , block ;
-procedure inputs = "ins" , newline , { procedure input } , "end" , newline ;
-procedure input = variable declaration , newline ;
-procedure outputs = "outs" , newline , { procedure output } , "end" , newline ;
-procedure output = variable declaration , newline ;
+procedure = [ procedure params ] , block ;
+procedure params = "params" , newline , { procedure param } , "end" , newline ;
+procedure param = [ ( "input" | "output" ) , ws ] , variable declaration , newline ;
-function = [ function inputs ] , block ;
-function inputs = "ins" , newline , { function input } , "end" , newline ;
-function input = variable declaration , newline ;
+function = [ function params ] , block ;
+function params = "params" , newline , { function param } , "end" , newline ;
+function param = [ ( "input" | "output" ) , ws ] , variable declaration , newline ;
mutop descriptor = mutop type, mutop token ;
mutop type = [ "left" , ws ] , "unary"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-09-24 04:46:58
|
Revision: 141
http://inc.svn.sourceforge.net/inc/?rev=141&view=rev
Author: chandlerc
Date: 2007-09-23 21:47:00 -0700 (Sun, 23 Sep 2007)
Log Message:
-----------
Minor updates and tweaks to the grammar.
Modified Paths:
--------------
docs/trunk/grammar.ebnf
Modified: docs/trunk/grammar.ebnf
===================================================================
--- docs/trunk/grammar.ebnf 2007-09-09 00:24:46 UTC (rev 140)
+++ docs/trunk/grammar.ebnf 2007-09-24 04:47:00 UTC (rev 141)
@@ -82,13 +82,25 @@
"end" , newline ;
loop block = "loop" , newline ,
- [ "pre" , newline , block , "end" , newline ] ,
+ [ ( pre statement | pre block ) ] ,
"body" , newline , block , "end" , newline ,
- [ "broken" , newline , block , "end" , newline ] ,
- [ "done" , newline , block , "end" , newline ] ,
- [ "post" , newline , block , "end" , newline ] ,
+ [ ( broken statement | broken block ) ] ,
+ [ ( done statement | done block ) ] ,
+ [ ( post statement | post block ) ] ,
"end" , newline ;
+pre statement = "pre:" , ws , statement ;
+pre block = "pre" , newline , block , "end" , newline ;
+
+broken statement = "broken:" , ws , statement ;
+broken block = "broken" , newline , block , "end" , newline ;
+
+done statement = "done:" , ws , statement ;
+done block = "done" , newline , block , "end" , newline ;
+
+post statement = "post:" , ws , statement ;
+post block = "post" , newline , block , "end" , newline ;
+
scope block = "scope" , newline , block , "end" , newline ;
local declaration = variable declaration , newline ;
@@ -96,7 +108,6 @@
variable declaration = type , ws , label ;
type = atomic type | vector type | pointer type | label ;
atomic type = integer type | floating point type;
-(* integer type = signed integer type | unsigned integer type ; *)
integer type = "int" , [ "<" , ws , precision , ws , ">" ] ;
floating point type = "float" , [ "<" , ws , precision , ws , ">" ] ;
precision = immediate ;
@@ -133,18 +144,6 @@
| function call
| name ;
-(* this is the more "semantic" way of thinking about exprs... *)
-old expression = "(" , [ ws ] , expression , [ ws ] , symbol , [ ws ] , expression , [ ws ] , ")"
- | "(" , [ ws ] , expression , ws , label , ws , expression , [ ws ] , ")"
- | "(" , [ ws ] , expression , [ ws ] , symbol , [ ws ] , ")"
- | "(" , [ ws ] , expression , ws , label , [ ws ] , ")"
- | "(" , [ ws ] , symbol , [ ws ] , expression , [ ws ] , ")"
- | "(" , [ ws ] , label , ws , expression , [ ws ] , ")"
- | immediate
- | "self"
- | name
- | function call ;
-
function call = name , "(" , [ ws ] , [ function call parameters ] , [ ws ] , ")" ;
function call parameters = expression , { [ ws ] , "," , ws , expression } , [ ws ] , [ "," ] ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-09-09 00:24:43
|
Revision: 140
http://inc.svn.sourceforge.net/inc/?rev=140&view=rev
Author: chandlerc
Date: 2007-09-08 17:24:46 -0700 (Sat, 08 Sep 2007)
Log Message:
-----------
Added resolutions for function pointer questions.
Modified Paths:
--------------
docs/trunk/notes/open_questions.txt
Modified: docs/trunk/notes/open_questions.txt
===================================================================
--- docs/trunk/notes/open_questions.txt 2007-09-03 07:45:28 UTC (rev 139)
+++ docs/trunk/notes/open_questions.txt 2007-09-09 00:24:46 UTC (rev 140)
@@ -34,7 +34,14 @@
a viable expression syntax. This of course, leads to another
open question. Allowing this opens the box of *calling* pointers
to functions, and whether that should be allowed.
+ RESOLUTION: Yes, but compile-time constant pointers
+ RATIONAL: Functions are ultimately singleton objects in the program,
+ and they have an address. However they are compile-time constant
+ singleton objects. Thus, the address of a function is a compile
+ time constant pointer to constant memory. This means read-only,
+ etc. Self modifying is out, but inspection is allowed.
+
Is there any reason for allowing pointers to functions to be
dereferenced and called?
DEPENDS ON: This necessitates pointers to functions...
@@ -44,6 +51,11 @@
created executable code for some JIT / Interpreter engine? See
above arguments, this really is a compromise on the above
question.
+ RESOLUTION: No
+ RATIONAL: The only functionality provided is polymorphism and
+ algorithm selection. There is no way to compute a valid and
+ usable function entry point, and forbidding this is A Good
+ Thing.
Should pointer dereferencing be an expression-like syntax, or should it
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-09-03 09:56:54
|
Revision: 139
http://inc.svn.sourceforge.net/inc/?rev=139&view=rev
Author: chandlerc
Date: 2007-09-03 00:45:28 -0700 (Mon, 03 Sep 2007)
Log Message:
-----------
Added some open questions.
Added Paths:
-----------
docs/trunk/notes/open_questions.txt
Added: docs/trunk/notes/open_questions.txt
===================================================================
--- docs/trunk/notes/open_questions.txt (rev 0)
+++ docs/trunk/notes/open_questions.txt 2007-09-03 07:45:28 UTC (rev 139)
@@ -0,0 +1,74 @@
+
+Is there any reason for allowing pointers to functions? More
+specifically, is there any reason to allow taking the address of
+a function?
+ INTUITION: No! Structured programming!
+ RATIONAL: The only use of function pointers is to either a) inspect
+ the memory representation of some piece of code, b) do some form
+ of dynamic function selection, c) modify the memory
+ representation of some code. These go from bad to worse in the
+ eyes of a structured programmer. While (a) seems suspicious and
+ not useful, (c) is downright dangerous, and should *never* be
+ allowed in this manner, should it? I understand the need for
+ dynamically executing dynamically generated machine code
+ (interpreters, JITing, etc), but it seems it should be managed
+ in a more careful way, and preferably one less prone to security
+ degradation. (b) actually seems somewhat useful, but is readily
+ and more reliably achieved through polymorphism on a pointer to
+ an object, and virtual method invocation. Same problem,
+ different solution. This later solution however allows more
+ sanity checking, and should in general be cleaner to represent
+ as a language feature. (c) remains the most convincing argument
+ _for_ this, but also the most convincing argument for explicitly
+ forbidding this.
+ IMPLICATIONS: Denying this sets up the potential for another layer
+ expression and name resolution syntax and semantic constraints.
+ Currently, name resolution can involve pointer dereferencing in
+ its many forms as well as scope resolution. However, pointer
+ dereferencing could become something done in expressions, not in
+ name resolution. Name resolution would be narrowed to scope
+ resolution. Pointer dereferencing and indexing would become an
+ expression-like construct, exempted due to its syntactical
+ vagaries. Alternatively, it could be expressly made an
+ expression and its syntax could be directly supported as
+ a viable expression syntax. This of course, leads to another
+ open question. Allowing this opens the box of *calling* pointers
+ to functions, and whether that should be allowed.
+
+Is there any reason for allowing pointers to functions to be
+dereferenced and called?
+ DEPENDS ON: This necessitates pointers to functions...
+ INTUITION: No! Structured Programming! OO! The Wrong Way!
+ RATIONAL: This is just dying for buffer overflow/underflow hackers
+ to abuse beyond all reason... But would allow calling into newly
+ created executable code for some JIT / Interpreter engine? See
+ above arguments, this really is a compromise on the above
+ question.
+
+
+Should pointer dereferencing be an expression-like syntax, or should it
+utilize well formed expressions with definitions specific to the pointer
+type. The latter would allow user defined types to provide user defined
+behavior for dereferencing and indexing syntaxes. The former would
+reserve those syntaxes as special and unique to pointer manipulation,
+along with double-quoted strings.
+ INTUITION: expression-like
+ RATIONAL: Expressions themselves are very minimally defined, but
+ also very general syntactical constructs. Because of their
+ generality, adding more syntactical combinations of them
+ increases their conceptual ambiguity even if the grammatical
+ ambiguities can be massaged away. Keep it simple, and provide
+ concise and *precise* exceptions to the rule where they are
+ actually needed.
+ INTUITION: expressions
+ RATIONAL: Exceptions to rules are bad, and should be avoided
+ whenever possible. The dereference syntax already fits that of
+ an expression: '( @foo )' why can @ not be a unary prefix
+ operator? The indexing syntax is significantly harder to fit
+ into this mold, and is syntactically closer to a function call.
+ Why not allow indexing syntax for all user defined objects in
+ the same way function call syntax is allowed for functions on an
+ object? There is no particular reason why one should be
+ provided, and the other should not.
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-09-02 08:18:01
|
Revision: 138
http://inc.svn.sourceforge.net/inc/?rev=138&view=rev
Author: chandlerc
Date: 2007-09-02 01:18:01 -0700 (Sun, 02 Sep 2007)
Log Message:
-----------
Adding some late-night inspiration notes.
Added Paths:
-----------
docs/trunk/notes/
docs/trunk/notes/globals_and_statics.txt
Added: docs/trunk/notes/globals_and_statics.txt
===================================================================
--- docs/trunk/notes/globals_and_statics.txt (rev 0)
+++ docs/trunk/notes/globals_and_statics.txt 2007-09-02 08:18:01 UTC (rev 138)
@@ -0,0 +1,126 @@
+# Globals and Statics #
+
+A major point of contention in programming languages are "global"
+variables or values, and "static" variables or values. Both of which are
+essentially the same thing. Objects have some state that is shared among
+all objects of the same type. This state is considered "static", a
+misnomer, meaning it is not specific to the instance object, but rather
+to the object type. This is widely used in C++ and Java OO idioms. One
+extremely common usage is to provide "static methods" that do not
+operate on specific instances. The most common of these are generator
+methods which generate instance objects, or instance object references.
+These allow registry based instance creation, etc.
+
+A related and also ill named concept are "globals", these being instance
+objects, variables, or values defined at a "global" scope. These are
+highly problematic because of the eventual scope polluting concerns (if
+globals are always visible, every time they are created, they eat up a
+slice of _every other scope_) and because of a contradiction in globals
+being visible in all scopes, but not having a well defined scope of
+their own. Where do they exist? When are they created? The so-called
+"global" scope is not a procedural block, and does not provide any
+semantics for ordering, providing near infinite chicken and egg
+problems.
+
+To compound matters, in C++ at least, arguably the most widespread OO
+language in this area of computing, "static" state is oft represented
+and handled with all the ambiguity and insanity of "global" objects.
+Furthermore, types themselves fall into this mire of uncertainty and
+ambiguity. When are types defined? Where? What is the scope of a type
+definition??? These are questions without rigorous and sensible answers
+in the land of C++ and Java, languages that seem to think structured
+programming, and the concepts there-in somehow don't apply, needn't
+apply, or are inherently incompatible with those of object-oriented
+program structuring.
+
+The solution to these problems is to drop the misnomers and ill-posed
+assumptions that these concepts are currently based on. Rather, look at
+the problems they solve, and look at the intuitive and object-oriented
+manner in which to address them. Most of all, do this without loosing
+sight of the overriding mandates: All things _must_ have scope, and all
+things _must_ be object-oriented in structure. Scope is a rigorously
+defined concept, and cannot be extricated from its foundations -- that
+is, we cannot have the effects of scoping without providing the
+framework to build and maintain scope. All things must, in some way,
+shape, or fashion, be objects. They can break the rules, do their own
+thing, and be completely specialized and unique objects, but at the end
+of the day, they must be objects, and even if they behave like no other
+object in the language, they must be _thought_ of as objects, at some
+level, by the programmer as they write the code, and the compiler as it
+interprets the code. This may seem trivial, when all the rules and
+strictures are allowed to be violated, but object-oriented structuring
+is a matter of philosophy, and mindset, not a set of hard and fast
+rules. It is a way of framing questions, and understanding answers, as
+long as these hold true, the mechanisms for obtaining said answers can
+vary as much as necessary.
+
+Thus, a solution begins with a better description of the problem faced
+by the programmer. Let us also begin in a bottom up fashion, lest a
+solution to a general problem end up solving a wide swath of other more
+specific problems for us.
+
+There is no "global" scope. This is a name given to a "scope" that is
+expressly undefined. The name is given to cover up the fact that no one
+bothered to give it a definition. A name does not suffice for a
+definition, and the problems arose thence. Rather, we are writing
+"programs". Thus the utmost highest scope of anything we write is the
+"program" scope. These are variables and values shared throughout an
+entire instance of a program, which intuitively maps to an execution of
+a program. What constitutes "static" state at the program scope? Why,
+compile time constants. That is, a value or state which is invariant
+from one execution to another, but is perhaps not known until the
+executable is produced. Particularly, we are discussing such a value or
+state which also pervades the entire program, and thus exists at the
+program scope.
+
+We have thus, in resolving "global" scope, or the root of the scope
+tree, provided two solutions. A program has a distinct scope. This roots
+the scope tree. A value which is "constant" at compile time, is the
+equivalent of a static value in the program scope. Sadly, this does not
+quite solve the issue of "static" state for more general circumstances.
+These may vary between executions of the program, but must not vary
+within a singly execution.
+
+NIX parts of the above: I was wrong, constant values are _not_
+program-scope "statics". Those would be shared between program
+instances, but potentially variant. Constants are just that, constants.
+They are a runtime v. compiletime construct, not a part of the object
+framework. However, it might be sufficient to think of program-scoped
+constants as the only equivalent of program-scope "statics" available.
+Thus, items at the program-scope, and which happen to be constant, could
+behave much like "statics" of other objects would.
+
+Let us approach this again, from a different perspective. First, assume
+all things, including definitions of types, are objects. Now, consider
+the singleton framework, or a group of related procedures and state.
+These have none of the polymorphic advantages of advanced object models.
+They are simpler constructs, simply organizing procedures and data into
+coherent groups. The definition of such a group _is_ the group, and is
+an object. Type definitions are a particular extension of this group
+construct. The type definition _is_ a group, an object, and likely
+contained within some other group. It might have group-level methods and
+data, providing the "static" functionality of shared state. Type
+definitions allow procedures to define new objects, instances of that
+particular type, but that is orthogonal to the issue of what the
+definition itself is. Still more interesting, these groups provide a
+clear breakdown of scope, and also form a good basis for a "program"
+object. You cannot create instances of a program object, it is not a
+defined type, but rather a group of related methods and data. There is
+no polymorphism to be done. It fits perfectly the description of a
+singleton "object". Whether "singleton" or "group" is the appropriate
+name for these constructs is an open question. "types" clearly inherit
+from them, as do "programs".
+
+It would be very nice if a "singleton" object were in actuality just as
+any other object. It might behave precisely as any other instance
+object, and have a similar interface. This may not be practical, for we
+must not confuse the definition of types in order to allow the
+definition of singletons to be similar. However, there is no inherent
+reason why all the features planed for instance types could not be used,
+just once, in the description of a singleton object, allowing it a data
+layout, etc etc. How to integrate these two concepts syntactically will
+be a challenge, but this conceptually solves the scope tree rooting
+problem, the singleton problem, the program-object problem, and the
+shared vs. instance data problem with a single stone.
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-08-15 16:47:22
|
Revision: 137
http://inc.svn.sourceforge.net/inc/?rev=137&view=rev
Author: chandlerc
Date: 2007-08-15 09:47:26 -0700 (Wed, 15 Aug 2007)
Log Message:
-----------
Recent work on the grammar.
Modified Paths:
--------------
docs/trunk/grammar.ebnf
Modified: docs/trunk/grammar.ebnf
===================================================================
--- docs/trunk/grammar.ebnf 2007-08-14 09:54:50 UTC (rev 136)
+++ docs/trunk/grammar.ebnf 2007-08-15 16:47:26 UTC (rev 137)
@@ -94,13 +94,14 @@
local declaration = variable declaration , newline ;
variable declaration = type , ws , label ;
-type = integer type | floating point type | pointer type | label ;
-integer type = signed integer type | unsigned integer type ;
-signed integer type = "int" , [ "<" , ws , precision , ws , ">" ] ;
-unsigned integer type = "uint" , [ "<" , ws , precision , ws , ">" ] ;
+type = atomic type | vector type | pointer type | label ;
+atomic type = integer type | floating point type;
+(* integer type = signed integer type | unsigned integer type ; *)
+integer type = "int" , [ "<" , ws , precision , ws , ">" ] ;
floating point type = "float" , [ "<" , ws , precision , ws , ">" ] ;
precision = immediate ;
-pointer type = "pointer" , "<" , ws , [ dimension , "," , ws ] , type , ws , ">" ;
+vector type = "vector" , "<" , ws , size , ws , "x" , ws , atomic type , ws , ">" ;
+pointer type = "pointer" , "<" , ws , [ dimension , [ ws ] , "d" , ws ] , type , ws , ">" ;
dimension = immediate ;
statement = procedure call , newline
@@ -149,7 +150,7 @@
name = label
| compound name ;
-
+inheritance
compound name = scoped name
| dereferenced name
| indexed name ;
@@ -158,7 +159,7 @@
internal name = label
| "(" , [ ws ] , compound name , [ ws ] , ")"
-scoped name = [ ( ".." | "." ) ] , internal name , { "." , label } ;
+scoped name = [ [ "." ] , "." ] , internal name , { "." , label } ;
dereferenced name = "@" , internal name ;
indexed name = internal name , "[" , [ ws ] , expression , { [ ws ] , "," , expression } , [ ws ] , [ "," ] , [ ws ] , "]" ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-08-14 09:54:49
|
Revision: 136
http://inc.svn.sourceforge.net/inc/?rev=136&view=rev
Author: chandlerc
Date: 2007-08-14 02:54:50 -0700 (Tue, 14 Aug 2007)
Log Message:
-----------
Added some better testing of the previously exposed label bug, and a gross
hack to fix it temporarily. Clears up any ambiguities, etc.
Modified Paths:
--------------
parser/trunk/src/label_node.cpp
parser/trunk/test/label_node_test.cpp
Modified: parser/trunk/src/label_node.cpp
===================================================================
--- parser/trunk/src/label_node.cpp 2007-08-14 09:20:25 UTC (rev 135)
+++ parser/trunk/src/label_node.cpp 2007-08-14 09:54:50 UTC (rev 136)
@@ -43,28 +43,26 @@
bool
labelNode::create(
- const char* text,
- unsigned int length,
- unsigned int begin,
- unsigned int& end,
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end,
parseTreeNode* parent,
parseTreeNode* next
)
{
- if( !this->parseTreeNode::init( parent, next ) )
+ if( this->parseTreeNode::init( parent, next ) )
{
- return( false );
- }
+ if( this->labelNode::init( text, length, begin, end ) )
+ {
+ return( true );
+ }
- if( !this->labelNode::init( text, length, begin, end ) )
- {
// revert anything we've done so far
this->parseTreeNode::deinit();
-
- return( false );
}
- return( true );
+ return( false );
}
@@ -81,12 +79,12 @@
{
bool ret = true;
- if( !this->parseTreeNode::deinit() )
+ if( !this->labelNode::deinit() )
{
ret = false;
}
- if( !this->labelNode::deinit() )
+ if( !this->parseTreeNode::deinit() )
{
ret = false;
}
@@ -127,6 +125,91 @@
return( false );
}
+ // We have to filter these results for any matches which form a reserved
+ // word. FIXME: This is an ugly, and grotesque HACK! We are hard coding the
+ // reserved words here, and embedding them in a switch. I have a hard time
+ // expressing how ugly this is. This is what I should do, but I don't have
+ // time to do currently:
+ //
+ // 1) Provide a static registry in the label node where other parse nodes
+ // are able to readily add their reserved labels (NB: This is not all
+ // word-tokens!! Only word tokens which occur in a potential label
+ // context!) with this parser.
+ //
+ // 2) Provide static construction of the regular expression (DUH) and
+ // construct it _including_ the ability to recognize and disregard any
+ // registered reserved words. This should still maintain linear complexity
+ // due to the lovely nature of regular languages, and their ability to be
+ // expressed as state machines.
+ switch( text[ begin ] )
+ {
+ default:
+ break;
+
+ case 'i':
+ if( consumed == 2 && memcmp( &( text[ begin ] ), "if", 2 ) == 0 )
+ {
+ return( false );
+ }
+ break;
+
+ case 'e':
+ if( consumed == 3 && memcmp( &( text[ begin ] ), "end", 3 ) == 0 )
+ {
+ return( false );
+ }
+
+ if( consumed == 4 && memcmp( &( text[ begin ] ), "else", 4 ) == 0 )
+ {
+ return( false );
+ }
+
+ break;
+
+ case 't':
+ if( consumed == 4 && memcmp( &( text[ begin ] ), "then", 4 ) == 0 )
+ {
+ return( false );
+ }
+ break;
+
+ case 'l':
+ if( consumed == 4 && memcmp( &( text[ begin ] ), "loop", 4 ) == 0 )
+ {
+ return( false );
+ }
+ break;
+
+ case 'b':
+ if( consumed == 5 && memcmp( &( text[ begin ] ), "break", 5 ) == 0 )
+ {
+ return( false );
+ }
+ break;
+
+ case 'd':
+ if( consumed == 4 && memcmp( &( text[ begin ] ), "done", 4 ) == 0 )
+ {
+ return( false );
+ }
+ break;
+
+ case 's':
+ if( consumed == 5 && memcmp( &( text[ begin ] ), "scope", 5 ) == 0 )
+ {
+ return( false );
+ }
+
+ if( consumed == 4 && memcmp( &( text[ begin ] ), "self", 4 ) == 0 )
+ {
+ return( false );
+ }
+
+ break;
+ }
+
+ // I feel dirty having even written this... wow.
+
end = begin + consumed;
return( true );
Modified: parser/trunk/test/label_node_test.cpp
===================================================================
--- parser/trunk/test/label_node_test.cpp 2007-08-14 09:20:25 UTC (rev 135)
+++ parser/trunk/test/label_node_test.cpp 2007-08-14 09:54:50 UTC (rev 136)
@@ -35,17 +35,44 @@
class labelNodeTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( labelNodeTest );
- CPPUNIT_TEST( test_create_empty );
- CPPUNIT_TEST( test_create_simple );
+ CPPUNIT_TEST( test_empty );
+ CPPUNIT_TEST( test_basic1 );
+ CPPUNIT_TEST( test_basic2 );
+ CPPUNIT_TEST( test_basic3 );
+ CPPUNIT_TEST( test_basic4 );
+ CPPUNIT_TEST( test_basic5 );
+ CPPUNIT_TEST( test_basic6 );
+ CPPUNIT_TEST( test_basic7 );
+ CPPUNIT_TEST( test_padded1 );
+ CPPUNIT_TEST( test_padded2 );
+ CPPUNIT_TEST( test_padded3 );
+ CPPUNIT_TEST( test_padded4 );
+ CPPUNIT_TEST( test_padded5 );
+ CPPUNIT_TEST( test_padded6 );
+ CPPUNIT_TEST( test_padded7 );
+ CPPUNIT_TEST( test_padded8 );
+ CPPUNIT_TEST( test_padded9 );
+ CPPUNIT_TEST( test_padded10 );
+ CPPUNIT_TEST( test_reserved1 );
+ CPPUNIT_TEST( test_reserved2 );
+ CPPUNIT_TEST( test_reserved3 );
+ CPPUNIT_TEST( test_reserved4 );
+ CPPUNIT_TEST( test_reserved5 );
+ CPPUNIT_TEST( test_reserved6 );
+ CPPUNIT_TEST( test_reserved7 );
+ CPPUNIT_TEST( test_reserved8 );
+ CPPUNIT_TEST( test_reserved9 );
CPPUNIT_TEST_SUITE_END();
private:
labelNode* node;
+ unsigned int end;
public:
void
setUp( void )
{
+ end = 0;
node = new labelNode;
CPPUNIT_ASSERT( node != NULL );
};
@@ -56,50 +83,79 @@
CPPUNIT_ASSERT( node != NULL );
delete node;
node = NULL;
+ end = 0;
};
- void
- test_create_empty( void )
- {
- unsigned int i;
- const char* empty = "";
+#define MY_TEST_NODE_PRE(name,val,start,stop) \
+ void \
+ test_##name( void ) \
+ { \
+ const char* s = val; \
+ CPPUNIT_ASSERT( node->create( s, strlen( s ), start, end ) ); \
+ CPPUNIT_ASSERT_EQUAL( (unsigned int)( strlen( s ) + stop ), end )
- CPPUNIT_ASSERT( !node->create( empty, 0, 0, i ) );
- };
+#define MY_TEST_NODE_POST() \
+ CPPUNIT_ASSERT( node->destroy() ); \
+ }
-#define MY_ASSERTS_NAME_VALUE(name,val,start,end) \
- unsigned int name##_i; \
- const char* name##_s = val; \
- CPPUNIT_ASSERT( node->create( name##_s, strlen( name##_s ), start, name##_i ) ); \
- CPPUNIT_ASSERT_EQUAL( (unsigned int)( strlen( name##_s ) + end ), name##_i ); \
- CPPUNIT_ASSERT( node->destroy() )
+#define MY_TEST_NODE_BOUNDS(name,val,start,stop) \
+ MY_TEST_NODE_PRE(name,val,start,stop); \
+ MY_TEST_NODE_POST()
-#define MY_ASSERTS_NAME_VALUE_FAIL(name,start) \
- CPPUNIT_ASSERT( !node->create( name##_s, strlen( name##_s ), start, name##_i ) )
+#define MY_TEST_NODE(name,val) \
+ MY_TEST_NODE_PRE(name,val,0,0); \
+ MY_TEST_NODE_POST()
- void
- test_create_simple( void )
- {
- MY_ASSERTS_NAME_VALUE( txt, "foo", 0, 0 );
- MY_ASSERTS_NAME_VALUE( txt_txt, "foo_bar", 0, 0 );
- MY_ASSERTS_NAME_VALUE( txtnum, "foo42", 0, 0 );
- MY_ASSERTS_NAME_VALUE( txt_num, "foo_42", 0, 0 );
- MY_ASSERTS_NAME_VALUE( txt_numtxt, "foo_42bar", 0, 0 );
- MY_ASSERTS_NAME_VALUE( _txt, "_foo", 0, 0 );
- MY_ASSERTS_NAME_VALUE( __txt__, "__bar__", 1, 0 );
+#define MY_TEST_NODE_FAIL_PRE(name,val,start) \
+ void \
+ test_##name( void ) \
+ { \
+ const char* s = val; \
+ CPPUNIT_ASSERT( !node->create( s, strlen( s ), start, end ) )
- MY_ASSERTS_NAME_VALUE( s_txtnum_s, " foo1024 ", 1, -1 );
- MY_ASSERTS_NAME_VALUE_FAIL( s_txtnum_s, 0 );
- MY_ASSERTS_NAME_VALUE( s_numtxt_s, " 1024foo ", 5, -1 );
- MY_ASSERTS_NAME_VALUE_FAIL( s_numtxt_s, 0 );
- MY_ASSERTS_NAME_VALUE_FAIL( s_numtxt_s, 1 );
- MY_ASSERTS_NAME_VALUE_FAIL( s_numtxt_s, 3 );
- MY_ASSERTS_NAME_VALUE( s_num__txt_s, " 1024__foo ", 5, -1 );
- MY_ASSERTS_NAME_VALUE_FAIL( s_num__txt_s, 0 );
- MY_ASSERTS_NAME_VALUE_FAIL( s_num__txt_s, 1 );
- MY_ASSERTS_NAME_VALUE_FAIL( s_num__txt_s, 3 );
- };
+#define MY_TEST_NODE_FAIL_POST() \
+ CPPUNIT_ASSERT( node->destroy() ); \
+ }
+#define MY_TEST_NODE_FAIL(name,val) \
+ MY_TEST_NODE_FAIL_PRE(name,val,0); \
+ MY_TEST_NODE_FAIL_POST()
+
+#define MY_TEST_NODE_BOUNDS_FAIL(name,val,start) \
+ MY_TEST_NODE_FAIL_PRE(name,val,start); \
+ MY_TEST_NODE_FAIL_POST()
+
+ MY_TEST_NODE_FAIL( empty, "" );
+
+ MY_TEST_NODE( basic1, "foo" );
+ MY_TEST_NODE( basic2, "foo_bar" );
+ MY_TEST_NODE( basic3, "foo42" );
+ MY_TEST_NODE( basic4, "foo_42" );
+ MY_TEST_NODE( basic5, "foo_42bar" );
+ MY_TEST_NODE( basic6, "_foo" );
+ MY_TEST_NODE_BOUNDS( basic7, "__bar__", 1, 0 );
+
+ MY_TEST_NODE_BOUNDS( padded1, " foo1024 ", 1, -1 );
+ MY_TEST_NODE_FAIL( padded2, " foo1024 " );
+ MY_TEST_NODE_BOUNDS( padded3, " 1024foo ", 5, -1 );
+ MY_TEST_NODE_FAIL( padded4, " 1024foo " );
+ MY_TEST_NODE_BOUNDS_FAIL( padded5, " 1024foo ", 1 );
+ MY_TEST_NODE_BOUNDS_FAIL( padded6, " 1024foo ", 3 );
+ MY_TEST_NODE_BOUNDS( padded7, " 1024__foo ", 5, -1 );
+ MY_TEST_NODE_FAIL( padded8, " 1024__foo " );
+ MY_TEST_NODE_BOUNDS_FAIL( padded9, " 1024__foo ", 1 );
+ MY_TEST_NODE_BOUNDS_FAIL( padded10, " 1024__foo ", 3 );
+
+ MY_TEST_NODE_FAIL( reserved1, "if" )
+ MY_TEST_NODE_FAIL( reserved2, "end" )
+ MY_TEST_NODE_FAIL( reserved3, "then" )
+ MY_TEST_NODE_FAIL( reserved4, "else" )
+ MY_TEST_NODE_FAIL( reserved5, "loop" )
+ MY_TEST_NODE_FAIL( reserved6, "break" )
+ MY_TEST_NODE_FAIL( reserved7, "done" )
+ MY_TEST_NODE_FAIL( reserved8, "scope" )
+ MY_TEST_NODE_FAIL( reserved9, "self" )
+
};
CPPUNIT_TEST_SUITE_REGISTRATION( labelNodeTest );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-08-14 09:20:23
|
Revision: 135
http://inc.svn.sourceforge.net/inc/?rev=135&view=rev
Author: chandlerc
Date: 2007-08-14 02:20:25 -0700 (Tue, 14 Aug 2007)
Log Message:
-----------
Include the if statement node as a viable block entry. The test cases for this
uncover a stupid bug -- currently reserved words are not withheld from the
label parser!!! Wow. I Loose... Adding test cases for this, and eventually
should probably systemize this somehow, so that nodes can "register" key
words, which then are respected by the label parser.
Modified Paths:
--------------
parser/trunk/include/block_entry_node.hpp
parser/trunk/include/node_decls.hpp
parser/trunk/src/block_entry_node.cpp
parser/trunk/test/block_entry_node_test.cpp
Modified: parser/trunk/include/block_entry_node.hpp
===================================================================
--- parser/trunk/include/block_entry_node.hpp 2007-08-14 08:56:45 UTC (rev 134)
+++ parser/trunk/include/block_entry_node.hpp 2007-08-14 09:20:25 UTC (rev 135)
@@ -49,23 +49,24 @@
/// \name Contained Node Choices
//@{
- statementNode* statement;
- localDeclNode* local_decl;
+ statementNode* statement;
+ localDeclNode* local_decl;
+ ifStatementNode* if_stmt;
//@}
/// \name Instance Creation and Destruction
//@{
- virtual bool create(
- const char* text,
- unsigned int length,
- unsigned int begin,
- unsigned int& end,
- parseTreeNode* parent = NULL,
- parseTreeNode* next = NULL
- );
- virtual bool destroy( void );
+ virtual bool create(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end,
+ parseTreeNode* parent = NULL,
+ parseTreeNode* next = NULL
+ );
+ virtual bool destroy( void );
//@}
@@ -74,13 +75,13 @@
/// \name Initialization Routines
//@{
- bool init(
- const char* text,
- unsigned int length,
- unsigned int begin,
- unsigned int& end
- );
- bool deinit( void );
+ bool init(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end
+ );
+ bool deinit( void );
//@}
Modified: parser/trunk/include/node_decls.hpp
===================================================================
--- parser/trunk/include/node_decls.hpp 2007-08-14 08:56:45 UTC (rev 134)
+++ parser/trunk/include/node_decls.hpp 2007-08-14 09:20:25 UTC (rev 135)
@@ -57,9 +57,9 @@
class typeNode;
class variableDeclNode;
class localDeclNode;
+class ifStatementNode;
class blockEntryNode;
class blockNode;
-class ifStatementNode;
#endif // _node_decls_header_
Modified: parser/trunk/src/block_entry_node.cpp
===================================================================
--- parser/trunk/src/block_entry_node.cpp 2007-08-14 08:56:45 UTC (rev 134)
+++ parser/trunk/src/block_entry_node.cpp 2007-08-14 09:20:25 UTC (rev 135)
@@ -31,6 +31,7 @@
#include <parse_tree_node.hpp>
#include <statement_node.hpp>
#include <local_decl_node.hpp>
+#include <if_statement_node.hpp>
///
@@ -120,22 +121,37 @@
unsigned int& end
)
{
- // we try the local declaration parser first
+ // initialize to NULL once, so we don't have to repeat code.
+ this->statement = NULL;
+ this->local_decl = NULL;
+ this->if_stmt = NULL;
+
+ // first try the if statement parser, as it has a distinctive starting
+ // token
+ this->if_stmt = new ifStatementNode;
+ if( this->if_stmt->create( text, length, begin, end, this ) )
+ {
+ // success
+ return( true );
+ }
+
+ // clean up if_stmt
+ delete this->if_stmt;
+ this->if_stmt = NULL;
+
+ // we try the local declaration parser next
this->local_decl = new localDeclNode;
if( this->local_decl->create( text, length, begin, end, this ) )
{
// success
- this->statement = NULL;
return( true );
}
// cleanup local_decl
delete this->local_decl;
-
- // mark it as unused.
this->local_decl = NULL;
- // now try the vector parser
+ // now try the statement parser
this->statement = new statementNode;
if( this->statement->create( text, length, begin, end, this ) )
{
@@ -145,8 +161,6 @@
// clean up statement
delete this->statement;
-
- // mark it as unused
this->statement = NULL;
return( false );
@@ -164,28 +178,39 @@
bool
blockEntryNode::deinit( void )
{
- bool ret = true;
+ bool ret = true;
+ if( this->statement != NULL )
+ {
+ if( !this->statement->destroy() )
+ {
+ ret = false;
+ }
+
+ delete this->statement;
+ this->statement = NULL;
+ }
+
if( this->local_decl != NULL )
{
if( !this->local_decl->destroy() )
{
- ret = false;
+ ret = false;
}
delete this->local_decl;
- this->local_decl = NULL;
+ this->local_decl = NULL;
}
- if( this->statement != NULL )
+ if( this->if_stmt != NULL )
{
- if( !this->statement->destroy() )
+ if( !this->if_stmt->destroy() )
{
- ret = false;
+ ret = false;
}
- delete this->statement;
- this->statement = NULL;
+ delete this->if_stmt;
+ this->if_stmt = NULL;
}
return( ret );
Modified: parser/trunk/test/block_entry_node_test.cpp
===================================================================
--- parser/trunk/test/block_entry_node_test.cpp 2007-08-14 08:56:45 UTC (rev 134)
+++ parser/trunk/test/block_entry_node_test.cpp 2007-08-14 09:20:25 UTC (rev 135)
@@ -31,6 +31,7 @@
#include <block_entry_node.hpp>
#include <statement_node.hpp>
#include <local_decl_node.hpp>
+#include <if_statement_node.hpp>
@@ -49,6 +50,12 @@
CPPUNIT_TEST( test_decl4 );
CPPUNIT_TEST( test_decl5 );
CPPUNIT_TEST( test_decl6 );
+ CPPUNIT_TEST( test_if_stmt1 );
+ CPPUNIT_TEST( test_if_stmt2 );
+ CPPUNIT_TEST( test_if_stmt3 );
+ CPPUNIT_TEST( test_if_stmt4 );
+ CPPUNIT_TEST( test_if_stmt5 );
+ CPPUNIT_TEST( test_if_stmt6 );
CPPUNIT_TEST_SUITE_END();
private:
@@ -107,11 +114,13 @@
MY_TEST_NODE_PRE( stmt1, "a := (2 + 2)\n" );
CPPUNIT_ASSERT( node->statement != NULL );
CPPUNIT_ASSERT( node->local_decl == NULL );
+ CPPUNIT_ASSERT( node->if_stmt == NULL );
MY_TEST_NODE_POST();
MY_TEST_NODE_PRE( stmt2, "a[ 5 ] := (b^2) \n \n\n " );
CPPUNIT_ASSERT( node->statement != NULL );
CPPUNIT_ASSERT( node->local_decl == NULL );
+ CPPUNIT_ASSERT( node->if_stmt == NULL );
MY_TEST_NODE_POST();
MY_TEST_NODE_FAIL( stmt3, "x = \n y \n" );
@@ -121,11 +130,13 @@
MY_TEST_NODE_PRE( decl1, "int foo\n" );
CPPUNIT_ASSERT( node->local_decl != NULL );
CPPUNIT_ASSERT( node->statement == NULL );
+ CPPUNIT_ASSERT( node->if_stmt == NULL );
MY_TEST_NODE_POST();
MY_TEST_NODE_PRE( decl2, "int< 1 >\t\tbar\n " );
CPPUNIT_ASSERT( node->local_decl != NULL );
CPPUNIT_ASSERT( node->statement == NULL );
+ CPPUNIT_ASSERT( node->if_stmt == NULL );
MY_TEST_NODE_POST();
MY_TEST_NODE_FAIL( decl3, "intbar\n" );
@@ -133,6 +144,23 @@
MY_TEST_NODE_FAIL( decl5, "int< 1 > \n bar\n" );
MY_TEST_NODE_FAIL( decl6, "int< 1 > bar" );
+ MY_TEST_NODE_PRE( if_stmt1, "if foo then x = y\n" );
+ CPPUNIT_ASSERT( node->if_stmt != NULL );
+ CPPUNIT_ASSERT( node->statement == NULL );
+ CPPUNIT_ASSERT( node->local_decl == NULL );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( if_stmt2, "if\t(x + 1)\t\t \tthen\t y <<= 42 \n \n\n " );
+ CPPUNIT_ASSERT( node->if_stmt != NULL );
+ CPPUNIT_ASSERT( node->statement == NULL );
+ CPPUNIT_ASSERT( node->local_decl == NULL );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_FAIL( if_stmt3, "if then\n" );
+ MY_TEST_NODE_FAIL( if_stmt4, "if\nx then y = x\n" );
+ MY_TEST_NODE_FAIL( if_stmt5, "if x \n then y = x\n" );
+ MY_TEST_NODE_FAIL( if_stmt6, "if x then \n y = x \n" );
+
};
CPPUNIT_TEST_SUITE_REGISTRATION( blockEntryNodeTest );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-08-14 08:56:43
|
Revision: 134
http://inc.svn.sourceforge.net/inc/?rev=134&view=rev
Author: chandlerc
Date: 2007-08-14 01:56:45 -0700 (Tue, 14 Aug 2007)
Log Message:
-----------
Added if statement nodes.
Modified Paths:
--------------
parser/trunk/Makefile.am
parser/trunk/include/node_decls.hpp
Added Paths:
-----------
parser/trunk/include/if_statement_node.hpp
parser/trunk/src/if_statement_node.cpp
parser/trunk/test/if_statement_node_test.cpp
Modified: parser/trunk/Makefile.am
===================================================================
--- parser/trunk/Makefile.am 2007-08-13 07:29:48 UTC (rev 133)
+++ parser/trunk/Makefile.am 2007-08-14 08:56:45 UTC (rev 134)
@@ -8,6 +8,7 @@
lib_libparser_la_SOURCES = \
src/block_node.cpp \
src/block_entry_node.cpp \
+ src/if_statement_node.cpp \
src/local_decl_node.cpp \
src/variable_decl_node.cpp \
src/type_node.cpp \
@@ -39,6 +40,7 @@
pkginclude_HEADERS = \
include/block_node.hpp \
include/block_entry_node.hpp \
+ include/if_statement_node.hpp \
include/variable_decl_node.hpp \
include/type_node.hpp \
include/vector_type_node.hpp \
@@ -84,6 +86,7 @@
test_runner_SOURCES = \
test/block_node_test.cpp \
test/block_entry_node_test.cpp \
+ test/if_statement_node_test.cpp \
test/variable_decl_node_test.cpp \
test/type_node_test.cpp \
test/vector_type_node_test.cpp \
Added: parser/trunk/include/if_statement_node.hpp
===================================================================
--- parser/trunk/include/if_statement_node.hpp (rev 0)
+++ parser/trunk/include/if_statement_node.hpp 2007-08-14 08:56:45 UTC (rev 134)
@@ -0,0 +1,101 @@
+////
+//
+/// \file ./include/if_statement_node.hpp
+//
+// Copyright 2007 Chandler Carruth
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////
+
+#ifndef _parser_if_statement_node_header_
+#define _parser_if_statement_node_header_
+
+// system includes
+#include <inttypes.h>
+
+// includes
+#include <node_decls.hpp>
+
+#include <ws_parser.hpp>
+#include <parse_tree_node.hpp>
+
+
+
+///
+/// \brief If-Statement parse node
+/// \author Chandler Carruth
+/// \date 2007.07.28
+///
+/// This is the parse node for a conditionally guarded statement, or an "if,
+/// then" statement. This is *not* to be confused with more traditional usage
+/// of the term "if statement" to refer to the C/C++ "if" statement which
+/// often begins a block of conditionally guarded code, rather than a single
+/// statement. This is precisely a single guarded statement. No other flow
+/// control constructs can appear within the statement, no nesting of flow can
+/// be achieved. There is a hard and clear syntactical and semantic
+/// distinction between a single guarded statement and a conditionally entered
+/// block. This also provides an convenient mechanism to express conditional
+/// stores and the like with a more "structured" feel.
+///
+
+class ifStatementNode : private wsParser, public parseTreeNode
+{
+public:
+
+ /// \name Required Contained Nodes
+ //@{
+
+ expressionNode* expr;
+ statementNode* stmt;
+
+ //@}
+
+ /// \name Instance Creation and Destruction
+ //@{
+
+ virtual bool create(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end,
+ parseTreeNode* parent = NULL,
+ parseTreeNode* next = NULL
+ );
+ virtual bool destroy( void );
+
+ //@}
+
+protected:
+
+ /// \name Initialization Routines
+ //@{
+
+ bool init(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end
+ );
+ bool deinit( void );
+
+ //@}
+
+private:
+
+};
+
+
+#endif // _parser_if_statement_node_header_
+
+
Modified: parser/trunk/include/node_decls.hpp
===================================================================
--- parser/trunk/include/node_decls.hpp 2007-08-13 07:29:48 UTC (rev 133)
+++ parser/trunk/include/node_decls.hpp 2007-08-14 08:56:45 UTC (rev 134)
@@ -59,6 +59,7 @@
class localDeclNode;
class blockEntryNode;
class blockNode;
+class ifStatementNode;
#endif // _node_decls_header_
Added: parser/trunk/src/if_statement_node.cpp
===================================================================
--- parser/trunk/src/if_statement_node.cpp (rev 0)
+++ parser/trunk/src/if_statement_node.cpp 2007-08-14 08:56:45 UTC (rev 134)
@@ -0,0 +1,232 @@
+////
+//
+/// \file ./src/if_statement_node.cpp
+//
+// Copyright 2007 Chandler Carruth
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////
+
+// System Headers
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+// Library Headers
+
+// Project Headers
+#include <if_statement_node.hpp>
+
+#include <parse_tree_node.hpp>
+#include <expression_node.hpp>
+#include <statement_node.hpp>
+
+
+///
+/// \brief Create an if-statement parse node
+/// \author Chandler Carruth
+/// \date 2007.07.28
+///
+/// This creates an instance of an if-then conditionally guarded statement
+/// parse node.
+///
+/// \param[in] text The text body we're parsing
+/// \param[in] length The length of the text body
+/// \param[in] begin The beginning point for this parse
+/// \param[out] end The end of what we could parse
+///
+
+bool
+ifStatementNode::create(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end,
+ parseTreeNode* parent,
+ parseTreeNode* next
+)
+{
+ if( this->parseTreeNode::init( parent, next ) )
+ {
+ if( this->ifStatementNode::init( text, length, begin, end ) )
+ {
+ return( true );
+ }
+
+ // back out everything we've done so far
+ this->parseTreeNode::deinit();
+ }
+
+ return( false );
+}
+
+
+///
+/// \brief Destroy an instance
+/// \author Chandler Carruth
+/// \date 2007.07.28
+///
+/// This will destroy an instance object.
+///
+
+bool
+ifStatementNode::destroy( void )
+{
+ bool ret = true;
+
+ if( !this->ifStatementNode::deinit() )
+ {
+ ret = false;
+ }
+
+ if( !this->parseTreeNode::deinit() )
+ {
+ ret = false;
+ }
+
+ return( ret );
+}
+
+
+///
+/// \brief Initialize the object
+/// \author Chandler Carruth
+/// \date 2007.07.28
+///
+/// This builds an instance of an if-guarded statement parse node. It parses
+/// delimiting "if", "then", and newline tokens to mark the structure of the
+/// if conditional, and also hands off parsing of the conditional expression
+/// and the conditionally guarded statement
+///
+/// \param[in] text The text body we're parsing
+/// \param[in] length The length of the text body
+/// \param[in] begin The beginning point for this parse
+/// \param[out] end The end of what we could parse
+///
+
+bool
+ifStatementNode::init(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end
+)
+{
+ // parse the opening token
+ if( memcmp( &( text[ begin ] ), "if", 2 ) == 0 )
+ {
+ begin += 2;
+
+ // require some whitespace, and eat up as much as we find
+ if( this->parse_ws( text, length, begin, end ) )
+ {
+ begin = end;
+
+ // parse the conditional expression
+ this->expr = new expressionNode;
+ if( this->expr->create( text, length, begin, end, this ) )
+ {
+ begin = end;
+
+ // require some more whitespace, eating up what we find
+ if( this->parse_ws( text, length, begin, end ) )
+ {
+ begin = end;
+
+ // parse the intermediary token
+ if( memcmp( &( text[ begin ] ), "then", 4 ) == 0 )
+ {
+ begin += 4;
+
+ // whitespace, ibid
+ if( this->parse_ws( text, length, begin, end ) )
+ {
+ begin = end;
+
+ // parse out the statement finally
+ this->stmt = new statementNode;
+ if( this->stmt->create( text, length, begin, end, this ) )
+ {
+ // success!
+ return( true );
+ }
+
+ // FAIL from here!
+
+ delete this->stmt;
+ this->stmt = NULL;
+ }
+ }
+ }
+
+ this->expr->destroy();
+ }
+
+ delete this->expr;
+ this->expr = NULL;
+ }
+ }
+
+ // we found no valid parsing for this node.
+ return( false );
+}
+
+
+///
+/// \brief Deinitialize the object
+/// \author Chandler Carruth
+/// \date 2007.07.26
+///
+/// This method deinitializes the instances data, etc.
+///
+
+bool
+ifStatementNode::deinit( void )
+{
+ bool ret = true;
+
+ // check for a expression
+ if( this->expr != NULL )
+ {
+ // try and destroy it
+ if( !this->expr->destroy() )
+ {
+ ret = false;
+ }
+
+ // clean up the memory
+ delete this->expr;
+ this->expr = NULL;
+ }
+
+ // check for a statement
+ if( this->stmt != NULL )
+ {
+ // try and destroy it
+ if( !this->stmt->destroy() )
+ {
+ ret = false;
+ }
+
+ // clean up the memory
+ delete this->stmt;
+ this->stmt = NULL;
+ }
+
+ return( ret );
+}
+
+
+
+
Added: parser/trunk/test/if_statement_node_test.cpp
===================================================================
--- parser/trunk/test/if_statement_node_test.cpp (rev 0)
+++ parser/trunk/test/if_statement_node_test.cpp 2007-08-14 08:56:45 UTC (rev 134)
@@ -0,0 +1,125 @@
+////
+//
+/// \file ./test/if_statement_node_test.cpp
+//
+// Copyright 2007 Chandler Carruth
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////
+
+// System Headers
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+// Library Headers
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+// Project Headers
+#include <if_statement_node.hpp>
+
+#include <statement_node.hpp>
+#include <expression_node.hpp>
+
+
+
+class ifStatementNodeTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( ifStatementNodeTest );
+ CPPUNIT_TEST( test_empty );
+ CPPUNIT_TEST( test_1 );
+ CPPUNIT_TEST( test_2 );
+ CPPUNIT_TEST( test_3 );
+ CPPUNIT_TEST( test_4 );
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ ifStatementNode* node;
+ unsigned int end;
+
+public:
+ void
+ setUp( void )
+ {
+ end = 0;
+ node = new ifStatementNode;
+ CPPUNIT_ASSERT( node != NULL );
+ };
+
+ void
+ tearDown( void )
+ {
+ delete node;
+ node = NULL;
+ end = 0;
+ };
+
+#define MY_TEST_NODE_PRE(name,val) \
+ void \
+ test_##name( void ) \
+ { \
+ const char* s = val; \
+ CPPUNIT_ASSERT( node->create( s, strlen( s ), 0, end ) ); \
+ CPPUNIT_ASSERT_EQUAL( (unsigned int)( strlen( s ) ), end )
+
+#define MY_TEST_NODE_POST() \
+ CPPUNIT_ASSERT( node->destroy() ); \
+ }
+
+#define MY_TEST_NODE_SIMPLE(name,val) \
+ MY_TEST_NODE_PRE(name,val,start,end); \
+ MY_TEST_NODE_POST()
+
+#define MY_TEST_NODE_FAIL_PRE(name,val) \
+ void \
+ test_##name( void ) \
+ { \
+ const char* s = val; \
+ CPPUNIT_ASSERT( !node->create( s, strlen( s ), 0, end ) )
+
+#define MY_TEST_NODE_FAIL_POST() \
+ }
+
+#define MY_TEST_NODE_FAIL(name,val) \
+ MY_TEST_NODE_FAIL_PRE(name,val); \
+ MY_TEST_NODE_FAIL_POST()
+
+ MY_TEST_NODE_FAIL( empty, "" );
+
+ MY_TEST_NODE_PRE( 1, "if x then y = x\n" );
+ CPPUNIT_ASSERT( node->expr != NULL );
+ CPPUNIT_ASSERT( node->stmt != NULL );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( 2, "if (x != y) then y = x\n" );
+ CPPUNIT_ASSERT( node->expr != NULL );
+ CPPUNIT_ASSERT( node->stmt != NULL );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( 3, "if (x != 42) then x = the_answer( 42 )\n" );
+ CPPUNIT_ASSERT( node->expr != NULL );
+ CPPUNIT_ASSERT( node->stmt != NULL );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( 4, "if ((x + 2) != ((a*4)+y)) then y = ((x*(x*(x+5))) + ((a^b)^c))\n" );
+ CPPUNIT_ASSERT( node->expr != NULL );
+ CPPUNIT_ASSERT( node->stmt != NULL );
+ MY_TEST_NODE_POST();
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( ifStatementNodeTest );
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-08-13 07:29:47
|
Revision: 133
http://inc.svn.sourceforge.net/inc/?rev=133&view=rev
Author: chandlerc
Date: 2007-08-13 00:29:48 -0700 (Mon, 13 Aug 2007)
Log Message:
-----------
Added the real deal, block nodes. The grammar should now be pseudo useful, as
it has some subset of the entire block level syntax. Next biggie is flow
control. After basics of flow control are in, I can start marching up the tree
again, and get it closer to being a sufficient grammar to recognize a complete
object definition.
Modified Paths:
--------------
parser/trunk/Makefile.am
parser/trunk/include/node_decls.hpp
Added Paths:
-----------
parser/trunk/include/block_node.hpp
parser/trunk/src/block_node.cpp
parser/trunk/test/block_node_test.cpp
Modified: parser/trunk/Makefile.am
===================================================================
--- parser/trunk/Makefile.am 2007-08-13 06:57:23 UTC (rev 132)
+++ parser/trunk/Makefile.am 2007-08-13 07:29:48 UTC (rev 133)
@@ -6,6 +6,7 @@
# libparser
lib_libparser_la_SOURCES = \
+ src/block_node.cpp \
src/block_entry_node.cpp \
src/local_decl_node.cpp \
src/variable_decl_node.cpp \
@@ -36,6 +37,7 @@
src/parse_tree_node.cpp
pkginclude_HEADERS = \
+ include/block_node.hpp \
include/block_entry_node.hpp \
include/variable_decl_node.hpp \
include/type_node.hpp \
@@ -80,6 +82,7 @@
test_libparser_test_la_LIBADD = $(lib_libparser_la_LIBADD)
test_runner_SOURCES = \
+ test/block_node_test.cpp \
test/block_entry_node_test.cpp \
test/variable_decl_node_test.cpp \
test/type_node_test.cpp \
Added: parser/trunk/include/block_node.hpp
===================================================================
--- parser/trunk/include/block_node.hpp (rev 0)
+++ parser/trunk/include/block_node.hpp 2007-08-13 07:29:48 UTC (rev 133)
@@ -0,0 +1,113 @@
+////
+//
+/// \file ./include/block_node.hpp
+//
+// Copyright 2007 Chandler Carruth
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////
+
+#ifndef _parser_block_node_header_
+#define _parser_block_node_header_
+
+// system includes
+#include <inttypes.h>
+
+// includes
+#include <node_decls.hpp>
+
+#include <ws_parser.hpp>
+#include <parse_tree_node.hpp>
+
+// std includes
+#include <list>
+
+
+
+///
+/// \brief Block parse node
+/// \author Chandler Carruth
+/// \date 2007.08.13
+///
+/// This is the parse node which manages code blocks. It is very dumb, and
+/// simply servers as a collection of block entries. Most of the interesting
+/// stuff happen in the individual block entries, and their various
+/// permutations.
+///
+
+class blockNode : private wsParser, public parseTreeNode
+{
+public:
+
+ /// \name Type Definitions
+ //@{
+
+ typedef std::list< blockEntryNode* > entry_list;
+ typedef entry_list::iterator entry_interator;
+ typedef entry_list::const_iterator entry_const_iterator;
+
+ //@}
+
+ /// \name Parameters
+ //@{
+
+ uint_fast32_t num_entries( void ) { return( entries.size() ); };
+
+ //@}
+
+ /// \name Required Contained Nodes
+ //@{
+
+ entry_list entries;
+
+ //@}
+
+ /// \name Instance Creation and Destruction
+ //@{
+
+ virtual bool create(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end,
+ parseTreeNode* parent = NULL,
+ parseTreeNode* next = NULL
+ );
+ virtual bool destroy( void );
+
+ //@}
+
+protected:
+
+ /// \name Initialization Routines
+ //@{
+
+ bool init(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end
+ );
+ bool deinit( void );
+
+ //@}
+
+private:
+
+};
+
+
+#endif // _parser_block_node_header_
+
+
Modified: parser/trunk/include/node_decls.hpp
===================================================================
--- parser/trunk/include/node_decls.hpp 2007-08-13 06:57:23 UTC (rev 132)
+++ parser/trunk/include/node_decls.hpp 2007-08-13 07:29:48 UTC (rev 133)
@@ -58,6 +58,7 @@
class variableDeclNode;
class localDeclNode;
class blockEntryNode;
+class blockNode;
#endif // _node_decls_header_
Added: parser/trunk/src/block_node.cpp
===================================================================
--- parser/trunk/src/block_node.cpp (rev 0)
+++ parser/trunk/src/block_node.cpp 2007-08-13 07:29:48 UTC (rev 133)
@@ -0,0 +1,213 @@
+////
+//
+/// \file ./src/block_node.cpp
+//
+// Copyright 2007 Chandler Carruth
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////
+
+// System Headers
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include <list>
+
+// Library Headers
+
+// Project Headers
+#include <block_node.hpp>
+
+#include <name_node.hpp>
+#include <block_entry_node.hpp>
+
+
+///
+/// \brief Create an instance of a block parse node
+/// \author Chandler Carruth
+/// \date 2007.08.13
+///
+/// This creates a block parse node instance, handing off the parsing to the
+/// initialization routine.
+///
+/// \param[in] text The text body we're parsing
+/// \param[in] length The length of the text body
+/// \param[in] begin The beginning point for this parse
+/// \param[out] end The end of what we could parse
+///
+
+bool
+blockNode::create(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end,
+ parseTreeNode* parent,
+ parseTreeNode* next
+)
+{
+ if( this->parseTreeNode::init( parent, next ) )
+ {
+ if( this->blockNode::init( text, length, begin, end ) )
+ {
+ return( true );
+ }
+
+ // back out everything we've done so far
+ this->parseTreeNode::deinit();
+ }
+
+ return( false );
+}
+
+
+///
+/// \brief Destroy an instance
+/// \author Chandler Carruth
+/// \date 2007.07.28
+///
+/// This will destroy an instance object.
+///
+
+bool
+blockNode::destroy( void )
+{
+ bool ret = true;
+
+ if( !this->blockNode::deinit() )
+ {
+ ret = false;
+ }
+
+ if( !this->parseTreeNode::deinit() )
+ {
+ ret = false;
+ }
+
+ return( ret );
+}
+
+
+///
+/// \brief Initialize the object
+/// \author Chandler Carruth
+/// \date 2007.07.28
+///
+/// This builds an instance of a block parse node by aggregating block
+/// entries. That's all it does.
+///
+/// \param[in] text The text body we're parsing
+/// \param[in] length The length of the text body
+/// \param[in] begin The beginning point for this parse
+/// \param[out] end The end of what we could parse
+///
+
+bool
+blockNode::init(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end
+)
+{
+ // begin loop to parse all entries in this block
+ while( true )
+ {
+ blockEntryNode* entry = NULL;
+
+ // skip any whitespace
+ if( this->parse_ws( text, length, begin, end ) )
+ {
+ begin = end;
+ }
+
+ // try to parse out an entry
+ entry = new blockEntryNode;
+ if( entry->create( text, length, begin, end, this ) )
+ {
+ begin = end;
+
+ this->entries.push_back( entry );
+ entry = NULL;
+
+ // skip over any further whitespace
+ if( this->parse_ws( text, length, begin, end ) )
+ {
+ begin = end;
+ }
+
+ // continue looking for block entries
+ continue;
+ }
+
+ // clean up the entry
+ delete entry;
+ entry = NULL;
+
+ // We failed to parse out another entry, consider the block finished.
+ break;
+ }
+
+
+ // This is a major problem. With the current INC grammar, there is no way
+ // for us to distinguish between a block entry parse which hit a bizarre
+ // syntax error, i.e. something that should _never_ happen in valid INC
+ // code, and simply an early ending to the block. We stop the block when we
+ // fail to parse out another entry, but there is no clear result returned
+ // to indicate the type of failure, whether it is a total impossibility for
+ // a legal INC text, or if it is simply not an entry.
+
+ return( true );
+}
+
+
+///
+/// \brief Deinitialize the object
+/// \author Chandler Carruth
+/// \date 2007.07.26
+///
+/// This method deinitializes the instances data, etc.
+///
+
+bool
+blockNode::deinit( void )
+{
+ bool ret = true;
+
+ // clean out any block entries
+ while( !this->entries.empty() )
+ {
+ if( this->entries.back() != NULL )
+ {
+ // try and destroy one
+ if( !this->entries.back()->destroy() )
+ {
+ ret = false;
+ }
+
+ // clean up the memory
+ delete this->entries.back();
+ }
+
+ // and pop one off the stack
+ this->entries.pop_back();
+ }
+
+ return( ret );
+}
+
+
+
+
Added: parser/trunk/test/block_node_test.cpp
===================================================================
--- parser/trunk/test/block_node_test.cpp (rev 0)
+++ parser/trunk/test/block_node_test.cpp 2007-08-13 07:29:48 UTC (rev 133)
@@ -0,0 +1,147 @@
+////
+//
+/// \file ./test/block_node_test.cpp
+//
+// Copyright 2007 Chandler Carruth
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////
+
+// System Headers
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+// Library Headers
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+// Project Headers
+#include <block_node.hpp>
+#include <block_entry_node.hpp>
+
+
+
+class blockNodeTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( blockNodeTest );
+ CPPUNIT_TEST( test_empty );
+ CPPUNIT_TEST( test_block1 );
+ CPPUNIT_TEST( test_block2 );
+ CPPUNIT_TEST( test_block3 );
+ CPPUNIT_TEST( test_block4 );
+ CPPUNIT_TEST( test_block5 );
+ CPPUNIT_TEST( test_block6 );
+ CPPUNIT_TEST( test_block7 );
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ blockNode* node;
+ unsigned int end;
+
+public:
+ void
+ setUp( void )
+ {
+ end = 0;
+ node = new blockNode;
+ CPPUNIT_ASSERT( node != NULL );
+ };
+
+ void
+ tearDown( void )
+ {
+ delete node;
+ node = NULL;
+ end = 0;
+ };
+
+#define MY_TEST_NODE_PRE(name,val) \
+ void \
+ test_##name( void ) \
+ { \
+ const char* s = val; \
+ CPPUNIT_ASSERT( node->create( s, strlen( s ), 0, end ) ); \
+
+#define MY_TEST_NODE_POST() \
+ CPPUNIT_ASSERT( node->destroy() ); \
+ }
+
+#define MY_TEST_NODE_SIMPLE(name,val) \
+ MY_TEST_NODE_PRE(name,val,start,end); \
+ MY_TEST_NODE_POST()
+
+#define MY_TEST_NODE_FAIL_PRE(name,val) \
+ void \
+ test_##name( void ) \
+ { \
+ const char* s = val; \
+ CPPUNIT_ASSERT( !node->create( s, strlen( s ), 0, end ) )
+
+#define MY_TEST_NODE_FAIL_POST() \
+ }
+
+#define MY_TEST_NODE_FAIL(name,val) \
+ MY_TEST_NODE_FAIL_PRE(name,val); \
+ MY_TEST_NODE_FAIL_POST()
+
+ MY_TEST_NODE_PRE( empty, "" );
+ CPPUNIT_ASSERT_EQUAL( 0ul, node->num_entries() );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( block1, "a := (2 + 2)\n" );
+ CPPUNIT_ASSERT_EQUAL( 1ul, node->num_entries() );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( block2, "a[ 5 ] := (b^2)\n"
+ "foo := bar\n"
+ "x := y \n" );
+ CPPUNIT_ASSERT_EQUAL( 3ul, node->num_entries() );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( block3, "a[ 5 ] := (b^2)\n"
+ "foo\n"
+ "x := y \n" );
+ CPPUNIT_ASSERT_EQUAL( 1ul, node->num_entries() );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( block4, "a 5 ] := (b^2)\n"
+ "foo := bar\n"
+ "x := y \n" );
+ CPPUNIT_ASSERT_EQUAL( 0ul, node->num_entries() );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( block5, "a[ 5 ] := (b^2)\n"
+ "foo := bar\n"
+ "x\n" );
+ CPPUNIT_ASSERT_EQUAL( 2ul, node->num_entries() );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( block6, "a[ 5 ] := (b^2)\n"
+ "int x\n"
+ "x := y \n" );
+ CPPUNIT_ASSERT_EQUAL( 3ul, node->num_entries() );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( block7, "a[ 5 ] := (b^2)\n"
+ "vector< 8 x int > m\n"
+ "x := y \n" );
+ CPPUNIT_ASSERT_EQUAL( 3ul, node->num_entries() );
+ MY_TEST_NODE_POST();
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( blockNodeTest );
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cha...@us...> - 2007-08-13 06:57:20
|
Revision: 132
http://inc.svn.sourceforge.net/inc/?rev=132&view=rev
Author: chandlerc
Date: 2007-08-12 23:57:23 -0700 (Sun, 12 Aug 2007)
Log Message:
-----------
Added block entry node. This is the last step before adding the first (dumb)
incarnation of the block node!
Modified Paths:
--------------
parser/trunk/Makefile.am
parser/trunk/include/node_decls.hpp
Added Paths:
-----------
parser/trunk/include/block_entry_node.hpp
parser/trunk/src/block_entry_node.cpp
parser/trunk/test/block_entry_node_test.cpp
Modified: parser/trunk/Makefile.am
===================================================================
--- parser/trunk/Makefile.am 2007-08-13 06:12:16 UTC (rev 131)
+++ parser/trunk/Makefile.am 2007-08-13 06:57:23 UTC (rev 132)
@@ -6,6 +6,7 @@
# libparser
lib_libparser_la_SOURCES = \
+ src/block_entry_node.cpp \
src/local_decl_node.cpp \
src/variable_decl_node.cpp \
src/type_node.cpp \
@@ -35,7 +36,7 @@
src/parse_tree_node.cpp
pkginclude_HEADERS = \
- include/local_decl_node.hpp \
+ include/block_entry_node.hpp \
include/variable_decl_node.hpp \
include/type_node.hpp \
include/vector_type_node.hpp \
@@ -79,7 +80,7 @@
test_libparser_test_la_LIBADD = $(lib_libparser_la_LIBADD)
test_runner_SOURCES = \
- test/local_decl_node_test.cpp \
+ test/block_entry_node_test.cpp \
test/variable_decl_node_test.cpp \
test/type_node_test.cpp \
test/vector_type_node_test.cpp \
Added: parser/trunk/include/block_entry_node.hpp
===================================================================
--- parser/trunk/include/block_entry_node.hpp (rev 0)
+++ parser/trunk/include/block_entry_node.hpp 2007-08-13 06:57:23 UTC (rev 132)
@@ -0,0 +1,94 @@
+////
+//
+/// \file ./include/block_entry_node.hpp
+//
+// Copyright 2007 Chandler Carruth
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////
+
+#ifndef _parser_block_entry_node_header_
+#define _parser_block_entry_node_header_
+
+// includes
+#include <parse_tree_node.hpp>
+
+#include <node_decls.hpp>
+
+///
+/// \brief Block entry parse node
+/// \author Chandler Carruth
+/// \date 2007.08.12
+///
+/// This is the block entry parse node. Conventional terminology often refers
+/// to this as a "statement" however, that is reserved for a different
+/// component of the INC grammar. The concept is that "statement"s are
+/// actions, or changes in the state of the program. The block level can hold
+/// many syntactic constructs that do not fit that definition. Among these are
+/// flow control, and variable declarations. Loop actions, which are to an
+/// extent a component of flow control, are modeled as statements as they
+/// change the state of flow control constructs rather than changing flow
+/// control themselves.
+///
+
+class blockEntryNode : public parseTreeNode
+{
+public:
+
+ /// \name Contained Node Choices
+ //@{
+
+ statementNode* statement;
+ localDeclNode* local_decl;
+
+ //@}
+
+ /// \name Instance Creation and Destruction
+ //@{
+
+ virtual bool create(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end,
+ parseTreeNode* parent = NULL,
+ parseTreeNode* next = NULL
+ );
+ virtual bool destroy( void );
+
+ //@}
+
+protected:
+
+ /// \name Initialization Routines
+ //@{
+
+ bool init(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end
+ );
+ bool deinit( void );
+
+ //@}
+
+private:
+
+};
+
+
+#endif // _parser_block_entry_node_header_
+
+
Modified: parser/trunk/include/node_decls.hpp
===================================================================
--- parser/trunk/include/node_decls.hpp 2007-08-13 06:12:16 UTC (rev 131)
+++ parser/trunk/include/node_decls.hpp 2007-08-13 06:57:23 UTC (rev 132)
@@ -57,6 +57,7 @@
class typeNode;
class variableDeclNode;
class localDeclNode;
+class blockEntryNode;
#endif // _node_decls_header_
Added: parser/trunk/src/block_entry_node.cpp
===================================================================
--- parser/trunk/src/block_entry_node.cpp (rev 0)
+++ parser/trunk/src/block_entry_node.cpp 2007-08-13 06:57:23 UTC (rev 132)
@@ -0,0 +1,196 @@
+////
+//
+/// \file ./src/block_entry_node.cpp
+//
+// Copyright 2007 Chandler Carruth
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////
+
+// System Headers
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+// Library Headers
+
+// Project Headers
+#include <block_entry_node.hpp>
+
+#include <parse_tree_node.hpp>
+#include <statement_node.hpp>
+#include <local_decl_node.hpp>
+
+
+///
+/// \brief Create a block entry parse node instance
+/// \author Chandler Carruth
+/// \date 2007.06.19
+///
+/// This creates a block entry parse node instance, passing the provided text
+/// down to be parsed.
+///
+/// \param[in] text The text body we're parsing
+/// \param[in] length The length of the text body
+/// \param[in] begin The beginning point for this parse
+/// \param[out] end The end of what we could parse
+///
+
+bool
+blockEntryNode::create(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end,
+ parseTreeNode* parent,
+ parseTreeNode* next
+)
+{
+ if( this->parseTreeNode::init( parent, next ) )
+ {
+ if( this->blockEntryNode::init( text, length, begin, end ) )
+ {
+ return( true );
+ }
+
+ // back out everything we've done so far
+ this->parseTreeNode::deinit();
+ }
+
+ return( false );
+}
+
+
+///
+/// \brief Destroy a parse node instance
+/// \author Chandler Carruth
+/// \date 2007.08.09
+///
+/// This will destroy an object instance.
+///
+
+bool
+blockEntryNode::destroy( void )
+{
+ bool ret = true;
+
+ if( !this->blockEntryNode::deinit() )
+ {
+ ret = false;
+ }
+
+ if( !this->parseTreeNode::deinit() )
+ {
+ ret = false;
+ }
+
+ return( ret );
+}
+
+
+///
+/// \brief Initialize the instance by parsing the text
+/// \author Chandler Carruth
+/// \date 2007.08.09
+///
+/// This builds an instance of a block entry node.
+///
+/// \param[in] text The text body we're parsing
+/// \param[in] length The length of the text body
+/// \param[in] begin The beginning point for this parse
+/// \param[out] end The end of what we could parse
+///
+
+bool
+blockEntryNode::init(
+ const char* text,
+ unsigned int length,
+ unsigned int begin,
+ unsigned int& end
+)
+{
+ // we try the local declaration parser first
+ this->local_decl = new localDeclNode;
+ if( this->local_decl->create( text, length, begin, end, this ) )
+ {
+ // success
+ this->statement = NULL;
+ return( true );
+ }
+
+ // cleanup local_decl
+ delete this->local_decl;
+
+ // mark it as unused.
+ this->local_decl = NULL;
+
+ // now try the vector parser
+ this->statement = new statementNode;
+ if( this->statement->create( text, length, begin, end, this ) )
+ {
+ // success
+ return( true );
+ }
+
+ // clean up statement
+ delete this->statement;
+
+ // mark it as unused
+ this->statement = NULL;
+
+ return( false );
+}
+
+///
+/// \brief Deinitialize the object
+/// \author Chandler Carruth
+/// \date 2007.06.19
+///
+/// This method deinitializes the instance, freeing any internal data
+/// structures.
+///
+
+bool
+blockEntryNode::deinit( void )
+{
+ bool ret = true;
+
+ if( this->local_decl != NULL )
+ {
+ if( !this->local_decl->destroy() )
+ {
+ ret = false;
+ }
+
+ delete this->local_decl;
+ this->local_decl = NULL;
+ }
+
+ if( this->statement != NULL )
+ {
+ if( !this->statement->destroy() )
+ {
+ ret = false;
+ }
+
+ delete this->statement;
+ this->statement = NULL;
+ }
+
+ return( ret );
+}
+
+
+
+
Added: parser/trunk/test/block_entry_node_test.cpp
===================================================================
--- parser/trunk/test/block_entry_node_test.cpp (rev 0)
+++ parser/trunk/test/block_entry_node_test.cpp 2007-08-13 06:57:23 UTC (rev 132)
@@ -0,0 +1,140 @@
+////
+//
+/// \file ./test/block_entry_node_test.cpp
+//
+// Copyright 2007 Chandler Carruth
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////
+
+// System Headers
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+// Library Headers
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+// Project Headers
+#include <block_entry_node.hpp>
+#include <statement_node.hpp>
+#include <local_decl_node.hpp>
+
+
+
+class blockEntryNodeTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( blockEntryNodeTest );
+ CPPUNIT_TEST( test_empty );
+ CPPUNIT_TEST( test_stmt1 );
+ CPPUNIT_TEST( test_stmt2 );
+ CPPUNIT_TEST( test_stmt3 );
+ CPPUNIT_TEST( test_stmt4 );
+ CPPUNIT_TEST( test_stmt5 );
+ CPPUNIT_TEST( test_decl1 );
+ CPPUNIT_TEST( test_decl2 );
+ CPPUNIT_TEST( test_decl3 );
+ CPPUNIT_TEST( test_decl4 );
+ CPPUNIT_TEST( test_decl5 );
+ CPPUNIT_TEST( test_decl6 );
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ blockEntryNode* node;
+ unsigned int end;
+
+public:
+ void
+ setUp( void )
+ {
+ end = 0;
+ node = new blockEntryNode;
+ CPPUNIT_ASSERT( node != NULL );
+ };
+
+ void
+ tearDown( void )
+ {
+ delete node;
+ node = NULL;
+ end = 0;
+ };
+
+#define MY_TEST_NODE_PRE(name,val) \
+ void \
+ test_##name( void ) \
+ { \
+ const char* s = val; \
+ CPPUNIT_ASSERT( node->create( s, strlen( s ), 0, end ) ); \
+ CPPUNIT_ASSERT_EQUAL( (unsigned int)( strlen( s ) ), end )
+
+#define MY_TEST_NODE_POST() \
+ CPPUNIT_ASSERT( node->destroy() ); \
+ }
+
+#define MY_TEST_NODE_SIMPLE(name,val) \
+ MY_TEST_NODE_PRE(name,val,start,end); \
+ MY_TEST_NODE_POST()
+
+#define MY_TEST_NODE_FAIL_PRE(name,val) \
+ void \
+ test_##name( void ) \
+ { \
+ const char* s = val; \
+ CPPUNIT_ASSERT( !node->create( s, strlen( s ), 0, end ) )
+
+#define MY_TEST_NODE_FAIL_POST() \
+ }
+
+#define MY_TEST_NODE_FAIL(name,val) \
+ MY_TEST_NODE_FAIL_PRE(name,val); \
+ MY_TEST_NODE_FAIL_POST()
+
+ MY_TEST_NODE_FAIL( empty, "" );
+
+ MY_TEST_NODE_PRE( stmt1, "a := (2 + 2)\n" );
+ CPPUNIT_ASSERT( node->statement != NULL );
+ CPPUNIT_ASSERT( node->local_decl == NULL );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( stmt2, "a[ 5 ] := (b^2) \n \n\n " );
+ CPPUNIT_ASSERT( node->statement != NULL );
+ CPPUNIT_ASSERT( node->local_decl == NULL );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_FAIL( stmt3, "x = \n y \n" );
+ MY_TEST_NODE_FAIL( stmt4, "x = \n y" );
+ MY_TEST_NODE_FAIL( stmt5, "\nx = y\n" );
+
+ MY_TEST_NODE_PRE( decl1, "int foo\n" );
+ CPPUNIT_ASSERT( node->local_decl != NULL );
+ CPPUNIT_ASSERT( node->statement == NULL );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_PRE( decl2, "int< 1 >\t\tbar\n " );
+ CPPUNIT_ASSERT( node->local_decl != NULL );
+ CPPUNIT_ASSERT( node->statement == NULL );
+ MY_TEST_NODE_POST();
+
+ MY_TEST_NODE_FAIL( decl3, "intbar\n" );
+ MY_TEST_NODE_FAIL( decl4, "int< 1 >bar\n" );
+ MY_TEST_NODE_FAIL( decl5, "int< 1 > \n bar\n" );
+ MY_TEST_NODE_FAIL( decl6, "int< 1 > bar" );
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( blockEntryNodeTest );
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|