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

tools: implement an -s option for v ast, to skip all nodes with default values like [], {}, 0, false; with it v ast -pts examples/hello_world.v | wc -l is 36 lines #23658

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

spytheman
Copy link
Member

@spytheman spytheman commented Feb 5, 2025

The output with the new -s option is a lot more terse, which can help with early diagnostics of parser problems.

#0 15:47:39 ^ master ~/code/v>./v ast -p examples/hello_world.v |wc
    180     335    3282
#0 15:48:28 ^ master ~/code/v>./v ast -pt examples/hello_world.v |wc
     75     141    1555
#0 15:48:29 ^ master ~/code/v>./v ast -pts examples/hello_world.v |wc
     36      64     643
#0 15:48:31 ^ master ~/code/v>

Output for a simple program:

#0 15:55:34 ^ master ~/code/v>v ast -pts examples/hello_world.v | wc -l
36
#0 15:55:35 ^ master ~/code/v>v ast -pts examples/hello_world.v
{
	"ast_type":	"ast.File",
	"path":	"/home/delian/code/v/examples/hello_world.v",
	"nr_lines":	1,
	"nr_bytes":	25,
	"mod":	{
		"ast_type":	"Module",
		"name":	"main",
		"is_skipped":	true
	},
	"stmts":	[{
			"ast_type":	"Module",
			"name":	"main",
			"is_skipped":	true
		}, {
			"ast_type":	"ExprStmt",
			"expr":	{
				"ast_type":	"CallExpr",
				"mod":	"main",
				"name":	"println",
				"left":	{
					"ast_type":	"NodeError"
				},
				"args":	[{
						"ast_type":	"CallArg",
						"expr":	{
							"ast_type":	"StringLiteral",
							"val":	"Hello, World!"
						}
					}],
				"or_block":	{
					"ast_type":	"OrExpr"
				}
			}
		}]
}
#0 15:55:38 ^ master ~/code/v>

…ault values like [], {}, 0, false; with it `v ast -pts examples/hello_world.v | wc -l` is 36 lines
@spytheman spytheman merged commit 94a97f6 into vlang:master Feb 5, 2025
51 of 62 checks passed
Copy link

Connected to Huly®: V_0.6-22078

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant