Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Output peg header comments to go file #150

Merged
merged 2 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions grammars/c/c.peg
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
# A.2.4 External definitions
#-------------------------------------------------------------------------

#go:build grammars
# +build grammars

package main

type C Peg {
Expand Down
3 changes: 3 additions & 0 deletions grammars/calculator/calculator.peg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

#go:build grammars
# +build grammars

package main

type Calculator Peg {
Expand Down
3 changes: 3 additions & 0 deletions grammars/calculator_ast/calculator.peg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

#go:build grammars
# +build grammars

package main

type Calculator Peg {
Expand Down
5 changes: 5 additions & 0 deletions grammars/fexl/fexl.peg
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# fexl

#go:build grammars
# +build grammars

package main

type Fexl Peg {
Expand Down
3 changes: 3 additions & 0 deletions grammars/java/java_1_7.peg
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
# Compilation Unit
#-------------------------------------------------------------------------

#go:build grammars
# +build grammars

package main

type Java Peg {
Expand Down
3 changes: 3 additions & 0 deletions grammars/long_test/long.peg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

#go:build grammars
# +build grammars

package main

type Long Peg {
Expand Down
5 changes: 4 additions & 1 deletion peg.peg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Peg Peg {
}

# Hierarchical syntax
Grammar <- Spacing 'package' MustSpacing Identifier { p.AddPackage(text) }
Grammar <- Header 'package' MustSpacing Identifier { p.AddPackage(text) }
Import*
'type' MustSpacing Identifier { p.AddPeg(text) }
'Peg' Spacing Action { p.AddState(text) }
Expand Down Expand Up @@ -118,6 +118,9 @@ Spacing <- SpaceComment*
MustSpacing <- SpaceComment+
Comment <- ('#' / '//') (!EndOfLine .)* EndOfLine
Space <- ' ' / '\t' / EndOfLine
Header <- HeaderSpaceComment*
HeaderSpaceComment <- (HeaderComment / <Space+> { p.AddSpace(text) } )
HeaderComment <- ('#' / '//') <(!EndOfLine .)*> { p.AddComment(text) } EndOfLine
EndOfLine <- '\r\n' / '\n' / '\r'
EndOfFile <- !.
Action <- '{' < ActionBody* > '}' Spacing
Expand Down
Loading